@aibee/crc-bmap 0.0.90 → 0.0.91

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.min.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var ye=Object.defineProperty,xe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var Rt=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable;var L=Math.pow,Dt=(n,r,t)=>r in n?ye(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,M=(n,r)=>{for(var t in r||(r={}))Ee.call(r,t)&&Dt(n,t,r[t]);if(Rt)for(var t of Rt(r))we.call(r,t)&&Dt(n,t,r[t]);return n},tt=(n,r)=>xe(n,be(r));var g=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(r,t)=>(typeof require!="undefined"?require:r)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var s=(n,r,t)=>(Dt(n,typeof r!="symbol"?r+"":r,t),t);var z=(n,r,t)=>new Promise((e,i)=>{var o=h=>{try{c(t.next(h))}catch(l){i(l)}},a=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(o,a);c((t=t.apply(n,r)).next())});var me=g("three");var _=class{constructor(){s(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(r){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),r()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(r){this.tasks.requestAnimation.delete(r),window.cancelAnimationFrame(r)}setTimeout(r,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),r()},t);return this.tasks.timeout.add(e),e}clearTimeout(r){this.tasks.timeout.delete(r),window.clearTimeout(r)}setInterval(r,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),r()},t);return this.tasks.interval.add(e),e}clearInterval(r){this.tasks.interval.delete(r),window.clearInterval(r)}dispose(){this.tasks.requestAnimation.forEach(r=>{window.cancelAnimationFrame(r)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(r=>{window.clearTimeout(r)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(r=>{window.clearInterval(r)}),this.tasks.interval.clear()}};var w=g("three"),Ht=g("three/examples/jsm/controls/MapControls");function _t(){let n=new w.Scene;return n.background=new w.Color(16777215),n}function Vt(){let n=new w.WebGLRenderer({antialias:!0});return n.autoClear=!0,n.setClearAlpha(1),n.setClearColor(16777215),n.setPixelRatio(window.devicePixelRatio),n.shadowMap.enabled=!0,n.shadowMap.autoUpdate=!0,n.shadowMap.type=w.PCFSoftShadowMap,n}function $t(n,r){let t=new w.OrthographicCamera(-n/2,n/2,r/2,-r/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function It(){let n=new w.Group,r=new w.AmbientLight(16777215,2.6);return n.add(r),n}function Ut(n,r){let t=new Ht.MapControls(n,r);return t.enableDamping=!1,t.zoomSpeed=2,t}function Kt(n,r=[]){let t=new w.Shape(n.map(e=>new w.Vector2(...e)));return r.length&&r.forEach(e=>{var i=new w.Path(e.map(o=>new w.Vector2(...o)));t.holes.push(i)}),t}function jt(n=16777215,r=1){let t=new w.DirectionalLight(n,r);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function H(n,r){var t;if(r&&n.children&&n.children.length&&n.children.forEach(e=>{H(e,r)}),n.isMesh){let e=n;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}n.isLight&&((t=n.dispose)==null||t.call(n))}function Zt(n){return/[\u4E00-\u9FA5]+/g.test(n)}var I=g("three");var et=new Map;function Pe(){let n=document.createElement("canvas");n.width=1024,n.height=64;let r=n.getContext("2d",{willReadFrequently:!0});return r.font="54px sans-serif",r.textBaseline="hanging",r.lineWidth=12,r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="white",{canvas:n,ctx:r}}var Ot,$;function Me(){if(!Ot){let{canvas:n,ctx:r}=Pe();Ot=n,$=r}}function Ve(n){if(et.has(n))return et.get(n);Me(),$.clearRect(0,0,1024,64);let r=Zt(n)?4:8;$.strokeText(n,2,r),$.fillText(n,2,r);let t=Math.ceil($.measureText(n).width);t=t%2===0?t:t+1,t+=2;let e=$.getImageData(0,0,t,64),i=new I.DataTexture(Uint8Array.from(e.data),t,64,I.RGBAFormat);return i.flipY=!0,i.minFilter=I.LinearFilter,i.magFilter=I.LinearFilter,et.set(n,i),i}function Xt(){et.clear()}function Wt(){$=null,Ot=null}var it=g("three"),W=g("@turf/turf");function b(n,r,t,e){let i=n.clone().project(r),o=t/2,a=e/2,c=Math.round(i.x*o+o),h=Math.round(-i.y*a+a);return{x:c,y:h}}function zt(n){let r=(0,W.featureCollection)(n.map(e=>(0,W.point)(e)));return(0,W.center)(r).geometry.coordinates}function ot(n,r,t){return n.x>=r.x&&n.x<=t.x&&n.y>=r.y&&n.y<=t.y}function Ue(n){let r=0,t=new it.Vector3;for(let e=1;e<n.length;e++){let i=new it.Vector3(n[e-1][0],n[e-1][1],0),o=new it.Vector3(n[e][0],n[e][1],0),a=o.distanceTo(i);a>r&&(r=a,t=o.clone().sub(i).normalize())}return t}function nt(n,r){return new Proxy(n,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,o)=>{let a=Reflect.get(t,e,o),c=Reflect.set(t,e,i,o);return a!==i&&r.dispatchEvent({type:`change-${e}`,value:i}),c}})}function N(n,r){return Promise.race([n,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function rt(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function Yt(n,r){let t=rt("svg");return t.setAttribute("width",n),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function Q(n="2",r){let t=rt("circle");return t.setAttribute("r",n),t.setAttribute("fill",r),t}function st(n){let r=rt("line");return r.setAttribute("stroke",n),r}function Y(n,r){let t=rt("rect");return t.setAttribute("stroke",n),t.setAttribute("fill",r),t}function U(n,r,t){n.setAttribute("cx",`${r}`),n.setAttribute("cy",`${t}`)}function k(n,r,t){r&&(n.setAttribute("x1",`${r.x}`),n.setAttribute("y1",`${r.y}`)),t&&(n.setAttribute("x2",`${t.x}`),n.setAttribute("y2",`${t.y}`))}function A(n,r,t,e,i){n.setAttribute("x",`${r}`),n.setAttribute("y",`${t}`),n.setAttribute("width",`${e}`),n.setAttribute("height",`${i}`)}function qt(){return Promise.resolve()}function We(){return new Promise(n=>{requestAnimationFrame(n)})}function qe(n){return parseInt(n.replace("#","0x"),16)}function Ne(n,r){let t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16),o=Math.round(t*r),a=Math.round(e*r),c=Math.round(i*r);return`#${(1<<24|o<<16|a<<8|c).toString(16).slice(1)}`}function at(n,r=.85){let t,e,i;if(n.startsWith("#"))t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16);else{let a=n.slice(4,-1).split(",");t=parseInt(a[0].trim()),e=parseInt(a[1].trim()),i=parseInt(a[2].trim())}return t=Math.min(Math.floor(t*r),255),e=Math.min(Math.floor(e*r),255),i=Math.min(Math.floor(i*r),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}var Nt=g("three/examples/jsm/loaders/GLTFLoader");function Ce(){return new Nt.GLTFLoader}var ct=null,ht=new Map;function Qt(n){if(ht.has(n)){let t=ht.get(n).then(e=>(e.scene=e.scene.clone(),e))}ct||(ct=Ce());let r=new Promise((t,e)=>{ct.load(n,i=>{t(i)},void 0,e)});return ht.set(n,r),r.then(t=>(t.scene=t.scene.clone(),t))}function Jt(){ct=null,ht.clear()}var lt=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function kt(n){return lt?n==="Meta":n==="Control"}var v=g("three"),X=g("@tweenjs/tween.js");var se=g("three");var P=g("three");var Le={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:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},T=class extends P.Object3D{constructor(t,e){super();this.context=t;s(this,"geometry");s(this,"material");s(this,"mesh");s(this,"line");s(this,"lineMaterial");s(this,"lineGeometry");s(this,"options");if(this.options=nt(M(M({},Le),e),this),this.options.geometry.type==="point"){let[i,o]=this.options.geometry.coords;return this.position.set(i,o,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var o;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(o=this.lineGeometry)==null||o.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new P.Vector3,e=new P.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new P.Vector3(0,0,0);let t=new P.Box3,e=new P.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=Kt(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new P.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:at(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}initGradualMaterial(){let{max:t,min:e}=new P.Box3().setFromObject(this),i=t.clone().sub(e),o=Math.max(i.x,i.y,i.z)/2,a=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:o,opacity:this.options.fillOpacity,direction:new P.Vector3(-1,.2,0),max:t,min:e});if(this.options.height<=.1)return this.material=a,a;let c=this.context.materialFactory.createShaderMaterial({gradualColor:[at(this.options.gradualColor[0],this.options.colorFactor),at(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:o,opacity:this.options.fillOpacity,direction:new P.Vector3(-1,.2,1),max:t,min:e});return this.material=[a,c],[a,c]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new P.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let o=0;o<i.length;o++){let a=i[o];for(let c=0;c<a.length;c++){let h=a[c],l=c+1===a.length?a[0]:a[c+1];t.push(new P.Vector3(h[0],h[1],e)),t.push(new P.Vector3(l[0],l[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new P.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new P.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:o}=e[0];return{position:i,distance:o}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};var O=g("three");var pt=class extends O.Object3D{constructor(){super();s(this,"directionalLight");s(this,"plane");s(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=jt(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new O.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 O.PlaneGeometry(t,e),o=new O.ShadowMaterial({transparent:!0,opacity:0,side:O.DoubleSide}),a=new O.Mesh(i,o);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(){H(this,!0)}};var dt=g("three");var K=g("three");var Ge={autoUpdate:!0,appendToBody:!1},mt=class extends K.EventDispatcher{constructor(t,e={}){super();this.context=t;s(this,"div");s(this,"element");s(this,"position",new K.Vector3);s(this,"clientPos",{x:0,y:0});s(this,"visible",!0);s(this,"options");s(this,"onUpdate",()=>{this.updatePosition()});this.options=M(M({},Ge),e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):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 K.Box3().setFromObject(this.element).getCenter(new K.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:o}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=o}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:o,x:a,y:c}=this.context.clientSize,{x:h,y:l}=b(e,this.context.camera,i,o);this.clientPos.x===h&&this.clientPos.y===l&&!t||(this.clientPos={x:h,y:l},this.options.appendToBody&&(this.div.style.left=`${a}px`,this.div.style.top=`${c+o}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${h}px, ${-o+l}px, 0)`:this.dispatchEvent({type:"update-position",x:h,y:l,width:i,height:o}))}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t;this.unRegistryEvent(),this.unBindElement(),(t=this.div)==null||t.remove(),this.div=null}};var Se={texts:[{text:""}],level:1,icon_position:"bottom",collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},J=class extends dt.EventDispatcher{constructor(t,e){var i,o,a;super();this.context=t;s(this,"div");s(this,"textDiv");s(this,"img");s(this,"overlay");s(this,"options");s(this,"visible",!0);s(this,"size",{width:0,height:0});s(this,"position",new dt.Vector3);s(this,"userData",{});s(this,"showTextStatus",!0);s(this,"_changePosition",()=>{this.overlay.updatePosition(!0)});this.options=nt(M(M({},Se),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((o=e.position)==null?void 0:o.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new mt(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:c,y:h,height:l})=>{this.overlay.div.style.transform=`translate3d(calc(${c}px - 50%), calc(${-l+h}px - ${this.options.icon?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.addText(),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`)}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return z(this,null,function*(){if(yield qt(),this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}})}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return this.div=t,this.addText(),this.options.icon&&this.addIcon(),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t)}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[o,a]of Object.entries(e.styles))i.style[o]=a;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,o=e*t,a=i*t,{x:c,y:h}=this.overlay.clientPos;return{left:c-o/2,right:c+o/2,top:this.options.icon?h-a:h-a/2,bottom:this.options.icon?h:h+a/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var D=g("three");var gt=g("three");var te=g("three");var q=class extends te.Object3D{constructor(t){super();this.context=t}dispose(){H(this),this.clear()}};var ut=class extends q{constructor(t){super(t);s(this,"graphicMap",new Map)}getCenter(){return new gt.Box3().setFromObject(this).getCenter(new gt.Vector3)}createGraphic(t){let e=new T(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((o,a)=>{if(a instanceof T){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<o.distance)return{distance:o.distance,position:o.position,graphic:a}}return o}else return o},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var ee=g("lodash");var ft=class extends q{constructor(t){super(t);s(this,"pois",[]);s(this,"debounceCollisionDetection");s(this,"timer",new _);s(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,ee.debounce)(this.collisionDetection,10)}clear(t=!1){return this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new J(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===0){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(o=>o instanceof J&&o.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,o)=>{let{left:a,right:c,top:h,bottom:l}=i.getBox();if(o===0||!i.options.collision_enable){t.push({left:a,right:c,top:h,bottom:l}),i.parentSetVisible(!0);return}let p=t.some(d=>d.left<c&&d.right>a&&d.top<l&&d.bottom>h);i.parentSetVisible(!p),p||t.push({left:a,right:c,top:h,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var C=g("three"),ie=g("@mars3d/heatmap.js"),V=g("@turf/turf");var vt=class extends C.Object3D{constructor(t){super();this.context=t;s(this,"heatmap");s(this,"div");s(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:o,center:a}=this.getBox(t);this.heatmap=(0,ie.create)(M({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,o)),this.initPlane(e,i),this.position.set(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new C.PlaneGeometry(t,e),o=new C.Texture(this.div.firstChild);o.needsUpdate=!0;let a=new C.MeshBasicMaterial({transparent:!0,side:C.DoubleSide,map:o});a.needsUpdate=!0,this.plane=new C.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new C.Matrix3().makeScale(1,-1).multiply(new C.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new C.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,V.featureCollection)(t.data.map(l=>(0,V.point)([l.x,l.y]))),i=(0,V.bbox)(e),o=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,V.center)(e);return{width:o,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var j=g("three");var yt=class extends j.Object3D{constructor(t,e){super();this.context=t;this.options=e;s(this,"poi",null);s(this,"model",null);this.position.copy(e.position||new j.Vector3(0,0,0)),this.loadModel()}loadModel(){return z(this,null,function*(){let t=yield Qt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t,this.initPoi()})}initPoi(){var e;if(!this.options.icon)return;let t=(e=this.context.currentFloor)==null?void 0:e.addPoi({icon:this.options.icon,icon_size:this.options.icon_size,built_in:!0,level:0});this.poi=t||null,this.model&&t&&(t.position=new j.Box3().setFromObject(this).getCenter(new j.Vector3))}dispose(){var t;H(this),this.model=null,this.poi&&((t=this.context.currentFloor)==null||t.poiLayer.removePoi(this.poi),this.poi=null)}};var xt=class extends D.Object3D{constructor(t){super();this.context=t;s(this,"graphicLayer");s(this,"poiLayer");s(this,"grounds",new Set);s(this,"shadow",new pt);s(this,"heatmap");s(this,"groundUpper",new D.Object3D);s(this,"models",new D.Object3D);s(this,"modelMap",new Map);s(this,"groundMaxHeight",0);this.graphicLayer=new ut(this.context),this.poiLayer=new ft(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper),this.add(this.models)}getPosition(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}createGround(t){let e=new T(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight,this.models.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}addModel(t){let e=new yt(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new D.Box3().setFromObject(this.groundUpper),e=t.getCenter(new D.Vector3),i=t.getSize(new D.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new vt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new D.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.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var bt=g("three");var F=class extends bt.EventDispatcher{constructor(t){super();this.context=t;s(this,"points",[]);s(this,"svg");s(this,"enable",!0);s(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=Yt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:o,offsetY:a}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=o/c*2-1,p=1-a/h*2;return new bt.Vector3(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return b(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var Et=class extends F{constructor(t){super(t);this.context=t;s(this,"circles");s(this,"line");s(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);U(this.circles[0],t.x,t.y),k(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);U(this.circles[1],t.x,t.y),k(this.line,void 0,t)}});s(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",k(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});s(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t,a=this.circles[this.points.length];U(a,i,o),this.points.length||k(this.line,{x:i,y:o},{x:i,y:o}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Q(e.radius,e.fill),Q(e.radius,e.fill)],this.line=st(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:o}]=this.points;return Math.sqrt(L(i-t,2)+L(o-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var wt=class extends F{constructor(t){super(t);s(this,"circles",[]);s(this,"lines",[]);s(this,"isClose",!1);s(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&U(this.circles[e],i.x,i.y),e!==0&&k(this.lines[e-1],void 0,i),this.lines[e]&&k(this.lines[e],i)})});s(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",k(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});s(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=Q(c,a);U(l,i,o),this.addCircle(l)}if(this.lines.length&&k(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=st(h);k(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],o=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(L(t-o,2)+L(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(o=>[o.x,o.y]),e=0,i=t.length;for(let o=0;o<i;o++){let a=(o+1)%i;e+=t[o][0]*t[a][1]-t[a][0]*t[o][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var ne=g("three");var oe=class extends F{constructor(t){super(t);this.context=t;s(this,"rect");s(this,"cornerRect",[]);s(this,"centerRect",[]);s(this,"graphic");s(this,"onUpdate",()=>{if(this.graphic){let t=new ne.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:o}}=this.context,{min:a,max:c}=t,h=b(a,e,i,o),l=b(c,e,i,o);A(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:d}=h,{x:y,y:f}=l,m=5,E=[{x:p-m,y:f-m},{x:y-m,y:f-m},{x:p-m,y:d-m},{x:y-m,y:d-m}];for(let S=0;S<E.length;S++)A(this.cornerRect[S],E[S].x,E[S].y,m*2,m*2);let x=4,u=(p+y)/2,R=(d+f)/2,B=[{x:u-x,y:f-x},{x:p-x,y:R-x},{x:y-x,y:R-x},{x:u-x,y:d-x}];for(let S=0;S<B.length;S++)A(this.centerRect[S],B[S].x,B[S].y,x*2,x*2)}else{A(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)A(this.cornerRect[t],0,0,0,0),A(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=Y(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Y(e.stroke,"#ffffff"),this.centerRect[i]=Y(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 re=g("three");var Pt=class extends F{constructor(t){super(t);s(this,"startPoint");s(this,"endPoint");s(this,"rect");s(this,"frustum",new re.Frustum);s(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});s(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});s(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});s(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=M({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},o=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);A(this.rect,i.x,i.y,o,a)}else A(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Y(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),A(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:o}}}=this,a=b(this.startPoint,e,i,o),c=b(this.endPoint,e,i,o),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},l={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var o;let{context:i}=this;return((o=i.currentFloor)==null?void 0:o.graphicLayer.children.filter(a=>a instanceof T&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:o,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let f=t.getPosition();if(f){let m=b(f,o,a,c);return ot(m,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,d=b(l,o,a,c),y=b(p,o,a,c);return!(!ot(d,e,i)||!ot(y,e,i))}dispose(){this.unRegistryEvent()}};var Mt=class extends se.EventDispatcher{constructor(t){super();this.context=t;s(this,"_list",new Set);s(this,"boxSelection");s(this,"prevPanStatus");s(this,"prevRotateStatus");s(this,"downPoint",null);s(this,"isMultipleSelect",!1);s(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});s(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:o,y:a}=this.downPoint;if(Math.sqrt(L(o-e,2)+L(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var d;if(!h.has(p.options.id)){let y=((d=this.context.currentFloor)==null?void 0:d.graphicLayer.graphicMap.get(p.options.id))||null;y&&y.options.geometry.type==="point"&&(c.push(y),h.add(p.options.id))}}),(lt?t.metaKey:t.ctrlKey)||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});s(this,"onPointerOut",t=>{this.disableBoxSelection()});s(this,"onKeyDown",t=>{kt(t.key)&&this.enableBoxSelection()});s(this,"onKeyUp",t=>{kt(t.key)&&this.disableBoxSelection()});s(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new Pt(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,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)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),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),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),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 ae=g("three");var Ct=class extends ae.EventDispatcher{constructor(t){super();this.context=t;s(this,"curGraphics",new Set);s(this,"timer",new _);s(this,"graphicTimerMap",new Map);s(this,"onPointerMove",({graphics:t,pois:e,e:i})=>{let o=e.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!t.length&&!o.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:a}=this.context.config.hover,c=new Set;if(o.length){let l,p=1e4;o.forEach(d=>{let y=e.find(x=>x.options.id===d.options.id),{x:f,y:m}=y.clientPos,E=Math.sqrt(L(f-i.offsetX,2)+L(m-i.offsetY,2));E<p&&(p=E,l=d)}),c.add(l)}c.size||t.forEach(l=>c.add(l)),c.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},a);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{c.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let h=this.curGraphics.size;this.curGraphics.forEach(l=>{c.has(l)||this.curGraphics.delete(l)}),h!==this.curGraphics.size&&this.handleHoverGraphicsChange()});s(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 G=g("three");function ce(n){return`${n.x}-${n.y}-${n.z}`}var Lt=class{constructor(r){this.context=r;s(this,"lineMaterialMap",new Map);s(this,"meshStandardMaterialMap",new Map);s(this,"meshBasicMaterialMap",new Map);s(this,"shaderMaterialMap",new Map)}generateLineMaterialKey({color:r,opacity:t}){return`${r}-${t}`}createLineMaterial({color:r,opacity:t}){let e=this.generateLineMaterialKey({color:r,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new G.LineBasicMaterial({color:new G.Color(r).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new G.MeshStandardMaterial({color:new G.Color(r).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}createMeshBasicMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let i=new G.MeshBasicMaterial({color:r,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,i),i}createShaderMaterial({gradualColor:r,center:t,maxValue:e,opacity:i,direction:o,max:a,min:c}){let h=`${r.toString()}-${ce(t)}-${e}-${i}-${ce(o)}`;if(this.shaderMaterialMap.has(h))return this.shaderMaterialMap.get(h);let l=`
1
+ "use strict";(()=>{var ye=Object.defineProperty,xe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var Rt=Object.getOwnPropertySymbols;var we=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var L=Math.pow,Dt=(n,r,t)=>r in n?ye(n,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[r]=t,M=(n,r)=>{for(var t in r||(r={}))we.call(r,t)&&Dt(n,t,r[t]);if(Rt)for(var t of Rt(r))Pe.call(r,t)&&Dt(n,t,r[t]);return n},tt=(n,r)=>xe(n,be(r));var f=(n=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(n,{get:(r,t)=>(typeof require!="undefined"?require:r)[t]}):n)(function(n){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var s=(n,r,t)=>(Dt(n,typeof r!="symbol"?r+"":r,t),t);var z=(n,r,t)=>new Promise((e,i)=>{var o=h=>{try{c(t.next(h))}catch(l){i(l)}},a=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(o,a);c((t=t.apply(n,r)).next())});var me=f("three");var _=class{constructor(){s(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(r){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),r()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(r){this.tasks.requestAnimation.delete(r),window.cancelAnimationFrame(r)}setTimeout(r,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),r()},t);return this.tasks.timeout.add(e),e}clearTimeout(r){this.tasks.timeout.delete(r),window.clearTimeout(r)}setInterval(r,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),r()},t);return this.tasks.interval.add(e),e}clearInterval(r){this.tasks.interval.delete(r),window.clearInterval(r)}dispose(){this.tasks.requestAnimation.forEach(r=>{window.cancelAnimationFrame(r)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(r=>{window.clearTimeout(r)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(r=>{window.clearInterval(r)}),this.tasks.interval.clear()}};var E=f("three"),Ht=f("three/examples/jsm/controls/MapControls");function _t(){let n=new E.Scene;return n.background=new E.Color(16777215),n}function Vt(){let n=new E.WebGLRenderer({antialias:!0});return n.autoClear=!0,n.setClearAlpha(1),n.setClearColor(16777215),n.setPixelRatio(window.devicePixelRatio),n.shadowMap.enabled=!0,n.shadowMap.autoUpdate=!0,n.shadowMap.type=E.PCFSoftShadowMap,n}function $t(n,r){let t=new E.OrthographicCamera(-n/2,n/2,r/2,-r/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function It(){let n=new E.Group,r=new E.AmbientLight(16777215,2.6);return n.add(r),n}function Ut(n,r){let t=new Ht.MapControls(n,r);return t.enableDamping=!1,t.zoomSpeed=2,t}function Kt(n,r=[]){let t=new E.Shape(n.map(e=>new E.Vector2(...e)));return r.length&&r.forEach(e=>{var i=new E.Path(e.map(o=>new E.Vector2(...o)));t.holes.push(i)}),t}function jt(n=16777215,r=1){let t=new E.DirectionalLight(n,r);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function H(n,r){var t;if(r&&n.children&&n.children.length&&n.children.forEach(e=>{H(e,r)}),n.isMesh){let e=n;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}n.isLight&&((t=n.dispose)==null||t.call(n))}function Zt(n){return/[\u4E00-\u9FA5]+/g.test(n)}var I=f("three");var et=new Map;function Ee(){let n=document.createElement("canvas");n.width=1024,n.height=64;let r=n.getContext("2d",{willReadFrequently:!0});return r.font="54px sans-serif",r.textBaseline="hanging",r.lineWidth=12,r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="white",{canvas:n,ctx:r}}var Ot,$;function Me(){if(!Ot){let{canvas:n,ctx:r}=Ee();Ot=n,$=r}}function Ve(n){if(et.has(n))return et.get(n);Me(),$.clearRect(0,0,1024,64);let r=Zt(n)?4:8;$.strokeText(n,2,r),$.fillText(n,2,r);let t=Math.ceil($.measureText(n).width);t=t%2===0?t:t+1,t+=2;let e=$.getImageData(0,0,t,64),i=new I.DataTexture(Uint8Array.from(e.data),t,64,I.RGBAFormat);return i.flipY=!0,i.minFilter=I.LinearFilter,i.magFilter=I.LinearFilter,et.set(n,i),i}function Xt(){et.clear()}function Wt(){$=null,Ot=null}var it=f("three"),W=f("@turf/turf");function P(n,r,t,e){let i=n.clone().project(r),o=t/2,a=e/2,c=Math.round(i.x*o+o),h=Math.round(-i.y*a+a);return{x:c,y:h}}function zt(n){let r=(0,W.featureCollection)(n.map(e=>(0,W.point)(e)));return(0,W.center)(r).geometry.coordinates}function ot(n,r,t){return n.x>=r.x&&n.x<=t.x&&n.y>=r.y&&n.y<=t.y}function Ue(n){let r=0,t=new it.Vector3;for(let e=1;e<n.length;e++){let i=new it.Vector3(n[e-1][0],n[e-1][1],0),o=new it.Vector3(n[e][0],n[e][1],0),a=o.distanceTo(i);a>r&&(r=a,t=o.clone().sub(i).normalize())}return t}function nt(n,r){return new Proxy(n,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,o)=>{let a=Reflect.get(t,e,o),c=Reflect.set(t,e,i,o);return a!==i&&r.dispatchEvent({type:`change-${e}`,value:i}),c}})}function N(n,r){return Promise.race([n,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function rt(n){return document.createElementNS("http://www.w3.org/2000/svg",n)}function Yt(n,r){let t=rt("svg");return t.setAttribute("width",n),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function Q(n="2",r){let t=rt("circle");return t.setAttribute("r",n),t.setAttribute("fill",r),t}function st(n){let r=rt("line");return r.setAttribute("stroke",n),r}function Y(n,r){let t=rt("rect");return t.setAttribute("stroke",n),t.setAttribute("fill",r),t}function U(n,r,t){n.setAttribute("cx",`${r}`),n.setAttribute("cy",`${t}`)}function A(n,r,t){r&&(n.setAttribute("x1",`${r.x}`),n.setAttribute("y1",`${r.y}`)),t&&(n.setAttribute("x2",`${t.x}`),n.setAttribute("y2",`${t.y}`))}function B(n,r,t,e,i){n.setAttribute("x",`${r}`),n.setAttribute("y",`${t}`),n.setAttribute("width",`${e}`),n.setAttribute("height",`${i}`)}function qt(){return Promise.resolve()}function We(){return new Promise(n=>{requestAnimationFrame(n)})}function qe(n){return parseInt(n.replace("#","0x"),16)}function Ne(n,r){let t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16),o=Math.round(t*r),a=Math.round(e*r),c=Math.round(i*r);return`#${(1<<24|o<<16|a<<8|c).toString(16).slice(1)}`}function at(n,r=.85){let t,e,i;if(n.startsWith("#"))t=parseInt(n.substring(1,3),16),e=parseInt(n.substring(3,5),16),i=parseInt(n.substring(5,7),16);else{let a=n.slice(4,-1).split(",");t=parseInt(a[0].trim()),e=parseInt(a[1].trim()),i=parseInt(a[2].trim())}return t=Math.min(Math.floor(t*r),255),e=Math.min(Math.floor(e*r),255),i=Math.min(Math.floor(i*r),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}var Nt=f("three/examples/jsm/loaders/GLTFLoader");function Ce(){return new Nt.GLTFLoader}var ct=null,ht=new Map;function Qt(n){if(ht.has(n)){let t=ht.get(n).then(e=>(e.scene=e.scene.clone(),e))}ct||(ct=Ce());let r=new Promise((t,e)=>{ct.load(n,i=>{t(i)},void 0,e)});return ht.set(n,r),r.then(t=>(t.scene=t.scene.clone(),t))}function Jt(){ct=null,ht.clear()}var lt=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function At(n){return lt?n==="Meta":n==="Control"}var x=f("three"),X=f("@tweenjs/tween.js");var se=f("three");var v=f("three");var Le={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:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},k=class extends v.Object3D{constructor(t,e){super();this.context=t;s(this,"geometry");s(this,"material");s(this,"mesh");s(this,"line");s(this,"lineMaterial");s(this,"lineGeometry");s(this,"options");if(this.options=nt(M(M({},Le),e),this),this.options.geometry.type==="point"){let[i,o]=this.options.geometry.coords;return this.position.set(i,o,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var o;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(o=this.lineGeometry)==null||o.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new v.Vector3,e=new v.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new v.Vector3(0,0,0);let t=new v.Box3,e=new v.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height/2),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=Kt(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new v.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:at(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}getMaxAndMin(t,e){let i=new v.Box3().setFromObject(this),o=t.clone().add(e.clone().multiplyScalar(1e3)),a=new v.Ray(o,e.clone().multiplyScalar(-1)),c=new v.Vector3;a.intersectBox(i,c);let h=t.clone().add(e.clone().multiplyScalar(-1e3)),l=new v.Ray(h,e.clone()),p=new v.Vector3;return l.intersectBox(i,p),{max:p,min:c}}initGradualMaterial(){let{max:t,min:e}=new v.Box3().setFromObject(this),i=t.clone().sub(e),o=Math.max(i.x,i.y,i.z)/2,a=this.getPosition(),c=new v.Vector3(-1,.2,0).normalize(),{max:h,min:l}=this.getMaxAndMin(a,c),p=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:o,opacity:this.options.fillOpacity,direction:new v.Vector3(-1,.2,0),max:h,min:l});if(this.options.height<=.1)return this.material=p,p;let d=this.getCenter(),y=new v.Vector3(-1,.2,1).normalize(),{max:g,min:m}=this.getMaxAndMin(d,y),b=this.context.materialFactory.createShaderMaterial({gradualColor:[at(this.options.gradualColor[0],this.options.colorFactor),at(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:o,opacity:this.options.fillOpacity,direction:new v.Vector3(-1,.2,1),max:g,min:m});return this.material=[p,b],[p,b]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new v.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let o=0;o<i.length;o++){let a=i[o];for(let c=0;c<a.length;c++){let h=a[c],l=c+1===a.length?a[0]:a[c+1];t.push(new v.Vector3(h[0],h[1],e)),t.push(new v.Vector3(l[0],l[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new v.BufferGeometry().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new v.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:o}=e[0];return{position:i,distance:o}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};var O=f("three");var pt=class extends O.Object3D{constructor(){super();s(this,"directionalLight");s(this,"plane");s(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=jt(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new O.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 O.PlaneGeometry(t,e),o=new O.ShadowMaterial({transparent:!0,opacity:0,side:O.DoubleSide}),a=new O.Mesh(i,o);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(){H(this,!0)}};var dt=f("three");var K=f("three");var Ge={autoUpdate:!0,appendToBody:!1},mt=class extends K.EventDispatcher{constructor(t,e={}){super();this.context=t;s(this,"div");s(this,"element");s(this,"position",new K.Vector3);s(this,"clientPos",{x:0,y:0});s(this,"visible",!0);s(this,"options");s(this,"onUpdate",()=>{this.updatePosition()});this.options=M(M({},Ge),e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):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 K.Box3().setFromObject(this.element).getCenter(new K.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:o}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=o}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:o,x:a,y:c}=this.context.clientSize,{x:h,y:l}=P(e,this.context.camera,i,o);this.clientPos.x===h&&this.clientPos.y===l&&!t||(this.clientPos={x:h,y:l},this.options.appendToBody&&(this.div.style.left=`${a}px`,this.div.style.top=`${c+o}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${h}px, ${-o+l}px, 0)`:this.dispatchEvent({type:"update-position",x:h,y:l,width:i,height:o}))}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t;this.unRegistryEvent(),this.unBindElement(),(t=this.div)==null||t.remove(),this.div=null}};var Se={texts:[{text:""}],level:1,icon_position:"bottom",collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},J=class extends dt.EventDispatcher{constructor(t,e){var i,o,a;super();this.context=t;s(this,"div");s(this,"textDiv");s(this,"img");s(this,"overlay");s(this,"options");s(this,"visible",!0);s(this,"size",{width:0,height:0});s(this,"position",new dt.Vector3);s(this,"userData",{});s(this,"showTextStatus",!0);s(this,"_changePosition",()=>{this.overlay.updatePosition(!0)});this.options=nt(M(M({},Se),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((o=e.position)==null?void 0:o.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new mt(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:c,y:h,height:l})=>{this.overlay.div.style.transform=`translate3d(calc(${c}px - 50%), calc(${-l+h}px - ${this.options.icon?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.addText(),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`)}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return z(this,null,function*(){if(yield qt(),this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}})}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return this.div=t,this.addText(),this.options.icon&&this.addIcon(),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t)}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[o,a]of Object.entries(e.styles))i.style[o]=a;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,o=e*t,a=i*t,{x:c,y:h}=this.overlay.clientPos;return{left:c-o/2,right:c+o/2,top:this.options.icon?h-a:h-a/2,bottom:this.options.icon?h:h+a/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var D=f("three");var gt=f("three");var te=f("three");var q=class extends te.Object3D{constructor(t){super();this.context=t}dispose(){H(this),this.clear()}};var ut=class extends q{constructor(t){super(t);s(this,"graphicMap",new Map)}getCenter(){return new gt.Box3().setFromObject(this).getCenter(new gt.Vector3)}createGraphic(t){let e=new k(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((o,a)=>{if(a instanceof k){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<o.distance)return{distance:o.distance,position:o.position,graphic:a}}return o}else return o},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var ee=f("lodash");var ft=class extends q{constructor(t){super(t);s(this,"pois",[]);s(this,"debounceCollisionDetection");s(this,"timer",new _);s(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,ee.debounce)(this.collisionDetection,10)}clear(t=!1){return this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new J(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===0){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(o=>o instanceof J&&o.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,o)=>{let{left:a,right:c,top:h,bottom:l}=i.getBox();if(o===0||!i.options.collision_enable){t.push({left:a,right:c,top:h,bottom:l}),i.parentSetVisible(!0);return}let p=t.some(d=>d.left<c&&d.right>a&&d.top<l&&d.bottom>h);i.parentSetVisible(!p),p||t.push({left:a,right:c,top:h,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var C=f("three"),ie=f("@mars3d/heatmap.js"),V=f("@turf/turf");var vt=class extends C.Object3D{constructor(t){super();this.context=t;s(this,"heatmap");s(this,"div");s(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:o,center:a}=this.getBox(t);this.heatmap=(0,ie.create)(M({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,o)),this.initPlane(e,i),this.position.set(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new C.PlaneGeometry(t,e),o=new C.Texture(this.div.firstChild);o.needsUpdate=!0;let a=new C.MeshBasicMaterial({transparent:!0,side:C.DoubleSide,map:o});a.needsUpdate=!0,this.plane=new C.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new C.Matrix3().makeScale(1,-1).multiply(new C.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new C.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,V.featureCollection)(t.data.map(l=>(0,V.point)([l.x,l.y]))),i=(0,V.bbox)(e),o=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,V.center)(e);return{width:o,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var j=f("three");var yt=class extends j.Object3D{constructor(t,e){super();this.context=t;this.options=e;s(this,"poi",null);s(this,"model",null);this.position.copy(e.position||new j.Vector3(0,0,0)),this.loadModel()}loadModel(){return z(this,null,function*(){let t=yield Qt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t,this.initPoi()})}initPoi(){var e;if(!this.options.icon)return;let t=(e=this.context.currentFloor)==null?void 0:e.addPoi({icon:this.options.icon,icon_size:this.options.icon_size,built_in:!0,level:0});this.poi=t||null,this.model&&t&&(t.position=new j.Box3().setFromObject(this).getCenter(new j.Vector3))}dispose(){var t;H(this),this.model=null,this.poi&&((t=this.context.currentFloor)==null||t.poiLayer.removePoi(this.poi),this.poi=null)}};var xt=class extends D.Object3D{constructor(t){super();this.context=t;s(this,"graphicLayer");s(this,"poiLayer");s(this,"grounds",new Set);s(this,"shadow",new pt);s(this,"heatmap");s(this,"groundUpper",new D.Object3D);s(this,"models",new D.Object3D);s(this,"modelMap",new Map);s(this,"groundMaxHeight",0);this.graphicLayer=new ut(this.context),this.poiLayer=new ft(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper),this.add(this.models)}getPosition(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}createGround(t){let e=new k(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight,this.models.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}addModel(t){let e=new yt(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new D.Box3().setFromObject(this.groundUpper),e=t.getCenter(new D.Vector3),i=t.getSize(new D.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new vt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new D.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.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var bt=f("three");var F=class extends bt.EventDispatcher{constructor(t){super();this.context=t;s(this,"points",[]);s(this,"svg");s(this,"enable",!0);s(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=Yt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:o,offsetY:a}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=o/c*2-1,p=1-a/h*2;return new bt.Vector3(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return P(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var wt=class extends F{constructor(t){super(t);this.context=t;s(this,"circles");s(this,"line");s(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);U(this.circles[0],t.x,t.y),A(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);U(this.circles[1],t.x,t.y),A(this.line,void 0,t)}});s(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",A(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});s(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t,a=this.circles[this.points.length];U(a,i,o),this.points.length||A(this.line,{x:i,y:o},{x:i,y:o}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Q(e.radius,e.fill),Q(e.radius,e.fill)],this.line=st(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:o}]=this.points;return Math.sqrt(L(i-t,2)+L(o-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var Pt=class extends F{constructor(t){super(t);s(this,"circles",[]);s(this,"lines",[]);s(this,"isClose",!1);s(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&U(this.circles[e],i.x,i.y),e!==0&&A(this.lines[e-1],void 0,i),this.lines[e]&&A(this.lines[e],i)})});s(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",A(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});s(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=Q(c,a);U(l,i,o),this.addCircle(l)}if(this.lines.length&&A(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=st(h);A(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],o=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(L(t-o,2)+L(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(o=>[o.x,o.y]),e=0,i=t.length;for(let o=0;o<i;o++){let a=(o+1)%i;e+=t[o][0]*t[a][1]-t[a][0]*t[o][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var ne=f("three");var oe=class extends F{constructor(t){super(t);this.context=t;s(this,"rect");s(this,"cornerRect",[]);s(this,"centerRect",[]);s(this,"graphic");s(this,"onUpdate",()=>{if(this.graphic){let t=new ne.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:o}}=this.context,{min:a,max:c}=t,h=P(a,e,i,o),l=P(c,e,i,o);B(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:d}=h,{x:y,y:g}=l,m=5,b=[{x:p-m,y:g-m},{x:y-m,y:g-m},{x:p-m,y:d-m},{x:y-m,y:d-m}];for(let S=0;S<b.length;S++)B(this.cornerRect[S],b[S].x,b[S].y,m*2,m*2);let w=4,u=(p+y)/2,R=(d+g)/2,T=[{x:u-w,y:g-w},{x:p-w,y:R-w},{x:y-w,y:R-w},{x:u-w,y:d-w}];for(let S=0;S<T.length;S++)B(this.centerRect[S],T[S].x,T[S].y,w*2,w*2)}else{B(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)B(this.cornerRect[t],0,0,0,0),B(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=Y(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Y(e.stroke,"#ffffff"),this.centerRect[i]=Y(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 re=f("three");var Et=class extends F{constructor(t){super(t);s(this,"startPoint");s(this,"endPoint");s(this,"rect");s(this,"frustum",new re.Frustum);s(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});s(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});s(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});s(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=M({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},o=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);B(this.rect,i.x,i.y,o,a)}else B(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Y(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),B(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:o}}}=this,a=P(this.startPoint,e,i,o),c=P(this.endPoint,e,i,o),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},l={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var o;let{context:i}=this;return((o=i.currentFloor)==null?void 0:o.graphicLayer.children.filter(a=>a instanceof k&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:o,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let g=t.getPosition();if(g){let m=P(g,o,a,c);return ot(m,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,d=P(l,o,a,c),y=P(p,o,a,c);return!(!ot(d,e,i)||!ot(y,e,i))}dispose(){this.unRegistryEvent()}};var Mt=class extends se.EventDispatcher{constructor(t){super();this.context=t;s(this,"_list",new Set);s(this,"boxSelection");s(this,"prevPanStatus");s(this,"prevRotateStatus");s(this,"downPoint",null);s(this,"isMultipleSelect",!1);s(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});s(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:o,y:a}=this.downPoint;if(Math.sqrt(L(o-e,2)+L(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var d;if(!h.has(p.options.id)){let y=((d=this.context.currentFloor)==null?void 0:d.graphicLayer.graphicMap.get(p.options.id))||null;y&&y.options.geometry.type==="point"&&(c.push(y),h.add(p.options.id))}}),(lt?t.metaKey:t.ctrlKey)||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});s(this,"onPointerOut",t=>{this.disableBoxSelection()});s(this,"onKeyDown",t=>{At(t.key)&&this.enableBoxSelection()});s(this,"onKeyUp",t=>{At(t.key)&&this.disableBoxSelection()});s(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new Et(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,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)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),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),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),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 ae=f("three");var Ct=class extends ae.EventDispatcher{constructor(t){super();this.context=t;s(this,"curGraphics",new Set);s(this,"timer",new _);s(this,"graphicTimerMap",new Map);s(this,"onPointerMove",({graphics:t,pois:e,e:i})=>{let o=e.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!t.length&&!o.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:a}=this.context.config.hover,c=new Set;if(o.length){let l,p=1e4;o.forEach(d=>{let y=e.find(w=>w.options.id===d.options.id),{x:g,y:m}=y.clientPos,b=Math.sqrt(L(g-i.offsetX,2)+L(m-i.offsetY,2));b<p&&(p=b,l=d)}),c.add(l)}c.size||t.forEach(l=>c.add(l)),c.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},a);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{c.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let h=this.curGraphics.size;this.curGraphics.forEach(l=>{c.has(l)||this.curGraphics.delete(l)}),h!==this.curGraphics.size&&this.handleHoverGraphicsChange()});s(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 G=f("three");function ce(n){return`${n.x}-${n.y}-${n.z}`}var Lt=class{constructor(r){this.context=r;s(this,"lineMaterialMap",new Map);s(this,"meshStandardMaterialMap",new Map);s(this,"meshBasicMaterialMap",new Map);s(this,"shaderMaterialMap",new Map)}generateLineMaterialKey({color:r,opacity:t}){return`${r}-${t}`}createLineMaterial({color:r,opacity:t}){let e=this.generateLineMaterialKey({color:r,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new G.LineBasicMaterial({color:new G.Color(r).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new G.MeshStandardMaterial({color:new G.Color(r).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}createMeshBasicMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let i=new G.MeshBasicMaterial({color:r,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,i),i}createShaderMaterial({gradualColor:r,center:t,maxValue:e,opacity:i,direction:o,max:a,min:c}){let h=`${r.toString()}-${ce(t)}-${e}-${i}-${ce(o)}`;if(this.shaderMaterialMap.has(h))return this.shaderMaterialMap.get(h);let l=`
2
2
  uniform vec3 uColor;
3
3
  uniform vec3 uGradualColor;
4
4
  uniform vec3 center;
@@ -9,11 +9,23 @@
9
9
  varying vec3 vColor;
10
10
 
11
11
  void main() {
12
+ vec3 lineVec = uMax - uMin; // \u7EBF\u6BB5AB\u7684\u65B9\u5411\u5411\u91CF
13
+ vec3 AP = position - uMin; // \u5411\u91CFAP
14
+ float t = dot(AP, lineVec) / dot(lineVec, lineVec); // \u53C2\u6570t
15
+ t = clamp(t, 0.0, 1.0); // \u9650\u5236t\u5728[0, 1]\u8303\u56F4\u5185\uFF0C\u786E\u4FDD\u6700\u77ED\u8DDD\u79BB\u5728\u7EBF\u6BB5AB\u4E0A
16
+
17
+ vec3 closestPoint = uMin + t * lineVec; // \u6700\u77ED\u8DDD\u79BB\u70B9\u7684\u4F4D\u7F6E
18
+ vec3 vecAP = closestPoint - uMin; // \u5411\u91CFAP'
19
+ float distance = length(vecAP);
20
+ float maxLen = length(lineVec);
21
+
12
22
  vec3 direction = normalize(uDirection);
23
+ float gradient = dot(normalize(normal), normalize(uDirection));
13
24
  vec3 currentPosition = position - center;
14
- float colorFactor = (dot(direction, currentPosition) / maxValue) * 0.5 + 0.5;
25
+ // float colorFactor = (dot(direction, currentPosition) / maxValue) * 0.5 + 0.5;
26
+ float colorFactor = distance / maxLen;
15
27
 
16
- vColor = mix(uColor, uGradualColor, colorFactor);
28
+ vColor = mix(uColor, uGradualColor, 1.0 - t);
17
29
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
18
30
  }
19
31
  `,p=`
@@ -23,5 +35,5 @@
23
35
  void main() {
24
36
  gl_FragColor = vec4(vColor.x, vColor.y, vColor.z, opacity);
25
37
  }
26
- `,d=new G.ShaderMaterial({uniforms:{uColor:{value:new G.Color(r[0]).convertLinearToSRGB()},uGradualColor:{value:new G.Color(r[1]).convertLinearToSRGB()},center:{value:t},maxValue:{value:e},opacity:{value:i},uDirection:{value:o},uMax:{value:a},uMin:{value:c}},vertexShader:l,fragmentShader:p,side:G.DoubleSide});return this.shaderMaterialMap.set(h,d),d}dispose(){this.lineMaterialMap.forEach((r,t)=>{r.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((r,t)=>{r.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((r,t)=>{r.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((r,t)=>{r.dispose()}),this.shaderMaterialMap.clear()}};var Z=g("three");var Gt=class{constructor(r){this.context=r;s(this,"prevCamera",{position:new Z.Vector3,zoom:1,target:new Z.Vector3});s(this,"enable",!0);s(this,"onCameraChange",()=>{});this.registryEvent(),this.changePrevCamera()}setEnable(r){this.enable=r,r?this.registryEvent():this.unRegistryEvent()}changePrevCamera(){this.prevCamera={position:this.context.camera.position.clone(),zoom:this.context.camera.zoom,target:this.context.control.target.clone()}}backToPrevCamera(){this.setEnable(!1),this.context.camera.position.copy(this.prevCamera.position),this.context.camera.zoom=this.prevCamera.zoom,this.context.control.target.copy(this.prevCamera.target),this.context.control.update(),this.setEnable(!0)}registryEvent(){this.context.addEventListener("control-change",this.onCameraChange)}unRegistryEvent(){this.context.removeEventListener("control-change",this.onCameraChange)}getCurFloorScreenPosition(){if(!this.context.currentFloor)return null;let r=new Z.Box3().setFromObject(this.context.currentFloor.groundUpper),{camera:t,container:{clientWidth:e,clientHeight:i}}=this.context,{min:o,max:a}=r,c=b(o,t,e,i),h=b(a,t,e,i),l=b(new Z.Vector3(o.x,a.y,a.z),t,e,i),p=b(new Z.Vector3(a.x,o.y,o.z),t,e,i),d=Math.min(c.x,h.x,l.x,p.x),y=Math.max(c.x,h.x,l.x,p.x),f=Math.min(c.y,h.y,l.y,p.y),m=Math.max(c.y,h.y,l.y,p.y);return{left:d,right:y,top:f,bottom:m}}checkDistanceToScreenEdge({left:r,right:t,top:e,bottom:i}){let{width:o,height:a}=this.context.clientSize,[c,h,l,p]=this.context.config.cameraBound.padding;return r<=p&&o-t<=h&&e<=c&&a-i<=l}dispose(){this.unRegistryEvent()}};var St=class extends v.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;s(this,"scene",_t());s(this,"renderer",Vt());s(this,"camera");s(this,"control");s(this,"lights",It());s(this,"timer",new _);s(this,"tweenGroup",new X.Group);s(this,"currentFloor");s(this,"selection");s(this,"hoverHelper");s(this,"basicRatio");s(this,"materialFactory");s(this,"cameraBound");s(this,"clientSize",{width:0,height:0,x:0,y:0});s(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:o,clientHeight:a}=t;o=Math.max(1,o),a=Math.max(1,a),e.left=-o/2,e.right=o/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(o,a),this.resizeClientSize(),this.dispatchEvent({type:"resize",width:o,height:a})});s(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);o.length&&this.dispatchEvent({type:"poi-click",pois:o})});s(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-over",e:t,graphics:e,pois:o,position:i})});s(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-move",e:t,graphics:e,pois:o,position:i})});s(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});s(this,"onSelectionSelect",({graphics:t,isMultipleSelect:e})=>{this.dispatchEvent({type:"select-graphic",graphics:t,isMultipleSelect:e})});s(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 Mt(this),this.hoverHelper=new Ct(this),this.materialFactory=new Lt(this),this.resizeClientSize(),this.registryEvent()}resizeClientSize(){let{x:t,y:e,width:i,height:o}=this.container.getBoundingClientRect();this.clientSize={width:i||this.container.clientWidth,height:o||this.container.clientHeight,x:t,y:e}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=$t(t,e),this.renderer.setSize(t,e),this.control=Ut(this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var o;let i=this.control.getPolarAngle();(o=this.currentFloor)==null||o.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})}),this.cameraBound=new Gt(this)}getRatio(t=new v.Vector3(0,0,0),e=new v.Vector3(100,0,0)){let{clientWidth:i,clientHeight:o}=this.container,a=b(t,this.camera,i,o),c=b(e,this.camera,i,o);return Math.ceil(Math.sqrt(L(c.x-a.x,2)+L(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.clientSize.width*2-1,i.y=e/this.clientSize.height*-2+1;let o=new v.Raycaster;return o.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(o))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var o;return((o=this.currentFloor)==null?void 0:o.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return e===0?(this.control.maxPolarAngle=t,this.control.minPolarAngle=t,this.control.update(),this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,Promise.resolve()):N(new Promise(i=>{let o={polar:this.control.getPolarAngle()},a={polar:t},c=new X.Tween(o,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxPolarAngle=o.polar,this.control.minPolarAngle=o.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}setAzimuthalAngle(t,e=500){if(e===0){this.control.maxAzimuthAngle=t,this.control.minAzimuthAngle=t,this.control.update(),this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0;return}return N(new Promise(i=>{let o={azimuthal:this.control.getAzimuthalAngle()},a={azimuthal:t},c=new X.Tween(o,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxAzimuthAngle=o.azimuthal,this.control.minAzimuthAngle=o.azimuthal,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new v.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){let o=this.getCameraLookAt(),a={zoom:this.camera.zoom,target:this.control.target.clone()};if(!i){this.camera.position.copy(e.clone().sub(o)),this.control.target.copy(e),this.camera.zoom=t,this.control.update();return}return N(new Promise(c=>{let h=new X.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(o)),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)}getFitCameraToObjectZoom(t,e=[20,20,20,20],i=500,o=!0){let[a,c,h,l]=e,{clientSize:{width:p,height:d}}=this,y=this.control.getPolarAngle();o&&this.setPolarAngle(0,0);let f=new v.Box3().setFromObject(t);this.setPolarAngle(y,0);let{max:m,min:E}=f,x=new v.Vector3(E.x,m.y,E.z),u=new v.Vector3(m.x,m.y,E.z),R=new v.Vector3(m.x,E.y,m.z),B=new v.Vector3(E.x,E.y,m.z),S=b(x,this.camera,p,d),At=b(u,this.camera,p,d),Tt=b(B,this.camera,p,d),Bt=b(R,this.camera,p,d),Ft=new v.Box2().setFromPoints([new v.Vector2(S.x,S.y),new v.Vector2(At.x,At.y),new v.Vector2(Tt.x,Tt.y),new v.Vector2(Bt.x,Bt.y)]).getSize(new v.Vector2),ue=(p-c-l)/Ft.x,ge=(d-a-h)/Ft.y,fe=Math.min(ue,ge),ve=new v.Vector3((m.x+E.x)/2,(m.y+E.y)/2,0);return{zoom:fe*this.camera.zoom,center:ve}}fitCameraToObject(t,e=[20,20,20,20],i=500,o=!0){let{zoom:a,center:c}=this.getFitCameraToObjectZoom(t,e,i,o);return this.setZoom(a,c,i)}getFitCameraToGroundZoom(t=[20,20,20,20],e=500,i=!0){if(this.currentFloor&&this.currentFloor.hasElement)return this.getFitCameraToObjectZoom(this.currentFloor.groundUpper,t,e,i).zoom}fitCameraToGround(t=[20,20,20,20],e=500,i=!0){return this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundUpper,t,e,i):Promise.resolve(!1)}setCameraPosition(t,e){return N(new Promise(i=>{let o=this.camera.position.clone(),a=this.getCameraLookAt(),c=new X.Tween(o,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(o.clone().sub(a)),this.control.target.copy(o.clone()),this.control.update()}).onComplete(()=>{this.tweenGroup.remove(c),this.camera.position.copy(o.clone().sub(a)),this.control.target.copy(t.clone()),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.cameraBound.dispose(),this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),this.materialFactory.dispose(),H(this.scene)}};var he=g("lodash"),De={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},resizeObserver:!1,initTransToMark:!1,heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2,defaultPolar:1.1,defaultAzimuthal:0},defaultPadding:[20,20,20,20],svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:100},ground:{color:"#F6F6F6",opacity:1,height:.001,stroke:!1,strokeColor:"#E6E6E6",strokeOpacity:1},markGraphic:{color:"#EEF0F3",opacity:1,height:.001,stroke:!1,strokeColor:"#000",strokeOpacity:1},graphic:{fillOpacity:1},cameraBound:{padding:[150,150,150,150]},poi:{boxScale:1}};function le(n){return(0,he.merge)({},De,n)}var de=g("lodash");var Oe=(t=>(t[t.D2=0]="D2",t[t.D3=1.1]="D3",t))(Oe||{}),pe=class extends me.EventDispatcher{constructor(t,e={}){super();this.container=t;s(this,"config");s(this,"context");s(this,"polarKeys",[]);s(this,"azimuthalKeys",[]);s(this,"svgLine");s(this,"svgPolygon");s(this,"basicZoom",1);s(this,"prevCameraZoom",1);s(this,"type","2d");s(this,"floorDataMap",new Map);s(this,"buildingGroundMap",new Map);s(this,"currentBuildGround",null);s(this,"observe",null);s(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)});s(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)});s(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}});s(this,"resize",()=>{this.context.cameraBound.setEnable(!1),this.context.onWindowResize();let t=this.context.control.getAzimuthalAngle(),e=this.context.camera.zoom;this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0);let i=this.context.getFitCameraToGroundZoom(void 0,0);this.basicZoom=i||0,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.camera.zoom=e,this.context.control.addEventListener("change",this.onControlChange),this.context.setAzimuthalAngle(t,0),this.context.cameraBound.setEnable(!0)});this.config=le(e),this.context=new St(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(l){return z(this,arguments,function*({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){let{apiDomain:p,apiPath:{floorGraphic:d},apiInfo:y}=this.config,f=`${p}${d}?brand=${t}&project=${e}&phase=${i}&building=${o}&floor=${a}&ts=${c}&resource_type_list=${h}`;return yield fetch(f,y).then(E=>E.json()).then(E=>E.data).then(E=>((E||[]).map(x=>x.info=JSON.parse(x.info)),E||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:o}){return`${t}-${e}-${i}-${o}`}loadBuildingGround(a){return z(this,arguments,function*({brand:t,project:e,phase:i,building:o}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:o});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:h,apiPath:{floorRange:l},apiInfo:p}=this.config,d=`${h}${l}?brand=${t}&project=${e}&phase=${i}&building=${o}`,y=yield fetch(d,p).then(f=>f.json()).then(f=>f.data).then(f=>{let m=(f||[])[0];return m&&(m.info=JSON.parse(m.info)),m});return this.buildingGroundMap.set(c,y),y})}getFloorKey({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${o}-${a}-${c}-${h}`}load(l){return z(this,arguments,function*({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h});if(this.floorDataMap.get(p))return;let[d,y]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:o})]);if(y){let x=zt(y.info.geometry.cds[0]);d.forEach(u=>{if(u.info.geometry.coords=JSON.parse(JSON.stringify(u.info.geometry.cds)),u.info.geometry.type==="polygon")u.info.geometry.coords.map(R=>{Array.isArray(R)&&R.forEach(B=>{B[0]-=x[0],B[1]-=x[1]})});else{let[R,B]=u.info.geometry.cds;u.info.geometry.coords=[R-x[0],B-x[1]]}u.info.transformToBuildingGround=!0})}let{ground:f,markGraphic:m,graphic:E}=this.config;for(let x=0;x<d.length;x++){let u=d[x];u.info.deltaHeight=1e-5*(x+1),u.info.group==="ground"?(u.info.fillColor=f.color,u.info.fillOpacity=f.opacity,u.info.height=f.height,u.info.stroke=f.stroke,u.info.strokeColor=f.strokeColor,u.info.strokeOpacity=f.strokeOpacity):u.info.userData.mark?(u.info.height=m.height,u.info.fillColor=m.color,u.info.fillOpacity=m.opacity,u.info.stroke=m.stroke,u.info.strokeColor=m.strokeColor,u.info.strokeOpacity=m.strokeOpacity):(u.info.fillOpacity=E.fillOpacity,this.config.initTransToMark&&(u.info.height=m.height,u.info.fillColor=m.color,u.info.stroke=m.stroke,u.info.strokeColor=m.strokeColor,u.info.strokeOpacity=m.strokeOpacity))}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(p,d),d})}createFloor(t){let e=new xt(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=new Map,o=[];for(let a of t)if(a.info.group==="ground")e.createGround(a.info);else{let c=e.addGraphic(a.info);c.userData.data=a,i.set(a.legacy_id,c),o.push(c)}return e.userData.legacyToGraphicMap=i,{curFloor:e,graphics:o}}switchFloor({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}),p=this.floorDataMap.get(l);if(this.context.control.removeEventListener("change",this.onControlChange),p){let d=this.getBuildingKey({brand:t,project:e,phase:i,building:o});this.currentBuildGround=this.buildingGroundMap.get(d)||null;let y=this.createFloor(p);y?(this.context.cameraBound.setEnable(!1),this.context.switchFloor(y.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,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.type==="3d"&&this.context.fitCameraToGround(this.config.defaultPadding,0,!1),this.onControlChange(),this.context.cameraBound.setEnable(!0)):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")}addModel(t,e){var i;if(t.options.geometry.type==="polygon"){let o=(i=this.context.currentFloor)==null?void 0:i.addModel(tt(M({},e),{position:t.getPosition().setZ(.1),id:t.options.id}));if(o){let{facilityAngle:a=0,facilityXScale:c=1,facilityYScale:h=1}=t.options.userData;o.rotateZ((180-a)/180*Math.PI),o.scale.set(c,h,1)}}}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 T))||[]}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(tt(M({},e),{position:tt(M({},i),{z:i.z+t.options.height/2})}))}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.getPosition();return this.context.setCameraPosition(i,e)}translateElementToCenterX(t,e=500){return z(this,null,function*(){let{y:i,z:o}=this.context.control.target,a=t.getPosition();a.setY(i),a.setZ(o),yield this.context.setCameraPosition(a,e)})}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:o}=this.container;return b(e,this.context.camera,i,o)}changeMapType(t,e=500){return this.type=t,t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(1.1,e)}resetView(t=300){return z(this,null,function*(){let e=t/3;yield this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,e),yield this.changeMapType(this.type,e),yield this.context.fitCameraToGround(this.config.defaultPadding,e,!1)})}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){if(window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp),this.config.resizeObserver){let t=new ResizeObserver((0,de.debounce)(this.resize,5));t.observe(this.container),this.observe=t}}unRegistryEvent(){var t;window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp),(t=this.observe)==null||t.disconnect(),this.observe=null}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return z(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new Et(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:o})=>{t(o)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new wt(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:o})=>{t(o)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}getGraphicByNodeId(t){var e;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=zt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.coords=JSON.parse(JSON.stringify(t.geometry.cds)),t.geometry.coords.map(o=>{Array.isArray(o)&&o.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[o,a]=t.geometry.cds;t.geometry.coords=[o-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)||[]).filter(e=>!e.options.built_in)}clearPoi(){this.context.currentFloor&&this.context.currentFloor.poiLayer.clear()}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){this.context.dispose(),this.floorDataMap.clear(),this.buildingGroundMap.clear(),Xt(),Wt(),Jt(),this.unRegistryEvent()}};})();
38
+ `,d=new G.ShaderMaterial({uniforms:{uColor:{value:new G.Color(r[0]).convertLinearToSRGB()},uGradualColor:{value:new G.Color(r[1]).convertLinearToSRGB()},center:{value:t},maxValue:{value:e},opacity:{value:i},uDirection:{value:o},uMax:{value:a},uMin:{value:c}},vertexShader:l,fragmentShader:p,side:G.DoubleSide});return this.shaderMaterialMap.set(h,d),d}dispose(){this.lineMaterialMap.forEach((r,t)=>{r.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((r,t)=>{r.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((r,t)=>{r.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((r,t)=>{r.dispose()}),this.shaderMaterialMap.clear()}};var Z=f("three");var Gt=class{constructor(r){this.context=r;s(this,"prevCamera",{position:new Z.Vector3,zoom:1,target:new Z.Vector3});s(this,"enable",!0);s(this,"onCameraChange",()=>{});this.registryEvent(),this.changePrevCamera()}setEnable(r){this.enable=r,r?this.registryEvent():this.unRegistryEvent()}changePrevCamera(){this.prevCamera={position:this.context.camera.position.clone(),zoom:this.context.camera.zoom,target:this.context.control.target.clone()}}backToPrevCamera(){this.setEnable(!1),this.context.camera.position.copy(this.prevCamera.position),this.context.camera.zoom=this.prevCamera.zoom,this.context.control.target.copy(this.prevCamera.target),this.context.control.update(),this.setEnable(!0)}registryEvent(){this.context.addEventListener("control-change",this.onCameraChange)}unRegistryEvent(){this.context.removeEventListener("control-change",this.onCameraChange)}getCurFloorScreenPosition(){if(!this.context.currentFloor)return null;let r=new Z.Box3().setFromObject(this.context.currentFloor.groundUpper),{camera:t,container:{clientWidth:e,clientHeight:i}}=this.context,{min:o,max:a}=r,c=P(o,t,e,i),h=P(a,t,e,i),l=P(new Z.Vector3(o.x,a.y,a.z),t,e,i),p=P(new Z.Vector3(a.x,o.y,o.z),t,e,i),d=Math.min(c.x,h.x,l.x,p.x),y=Math.max(c.x,h.x,l.x,p.x),g=Math.min(c.y,h.y,l.y,p.y),m=Math.max(c.y,h.y,l.y,p.y);return{left:d,right:y,top:g,bottom:m}}checkDistanceToScreenEdge({left:r,right:t,top:e,bottom:i}){let{width:o,height:a}=this.context.clientSize,[c,h,l,p]=this.context.config.cameraBound.padding;return r<=p&&o-t<=h&&e<=c&&a-i<=l}dispose(){this.unRegistryEvent()}};var St=class extends x.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;s(this,"scene",_t());s(this,"renderer",Vt());s(this,"camera");s(this,"control");s(this,"lights",It());s(this,"timer",new _);s(this,"tweenGroup",new X.Group);s(this,"currentFloor");s(this,"selection");s(this,"hoverHelper");s(this,"basicRatio");s(this,"materialFactory");s(this,"cameraBound");s(this,"clientSize",{width:0,height:0,x:0,y:0});s(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:o,clientHeight:a}=t;o=Math.max(1,o),a=Math.max(1,a),e.left=-o/2,e.right=o/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(o,a),this.resizeClientSize(),this.dispatchEvent({type:"resize",width:o,height:a})});s(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);o.length&&this.dispatchEvent({type:"poi-click",pois:o})});s(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-over",e:t,graphics:e,pois:o,position:i})});s(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),o=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-move",e:t,graphics:e,pois:o,position:i})});s(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});s(this,"onSelectionSelect",({graphics:t,isMultipleSelect:e})=>{this.dispatchEvent({type:"select-graphic",graphics:t,isMultipleSelect:e})});s(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 Mt(this),this.hoverHelper=new Ct(this),this.materialFactory=new Lt(this),this.resizeClientSize(),this.registryEvent()}resizeClientSize(){let{x:t,y:e,width:i,height:o}=this.container.getBoundingClientRect();this.clientSize={width:i||this.container.clientWidth,height:o||this.container.clientHeight,x:t,y:e}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=$t(t,e),this.renderer.setSize(t,e),this.control=Ut(this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var o;let i=this.control.getPolarAngle();(o=this.currentFloor)==null||o.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})}),this.cameraBound=new Gt(this)}getRatio(t=new x.Vector3(0,0,0),e=new x.Vector3(100,0,0)){let{clientWidth:i,clientHeight:o}=this.container,a=P(t,this.camera,i,o),c=P(e,this.camera,i,o);return Math.ceil(Math.sqrt(L(c.x-a.x,2)+L(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof x.AmbientLight&&(e.color=new x.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 x.Vector2;i.x=t/this.clientSize.width*2-1,i.y=e/this.clientSize.height*-2+1;let o=new x.Raycaster;return o.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(o))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var o;return((o=this.currentFloor)==null?void 0:o.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return e===0?(this.control.maxPolarAngle=t,this.control.minPolarAngle=t,this.control.update(),this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,Promise.resolve()):N(new Promise(i=>{let o={polar:this.control.getPolarAngle()},a={polar:t},c=new X.Tween(o,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxPolarAngle=o.polar,this.control.minPolarAngle=o.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}setAzimuthalAngle(t,e=500){if(e===0){this.control.maxAzimuthAngle=t,this.control.minAzimuthAngle=t,this.control.update(),this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0;return}return N(new Promise(i=>{let o={azimuthal:this.control.getAzimuthalAngle()},a={azimuthal:t},c=new X.Tween(o,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxAzimuthAngle=o.azimuthal,this.control.minAzimuthAngle=o.azimuthal,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new x.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){let o=this.getCameraLookAt(),a={zoom:this.camera.zoom,target:this.control.target.clone()};if(!i){this.camera.position.copy(e.clone().sub(o)),this.control.target.copy(e),this.camera.zoom=t,this.control.update();return}return N(new Promise(c=>{let h=new X.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(o)),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)}getFitCameraToObjectZoom(t,e=[20,20,20,20],i=500,o=!0){let[a,c,h,l]=e,{clientSize:{width:p,height:d}}=this,y=this.control.getPolarAngle();o&&this.setPolarAngle(0,0);let g=new x.Box3().setFromObject(t);this.setPolarAngle(y,0);let{max:m,min:b}=g,w=new x.Vector3(b.x,m.y,b.z),u=new x.Vector3(m.x,m.y,b.z),R=new x.Vector3(m.x,b.y,m.z),T=new x.Vector3(b.x,b.y,m.z),S=P(w,this.camera,p,d),Bt=P(u,this.camera,p,d),kt=P(T,this.camera,p,d),Tt=P(R,this.camera,p,d),Ft=new x.Box2().setFromPoints([new x.Vector2(S.x,S.y),new x.Vector2(Bt.x,Bt.y),new x.Vector2(kt.x,kt.y),new x.Vector2(Tt.x,Tt.y)]).getSize(new x.Vector2),ue=(p-c-l)/Ft.x,ge=(d-a-h)/Ft.y,fe=Math.min(ue,ge),ve=new x.Vector3((m.x+b.x)/2,(m.y+b.y)/2,0);return{zoom:fe*this.camera.zoom,center:ve}}fitCameraToObject(t,e=[20,20,20,20],i=500,o=!0){let{zoom:a,center:c}=this.getFitCameraToObjectZoom(t,e,i,o);return this.setZoom(a,c,i)}getFitCameraToGroundZoom(t=[20,20,20,20],e=500,i=!0){if(this.currentFloor&&this.currentFloor.hasElement)return this.getFitCameraToObjectZoom(this.currentFloor.groundUpper,t,e,i).zoom}fitCameraToGround(t=[20,20,20,20],e=500,i=!0){return this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundUpper,t,e,i):Promise.resolve(!1)}setCameraPosition(t,e){return N(new Promise(i=>{let o=this.camera.position.clone(),a=this.getCameraLookAt(),c=new X.Tween(o,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(o.clone().sub(a)),this.control.target.copy(o.clone()),this.control.update()}).onComplete(()=>{this.tweenGroup.remove(c),this.camera.position.copy(o.clone().sub(a)),this.control.target.copy(t.clone()),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.cameraBound.dispose(),this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),this.materialFactory.dispose(),H(this.scene)}};var he=f("lodash"),De={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},resizeObserver:!1,initTransToMark:!1,heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2,defaultPolar:1.1,defaultAzimuthal:0},defaultPadding:[20,20,20,20],svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:100},ground:{color:"#F6F6F6",opacity:1,height:.001,stroke:!1,strokeColor:"#E6E6E6",strokeOpacity:1},markGraphic:{color:"#EEF0F3",opacity:1,height:.001,stroke:!1,strokeColor:"#000",strokeOpacity:1},graphic:{fillOpacity:1},cameraBound:{padding:[150,150,150,150]},poi:{boxScale:1}};function le(n){return(0,he.merge)({},De,n)}var de=f("lodash");var Oe=(t=>(t[t.D2=0]="D2",t[t.D3=1.1]="D3",t))(Oe||{}),pe=class extends me.EventDispatcher{constructor(t,e={}){super();this.container=t;s(this,"config");s(this,"context");s(this,"polarKeys",[]);s(this,"azimuthalKeys",[]);s(this,"svgLine");s(this,"svgPolygon");s(this,"basicZoom",1);s(this,"prevCameraZoom",1);s(this,"type","2d");s(this,"floorDataMap",new Map);s(this,"buildingGroundMap",new Map);s(this,"currentBuildGround",null);s(this,"observe",null);s(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)});s(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)});s(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}});s(this,"resize",()=>{this.context.cameraBound.setEnable(!1),this.context.onWindowResize();let t=this.context.control.getAzimuthalAngle(),e=this.context.camera.zoom;this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(0,0);let i=this.context.getFitCameraToGroundZoom(void 0,0);this.basicZoom=i||0,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.camera.zoom=e,this.context.control.addEventListener("change",this.onControlChange),this.context.setAzimuthalAngle(t,0),this.context.cameraBound.setEnable(!0)});this.config=le(e),this.context=new St(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(l){return z(this,arguments,function*({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){let{apiDomain:p,apiPath:{floorGraphic:d},apiInfo:y}=this.config,g=`${p}${d}?brand=${t}&project=${e}&phase=${i}&building=${o}&floor=${a}&ts=${c}&resource_type_list=${h}`;return yield fetch(g,y).then(b=>b.json()).then(b=>b.data).then(b=>((b||[]).map(w=>w.info=JSON.parse(w.info)),b||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:o}){return`${t}-${e}-${i}-${o}`}loadBuildingGround(a){return z(this,arguments,function*({brand:t,project:e,phase:i,building:o}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:o});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:h,apiPath:{floorRange:l},apiInfo:p}=this.config,d=`${h}${l}?brand=${t}&project=${e}&phase=${i}&building=${o}`,y=yield fetch(d,p).then(g=>g.json()).then(g=>g.data).then(g=>{let m=(g||[])[0];return m&&(m.info=JSON.parse(m.info)),m});return this.buildingGroundMap.set(c,y),y})}getFloorKey({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${o}-${a}-${c}-${h}`}load(l){return z(this,arguments,function*({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h});if(this.floorDataMap.get(p))return;let[d,y]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:o})]);if(y){let w=zt(y.info.geometry.cds[0]);d.forEach(u=>{if(u.info.geometry.coords=JSON.parse(JSON.stringify(u.info.geometry.cds)),u.info.geometry.type==="polygon")u.info.geometry.coords.map(R=>{Array.isArray(R)&&R.forEach(T=>{T[0]-=w[0],T[1]-=w[1]})});else{let[R,T]=u.info.geometry.cds;u.info.geometry.coords=[R-w[0],T-w[1]]}u.info.transformToBuildingGround=!0})}let{ground:g,markGraphic:m,graphic:b}=this.config;for(let w=0;w<d.length;w++){let u=d[w];u.info.deltaHeight=1e-5*(w+1),u.info.group==="ground"?(u.info.fillColor=g.color,u.info.fillOpacity=g.opacity,u.info.height=g.height,u.info.stroke=g.stroke,u.info.strokeColor=g.strokeColor,u.info.strokeOpacity=g.strokeOpacity):u.info.userData.mark?(u.info.height=m.height,u.info.fillColor=m.color,u.info.fillOpacity=m.opacity,u.info.stroke=m.stroke,u.info.strokeColor=m.strokeColor,u.info.strokeOpacity=m.strokeOpacity):(u.info.fillOpacity=b.fillOpacity,this.config.initTransToMark&&(u.info.height=m.height,u.info.fillColor=m.color,u.info.stroke=m.stroke,u.info.strokeColor=m.strokeColor,u.info.strokeOpacity=m.strokeOpacity))}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(p,d),d})}createFloor(t){let e=new xt(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=new Map,o=[];for(let a of t)if(a.info.group==="ground")e.createGround(a.info);else{let c=e.addGraphic(a.info);c.userData.data=a,i.set(a.legacy_id,c),o.push(c)}return e.userData.legacyToGraphicMap=i,{curFloor:e,graphics:o}}switchFloor({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:o,floor:a,ts:c,resource_type_list:h}),p=this.floorDataMap.get(l);if(this.context.control.removeEventListener("change",this.onControlChange),p){let d=this.getBuildingKey({brand:t,project:e,phase:i,building:o});this.currentBuildGround=this.buildingGroundMap.get(d)||null;let y=this.createFloor(p);y?(this.context.cameraBound.setEnable(!1),this.context.switchFloor(y.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,this.context.camera.zoom=1,this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,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.type==="3d"&&this.context.fitCameraToGround(this.config.defaultPadding,0,!1),this.onControlChange(),this.context.cameraBound.setEnable(!0)):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")}addModel(t,e){var i;if(t.options.geometry.type==="polygon"){let o=(i=this.context.currentFloor)==null?void 0:i.addModel(tt(M({},e),{position:t.getPosition().setZ(.1),id:t.options.id}));if(o){let{facilityAngle:a=0,facilityXScale:c=1,facilityYScale:h=1}=t.options.userData;o.rotateZ((180-a)/180*Math.PI),o.scale.set(c,h,1)}}}addHeatmap(t){var e;return(e=this.context.currentFloor)==null?void 0:e.addHeatmap(t)}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.graphicLayer.children.filter(e=>e instanceof k))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);let i=t.getCenter();return this.context.currentFloor.addPoi(tt(M({},e),{position:tt(M({},i),{z:i.z+t.options.height/2})}))}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.getPosition();return this.context.setCameraPosition(i,e)}translateElementToCenterX(t,e=500){return z(this,null,function*(){let{y:i,z:o}=this.context.control.target,a=t.getPosition();a.setY(i),a.setZ(o),yield this.context.setCameraPosition(a,e)})}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:o}=this.container;return P(e,this.context.camera,i,o)}changeMapType(t,e=500){return this.type=t,t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(1.1,e)}resetView(t=300){return z(this,null,function*(){let e=t/3;yield this.context.setAzimuthalAngle(this.config.control.defaultAzimuthal,e),yield this.changeMapType(this.type,e),yield this.context.fitCameraToGround(this.config.defaultPadding,e,!1)})}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){if(window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp),this.config.resizeObserver){let t=new ResizeObserver((0,de.debounce)(this.resize,5));t.observe(this.container),this.observe=t}}unRegistryEvent(){var t;window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp),(t=this.observe)==null||t.disconnect(),this.observe=null}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return z(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new wt(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:o})=>{t(o)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new Pt(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:o})=>{t(o)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}getGraphicByNodeId(t){var e;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=zt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.coords=JSON.parse(JSON.stringify(t.geometry.cds)),t.geometry.coords.map(o=>{Array.isArray(o)&&o.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[o,a]=t.geometry.cds;t.geometry.coords=[o-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)||[]).filter(e=>!e.options.built_in)}clearPoi(){this.context.currentFloor&&this.context.currentFloor.poiLayer.clear()}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){this.context.dispose(),this.floorDataMap.clear(),this.buildingGroundMap.clear(),Xt(),Wt(),Jt(),this.unRegistryEvent()}};})();
27
39
  //# sourceMappingURL=bmap.min.js.map