@aibee/crc-bmap 0.6.10 → 0.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bmap.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +2 -2
- package/lib/bmap.esm.js +3 -1
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +1 -1
- package/lib/bmap.esm.min.js.map +2 -2
- package/lib/bmap.min.js +1 -1
- package/lib/bmap.min.js.map +2 -2
- package/package.json +1 -1
package/lib/bmap.cjs.min.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
void main() {
|
|
36
36
|
gl_FragColor = vec4(vColor.x, vColor.y, vColor.z, opacity);
|
|
37
37
|
}
|
|
38
|
-
`,h=new H.ShaderMaterial({uniforms:{uColor:{value:new H.Color(e[0]).convertLinearToSRGB()},uGradualColor:{value:new H.Color(e[1]).convertLinearToSRGB()},center:{value:t},maxValue:{value:n},opacity:{value:r},uDirection:{value:i},uMax:{value:o},uMin:{value:a}},vertexShader:u,fragmentShader:c,side:H.DoubleSide});return this.shaderMaterialMap.set(l,h),h}static createLine2MaterialMap({color:e,width:t,dashed:n,resolution:r}){let i=`${e}-${t}-${n}-${r.x}-${r.y}`;if(this.line2MaterialMap.has(i))return this.line2MaterialMap.get(i);let o=new yr.LineMaterial({color:parseInt(e.slice(1),16),dashed:n,linewidth:t,worldUnits:!0,dashSize:1,gapSize:3,dashScale:1,resolution:r});return this.line2MaterialMap.set(i,o),o}static dispose(){this.lineMaterialMap.forEach((e,t)=>{e.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((e,t)=>{e.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((e,t)=>{e.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((e,t)=>{e.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((e,t)=>{e.dispose()}),this.line2MaterialMap.clear()}};var Ot=require("three");var vt=class{static canvas=document.createElement("canvas");static ctx=this.canvas.getContext("2d");static cacheMap=new Map;static options={width:1024,height:64,font:"54px sans-serif",textBaseline:"hanging",lineWidth:12,fillStyle:"rgba(0,0,0,1)",strokeStyle:"white"};static getCanvas(){if(this.canvas)return this.canvas;{let e=document.createElement("canvas");return this.canvas=e,e}}static getCtx(){if(this.ctx)return this.ctx;let t=this.getCanvas().getContext("2d");return this.ctx=t,t}static getMergedOptions(e){return{...this.options,...e}}static setCtxStyle(e){let t=this.getCanvas(),n=this.getCtx();t.width=e.width,t.height=e.height,n.font=e.font,n.textBaseline=e.textBaseline,n.lineWidth=e.lineWidth,n.fillStyle=e.fillStyle,n.strokeStyle=e.strokeStyle}static getTextureByText(e,t){let n=this.getMergedOptions(t),r=Lt({...n,text:e});if(this.cacheMap.has(r))return this.cacheMap.get(r);let i=this.getCanvas(),o=this.getCtx();o.clearRect(0,0,i.width,i.height),this.setCtxStyle(n);let a=Qe(e)?4:8;n.lineWidth&&o.strokeText(e,2,a),o.fillText(e,2,a);let l=Math.ceil(o.measureText(e).width);l=l%2===0?l:l+1,l+=2;let u=o.getImageData(0,0,l,64),c=new Ot.DataTexture(Uint8Array.from(u.data),l,64,Ot.RGBAFormat);return c.flipY=!0,c.minFilter=Ot.LinearFilter,c.magFilter=Ot.LinearFilter,this.cacheMap.set(r,c),c}static dispose(){this.ctx=null,this.canvas=null,this.cacheMap.forEach(e=>e.dispose()),this.cacheMap.clear()}};var Ft=require("three"),xt=class{static textureLoader=new Ft.TextureLoader;static urlTextureMap=new Map;static getTextureByUrl(e){if(this.urlTextureMap.has(e))return this.urlTextureMap.get(e);let t=this.textureLoader.loadAsync(e);return t.then(n=>{n.format=Ft.RGBAFormat,n.magFilter=Ft.LinearFilter,n.minFilter=Ft.LinearFilter,n.colorSpace="srgb",this.urlTextureMap.set(e,n)}),this.urlTextureMap.set(e,t),t}static dispose(){this.urlTextureMap.forEach(e=>{e instanceof Promise?e.then(t=>t.dispose()):e.dispose()}),this.urlTextureMap.clear()}};var vr=require("three/examples/jsm/loaders/GLTFLoader"),Et=class{static loader=new vr.GLTFLoader;static modelMap=new Map;static async loadModel(e){if(this.modelMap.has(e)){let n=this.modelMap.get(e);if(n instanceof Promise)n.then(r=>({...r,scene:r.scene.clone()}));else return{...n,scene:n.scene.clone()}}let t=new Promise((n,r)=>{this.loader.load(e,i=>{n(i),this.modelMap.set(e,i)},void 0,r)});return this.modelMap.set(e,t),t.then(n=>({...n,scene:n.scene.clone()}))}static dispose(){this.modelMap.forEach(e=>{e instanceof Promise?e.then(t=>V(t.scene)):V(e.scene)}),this.modelMap.clear()}};var xr=require("lodash"),Te={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},R=class extends v.Object3D{constructor(t,n){super();this.context=t;if(this.options=At((0,xr.cloneDeep)({...Te,...n}),this),this.options.geometry.type==="point"){let[r,i]=this.options.geometry.coords;return this.position.set(r,i,this.options.height+this.options.airHeight),this}this.initDoor(),this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:r})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:r})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:r})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:r})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:r})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:r})=>{this.position.z=r}),this.addEventListener("change-visible",({value:r})=>{this.visible=r}),this.addEventListener("change-stroke",({value:r})=>{if(r){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),this.lineGeometry?.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}geometry;material;mesh;line;lineMaterial;lineGeometry;options;getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new v.Vector3,n=new v.Box3;return n.setFromObject(this),n.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new v.Vector3(0,0,0);let t=new v.Box3,n=new v.Vector3;return t.setFromObject(this),t.getSize(n),n}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height/2),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&this.options.strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initDoor(){if(this.options.doors?.length&&this.options.geometry.type==="polygon"){let t=this.options.geometry.coords[0];this.options.doors.forEach(n=>{let r=n.type==="single"?.5:1,i=.5,o=Pt(t,n.coord),a=new v.Vector2(...n.coord),l=new v.Vector2(...t[o]).sub(new v.Vector2(...n.coord)).normalize(),u=new v.Vector2().addVectors(a,l.clone().multiplyScalar(r)),c=new v.Vector2().addVectors(a,l.clone().multiplyScalar(-r)),h=new v.Vector2(-l.y,l.x),p=new v.Vector2().addVectors(u,h.clone().multiplyScalar(i));nn([p.x,p.y],t)||(h.multiplyScalar(-1),p=new v.Vector2().addVectors(u,h.clone().multiplyScalar(i)));let d=new v.Vector2().addVectors(c,h.clone().multiplyScalar(i)),m=[[u.x,u.y],[p.x,p.y],[d.x,d.y],[c.x,c.y]];this.options.geometry.coords=[[...t.slice(0,o+1),...m,...t.slice(o+1)]],t=this.options.geometry.coords[0]})}}initGeometry(){let t=st(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new v.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=I.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let n=I.createMeshBasicMaterial({color:pt(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,n],[t,n]}getMaxAndMin(t,n){let r=new v.Box3().setFromObject(this),i=t.clone().add(n.clone().multiplyScalar(1e3)),o=new v.Ray(i,n.clone().multiplyScalar(-1)),a=new v.Vector3;o.intersectBox(r,a);let l=t.clone().add(n.clone().multiplyScalar(-1e3)),u=new v.Ray(l,n.clone()),c=new v.Vector3;return u.intersectBox(r,c),{max:c,min:a}}initGradualMaterial(){let{max:t,min:n}=new v.Box3().setFromObject(this),r=t.clone().sub(n),i=Math.max(r.x,r.y,r.z)/2,o=this.getPosition(),a=new v.Vector3(-1,.2,0).normalize(),{max:l,min:u}=this.getMaxAndMin(o,a),c=I.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:i,opacity:this.options.fillOpacity,direction:new v.Vector3(-1,.2,0),max:l,min:u});if(this.options.height<=.1)return this.material=c,c;let h=this.getCenter(),p=new v.Vector3(-1,.2,1).normalize(),{max:d,min:m}=this.getMaxAndMin(h,p),f=I.createShaderMaterial({gradualColor:[pt(this.options.gradualColor[0],this.options.colorFactor),pt(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:i,opacity:this.options.fillOpacity,direction:new v.Vector3(-1,.2,1),max:d,min:m});return this.material=[c,f],[c,f]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=I.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new v.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],n=this.options.height+this.options.deltaHeight,{coords:r}=this.options.geometry;for(let i=0;i<r.length;i++){let o=r[i];for(let a=0;a<o.length;a++){let l=o[a],u=a+1===o.length?o[0]:o[a+1];t.push(new v.Vector3(l[0],l[1],n)),t.push(new v.Vector3(u[0],u[1],n))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),n=new v.BufferGeometry().setFromPoints(t);this.lineGeometry=n}createBorder(){this.line&&this.remove(this.line);let t=new v.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;this.mesh.updateMatrixWorld(!0);let n=t.intersectObject(this.mesh);if(n[0]){let{point:r,distance:i}=n[0];return{position:r,distance:i}}return!1}dispose(){this.geometry?.dispose(),this.line?.geometry.dispose(),this.clear()}};var it=require("three");var ne=class extends it.Object3D{directionalLight;plane;basicOpacity=.07;constructor(){super(),this.directionalLight=this.initLight(),this.initPlane()}initLight(){let e=Je(16777215,.5);return e.position.set(0,0,100),this.add(e),e}changeLightCamera(e){let t=e.x,n=e.y;this.directionalLight.shadow.camera.left=-t,this.directionalLight.shadow.camera.right=t,this.directionalLight.shadow.camera.top=n,this.directionalLight.shadow.camera.bottom=-n,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(t,n)}changeLightColor(e){this.directionalLight.color=new it.Color(e)}setPosition(e){this.position.copy(e),this.directionalLight.position.set(-e.x/2,-e.y/2,100)}initPlane(e=1e3,t=1e3){let n=new it.PlaneGeometry(e,t),r=new it.ShadowMaterial({transparent:!0,opacity:0,side:it.DoubleSide}),i=new it.Mesh(n,r);return i.receiveShadow=!0,i.position.z=-10,this.add(i),this.plane=i,i}setTarget(e){this.directionalLight.target=e}transformOpacity(e){return e*this.basicOpacity}setOpacity(e){this.plane.material.opacity=this.transformOpacity(e)}dispose(){V(this,!0)}};var Ce=require("three");var M=require("three");var Er=require("lodash");var Gi={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},re=class extends M.EventDispatcher{constructor(t,n={}){super();this.context=t;this.options={...Gi,...n},this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}div;element;position=new M.Vector3;clientPos={x:0,y:0};visible=!0;options;placement="top";observer=null;initObserver(){let t=new MutationObserver((0,Er.debounce)(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){if(this.element instanceof R&&this.element.options.geometry.type==="polygon"){let{max:i,min:o}=new M.Box3().setFromObject(this.element),a=(i.x+o.x)/2,l=(i.y+o.y)/2;return{left:new M.Vector3(o.x,l,i.z),leftTop:new M.Vector3(o.x,i.y,i.z),top:new M.Vector3(a,i.y,i.z),rightTop:new M.Vector3(i.x,i.y,i.z),right:new M.Vector3(i.x,l,i.z),rightBottom:new M.Vector3(i.x,o.y,i.z),bottom:new M.Vector3(a,o.y,i.z),leftBottom:new M.Vector3(o.x,o.y,i.z),center:new M.Vector3(a,l,i.z)}}let{x:t,y:n,z:r}=this.element?.getPosition?.()||this.position;return{left:new M.Vector3(t,n,r),leftTop:new M.Vector3(t,n,r),top:new M.Vector3(t,n,r),rightTop:new M.Vector3(t,n,r),right:new M.Vector3(t,n,r),rightBottom:new M.Vector3(t,n,r),bottom:new M.Vector3(t,n,r),leftBottom:new M.Vector3(t,n,r),center:new M.Vector3(t,n,r)}}getPlacementScreenPosition(){let{width:t,height:n}=this.context.clientSize,r=this.getPlacementPosition();return Object.keys(r).reduce((i,o)=>{let{x:a,y:l}=y(r[o],this.context.camera,t,n);return i[o]={x:a,y:l},i},{})}checkOverflow(t,n){let{width:r,height:i}=this.context.clientSize;return n.x>0&&t.x<r&&n.y<i&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:n}=this.div,r=this.getPlacementScreenPosition(),i=t/2,o=n/2,a=[{type:"center",getBox(l,u){return{max:{x:i+l,y:u-n},min:{x:l-i,y:u}}}},{type:"left",getBox(l,u){return{max:{x:l,y:u-o},min:{x:l-t,y:u+o}}}},{type:"leftTop",getBox(l,u){return{max:{x:l,y:u-n},min:{x:l-t,y:u}}}},{type:"top",getBox(l,u){return{max:{x:l+i,y:u-n},min:{x:l-i,y:u}}}},{type:"rightTop",getBox(l,u){return{max:{x:l+t,y:u-n},min:{x:l,y:u}}}},{type:"right",getBox(l,u){return{max:{x:l+t,y:u-o},min:{x:l,y:u+o}}}},{type:"rightBottom",getBox(l,u){return{max:{x:l+t,y:u},min:{x:l,y:u+n}}}},{type:"bottom",getBox(l,u){return{max:{x:l+i,y:u},min:{x:l-i,y:u+n}}}},{type:"leftBottom",getBox(l,u){return{max:{x:l,y:u},min:{x:l-t,y:u+o}}}}];for(let l=0;l<a.length;l++){let u=a[l],c=r[u.type],{max:h,min:p}=u.getBox(c.x,c.y);if(this.checkOverflow(h,p))return{type:u.type,position:c}}return{type:"center",position:r.center}}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}usePlacement(){let t=this.getPlacement();this.div.className=`overlay_${t.type}`,this._updatePosition(t.position.x,t.position.y)}bindElement(t){this.element=t,this.options.autoChangePlacement&&this.initObserver(),this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,n="block"){t!==this.visible&&(this.div.style.display=t?n:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new M.Box3().setFromObject(this.element).getCenter(new M.Vector3):this.position}get withinDisplayRange(){let{x:t,y:n}=this.clientPos,{width:r,height:i}=this.context.clientSize;return t>=0&&t<=r&&n>=0&&n<=i}_updatePosition(t,n){this.clientPos={x:t,y:n};let{width:r,height:i,x:o,y:a}=this.context.clientSize;this.options.appendToBody&&(this.div.style.left=`${o}px`,this.div.style.top=`${a+i}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${t}px, ${-i+n}px, 0)`:this.dispatchEvent({type:"update-position",x:t,y:n,width:r,height:i})}updatePosition(t=!1){let n=this.getPosition(),{width:r,height:i}=this.context.clientSize,{x:o,y:a}=y(n,this.context.camera,r,i);this.clientPos.x===o&&this.clientPos.y===a&&!t||this._updatePosition(o,a)}onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()};registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.observer?.disconnect(),this.div?.remove(),this.div=null}};var zi={texts:[{text:""}],level:1,icon_position:"bottom",collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},bt=class extends Ce.EventDispatcher{constructor(t,n){super();this.context=t;this.options=At({...zi,...n},this),this.position.set(n.position?.x||0,n.position?.y||0,n.position?.z||0),this.overlay=new re(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:r,y:i,height:o})=>{this.overlay.div.style.transform=`translate3d(calc(${r}px - 50%), calc(${-o+i}px - ${this.options.icon&&this.options.icon_position!=="center"?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:r})=>{r?this.img?this.img.setAttribute("src",r):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:r})=>{let i=this.textDiv;if(i){let o=this.initText();this.div.replaceChild(o,i)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",({value:r})=>{this.overlay.setOpacity(r)}),this.addEventListener("change-icon_size",({value:r})=>{this.img&&(this.img.style.width=`${r?.[0]||32}px`,this.img.style.height=`${r?.[1]||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:r})=>{this.img&&(this.img.style.opacity=`${r}`)}),this.addEventListener("change-icon_border",({value:r})=>{this.img&&(this.img.style.border=`${r.width}px solid ${r.color}`)}),this.addEventListener("change-background",({value:r})=>{this.div.style.background=r})}div;textDiv;img;overlay;options;visible=!0;size={width:0,height:0};position=new Ce.Vector3;userData={};showTextStatus=!0;disposed=!1;get withinDisplayRange(){return this.overlay.withinDisplayRange}async resetSize(){if(await on(),!this.disposed)if(this.options.box_only_icon){if(!this.img)return;let{width:t,height:n}=this.img.getBoundingClientRect();this.size={width:t+2,height:n+2}}else{let{width:t,height:n}=this.div.getBoundingClientRect();this.size={width:t+2,height:n+2}}}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return this.div=t,this.addText(),this.options.icon&&this.addIcon(),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t)}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(n=>{let r=document.createElement("div");if(r.style.whiteSpace="nowrap",n.styles)for(let[i,o]of Object.entries(n.styles))r.style[i]=o;r.textContent=n.text,t.appendChild(r)}),t}initIcon(){let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${this.options.icon_size?.[0]||32}px`,t.style.height=`${this.options.icon_size?.[1]||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}_changePosition=()=>{this.overlay.updatePosition(!0)};registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:n,height:r}=this.size,i=n*t,o=r*t,{x:a,y:l}=this.overlay.clientPos;return{left:a-i/2,right:a+i/2,top:this.options.icon?l-o:l-o/2,bottom:this.options.icon?l:l+o/2}}getOriginBox(){return this.getBox(1)}isContain(t,n){if(!this.overlay.visible||!this.visible)return!1;let r=this.getOriginBox();return t>=r.left&&t<=r.right&&n>=r.top&&n<=r.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose(),this.disposed=!0}};var j=require("three");var O=require("three"),br=require("@mars3d/heatmap.js"),St=require("@turf/turf"),ie=class extends O.Object3D{constructor(t){super();this.context=t;this.div=document.createElement("div")}heatmap;div;plane;clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:n,height:r,leftTop:i,center:o}=this.getBox(t);this.heatmap=(0,br.create)({width:n,height:r,container:this.div,...this.context.config.heatMap}),this.heatmap.setData(this.transformData(t,i)),this.initPlane(n,r),this.position.set(o[0],o[1],this.position.z)}initPlane(t,n){this.plane&&this.remove(this.plane);let r=new O.PlaneGeometry(t,n),i=new O.Texture(this.div.firstChild);i.needsUpdate=!0;let o=new O.MeshBasicMaterial({transparent:!0,side:O.DoubleSide,map:i});o.needsUpdate=!0,this.plane=new O.Mesh(r,o),this.add(this.plane)}getTransMatrix({x:t,y:n}){return new O.Matrix3().makeScale(1,-1).multiply(new O.Matrix3().makeTranslation(0-t,0-n))}transformData(t,n){let r=this.getTransMatrix(n);return{data:t.data.map(o=>{let a=new O.Vector2(o.x,o.y).applyMatrix3(r);return{x:a.x,y:a.y,value:o.value}}),max:t.max,min:t.min}}getBox(t){let n=(0,St.featureCollection)(t.data.map(u=>(0,St.point)([u.x,u.y]))),r=(0,St.bbox)(n),i=r[2]-r[0],o=r[3]-r[1],a={x:r[0],y:r[3]},l=(0,St.center)(n);return{width:i,height:o,leftTop:a,center:l.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var Pe=require("three");var oe=class extends Pe.Object3D{constructor(t,n){super();this.context=t;this.options=n;this.position.copy(n.position||new Pe.Vector3(0,0,0)),this.loadModel()}model=null;async loadModel(){let t=await Et.loadModel(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t}dispose(){V(this),this.model=null}};var Ae=require("three");var Sr=require("three");var F=class extends Sr.Object3D{constructor(t){super();this.context=t}dispose(){V(this),this.children.forEach(t=>t.dispose?.()),this.clear()}};var se=class extends F{graphicMap=new Map;constructor(e){super(e)}getCenter(){return new Ae.Box3().setFromObject(this).getCenter(new Ae.Vector3)}createGraphic(e){let t=new R(this.context,e);return this.add(t),this.graphicMap.set(e.id,t),t}removeGraphic(e){this.remove(e),this.graphicMap.delete(e.options.id),e.dispose()}removeGraphicById(e){this.graphicMap.has(e)&&this.removeGraphic(this.graphicMap.get(e))}getGraphicByNodeId(e){return this.graphicMap.get(e)||null}getGraphicByRaycaster(e){let t={distance:1e4,graphic:null,position:null},n=this.children.reduce((r,i)=>{if(i instanceof R){let o=i.raycast(e);if(o){let{distance:a}=o;if(a<r.distance)return{distance:o.distance,position:o.position,graphic:i}}return r}else return r},t);return n===t?{graphics:[],position:null}:{graphics:[n.graphic],position:n.position}}};var Mr=require("lodash");var ae=class extends F{pois=[];debounceCollisionDetection;timer=new D;constructor(e){super(e),this.registryEvent(),this.debounceCollisionDetection=(0,Mr.debounce)(this.collisionDetection,10)}clear(e=!1){return this.pois.forEach(t=>{t.options.built_in&&!e||t.dispose()}),this.pois=e?[]:this.pois.filter(t=>t.options.built_in),this}createPoi(e){let t=new bt(this.context,e);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.pois.splice(t,1),this.pushPoi(e))}removePoi(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.pois.splice(t,1),e.dispose())}removePoiById(e){let t=this.pois.find(n=>n.options.id===e);t&&this.removePoi(t)}getPoiById(e){return this.pois.find(n=>n.options.id===e)||null}pushPoi(e){if(!e.options.collision_enable){this.pois.unshift(e);return}if(e.options.level===0){this.pois.push(e);return}for(let t=0;t<this.pois.length;t++){let n=this.pois[t];if(n.options.collision_enable&&n.options.level<=e.options.level){this.pois.splice(t,0,e);return}}this.pois.push(e)}getPoiByDeviceXy(e,t){return this.pois.filter(r=>r instanceof bt&&r.isContain(e,t))}onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let e=[];this.pois.filter(n=>n.visible&&n.withinDisplayRange).forEach((n,r)=>{let{left:i,right:o,top:a,bottom:l}=n.getBox();if(r===0||!n.options.collision_enable){e.push({left:i,right:o,top:a,bottom:l}),n.parentSetVisible(!0);return}let u=e.some(c=>c.left<o&&c.right>i&&c.top<l&&c.bottom>a);n.parentSetVisible(!u),u||e.push({left:i,right:o,top:a,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(e=>e.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var xn=require("lodash");var Ie=require("three"),Ut=class extends F{pois=[];debounceCollisionDetection;debounceChangeParkingSpaceVisibleByZoom;timer=new D;constructor(e){super(e),this.registryEvent(),this.debounceCollisionDetection=(0,xn.debounce)(this.collisionDetection,10),this.debounceChangeParkingSpaceVisibleByZoom=(0,xn.debounce)(this.changeParkingSpaceVisibleByZoom,10)}clear(){return this.pois.forEach(e=>{e.dispose()}),this.pois=[],this}createPoi(e){let t=new q(this.context,e);return this.pushPoi(t),t}changePoiLevelOrCollisionEnable(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.pois.splice(t,1),this.pushPoi(e))}removePoi(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.remove(e),this.pois.splice(t,1),e.dispose())}removePoiById(e){let t=this.pois.find(n=>n.options.id===e);t&&this.removePoi(t)}getPoiById(e){return this.pois.find(n=>n.options.id===e)||null}pushPoi(e){if(this.add(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceChangeParkingSpaceVisibleByZoom(),this.debounceCollisionDetection()}),!e.options.collision_enable){this.pois.unshift(e);return}if(e.options.level===0){this.pois.push(e);return}for(let t=0;t<this.pois.length;t++){let n=this.pois[t];if(n.options.collision_enable&&n.options.level<=e.options.level){this.pois.splice(t,0,e);return}}this.pois.push(e)}getPoiByDeviceXy(e,t){let n=new Ie.Vector2(e,t);return this.pois.filter(i=>i instanceof q&&i.canSelect&&i.box.containsPoint(n))}changeParkingSpaceVisibleByZoom=()=>{let e=this.parent?.parent;if(e&&e instanceof ct){let{clientSize:{width:t,height:n}}=this.context,{max:r,min:i}=e.box,a=Math.min(t/(r.x-i.x),n/(r.y-i.y))*(r.x-i.x)/45;this.pois.filter(l=>l.userData.type==="parkingSpace").map(l=>{let u=this.context.camera.zoom>=a;l.visible=u,u||l.parentSetVisible(u)})}};onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let e=[],{camera:t}=this.context;t.updateMatrixWorld();let n=o=>o<=1&&o>=-1,r=t.projectionMatrix.clone();r.multiply(t.matrixWorldInverse),this.pois.filter(o=>{if(o.visible){let a=o.spriteIcon?o.spriteIcon?.matrixWorld:o.spriteText?.matrixWorld||o.matrixWorld,l=new Ie.Vector3().setFromMatrixPosition(a);return l.applyMatrix4(r),o.screenPosition=l,n(l.x)&&n(l.y)&&n(l.z)}return!1}).forEach((o,a)=>{let l=o.getBox(o.screenPosition);if(a===0||!o.options.collision_enable){e.push(l),o.parentSetVisible(!0);return}let u=e.some(c=>c.intersectsBox(l));o.parentSetVisible(!u),u||e.push(l)})}registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}dispose(){this.timer.dispose(),this.pois.forEach(e=>e.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var ct=class extends j.Object3D{constructor(t){super();this.context=t;this.groundLayer=new F(this.context),this.graphicLayer=new se(this.context),this.poiLayer=new ae(this.context),this.poiLayer2=new Ut(this.context),this.wallLayer=new F(this.context),this.textureLayer=new F(this.context),this.glbModelLayer=new F(this.context),this.laneLayer=new F(this.context),this.mergeGraphicLayer=new F(this.context),this.textTextureLayer=new F(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),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)}graphicLayer;poiLayer;poiLayer2;wallLayer;textureLayer;glbModelLayer;laneLayer;mergeGraphicLayer;textTextureLayer;grounds=new Set;groundLayer;shadow=new ne;heatmap;groundUpper=new j.Object3D;models=new j.Object3D;modelMap=new Map;groundMaxHeight=0;name="";key="";box=new j.Box3;getPosition(){return this.box.getCenter(new j.Vector3)}createGround(t){let n=new R(this.context,t);this.addGrounds([n])}addGrounds(t){t.forEach(n=>{this.grounds.has(n)||(n.mesh.castShadow=!0,this.grounds.add(n),this.groundLayer.add(n))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(n=>n.options.height+n.options.airHeight+n.options.deltaHeight)):0,this.groundUpper.position.z=this.groundMaxHeight+.001}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new j.Box3().setFromObject(this).getCenter(new j.Vector3)}addModel(t){let n=new oe(this.context,t);return this.models.add(n),this.modelMap.set(t.id,n),n}addShadow(){let t=new j.Box3().setFromObject(this.groundUpper),n=t.getCenter(new j.Vector3),r=t.getSize(new j.Vector3);this.shadow.setPosition(n),this.shadow.changeLightCamera(r)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new ie(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let n=new j.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(n.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}updateBox(){this.box.setFromObject(this)}dispose(){console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.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.heatmap?.dispose(),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var Re=require("three");var J=class extends Re.EventDispatcher{constructor(t){super();this.context=t;this.svg=rn(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}points=[];svg;enable=!0;_onResize=({width:t,height:n})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${n}`))};_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:n,renderer:r}=this.context,{offsetX:i,offsetY:o}=t,{clientWidth:a,clientHeight:l}=r.domElement,u=i/a*2-1,c=1-o/l*2;return new Re.Vector3(u,c,0).unproject(n)}getSvgCoordinate(t){let{camera:n,container:r}=this.context;return y(t,n,r.clientWidth,r.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var le=class extends J{constructor(t){super(t);this.context=t;let{config:{svg:{circle:n,line:r}}}=t;this.circles=[Vt(n.radius,n.fill),Vt(n.radius,n.fill)],this.line=te(r.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}circles;line;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)}onUpdate=()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);_t(this.circles[0],t.x,t.y),et(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);_t(this.circles[1],t.x,t.y),et(this.line,void 0,t)}};onPointermove=t=>{this.points.length===1&&(this.line.style.display="block",et(this.line,void 0,{x:t.offsetX,y:t.offsetY}))};onPointerleave=()=>{this.points[1]||(this.line.style.display="none")};onPointerdown=t=>{if(this.points[1])return;let n=this.getIntersectByPointerEvent(t);if(n){let{offsetX:r,offsetY:i}=t,o=this.circles[this.points.length];_t(o,r,i),this.points.length||et(this.line,{x:r,y:i},{x:r,y:i}),this.addPoint(n)}};addPoint(t){if(this.points.push(t),this.points.length>=2){let n=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:n})}}calculatedDistance(){let[{x:t,y:n},{x:r,y:i}]=this.points;return Math.sqrt((r-t)**2+(i-n)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var ue=class extends J{circles=[];lines=[];isClose=!1;constructor(e){super(e),this.registryEvent()}setEnable(e){super.setEnable(e),e?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(e){this.circles.push(e),this.svg.appendChild(e)}addLine(e){this.lines.push(e),this.svg.appendChild(e)}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)}onUpdate=()=>{this.points.length&&this.points.forEach((e,t)=>{let n=this.getSvgCoordinate(e);this.circles[t]&&_t(this.circles[t],n.x,n.y),t!==0&&et(this.lines[t-1],void 0,n),this.lines[t]&&et(this.lines[t],n)})};onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",et(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))};onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")};onPointerdown=e=>{if(this.isClose)return;let t=this.getIntersectByPointerEvent(e);if(t){let{offsetX:n,offsetY:r}=e;this.checkAdsorb(n,r)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(t);let{circle:{fill:i,radius:o},line:{stroke:a}}=this.context.config.svg;if(!this.isClose){let l=Vt(o,i);_t(l,n,r),this.addCircle(l)}if(this.lines.length&&et(this.lastLine,void 0,{x:n,y:r}),!this.isClose){let l=te(a);et(l,{x:n,y:r},{x:n,y:r}),this.addLine(l)}}};checkAdsorb(e,t){if(this.points.length<3)return!1;let n=this.circles[0],r=+n.getAttribute("cx"),i=+n.getAttribute("cy");return Math.sqrt((e-r)**2+(t-i)**2)<=5}addPoint(e){if(this.points.push(e),this.isClose){let t=this.calculatedArea();this.dispatchEvent({type:"area",area:t})}}calculatedArea(){let e=this.points.map(r=>[r.x,r.y]),t=0,n=e.length;for(let r=0;r<n;r++){let i=(r+1)%n;t+=e[r][0]*e[i][1]-e[i][0]*e[r][1]}return Math.abs(t/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var wr=require("three");var En=class extends J{constructor(t){super(t);this.context=t;let{config:{svg:{line:n}}}=t;this.rect=mt(n.stroke,"transparent"),this.svg.appendChild(this.rect);for(let r=0;r<4;r++)this.cornerRect[r]=mt(n.stroke,"#ffffff"),this.centerRect[r]=mt(n.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[r]),this.svg.appendChild(this.centerRect[r]);this.registryEvent()}rect;cornerRect=[];centerRect=[];graphic;setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}onUpdate=()=>{if(this.graphic){let t=new wr.Box3().setFromObject(this.graphic),{camera:n,container:{clientWidth:r,clientHeight:i}}=this.context,{min:o,max:a}=t,l=y(o,n,r,i),u=y(a,n,r,i);B(this.rect,l.x,u.y,Math.abs(u.x-l.x),Math.abs(u.y-l.y));let{x:c,y:h}=l,{x:p,y:d}=u,m=5,f=[{x:c-m,y:d-m},{x:p-m,y:d-m},{x:c-m,y:h-m},{x:p-m,y:h-m}];for(let b=0;b<f.length;b++)B(this.cornerRect[b],f[b].x,f[b].y,m*2,m*2);let g=4,E=(c+p)/2,x=(h+d)/2,z=[{x:E-g,y:d-g},{x:c-g,y:x-g},{x:p-g,y:x-g},{x:E-g,y:h-g}];for(let b=0;b<z.length;b++)B(this.centerRect[b],z[b].x,z[b].y,g*2,g*2)}else{B(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)B(this.cornerRect[t],0,0,0,0),B(this.centerRect[t],0,0,0,0)}};selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var P=require("three");var bn=require("three/examples/jsm/utils/BufferGeometryUtils");var ce=class extends P.Object3D{constructor(t,n){super();this.context=t;this.options=n;n.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(n=>{let r=st(n.geometry.coords[0],n.geometry.coords.slice(1));return new P.ExtrudeGeometry(r,{steps:1,bevelEnabled:!1,depth:n.height,curveSegments:4})});this.geometry=(0,bn.mergeGeometries)(t),t.forEach(n=>n.dispose())}initMaterial(){let t=`
|
|
38
|
+
`,h=new H.ShaderMaterial({uniforms:{uColor:{value:new H.Color(e[0]).convertLinearToSRGB()},uGradualColor:{value:new H.Color(e[1]).convertLinearToSRGB()},center:{value:t},maxValue:{value:n},opacity:{value:r},uDirection:{value:i},uMax:{value:o},uMin:{value:a}},vertexShader:u,fragmentShader:c,side:H.DoubleSide});return this.shaderMaterialMap.set(l,h),h}static createLine2MaterialMap({color:e,width:t,dashed:n,resolution:r}){let i=`${e}-${t}-${n}-${r.x}-${r.y}`;if(this.line2MaterialMap.has(i))return this.line2MaterialMap.get(i);let o=new yr.LineMaterial({color:parseInt(e.slice(1),16),dashed:n,linewidth:t,worldUnits:!0,dashSize:1,gapSize:3,dashScale:1,resolution:r});return this.line2MaterialMap.set(i,o),o}static dispose(){this.lineMaterialMap.forEach((e,t)=>{e.dispose()}),this.lineMaterialMap.clear(),this.meshStandardMaterialMap.forEach((e,t)=>{e.dispose()}),this.meshStandardMaterialMap.clear(),this.meshBasicMaterialMap.forEach((e,t)=>{e.dispose()}),this.meshBasicMaterialMap.clear(),this.shaderMaterialMap.forEach((e,t)=>{e.dispose()}),this.shaderMaterialMap.clear(),this.line2MaterialMap.forEach((e,t)=>{e.dispose()}),this.line2MaterialMap.clear()}};var Ot=require("three");var vt=class{static canvas=document.createElement("canvas");static ctx=this.canvas.getContext("2d");static cacheMap=new Map;static options={width:1024,height:64,font:"54px sans-serif",textBaseline:"hanging",lineWidth:12,fillStyle:"rgba(0,0,0,1)",strokeStyle:"white"};static getCanvas(){if(this.canvas)return this.canvas;{let e=document.createElement("canvas");return this.canvas=e,e}}static getCtx(){if(this.ctx)return this.ctx;let t=this.getCanvas().getContext("2d");return this.ctx=t,t}static getMergedOptions(e){return{...this.options,...e}}static setCtxStyle(e){let t=this.getCanvas(),n=this.getCtx();t.width=e.width,t.height=e.height,n.font=e.font,n.textBaseline=e.textBaseline,n.lineWidth=e.lineWidth,n.fillStyle=e.fillStyle,n.strokeStyle=e.strokeStyle}static getTextureByText(e,t){let n=this.getMergedOptions(t),r=Lt({...n,text:e});if(this.cacheMap.has(r))return this.cacheMap.get(r);let i=this.getCanvas(),o=this.getCtx();o.clearRect(0,0,i.width,i.height),this.setCtxStyle(n);let a=Qe(e)?4:8;n.lineWidth&&o.strokeText(e,2,a),o.fillText(e,2,a);let l=Math.ceil(o.measureText(e).width);l=l%2===0?l:l+1,l+=2;let u=o.getImageData(0,0,l,64),c=new Ot.DataTexture(Uint8Array.from(u.data),l,64,Ot.RGBAFormat);return c.flipY=!0,c.minFilter=Ot.LinearFilter,c.magFilter=Ot.LinearFilter,this.cacheMap.set(r,c),c}static dispose(){this.ctx=null,this.canvas=null,this.cacheMap.forEach(e=>e.dispose()),this.cacheMap.clear()}};var Ft=require("three"),xt=class{static textureLoader=new Ft.TextureLoader;static urlTextureMap=new Map;static getTextureByUrl(e){if(this.urlTextureMap.has(e))return this.urlTextureMap.get(e);let t=this.textureLoader.loadAsync(e);return t.then(n=>{n.format=Ft.RGBAFormat,n.magFilter=Ft.LinearFilter,n.minFilter=Ft.LinearFilter,n.colorSpace="srgb",this.urlTextureMap.set(e,n)}),this.urlTextureMap.set(e,t),t}static dispose(){this.urlTextureMap.forEach(e=>{e instanceof Promise?e.then(t=>t.dispose()):e.dispose()}),this.urlTextureMap.clear()}};var vr=require("three/examples/jsm/loaders/GLTFLoader"),Et=class{static loader=new vr.GLTFLoader;static modelMap=new Map;static async loadModel(e){if(this.modelMap.has(e)){let n=this.modelMap.get(e);if(n instanceof Promise)n.then(r=>({...r,scene:r.scene.clone()}));else return{...n,scene:n.scene.clone()}}let t=new Promise((n,r)=>{this.loader.load(e,i=>{n(i),this.modelMap.set(e,i)},void 0,r)});return this.modelMap.set(e,t),t.then(n=>({...n,scene:n.scene.clone()}))}static dispose(){this.modelMap.forEach(e=>{e instanceof Promise?e.then(t=>V(t.scene)):V(e.scene)}),this.modelMap.clear()}};var xr=require("lodash"),Te={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},R=class extends v.Object3D{constructor(t,n){super();this.context=t;if(this.options=At((0,xr.cloneDeep)({...Te,...n}),this),this.options.geometry.type==="point"){let[r,i]=this.options.geometry.coords;return this.position.set(r,i,this.options.height+this.options.airHeight),this}this.initDoor(),this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:r})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:r})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:r})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:r})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:r})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:r})=>{this.position.z=r}),this.addEventListener("change-visible",({value:r})=>{this.visible=r}),this.addEventListener("change-stroke",({value:r})=>{if(r){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),this.lineGeometry?.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}geometry;material;mesh;line;lineMaterial;lineGeometry;options;getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new v.Vector3,n=new v.Box3;return n.setFromObject(this),n.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new v.Vector3(0,0,0);let t=new v.Box3,n=new v.Vector3;return t.setFromObject(this),t.getSize(n),n}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height/2),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&this.options.strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initDoor(){if(this.options.doors?.length&&this.options.geometry.type==="polygon"){let t=this.options.geometry.coords[0];this.options.doors.forEach(n=>{let r=n.type==="single"?.5:1,i=.5,o=Pt(t,n.coord),a=new v.Vector2(...n.coord),l=new v.Vector2(...t[o]).sub(new v.Vector2(...n.coord)).normalize(),u=new v.Vector2().addVectors(a,l.clone().multiplyScalar(r)),c=new v.Vector2().addVectors(a,l.clone().multiplyScalar(-r)),h=new v.Vector2(-l.y,l.x),p=new v.Vector2().addVectors(u,h.clone().multiplyScalar(i));nn([p.x,p.y],t)||(h.multiplyScalar(-1),p=new v.Vector2().addVectors(u,h.clone().multiplyScalar(i)));let d=new v.Vector2().addVectors(c,h.clone().multiplyScalar(i)),m=[[u.x,u.y],[p.x,p.y],[d.x,d.y],[c.x,c.y]];this.options.geometry.coords=[[...t.slice(0,o+1),...m,...t.slice(o+1)]],t=this.options.geometry.coords[0]})}}initGeometry(){let t=st(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new v.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=I.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let n=I.createMeshBasicMaterial({color:pt(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,n],[t,n]}getMaxAndMin(t,n){let r=new v.Box3().setFromObject(this),i=t.clone().add(n.clone().multiplyScalar(1e3)),o=new v.Ray(i,n.clone().multiplyScalar(-1)),a=new v.Vector3;o.intersectBox(r,a);let l=t.clone().add(n.clone().multiplyScalar(-1e3)),u=new v.Ray(l,n.clone()),c=new v.Vector3;return u.intersectBox(r,c),{max:c,min:a}}initGradualMaterial(){let{max:t,min:n}=new v.Box3().setFromObject(this),r=t.clone().sub(n),i=Math.max(r.x,r.y,r.z)/2,o=this.getPosition(),a=new v.Vector3(-1,.2,0).normalize(),{max:l,min:u}=this.getMaxAndMin(o,a),c=I.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:i,opacity:this.options.fillOpacity,direction:new v.Vector3(-1,.2,0),max:l,min:u});if(this.options.height<=.1)return this.material=c,c;let h=this.getCenter(),p=new v.Vector3(-1,.2,1).normalize(),{max:d,min:m}=this.getMaxAndMin(h,p),f=I.createShaderMaterial({gradualColor:[pt(this.options.gradualColor[0],this.options.colorFactor),pt(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:i,opacity:this.options.fillOpacity,direction:new v.Vector3(-1,.2,1),max:d,min:m});return this.material=[c,f],[c,f]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=I.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new v.Mesh(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],n=this.options.height+this.options.deltaHeight,{coords:r}=this.options.geometry;for(let i=0;i<r.length;i++){let o=r[i];for(let a=0;a<o.length;a++){let l=o[a],u=a+1===o.length?o[0]:o[a+1];t.push(new v.Vector3(l[0],l[1],n)),t.push(new v.Vector3(u[0],u[1],n))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),n=new v.BufferGeometry().setFromPoints(t);this.lineGeometry=n}createBorder(){this.line&&this.remove(this.line);let t=new v.LineSegments(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;this.mesh.updateMatrixWorld(!0);let n=t.intersectObject(this.mesh);if(n[0]){let{point:r,distance:i}=n[0];return{position:r,distance:i}}return!1}dispose(){this.geometry?.dispose(),this.line?.geometry.dispose(),this.clear()}};var it=require("three");var ne=class extends it.Object3D{directionalLight;plane;basicOpacity=.07;constructor(){super(),this.directionalLight=this.initLight(),this.initPlane()}initLight(){let e=Je(16777215,.5);return e.position.set(0,0,100),this.add(e),e}changeLightCamera(e){let t=e.x,n=e.y;this.directionalLight.shadow.camera.left=-t,this.directionalLight.shadow.camera.right=t,this.directionalLight.shadow.camera.top=n,this.directionalLight.shadow.camera.bottom=-n,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(t,n)}changeLightColor(e){this.directionalLight.color=new it.Color(e)}setPosition(e){this.position.copy(e),this.directionalLight.position.set(-e.x/2,-e.y/2,100)}initPlane(e=1e3,t=1e3){let n=new it.PlaneGeometry(e,t),r=new it.ShadowMaterial({transparent:!0,opacity:0,side:it.DoubleSide}),i=new it.Mesh(n,r);return i.receiveShadow=!0,i.position.z=-10,this.add(i),this.plane=i,i}setTarget(e){this.directionalLight.target=e}transformOpacity(e){return e*this.basicOpacity}setOpacity(e){this.plane.material.opacity=this.transformOpacity(e)}dispose(){V(this,!0)}};var Ce=require("three");var M=require("three");var Er=require("lodash");var Gi={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},re=class extends M.EventDispatcher{constructor(t,n={}){super();this.context=t;this.options={...Gi,...n},this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}div;element;position=new M.Vector3;clientPos={x:0,y:0};visible=!0;options;placement="top";observer=null;initObserver(){let t=new MutationObserver((0,Er.debounce)(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){if(this.element instanceof R&&this.element.options.geometry.type==="polygon"){let{max:i,min:o}=new M.Box3().setFromObject(this.element),a=(i.x+o.x)/2,l=(i.y+o.y)/2;return{left:new M.Vector3(o.x,l,i.z),leftTop:new M.Vector3(o.x,i.y,i.z),top:new M.Vector3(a,i.y,i.z),rightTop:new M.Vector3(i.x,i.y,i.z),right:new M.Vector3(i.x,l,i.z),rightBottom:new M.Vector3(i.x,o.y,i.z),bottom:new M.Vector3(a,o.y,i.z),leftBottom:new M.Vector3(o.x,o.y,i.z),center:new M.Vector3(a,l,i.z)}}let{x:t,y:n,z:r}=this.element?.getPosition?.()||this.position;return{left:new M.Vector3(t,n,r),leftTop:new M.Vector3(t,n,r),top:new M.Vector3(t,n,r),rightTop:new M.Vector3(t,n,r),right:new M.Vector3(t,n,r),rightBottom:new M.Vector3(t,n,r),bottom:new M.Vector3(t,n,r),leftBottom:new M.Vector3(t,n,r),center:new M.Vector3(t,n,r)}}getPlacementScreenPosition(){let{width:t,height:n}=this.context.clientSize,r=this.getPlacementPosition();return Object.keys(r).reduce((i,o)=>{let{x:a,y:l}=y(r[o],this.context.camera,t,n);return i[o]={x:a,y:l},i},{})}checkOverflow(t,n){let{width:r,height:i}=this.context.clientSize;return n.x>0&&t.x<r&&n.y<i&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:n}=this.div,r=this.getPlacementScreenPosition(),i=t/2,o=n/2,a=[{type:"center",getBox(l,u){return{max:{x:i+l,y:u-n},min:{x:l-i,y:u}}}},{type:"left",getBox(l,u){return{max:{x:l,y:u-o},min:{x:l-t,y:u+o}}}},{type:"leftTop",getBox(l,u){return{max:{x:l,y:u-n},min:{x:l-t,y:u}}}},{type:"top",getBox(l,u){return{max:{x:l+i,y:u-n},min:{x:l-i,y:u}}}},{type:"rightTop",getBox(l,u){return{max:{x:l+t,y:u-n},min:{x:l,y:u}}}},{type:"right",getBox(l,u){return{max:{x:l+t,y:u-o},min:{x:l,y:u+o}}}},{type:"rightBottom",getBox(l,u){return{max:{x:l+t,y:u},min:{x:l,y:u+n}}}},{type:"bottom",getBox(l,u){return{max:{x:l+i,y:u},min:{x:l-i,y:u+n}}}},{type:"leftBottom",getBox(l,u){return{max:{x:l,y:u},min:{x:l-t,y:u+o}}}}];for(let l=0;l<a.length;l++){let u=a[l],c=r[u.type],{max:h,min:p}=u.getBox(c.x,c.y);if(this.checkOverflow(h,p))return{type:u.type,position:c}}return{type:"center",position:r.center}}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}usePlacement(){let t=this.getPlacement();this.div.className=`overlay_${t.type}`,this._updatePosition(t.position.x,t.position.y)}bindElement(t){this.element=t,this.options.autoChangePlacement&&this.initObserver(),this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,n="block"){t!==this.visible&&(this.div.style.display=t?n:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new M.Box3().setFromObject(this.element).getCenter(new M.Vector3):this.position}get withinDisplayRange(){let{x:t,y:n}=this.clientPos,{width:r,height:i}=this.context.clientSize;return t>=0&&t<=r&&n>=0&&n<=i}_updatePosition(t,n){this.clientPos={x:t,y:n};let{width:r,height:i,x:o,y:a}=this.context.clientSize;this.options.appendToBody&&(this.div.style.left=`${o}px`,this.div.style.top=`${a+i}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${t}px, ${-i+n}px, 0)`:this.dispatchEvent({type:"update-position",x:t,y:n,width:r,height:i})}updatePosition(t=!1){let n=this.getPosition(),{width:r,height:i}=this.context.clientSize,{x:o,y:a}=y(n,this.context.camera,r,i);this.clientPos.x===o&&this.clientPos.y===a&&!t||this._updatePosition(o,a)}onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()};registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.observer?.disconnect(),this.div?.remove(),this.div=null}};var zi={texts:[{text:""}],level:1,icon_position:"bottom",collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},bt=class extends Ce.EventDispatcher{constructor(t,n){super();this.context=t;this.options=At({...zi,...n},this),this.position.set(n.position?.x||0,n.position?.y||0,n.position?.z||0),this.overlay=new re(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:r,y:i,height:o})=>{this.overlay.div.style.transform=`translate3d(calc(${r}px - 50%), calc(${-o+i}px - ${this.options.icon&&this.options.icon_position!=="center"?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:r})=>{r?this.img?this.img.setAttribute("src",r):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:r})=>{let i=this.textDiv;if(i){let o=this.initText();this.div.replaceChild(o,i)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",({value:r})=>{this.overlay.setOpacity(r)}),this.addEventListener("change-icon_size",({value:r})=>{this.img&&(this.img.style.width=`${r?.[0]||32}px`,this.img.style.height=`${r?.[1]||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:r})=>{this.img&&(this.img.style.opacity=`${r}`)}),this.addEventListener("change-icon_border",({value:r})=>{this.img&&(this.img.style.border=`${r.width}px solid ${r.color}`)}),this.addEventListener("change-background",({value:r})=>{this.div.style.background=r})}div;textDiv;img;overlay;options;visible=!0;size={width:0,height:0};position=new Ce.Vector3;userData={};showTextStatus=!0;disposed=!1;get withinDisplayRange(){return this.overlay.withinDisplayRange}async resetSize(){if(await on(),!this.disposed)if(this.options.box_only_icon){if(!this.img)return;let{width:t,height:n}=this.img.getBoundingClientRect();this.size={width:t+2,height:n+2}}else{let{width:t,height:n}=this.div.getBoundingClientRect();this.size={width:t+2,height:n+2}}}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return this.div=t,this.addText(),this.options.icon&&this.addIcon(),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t)}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(n=>{let r=document.createElement("div");if(r.style.whiteSpace="nowrap",n.styles)for(let[i,o]of Object.entries(n.styles))r.style[i]=o;r.textContent=n.text,t.appendChild(r)}),t}initIcon(){let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${this.options.icon_size?.[0]||32}px`,t.style.height=`${this.options.icon_size?.[1]||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}_changePosition=()=>{this.overlay.updatePosition(!0)};registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:n,height:r}=this.size,i=n*t,o=r*t,{x:a,y:l}=this.overlay.clientPos;return{left:a-i/2,right:a+i/2,top:this.options.icon?l-o:l-o/2,bottom:this.options.icon?l:l+o/2}}getOriginBox(){return this.getBox(1)}isContain(t,n){if(!this.overlay.visible||!this.visible)return!1;let r=this.getOriginBox();return t>=r.left&&t<=r.right&&n>=r.top&&n<=r.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose(),this.disposed=!0}};var j=require("three");var O=require("three"),br=require("@mars3d/heatmap.js"),St=require("@turf/turf"),ie=class extends O.Object3D{constructor(t){super();this.context=t;this.div=document.createElement("div")}heatmap;div;plane;clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:n,height:r,leftTop:i,center:o}=this.getBox(t);this.heatmap=(0,br.create)({width:n,height:r,container:this.div,...this.context.config.heatMap}),this.heatmap.setData(this.transformData(t,i)),this.initPlane(n,r),this.position.set(o[0],o[1],this.position.z)}initPlane(t,n){this.plane&&this.remove(this.plane);let r=new O.PlaneGeometry(t,n),i=new O.Texture(this.div.firstChild);i.needsUpdate=!0;let o=new O.MeshBasicMaterial({transparent:!0,side:O.DoubleSide,map:i});o.needsUpdate=!0,this.plane=new O.Mesh(r,o),this.add(this.plane)}getTransMatrix({x:t,y:n}){return new O.Matrix3().makeScale(1,-1).multiply(new O.Matrix3().makeTranslation(0-t,0-n))}transformData(t,n){let r=this.getTransMatrix(n);return{data:t.data.map(o=>{let a=new O.Vector2(o.x,o.y).applyMatrix3(r);return{x:a.x,y:a.y,value:o.value}}),max:t.max,min:t.min}}getBox(t){let n=(0,St.featureCollection)(t.data.map(u=>(0,St.point)([u.x,u.y]))),r=(0,St.bbox)(n),i=r[2]-r[0],o=r[3]-r[1],a={x:r[0],y:r[3]},l=(0,St.center)(n);return{width:i,height:o,leftTop:a,center:l.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var Pe=require("three");var oe=class extends Pe.Object3D{constructor(t,n){super();this.context=t;this.options=n;this.position.copy(n.position||new Pe.Vector3(0,0,0)),this.loadModel()}model=null;async loadModel(){let t=await Et.loadModel(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t}dispose(){V(this),this.model=null}};var Ae=require("three");var Sr=require("three");var F=class extends Sr.Object3D{constructor(t){super();this.context=t}dispose(){V(this),this.children.forEach(t=>t.dispose?.()),this.clear()}};var se=class extends F{graphicMap=new Map;constructor(e){super(e)}getCenter(){return new Ae.Box3().setFromObject(this).getCenter(new Ae.Vector3)}createGraphic(e){let t=new R(this.context,e);return t.userData.data=e,this.add(t),this.graphicMap.set(e.id,t),t}removeGraphic(e){this.remove(e),this.graphicMap.delete(e.options.id),e.dispose()}removeGraphicById(e){this.graphicMap.has(e)&&this.removeGraphic(this.graphicMap.get(e))}getGraphicByNodeId(e){return this.graphicMap.get(e)||null}getGraphicByRaycaster(e){let t={distance:1e4,graphic:null,position:null},n=this.children.reduce((r,i)=>{if(i instanceof R){let o=i.raycast(e);if(o){let{distance:a}=o;if(a<r.distance)return{distance:o.distance,position:o.position,graphic:i}}return r}else return r},t);return n===t?{graphics:[],position:null}:{graphics:[n.graphic],position:n.position}}};var Mr=require("lodash");var ae=class extends F{pois=[];debounceCollisionDetection;timer=new D;constructor(e){super(e),this.registryEvent(),this.debounceCollisionDetection=(0,Mr.debounce)(this.collisionDetection,10)}clear(e=!1){return this.pois.forEach(t=>{t.options.built_in&&!e||t.dispose()}),this.pois=e?[]:this.pois.filter(t=>t.options.built_in),this}createPoi(e){let t=new bt(this.context,e);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.pois.splice(t,1),this.pushPoi(e))}removePoi(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.pois.splice(t,1),e.dispose())}removePoiById(e){let t=this.pois.find(n=>n.options.id===e);t&&this.removePoi(t)}getPoiById(e){return this.pois.find(n=>n.options.id===e)||null}pushPoi(e){if(!e.options.collision_enable){this.pois.unshift(e);return}if(e.options.level===0){this.pois.push(e);return}for(let t=0;t<this.pois.length;t++){let n=this.pois[t];if(n.options.collision_enable&&n.options.level<=e.options.level){this.pois.splice(t,0,e);return}}this.pois.push(e)}getPoiByDeviceXy(e,t){return this.pois.filter(r=>r instanceof bt&&r.isContain(e,t))}onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let e=[];this.pois.filter(n=>n.visible&&n.withinDisplayRange).forEach((n,r)=>{let{left:i,right:o,top:a,bottom:l}=n.getBox();if(r===0||!n.options.collision_enable){e.push({left:i,right:o,top:a,bottom:l}),n.parentSetVisible(!0);return}let u=e.some(c=>c.left<o&&c.right>i&&c.top<l&&c.bottom>a);n.parentSetVisible(!u),u||e.push({left:i,right:o,top:a,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(e=>e.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var xn=require("lodash");var Ie=require("three"),Ut=class extends F{pois=[];debounceCollisionDetection;debounceChangeParkingSpaceVisibleByZoom;timer=new D;constructor(e){super(e),this.registryEvent(),this.debounceCollisionDetection=(0,xn.debounce)(this.collisionDetection,10),this.debounceChangeParkingSpaceVisibleByZoom=(0,xn.debounce)(this.changeParkingSpaceVisibleByZoom,10)}clear(){return this.pois.forEach(e=>{e.dispose()}),this.pois=[],this}createPoi(e){let t=new q(this.context,e);return this.pushPoi(t),t}changePoiLevelOrCollisionEnable(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.pois.splice(t,1),this.pushPoi(e))}removePoi(e){let t=this.pois.findIndex(n=>n===e);t!==-1&&(this.remove(e),this.pois.splice(t,1),e.dispose())}removePoiById(e){let t=this.pois.find(n=>n.options.id===e);t&&this.removePoi(t)}getPoiById(e){return this.pois.find(n=>n.options.id===e)||null}pushPoi(e){if(this.add(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceChangeParkingSpaceVisibleByZoom(),this.debounceCollisionDetection()}),!e.options.collision_enable){this.pois.unshift(e);return}if(e.options.level===0){this.pois.push(e);return}for(let t=0;t<this.pois.length;t++){let n=this.pois[t];if(n.options.collision_enable&&n.options.level<=e.options.level){this.pois.splice(t,0,e);return}}this.pois.push(e)}getPoiByDeviceXy(e,t){let n=new Ie.Vector2(e,t);return this.pois.filter(i=>i instanceof q&&i.canSelect&&i.box.containsPoint(n))}changeParkingSpaceVisibleByZoom=()=>{let e=this.parent?.parent;if(e&&e instanceof ct){let{clientSize:{width:t,height:n}}=this.context,{max:r,min:i}=e.box,a=Math.min(t/(r.x-i.x),n/(r.y-i.y))*(r.x-i.x)/45;this.pois.filter(l=>l.userData.type==="parkingSpace").map(l=>{let u=this.context.camera.zoom>=a;l.visible=u,u||l.parentSetVisible(u)})}};onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let e=[],{camera:t}=this.context;t.updateMatrixWorld();let n=o=>o<=1&&o>=-1,r=t.projectionMatrix.clone();r.multiply(t.matrixWorldInverse),this.pois.filter(o=>{if(o.visible){let a=o.spriteIcon?o.spriteIcon?.matrixWorld:o.spriteText?.matrixWorld||o.matrixWorld,l=new Ie.Vector3().setFromMatrixPosition(a);return l.applyMatrix4(r),o.screenPosition=l,n(l.x)&&n(l.y)&&n(l.z)}return!1}).forEach((o,a)=>{let l=o.getBox(o.screenPosition);if(a===0||!o.options.collision_enable){e.push(l),o.parentSetVisible(!0);return}let u=e.some(c=>c.intersectsBox(l));o.parentSetVisible(!u),u||e.push(l)})}registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}dispose(){this.timer.dispose(),this.pois.forEach(e=>e.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var ct=class extends j.Object3D{constructor(t){super();this.context=t;this.groundLayer=new F(this.context),this.graphicLayer=new se(this.context),this.poiLayer=new ae(this.context),this.poiLayer2=new Ut(this.context),this.wallLayer=new F(this.context),this.textureLayer=new F(this.context),this.glbModelLayer=new F(this.context),this.laneLayer=new F(this.context),this.mergeGraphicLayer=new F(this.context),this.textTextureLayer=new F(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),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)}graphicLayer;poiLayer;poiLayer2;wallLayer;textureLayer;glbModelLayer;laneLayer;mergeGraphicLayer;textTextureLayer;grounds=new Set;groundLayer;shadow=new ne;heatmap;groundUpper=new j.Object3D;models=new j.Object3D;modelMap=new Map;groundMaxHeight=0;name="";key="";box=new j.Box3;getPosition(){return this.box.getCenter(new j.Vector3)}createGround(t){let n=new R(this.context,t);n.userData.data=t,this.addGrounds([n])}addGrounds(t){t.forEach(n=>{this.grounds.has(n)||(n.mesh.castShadow=!0,this.grounds.add(n),this.groundLayer.add(n))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(n=>n.options.height+n.options.airHeight+n.options.deltaHeight)):0,this.groundUpper.position.z=this.groundMaxHeight+.01}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new j.Box3().setFromObject(this).getCenter(new j.Vector3)}addModel(t){let n=new oe(this.context,t);return this.models.add(n),this.modelMap.set(t.id,n),n}addShadow(){let t=new j.Box3().setFromObject(this.groundUpper),n=t.getCenter(new j.Vector3),r=t.getSize(new j.Vector3);this.shadow.setPosition(n),this.shadow.changeLightCamera(r)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new ie(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let n=new j.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(n.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}updateBox(){this.box.setFromObject(this)}dispose(){console.log("floor dispose",this.name),this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.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.heatmap?.dispose(),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};var Re=require("three");var J=class extends Re.EventDispatcher{constructor(t){super();this.context=t;this.svg=rn(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}points=[];svg;enable=!0;_onResize=({width:t,height:n})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${n}`))};_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:n,renderer:r}=this.context,{offsetX:i,offsetY:o}=t,{clientWidth:a,clientHeight:l}=r.domElement,u=i/a*2-1,c=1-o/l*2;return new Re.Vector3(u,c,0).unproject(n)}getSvgCoordinate(t){let{camera:n,container:r}=this.context;return y(t,n,r.clientWidth,r.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var le=class extends J{constructor(t){super(t);this.context=t;let{config:{svg:{circle:n,line:r}}}=t;this.circles=[Vt(n.radius,n.fill),Vt(n.radius,n.fill)],this.line=te(r.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}circles;line;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)}onUpdate=()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);_t(this.circles[0],t.x,t.y),et(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);_t(this.circles[1],t.x,t.y),et(this.line,void 0,t)}};onPointermove=t=>{this.points.length===1&&(this.line.style.display="block",et(this.line,void 0,{x:t.offsetX,y:t.offsetY}))};onPointerleave=()=>{this.points[1]||(this.line.style.display="none")};onPointerdown=t=>{if(this.points[1])return;let n=this.getIntersectByPointerEvent(t);if(n){let{offsetX:r,offsetY:i}=t,o=this.circles[this.points.length];_t(o,r,i),this.points.length||et(this.line,{x:r,y:i},{x:r,y:i}),this.addPoint(n)}};addPoint(t){if(this.points.push(t),this.points.length>=2){let n=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:n})}}calculatedDistance(){let[{x:t,y:n},{x:r,y:i}]=this.points;return Math.sqrt((r-t)**2+(i-n)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var ue=class extends J{circles=[];lines=[];isClose=!1;constructor(e){super(e),this.registryEvent()}setEnable(e){super.setEnable(e),e?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(e){this.circles.push(e),this.svg.appendChild(e)}addLine(e){this.lines.push(e),this.svg.appendChild(e)}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)}onUpdate=()=>{this.points.length&&this.points.forEach((e,t)=>{let n=this.getSvgCoordinate(e);this.circles[t]&&_t(this.circles[t],n.x,n.y),t!==0&&et(this.lines[t-1],void 0,n),this.lines[t]&&et(this.lines[t],n)})};onPointermove=e=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",et(this.lastLine,void 0,{x:e.offsetX,y:e.offsetY}))};onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")};onPointerdown=e=>{if(this.isClose)return;let t=this.getIntersectByPointerEvent(e);if(t){let{offsetX:n,offsetY:r}=e;this.checkAdsorb(n,r)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(t);let{circle:{fill:i,radius:o},line:{stroke:a}}=this.context.config.svg;if(!this.isClose){let l=Vt(o,i);_t(l,n,r),this.addCircle(l)}if(this.lines.length&&et(this.lastLine,void 0,{x:n,y:r}),!this.isClose){let l=te(a);et(l,{x:n,y:r},{x:n,y:r}),this.addLine(l)}}};checkAdsorb(e,t){if(this.points.length<3)return!1;let n=this.circles[0],r=+n.getAttribute("cx"),i=+n.getAttribute("cy");return Math.sqrt((e-r)**2+(t-i)**2)<=5}addPoint(e){if(this.points.push(e),this.isClose){let t=this.calculatedArea();this.dispatchEvent({type:"area",area:t})}}calculatedArea(){let e=this.points.map(r=>[r.x,r.y]),t=0,n=e.length;for(let r=0;r<n;r++){let i=(r+1)%n;t+=e[r][0]*e[i][1]-e[i][0]*e[r][1]}return Math.abs(t/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var wr=require("three");var En=class extends J{constructor(t){super(t);this.context=t;let{config:{svg:{line:n}}}=t;this.rect=mt(n.stroke,"transparent"),this.svg.appendChild(this.rect);for(let r=0;r<4;r++)this.cornerRect[r]=mt(n.stroke,"#ffffff"),this.centerRect[r]=mt(n.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[r]),this.svg.appendChild(this.centerRect[r]);this.registryEvent()}rect;cornerRect=[];centerRect=[];graphic;setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}onUpdate=()=>{if(this.graphic){let t=new wr.Box3().setFromObject(this.graphic),{camera:n,container:{clientWidth:r,clientHeight:i}}=this.context,{min:o,max:a}=t,l=y(o,n,r,i),u=y(a,n,r,i);B(this.rect,l.x,u.y,Math.abs(u.x-l.x),Math.abs(u.y-l.y));let{x:c,y:h}=l,{x:p,y:d}=u,m=5,f=[{x:c-m,y:d-m},{x:p-m,y:d-m},{x:c-m,y:h-m},{x:p-m,y:h-m}];for(let b=0;b<f.length;b++)B(this.cornerRect[b],f[b].x,f[b].y,m*2,m*2);let g=4,E=(c+p)/2,x=(h+d)/2,z=[{x:E-g,y:d-g},{x:c-g,y:x-g},{x:p-g,y:x-g},{x:E-g,y:h-g}];for(let b=0;b<z.length;b++)B(this.centerRect[b],z[b].x,z[b].y,g*2,g*2)}else{B(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)B(this.cornerRect[t],0,0,0,0),B(this.centerRect[t],0,0,0,0)}};selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var P=require("three");var bn=require("three/examples/jsm/utils/BufferGeometryUtils");var ce=class extends P.Object3D{constructor(t,n){super();this.context=t;this.options=n;n.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(n=>{let r=st(n.geometry.coords[0],n.geometry.coords.slice(1));return new P.ExtrudeGeometry(r,{steps:1,bevelEnabled:!1,depth:n.height,curveSegments:4})});this.geometry=(0,bn.mergeGeometries)(t),t.forEach(n=>n.dispose())}initMaterial(){let t=`
|
|
39
39
|
varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
|
|
40
40
|
uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
|
|
41
41
|
uniform vec3 uColor;
|