@aibee/crc-bmap 0.13.9 → 0.13.10

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/index.cjs CHANGED
@@ -433,7 +433,7 @@
433
433
  gl_FragColor = vec4(newColor, vOpacity);
434
434
  }
435
435
  }
436
- `;return this.instancedWallMaterial=new st.ShaderMaterial({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};dt(At,"lineMaterialMap",new Map),dt(At,"meshStandardMaterialMap",new Map),dt(At,"meshBasicMaterialMap",new Map),dt(At,"shaderMaterialMap",new Map),dt(At,"line2MaterialMap",new Map),dt(At,"mergeAttributeGraphicMaterial",null),dt(At,"mergeAttributeWallMaterial",null),dt(At,"mergeAttributeGraphicLineMaterial",null),dt(At,"instancedGraphicMaterial",null),dt(At,"instancedWallMaterial",null),dt(At,"lineDashedMaterialMap",new Map);var si=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};dt(si,"keySet",new Set);function oi(a,t,e){return new Promise((i,s)=>{let o=si.genUniqueKey(),n=({data:r})=>{r.type===`${t}_result`&&r.key===o&&(si.removeKey(o),self.removeEventListener("message",n),r.error?s(r.error):i(r.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}var Ar=require("three");var Ws=class extends Ar.EventDispatcher{constructor(e=10,i){super();dt(this,"max",10);dt(this,"workerConstructor");dt(this,"pool",[]);this.max=e,this.workerConstructor=i}getWorker(){return new Promise(e=>{let i=this.pool.find(o=>o.state==="leisure");if(i){i.state="used",e(i.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let o=this.workerConstructor();this.pool.push({worker:o,state:"used"}),e(o);return}let s=()=>{let o=this.pool.find(n=>n.state==="leisure");o&&(this.removeEventListener("release",s),o.state="used",e(o.worker))};this.addEventListener("release",s)})}releaseWorker(e){let i=this.pool.find(s=>s.worker===e);i&&(i.state="leisure",this.dispatchEvent({type:"release",worker:e}))}dispose(){this._listeners={},this.pool.forEach(e=>{e.worker.terminate()}),this.pool=[]}};var xh={};function Zo(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",xh.url))}var Vi=require("three");var ni=class{static GetMergeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new Vi.BufferGeometry;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Vi.BufferAttribute(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Vi.BufferAttribute(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?Si(Si({},t[0]),i):null})}static GetMergedGeometryLine(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?Si(Si({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};dt(ni,"WorkerPool",new Ws(10,Zo));var Ki=class extends it{getCenter(){return new Ut.Box3().setFromObject(this).getCenter(new Ut.Vector3)}addInstancedGraphic(t){this.instancedGraphicConfig?(this.instancedGraphicConfig.size+=t.size,this.instancedGraphicConfig.colors=[...this.instancedGraphicConfig.colors,...t.colors],this.instancedGraphicConfig.matrixes=[...this.instancedGraphicConfig.matrixes,...t.matrixes],this.instancedGraphicConfig.opacities=[...this.instancedGraphicConfig.opacities,...t.opacities],this.instancedGraphicConfig.maxZs=[...this.instancedGraphicConfig.maxZs,...t.maxZs],this.instancedGraphicConfig.ids=[...this.instancedGraphicConfig.ids,...t.ids]):this.instancedGraphicConfig=t,this.refeshInstancedGraphic()}refeshInstancedGraphic(){this.instancedGraphic&&(this.remove(this.instancedGraphic),G(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new qe(this.context,this.instancedGraphicConfig),this.add(this.instancedGraphic))}addGraphics(t,e){t.map(i=>{this.graphicDataMap.set(i.id,i),this.graphicOriginOptionMap.set(i.id,{fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity})}),e?e.map(i=>{if(i.instancedGeometry&&this.addInstancedGraphic(i.instancedGeometry),i.mergedGeometry){let s=new ri(this.context,x({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new Ie(this.context,i.lineGeometry);this.mergedLineGroup.add(s)}}):(this.refreshMergeGraphic(),this.refreshLine())}createGraphic(t){return f(this,null,function*(){let e=yield ni.GetMergedGeometry(t);if(G(this.mergedGraphicGroup),this.mergedGraphicGroup.clear(),e){let i=new ri(this.context,e);this.mergedGraphicGroup.add(i)}})}createLine(t){return f(this,null,function*(){let e=yield ni.GetMergedGeometryLine(t);if(G(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new Ie(this.context,e.lineGeometry);this.mergedLineGroup.add(i)}})}refreshMergeGraphic(){let t=Array.from(this.graphicDataMap.values());this.instancedGraphicConfig&&(t=t.filter(e=>{var i;return!((i=this.instancedGraphicConfig)!=null&&i.ids.includes(e.id))})),this.createGraphic(t)}refreshLine(){let t=Array.from(this.graphicDataMap.values());this.createLine(t)}removeGraphicById(t){var e;if(this.graphicDataMap.delete(t),(e=this.instancedGraphicConfig)!=null&&e.ids.includes(t)){let i=this.instancedGraphicConfig.ids.findIndex(s=>s===t);this.instancedGraphicConfig.size--,this.instancedGraphicConfig.colors.splice(i*3,3),this.instancedGraphicConfig.matrixes.splice(i*16,16),this.instancedGraphicConfig.opacities.splice(i,1),this.instancedGraphicConfig.maxZs.splice(i,1),this.instancedGraphicConfig.ids.splice(i,1),this.refeshInstancedGraphic()}else this.refreshMergeGraphic();this.refreshLine()}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){var i;let s,o=this.graphicDataMap.get(t);if(o){if(typeof e=="function"?s=e(o):s=x({},o,e),this.graphicDataMap.set(t,s),(i=this.instancedGraphicConfig)!=null&&i.ids.includes(t)&&this.instancedGraphic){this.instancedGraphic.setColorById(t,s.fillColor),this.instancedGraphic.setOpacityById(t,s.fillOpacity),this.instancedGraphic.setMaxZById(t,s.deltaHeight+s.airHeight+s.height);let n=this.instancedGraphicConfig.ids.findIndex(d=>d===t),r=this.instancedGraphicConfig.matrixes.slice(n*16,(n+1)*16),h=new Ut.Matrix4().fromArray(r),c=new Ut.Vector3,l=new Ut.Quaternion,p=new Ut.Vector3;h.decompose(c,l,p),p.z=s.height,c.z=s.deltaHeight+s.airHeight+s.height/2,h.compose(c,l,p),this.instancedGraphic.setMatrixById(t,h)}else this.refreshMergeGraphic();this.refreshLine()}}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1);var i;this.graphicDataMap.forEach((s,o)=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let h=this.graphicOriginOptionMap.get(o);var n;s.fillOpacity=Math.min(t,(n=h==null?void 0:h.fillOpacity)!=null?n:1);var r;s.strokeOpacity=Math.min(t,(r=h==null?void 0:h.strokeOpacity)!=null?r:1)}}),(i=this.instancedGraphic)==null||i.setOpacity(t,e),this.refeshInstancedGraphic(),this.refreshLine()}dispose(){super.dispose(),this.mergedGraphicGroup.clear(),this.mergedLineGroup.clear(),this.instancedGraphic=null,this.instancedGraphicConfig=null}constructor(t){super(t),this.graphicMap=new Map,this.mergedGraphicGroup=new Ut.Group,this.mergedLineGroup=new Ut.Group,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};var yf=require("core-js/modules/web.dom-collections.iterator.js"),vf=require("core-js/modules/es.array.push.js");var yt=require("three");var lf=require("core-js/modules/es.string.replace.js"),pf=require("core-js/modules/es.regexp.exec.js"),df=require("core-js/modules/es.error.cause.js"),uf=require("core-js/modules/web.dom-collections.iterator.js"),Us=require("three");var Yi=class{setBaseUrl(t){this.baseUrl=t.replace(/\/$/,"")}setConfig(t){this.config=t}loadConfig(){return f(this,null,function*(){if(this.config)return this.config;if(!this.baseUrl)throw new Error("Base URL is not set");try{let t=yield fetch(""+this.baseUrl+"/config.json");return this.config=yield t.json(),this.config}catch(t){return console.error("Failed to load tile config:",t),this.config={extent:[12276734621488994e-9,2.1183542845726013e6,12279646804065457e-9,2121524247761597e-9],maxZoom:21,minZoom:11},this.config}})}buildTileUrl(t,e,i){if(!this.baseUrl)throw new Error("Base URL is not set");return this.baseUrl+"/"+i+"/"+t+"/"+e+".png"}loadTileTexture(t,e,i){return f(this,null,function*(){if(!this.baseUrl)throw new Error("Base URL is not set");let s=this.buildTileUrl(t,e,i);if(this.textureCache.has(s)){let n=this.textureCache.get(s);return n instanceof Promise?n:Promise.resolve(n)}let o=this.textureLoader.loadAsync(s).then(n=>(n.flipY=!0,n.colorSpace=Us.SRGBColorSpace,this.textureCache.set(s,n),n)).catch(n=>null);return this.textureCache.set(s,o),o})}clearCache(){this.textureCache.forEach(t=>{t instanceof Promise?t.then(e=>e==null?void 0:e.dispose()):t.dispose()}),this.textureCache.clear()}dispose(){this.clearCache()}constructor(t){this.baseUrl="",this.config=null,this.textureCache=new Map,this.textureLoader=new Us.TextureLoader,t&&this.setBaseUrl(t)}};var Ir=require("lodash");var Or={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},Re=class a extends it{loadTileConfig(){return f(this,null,function*(){return this.tileLoader.loadConfig()})}initEvents(){this.context.addEventListener("control-change",this.onUpdate),this.context.bmap.addEventListener("center-change",this.onCenterChange)}removeEvents(){this.context.removeEventListener("control-change",this.onUpdate),this.context.bmap.removeEventListener("center-change",this.onCenterChange)}getViewBounds(){let t=this.context.camera,e=new yt.Raycaster,i=new yt.Vector2,s=[],[o,n]=this.context.center||[0,0],r=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}];for(let d of r){i.set(d.x,d.y),e.setFromCamera(i,t);let u=new yt.Vector3(0,0,1),m=new yt.Vector3(0,0,0),g=new yt.Plane().setFromNormalAndCoplanarPoint(u,m),y=new yt.Vector3;e.ray.intersectPlane(g,y)?s.push(y):(e.ray.direction.negate(),e.ray.intersectPlane(g,y)&&s.push(y))}if(s.length<4)return null;let h=1/0,c=1/0,l=-1/0,p=-1/0;return s.forEach(d=>{h=Math.min(h,d.x+o),c=Math.min(c,d.y+n),l=Math.max(l,d.x+o),p=Math.max(p,d.y+n)}),{minX:h,minY:c,maxX:l,maxY:p}}getTileZoomLevel(t,e){let{minZoom:i,maxZoom:s}=e,o=this.context.camera,n=(o.right-o.left)/o.zoom,r=this.context.clientSize.width,h=n/r,c=a.WORLD_WIDTH,l=Math.log2(c/(h*this.tileSize));return Math.min(s,Math.max(i,Math.round(l)))}getTilesInView(t,e,i){let[s,o,n,r]=i.extent,h=Math.max(t.minX,s),c=Math.max(t.minY,o),l=Math.min(t.maxX,n),p=Math.min(t.maxY,r);if(h>=l||c>=p)return[];let d=Math.pow(2,e),u=a.WORLD_WIDTH/d,m=a.WORLD_WIDTH_HALF,g=Math.max(0,Math.floor((h+m)/u)),y=Math.floor((l+m)/u),w=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),_=[];for(let k=g;k<=y;k++)for(let D=w;D<=M;D++)_.push({x:k,y:D,z:e});return _}renderTiles(t,e){return f(this,null,function*(){let i=t,s=[];if(this.currentLevel!==e)s=[...this.tileGroup.children];else{let r=this.tileGroup.children,h=r.map(l=>l.userData.key),c=t.map(l=>l.z+"/"+l.x+"/"+l.y);i=t.filter(l=>!h.includes(l.z+"/"+l.x+"/"+l.y)),s=r.filter(l=>!c.includes(l.userData.key))}let o=Math.pow(2,e),n=a.WORLD_WIDTH/o;yield Promise.all(i.map(r=>f(this,null,function*(){let h=r.z+"/"+r.x+"/"+r.y,c=yield this.tileLoader.loadTileTexture(r.x,r.y,r.z);if(c){let l=new yt.MeshBasicMaterial({map:c,transparent:!0}),p=new yt.Mesh(this.baseGeometry,l);p.scale.setX(n).setY(n),p.position.set((r.x-o/2)*n+n/2,-((r.y-o/2)*n)-n/2,0),p.userData.key=h,this.tileGroup.add(p)}}))),this.tileGroup.children.forEach(r=>{s.includes(r)&&(r.material.dispose(),this.tileGroup.remove(r))})})}setVisibility(t){this.visible=t,t&&this.onUpdate()}setOpacity(t){super.setOpacity(t)}clearTiles(){this.tileGroup.children.forEach(t=>{t.material.dispose()}),this.tileGroup.clear()}dispose(){this.removeEvents(),this.clearTiles(),this.baseGeometry.dispose(),this.tileLoader.dispose(),super.dispose()}constructor(t,e){super(t),this.loadedTiles=new Map,this.currentLevel=0,this.tileSize=256,this.baseGeometry=new yt.PlaneGeometry(1,1),this.options=Or,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=(0,Ir.debounce)(()=>f(this,null,function*(){if(!this.visible)return;let s=yield this.loadTileConfig(),o=this.context.camera,n=this.getViewBounds();if(!n)return;let r=this.getTileZoomLevel(o.zoom,s),h=this.getTilesInView(n,r,s);this.renderTiles(h,r)}),100),this.options=x({},Or,e),this.tileGroup=new yt.Group;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Yi(this.options.base_url),this.initEvents(),this.updateTiles()}};Re.WORLD_WIDTH=4007501668e-2;Re.WORLD_WIDTH_HALF=Re.WORLD_WIDTH/2;var bf=require("core-js/modules/es.array.push.js"),Sf=require("core-js/modules/web.dom-collections.iterator.js"),Ef=require("core-js/modules/es.string.trim.js");var Et=require("three");var Fe=require("lodash");var wh={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1},rt=class extends Et.Object3D{get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){return this.hasText?this.options.text_font_size*this.textureLines:0}get hasOriginTexture(){let{text_texture:t,text_texture_width:e,text_texture_height:i,text_texture_offset_x:s,text_texture_offset_y:o}=this.options;return!(0,Fe.isNil)(t)&&!(0,Fe.isNil)(e)&&!(0,Fe.isNil)(i)&&!(0,Fe.isNil)(s)&&!(0,Fe.isNil)(o)}get inited(){return!this.options.text||this.options.text&&this.textTexture}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&this._shouldShow}show(){return f(this,null,function*(){if(this._shouldShow)return;this._shouldShow=!0;let t=[];if(!this.spriteIcon&&this.options.icon&&t.push(this.initIcon()),!this.spriteText&&this.hasText&&t.push(this.initText()),yield Promise.all(t),!this._shouldShow){this.hide();return}this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.spriteIcon&&(this.spriteIcon.visible=!0),this.spriteText&&(this.spriteText.visible=!0)})}hide(){this._shouldShow=!1,this.spriteIcon&&(this.remove(this.spriteIcon),this.spriteIcon.material.dispose(),this.spriteIcon=void 0),this.spriteText&&(this.remove(this.spriteText),this.spriteText.material.dispose(),this.spriteText=void 0)}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text_font_size",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show())})),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;this._initScale({zoom:this.context.camera.zoom}),this.options.icon&&this.context.forceUpdate()}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.depthTest=e),this.spriteText&&(this.spriteText.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;this.spriteText&&(this.spriteText.material.opacity=e)})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return f(this,null,function*(){if(this.options.icon)return this._initIconPromise=new Promise(t=>f(this,null,function*(){let e;if(this.options.icon_border){let{icon:s,icon_size:o,icon_border:n}=this.options;e=yield ft.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield ft.getTextureByUrl(this.options.icon);let i=new Et.Sprite(new Et.SpriteMaterial({map:e,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));i.visible=!1,i.renderOrder=1e5+this.options.level,e.needsUpdate=!0,this.add(i),this.spriteIcon=i,t(i)})).then(()=>{this._initIconPromise=null})})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;if(!t)return;let e=new Et.Sprite(new Et.SpriteMaterial({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,opacity:this.options.text_opacity}));e.visible=!1,e.renderOrder=100001+this.options.level,t.needsUpdate=!0,this.spriteText=e,this.add(e)}})}initSize(){var t,e;let i=0,s=0,{icon:o}=this.options;o?this.hasText?(i=0,s=i*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(i=.5,s=0):this.hasText?(s=.5,i=0):(i=0,s=0),(t=this.spriteIcon)==null||t.center.set(.5,i),(e=this.spriteText)==null||e.center.set(.5,s)}init(){return f(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.spriteText&&(this.spriteText.position.z=t)}getBox(t){if(!this.inited)return this.initTextTexture(),null;let{clientSize:{width:e,height:i}}=this.context,s=e*(t.x+1)/2,o=i*(-t.y+1)/2;o+=this.offset*(this.iconHeight+this.durIconAndText+this.textHeight);let n=this.iconWidth/2,r=new Et.Box2(new Et.Vector2(s-n,o-this.iconHeight),new Et.Vector2(s+n,o)),h=this.textWidth/2,c=new Et.Box2(new Et.Vector2(s-h,o-this.textHeight-this.durIconAndText-this.iconHeight),new Et.Vector2(s+h,o-this.iconHeight-this.durIconAndText));return this.box=c.union(r),this.box}renderBoxHelper(t,e){if(!this.boxHelper){let i=document.createElement("div");i.style.position="absolute",i.style.zIndex="999",i.style.border="1px solid red",i.style.pointerEvents="none",this.boxHelper=i,this.context.container.appendChild(i)}t&&e?(this.boxHelper.style.left=t+"px",this.boxHelper.style.top=e+"px",this.boxHelper.style.width="2px",this.boxHelper.style.height="2px"):(this.boxHelper.style.left=this.box.min.x+"px",this.boxHelper.style.top=this.box.min.y+"px",this.boxHelper.style.width=this.box.max.x-this.box.min.x+"px",this.boxHelper.style.height=this.box.max.y-this.box.min.y+"px")}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.textAspect=1,this.box=new Et.Box2,this._initIconPromise=null,this.textureLines=1,this._shouldShow=!1,this.initTextTexture=(0,Fe.once)(()=>f(this,null,function*(){if(!this.options.text||this.textTexture)return;let o;if(this.hasOriginTexture){let{text_texture:n,text_texture_width:r,text_texture_height:h,text_texture_offset_x:c,text_texture_offset_y:l}=this.options;o=this.options.text_texture.clone(),o.uuid=n.uuid,o.offset.set(c/o.image.width,1-(h+l)/o.image.height),o.repeat.set(r/o.image.width,h/o.image.height),this.textAspect=r/h}else{let n=yield mt.getTextureByText(this.options.text);o=n.texture,this.textureLines=n.lines,this.textAspect=o.image.width/o.image.height}this.textTexture=o,this.dispatchEvent({type:"text-texture-inited"})})),this._initScale=o=>{let{zoom:n}=o;if(this.spriteText){let h=this.textHeight/n;this.spriteText.scale.set(this.textAspect*h,h,.1)}if(this.spriteIcon){var r;(r=this.spriteIcon)==null||r.scale.set(this.options.icon_size[0]/n,this.options.icon_size[1]/n,.1)}this.resetZ()};var s;this.options=He(x({},wh,e,{text:(s=(i=e.text)==null?void 0:i.trim())!=null?s:""}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent()}};var se=class extends Rt.Object3D{getPosition(){return this.box.getCenter(new Rt.Vector3)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new gt(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundLayer.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.groundUpper.position.z=this.groundMaxHeight+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new Rt.Box3().setFromObject(this).getCenter(new Rt.Vector3)}addModel(t){let e=new Bi(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new Rt.Box3().setFromObject(this.groundUpper),e=t.getCenter(new Rt.Vector3),i=t.getSize(new Rt.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new rt(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}addHeatmap(t){this.heatmap||(this.heatmap=new zi(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new Rt.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z+.1),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}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}getParkingOptionsByParkingNo(t){return this.parkingSpaceLayer.getParkingOptionsByParkingNo(t)}updateBox(){this.box.setFromObject(this.groundLayer)}getGraphics(){return this.graphicLayer.children.filter(t=>t instanceof gt)}setOpacity(t,e){e===void 0&&(e=!1),this.groundLayer.setOpacity(t,e),this.graphicLayer.setOpacity(t,e),this.mergeGraphicLayer.setOpacity(t,e),this.poiLayer2.setOpacity(t),this.parkingSpaceLayer.setOpacity(t,e),this.laneLayer.setOpacity(t,e),this.wallLayer.setOpacity(t,e),this.textureLayer.setOpacity(t),this.textTextureLayer.setOpacity(t),this.glbModelLayer.setOpacity(t,e),this.userData.opacity=t}dispose(){var t;console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.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()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Gi,this.groundUpper=new Rt.Object3D,this.models=new Rt.Object3D,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new Rt.Box3,this.groundLayer=new it(this.context),this.graphicLayer=new Wi(this.context),this.poiLayer=new Ui(this.context),this.poiLayer2=new Hi(this.context),this.parkingSpaceLayer=new Ni(this.context),this.wallLayer=new it(this.context),this.textureLayer=new it(this.context),this.glbModelLayer=new Zi(this.context),this.laneLayer=new it(this.context),this.mergeGraphicLayer=new Ki(this.context),this.textTextureLayer=new it(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};var Yf=require("core-js/modules/es.array.push.js"),Xf=require("core-js/modules/web.dom-collections.iterator.js");var Hs=require("three");var Ht=class extends Hs.EventDispatcher{_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:s,offsetY:o}=t,{clientWidth:n,clientHeight:r}=i.domElement,h=s/n*2-1,c=1-o/r*2;return new Hs.Vector3(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return O(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.points=[],this.enable=!0,this._onResize=e=>{let{width:i,height:s}=e;this.svg&&(this.svg.setAttribute("width",""+i),this.svg.setAttribute("height",""+s))},this.svg=Po(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Xi=class extends Ht{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:s}]=this.points;return Math.sqrt((i-t)**2+(s-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.onUpdate=()=>{if(this.points[0]){let s=this.getSvgCoordinate(this.points[0]);Ce(this.circles[0],s.x,s.y),Yt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);Ce(this.circles[1],s.x,s.y),Yt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",Yt(this.line,void 0,{x:s.offsetX,y:s.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=s=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(s);if(o){let{offsetX:n,offsetY:r}=s,h=this.circles[this.points.length];Ce(h,n,r),this.points.length||Yt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[ti(e.radius,e.fill),ti(e.radius,e.fill)],this.line=Ti(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};var Qf=require("core-js/modules/es.array.push.js");var qi=class extends Ht{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],s=+i.getAttribute("cx"),o=+i.getAttribute("cy");return Math.sqrt((t-s)**2+(e-o)**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(s=>[s.x,s.y]),e=0,i=t.length;for(let s=0;s<i;s++){let o=(s+1)%i;e+=t[s][0]*t[o][1]-t[o][0]*t[s][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,i)=>{let s=this.getSvgCoordinate(e);this.circles[i]&&Ce(this.circles[i],s.x,s.y),i!==0&&Yt(this.lines[i-1],void 0,s),this.lines[i]&&Yt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",Yt(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let i=this.getIntersectByPointerEvent(e);if(i){let{offsetX:s,offsetY:o}=e;this.checkAdsorb(s,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(i);let{circle:{fill:n,radius:r},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let c=ti(r,n);Ce(c,s,o),this.addCircle(c)}if(this.lines.length&&Yt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=Ti(h);Yt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};var Rr=require("three");var jo=class extends Ht{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=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let i=new Rr.Box3().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=O(r,s,o,n),l=O(h,s,o,n);Ct(this.rect,c.x,l.y,Math.abs(l.x-c.x),Math.abs(l.y-c.y));let{x:p,y:d}=c,{x:u,y:m}=l,g=5,y=[{x:p-g,y:m-g},{x:u-g,y:m-g},{x:p-g,y:d-g},{x:u-g,y:d-g}];for(let D=0;D<y.length;D++)Ct(this.cornerRect[D],y[D].x,y[D].y,g*2,g*2);let w=4,M=(p+u)/2,_=(d+m)/2,k=[{x:M-w,y:m-w},{x:p-w,y:_-w},{x:u-w,y:_-w},{x:M-w,y:d-w}];for(let D=0;D<k.length;D++)Ct(this.centerRect[D],k[D].x,k[D].y,w*2,w*2)}else{Ct(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)Ct(this.cornerRect[i],0,0,0,0),Ct(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=Me(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Me(e.stroke,"#ffffff"),this.centerRect[i]=Me(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}};var rg=require("core-js/modules/es.array.push.js"),Lt=require("three");var Fr=require("three/examples/jsm/utils/BufferGeometryUtils.js");var $i=class extends Lt.Object3D{initGeometry(){return f(this,null,function*(){let t=yield ie.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
436
+ `;return this.instancedWallMaterial=new st.ShaderMaterial({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};dt(At,"lineMaterialMap",new Map),dt(At,"meshStandardMaterialMap",new Map),dt(At,"meshBasicMaterialMap",new Map),dt(At,"shaderMaterialMap",new Map),dt(At,"line2MaterialMap",new Map),dt(At,"mergeAttributeGraphicMaterial",null),dt(At,"mergeAttributeWallMaterial",null),dt(At,"mergeAttributeGraphicLineMaterial",null),dt(At,"instancedGraphicMaterial",null),dt(At,"instancedWallMaterial",null),dt(At,"lineDashedMaterialMap",new Map);var si=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};dt(si,"keySet",new Set);function oi(a,t,e){return new Promise((i,s)=>{let o=si.genUniqueKey(),n=({data:r})=>{r.type===`${t}_result`&&r.key===o&&(si.removeKey(o),self.removeEventListener("message",n),r.error?s(r.error):i(r.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}var Ar=require("three");var Ws=class extends Ar.EventDispatcher{constructor(e=10,i){super();dt(this,"max",10);dt(this,"workerConstructor");dt(this,"pool",[]);this.max=e,this.workerConstructor=i}getWorker(){return new Promise(e=>{let i=this.pool.find(o=>o.state==="leisure");if(i){i.state="used",e(i.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let o=this.workerConstructor();this.pool.push({worker:o,state:"used"}),e(o);return}let s=()=>{let o=this.pool.find(n=>n.state==="leisure");o&&(this.removeEventListener("release",s),o.state="used",e(o.worker))};this.addEventListener("release",s)})}releaseWorker(e){let i=this.pool.find(s=>s.worker===e);i&&(i.state="leisure",this.dispatchEvent({type:"release",worker:e}))}dispose(){this._listeners={},this.pool.forEach(e=>{e.worker.terminate()}),this.pool=[]}};var xh={};function Zo(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",xh.url))}var Vi=require("three");var ni=class{static GetMergeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new Vi.BufferGeometry;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Vi.BufferAttribute(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Vi.BufferAttribute(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?Si(Si({},t[0]),i):null})}static GetMergedGeometryLine(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield oi(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?Si(Si({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};dt(ni,"WorkerPool",new Ws(10,Zo));var Ki=class extends it{getCenter(){return new Ut.Box3().setFromObject(this).getCenter(new Ut.Vector3)}addInstancedGraphic(t){this.instancedGraphicConfig?(this.instancedGraphicConfig.size+=t.size,this.instancedGraphicConfig.colors=[...this.instancedGraphicConfig.colors,...t.colors],this.instancedGraphicConfig.matrixes=[...this.instancedGraphicConfig.matrixes,...t.matrixes],this.instancedGraphicConfig.opacities=[...this.instancedGraphicConfig.opacities,...t.opacities],this.instancedGraphicConfig.maxZs=[...this.instancedGraphicConfig.maxZs,...t.maxZs],this.instancedGraphicConfig.ids=[...this.instancedGraphicConfig.ids,...t.ids]):this.instancedGraphicConfig=t,this.refeshInstancedGraphic()}refeshInstancedGraphic(){this.instancedGraphic&&(this.remove(this.instancedGraphic),G(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new qe(this.context,this.instancedGraphicConfig),this.add(this.instancedGraphic))}addGraphics(t,e){t.map(i=>{this.graphicDataMap.set(i.id,i),this.graphicOriginOptionMap.set(i.id,{fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity})}),e?e.map(i=>{if(i.instancedGeometry&&this.addInstancedGraphic(i.instancedGeometry),i.mergedGeometry){let s=new ri(this.context,x({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new Ie(this.context,i.lineGeometry);this.mergedLineGroup.add(s)}}):(this.refreshMergeGraphic(),this.refreshLine())}createGraphic(t){return f(this,null,function*(){let e=yield ni.GetMergedGeometry(t);if(G(this.mergedGraphicGroup),this.mergedGraphicGroup.clear(),e){let i=new ri(this.context,e);this.mergedGraphicGroup.add(i)}})}createLine(t){return f(this,null,function*(){let e=yield ni.GetMergedGeometryLine(t);if(G(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new Ie(this.context,e.lineGeometry);this.mergedLineGroup.add(i)}})}refreshMergeGraphic(){let t=Array.from(this.graphicDataMap.values());this.instancedGraphicConfig&&(t=t.filter(e=>{var i;return!((i=this.instancedGraphicConfig)!=null&&i.ids.includes(e.id))})),this.createGraphic(t)}refreshLine(){let t=Array.from(this.graphicDataMap.values());this.createLine(t)}removeGraphicById(t){var e;if(this.graphicDataMap.delete(t),(e=this.instancedGraphicConfig)!=null&&e.ids.includes(t)){let i=this.instancedGraphicConfig.ids.findIndex(s=>s===t);this.instancedGraphicConfig.size--,this.instancedGraphicConfig.colors.splice(i*3,3),this.instancedGraphicConfig.matrixes.splice(i*16,16),this.instancedGraphicConfig.opacities.splice(i,1),this.instancedGraphicConfig.maxZs.splice(i,1),this.instancedGraphicConfig.ids.splice(i,1),this.refeshInstancedGraphic()}else this.refreshMergeGraphic();this.refreshLine()}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){var i;let s,o=this.graphicDataMap.get(t);if(o){if(typeof e=="function"?s=e(o):s=x({},o,e),this.graphicDataMap.set(t,s),(i=this.instancedGraphicConfig)!=null&&i.ids.includes(t)&&this.instancedGraphic){this.instancedGraphic.setColorById(t,s.fillColor),this.instancedGraphic.setOpacityById(t,s.fillOpacity),this.instancedGraphic.setMaxZById(t,s.deltaHeight+s.airHeight+s.height);let n=this.instancedGraphicConfig.ids.findIndex(d=>d===t),r=this.instancedGraphicConfig.matrixes.slice(n*16,(n+1)*16),h=new Ut.Matrix4().fromArray(r),c=new Ut.Vector3,l=new Ut.Quaternion,p=new Ut.Vector3;h.decompose(c,l,p),p.z=s.height,c.z=s.deltaHeight+s.airHeight+s.height/2,h.compose(c,l,p),this.instancedGraphic.setMatrixById(t,h)}else this.refreshMergeGraphic();this.refreshLine()}}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1);var i;this.graphicDataMap.forEach((s,o)=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let h=this.graphicOriginOptionMap.get(o);var n;s.fillOpacity=Math.min(t,(n=h==null?void 0:h.fillOpacity)!=null?n:1);var r;s.strokeOpacity=Math.min(t,(r=h==null?void 0:h.strokeOpacity)!=null?r:1)}}),(i=this.instancedGraphic)==null||i.setOpacity(t,e),this.refeshInstancedGraphic(),this.refreshLine()}dispose(){super.dispose(),this.mergedGraphicGroup.clear(),this.mergedLineGroup.clear(),this.instancedGraphic=null,this.instancedGraphicConfig=null}constructor(t){super(t),this.graphicMap=new Map,this.mergedGraphicGroup=new Ut.Group,this.mergedLineGroup=new Ut.Group,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};var yf=require("core-js/modules/web.dom-collections.iterator.js"),vf=require("core-js/modules/es.array.push.js");var yt=require("three");var lf=require("core-js/modules/es.string.replace.js"),pf=require("core-js/modules/es.regexp.exec.js"),df=require("core-js/modules/es.error.cause.js"),uf=require("core-js/modules/web.dom-collections.iterator.js"),Us=require("three");var Yi=class{setBaseUrl(t){this.baseUrl=t.replace(/\/$/,"")}setConfig(t){this.config=t}loadConfig(){return f(this,null,function*(){if(this.config)return this.config;if(!this.baseUrl)throw new Error("Base URL is not set");try{let t=yield fetch(""+this.baseUrl+"/config.json");return this.config=yield t.json(),this.config}catch(t){return console.error("Failed to load tile config:",t),this.config={extent:[12276734621488994e-9,2.1183542845726013e6,12279646804065457e-9,2121524247761597e-9],maxZoom:21,minZoom:11},this.config}})}buildTileUrl(t,e,i){if(!this.baseUrl)throw new Error("Base URL is not set");return this.baseUrl+"/"+i+"/"+t+"/"+e+".png"}loadTileTexture(t,e,i){return f(this,null,function*(){if(!this.baseUrl)throw new Error("Base URL is not set");let s=this.buildTileUrl(t,e,i);if(this.textureCache.has(s)){let n=this.textureCache.get(s);return n instanceof Promise?n:Promise.resolve(n)}let o=this.textureLoader.loadAsync(s).then(n=>(n.flipY=!0,n.colorSpace=Us.SRGBColorSpace,this.textureCache.set(s,n),n)).catch(n=>null);return this.textureCache.set(s,o),o})}clearCache(){this.textureCache.forEach(t=>{t instanceof Promise?t.then(e=>e==null?void 0:e.dispose()):t.dispose()}),this.textureCache.clear()}dispose(){this.clearCache()}constructor(t){this.baseUrl="",this.config=null,this.textureCache=new Map,this.textureLoader=new Us.TextureLoader,t&&this.setBaseUrl(t)}};var Ir=require("lodash");var Or={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},Re=class a extends it{loadTileConfig(){return f(this,null,function*(){return this.tileLoader.loadConfig()})}initEvents(){this.context.addEventListener("control-change",this.onUpdate),this.context.bmap.addEventListener("center-change",this.onCenterChange)}removeEvents(){this.context.removeEventListener("control-change",this.onUpdate),this.context.bmap.removeEventListener("center-change",this.onCenterChange)}getViewBounds(){let t=this.context.camera,e=new yt.Raycaster,i=new yt.Vector2,s=[],[o,n]=this.context.center||[0,0],r=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}];for(let d of r){i.set(d.x,d.y),e.setFromCamera(i,t);let u=new yt.Vector3(0,0,1),m=new yt.Vector3(0,0,0),g=new yt.Plane().setFromNormalAndCoplanarPoint(u,m),y=new yt.Vector3;e.ray.intersectPlane(g,y)?s.push(y):(e.ray.direction.negate(),e.ray.intersectPlane(g,y)&&s.push(y))}if(s.length<4)return null;let h=1/0,c=1/0,l=-1/0,p=-1/0;return s.forEach(d=>{h=Math.min(h,d.x+o),c=Math.min(c,d.y+n),l=Math.max(l,d.x+o),p=Math.max(p,d.y+n)}),{minX:h,minY:c,maxX:l,maxY:p}}getTileZoomLevel(t,e){let{minZoom:i,maxZoom:s}=e,o=this.context.camera,n=(o.right-o.left)/o.zoom,r=this.context.clientSize.width,h=n/r,c=a.WORLD_WIDTH,l=Math.log2(c/(h*this.tileSize));return Math.min(s,Math.max(i,Math.round(l)))}getTilesInView(t,e,i){let[s,o,n,r]=i.extent,h=Math.max(t.minX,s),c=Math.max(t.minY,o),l=Math.min(t.maxX,n),p=Math.min(t.maxY,r);if(h>=l||c>=p)return[];let d=Math.pow(2,e),u=a.WORLD_WIDTH/d,m=a.WORLD_WIDTH_HALF,g=Math.max(0,Math.floor((h+m)/u)),y=Math.floor((l+m)/u),w=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),_=[];for(let k=g;k<=y;k++)for(let D=w;D<=M;D++)_.push({x:k,y:D,z:e});return _}renderTiles(t,e){return f(this,null,function*(){let i=t,s=[];if(this.currentLevel!==e)s=[...this.tileGroup.children];else{let r=this.tileGroup.children,h=r.map(l=>l.userData.key),c=t.map(l=>l.z+"/"+l.x+"/"+l.y);i=t.filter(l=>!h.includes(l.z+"/"+l.x+"/"+l.y)),s=r.filter(l=>!c.includes(l.userData.key))}let o=Math.pow(2,e),n=a.WORLD_WIDTH/o;yield Promise.all(i.map(r=>f(this,null,function*(){let h=r.z+"/"+r.x+"/"+r.y,c=yield this.tileLoader.loadTileTexture(r.x,r.y,r.z);if(c){let l=new yt.MeshBasicMaterial({map:c,transparent:!0}),p=new yt.Mesh(this.baseGeometry,l);p.scale.setX(n).setY(n),p.position.set((r.x-o/2)*n+n/2,-((r.y-o/2)*n)-n/2,0),p.userData.key=h,this.tileGroup.add(p)}}))),this.tileGroup.children.forEach(r=>{s.includes(r)&&(r.material.dispose(),this.tileGroup.remove(r))})})}setVisibility(t){this.visible=t,t&&this.onUpdate()}setOpacity(t){super.setOpacity(t)}clearTiles(){this.tileGroup.children.forEach(t=>{t.material.dispose()}),this.tileGroup.clear()}dispose(){this.removeEvents(),this.clearTiles(),this.baseGeometry.dispose(),this.tileLoader.dispose(),super.dispose()}constructor(t,e){super(t),this.loadedTiles=new Map,this.currentLevel=0,this.tileSize=256,this.baseGeometry=new yt.PlaneGeometry(1,1),this.options=Or,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=(0,Ir.debounce)(()=>f(this,null,function*(){if(!this.visible)return;let s=yield this.loadTileConfig(),o=this.context.camera,n=this.getViewBounds();if(!n)return;let r=this.getTileZoomLevel(o.zoom,s),h=this.getTilesInView(n,r,s);this.renderTiles(h,r)}),100),this.options=x({},Or,e),this.tileGroup=new yt.Group;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Yi(this.options.base_url),this.initEvents(),this.updateTiles()}};Re.WORLD_WIDTH=4007501668e-2;Re.WORLD_WIDTH_HALF=Re.WORLD_WIDTH/2;var bf=require("core-js/modules/es.array.push.js"),Sf=require("core-js/modules/web.dom-collections.iterator.js"),Ef=require("core-js/modules/es.string.trim.js");var Et=require("three");var Fe=require("lodash");var wh={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1},rt=class extends Et.Object3D{get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){return this.hasText?this.options.text_font_size*this.textureLines:0}get hasOriginTexture(){let{text_texture:t,text_texture_width:e,text_texture_height:i,text_texture_offset_x:s,text_texture_offset_y:o}=this.options;return!(0,Fe.isNil)(t)&&!(0,Fe.isNil)(e)&&!(0,Fe.isNil)(i)&&!(0,Fe.isNil)(s)&&!(0,Fe.isNil)(o)}get inited(){return!this.options.text||this.options.text&&this.textTexture}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&this._shouldShow}show(){return f(this,null,function*(){if(this._shouldShow)return;this._shouldShow=!0;let t=[];if(!this.spriteIcon&&this.options.icon&&t.push(this.initIcon()),!this.spriteText&&this.hasText&&t.push(this.initText()),yield Promise.all(t),!this._shouldShow){this.hide();return}this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.spriteIcon&&(this.spriteIcon.visible=!0),this.spriteText&&(this.spriteText.visible=!0)})}hide(){this._shouldShow=!1,this.spriteIcon&&(this.remove(this.spriteIcon),this.spriteIcon.material.dispose(),this.spriteIcon=void 0),this.spriteText&&(this.remove(this.spriteText),this.spriteText.material.dispose(),this.spriteText=void 0)}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text_font_size",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate()})),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;this._initScale({zoom:this.context.camera.zoom}),this.initSize(),this.options.icon&&this.context.forceUpdate()}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.depthTest=e),this.spriteText&&(this.spriteText.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;this.spriteText&&(this.spriteText.material.opacity=e)})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return f(this,null,function*(){if(this.options.icon)return this._initIconPromise=new Promise(t=>f(this,null,function*(){let e;if(this.options.icon_border){let{icon:s,icon_size:o,icon_border:n}=this.options;e=yield ft.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield ft.getTextureByUrl(this.options.icon);let i=new Et.Sprite(new Et.SpriteMaterial({map:e,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));i.visible=!1,i.renderOrder=1e5+this.options.level,e.needsUpdate=!0,this.add(i),this.spriteIcon=i,t(i)})).then(()=>{this._initIconPromise=null})})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;if(!t)return;let e=new Et.Sprite(new Et.SpriteMaterial({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,opacity:this.options.text_opacity}));e.visible=!1,e.renderOrder=100001+this.options.level,t.needsUpdate=!0,this.spriteText=e,this.add(e)}})}initSize(){var t,e;let i=0,s=0,{icon:o}=this.options;o?this.hasText?(i=0,s=i*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(i=.5,s=0):this.hasText?(s=.5,i=0):(i=0,s=0),(t=this.spriteIcon)==null||t.center.set(.5,i),(e=this.spriteText)==null||e.center.set(.5,s)}init(){return f(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.spriteText&&(this.spriteText.position.z=t)}getBox(t){if(!this.inited)return this.initTextTexture(),null;let{clientSize:{width:e,height:i}}=this.context,s=e*(t.x+1)/2,o=i*(-t.y+1)/2;o+=this.offset*(this.iconHeight+this.durIconAndText+this.textHeight);let n=this.iconWidth/2,r=new Et.Box2(new Et.Vector2(s-n,o-this.iconHeight),new Et.Vector2(s+n,o)),h=this.textWidth/2,c=new Et.Box2(new Et.Vector2(s-h,o-this.textHeight-this.durIconAndText-this.iconHeight),new Et.Vector2(s+h,o-this.iconHeight-this.durIconAndText));return this.box=c.union(r),this.box}renderBoxHelper(t,e){if(!this.boxHelper){let i=document.createElement("div");i.style.position="absolute",i.style.zIndex="999",i.style.border="1px solid red",i.style.pointerEvents="none",this.boxHelper=i,this.context.container.appendChild(i)}t&&e?(this.boxHelper.style.left=t+"px",this.boxHelper.style.top=e+"px",this.boxHelper.style.width="2px",this.boxHelper.style.height="2px"):(this.boxHelper.style.left=this.box.min.x+"px",this.boxHelper.style.top=this.box.min.y+"px",this.boxHelper.style.width=this.box.max.x-this.box.min.x+"px",this.boxHelper.style.height=this.box.max.y-this.box.min.y+"px")}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.textAspect=1,this.box=new Et.Box2,this._initIconPromise=null,this.textureLines=1,this._shouldShow=!1,this.initTextTexture=(0,Fe.once)(()=>f(this,null,function*(){if(!this.options.text||this.textTexture)return;let o;if(this.hasOriginTexture){let{text_texture:n,text_texture_width:r,text_texture_height:h,text_texture_offset_x:c,text_texture_offset_y:l}=this.options;o=this.options.text_texture.clone(),o.uuid=n.uuid,o.offset.set(c/o.image.width,1-(h+l)/o.image.height),o.repeat.set(r/o.image.width,h/o.image.height),this.textAspect=r/h}else{let n=yield mt.getTextureByText(this.options.text);o=n.texture,this.textureLines=n.lines,this.textAspect=o.image.width/o.image.height}this.textTexture=o,this.dispatchEvent({type:"text-texture-inited"})})),this._initScale=o=>{let{zoom:n}=o;if(this.spriteText){let h=this.textHeight/n;this.spriteText.scale.set(this.textAspect*h,h,.1)}if(this.spriteIcon){var r;(r=this.spriteIcon)==null||r.scale.set(this.options.icon_size[0]/n,this.options.icon_size[1]/n,.1)}this.resetZ()};var s;this.options=He(x({},wh,e,{text:(s=(i=e.text)==null?void 0:i.trim())!=null?s:""}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent()}};var se=class extends Rt.Object3D{getPosition(){return this.box.getCenter(new Rt.Vector3)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new gt(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundLayer.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.groundUpper.position.z=this.groundMaxHeight+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new Rt.Box3().setFromObject(this).getCenter(new Rt.Vector3)}addModel(t){let e=new Bi(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new Rt.Box3().setFromObject(this.groundUpper),e=t.getCenter(new Rt.Vector3),i=t.getSize(new Rt.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new rt(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}addHeatmap(t){this.heatmap||(this.heatmap=new zi(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new Rt.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z+.1),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}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}getParkingOptionsByParkingNo(t){return this.parkingSpaceLayer.getParkingOptionsByParkingNo(t)}updateBox(){this.box.setFromObject(this.groundLayer)}getGraphics(){return this.graphicLayer.children.filter(t=>t instanceof gt)}setOpacity(t,e){e===void 0&&(e=!1),this.groundLayer.setOpacity(t,e),this.graphicLayer.setOpacity(t,e),this.mergeGraphicLayer.setOpacity(t,e),this.poiLayer2.setOpacity(t),this.parkingSpaceLayer.setOpacity(t,e),this.laneLayer.setOpacity(t,e),this.wallLayer.setOpacity(t,e),this.textureLayer.setOpacity(t),this.textTextureLayer.setOpacity(t),this.glbModelLayer.setOpacity(t,e),this.userData.opacity=t}dispose(){var t;console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.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()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Gi,this.groundUpper=new Rt.Object3D,this.models=new Rt.Object3D,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new Rt.Box3,this.groundLayer=new it(this.context),this.graphicLayer=new Wi(this.context),this.poiLayer=new Ui(this.context),this.poiLayer2=new Hi(this.context),this.parkingSpaceLayer=new Ni(this.context),this.wallLayer=new it(this.context),this.textureLayer=new it(this.context),this.glbModelLayer=new Zi(this.context),this.laneLayer=new it(this.context),this.mergeGraphicLayer=new Ki(this.context),this.textTextureLayer=new it(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};var Yf=require("core-js/modules/es.array.push.js"),Xf=require("core-js/modules/web.dom-collections.iterator.js");var Hs=require("three");var Ht=class extends Hs.EventDispatcher{_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:s,offsetY:o}=t,{clientWidth:n,clientHeight:r}=i.domElement,h=s/n*2-1,c=1-o/r*2;return new Hs.Vector3(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return O(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.points=[],this.enable=!0,this._onResize=e=>{let{width:i,height:s}=e;this.svg&&(this.svg.setAttribute("width",""+i),this.svg.setAttribute("height",""+s))},this.svg=Po(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Xi=class extends Ht{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:s}]=this.points;return Math.sqrt((i-t)**2+(s-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.onUpdate=()=>{if(this.points[0]){let s=this.getSvgCoordinate(this.points[0]);Ce(this.circles[0],s.x,s.y),Yt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);Ce(this.circles[1],s.x,s.y),Yt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",Yt(this.line,void 0,{x:s.offsetX,y:s.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=s=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(s);if(o){let{offsetX:n,offsetY:r}=s,h=this.circles[this.points.length];Ce(h,n,r),this.points.length||Yt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[ti(e.radius,e.fill),ti(e.radius,e.fill)],this.line=Ti(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};var Qf=require("core-js/modules/es.array.push.js");var qi=class extends Ht{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],s=+i.getAttribute("cx"),o=+i.getAttribute("cy");return Math.sqrt((t-s)**2+(e-o)**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(s=>[s.x,s.y]),e=0,i=t.length;for(let s=0;s<i;s++){let o=(s+1)%i;e+=t[s][0]*t[o][1]-t[o][0]*t[s][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,i)=>{let s=this.getSvgCoordinate(e);this.circles[i]&&Ce(this.circles[i],s.x,s.y),i!==0&&Yt(this.lines[i-1],void 0,s),this.lines[i]&&Yt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",Yt(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let i=this.getIntersectByPointerEvent(e);if(i){let{offsetX:s,offsetY:o}=e;this.checkAdsorb(s,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(i);let{circle:{fill:n,radius:r},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let c=ti(r,n);Ce(c,s,o),this.addCircle(c)}if(this.lines.length&&Yt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=Ti(h);Yt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};var Rr=require("three");var jo=class extends Ht{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=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let i=new Rr.Box3().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=O(r,s,o,n),l=O(h,s,o,n);Ct(this.rect,c.x,l.y,Math.abs(l.x-c.x),Math.abs(l.y-c.y));let{x:p,y:d}=c,{x:u,y:m}=l,g=5,y=[{x:p-g,y:m-g},{x:u-g,y:m-g},{x:p-g,y:d-g},{x:u-g,y:d-g}];for(let D=0;D<y.length;D++)Ct(this.cornerRect[D],y[D].x,y[D].y,g*2,g*2);let w=4,M=(p+u)/2,_=(d+m)/2,k=[{x:M-w,y:m-w},{x:p-w,y:_-w},{x:u-w,y:_-w},{x:M-w,y:d-w}];for(let D=0;D<k.length;D++)Ct(this.centerRect[D],k[D].x,k[D].y,w*2,w*2)}else{Ct(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)Ct(this.cornerRect[i],0,0,0,0),Ct(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=Me(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=Me(e.stroke,"#ffffff"),this.centerRect[i]=Me(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}};var rg=require("core-js/modules/es.array.push.js"),Lt=require("three");var Fr=require("three/examples/jsm/utils/BufferGeometryUtils.js");var $i=class extends Lt.Object3D{initGeometry(){return f(this,null,function*(){let t=yield ie.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
437
437
  varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
438
438
  uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
439
439
  uniform vec3 uColor;
@@ -433,7 +433,7 @@ var sa=Object.create;var Fs=Object.defineProperty;var oa=Object.getOwnPropertyDe
433
433
  gl_FragColor = vec4(newColor, vOpacity);
434
434
  }
435
435
  }
436
- `;return this.instancedWallMaterial=new Ee({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};Q(lt,"lineMaterialMap",new Map),Q(lt,"meshStandardMaterialMap",new Map),Q(lt,"meshBasicMaterialMap",new Map),Q(lt,"shaderMaterialMap",new Map),Q(lt,"line2MaterialMap",new Map),Q(lt,"mergeAttributeGraphicMaterial",null),Q(lt,"mergeAttributeWallMaterial",null),Q(lt,"mergeAttributeGraphicLineMaterial",null),Q(lt,"instancedGraphicMaterial",null),Q(lt,"instancedWallMaterial",null),Q(lt,"lineDashedMaterialMap",new Map);var Le=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};Q(Le,"keySet",new Set);function Ce(a,t,e){return new Promise((i,s)=>{let o=Le.genUniqueKey(),n=({data:r})=>{r.type===`${t}_result`&&r.key===o&&(Le.removeKey(o),self.removeEventListener("message",n),r.error?s(r.error):i(r.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}import{EventDispatcher as Kh}from"three";var Ri=class extends Kh{constructor(e=10,i){super();Q(this,"max",10);Q(this,"workerConstructor");Q(this,"pool",[]);this.max=e,this.workerConstructor=i}getWorker(){return new Promise(e=>{let i=this.pool.find(o=>o.state==="leisure");if(i){i.state="used",e(i.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let o=this.workerConstructor();this.pool.push({worker:o,state:"used"}),e(o);return}let s=()=>{let o=this.pool.find(n=>n.state==="leisure");o&&(this.removeEventListener("release",s),o.state="used",e(o.worker))};this.addEventListener("release",s)})}releaseWorker(e){let i=this.pool.find(s=>s.worker===e);i&&(i.state="leisure",this.dispatchEvent({type:"release",worker:e}))}dispose(){this._listeners={},this.pool.forEach(e=>{e.worker.terminate()}),this.pool=[]}};function so(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",import.meta.url))}import{BufferGeometry as Yh,BufferAttribute as Bn}from"three";var Te=class{static GetMergeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new Yh;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Bn(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Bn(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static GetMergedGeometryLine(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};Q(Te,"WorkerPool",new Ri(10,so));var Fi=class extends Y{getCenter(){return new Xh().setFromObject(this).getCenter(new oo)}addInstancedGraphic(t){this.instancedGraphicConfig?(this.instancedGraphicConfig.size+=t.size,this.instancedGraphicConfig.colors=[...this.instancedGraphicConfig.colors,...t.colors],this.instancedGraphicConfig.matrixes=[...this.instancedGraphicConfig.matrixes,...t.matrixes],this.instancedGraphicConfig.opacities=[...this.instancedGraphicConfig.opacities,...t.opacities],this.instancedGraphicConfig.maxZs=[...this.instancedGraphicConfig.maxZs,...t.maxZs],this.instancedGraphicConfig.ids=[...this.instancedGraphicConfig.ids,...t.ids]):this.instancedGraphicConfig=t,this.refeshInstancedGraphic()}refeshInstancedGraphic(){this.instancedGraphic&&(this.remove(this.instancedGraphic),I(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new Se(this.context,this.instancedGraphicConfig),this.add(this.instancedGraphic))}addGraphics(t,e){t.map(i=>{this.graphicDataMap.set(i.id,i),this.graphicOriginOptionMap.set(i.id,{fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity})}),e?e.map(i=>{if(i.instancedGeometry&&this.addInstancedGraphic(i.instancedGeometry),i.mergedGeometry){let s=new Ye(this.context,x({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new pe(this.context,i.lineGeometry);this.mergedLineGroup.add(s)}}):(this.refreshMergeGraphic(),this.refreshLine())}createGraphic(t){return f(this,null,function*(){let e=yield Te.GetMergedGeometry(t);if(I(this.mergedGraphicGroup),this.mergedGraphicGroup.clear(),e){let i=new Ye(this.context,e);this.mergedGraphicGroup.add(i)}})}createLine(t){return f(this,null,function*(){let e=yield Te.GetMergedGeometryLine(t);if(I(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new pe(this.context,e.lineGeometry);this.mergedLineGroup.add(i)}})}refreshMergeGraphic(){let t=Array.from(this.graphicDataMap.values());this.instancedGraphicConfig&&(t=t.filter(e=>{var i;return!((i=this.instancedGraphicConfig)!=null&&i.ids.includes(e.id))})),this.createGraphic(t)}refreshLine(){let t=Array.from(this.graphicDataMap.values());this.createLine(t)}removeGraphicById(t){var e;if(this.graphicDataMap.delete(t),(e=this.instancedGraphicConfig)!=null&&e.ids.includes(t)){let i=this.instancedGraphicConfig.ids.findIndex(s=>s===t);this.instancedGraphicConfig.size--,this.instancedGraphicConfig.colors.splice(i*3,3),this.instancedGraphicConfig.matrixes.splice(i*16,16),this.instancedGraphicConfig.opacities.splice(i,1),this.instancedGraphicConfig.maxZs.splice(i,1),this.instancedGraphicConfig.ids.splice(i,1),this.refeshInstancedGraphic()}else this.refreshMergeGraphic();this.refreshLine()}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){var i;let s,o=this.graphicDataMap.get(t);if(o){if(typeof e=="function"?s=e(o):s=x({},o,e),this.graphicDataMap.set(t,s),(i=this.instancedGraphicConfig)!=null&&i.ids.includes(t)&&this.instancedGraphic){this.instancedGraphic.setColorById(t,s.fillColor),this.instancedGraphic.setOpacityById(t,s.fillOpacity),this.instancedGraphic.setMaxZById(t,s.deltaHeight+s.airHeight+s.height);let n=this.instancedGraphicConfig.ids.findIndex(d=>d===t),r=this.instancedGraphicConfig.matrixes.slice(n*16,(n+1)*16),h=new qh().fromArray(r),c=new oo,l=new $h,p=new oo;h.decompose(c,l,p),p.z=s.height,c.z=s.deltaHeight+s.airHeight+s.height/2,h.compose(c,l,p),this.instancedGraphic.setMatrixById(t,h)}else this.refreshMergeGraphic();this.refreshLine()}}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1);var i;this.graphicDataMap.forEach((s,o)=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let h=this.graphicOriginOptionMap.get(o);var n;s.fillOpacity=Math.min(t,(n=h==null?void 0:h.fillOpacity)!=null?n:1);var r;s.strokeOpacity=Math.min(t,(r=h==null?void 0:h.strokeOpacity)!=null?r:1)}}),(i=this.instancedGraphic)==null||i.setOpacity(t,e),this.refeshInstancedGraphic(),this.refreshLine()}dispose(){super.dispose(),this.mergedGraphicGroup.clear(),this.mergedLineGroup.clear(),this.instancedGraphic=null,this.instancedGraphicConfig=null}constructor(t){super(t),this.graphicMap=new Map,this.mergedGraphicGroup=new Wn,this.mergedLineGroup=new Wn,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Group as tc,Mesh as ec,MeshBasicMaterial as ic,PlaneGeometry as sc,Vector2 as oc,Vector3 as no,Raycaster as nc,Plane as rc}from"three";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-collections.iterator.js";import{SRGBColorSpace as Jh,TextureLoader as Qh}from"three";var Gi=class{setBaseUrl(t){this.baseUrl=t.replace(/\/$/,"")}setConfig(t){this.config=t}loadConfig(){return f(this,null,function*(){if(this.config)return this.config;if(!this.baseUrl)throw new Error("Base URL is not set");try{let t=yield fetch(""+this.baseUrl+"/config.json");return this.config=yield t.json(),this.config}catch(t){return console.error("Failed to load tile config:",t),this.config={extent:[12276734621488994e-9,2.1183542845726013e6,12279646804065457e-9,2121524247761597e-9],maxZoom:21,minZoom:11},this.config}})}buildTileUrl(t,e,i){if(!this.baseUrl)throw new Error("Base URL is not set");return this.baseUrl+"/"+i+"/"+t+"/"+e+".png"}loadTileTexture(t,e,i){return f(this,null,function*(){if(!this.baseUrl)throw new Error("Base URL is not set");let s=this.buildTileUrl(t,e,i);if(this.textureCache.has(s)){let n=this.textureCache.get(s);return n instanceof Promise?n:Promise.resolve(n)}let o=this.textureLoader.loadAsync(s).then(n=>(n.flipY=!0,n.colorSpace=Jh,this.textureCache.set(s,n),n)).catch(n=>null);return this.textureCache.set(s,o),o})}clearCache(){this.textureCache.forEach(t=>{t instanceof Promise?t.then(e=>e==null?void 0:e.dispose()):t.dispose()}),this.textureCache.clear()}dispose(){this.clearCache()}constructor(t){this.baseUrl="",this.config=null,this.textureCache=new Map,this.textureLoader=new Qh,t&&this.setBaseUrl(t)}};import{debounce as ac}from"lodash";var Un={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},de=class a extends Y{loadTileConfig(){return f(this,null,function*(){return this.tileLoader.loadConfig()})}initEvents(){this.context.addEventListener("control-change",this.onUpdate),this.context.bmap.addEventListener("center-change",this.onCenterChange)}removeEvents(){this.context.removeEventListener("control-change",this.onUpdate),this.context.bmap.removeEventListener("center-change",this.onCenterChange)}getViewBounds(){let t=this.context.camera,e=new nc,i=new oc,s=[],[o,n]=this.context.center||[0,0],r=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}];for(let d of r){i.set(d.x,d.y),e.setFromCamera(i,t);let u=new no(0,0,1),m=new no(0,0,0),g=new rc().setFromNormalAndCoplanarPoint(u,m),y=new no;e.ray.intersectPlane(g,y)?s.push(y):(e.ray.direction.negate(),e.ray.intersectPlane(g,y)&&s.push(y))}if(s.length<4)return null;let h=1/0,c=1/0,l=-1/0,p=-1/0;return s.forEach(d=>{h=Math.min(h,d.x+o),c=Math.min(c,d.y+n),l=Math.max(l,d.x+o),p=Math.max(p,d.y+n)}),{minX:h,minY:c,maxX:l,maxY:p}}getTileZoomLevel(t,e){let{minZoom:i,maxZoom:s}=e,o=this.context.camera,n=(o.right-o.left)/o.zoom,r=this.context.clientSize.width,h=n/r,c=a.WORLD_WIDTH,l=Math.log2(c/(h*this.tileSize));return Math.min(s,Math.max(i,Math.round(l)))}getTilesInView(t,e,i){let[s,o,n,r]=i.extent,h=Math.max(t.minX,s),c=Math.max(t.minY,o),l=Math.min(t.maxX,n),p=Math.min(t.maxY,r);if(h>=l||c>=p)return[];let d=Math.pow(2,e),u=a.WORLD_WIDTH/d,m=a.WORLD_WIDTH_HALF,g=Math.max(0,Math.floor((h+m)/u)),y=Math.floor((l+m)/u),w=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),_=[];for(let L=g;L<=y;L++)for(let C=w;C<=M;C++)_.push({x:L,y:C,z:e});return _}renderTiles(t,e){return f(this,null,function*(){let i=t,s=[];if(this.currentLevel!==e)s=[...this.tileGroup.children];else{let r=this.tileGroup.children,h=r.map(l=>l.userData.key),c=t.map(l=>l.z+"/"+l.x+"/"+l.y);i=t.filter(l=>!h.includes(l.z+"/"+l.x+"/"+l.y)),s=r.filter(l=>!c.includes(l.userData.key))}let o=Math.pow(2,e),n=a.WORLD_WIDTH/o;yield Promise.all(i.map(r=>f(this,null,function*(){let h=r.z+"/"+r.x+"/"+r.y,c=yield this.tileLoader.loadTileTexture(r.x,r.y,r.z);if(c){let l=new ic({map:c,transparent:!0}),p=new ec(this.baseGeometry,l);p.scale.setX(n).setY(n),p.position.set((r.x-o/2)*n+n/2,-((r.y-o/2)*n)-n/2,0),p.userData.key=h,this.tileGroup.add(p)}}))),this.tileGroup.children.forEach(r=>{s.includes(r)&&(r.material.dispose(),this.tileGroup.remove(r))})})}setVisibility(t){this.visible=t,t&&this.onUpdate()}setOpacity(t){super.setOpacity(t)}clearTiles(){this.tileGroup.children.forEach(t=>{t.material.dispose()}),this.tileGroup.clear()}dispose(){this.removeEvents(),this.clearTiles(),this.baseGeometry.dispose(),this.tileLoader.dispose(),super.dispose()}constructor(t,e){super(t),this.loadedTiles=new Map,this.currentLevel=0,this.tileSize=256,this.baseGeometry=new sc(1,1),this.options=Un,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=ac(()=>f(this,null,function*(){if(!this.visible)return;let s=yield this.loadTileConfig(),o=this.context.camera,n=this.getViewBounds();if(!n)return;let r=this.getTileZoomLevel(o.zoom,s),h=this.getTilesInView(n,r,s);this.renderTiles(h,r)}),100),this.options=x({},Un,e),this.tileGroup=new tc;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Gi(this.options.base_url),this.initEvents(),this.updateTiles()}};de.WORLD_WIDTH=4007501668e-2;de.WORLD_WIDTH_HALF=de.WORLD_WIDTH/2;import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.string.trim.js";import{Box2 as ro,Object3D as hc,Sprite as Hn,SpriteMaterial as Nn,Vector2 as zi}from"three";import{isNil as Xe,once as cc}from"lodash";var lc={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1},J=class extends hc{get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){return this.hasText?this.options.text_font_size*this.textureLines:0}get hasOriginTexture(){let{text_texture:t,text_texture_width:e,text_texture_height:i,text_texture_offset_x:s,text_texture_offset_y:o}=this.options;return!Xe(t)&&!Xe(e)&&!Xe(i)&&!Xe(s)&&!Xe(o)}get inited(){return!this.options.text||this.options.text&&this.textTexture}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&this._shouldShow}show(){return f(this,null,function*(){if(this._shouldShow)return;this._shouldShow=!0;let t=[];if(!this.spriteIcon&&this.options.icon&&t.push(this.initIcon()),!this.spriteText&&this.hasText&&t.push(this.initText()),yield Promise.all(t),!this._shouldShow){this.hide();return}this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.spriteIcon&&(this.spriteIcon.visible=!0),this.spriteText&&(this.spriteText.visible=!0)})}hide(){this._shouldShow=!1,this.spriteIcon&&(this.remove(this.spriteIcon),this.spriteIcon.material.dispose(),this.spriteIcon=void 0),this.spriteText&&(this.remove(this.spriteText),this.spriteText.material.dispose(),this.spriteText=void 0)}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text_font_size",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show())})),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;this._initScale({zoom:this.context.camera.zoom}),this.options.icon&&this.context.forceUpdate()}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.depthTest=e),this.spriteText&&(this.spriteText.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;this.spriteText&&(this.spriteText.material.opacity=e)})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return f(this,null,function*(){if(this.options.icon)return this._initIconPromise=new Promise(t=>f(this,null,function*(){let e;if(this.options.icon_border){let{icon:s,icon_size:o,icon_border:n}=this.options;e=yield st.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield st.getTextureByUrl(this.options.icon);let i=new Hn(new Nn({map:e,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));i.visible=!1,i.renderOrder=1e5+this.options.level,e.needsUpdate=!0,this.add(i),this.spriteIcon=i,t(i)})).then(()=>{this._initIconPromise=null})})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;if(!t)return;let e=new Hn(new Nn({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,opacity:this.options.text_opacity}));e.visible=!1,e.renderOrder=100001+this.options.level,t.needsUpdate=!0,this.spriteText=e,this.add(e)}})}initSize(){var t,e;let i=0,s=0,{icon:o}=this.options;o?this.hasText?(i=0,s=i*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(i=.5,s=0):this.hasText?(s=.5,i=0):(i=0,s=0),(t=this.spriteIcon)==null||t.center.set(.5,i),(e=this.spriteText)==null||e.center.set(.5,s)}init(){return f(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.spriteText&&(this.spriteText.position.z=t)}getBox(t){if(!this.inited)return this.initTextTexture(),null;let{clientSize:{width:e,height:i}}=this.context,s=e*(t.x+1)/2,o=i*(-t.y+1)/2;o+=this.offset*(this.iconHeight+this.durIconAndText+this.textHeight);let n=this.iconWidth/2,r=new ro(new zi(s-n,o-this.iconHeight),new zi(s+n,o)),h=this.textWidth/2,c=new ro(new zi(s-h,o-this.textHeight-this.durIconAndText-this.iconHeight),new zi(s+h,o-this.iconHeight-this.durIconAndText));return this.box=c.union(r),this.box}renderBoxHelper(t,e){if(!this.boxHelper){let i=document.createElement("div");i.style.position="absolute",i.style.zIndex="999",i.style.border="1px solid red",i.style.pointerEvents="none",this.boxHelper=i,this.context.container.appendChild(i)}t&&e?(this.boxHelper.style.left=t+"px",this.boxHelper.style.top=e+"px",this.boxHelper.style.width="2px",this.boxHelper.style.height="2px"):(this.boxHelper.style.left=this.box.min.x+"px",this.boxHelper.style.top=this.box.min.y+"px",this.boxHelper.style.width=this.box.max.x-this.box.min.x+"px",this.boxHelper.style.height=this.box.max.y-this.box.min.y+"px")}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.textAspect=1,this.box=new ro,this._initIconPromise=null,this.textureLines=1,this._shouldShow=!1,this.initTextTexture=cc(()=>f(this,null,function*(){if(!this.options.text||this.textTexture)return;let o;if(this.hasOriginTexture){let{text_texture:n,text_texture_width:r,text_texture_height:h,text_texture_offset_x:c,text_texture_offset_y:l}=this.options;o=this.options.text_texture.clone(),o.uuid=n.uuid,o.offset.set(c/o.image.width,1-(h+l)/o.image.height),o.repeat.set(r/o.image.width,h/o.image.height),this.textAspect=r/h}else{let n=yield et.getTextureByText(this.options.text);o=n.texture,this.textureLines=n.lines,this.textAspect=o.image.width/o.image.height}this.textTexture=o,this.dispatchEvent({type:"text-texture-inited"})})),this._initScale=o=>{let{zoom:n}=o;if(this.spriteText){let h=this.textHeight/n;this.spriteText.scale.set(this.textAspect*h,h,.1)}if(this.spriteIcon){var r;(r=this.spriteIcon)==null||r.scale.set(this.options.icon_size[0]/n,this.options.icon_size[1]/n,.1)}this.resetZ()};var s;this.options=fe(x({},lc,e,{text:(s=(i=e.text)==null?void 0:i.trim())!=null?s:""}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent()}};var At=class extends ao{getPosition(){return this.box.getCenter(new Wi)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new ot(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundLayer.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.groundUpper.position.z=this.groundMaxHeight+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new Bi().setFromObject(this).getCenter(new Wi)}addModel(t){let e=new Ci(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new Bi().setFromObject(this.groundUpper),e=t.getCenter(new Wi),i=t.getSize(new Wi);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new J(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}addHeatmap(t){this.heatmap||(this.heatmap=new Li(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new Bi().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z+.1),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}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}getParkingOptionsByParkingNo(t){return this.parkingSpaceLayer.getParkingOptionsByParkingNo(t)}updateBox(){this.box.setFromObject(this.groundLayer)}getGraphics(){return this.graphicLayer.children.filter(t=>t instanceof ot)}setOpacity(t,e){e===void 0&&(e=!1),this.groundLayer.setOpacity(t,e),this.graphicLayer.setOpacity(t,e),this.mergeGraphicLayer.setOpacity(t,e),this.poiLayer2.setOpacity(t),this.parkingSpaceLayer.setOpacity(t,e),this.laneLayer.setOpacity(t,e),this.wallLayer.setOpacity(t,e),this.textureLayer.setOpacity(t),this.textTextureLayer.setOpacity(t),this.glbModelLayer.setOpacity(t,e),this.userData.opacity=t}dispose(){var t;console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.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()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Ei,this.groundUpper=new ao,this.models=new ao,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new Bi,this.groundLayer=new Y(this.context),this.graphicLayer=new Ti(this.context),this.poiLayer=new ki(this.context),this.poiLayer2=new Di(this.context),this.parkingSpaceLayer=new Ai(this.context),this.wallLayer=new Y(this.context),this.textureLayer=new Y(this.context),this.glbModelLayer=new Oi(this.context),this.laneLayer=new Y(this.context),this.mergeGraphicLayer=new Fi(this.context),this.textTextureLayer=new Y(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as pc,Vector3 as dc}from"three";var wt=class extends pc{_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:s,offsetY:o}=t,{clientWidth:n,clientHeight:r}=i.domElement,h=s/n*2-1,c=1-o/r*2;return new dc(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return D(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.points=[],this.enable=!0,this._onResize=e=>{let{width:i,height:s}=e;this.svg&&(this.svg.setAttribute("width",""+i),this.svg.setAttribute("height",""+s))},this.svg=Ho(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Ui=class extends wt{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:s}]=this.points;return Math.sqrt((i-t)**2+(s-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.onUpdate=()=>{if(this.points[0]){let s=this.getSvgCoordinate(this.points[0]);oe(this.circles[0],s.x,s.y),_t(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);oe(this.circles[1],s.x,s.y),_t(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",_t(this.line,void 0,{x:s.offsetX,y:s.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=s=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(s);if(o){let{offsetX:n,offsetY:r}=s,h=this.circles[this.points.length];oe(h,n,r),this.points.length||_t(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Ue(e.radius,e.fill),Ue(e.radius,e.fill)],this.line=di(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};import"core-js/modules/es.array.push.js";var Hi=class extends wt{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],s=+i.getAttribute("cx"),o=+i.getAttribute("cy");return Math.sqrt((t-s)**2+(e-o)**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(s=>[s.x,s.y]),e=0,i=t.length;for(let s=0;s<i;s++){let o=(s+1)%i;e+=t[s][0]*t[o][1]-t[o][0]*t[s][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,i)=>{let s=this.getSvgCoordinate(e);this.circles[i]&&oe(this.circles[i],s.x,s.y),i!==0&&_t(this.lines[i-1],void 0,s),this.lines[i]&&_t(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",_t(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let i=this.getIntersectByPointerEvent(e);if(i){let{offsetX:s,offsetY:o}=e;this.checkAdsorb(s,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(i);let{circle:{fill:n,radius:r},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let c=Ue(r,n);oe(c,s,o),this.addCircle(c)}if(this.lines.length&&_t(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=di(h);_t(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};import{Box3 as uc}from"three";var Zn=class extends wt{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=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let i=new uc().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=D(r,s,o,n),l=D(h,s,o,n);ht(this.rect,c.x,l.y,Math.abs(l.x-c.x),Math.abs(l.y-c.y));let{x:p,y:d}=c,{x:u,y:m}=l,g=5,y=[{x:p-g,y:m-g},{x:u-g,y:m-g},{x:p-g,y:d-g},{x:u-g,y:d-g}];for(let C=0;C<y.length;C++)ht(this.cornerRect[C],y[C].x,y[C].y,g*2,g*2);let w=4,M=(p+u)/2,_=(d+m)/2,L=[{x:M-w,y:m-w},{x:p-w,y:_-w},{x:u-w,y:_-w},{x:M-w,y:d-w}];for(let C=0;C<L.length;C++)ht(this.centerRect[C],L[C].x,L[C].y,w*2,w*2)}else{ht(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)ht(this.cornerRect[i],0,0,0,0),ht(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=$t(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=$t(e.stroke,"#ffffff"),this.centerRect[i]=$t(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}};import"core-js/modules/es.array.push.js";import{BufferGeometry as mc,Color as ho,LineSegments as fc,Mesh as gc,Object3D as yc,ShaderMaterial as vc,Vector3 as jn}from"three";import{mergeGeometries as xc}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ni=class extends yc{initGeometry(){return f(this,null,function*(){let t=yield bt.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
436
+ `;return this.instancedWallMaterial=new Ee({vertexShader:t,fragmentShader:e,transparent:!0})}static dispose(){this.lineMaterialMap.forEach((t,e)=>{t.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((t,e)=>{t.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((t,e)=>{t.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((t,e)=>{t.dispose()}),this.line2MaterialMap.clear(),this.lineDashedMaterialMap.forEach(t=>{t.dispose()}),this.lineDashedMaterialMap.clear(),this.mergeAttributeGraphicMaterial&&(this.mergeAttributeGraphicMaterial.dispose(),this.mergeAttributeGraphicMaterial=null),this.mergeAttributeWallMaterial&&(this.mergeAttributeWallMaterial.dispose(),this.mergeAttributeWallMaterial=null),this.mergeAttributeGraphicLineMaterial&&(this.mergeAttributeGraphicLineMaterial.dispose(),this.mergeAttributeGraphicLineMaterial=null),this.instancedGraphicMaterial&&(this.instancedGraphicMaterial.dispose(),this.instancedGraphicMaterial=null),this.instancedWallMaterial&&(this.instancedWallMaterial.dispose(),this.instancedWallMaterial=null)}};Q(lt,"lineMaterialMap",new Map),Q(lt,"meshStandardMaterialMap",new Map),Q(lt,"meshBasicMaterialMap",new Map),Q(lt,"shaderMaterialMap",new Map),Q(lt,"line2MaterialMap",new Map),Q(lt,"mergeAttributeGraphicMaterial",null),Q(lt,"mergeAttributeWallMaterial",null),Q(lt,"mergeAttributeGraphicLineMaterial",null),Q(lt,"instancedGraphicMaterial",null),Q(lt,"instancedWallMaterial",null),Q(lt,"lineDashedMaterialMap",new Map);var Le=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};Q(Le,"keySet",new Set);function Ce(a,t,e){return new Promise((i,s)=>{let o=Le.genUniqueKey(),n=({data:r})=>{r.type===`${t}_result`&&r.key===o&&(Le.removeKey(o),self.removeEventListener("message",n),r.error?s(r.error):i(r.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}import{EventDispatcher as Kh}from"three";var Ri=class extends Kh{constructor(e=10,i){super();Q(this,"max",10);Q(this,"workerConstructor");Q(this,"pool",[]);this.max=e,this.workerConstructor=i}getWorker(){return new Promise(e=>{let i=this.pool.find(o=>o.state==="leisure");if(i){i.state="used",e(i.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let o=this.workerConstructor();this.pool.push({worker:o,state:"used"}),e(o);return}let s=()=>{let o=this.pool.find(n=>n.state==="leisure");o&&(this.removeEventListener("release",s),o.state="used",e(o.worker))};this.addEventListener("release",s)})}releaseWorker(e){let i=this.pool.find(s=>s.worker===e);i&&(i.state="leisure",this.dispatchEvent({type:"release",worker:e}))}dispose(){this._listeners={},this.pool.forEach(e=>{e.worker.terminate()}),this.pool=[]}};function so(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",import.meta.url))}import{BufferGeometry as Yh,BufferAttribute as Bn}from"three";var Te=class{static GetMergeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedShapeGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetMergedTexture2dGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_texture2d_shape_geometry_attributes",{data:t}),s=this.GetBufferGeometryByData(i);return this.WorkerPool.releaseWorker(e),s})}static GetBufferGeometryByData(t){let e=new Yh;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Bn(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Bn(t.index.array,t.index.itemSize)),e.morphAttributes=t.morphAttributes,e.morphTargetsRelative=t.morphTargetsRelative,e.groups=t.groups,e.boundingSphere=t.boundingSphere,e}static GetMergedGeometry(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_geometries_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static GetMergedGeometryLine(t){return f(this,null,function*(){let e=yield this.WorkerPool.getWorker(),i=yield Ce(e,"get_merged_geometries_line_json",{data:t});return this.WorkerPool.releaseWorker(e),i?We(We({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};Q(Te,"WorkerPool",new Ri(10,so));var Fi=class extends Y{getCenter(){return new Xh().setFromObject(this).getCenter(new oo)}addInstancedGraphic(t){this.instancedGraphicConfig?(this.instancedGraphicConfig.size+=t.size,this.instancedGraphicConfig.colors=[...this.instancedGraphicConfig.colors,...t.colors],this.instancedGraphicConfig.matrixes=[...this.instancedGraphicConfig.matrixes,...t.matrixes],this.instancedGraphicConfig.opacities=[...this.instancedGraphicConfig.opacities,...t.opacities],this.instancedGraphicConfig.maxZs=[...this.instancedGraphicConfig.maxZs,...t.maxZs],this.instancedGraphicConfig.ids=[...this.instancedGraphicConfig.ids,...t.ids]):this.instancedGraphicConfig=t,this.refeshInstancedGraphic()}refeshInstancedGraphic(){this.instancedGraphic&&(this.remove(this.instancedGraphic),I(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new Se(this.context,this.instancedGraphicConfig),this.add(this.instancedGraphic))}addGraphics(t,e){t.map(i=>{this.graphicDataMap.set(i.id,i),this.graphicOriginOptionMap.set(i.id,{fillOpacity:i.fillOpacity,strokeOpacity:i.strokeOpacity})}),e?e.map(i=>{if(i.instancedGeometry&&this.addInstancedGraphic(i.instancedGeometry),i.mergedGeometry){let s=new Ye(this.context,x({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new pe(this.context,i.lineGeometry);this.mergedLineGroup.add(s)}}):(this.refreshMergeGraphic(),this.refreshLine())}createGraphic(t){return f(this,null,function*(){let e=yield Te.GetMergedGeometry(t);if(I(this.mergedGraphicGroup),this.mergedGraphicGroup.clear(),e){let i=new Ye(this.context,e);this.mergedGraphicGroup.add(i)}})}createLine(t){return f(this,null,function*(){let e=yield Te.GetMergedGeometryLine(t);if(I(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new pe(this.context,e.lineGeometry);this.mergedLineGroup.add(i)}})}refreshMergeGraphic(){let t=Array.from(this.graphicDataMap.values());this.instancedGraphicConfig&&(t=t.filter(e=>{var i;return!((i=this.instancedGraphicConfig)!=null&&i.ids.includes(e.id))})),this.createGraphic(t)}refreshLine(){let t=Array.from(this.graphicDataMap.values());this.createLine(t)}removeGraphicById(t){var e;if(this.graphicDataMap.delete(t),(e=this.instancedGraphicConfig)!=null&&e.ids.includes(t)){let i=this.instancedGraphicConfig.ids.findIndex(s=>s===t);this.instancedGraphicConfig.size--,this.instancedGraphicConfig.colors.splice(i*3,3),this.instancedGraphicConfig.matrixes.splice(i*16,16),this.instancedGraphicConfig.opacities.splice(i,1),this.instancedGraphicConfig.maxZs.splice(i,1),this.instancedGraphicConfig.ids.splice(i,1),this.refeshInstancedGraphic()}else this.refreshMergeGraphic();this.refreshLine()}getGraphicDataByNodeId(t){return this.graphicMap.get(t)||null}setGraphicOptions(t,e){var i;let s,o=this.graphicDataMap.get(t);if(o){if(typeof e=="function"?s=e(o):s=x({},o,e),this.graphicDataMap.set(t,s),(i=this.instancedGraphicConfig)!=null&&i.ids.includes(t)&&this.instancedGraphic){this.instancedGraphic.setColorById(t,s.fillColor),this.instancedGraphic.setOpacityById(t,s.fillOpacity),this.instancedGraphic.setMaxZById(t,s.deltaHeight+s.airHeight+s.height);let n=this.instancedGraphicConfig.ids.findIndex(d=>d===t),r=this.instancedGraphicConfig.matrixes.slice(n*16,(n+1)*16),h=new qh().fromArray(r),c=new oo,l=new $h,p=new oo;h.decompose(c,l,p),p.z=s.height,c.z=s.deltaHeight+s.airHeight+s.height/2,h.compose(c,l,p),this.instancedGraphic.setMatrixById(t,h)}else this.refreshMergeGraphic();this.refreshLine()}}getGraphicPosition(t){let e=this.graphicDataMap.get(t);return e?[e.center_x,e.center_y]:null}setOpacity(t,e){e===void 0&&(e=!1);var i;this.graphicDataMap.forEach((s,o)=>{if(e)s.fillOpacity=t,s.strokeOpacity=t;else{let h=this.graphicOriginOptionMap.get(o);var n;s.fillOpacity=Math.min(t,(n=h==null?void 0:h.fillOpacity)!=null?n:1);var r;s.strokeOpacity=Math.min(t,(r=h==null?void 0:h.strokeOpacity)!=null?r:1)}}),(i=this.instancedGraphic)==null||i.setOpacity(t,e),this.refeshInstancedGraphic(),this.refreshLine()}dispose(){super.dispose(),this.mergedGraphicGroup.clear(),this.mergedLineGroup.clear(),this.instancedGraphic=null,this.instancedGraphicConfig=null}constructor(t){super(t),this.graphicMap=new Map,this.mergedGraphicGroup=new Wn,this.mergedLineGroup=new Wn,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Group as tc,Mesh as ec,MeshBasicMaterial as ic,PlaneGeometry as sc,Vector2 as oc,Vector3 as no,Raycaster as nc,Plane as rc}from"three";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.error.cause.js";import"core-js/modules/web.dom-collections.iterator.js";import{SRGBColorSpace as Jh,TextureLoader as Qh}from"three";var Gi=class{setBaseUrl(t){this.baseUrl=t.replace(/\/$/,"")}setConfig(t){this.config=t}loadConfig(){return f(this,null,function*(){if(this.config)return this.config;if(!this.baseUrl)throw new Error("Base URL is not set");try{let t=yield fetch(""+this.baseUrl+"/config.json");return this.config=yield t.json(),this.config}catch(t){return console.error("Failed to load tile config:",t),this.config={extent:[12276734621488994e-9,2.1183542845726013e6,12279646804065457e-9,2121524247761597e-9],maxZoom:21,minZoom:11},this.config}})}buildTileUrl(t,e,i){if(!this.baseUrl)throw new Error("Base URL is not set");return this.baseUrl+"/"+i+"/"+t+"/"+e+".png"}loadTileTexture(t,e,i){return f(this,null,function*(){if(!this.baseUrl)throw new Error("Base URL is not set");let s=this.buildTileUrl(t,e,i);if(this.textureCache.has(s)){let n=this.textureCache.get(s);return n instanceof Promise?n:Promise.resolve(n)}let o=this.textureLoader.loadAsync(s).then(n=>(n.flipY=!0,n.colorSpace=Jh,this.textureCache.set(s,n),n)).catch(n=>null);return this.textureCache.set(s,o),o})}clearCache(){this.textureCache.forEach(t=>{t instanceof Promise?t.then(e=>e==null?void 0:e.dispose()):t.dispose()}),this.textureCache.clear()}dispose(){this.clearCache()}constructor(t){this.baseUrl="",this.config=null,this.textureCache=new Map,this.textureLoader=new Qh,t&&this.setBaseUrl(t)}};import{debounce as ac}from"lodash";var Un={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},de=class a extends Y{loadTileConfig(){return f(this,null,function*(){return this.tileLoader.loadConfig()})}initEvents(){this.context.addEventListener("control-change",this.onUpdate),this.context.bmap.addEventListener("center-change",this.onCenterChange)}removeEvents(){this.context.removeEventListener("control-change",this.onUpdate),this.context.bmap.removeEventListener("center-change",this.onCenterChange)}getViewBounds(){let t=this.context.camera,e=new nc,i=new oc,s=[],[o,n]=this.context.center||[0,0],r=[{x:-1,y:1},{x:1,y:1},{x:1,y:-1},{x:-1,y:-1}];for(let d of r){i.set(d.x,d.y),e.setFromCamera(i,t);let u=new no(0,0,1),m=new no(0,0,0),g=new rc().setFromNormalAndCoplanarPoint(u,m),y=new no;e.ray.intersectPlane(g,y)?s.push(y):(e.ray.direction.negate(),e.ray.intersectPlane(g,y)&&s.push(y))}if(s.length<4)return null;let h=1/0,c=1/0,l=-1/0,p=-1/0;return s.forEach(d=>{h=Math.min(h,d.x+o),c=Math.min(c,d.y+n),l=Math.max(l,d.x+o),p=Math.max(p,d.y+n)}),{minX:h,minY:c,maxX:l,maxY:p}}getTileZoomLevel(t,e){let{minZoom:i,maxZoom:s}=e,o=this.context.camera,n=(o.right-o.left)/o.zoom,r=this.context.clientSize.width,h=n/r,c=a.WORLD_WIDTH,l=Math.log2(c/(h*this.tileSize));return Math.min(s,Math.max(i,Math.round(l)))}getTilesInView(t,e,i){let[s,o,n,r]=i.extent,h=Math.max(t.minX,s),c=Math.max(t.minY,o),l=Math.min(t.maxX,n),p=Math.min(t.maxY,r);if(h>=l||c>=p)return[];let d=Math.pow(2,e),u=a.WORLD_WIDTH/d,m=a.WORLD_WIDTH_HALF,g=Math.max(0,Math.floor((h+m)/u)),y=Math.floor((l+m)/u),w=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),_=[];for(let L=g;L<=y;L++)for(let C=w;C<=M;C++)_.push({x:L,y:C,z:e});return _}renderTiles(t,e){return f(this,null,function*(){let i=t,s=[];if(this.currentLevel!==e)s=[...this.tileGroup.children];else{let r=this.tileGroup.children,h=r.map(l=>l.userData.key),c=t.map(l=>l.z+"/"+l.x+"/"+l.y);i=t.filter(l=>!h.includes(l.z+"/"+l.x+"/"+l.y)),s=r.filter(l=>!c.includes(l.userData.key))}let o=Math.pow(2,e),n=a.WORLD_WIDTH/o;yield Promise.all(i.map(r=>f(this,null,function*(){let h=r.z+"/"+r.x+"/"+r.y,c=yield this.tileLoader.loadTileTexture(r.x,r.y,r.z);if(c){let l=new ic({map:c,transparent:!0}),p=new ec(this.baseGeometry,l);p.scale.setX(n).setY(n),p.position.set((r.x-o/2)*n+n/2,-((r.y-o/2)*n)-n/2,0),p.userData.key=h,this.tileGroup.add(p)}}))),this.tileGroup.children.forEach(r=>{s.includes(r)&&(r.material.dispose(),this.tileGroup.remove(r))})})}setVisibility(t){this.visible=t,t&&this.onUpdate()}setOpacity(t){super.setOpacity(t)}clearTiles(){this.tileGroup.children.forEach(t=>{t.material.dispose()}),this.tileGroup.clear()}dispose(){this.removeEvents(),this.clearTiles(),this.baseGeometry.dispose(),this.tileLoader.dispose(),super.dispose()}constructor(t,e){super(t),this.loadedTiles=new Map,this.currentLevel=0,this.tileSize=256,this.baseGeometry=new sc(1,1),this.options=Un,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=ac(()=>f(this,null,function*(){if(!this.visible)return;let s=yield this.loadTileConfig(),o=this.context.camera,n=this.getViewBounds();if(!n)return;let r=this.getTileZoomLevel(o.zoom,s),h=this.getTilesInView(n,r,s);this.renderTiles(h,r)}),100),this.options=x({},Un,e),this.tileGroup=new tc;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Gi(this.options.base_url),this.initEvents(),this.updateTiles()}};de.WORLD_WIDTH=4007501668e-2;de.WORLD_WIDTH_HALF=de.WORLD_WIDTH/2;import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.string.trim.js";import{Box2 as ro,Object3D as hc,Sprite as Hn,SpriteMaterial as Nn,Vector2 as zi}from"three";import{isNil as Xe,once as cc}from"lodash";var lc={text:"",icon:"",icon_size:[22,22],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},text_font_size:14,icon_rotate:0,depth_test:!1,hide_text:!1,maxWeight:25,minWeight:1,text_opacity:1,icon_opacity:1},J=class extends hc{get hasText(){return!this.options.hide_text&&this.options.text}get durIconAndText(){return this.options.icon&&this.hasText?2:0}get offset(){return this.options.icon&&this.hasText?0:.5}get iconWidth(){return this.options.icon?this.options.icon_size[0]:0}get iconHeight(){return this.options.icon?this.options.icon_size[1]:0}get textWidth(){return this.hasText?this.textHeight*this.textAspect:0}get textHeight(){return this.hasText?this.options.text_font_size*this.textureLines:0}get hasOriginTexture(){let{text_texture:t,text_texture_width:e,text_texture_height:i,text_texture_offset_x:s,text_texture_offset_y:o}=this.options;return!Xe(t)&&!Xe(e)&&!Xe(i)&&!Xe(s)&&!Xe(o)}get inited(){return!this.options.text||this.options.text&&this.textTexture}get deltaZ(){return this.options.icon&&this.hasText?.1+this.offset*(this.iconHeight+this.durIconAndText+this.textHeight)/this.context.camera.zoom:this.hasText?.1+.5*this.textHeight/this.context.camera.zoom:.1}get canSelect(){return this.visible&&this._shouldShow}show(){return f(this,null,function*(){if(this._shouldShow)return;this._shouldShow=!0;let t=[];if(!this.spriteIcon&&this.options.icon&&t.push(this.initIcon()),!this.spriteText&&this.hasText&&t.push(this.initText()),yield Promise.all(t),!this._shouldShow){this.hide();return}this.initSize(),this._initScale({zoom:this.context.camera.zoom}),this.spriteIcon&&(this.spriteIcon.visible=!0),this.spriteText&&(this.spriteText.visible=!0)})}hide(){this._shouldShow=!1,this.spriteIcon&&(this.remove(this.spriteIcon),this.spriteIcon.material.dispose(),this.spriteIcon=void 0),this.spriteText&&(this.remove(this.spriteText),this.spriteText.material.dispose(),this.spriteText=void 0)}registryEvent(){this.context.addEventListener("control-zoom-change",this._initScale),this.addEventListener("change-icon",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.context.forceUpdate()})),this.addEventListener("change-text_font_size",t=>f(this,null,function*(){let{value:e}=t;this._shouldShow&&(this.hide(),yield this.show()),this.options.text&&this.context.forceUpdate()})),this.addEventListener("change-icon_rotate",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.rotation=e/180*Math.PI)}),this.addEventListener("change-icon_size",t=>{let{value:e}=t;this._initScale({zoom:this.context.camera.zoom}),this.initSize(),this.options.icon&&this.context.forceUpdate()}),this.addEventListener("change-depth_test",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.depthTest=e),this.spriteText&&(this.spriteText.material.depthTest=e)}),this.addEventListener("change-icon_opacity",t=>{let{value:e}=t;this.spriteIcon&&(this.spriteIcon.material.opacity=e)}),this.addEventListener("change-text_opacity",t=>{let{value:e}=t;this.spriteText&&(this.spriteText.material.opacity=e)})}unRegistryEvent(){this.context.removeEventListener("control-zoom-change",this._initScale)}getPosition(){return this.position}initIcon(){return f(this,null,function*(){if(this.options.icon)return this._initIconPromise=new Promise(t=>f(this,null,function*(){let e;if(this.options.icon_border){let{icon:s,icon_size:o,icon_border:n}=this.options;e=yield st.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield st.getTextureByUrl(this.options.icon);let i=new Hn(new Nn({map:e,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI,opacity:this.options.icon_opacity}));i.visible=!1,i.renderOrder=1e5+this.options.level,e.needsUpdate=!0,this.add(i),this.spriteIcon=i,t(i)})).then(()=>{this._initIconPromise=null})})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;if(!t)return;let e=new Hn(new Nn({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,opacity:this.options.text_opacity}));e.visible=!1,e.renderOrder=100001+this.options.level,t.needsUpdate=!0,this.spriteText=e,this.add(e)}})}initSize(){var t,e;let i=0,s=0,{icon:o}=this.options;o?this.hasText?(i=0,s=i*(this.iconHeight/this.textHeight)-this.iconHeight/this.textHeight-this.durIconAndText/this.textHeight):(i=.5,s=0):this.hasText?(s=.5,i=0):(i=0,s=0),(t=this.spriteIcon)==null||t.center.set(.5,i),(e=this.spriteText)==null||e.center.set(.5,s)}init(){return f(this,null,function*(){yield Promise.all([this.initIcon(),this.initText()]),this.initSize(),this._initScale({zoom:this.context.camera.zoom})})}resetZ(){let t=this.deltaZ;this.spriteIcon&&(this.spriteIcon.position.z=t),this.spriteText&&(this.spriteText.position.z=t)}getBox(t){if(!this.inited)return this.initTextTexture(),null;let{clientSize:{width:e,height:i}}=this.context,s=e*(t.x+1)/2,o=i*(-t.y+1)/2;o+=this.offset*(this.iconHeight+this.durIconAndText+this.textHeight);let n=this.iconWidth/2,r=new ro(new zi(s-n,o-this.iconHeight),new zi(s+n,o)),h=this.textWidth/2,c=new ro(new zi(s-h,o-this.textHeight-this.durIconAndText-this.iconHeight),new zi(s+h,o-this.iconHeight-this.durIconAndText));return this.box=c.union(r),this.box}renderBoxHelper(t,e){if(!this.boxHelper){let i=document.createElement("div");i.style.position="absolute",i.style.zIndex="999",i.style.border="1px solid red",i.style.pointerEvents="none",this.boxHelper=i,this.context.container.appendChild(i)}t&&e?(this.boxHelper.style.left=t+"px",this.boxHelper.style.top=e+"px",this.boxHelper.style.width="2px",this.boxHelper.style.height="2px"):(this.boxHelper.style.left=this.box.min.x+"px",this.boxHelper.style.top=this.box.min.y+"px",this.boxHelper.style.width=this.box.max.x-this.box.min.x+"px",this.boxHelper.style.height=this.box.max.y-this.box.min.y+"px")}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.textAspect=1,this.box=new ro,this._initIconPromise=null,this.textureLines=1,this._shouldShow=!1,this.initTextTexture=cc(()=>f(this,null,function*(){if(!this.options.text||this.textTexture)return;let o;if(this.hasOriginTexture){let{text_texture:n,text_texture_width:r,text_texture_height:h,text_texture_offset_x:c,text_texture_offset_y:l}=this.options;o=this.options.text_texture.clone(),o.uuid=n.uuid,o.offset.set(c/o.image.width,1-(h+l)/o.image.height),o.repeat.set(r/o.image.width,h/o.image.height),this.textAspect=r/h}else{let n=yield et.getTextureByText(this.options.text);o=n.texture,this.textureLines=n.lines,this.textAspect=o.image.width/o.image.height}this.textTexture=o,this.dispatchEvent({type:"text-texture-inited"})})),this._initScale=o=>{let{zoom:n}=o;if(this.spriteText){let h=this.textHeight/n;this.spriteText.scale.set(this.textAspect*h,h,.1)}if(this.spriteIcon){var r;(r=this.spriteIcon)==null||r.scale.set(this.options.icon_size[0]/n,this.options.icon_size[1]/n,.1)}this.resetZ()};var s;this.options=fe(x({},lc,e,{text:(s=(i=e.text)==null?void 0:i.trim())!=null?s:""}),this),this.position.set(this.options.position.x,this.options.position.y,this.options.position.z),this.registryEvent()}};var At=class extends ao{getPosition(){return this.box.getCenter(new Wi)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new ot(this.context,t);e.userData.data=t,this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundLayer.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.groundUpper.position.z=this.groundMaxHeight+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new Bi().setFromObject(this).getCenter(new Wi)}addModel(t){let e=new Ci(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new Bi().setFromObject(this.groundUpper),e=t.getCenter(new Wi),i=t.getSize(new Wi);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addPoi2(t){let e=new J(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}addHeatmap(t){this.heatmap||(this.heatmap=new Li(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new Bi().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z+.1),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}setGraphicOptions(t,e){this.graphicLayer.graphicMap.has(t)?this.graphicLayer.setGraphicOptions(t,e):this.mergeGraphicLayer.setGraphicOptions(t,e)}getGraphicPosition(t){return this.graphicLayer.getGraphicPosition(t)||this.mergeGraphicLayer.getGraphicPosition(t)||this.parkingSpaceLayer.getGraphicPosition(t)}changeParkingColor(t){this.parkingSpaceLayer.changeParkingColor(t)}getParkingOptionsByParkingNo(t){return this.parkingSpaceLayer.getParkingOptionsByParkingNo(t)}updateBox(){this.box.setFromObject(this.groundLayer)}getGraphics(){return this.graphicLayer.children.filter(t=>t instanceof ot)}setOpacity(t,e){e===void 0&&(e=!1),this.groundLayer.setOpacity(t,e),this.graphicLayer.setOpacity(t,e),this.mergeGraphicLayer.setOpacity(t,e),this.poiLayer2.setOpacity(t),this.parkingSpaceLayer.setOpacity(t,e),this.laneLayer.setOpacity(t,e),this.wallLayer.setOpacity(t,e),this.textureLayer.setOpacity(t),this.textTextureLayer.setOpacity(t),this.glbModelLayer.setOpacity(t,e),this.userData.opacity=t}dispose(){var t;console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.parkingSpaceLayer.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.textTextureLayer.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()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Ei,this.groundUpper=new ao,this.models=new ao,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new Bi,this.groundLayer=new Y(this.context),this.graphicLayer=new Ti(this.context),this.poiLayer=new ki(this.context),this.poiLayer2=new Di(this.context),this.parkingSpaceLayer=new Ai(this.context),this.wallLayer=new Y(this.context),this.textureLayer=new Y(this.context),this.glbModelLayer=new Oi(this.context),this.laneLayer=new Y(this.context),this.mergeGraphicLayer=new Fi(this.context),this.textTextureLayer=new Y(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.parkingSpaceLayer),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.groundUpper.add(this.textTextureLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as pc,Vector3 as dc}from"three";var wt=class extends pc{_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:s,offsetY:o}=t,{clientWidth:n,clientHeight:r}=i.domElement,h=s/n*2-1,c=1-o/r*2;return new dc(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return D(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}constructor(t){super(),this.context=t,this.points=[],this.enable=!0,this._onResize=e=>{let{width:i,height:s}=e;this.svg&&(this.svg.setAttribute("width",""+i),this.svg.setAttribute("height",""+s))},this.svg=Ho(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Ui=class extends wt{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:s}]=this.points;return Math.sqrt((i-t)**2+(s-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}constructor(t){super(t),this.context=t,this.onUpdate=()=>{if(this.points[0]){let s=this.getSvgCoordinate(this.points[0]);oe(this.circles[0],s.x,s.y),_t(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);oe(this.circles[1],s.x,s.y),_t(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",_t(this.line,void 0,{x:s.offsetX,y:s.offsetY}))},this.onPointerleave=()=>{this.points[1]||(this.line.style.display="none")},this.onPointerdown=s=>{if(this.points[1])return;let o=this.getIntersectByPointerEvent(s);if(o){let{offsetX:n,offsetY:r}=s,h=this.circles[this.points.length];oe(h,n,r),this.points.length||_t(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Ue(e.radius,e.fill),Ue(e.radius,e.fill)],this.line=di(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};import"core-js/modules/es.array.push.js";var Hi=class extends wt{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],s=+i.getAttribute("cx"),o=+i.getAttribute("cy");return Math.sqrt((t-s)**2+(e-o)**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(s=>[s.x,s.y]),e=0,i=t.length;for(let s=0;s<i;s++){let o=(s+1)%i;e+=t[s][0]*t[o][1]-t[o][0]*t[s][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}constructor(t){super(t),this.circles=[],this.lines=[],this.isClose=!1,this.onUpdate=()=>{this.points.length&&this.points.forEach((e,i)=>{let s=this.getSvgCoordinate(e);this.circles[i]&&oe(this.circles[i],s.x,s.y),i!==0&&_t(this.lines[i-1],void 0,s),this.lines[i]&&_t(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",_t(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))},this.onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")},this.onPointerdown=e=>{if(this.isClose)return;let i=this.getIntersectByPointerEvent(e);if(i){let{offsetX:s,offsetY:o}=e;this.checkAdsorb(s,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(i);let{circle:{fill:n,radius:r},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let c=Ue(r,n);oe(c,s,o),this.addCircle(c)}if(this.lines.length&&_t(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=di(h);_t(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};import{Box3 as uc}from"three";var Zn=class extends wt{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=[]}constructor(t){super(t),this.context=t,this.cornerRect=[],this.centerRect=[],this.onUpdate=()=>{if(this.graphic){let i=new uc().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=D(r,s,o,n),l=D(h,s,o,n);ht(this.rect,c.x,l.y,Math.abs(l.x-c.x),Math.abs(l.y-c.y));let{x:p,y:d}=c,{x:u,y:m}=l,g=5,y=[{x:p-g,y:m-g},{x:u-g,y:m-g},{x:p-g,y:d-g},{x:u-g,y:d-g}];for(let C=0;C<y.length;C++)ht(this.cornerRect[C],y[C].x,y[C].y,g*2,g*2);let w=4,M=(p+u)/2,_=(d+m)/2,L=[{x:M-w,y:m-w},{x:p-w,y:_-w},{x:u-w,y:_-w},{x:M-w,y:d-w}];for(let C=0;C<L.length;C++)ht(this.centerRect[C],L[C].x,L[C].y,w*2,w*2)}else{ht(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)ht(this.cornerRect[i],0,0,0,0),ht(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=$t(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=$t(e.stroke,"#ffffff"),this.centerRect[i]=$t(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}};import"core-js/modules/es.array.push.js";import{BufferGeometry as mc,Color as ho,LineSegments as fc,Mesh as gc,Object3D as yc,ShaderMaterial as vc,Vector3 as jn}from"three";import{mergeGeometries as xc}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Ni=class extends yc{initGeometry(){return f(this,null,function*(){let t=yield bt.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
437
437
  varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
438
438
  uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
439
439
  uniform vec3 uColor;
package/lib/meta.json CHANGED
@@ -2998,7 +2998,7 @@
2998
2998
  "format": "esm"
2999
2999
  },
3000
3000
  "../lib/src/elements/poi2.js": {
3001
- "bytes": 14218,
3001
+ "bytes": 14342,
3002
3002
  "imports": [
3003
3003
  {
3004
3004
  "path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
@@ -9466,7 +9466,7 @@
9466
9466
  "bytesInOutput": 1595
9467
9467
  },
9468
9468
  "../lib/src/elements/poi2.js": {
9469
- "bytesInOutput": 7619
9469
+ "bytesInOutput": 7681
9470
9470
  },
9471
9471
  "../lib/src/elements/svg-line.js": {
9472
9472
  "bytesInOutput": 2240
@@ -9697,7 +9697,7 @@
9697
9697
  "bytesInOutput": 433
9698
9698
  }
9699
9699
  },
9700
- "bytes": 401126
9700
+ "bytes": 401188
9701
9701
  }
9702
9702
  }
9703
9703
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aibee/crc-bmap",
3
- "version": "0.13.9",
3
+ "version": "0.13.10",
4
4
  "description": "",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.esm.min.js",