@aibee/crc-bmap 0.14.12 → 0.14.14
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 +2 -2
- package/lib/index.esm.min.js +2 -2
- package/lib/meta.json +5 -5
- package/lib/src/elements/poi2.d.ts +2 -0
- package/package.json +1 -1
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 $.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)}};at(Lt,"lineMaterialMap",new Map),at(Lt,"meshStandardMaterialMap",new Map),at(Lt,"meshBasicMaterialMap",new Map),at(Lt,"shaderMaterialMap",new Map),at(Lt,"line2MaterialMap",new Map),at(Lt,"mergeAttributeGraphicMaterial",null),at(Lt,"mergeAttributeWallMaterial",null),at(Lt,"mergeAttributeGraphicLineMaterial",null),at(Lt,"instancedGraphicMaterial",null),at(Lt,"instancedWallMaterial",null),at(Lt,"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()}};at(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 Gr=require("three");var Us=class extends Gr.EventDispatcher{constructor(e=10,i){super();at(this,"max",10);at(this,"workerConstructor");at(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 Sh={};function Xo(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",Sh.url))}var Xi=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 Xi.BufferGeometry;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Xi.BufferAttribute(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Xi.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?Ei(Ei({},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?Ei(Ei({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};at(ni,"WorkerPool",new Us(10,Xo));var Yi=class extends q{getCenter(){return new Ft.Box3().setFromObject(this).getCenter(new Ft.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),I(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new Xe(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,w({},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(I(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(I(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=w({},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 Ft.Matrix4().fromArray(r),c=new Ft.Vector3,l=new Ft.Quaternion,p=new Ft.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 Ft.Group,this.mergedLineGroup=new Ft.Group,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};var Mf=require("core-js/modules/web.dom-collections.iterator.js"),_f=require("core-js/modules/es.array.push.js");var pt=require("three");var mf=require("core-js/modules/es.string.replace.js"),ff=require("core-js/modules/es.regexp.exec.js"),gf=require("core-js/modules/es.error.cause.js"),yf=require("core-js/modules/web.dom-collections.iterator.js"),Hs=require("three");var qi=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=Hs.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 Hs.TextureLoader,t&&this.setBaseUrl(t)}};var zr=require("lodash");var Fr={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},Re=class a extends q{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 pt.Raycaster,i=new pt.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 pt.Vector3(0,0,1),m=new pt.Vector3(0,0,0),v=new pt.Plane().setFromNormalAndCoplanarPoint(u,m),g=new pt.Vector3;e.ray.intersectPlane(v,g)?s.push(g):(e.ray.direction.negate(),e.ray.intersectPlane(v,g)&&s.push(g))}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,v=Math.max(0,Math.floor((h+m)/u)),g=Math.floor((l+m)/u),x=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),P=[];for(let C=v;C<=g;C++)for(let S=x;S<=M;S++)P.push({x:C,y:S,z:e});return P}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 pt.MeshBasicMaterial({map:c,transparent:!0}),p=new pt.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 pt.PlaneGeometry(1,1),this.options=Fr,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,zr.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=w({},Fr,e),this.tileGroup=new pt.Group;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new qi(this.options.base_url),this.initEvents(),this.updateTiles()}};Re.WORLD_WIDTH=4007501668e-2;Re.WORLD_WIDTH_HALF=Re.WORLD_WIDTH/2;var Cf=require("core-js/modules/es.array.push.js"),Tf=require("core-js/modules/web.dom-collections.iterator.js"),kf=require("core-js/modules/es.string.trim.js");var Mt=require("three");var ee=require("lodash");var Eh={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},tt=class extends Mt.Object3D{get textTexture(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureMap[e])==null?void 0:t.texture)!=null?i:null}get textTextureRect(){let t=this.options.text;var e;return t&&(e=this.textTextureRectMap[t])!=null?e:null}get textureLines(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.lines)!=null?i:1}get textAspect(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.aspect)!=null?i:1}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,ee.isNil)(t)&&!(0,ee.isNil)(e)&&!(0,ee.isNil)(i)&&!(0,ee.isNil)(s)&&!(0,ee.isNil)(o)}get initedTextRect(){return!this.options.text||this.options.text&&this.textTextureRect}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.initTextTexture=(0,ee.once)(this._initTextTexture),this.initTextTextureRect=(0,ee.once)(this._initTextTextureRect),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 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 lt.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield lt.getTextureByUrl(this.options.icon);let i=new Mt.Sprite(new Mt.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)}))})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;t||(yield this.initTextTexture()),t=this.textTexture;let e=new Mt.Sprite(new Mt.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.initedTextRect)return this.initTextTextureRect(),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 Mt.Box2(new Mt.Vector2(s-n,o-this.iconHeight),new Mt.Vector2(s+n,o)),h=this.textWidth/2,c=new Mt.Box2(new Mt.Vector2(s-h,o-this.textHeight-this.durIconAndText-this.iconHeight),new Mt.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")}setVisible(t){this.visible=t,this.context.forceUpdate()}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.textTextureMap={},this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.box=new Mt.Box2,this._shouldShow=!1,this.textTextureMap={},this.textTextureRectMap={},this._initTextTexture=()=>f(this,null,function*(){if(!this.options.text||this.textTextureMap[this.options.text])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.textTextureMap[this.options.text]={texture:o,lines:1,textAspect:r/h}}else{let n=yield Q.getTextureByText(this.options.text);this.textTextureMap[this.options.text]=w({},n,{textAspect:n.texture.image.width/n.texture.image.height})}this.dispatchEvent({type:"text-texture-inited"})}),this.initTextTexture=(0,ee.once)(this._initTextTexture),this._initTextTextureRect=()=>f(this,null,function*(){if(!this.options.text||this.textTextureRectMap[this.options.text])return;let o=yield Q.getTextureRectByTexts(this.options.text);this.textTextureRectMap[this.options.text]=w({},o,{aspect:o.width/o.height}),this.dispatchEvent({type:"text-texture-rect-inited"})}),this.initTextTextureRect=(0,ee.once)(this._initTextTextureRect),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=Ue(w({},Eh,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 ie=class extends zt.Object3D{getPosition(){return this.box.getCenter(new zt.Vector3)}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 zt.Box3().setFromObject(this).getCenter(new zt.Vector3)}addModel(t){let e=new Ui(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new zt.Box3().setFromObject(this.groundUpper),e=t.getCenter(new zt.Vector3),i=t.getSize(new zt.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 tt(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}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(){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(t=>t.dispose()),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Wi,this.groundUpper=new zt.Object3D,this.models=new zt.Object3D,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new zt.Box3,this.groundLayer=new q(this.context),this.graphicLayer=new Hi(this.context),this.poiLayer=new Ni(this.context),this.poiLayer2=new Zi(this.context),this.parkingSpaceLayer=new ji(this.context),this.wallLayer=new q(this.context),this.textureLayer=new q(this.context),this.glbModelLayer=new Vi(this.context),this.laneLayer=new q(this.context),this.mergeGraphicLayer=new Yi(this.context),this.textTextureLayer=new q(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 _t=require("three"),Br=require("@mars3d/heatmap.js"),Ns=require("@turf/turf");var $i=class extends _t.Object3D{clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){var e;this.clearHeatmap();let{width:i,height:s,leftTop:o,center:n,scale:r}=this.box,h=((e=this.context.config.heatMap)==null?void 0:e.radius)||1,c=w({width:i,height:s,container:this.div},this.context.config.heatMap,{radius:h});this.heatmap=(0,Br.create)(c);let l=this.transformData(t,o,r);t.maxValue!==void 0&&(l.max=t.maxValue),t.minValue!==void 0&&(l.min=t.minValue),this.heatmap.setData(l),this.initPlane(i/r,s/r);let p=this.context.center;this.position.set(n[0]-p[0],n[1]-p[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new _t.PlaneGeometry(t,e),s=new _t.Texture(this.div.firstChild);s.needsUpdate=!0;let o=new _t.MeshBasicMaterial({transparent:!0,side:_t.FrontSide,map:s});o.needsUpdate=!0,this.plane=new _t.Mesh(i,o),this.plane.renderOrder=1e5,this.add(this.plane)}getTransMatrix(t){let{x:e,y:i}=t;return new _t.Matrix3().makeScale(this.box.scale,-this.box.scale).multiply(new _t.Matrix3().makeTranslation(-e,-i))}transformData(t,e,i){var s,o;let n=this.getTransMatrix(e);var r;let h=(r=(s=t.data[0])==null?void 0:s.value)!=null?r:0;var c;let l=(c=(o=t.data[0])==null?void 0:o.value)!=null?c:0;return{data:t.data.map(d=>{let u=new _t.Vector2(d.x,d.y).applyMatrix3(n);return d.value>h&&(h=d.value),d.value<l&&(l=d.value),{x:Math.ceil(u.x),y:Math.ceil(u.y),value:d.value}}),max:h,min:l}}getBox(){let t=this.context.range,e=(0,Ns.bbox)(t),i=Math.ceil(e[2]-e[0]),s=Math.ceil(e[3]-e[1]),o=4e3,n=4e3,r=o/i,h=n/s,c=Math.min(r,h);this.scaleRatio=c;let l=i*c,p=s*c,d={x:Math.ceil(e[0]),y:Math.ceil(e[3])},u=(0,Ns.center)(t).geometry.coordinates;return{width:l,height:p,leftTop:d,center:u,scale:c}}dispose(){this.clearHeatmap(),this.div.remove(),this.div=null,this.plane&&(this.remove(this.plane),I(this.plane))}constructor(t){super(),this.context=t,this.scaleRatio=1,this.div=document.createElement("div"),this.box=this.getBox()}};var tg=require("core-js/modules/es.array.push.js"),eg=require("core-js/modules/web.dom-collections.iterator.js");var Zs=require("three");var Bt=class extends Zs.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 Zs.Vector3(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=So(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Ji=class extends Bt{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]);Le(this.circles[0],s.x,s.y),jt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);Le(this.circles[1],s.x,s.y),jt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",jt(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];Le(h,n,r),this.points.length||jt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Qe(e.radius,e.fill),Qe(e.radius,e.fill)],this.line=ki(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};var ng=require("core-js/modules/es.array.push.js");var Qi=class extends Bt{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]&&Le(this.circles[i],s.x,s.y),i!==0&&jt(this.lines[i-1],void 0,s),this.lines[i]&&jt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",jt(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=Qe(r,n);Le(c,s,o),this.addCircle(c)}if(this.lines.length&&jt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=ki(h);jt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};var Wr=require("three");var Yo=class extends Bt{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 Wr.Box3().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);bt(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,v=5,g=[{x:p-v,y:m-v},{x:u-v,y:m-v},{x:p-v,y:d-v},{x:u-v,y:d-v}];for(let S=0;S<g.length;S++)bt(this.cornerRect[S],g[S].x,g[S].y,v*2,v*2);let x=4,M=(p+u)/2,P=(d+m)/2,C=[{x:M-x,y:m-x},{x:p-x,y:P-x},{x:u-x,y:P-x},{x:M-x,y:d-x}];for(let S=0;S<C.length;S++)bt(this.centerRect[S],C[S].x,C[S].y,x*2,x*2)}else{bt(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)bt(this.cornerRect[i],0,0,0,0),bt(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 dg=require("core-js/modules/es.array.push.js"),Pt=require("three");var Ur=require("three/examples/jsm/utils/BufferGeometryUtils.js");var ts=class extends Pt.Object3D{initGeometry(){return f(this,null,function*(){let t=yield te.GetMergeGeometry(this.options);this.geometry=t})}initMaterial(){let t=`
|
|
436
|
+
`;return this.instancedWallMaterial=new $.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)}};at(Lt,"lineMaterialMap",new Map),at(Lt,"meshStandardMaterialMap",new Map),at(Lt,"meshBasicMaterialMap",new Map),at(Lt,"shaderMaterialMap",new Map),at(Lt,"line2MaterialMap",new Map),at(Lt,"mergeAttributeGraphicMaterial",null),at(Lt,"mergeAttributeWallMaterial",null),at(Lt,"mergeAttributeGraphicLineMaterial",null),at(Lt,"instancedGraphicMaterial",null),at(Lt,"instancedWallMaterial",null),at(Lt,"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()}};at(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 Gr=require("three");var Us=class extends Gr.EventDispatcher{constructor(e=10,i){super();at(this,"max",10);at(this,"workerConstructor");at(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 Sh={};function Xo(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",Sh.url))}var Xi=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 Xi.BufferGeometry;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Xi.BufferAttribute(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Xi.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?Ei(Ei({},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?Ei(Ei({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};at(ni,"WorkerPool",new Us(10,Xo));var Yi=class extends q{getCenter(){return new Ft.Box3().setFromObject(this).getCenter(new Ft.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),I(this.instancedGraphic)),this.instancedGraphicConfig&&(this.instancedGraphic=new Xe(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,w({},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(I(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(I(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=w({},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 Ft.Matrix4().fromArray(r),c=new Ft.Vector3,l=new Ft.Quaternion,p=new Ft.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 Ft.Group,this.mergedLineGroup=new Ft.Group,this.graphicDataMap=new Map,this.graphicOriginOptionMap=new Map,this.instancedGraphic=null,this.instancedGraphicConfig=null,this.add(this.mergedGraphicGroup),this.add(this.mergedLineGroup)}};var Mf=require("core-js/modules/web.dom-collections.iterator.js"),_f=require("core-js/modules/es.array.push.js");var pt=require("three");var mf=require("core-js/modules/es.string.replace.js"),ff=require("core-js/modules/es.regexp.exec.js"),gf=require("core-js/modules/es.error.cause.js"),yf=require("core-js/modules/web.dom-collections.iterator.js"),Hs=require("three");var qi=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=Hs.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 Hs.TextureLoader,t&&this.setBaseUrl(t)}};var zr=require("lodash");var Fr={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},Re=class a extends q{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 pt.Raycaster,i=new pt.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 pt.Vector3(0,0,1),m=new pt.Vector3(0,0,0),v=new pt.Plane().setFromNormalAndCoplanarPoint(u,m),g=new pt.Vector3;e.ray.intersectPlane(v,g)?s.push(g):(e.ray.direction.negate(),e.ray.intersectPlane(v,g)&&s.push(g))}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,v=Math.max(0,Math.floor((h+m)/u)),g=Math.floor((l+m)/u),x=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),P=[];for(let C=v;C<=g;C++)for(let S=x;S<=M;S++)P.push({x:C,y:S,z:e});return P}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 pt.MeshBasicMaterial({map:c,transparent:!0}),p=new pt.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 pt.PlaneGeometry(1,1),this.options=Fr,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,zr.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=w({},Fr,e),this.tileGroup=new pt.Group;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new qi(this.options.base_url),this.initEvents(),this.updateTiles()}};Re.WORLD_WIDTH=4007501668e-2;Re.WORLD_WIDTH_HALF=Re.WORLD_WIDTH/2;var Cf=require("core-js/modules/es.array.push.js"),Tf=require("core-js/modules/web.dom-collections.iterator.js"),kf=require("core-js/modules/es.string.trim.js");var Mt=require("three");var ee=require("lodash");var Eh={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,icon_alpha_test:.2,text_alpha_test:.2},tt=class extends Mt.Object3D{get textTexture(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureMap[e])==null?void 0:t.texture)!=null?i:null}get textTextureRect(){let t=this.options.text;var e;return t&&(e=this.textTextureRectMap[t])!=null?e:null}get textureLines(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.lines)!=null?i:1}get textAspect(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.aspect)!=null?i:1}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,ee.isNil)(t)&&!(0,ee.isNil)(e)&&!(0,ee.isNil)(i)&&!(0,ee.isNil)(s)&&!(0,ee.isNil)(o)}get initedTextRect(){return!this.options.text||this.options.text&&this.textTextureRect}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.initTextTexture=(0,ee.once)(this._initTextTexture),this.initTextTextureRect=(0,ee.once)(this._initTextTextureRect),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 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 lt.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield lt.getTextureByUrl(this.options.icon);let i=new Mt.Sprite(new Mt.SpriteMaterial({map:e,transparent:!0,alphaTest:this.options.icon_alpha_test,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)}))})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;t||(yield this.initTextTexture()),t=this.textTexture;let e=new Mt.Sprite(new Mt.SpriteMaterial({map:t,transparent:!0,alphaTest:this.options.text_alpha_test,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.initedTextRect)return this.initTextTextureRect(),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 Mt.Box2(new Mt.Vector2(s-n,o-this.iconHeight),new Mt.Vector2(s+n,o)),h=this.textWidth/2,c=new Mt.Box2(new Mt.Vector2(s-h,o-this.textHeight-this.durIconAndText-this.iconHeight),new Mt.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")}setVisible(t){this.visible=t,this.context.forceUpdate()}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.textTextureMap={},this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.box=new Mt.Box2,this._shouldShow=!1,this.textTextureMap={},this.textTextureRectMap={},this._initTextTexture=()=>f(this,null,function*(){if(!this.options.text||this.textTextureMap[this.options.text])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.textTextureMap[this.options.text]={texture:o,lines:1,textAspect:r/h}}else{let n=yield Q.getTextureByText(this.options.text);this.textTextureMap[this.options.text]=w({},n,{textAspect:n.texture.image.width/n.texture.image.height})}this.dispatchEvent({type:"text-texture-inited"})}),this.initTextTexture=(0,ee.once)(this._initTextTexture),this._initTextTextureRect=()=>f(this,null,function*(){if(!this.options.text||this.textTextureRectMap[this.options.text])return;let o=yield Q.getTextureRectByTexts(this.options.text);this.textTextureRectMap[this.options.text]=w({},o,{aspect:o.width/o.height}),this.dispatchEvent({type:"text-texture-rect-inited"})}),this.initTextTextureRect=(0,ee.once)(this._initTextTextureRect),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=Ue(w({},Eh,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 ie=class extends zt.Object3D{getPosition(){return this.box.getCenter(new zt.Vector3)}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 zt.Box3().setFromObject(this).getCenter(new zt.Vector3)}addModel(t){let e=new Ui(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new zt.Box3().setFromObject(this.groundUpper),e=t.getCenter(new zt.Vector3),i=t.getSize(new zt.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 tt(this.context,t);return this.poiLayer2.pushPoi(e),e}removePoi2(t){return this.poiLayer2.removePoi(t)}removePoi2ById(t){return this.poiLayer2.removePoiById(t)}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(){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(t=>t.dispose()),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Wi,this.groundUpper=new zt.Object3D,this.models=new zt.Object3D,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new zt.Box3,this.groundLayer=new q(this.context),this.graphicLayer=new Hi(this.context),this.poiLayer=new Ni(this.context),this.poiLayer2=new Zi(this.context),this.parkingSpaceLayer=new ji(this.context),this.wallLayer=new q(this.context),this.textureLayer=new q(this.context),this.glbModelLayer=new Vi(this.context),this.laneLayer=new q(this.context),this.mergeGraphicLayer=new Yi(this.context),this.textTextureLayer=new q(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 _t=require("three"),Br=require("@mars3d/heatmap.js"),Ns=require("@turf/turf");var $i=class extends _t.Object3D{clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){var e;this.clearHeatmap();let{width:i,height:s,leftTop:o,center:n,scale:r}=this.box,h=((e=this.context.config.heatMap)==null?void 0:e.radius)||1,c=w({width:i,height:s,container:this.div},this.context.config.heatMap,{radius:h});this.heatmap=(0,Br.create)(c);let l=this.transformData(t,o,r);t.maxValue!==void 0&&(l.max=t.maxValue),t.minValue!==void 0&&(l.min=t.minValue),this.heatmap.setData(l),this.initPlane(i/r,s/r);let p=this.context.center;this.position.set(n[0]-p[0],n[1]-p[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new _t.PlaneGeometry(t,e),s=new _t.Texture(this.div.firstChild);s.needsUpdate=!0;let o=new _t.MeshBasicMaterial({transparent:!0,side:_t.FrontSide,map:s});o.needsUpdate=!0,this.plane=new _t.Mesh(i,o),this.plane.renderOrder=1e5,this.add(this.plane)}getTransMatrix(t){let{x:e,y:i}=t;return new _t.Matrix3().makeScale(this.box.scale,-this.box.scale).multiply(new _t.Matrix3().makeTranslation(-e,-i))}transformData(t,e,i){var s,o;let n=this.getTransMatrix(e);var r;let h=(r=(s=t.data[0])==null?void 0:s.value)!=null?r:0;var c;let l=(c=(o=t.data[0])==null?void 0:o.value)!=null?c:0;return{data:t.data.map(d=>{let u=new _t.Vector2(d.x,d.y).applyMatrix3(n);return d.value>h&&(h=d.value),d.value<l&&(l=d.value),{x:Math.ceil(u.x),y:Math.ceil(u.y),value:d.value}}),max:h,min:l}}getBox(){let t=this.context.range,e=(0,Ns.bbox)(t),i=Math.ceil(e[2]-e[0]),s=Math.ceil(e[3]-e[1]),o=4e3,n=4e3,r=o/i,h=n/s,c=Math.min(r,h);this.scaleRatio=c;let l=i*c,p=s*c,d={x:Math.ceil(e[0]),y:Math.ceil(e[3])},u=(0,Ns.center)(t).geometry.coordinates;return{width:l,height:p,leftTop:d,center:u,scale:c}}dispose(){this.clearHeatmap(),this.div.remove(),this.div=null,this.plane&&(this.remove(this.plane),I(this.plane))}constructor(t){super(),this.context=t,this.scaleRatio=1,this.div=document.createElement("div"),this.box=this.getBox()}};var tg=require("core-js/modules/es.array.push.js"),eg=require("core-js/modules/web.dom-collections.iterator.js");var Zs=require("three");var Bt=class extends Zs.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 Zs.Vector3(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=So(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Ji=class extends Bt{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]);Le(this.circles[0],s.x,s.y),jt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);Le(this.circles[1],s.x,s.y),jt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",jt(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];Le(h,n,r),this.points.length||jt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[Qe(e.radius,e.fill),Qe(e.radius,e.fill)],this.line=ki(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}};var ng=require("core-js/modules/es.array.push.js");var Qi=class extends Bt{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]&&Le(this.circles[i],s.x,s.y),i!==0&&jt(this.lines[i-1],void 0,s),this.lines[i]&&jt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",jt(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=Qe(r,n);Le(c,s,o),this.addCircle(c)}if(this.lines.length&&jt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=ki(h);jt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};var Wr=require("three");var Yo=class extends Bt{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 Wr.Box3().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);bt(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,v=5,g=[{x:p-v,y:m-v},{x:u-v,y:m-v},{x:p-v,y:d-v},{x:u-v,y:d-v}];for(let S=0;S<g.length;S++)bt(this.cornerRect[S],g[S].x,g[S].y,v*2,v*2);let x=4,M=(p+u)/2,P=(d+m)/2,C=[{x:M-x,y:m-x},{x:p-x,y:P-x},{x:u-x,y:P-x},{x:M-x,y:d-x}];for(let S=0;S<C.length;S++)bt(this.centerRect[S],C[S].x,C[S].y,x*2,x*2)}else{bt(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)bt(this.cornerRect[i],0,0,0,0),bt(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 dg=require("core-js/modules/es.array.push.js"),Pt=require("three");var Ur=require("three/examples/jsm/utils/BufferGeometryUtils.js");var ts=class extends Pt.Object3D{initGeometry(){return f(this,null,function*(){let t=yield te.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;
|
|
@@ -505,7 +505,7 @@
|
|
|
505
505
|
top: 0;
|
|
506
506
|
left: 0;
|
|
507
507
|
z-index: 9999;
|
|
508
|
-
`,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new $t.Sprite(new $t.SpriteMaterial({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new $t.DataTexture(Uint8Array.from(t.data),e[0],e[1],$t.RGBAFormat);return i.format=$t.RGBAFormat,i.magFilter=$t.LinearFilter,i.minFilter=$t.LinearFilter,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};be.canvas=document.createElement("canvas");be.ctx=be.canvas.getContext("2d",{willReadFrequently:!0});be.textureMap=new Map;var $h={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},un=class extends X{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(yt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new be(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(yt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new eo(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new tt(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ai(this.bmap.context,new Dt.Vector3(e[0][0],e[0][1],.51),new Dt.Vector3(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new tt(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return Di(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=he(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new Dt.Vector3(i[0]-e[0],i[1]-e[1],0).normalize(),o=new Dt.Vector3(0,1,0).normalize(),n=s.angleTo(o),r=new Dt.Vector3().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=he(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new Dt.Vector2(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return f(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return Gt(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new fi.Tween(h,this.tweenUtil.group).to(c,n).easing(fi.Easing.Quadratic.InOut).onUpdate(()=>f(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return f(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>Gt(f(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=D(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new Dt.Vector3;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new Dt.Vector3(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new Dt.Vector3;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new Dt.Vector3(d.x,d.y,0))}return Gt(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let m=new fi.Tween(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(m),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,h=Math.min(e/(o.x-n.x),i/(o.y-n.y))*(o.x-n.x)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(h,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return f(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=Io(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),Gt(new Promise(l=>{let p=this.pathTween=new fi.Tween({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>f(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return f(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=Ze(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new tt(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ai(this.bmap.context,new Dt.Vector3(e.x,e.y,.51),new Dt.Vector3(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,s=(360-t-i)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=s),this.startPoi&&(this.startPoi.options.icon_rotate=s,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(s))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),be.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new _e,this.taskQueue=new Ve,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},$h,i),this.positionNavigation=new io(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};var cM=require("core-js/modules/web.dom-collections.iterator.js");var gs=require("three"),mn=class extends X{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new gs.Color((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.visible=!1;return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new gs.Color((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.visible=!0,i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.floors=[],this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new gs.Group,this.showStatus=!1,this.group.name="mul-floor-group"}};var ya=require("three");var va=require("lodash");var Jh={};function fn(){return new Worker(new URL("./worker/path.worker-W3VDPRQY.js",Jh.url))}var ga={useWorker:!1},ys=class extends ya.EventDispatcher{setLiftPriority(t){return f(this,null,function*(){var e;(e=this.roadNetwork)==null||e.setLiftPriority(t),this.worker&&(yield Z(this.worker,"onSetLiftPriority",t))})}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),this.roadNetwork&&this.roadNetwork.initRoute(t,e),this.worker&&(yield Z(this.worker,"set_road_info",{roadData:t,facilities:e})),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>f(this,null,function*(){yield this.loaded();function c(l){l?typeof l=="string"?h(l):r(l):h("no-path")}if(this.roadNetwork){let l=this.roadNetwork.getPath(t,e,i,s,o,n);c(l)}else if(this.worker){let l=yield Z(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n});c(l)}else console.log("\u6CA1\u6709\u521D\u59CB\u5316\u8DEF\u7F51"),h("no-road-network")}))})}getDirectionPath(t){return f(this,null,function*(){return this.worker?Z(this.worker,"get_direction_path",t):Oo(t)})}dispose(){return f(this,null,function*(){this.roadNetwork&&this.roadNetwork.clear(),this.worker&&(yield Z(this.worker,"clear",""),this.worker.terminate())})}constructor(t=ga){super(),this.worker=null,this.initRoadStatus=!1,this.roadNetwork=null,this.options=(0,va.merge)({},ga,t),this.options.useWorker?this.worker=fn():this.roadNetwork=new Oi}};var xa=require("three");var Qh={};function gn(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",Qh.url))}var yn=class extends xa.EventDispatcher{setRoadData(t){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield Z(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{Z(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return Z(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){Z(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=gn(),this.initRoadStatus=!1}};var CM=require("core-js/modules/web.dom-collections.iterator.js"),TM=require("core-js/modules/es.set.difference.v2.js"),kM=require("core-js/modules/es.set.intersection.v2.js"),DM=require("core-js/modules/es.set.is-disjoint-from.v2.js"),AM=require("core-js/modules/es.set.is-subset-of.v2.js"),OM=require("core-js/modules/es.set.is-superset-of.v2.js"),IM=require("core-js/modules/es.set.symmetric-difference.v2.js"),RM=require("core-js/modules/es.set.union.v2.js"),GM=require("core-js/modules/es.array.push.js");var wa=require("three"),so=class extends Bt{setEnable(t){super.setEnable(t),bt(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=D(this.startPoint,e,i,s),n=D(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof ot&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=D(d,s,o,n);return we(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=D(h,s,o,n),p=D(c,s,o,n);return!(!we(l,e,i)||!we(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new wa.Frustum,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);bt(this.rect,n.x,n.y,r,h)}else bt(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Me(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var tc={boxSelection:!1,elements:["graphic","poi"]},vn=class extends X{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let m=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;m&&(h.add(d.options.id),c.push(m))}})}(!this.options.boxSelection||!(He?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{Ne(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{Ne(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},tc,e),this.boxSelection=new so(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var NM=require("core-js/modules/es.array.push.js"),At=require("lodash");var F=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var ec={time:1e3,elements:[F.COMPASS,F.DEVICE_MOTION,F.ACCELERATION,F.GPS]},vs=class extends st{start(){this.options.elements.some(t=>[F.DEVICE_MOTION,F.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(F.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(F.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,At.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){le?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:F.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return f(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return f(this,null,function*(){var t;if(!le)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),le?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,At.isNil)(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new j,this.dispatchTimer=null,this.addAcceleration=(0,At.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,At.throttle)(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if((0,At.isNil)(s)||(0,At.isNil)(o)||(0,At.isNil)(n))return;let r;le?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(F.DEVICE_MOTION)&&this.addDataItem({type:F.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(F.COMPASS)&&this.addDataItem({type:F.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;(0,At.isNil)(i)||(0,At.isNil)(i.x)||(0,At.isNil)(i.y)||(0,At.isNil)(i.z)||this.addAcceleration({type:F.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},ec,t)}};var c_=require("core-js/modules/web.dom-collections.iterator.js");var s_=require("core-js/modules/es.array.push.js");var YM=require("core-js/modules/es.array.push.js"),qM=require("core-js/modules/web.dom-collections.iterator.js");function oo(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function xs(a){return(a+360)%360}function Ma(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function gi(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var no=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=xs(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=xs(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=xs(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=oo(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=gi(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*oo(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=gi(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*oo(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=gi(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=xs(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};var QM=require("core-js/modules/es.array.push.js"),t_=require("core-js/modules/web.dom-collections.iterator.js");var ro=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var ic={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},ao=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===F.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===F.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===F.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===F.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===F.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===F.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:Ma(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=gi(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},ic,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new no({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new ro}};var ho=require("@turf/turf"),ws=class extends st{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&(0,ho.booleanPointInPolygon)((0,ho.point)([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===F.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new vs(e.sensor),this.pdr=new ao(e.pdr||{})}};var k_=require("core-js/modules/web.dom-collections.iterator.js"),D_=require("core-js/modules/es.array.push.js");var g_=require("core-js/modules/web.dom-collections.iterator.js"),y_=require("core-js/modules/es.array.push.js"),v_=require("core-js/modules/es.array.flat.js"),x_=require("core-js/modules/es.array.unscopables.flat.js"),ft=require("three");var mt=require("three");mt.UniformsLib["custom-line"]={linewidth:{value:1},resolution:{value:new mt.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new mt.Vector2(1,1)},allDistance:{value:1}};mt.ShaderLib["custom-line"]={uniforms:mt.UniformsUtils.merge([mt.UniformsLib.common,mt.UniformsLib.fog,mt.UniformsLib["custom-line"]]),vertexShader:`
|
|
508
|
+
`,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new $t.Sprite(new $t.SpriteMaterial({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new $t.DataTexture(Uint8Array.from(t.data),e[0],e[1],$t.RGBAFormat);return i.format=$t.RGBAFormat,i.magFilter=$t.LinearFilter,i.minFilter=$t.LinearFilter,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};be.canvas=document.createElement("canvas");be.ctx=be.canvas.getContext("2d",{willReadFrequently:!0});be.textureMap=new Map;var $h={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},un=class extends X{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(yt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new be(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(yt.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new eo(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new tt(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ai(this.bmap.context,new Dt.Vector3(e[0][0],e[0][1],.51),new Dt.Vector3(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new tt(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return Di(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=he(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new Dt.Vector3(i[0]-e[0],i[1]-e[1],0).normalize(),o=new Dt.Vector3(0,1,0).normalize(),n=s.angleTo(o),r=new Dt.Vector3().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=he(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new Dt.Vector2(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return f(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return Gt(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new fi.Tween(h,this.tweenUtil.group).to(c,n).easing(fi.Easing.Quadratic.InOut).onUpdate(()=>f(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return f(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>Gt(f(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=D(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new Dt.Vector3;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new Dt.Vector3(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new Dt.Vector3;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new Dt.Vector3(d.x,d.y,0))}return Gt(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let m=new fi.Tween(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(m),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,r=e/(o.x-n.x),h=i/(o.y-n.y),l=(r>h?e:i)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(l,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return f(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=Io(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),Gt(new Promise(l=>{let p=this.pathTween=new fi.Tween({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>f(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return f(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=Ze(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new tt(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new ai(this.bmap.context,new Dt.Vector3(e.x,e.y,.51),new Dt.Vector3(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,s=(360-t-i)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=s),this.startPoi&&(this.startPoi.options.icon_rotate=s,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(s))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),be.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new _e,this.taskQueue=new Ve,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},$h,i),this.positionNavigation=new io(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};var cM=require("core-js/modules/web.dom-collections.iterator.js");var gs=require("three"),mn=class extends X{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new gs.Color((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.visible=!1;return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new gs.Color((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.visible=!0,i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.floors=[],this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new gs.Group,this.showStatus=!1,this.group.name="mul-floor-group"}};var ya=require("three");var va=require("lodash");var Jh={};function fn(){return new Worker(new URL("./worker/path.worker-W3VDPRQY.js",Jh.url))}var ga={useWorker:!1},ys=class extends ya.EventDispatcher{setLiftPriority(t){return f(this,null,function*(){var e;(e=this.roadNetwork)==null||e.setLiftPriority(t),this.worker&&(yield Z(this.worker,"onSetLiftPriority",t))})}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),this.roadNetwork&&this.roadNetwork.initRoute(t,e),this.worker&&(yield Z(this.worker,"set_road_info",{roadData:t,facilities:e})),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>f(this,null,function*(){yield this.loaded();function c(l){l?typeof l=="string"?h(l):r(l):h("no-path")}if(this.roadNetwork){let l=this.roadNetwork.getPath(t,e,i,s,o,n);c(l)}else if(this.worker){let l=yield Z(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n});c(l)}else console.log("\u6CA1\u6709\u521D\u59CB\u5316\u8DEF\u7F51"),h("no-road-network")}))})}getDirectionPath(t){return f(this,null,function*(){return this.worker?Z(this.worker,"get_direction_path",t):Oo(t)})}dispose(){return f(this,null,function*(){this.roadNetwork&&this.roadNetwork.clear(),this.worker&&(yield Z(this.worker,"clear",""),this.worker.terminate())})}constructor(t=ga){super(),this.worker=null,this.initRoadStatus=!1,this.roadNetwork=null,this.options=(0,va.merge)({},ga,t),this.options.useWorker?this.worker=fn():this.roadNetwork=new Oi}};var xa=require("three");var Qh={};function gn(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",Qh.url))}var yn=class extends xa.EventDispatcher{setRoadData(t){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield Z(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{Z(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return Z(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){Z(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=gn(),this.initRoadStatus=!1}};var CM=require("core-js/modules/web.dom-collections.iterator.js"),TM=require("core-js/modules/es.set.difference.v2.js"),kM=require("core-js/modules/es.set.intersection.v2.js"),DM=require("core-js/modules/es.set.is-disjoint-from.v2.js"),AM=require("core-js/modules/es.set.is-subset-of.v2.js"),OM=require("core-js/modules/es.set.is-superset-of.v2.js"),IM=require("core-js/modules/es.set.symmetric-difference.v2.js"),RM=require("core-js/modules/es.set.union.v2.js"),GM=require("core-js/modules/es.array.push.js");var wa=require("three"),so=class extends Bt{setEnable(t){super.setEnable(t),bt(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=D(this.startPoint,e,i,s),n=D(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof ot&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=D(d,s,o,n);return we(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=D(h,s,o,n),p=D(c,s,o,n);return!(!we(l,e,i)||!we(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new wa.Frustum,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);bt(this.rect,n.x,n.y,r,h)}else bt(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Me(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var tc={boxSelection:!1,elements:["graphic","poi"]},vn=class extends X{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let m=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;m&&(h.add(d.options.id),c.push(m))}})}(!this.options.boxSelection||!(He?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{Ne(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{Ne(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},tc,e),this.boxSelection=new so(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var NM=require("core-js/modules/es.array.push.js"),At=require("lodash");var F=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var ec={time:1e3,elements:[F.COMPASS,F.DEVICE_MOTION,F.ACCELERATION,F.GPS]},vs=class extends st{start(){this.options.elements.some(t=>[F.DEVICE_MOTION,F.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(F.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(F.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,At.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){le?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:F.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return f(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return f(this,null,function*(){var t;if(!le)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),le?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,At.isNil)(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new j,this.dispatchTimer=null,this.addAcceleration=(0,At.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,At.throttle)(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if((0,At.isNil)(s)||(0,At.isNil)(o)||(0,At.isNil)(n))return;let r;le?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(F.DEVICE_MOTION)&&this.addDataItem({type:F.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(F.COMPASS)&&this.addDataItem({type:F.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;(0,At.isNil)(i)||(0,At.isNil)(i.x)||(0,At.isNil)(i.y)||(0,At.isNil)(i.z)||this.addAcceleration({type:F.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},ec,t)}};var c_=require("core-js/modules/web.dom-collections.iterator.js");var s_=require("core-js/modules/es.array.push.js");var YM=require("core-js/modules/es.array.push.js"),qM=require("core-js/modules/web.dom-collections.iterator.js");function oo(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function xs(a){return(a+360)%360}function Ma(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function gi(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var no=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=xs(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=xs(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=xs(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=oo(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=gi(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*oo(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=gi(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*oo(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=gi(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=xs(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};var QM=require("core-js/modules/es.array.push.js"),t_=require("core-js/modules/web.dom-collections.iterator.js");var ro=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var ic={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},ao=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===F.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===F.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===F.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===F.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===F.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===F.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:Ma(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=gi(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},ic,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new no({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new ro}};var ho=require("@turf/turf"),ws=class extends st{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&(0,ho.booleanPointInPolygon)((0,ho.point)([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===F.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new vs(e.sensor),this.pdr=new ao(e.pdr||{})}};var k_=require("core-js/modules/web.dom-collections.iterator.js"),D_=require("core-js/modules/es.array.push.js");var g_=require("core-js/modules/web.dom-collections.iterator.js"),y_=require("core-js/modules/es.array.push.js"),v_=require("core-js/modules/es.array.flat.js"),x_=require("core-js/modules/es.array.unscopables.flat.js"),ft=require("three");var mt=require("three");mt.UniformsLib["custom-line"]={linewidth:{value:1},resolution:{value:new mt.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new mt.Vector2(1,1)},allDistance:{value:1}};mt.ShaderLib["custom-line"]={uniforms:mt.UniformsUtils.merge([mt.UniformsLib.common,mt.UniformsLib.fog,mt.UniformsLib["custom-line"]]),vertexShader:`
|
|
509
509
|
#include <common>
|
|
510
510
|
#include <color_pars_vertex>
|
|
511
511
|
#include <fog_pars_vertex>
|
package/lib/index.esm.min.js
CHANGED
|
@@ -433,7 +433,7 @@ var ha=Object.create;var Fs=Object.defineProperty;var ca=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)}};K(nt,"lineMaterialMap",new Map),K(nt,"meshStandardMaterialMap",new Map),K(nt,"meshBasicMaterialMap",new Map),K(nt,"shaderMaterialMap",new Map),K(nt,"line2MaterialMap",new Map),K(nt,"mergeAttributeGraphicMaterial",null),K(nt,"mergeAttributeWallMaterial",null),K(nt,"mergeAttributeGraphicLineMaterial",null),K(nt,"instancedGraphicMaterial",null),K(nt,"instancedWallMaterial",null),K(nt,"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()}};K(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 Hh}from"three";var Ri=class extends Hh{constructor(e=10,i){super();K(this,"max",10);K(this,"workerConstructor");K(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 oo(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",import.meta.url))}import{BufferGeometry as Nh,BufferAttribute as Un}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 Nh;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Un(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Un(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?Ue(Ue({},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?Ue(Ue({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};K(Te,"WorkerPool",new Ri(10,oo));var Gi=class extends H{getCenter(){return new Zh().setFromObject(this).getCenter(new no)}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),D(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,w({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new le(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(D(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(D(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new le(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=w({},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 jh().fromArray(r),c=new no,l=new Vh,p=new no;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 Hn,this.mergedLineGroup=new Hn,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 Yh,Mesh as qh,MeshBasicMaterial as $h,PlaneGeometry as Jh,Vector2 as Qh,Vector3 as ro,Raycaster as tc,Plane as ec}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 Kh,TextureLoader as Xh}from"three";var Fi=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=Kh,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 Xh,t&&this.setBaseUrl(t)}};import{debounce as ic}from"lodash";var Nn={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},pe=class a extends H{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 tc,i=new Qh,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 ro(0,0,1),m=new ro(0,0,0),v=new ec().setFromNormalAndCoplanarPoint(u,m),g=new ro;e.ray.intersectPlane(v,g)?s.push(g):(e.ray.direction.negate(),e.ray.intersectPlane(v,g)&&s.push(g))}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,v=Math.max(0,Math.floor((h+m)/u)),g=Math.floor((l+m)/u),x=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),P=[];for(let E=v;E<=g;E++)for(let b=x;b<=M;b++)P.push({x:E,y:b,z:e});return P}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 $h({map:c,transparent:!0}),p=new qh(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 Jh(1,1),this.options=Nn,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=ic(()=>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=w({},Nn,e),this.tileGroup=new Yh;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Fi(this.options.base_url),this.initEvents(),this.updateTiles()}};pe.WORLD_WIDTH=4007501668e-2;pe.WORLD_WIDTH_HALF=pe.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 ao,Object3D as sc,Sprite as Zn,SpriteMaterial as jn,Vector2 as zi}from"three";import{isNil as qe,once as Bi}from"lodash";var oc={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 sc{get textTexture(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureMap[e])==null?void 0:t.texture)!=null?i:null}get textTextureRect(){let t=this.options.text;var e;return t&&(e=this.textTextureRectMap[t])!=null?e:null}get textureLines(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.lines)!=null?i:1}get textAspect(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.aspect)!=null?i:1}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!qe(t)&&!qe(e)&&!qe(i)&&!qe(s)&&!qe(o)}get initedTextRect(){return!this.options.text||this.options.text&&this.textTextureRect}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.initTextTexture=Bi(this._initTextTexture),this.initTextTextureRect=Bi(this._initTextTextureRect),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 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 J.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield J.getTextureByUrl(this.options.icon);let i=new Zn(new jn({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)}))})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;t||(yield this.initTextTexture()),t=this.textTexture;let e=new Zn(new jn({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.initedTextRect)return this.initTextTextureRect(),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 ao(new zi(s-n,o-this.iconHeight),new zi(s+n,o)),h=this.textWidth/2,c=new ao(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")}setVisible(t){this.visible=t,this.context.forceUpdate()}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.textTextureMap={},this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.box=new ao,this._shouldShow=!1,this.textTextureMap={},this.textTextureRectMap={},this._initTextTexture=()=>f(this,null,function*(){if(!this.options.text||this.textTextureMap[this.options.text])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.textTextureMap[this.options.text]={texture:o,lines:1,textAspect:r/h}}else{let n=yield U.getTextureByText(this.options.text);this.textTextureMap[this.options.text]=w({},n,{textAspect:n.texture.image.width/n.texture.image.height})}this.dispatchEvent({type:"text-texture-inited"})}),this.initTextTexture=Bi(this._initTextTexture),this._initTextTextureRect=()=>f(this,null,function*(){if(!this.options.text||this.textTextureRectMap[this.options.text])return;let o=yield U.getTextureRectByTexts(this.options.text);this.textTextureRectMap[this.options.text]=w({},o,{aspect:o.width/o.height}),this.dispatchEvent({type:"text-texture-rect-inited"})}),this.initTextTextureRect=Bi(this._initTextTextureRect),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(w({},oc,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 co{getPosition(){return this.box.getCenter(new Wi)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new Y(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 ho().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 ho().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)}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 Y)}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(){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(t=>t.dispose()),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Li,this.groundUpper=new co,this.models=new co,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new ho,this.groundLayer=new H(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 H(this.context),this.textureLayer=new H(this.context),this.glbModelLayer=new Oi(this.context),this.laneLayer=new H(this.context),this.mergeGraphicLayer=new Gi(this.context),this.textTextureLayer=new H(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{MeshBasicMaterial as nc,Object3D as rc,PlaneGeometry as ac,Texture as hc,Mesh as cc,Matrix3 as Vn,Vector2 as lc,FrontSide as pc}from"three";import{create as dc}from"@mars3d/heatmap.js";import{bbox as uc,center as mc}from"@turf/turf";var Ui=class extends rc{clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){var e;this.clearHeatmap();let{width:i,height:s,leftTop:o,center:n,scale:r}=this.box,h=((e=this.context.config.heatMap)==null?void 0:e.radius)||1,c=w({width:i,height:s,container:this.div},this.context.config.heatMap,{radius:h});this.heatmap=dc(c);let l=this.transformData(t,o,r);t.maxValue!==void 0&&(l.max=t.maxValue),t.minValue!==void 0&&(l.min=t.minValue),this.heatmap.setData(l),this.initPlane(i/r,s/r);let p=this.context.center;this.position.set(n[0]-p[0],n[1]-p[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new ac(t,e),s=new hc(this.div.firstChild);s.needsUpdate=!0;let o=new nc({transparent:!0,side:pc,map:s});o.needsUpdate=!0,this.plane=new cc(i,o),this.plane.renderOrder=1e5,this.add(this.plane)}getTransMatrix(t){let{x:e,y:i}=t;return new Vn().makeScale(this.box.scale,-this.box.scale).multiply(new Vn().makeTranslation(-e,-i))}transformData(t,e,i){var s,o;let n=this.getTransMatrix(e);var r;let h=(r=(s=t.data[0])==null?void 0:s.value)!=null?r:0;var c;let l=(c=(o=t.data[0])==null?void 0:o.value)!=null?c:0;return{data:t.data.map(d=>{let u=new lc(d.x,d.y).applyMatrix3(n);return d.value>h&&(h=d.value),d.value<l&&(l=d.value),{x:Math.ceil(u.x),y:Math.ceil(u.y),value:d.value}}),max:h,min:l}}getBox(){let t=this.context.range,e=uc(t),i=Math.ceil(e[2]-e[0]),s=Math.ceil(e[3]-e[1]),o=4e3,n=4e3,r=o/i,h=n/s,c=Math.min(r,h);this.scaleRatio=c;let l=i*c,p=s*c,d={x:Math.ceil(e[0]),y:Math.ceil(e[3])},u=mc(t).geometry.coordinates;return{width:l,height:p,leftTop:d,center:u,scale:c}}dispose(){this.clearHeatmap(),this.div.remove(),this.div=null,this.plane&&(this.remove(this.plane),D(this.plane))}constructor(t){super(),this.context=t,this.scaleRatio=1,this.div=document.createElement("div"),this.box=this.getBox()}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as fc,Vector3 as gc}from"three";var vt=class extends fc{_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 gc(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return C(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=Zo(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Hi=class extends vt{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]);se(this.circles[0],s.x,s.y),Mt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);se(this.circles[1],s.x,s.y),Mt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",Mt(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];se(h,n,r),this.points.length||Mt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[He(e.radius,e.fill),He(e.radius,e.fill)],this.line=ui(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 Ni=class extends vt{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]&&se(this.circles[i],s.x,s.y),i!==0&&Mt(this.lines[i-1],void 0,s),this.lines[i]&&Mt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",Mt(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=He(r,n);se(c,s,o),this.addCircle(c)}if(this.lines.length&&Mt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=ui(h);Mt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};import{Box3 as yc}from"three";var Kn=class extends vt{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 yc().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=C(r,s,o,n),l=C(h,s,o,n);ot(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,v=5,g=[{x:p-v,y:m-v},{x:u-v,y:m-v},{x:p-v,y:d-v},{x:u-v,y:d-v}];for(let b=0;b<g.length;b++)ot(this.cornerRect[b],g[b].x,g[b].y,v*2,v*2);let x=4,M=(p+u)/2,P=(d+m)/2,E=[{x:M-x,y:m-x},{x:p-x,y:P-x},{x:u-x,y:P-x},{x:M-x,y:d-x}];for(let b=0;b<E.length;b++)ot(this.centerRect[b],E[b].x,E[b].y,x*2,x*2)}else{ot(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)ot(this.cornerRect[i],0,0,0,0),ot(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=qt(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=qt(e.stroke,"#ffffff"),this.centerRect[i]=qt(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 vc,Color as lo,LineSegments as xc,Mesh as wc,Object3D as Mc,ShaderMaterial as _c,Vector3 as Xn}from"three";import{mergeGeometries as Pc}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Zi=class extends Mc{initGeometry(){return f(this,null,function*(){let t=yield Pt.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)}};K(nt,"lineMaterialMap",new Map),K(nt,"meshStandardMaterialMap",new Map),K(nt,"meshBasicMaterialMap",new Map),K(nt,"shaderMaterialMap",new Map),K(nt,"line2MaterialMap",new Map),K(nt,"mergeAttributeGraphicMaterial",null),K(nt,"mergeAttributeWallMaterial",null),K(nt,"mergeAttributeGraphicLineMaterial",null),K(nt,"instancedGraphicMaterial",null),K(nt,"instancedWallMaterial",null),K(nt,"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()}};K(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 Hh}from"three";var Ri=class extends Hh{constructor(e=10,i){super();K(this,"max",10);K(this,"workerConstructor");K(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 oo(){return new Worker(new URL("./worker/merge-geometry.worker-S6YLXRL5.js",import.meta.url))}import{BufferGeometry as Nh,BufferAttribute as Un}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 Nh;return Object.keys(t.attributes).forEach(i=>{e.setAttribute(i,new Un(t.attributes[i].array,t.attributes[i].itemSize))}),t.index&&e.setIndex(new Un(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?Ue(Ue({},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?Ue(Ue({},t[0]),i):null})}static dispose(){this.WorkerPool.dispose()}};K(Te,"WorkerPool",new Ri(10,oo));var Gi=class extends H{getCenter(){return new Zh().setFromObject(this).getCenter(new no)}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),D(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,w({},i,{lineGeometry:null}));this.mergedGraphicGroup.add(s)}if(i.lineGeometry){let s=new le(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(D(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(D(this.mergedLineGroup),this.mergedLineGroup.clear(),e){let i=new le(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=w({},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 jh().fromArray(r),c=new no,l=new Vh,p=new no;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 Hn,this.mergedLineGroup=new Hn,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 Yh,Mesh as qh,MeshBasicMaterial as $h,PlaneGeometry as Jh,Vector2 as Qh,Vector3 as ro,Raycaster as tc,Plane as ec}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 Kh,TextureLoader as Xh}from"three";var Fi=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=Kh,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 Xh,t&&this.setBaseUrl(t)}};import{debounce as ic}from"lodash";var Nn={base_url:"https://robot-vr-public.aibee.cn/static_resource/tiles"},pe=class a extends H{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 tc,i=new Qh,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 ro(0,0,1),m=new ro(0,0,0),v=new ec().setFromNormalAndCoplanarPoint(u,m),g=new ro;e.ray.intersectPlane(v,g)?s.push(g):(e.ray.direction.negate(),e.ray.intersectPlane(v,g)&&s.push(g))}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,v=Math.max(0,Math.floor((h+m)/u)),g=Math.floor((l+m)/u),x=Math.max(0,Math.floor((m-p)/u)),M=Math.floor((m-c)/u),P=[];for(let E=v;E<=g;E++)for(let b=x;b<=M;b++)P.push({x:E,y:b,z:e});return P}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 $h({map:c,transparent:!0}),p=new qh(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 Jh(1,1),this.options=Nn,this.onUpdate=()=>{this.updateTiles()},this.onCenterChange=()=>{let{center:s}=this.context;this.tileGroup.position.set(-s[0],-s[1],0),this.updateTiles()},this.updateTiles=ic(()=>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=w({},Nn,e),this.tileGroup=new Yh;let{center:i}=t;this.tileGroup.position.set(-i[0],-i[1],0),this.add(this.tileGroup),this.tileLoader=new Fi(this.options.base_url),this.initEvents(),this.updateTiles()}};pe.WORLD_WIDTH=4007501668e-2;pe.WORLD_WIDTH_HALF=pe.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 ao,Object3D as sc,Sprite as Zn,SpriteMaterial as jn,Vector2 as zi}from"three";import{isNil as qe,once as Bi}from"lodash";var oc={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,icon_alpha_test:.2,text_alpha_test:.2},j=class extends sc{get textTexture(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureMap[e])==null?void 0:t.texture)!=null?i:null}get textTextureRect(){let t=this.options.text;var e;return t&&(e=this.textTextureRectMap[t])!=null?e:null}get textureLines(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.lines)!=null?i:1}get textAspect(){var t;let e=this.options.text;var i;return e&&(i=(t=this.textTextureRectMap[e])==null?void 0:t.aspect)!=null?i:1}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!qe(t)&&!qe(e)&&!qe(i)&&!qe(s)&&!qe(o)}get initedTextRect(){return!this.options.text||this.options.text&&this.textTextureRect}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.initTextTexture=Bi(this._initTextTexture),this.initTextTextureRect=Bi(this._initTextTextureRect),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 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 J.getUrlTextureBorder(s,o[0]-n.width*2,n)}else e=yield J.getTextureByUrl(this.options.icon);let i=new Zn(new jn({map:e,transparent:!0,alphaTest:this.options.icon_alpha_test,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)}))})}initText(){return f(this,null,function*(){if(this.hasText){let t=this.textTexture;t||(yield this.initTextTexture()),t=this.textTexture;let e=new Zn(new jn({map:t,transparent:!0,alphaTest:this.options.text_alpha_test,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.initedTextRect)return this.initTextTextureRect(),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 ao(new zi(s-n,o-this.iconHeight),new zi(s+n,o)),h=this.textWidth/2,c=new ao(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")}setVisible(t){this.visible=t,this.context.forceUpdate()}parentSetVisible(t){t?this.show():this.hide(),this.boxHelper&&(this.boxHelper.style.display=t?"block":"none")}dispose(){this.hide(),this.textTextureMap={},this.unRegistryEvent(),this._listeners={}}constructor(t,e){var i;super(),this.context=t,this.box=new ao,this._shouldShow=!1,this.textTextureMap={},this.textTextureRectMap={},this._initTextTexture=()=>f(this,null,function*(){if(!this.options.text||this.textTextureMap[this.options.text])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.textTextureMap[this.options.text]={texture:o,lines:1,textAspect:r/h}}else{let n=yield U.getTextureByText(this.options.text);this.textTextureMap[this.options.text]=w({},n,{textAspect:n.texture.image.width/n.texture.image.height})}this.dispatchEvent({type:"text-texture-inited"})}),this.initTextTexture=Bi(this._initTextTexture),this._initTextTextureRect=()=>f(this,null,function*(){if(!this.options.text||this.textTextureRectMap[this.options.text])return;let o=yield U.getTextureRectByTexts(this.options.text);this.textTextureRectMap[this.options.text]=w({},o,{aspect:o.width/o.height}),this.dispatchEvent({type:"text-texture-rect-inited"})}),this.initTextTextureRect=Bi(this._initTextTextureRect),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(w({},oc,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 co{getPosition(){return this.box.getCenter(new Wi)}onAddToScene(t){this.poiLayer2.onAddToScene(t)}onRemoveFromScene(){this.poiLayer2.onRemoveFromScene()}createGround(t){let e=new Y(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 ho().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 ho().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)}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 Y)}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(){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(t=>t.dispose()),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}constructor(t){super(),this.context=t,this.grounds=new Set,this.shadow=new Li,this.groundUpper=new co,this.models=new co,this.modelMap=new Map,this.groundMaxHeight=0,this.name="",this.key="",this.box=new ho,this.groundLayer=new H(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 H(this.context),this.textureLayer=new H(this.context),this.glbModelLayer=new Oi(this.context),this.laneLayer=new H(this.context),this.mergeGraphicLayer=new Gi(this.context),this.textTextureLayer=new H(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{MeshBasicMaterial as nc,Object3D as rc,PlaneGeometry as ac,Texture as hc,Mesh as cc,Matrix3 as Vn,Vector2 as lc,FrontSide as pc}from"three";import{create as dc}from"@mars3d/heatmap.js";import{bbox as uc,center as mc}from"@turf/turf";var Ui=class extends rc{clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){var e;this.clearHeatmap();let{width:i,height:s,leftTop:o,center:n,scale:r}=this.box,h=((e=this.context.config.heatMap)==null?void 0:e.radius)||1,c=w({width:i,height:s,container:this.div},this.context.config.heatMap,{radius:h});this.heatmap=dc(c);let l=this.transformData(t,o,r);t.maxValue!==void 0&&(l.max=t.maxValue),t.minValue!==void 0&&(l.min=t.minValue),this.heatmap.setData(l),this.initPlane(i/r,s/r);let p=this.context.center;this.position.set(n[0]-p[0],n[1]-p[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new ac(t,e),s=new hc(this.div.firstChild);s.needsUpdate=!0;let o=new nc({transparent:!0,side:pc,map:s});o.needsUpdate=!0,this.plane=new cc(i,o),this.plane.renderOrder=1e5,this.add(this.plane)}getTransMatrix(t){let{x:e,y:i}=t;return new Vn().makeScale(this.box.scale,-this.box.scale).multiply(new Vn().makeTranslation(-e,-i))}transformData(t,e,i){var s,o;let n=this.getTransMatrix(e);var r;let h=(r=(s=t.data[0])==null?void 0:s.value)!=null?r:0;var c;let l=(c=(o=t.data[0])==null?void 0:o.value)!=null?c:0;return{data:t.data.map(d=>{let u=new lc(d.x,d.y).applyMatrix3(n);return d.value>h&&(h=d.value),d.value<l&&(l=d.value),{x:Math.ceil(u.x),y:Math.ceil(u.y),value:d.value}}),max:h,min:l}}getBox(){let t=this.context.range,e=uc(t),i=Math.ceil(e[2]-e[0]),s=Math.ceil(e[3]-e[1]),o=4e3,n=4e3,r=o/i,h=n/s,c=Math.min(r,h);this.scaleRatio=c;let l=i*c,p=s*c,d={x:Math.ceil(e[0]),y:Math.ceil(e[3])},u=mc(t).geometry.coordinates;return{width:l,height:p,leftTop:d,center:u,scale:c}}dispose(){this.clearHeatmap(),this.div.remove(),this.div=null,this.plane&&(this.remove(this.plane),D(this.plane))}constructor(t){super(),this.context=t,this.scaleRatio=1,this.div=document.createElement("div"),this.box=this.getBox()}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{EventDispatcher as fc,Vector3 as gc}from"three";var vt=class extends fc{_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 gc(h,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return C(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=Zo(""+t.container.clientWidth,""+t.container.clientHeight),t.container.appendChild(this.svg),this._registryEvent()}};var Hi=class extends vt{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]);se(this.circles[0],s.x,s.y),Mt(this.line,s)}if(this.points[1]){let s=this.getSvgCoordinate(this.points[1]);se(this.circles[1],s.x,s.y),Mt(this.line,void 0,s)}},this.onPointermove=s=>{this.points.length===1&&(this.line.style.display="block",Mt(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];se(h,n,r),this.points.length||Mt(this.line,{x:n,y:r},{x:n,y:r}),this.addPoint(o)}};let{config:{svg:{circle:e,line:i}}}=t;this.circles=[He(e.radius,e.fill),He(e.radius,e.fill)],this.line=ui(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 Ni=class extends vt{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]&&se(this.circles[i],s.x,s.y),i!==0&&Mt(this.lines[i-1],void 0,s),this.lines[i]&&Mt(this.lines[i],s)})},this.onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",Mt(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=He(r,n);se(c,s,o),this.addCircle(c)}if(this.lines.length&&Mt(this.lastLine,void 0,{x:s,y:o}),!this.isClose){let c=ui(h);Mt(c,{x:s,y:o},{x:s,y:o}),this.addLine(c)}}},this.registryEvent()}};import{Box3 as yc}from"three";var Kn=class extends vt{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 yc().setFromObject(this.graphic),{camera:s,container:{clientWidth:o,clientHeight:n}}=this.context,{min:r,max:h}=i,c=C(r,s,o,n),l=C(h,s,o,n);ot(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,v=5,g=[{x:p-v,y:m-v},{x:u-v,y:m-v},{x:p-v,y:d-v},{x:u-v,y:d-v}];for(let b=0;b<g.length;b++)ot(this.cornerRect[b],g[b].x,g[b].y,v*2,v*2);let x=4,M=(p+u)/2,P=(d+m)/2,E=[{x:M-x,y:m-x},{x:p-x,y:P-x},{x:u-x,y:P-x},{x:M-x,y:d-x}];for(let b=0;b<E.length;b++)ot(this.centerRect[b],E[b].x,E[b].y,x*2,x*2)}else{ot(this.rect,0,0,0,0);for(let i=0;i<this.cornerRect.length;i++)ot(this.cornerRect[i],0,0,0,0),ot(this.centerRect[i],0,0,0,0)}};let{config:{svg:{line:e}}}=t;this.rect=qt(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=qt(e.stroke,"#ffffff"),this.centerRect[i]=qt(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 vc,Color as lo,LineSegments as xc,Mesh as wc,Object3D as Mc,ShaderMaterial as _c,Vector3 as Xn}from"three";import{mergeGeometries as Pc}from"three/examples/jsm/utils/BufferGeometryUtils.js";var Zi=class extends Mc{initGeometry(){return f(this,null,function*(){let t=yield Pt.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;
|
|
@@ -505,7 +505,7 @@ var ha=Object.create;var Fs=Object.defineProperty;var ca=Object.getOwnPropertyDe
|
|
|
505
505
|
top: 0;
|
|
506
506
|
left: 0;
|
|
507
507
|
z-index: 9999;
|
|
508
|
-
`,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new dd(new ud({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new pd(Uint8Array.from(t.data),e[0],e[1],Lr);return i.format=Lr,i.magFilter=Er,i.minFilter=Er,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};Vt.canvas=document.createElement("canvas");Vt.ctx=Vt.canvas.getContext("2d",{willReadFrequently:!0});Vt.textureMap=new Map;var gd={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},Cr=class extends B{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new Vt(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new gs(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e[0][0],e[0][1],.51),new bt(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new j(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return mi(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new bt(i[0]-e[0],i[1]-e[1],0).normalize(),o=new bt(0,1,0).normalize(),n=s.angleTo(o),r=new bt().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new fd(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return f(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return ft(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new _o(h,this.tweenUtil.group).to(c,n).easing(md.Quadratic.InOut).onUpdate(()=>f(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return f(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>ft(f(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=C(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new bt(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new bt(d.x,d.y,0))}return ft(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let m=new _o(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(m),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,h=Math.min(e/(o.x-n.x),i/(o.y-n.y))*(o.x-n.x)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(h,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return f(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=nn(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),ft(new Promise(l=>{let p=this.pathTween=new _o({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>f(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return f(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=ve(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e.x,e.y,.51),new bt(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,s=(360-t-i)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=s),this.startPoi&&(this.startPoi.options.icon_rotate=s,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(s))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),Vt.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new Qt,this.taskQueue=new we,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},gd,i),this.positionNavigation=new ys(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Group as yd,Color as Tr}from"three";var kr=class extends B{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new Tr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.visible=!1;return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new Tr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.visible=!0,i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.floors=[],this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new yd,this.showStatus=!1,this.group.name="mul-floor-group"}};import{EventDispatcher as vd}from"three";import{merge as xd}from"lodash";function Po(){return new Worker(new URL("./worker/path.worker-W3VDPRQY.js",import.meta.url))}var Dr={useWorker:!1},vs=class extends vd{setLiftPriority(t){return f(this,null,function*(){var e;(e=this.roadNetwork)==null||e.setLiftPriority(t),this.worker&&(yield F(this.worker,"onSetLiftPriority",t))})}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),this.roadNetwork&&this.roadNetwork.initRoute(t,e),this.worker&&(yield F(this.worker,"set_road_info",{roadData:t,facilities:e})),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>f(this,null,function*(){yield this.loaded();function c(l){l?typeof l=="string"?h(l):r(l):h("no-path")}if(this.roadNetwork){let l=this.roadNetwork.getPath(t,e,i,s,o,n);c(l)}else if(this.worker){let l=yield F(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n});c(l)}else console.log("\u6CA1\u6709\u521D\u59CB\u5316\u8DEF\u7F51"),h("no-road-network")}))})}getDirectionPath(t){return f(this,null,function*(){return this.worker?F(this.worker,"get_direction_path",t):on(t)})}dispose(){return f(this,null,function*(){this.roadNetwork&&this.roadNetwork.clear(),this.worker&&(yield F(this.worker,"clear",""),this.worker.terminate())})}constructor(t=Dr){super(),this.worker=null,this.initRoadStatus=!1,this.roadNetwork=null,this.options=xd({},Dr,t),this.options.useWorker?this.worker=Po():this.roadNetwork=new gi}};import{EventDispatcher as wd}from"three";function bo(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",import.meta.url))}var Ar=class extends wd{setRoadData(t){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield F(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{F(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return F(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){F(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=bo(),this.initRoadStatus=!1}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{Frustum as Md}from"three";var xs=class extends vt{setEnable(t){super.setEnable(t),ot(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=C(this.startPoint,e,i,s),n=C(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof Y&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=C(d,s,o,n);return Yt(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=C(h,s,o,n),p=C(c,s,o,n);return!(!Yt(l,e,i)||!Yt(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new Md,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);ot(this.rect,n.x,n.y,r,h)}else ot(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=qt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var _d={boxSelection:!1,elements:["graphic","poi"]},Or=class extends B{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let m=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;m&&(h.add(d.options.id),c.push(m))}})}(!this.options.boxSelection||!(ge?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{ye(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{ye(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},_d,e),this.boxSelection=new xs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.array.push.js";import{cloneDeep as Pd,isNil as ee,throttle as Ir}from"lodash";var O=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var bd={time:1e3,elements:[O.COMPASS,O.DEVICE_MOTION,O.ACCELERATION,O.GPS]},ws=class extends X{start(){this.options.elements.some(t=>[O.DEVICE_MOTION,O.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(O.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(O.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:Pd(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Ut?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:O.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return f(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return f(this,null,function*(){var t;if(!Ut)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Ut?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),ee(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new z,this.dispatchTimer=null,this.addAcceleration=Ir(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=Ir(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if(ee(s)||ee(o)||ee(n))return;let r;Ut?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(O.DEVICE_MOTION)&&this.addDataItem({type:O.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(O.COMPASS)&&this.addDataItem({type:O.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;ee(i)||ee(i.x)||ee(i.y)||ee(i.z)||this.addAcceleration({type:O.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},bd,t)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";function Ms(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function ii(a){return(a+360)%360}function Rr(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function Re(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var _s=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=ii(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=ii(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=ii(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=Ms(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=Re(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Ms(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=Re(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*Ms(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=Re(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=ii(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";var Ps=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var Sd={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},bs=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===O.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===O.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===O.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===O.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===O.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===O.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:Rr(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=Re(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},Sd,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new _s({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new Ps}};import{booleanPointInPolygon as Ed,point as Ld}from"@turf/turf";var Ss=class extends X{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&Ed(Ld([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===O.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new ws(e.sensor),this.pdr=new bs(e.pdr||{})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Object3D as Td,TextureLoader as kd,Color as Dd,Vector2 as So,Vector3 as Ad,NormalBlending as Od,RepeatWrapping as Id,Box3 as Rd}from"three";import{ShaderLib as Es,ShaderMaterial as Cd,UniformsLib as Ls,UniformsUtils as Fr,Vector2 as Gr}from"three";Ls["custom-line"]={linewidth:{value:1},resolution:{value:new Gr(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new Gr(1,1)},allDistance:{value:1}};Es["custom-line"]={uniforms:Fr.merge([Ls.common,Ls.fog,Ls["custom-line"]]),vertexShader:`
|
|
508
|
+
`,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new dd(new ud({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new pd(Uint8Array.from(t.data),e[0],e[1],Lr);return i.format=Lr,i.magFilter=Er,i.minFilter=Er,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};Vt.canvas=document.createElement("canvas");Vt.ctx=Vt.canvas.getContext("2d",{willReadFrequently:!0});Vt.textureMap=new Map;var gd={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},Cr=class extends B{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new Vt(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new gs(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e[0][0],e[0][1],.51),new bt(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new j(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return mi(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new bt(i[0]-e[0],i[1]-e[1],0).normalize(),o=new bt(0,1,0).normalize(),n=s.angleTo(o),r=new bt().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new fd(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return f(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return ft(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new _o(h,this.tweenUtil.group).to(c,n).easing(md.Quadratic.InOut).onUpdate(()=>f(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return f(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>ft(f(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=C(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new bt(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new bt(d.x,d.y,0))}return ft(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let m=new _o(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(m),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,r=e/(o.x-n.x),h=i/(o.y-n.y),l=(r>h?e:i)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(l,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return f(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=nn(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),ft(new Promise(l=>{let p=this.pathTween=new _o({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>f(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return f(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=ve(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e.x,e.y,.51),new bt(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,s=(360-t-i)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=s),this.startPoi&&(this.startPoi.options.icon_rotate=s,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(s))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),Vt.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new Qt,this.taskQueue=new we,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},gd,i),this.positionNavigation=new ys(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Group as yd,Color as Tr}from"three";var kr=class extends B{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new Tr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.visible=!1;return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new Tr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.visible=!0,i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.floors=[],this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new yd,this.showStatus=!1,this.group.name="mul-floor-group"}};import{EventDispatcher as vd}from"three";import{merge as xd}from"lodash";function Po(){return new Worker(new URL("./worker/path.worker-W3VDPRQY.js",import.meta.url))}var Dr={useWorker:!1},vs=class extends vd{setLiftPriority(t){return f(this,null,function*(){var e;(e=this.roadNetwork)==null||e.setLiftPriority(t),this.worker&&(yield F(this.worker,"onSetLiftPriority",t))})}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),this.roadNetwork&&this.roadNetwork.initRoute(t,e),this.worker&&(yield F(this.worker,"set_road_info",{roadData:t,facilities:e})),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>f(this,null,function*(){yield this.loaded();function c(l){l?typeof l=="string"?h(l):r(l):h("no-path")}if(this.roadNetwork){let l=this.roadNetwork.getPath(t,e,i,s,o,n);c(l)}else if(this.worker){let l=yield F(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n});c(l)}else console.log("\u6CA1\u6709\u521D\u59CB\u5316\u8DEF\u7F51"),h("no-road-network")}))})}getDirectionPath(t){return f(this,null,function*(){return this.worker?F(this.worker,"get_direction_path",t):on(t)})}dispose(){return f(this,null,function*(){this.roadNetwork&&this.roadNetwork.clear(),this.worker&&(yield F(this.worker,"clear",""),this.worker.terminate())})}constructor(t=Dr){super(),this.worker=null,this.initRoadStatus=!1,this.roadNetwork=null,this.options=xd({},Dr,t),this.options.useWorker?this.worker=Po():this.roadNetwork=new gi}};import{EventDispatcher as wd}from"three";function bo(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",import.meta.url))}var Ar=class extends wd{setRoadData(t){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield F(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{F(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return F(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){F(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=bo(),this.initRoadStatus=!1}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{Frustum as Md}from"three";var xs=class extends vt{setEnable(t){super.setEnable(t),ot(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=C(this.startPoint,e,i,s),n=C(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof Y&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=C(d,s,o,n);return Yt(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=C(h,s,o,n),p=C(c,s,o,n);return!(!Yt(l,e,i)||!Yt(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new Md,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);ot(this.rect,n.x,n.y,r,h)}else ot(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=qt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var _d={boxSelection:!1,elements:["graphic","poi"]},Or=class extends B{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let m=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;m&&(h.add(d.options.id),c.push(m))}})}(!this.options.boxSelection||!(ge?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{ye(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{ye(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},_d,e),this.boxSelection=new xs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.array.push.js";import{cloneDeep as Pd,isNil as ee,throttle as Ir}from"lodash";var O=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var bd={time:1e3,elements:[O.COMPASS,O.DEVICE_MOTION,O.ACCELERATION,O.GPS]},ws=class extends X{start(){this.options.elements.some(t=>[O.DEVICE_MOTION,O.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(O.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(O.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:Pd(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Ut?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:O.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return f(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return f(this,null,function*(){var t;if(!Ut)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Ut?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),ee(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new z,this.dispatchTimer=null,this.addAcceleration=Ir(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=Ir(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if(ee(s)||ee(o)||ee(n))return;let r;Ut?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(O.DEVICE_MOTION)&&this.addDataItem({type:O.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(O.COMPASS)&&this.addDataItem({type:O.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;ee(i)||ee(i.x)||ee(i.y)||ee(i.z)||this.addAcceleration({type:O.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},bd,t)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";function Ms(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function ii(a){return(a+360)%360}function Rr(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function Re(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var _s=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=ii(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=ii(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=ii(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=Ms(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=Re(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Ms(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=Re(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*Ms(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=Re(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=ii(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";var Ps=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var Sd={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},bs=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===O.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===O.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===O.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===O.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===O.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===O.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:Rr(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=Re(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},Sd,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new _s({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new Ps}};import{booleanPointInPolygon as Ed,point as Ld}from"@turf/turf";var Ss=class extends X{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&Ed(Ld([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===O.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new ws(e.sensor),this.pdr=new bs(e.pdr||{})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Object3D as Td,TextureLoader as kd,Color as Dd,Vector2 as So,Vector3 as Ad,NormalBlending as Od,RepeatWrapping as Id,Box3 as Rd}from"three";import{ShaderLib as Es,ShaderMaterial as Cd,UniformsLib as Ls,UniformsUtils as Fr,Vector2 as Gr}from"three";Ls["custom-line"]={linewidth:{value:1},resolution:{value:new Gr(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new Gr(1,1)},allDistance:{value:1}};Es["custom-line"]={uniforms:Fr.merge([Ls.common,Ls.fog,Ls["custom-line"]]),vertexShader:`
|
|
509
509
|
#include <common>
|
|
510
510
|
#include <color_pars_vertex>
|
|
511
511
|
#include <fog_pars_vertex>
|
package/lib/meta.json
CHANGED
|
@@ -2972,7 +2972,7 @@
|
|
|
2972
2972
|
"format": "esm"
|
|
2973
2973
|
},
|
|
2974
2974
|
"../lib/src/elements/poi2.js": {
|
|
2975
|
-
"bytes":
|
|
2975
|
+
"bytes": 16947,
|
|
2976
2976
|
"imports": [
|
|
2977
2977
|
{
|
|
2978
2978
|
"path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
|
|
@@ -5318,7 +5318,7 @@
|
|
|
5318
5318
|
"format": "esm"
|
|
5319
5319
|
},
|
|
5320
5320
|
"../lib/src/plugins/navigation/navigation.js": {
|
|
5321
|
-
"bytes":
|
|
5321
|
+
"bytes": 30494,
|
|
5322
5322
|
"imports": [
|
|
5323
5323
|
{
|
|
5324
5324
|
"path": "../../../node_modules/.pnpm/@swc+helpers@0.5.17/node_modules/@swc/helpers/esm/_extends.js",
|
|
@@ -9527,7 +9527,7 @@
|
|
|
9527
9527
|
"bytesInOutput": 1595
|
|
9528
9528
|
},
|
|
9529
9529
|
"../lib/src/elements/poi2.js": {
|
|
9530
|
-
"bytesInOutput":
|
|
9530
|
+
"bytesInOutput": 8928
|
|
9531
9531
|
},
|
|
9532
9532
|
"../lib/src/elements/heatmap.js": {
|
|
9533
9533
|
"bytesInOutput": 2123
|
|
@@ -9656,7 +9656,7 @@
|
|
|
9656
9656
|
"bytesInOutput": 205
|
|
9657
9657
|
},
|
|
9658
9658
|
"../lib/src/plugins/navigation/navigation.js": {
|
|
9659
|
-
"bytesInOutput":
|
|
9659
|
+
"bytesInOutput": 15187
|
|
9660
9660
|
},
|
|
9661
9661
|
"../lib/src/plugins/navigation/path.js": {
|
|
9662
9662
|
"bytesInOutput": 2839
|
|
@@ -9764,7 +9764,7 @@
|
|
|
9764
9764
|
"bytesInOutput": 575
|
|
9765
9765
|
}
|
|
9766
9766
|
},
|
|
9767
|
-
"bytes":
|
|
9767
|
+
"bytes": 406133
|
|
9768
9768
|
}
|
|
9769
9769
|
}
|
|
9770
9770
|
}
|