@aibee/crc-bmap 0.0.120 → 0.0.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/bmap.min.js CHANGED
@@ -24,7 +24,7 @@
24
24
  gl_FragColor = vec4(uColor2, uOpacity); // \u5176\u4ED6\u9762\u989C\u8272\uFF09
25
25
  }
26
26
  }
27
- `,r=-1/0,i=this.geometry.getAttribute("position");if(i)for(let l=0;l<i.count;l++){let u=i.getZ(l);u>r&&(r=u)}let s=new C.ShaderMaterial({uniforms:{maxZ:{value:r},uColor:{value:new C.Color(this.options[0].fillColor)},uColor2:{value:new C.Color(pt(this.options[0].fillColor))},uOpacity:{value:this.options[0].fillOpacity}},vertexShader:t,fragmentShader:e});this.material=s}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],r=this.context.materialFactory.createLineMaterial({color:t,opacity:e});return this.lineMaterial=r,r}getBorderPoints(t){let{height:e,deltaHeight:r,geometry:i}=t,s=[],l=e+(r||0),{coords:u}=i;for(let a=0;a<u.length;a++){let c=u[a];for(let p=0;p<c.length;p++){let d=c[p],h=p+1===c.length?c[0]:c[p+1];s.push(new C.Vector3(d[0],d[1],l)),s.push(new C.Vector3(h[0],h[1],l))}}return s}initLineGeometry(){let t=this.options.map(e=>{let r=this.getBorderPoints(e);return new C.BufferGeometry().setFromPoints(r)});this.lineGeometry=(0,ge.mergeGeometries)(t)}createBorder(){let t=new C.LineSegments(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}init(){this.initGeometry(),this.initMaterial();let t=new C.Mesh(this.geometry,this.material);this.add(t),this.initLineMaterial(),this.initLineGeometry(),this.createBorder()}dispose(){this.geometry?.dispose(),this.material?.dispose(),this.lineGeometry?.dispose(),this.clear()}};var mt=y("three"),yr={uuid:"",iconUrl:"",name:"",secondRotate:0,airHeight:0,deltaHeight:0,height:0,geometry:{cds:[],type:"polygon",coords:[],curveCpt:[],curveIndex:[]},opacity:1,visible:!0},qt=class extends mt.Object3D{constructor(t,e){super();this.context=t;this.options=ct({...yr,...e},this),this.init()}options;mesh;async init(){let{deltaHeight:t,airHeight:e,geometry:r,iconUrl:i,opacity:s}=this.options,l=K(r.coords[0],r.coords.slice(1)),u=new mt.ExtrudeGeometry(l,{steps:1,bevelEnabled:!1,depth:0,curveSegments:4}),a=await this.context.materialFactory.createGroundTextureMaterial({url:i,opacity:s}),c=new mt.Mesh(u,a);this.mesh=c,this.mesh.position.z=e+t,this.add(c)}dispose(){this.mesh?.geometry.dispose(),this.clear()}};var st=y("three");var _r={url:"",geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},id:"",width:0,rotate:1,airHeight:1,deltaHeight:0},jt=class extends st.Object3D{constructor(t,e){super();this.context=t;this.options=Object.assign({},_r,e),this.loadModel()}model=null;options;async loadModel(){let t=await It(this.options.url);t.scene.rotation.set(Math.PI/2,Math.PI/2,0);let e=new st.Box3().setFromObject(t.scene),r=e.getSize(new st.Vector3),i=Math.max(r.x,r.y),s=this.options.width/i;this.scale.set(s,s,s),this.add(t.scene),this.position.copy(e.getCenter(new st.Vector3)),this.position.z+=this.options.airHeight+this.options.deltaHeight,this.model=t}dispose(){B(this),this.model=null}};var O=y("three");var me=y("three/examples/jsm/utils/BufferGeometryUtils.js"),En=y("three/examples/jsm/lines/line2.js"),bn=y("three/examples/jsm/lines/lineGeometry.js"),Yt=class extends O.Object3D{constructor(t,e){super();this.context=t;this.options=e;e.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(e=>{let r=K(e.geometry.coords[0],e.geometry.coords.slice(1));return new O.ExtrudeGeometry(r,{steps:1,bevelEnabled:!1,depth:0,curveSegments:4})});this.geometry=(0,me.mergeGeometries)(t),t.forEach(e=>e.dispose())}initMaterial(){let{fillColor:t,fillOpacity:e}=this.options[0],r=this.context.materialFactory.createMeshBasicMaterial({color:t,opacity:e});return this.material=r,r}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],r=this.context.materialFactory.createLineMaterial({color:t,opacity:e});return this.lineMaterial=r,r}getBorderPoints(t){let{deltaHeight:e,geometry:r}=t,i=[],s=e||0,{coords:l}=r;for(let u=0;u<l.length;u++){let a=l[u];for(let c=0;c<a.length;c++){let p=a[c],d=c+1===a.length?a[0]:a[c+1];i.push(new O.Vector3(p[0],p[1],s)),i.push(new O.Vector3(d[0],d[1],s))}}return i}initDoubleLine(){let t=this.options.filter(r=>r.double&&r.geometry.otherCoords?.[1]?.length);if(!t.length)return;let e=t.reduce((r,i)=>{let s=`${i.secondColor}-${i.dashed}`;return r[s]&&r[s].push(i),r[s]||(r[s]=[i]),r},{});Object.values(e).map(r=>{let i=this.context.materialFactory.createLine2MaterialMap({color:r[0].secondColor,width:.2,dashed:r[0].dashed});r.map(s=>{let l=new bn.LineGeometry,u=s.geometry.otherCoords[1].map(c=>[...c,0]).flat(2);l.setPositions(u);let a=new En.Line2(l,i);a.computeLineDistances(),a.position.z+=.001,this.add(a)})})}initLineGeometry(){let t=this.options.map(e=>{let r=this.getBorderPoints(e);return new O.BufferGeometry().setFromPoints(r)});this.lineGeometry=(0,me.mergeGeometries)(t)}createBorder(){let t=new O.LineSegments(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}init(){this.initGeometry(),this.initMaterial();let t=new O.Mesh(this.geometry,this.material);this.add(t),this.initLineMaterial(),this.initLineGeometry(),this.createBorder(),this.initDoubleLine(),this.position.z+=.001+(this.options[0].deltaHeight||0)}dispose(){this.geometry?.dispose(),this.lineGeometry?.dispose(),this.clear()}};var Mn=y("three"),Zt=class extends q{startPoint;endPoint;rect;frustum=new Mn.Frustum;constructor(n){super(n);let{config:{selectBox:{fill:t,stroke:e}}}=n;this.rect=ht(e,t),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(n){super.setEnable(n),k(this.rect,0,0,0,0),n?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}onPointerDown=n=>{if(!this.enable)return;let t=this.getIntersectByPointerEvent(n);t&&(this.startPoint=t),this.endPoint=void 0};onPointerMove=n=>{if(!this.enable||!this.startPoint)return;let t=this.getIntersectByPointerEvent(n);t&&(this.endPoint=t)};onPointerUp=n=>{if(!this.enable)return;let t=this.getIntersectByPointerEvent(n);t&&(this.endPoint=t),this.doSelect(),this.startPoint=void 0};onUpdate=()=>{if(this.startPoint){let n=this.getSvgCoordinate(this.startPoint),t={...n};this.endPoint&&(t=this.getSvgCoordinate(this.endPoint));let e={x:Math.min(n.x,t.x),y:Math.min(n.y,t.y)},r=Math.abs(t.x-n.x),i=Math.abs(t.y-n.y);k(this.rect,e.x,e.y,r,i)}else k(this.rect,0,0,0,0)};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:t,container:{clientWidth:e,clientHeight:r}}}=this,i=v(this.startPoint,t,e,r),s=v(this.endPoint,t,e,r),l={x:Math.min(i.x,s.x),y:Math.min(i.y,s.y)},u={x:Math.max(i.x,s.x),y:Math.max(i.y,s.y)},a=this.searchMapInFrustum(l,u);this.dispatchEvent({type:"selected",list:a})}}searchMapInFrustum(n,t){let{context:e}=this;return e.currentFloor?.graphicLayer.children.filter(r=>r instanceof I&&this.searchChildInFrustum(r,n,t))||[]}searchChildInFrustum(n,t,e){let{context:{camera:r,container:{clientWidth:i,clientHeight:s}}}=this;if(!n)return!1;if(!n.mesh){let d=n.getPosition();if(d){let h=v(d,r,i,s);return Tt(h,t,e)}return!1}n.mesh.geometry.boundingBox||n.mesh.geometry.computeBoundingBox();let l=n.mesh.geometry.boundingBox;if(!l)return!1;let{min:u,max:a}=l,c=v(u,r,i,s),p=v(a,r,i,s);return!(!Tt(c,t,e)||!Tt(p,t,e))}dispose(){this.unRegistryEvent()}};var Kt=class extends Sn.EventDispatcher{constructor(t){super();this.context=t;this.boxSelection=new Zt(t),this.boxSelection.setEnable(!1),this.registryEvent()}_list=new Set;boxSelection;prevPanStatus;prevRotateStatus;downPoint=null;isMultipleSelect=!1;get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}onPointerDown=t=>{this.downPoint={x:t.offsetX,y:t.offsetY}};onPointerUp=t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:r}=t,{x:i,y:s}=this.downPoint;if(Math.sqrt((i-e)**2+(s-r)**2)>3)return;let{graphics:l}=this.context.getGraphicsByDeviceXy(e,r),u=new Set(l.map(c=>c.options.id));this.context.getPoisByDeviceXy(e,r).forEach(c=>{if(!u.has(c.options.id)){let p=this.context.currentFloor?.graphicLayer.graphicMap.get(c.options.id)||null;p&&p.options.geometry.type==="point"&&(l.push(p),u.add(c.options.id))}}),(Nt?t.metaKey:t.ctrlKey)||this._list.clear(),l.forEach(c=>this._list.add(c)),this.selectEnd(),this.downPoint=null};onPointerOut=t=>{this.disableBoxSelection()};onKeyDown=t=>{he(t.key)&&this.enableBoxSelection()};onKeyUp=t=>{he(t.key)&&this.disableBoxSelection()};onBoxSelected=({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()};selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};var wn=y("three");var $t=class extends wn.EventDispatcher{constructor(t){super();this.context=t;this.registryEvent()}curGraphics=new Set;timer=new W;graphicTimerMap=new Map;onPointerMove=({graphics:t,pois:e,e:r})=>{let i=e.map(a=>this.context.currentFloor?.graphicLayer.graphicMap.get(a.options.id)).filter(a=>a&&a.options.geometry.type==="point");if(!t.length&&!i.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:s}=this.context.config.hover,l=new Set;if(i.length){let a,c=1e4;i.forEach(p=>{let d=e.find(m=>m.options.id===p.options.id),{x:h,y:f}=d.clientPos,_=Math.sqrt((h-r.offsetX)**2+(f-r.offsetY)**2);_<c&&(c=_,a=p)}),l.add(a)}l.size||t.forEach(a=>l.add(a)),l.forEach(a=>{if(this.graphicTimerMap.get(a)||this.curGraphics.has(a))return;let c=this.timer.setTimeout(()=>{this.curGraphics.add(a),this.graphicTimerMap.delete(a),this.timer.clearTimeout(c),this.handleHoverGraphicsChange()},s);this.graphicTimerMap.set(a,c)}),this.graphicTimerMap.forEach((a,c)=>{l.has(c)||(this.timer.clearTimeout(a),this.graphicTimerMap.delete(c))});let u=this.curGraphics.size;this.curGraphics.forEach(a=>{l.has(a)||this.curGraphics.delete(a)}),u!==this.curGraphics.size&&this.handleHoverGraphicsChange()};onPointerLevel=()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()};onBodyPointerMove=t=>{if(this.curGraphics.size){let e=this.context.container.getBoundingClientRect();(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this.onPointerLevel()}};handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel),document.body.addEventListener("pointermove",this.onBodyPointerMove)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel),document.body.removeEventListener("pointermove",this.onBodyPointerMove)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};var Cn=y("three/examples/jsm/lines/LineMaterial"),P=y("three");function Tn(o){return`${o.x}-${o.y}-${o.z}`}var Jt=class{constructor(n){this.context=n}lineMaterialMap=new Map;meshStandardMaterialMap=new Map;meshBasicMaterialMap=new Map;shaderMaterialMap=new Map;groundTextureMaterialMap=new Map;line2MaterialMap=new Map;generateLineMaterialKey({color:n,opacity:t}){return`${n}-${t}`}createLineMaterial({color:n,opacity:t}){let e=this.generateLineMaterialKey({color:n,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let r=new P.LineBasicMaterial({color:new P.Color(n).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,r),r}createMeshStandardMaterial({color:n,opacity:t}){let e=`${n}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let r=new P.MeshStandardMaterial({color:new P.Color(n).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,r),r}createMeshBasicMaterial({color:n,opacity:t}){let e=`${n}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let r=new P.MeshBasicMaterial({color:n,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,r),r}createShaderMaterial({gradualColor:n,center:t,maxValue:e,opacity:r,direction:i,max:s,min:l}){let u=`${n.toString()}-${Tn(t)}-${e}-${r}-${Tn(i)}`;if(this.shaderMaterialMap.has(u))return this.shaderMaterialMap.get(u);let a=`
27
+ `,r=-1/0,i=this.geometry.getAttribute("position");if(i)for(let l=0;l<i.count;l++){let u=i.getZ(l);u>r&&(r=u)}let s=new C.ShaderMaterial({uniforms:{maxZ:{value:r},uColor:{value:new C.Color(this.options[0].fillColor)},uColor2:{value:new C.Color(pt(this.options[0].fillColor))},uOpacity:{value:this.options[0].fillOpacity}},vertexShader:t,fragmentShader:e});this.material=s}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],r=this.context.materialFactory.createLineMaterial({color:t,opacity:e});return this.lineMaterial=r,r}getBorderPoints(t){let{height:e,deltaHeight:r,geometry:i}=t,s=[],l=e+(r||0),{coords:u}=i;for(let a=0;a<u.length;a++){let c=u[a];for(let p=0;p<c.length;p++){let d=c[p],h=p+1===c.length?c[0]:c[p+1];s.push(new C.Vector3(d[0],d[1],l)),s.push(new C.Vector3(h[0],h[1],l))}}return s}initLineGeometry(){let t=this.options.map(e=>{let r=this.getBorderPoints(e);return new C.BufferGeometry().setFromPoints(r)});this.lineGeometry=(0,ge.mergeGeometries)(t)}createBorder(){let t=new C.LineSegments(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}init(){this.initGeometry(),this.initMaterial();let t=new C.Mesh(this.geometry,this.material);this.add(t),this.initLineMaterial(),this.initLineGeometry(),this.createBorder()}dispose(){this.geometry?.dispose(),this.material?.dispose(),this.lineGeometry?.dispose(),this.clear()}};var mt=y("three"),yr={uuid:"",iconUrl:"",name:"",secondRotate:0,airHeight:0,deltaHeight:0,height:0,geometry:{cds:[],type:"polygon",coords:[],curveCpt:[],curveIndex:[]},opacity:1,visible:!0},qt=class extends mt.Object3D{constructor(t,e){super();this.context=t;this.options=ct({...yr,...e},this),this.init()}options;mesh;async init(){let{deltaHeight:t,airHeight:e,geometry:r,iconUrl:i,opacity:s}=this.options,l=K(r.coords[0],r.coords.slice(1)),u=new mt.ExtrudeGeometry(l,{steps:1,bevelEnabled:!1,depth:0,curveSegments:4}),a=await this.context.materialFactory.createGroundTextureMaterial({url:i,opacity:s}),c=new mt.Mesh(u,a);this.mesh=c,this.mesh.position.z=e+t,this.add(c)}dispose(){this.mesh?.geometry.dispose(),this.clear()}};var st=y("three");var _r={url:"",geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},id:"",width:0,rotate:1,airHeight:1,deltaHeight:0},jt=class extends st.Object3D{constructor(t,e){super();this.context=t;this.options=Object.assign({},_r,e),this.loadModel()}model=null;options;async loadModel(){let t=await It(this.options.url);t.scene.rotation.set(Math.PI/2,Math.PI/2,0);let e=new st.Box3().setFromObject(t.scene),r=e.getSize(new st.Vector3),i=Math.max(r.x,r.y),s=this.options.width/i;this.scale.set(s,s,s),this.add(t.scene),this.position.copy(e.getCenter(new st.Vector3)),this.position.z+=this.options.airHeight+this.options.deltaHeight,this.model=t}dispose(){B(this),this.model=null}};var O=y("three");var me=y("three/examples/jsm/utils/BufferGeometryUtils"),En=y("three/examples/jsm/lines/Line2"),bn=y("three/examples/jsm/lines/LineGeometry"),Yt=class extends O.Object3D{constructor(t,e){super();this.context=t;this.options=e;e.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(e=>{let r=K(e.geometry.coords[0],e.geometry.coords.slice(1));return new O.ExtrudeGeometry(r,{steps:1,bevelEnabled:!1,depth:0,curveSegments:4})});this.geometry=(0,me.mergeGeometries)(t),t.forEach(e=>e.dispose())}initMaterial(){let{fillColor:t,fillOpacity:e}=this.options[0],r=this.context.materialFactory.createMeshBasicMaterial({color:t,opacity:e});return this.material=r,r}initLineMaterial(){let{strokeColor:t,strokeOpacity:e}=this.options[0],r=this.context.materialFactory.createLineMaterial({color:t,opacity:e});return this.lineMaterial=r,r}getBorderPoints(t){let{deltaHeight:e,geometry:r}=t,i=[],s=e||0,{coords:l}=r;for(let u=0;u<l.length;u++){let a=l[u];for(let c=0;c<a.length;c++){let p=a[c],d=c+1===a.length?a[0]:a[c+1];i.push(new O.Vector3(p[0],p[1],s)),i.push(new O.Vector3(d[0],d[1],s))}}return i}initDoubleLine(){let t=this.options.filter(r=>r.double&&r.geometry.otherCoords?.[1]?.length);if(!t.length)return;let e=t.reduce((r,i)=>{let s=`${i.secondColor}-${i.dashed}`;return r[s]&&r[s].push(i),r[s]||(r[s]=[i]),r},{});Object.values(e).map(r=>{let i=this.context.materialFactory.createLine2MaterialMap({color:r[0].secondColor,width:.2,dashed:r[0].dashed});r.map(s=>{let l=new bn.LineGeometry,u=s.geometry.otherCoords[1].map(c=>[...c,0]).flat(2);l.setPositions(u);let a=new En.Line2(l,i);a.computeLineDistances(),a.position.z+=.001,this.add(a)})})}initLineGeometry(){let t=this.options.map(e=>{let r=this.getBorderPoints(e);return new O.BufferGeometry().setFromPoints(r)});this.lineGeometry=(0,me.mergeGeometries)(t)}createBorder(){let t=new O.LineSegments(this.lineGeometry,this.lineMaterial);return this.LineMesh=t,this.add(t),t}init(){this.initGeometry(),this.initMaterial();let t=new O.Mesh(this.geometry,this.material);this.add(t),this.initLineMaterial(),this.initLineGeometry(),this.createBorder(),this.initDoubleLine(),this.position.z+=.001+(this.options[0].deltaHeight||0)}dispose(){this.geometry?.dispose(),this.lineGeometry?.dispose(),this.clear()}};var Mn=y("three"),Zt=class extends q{startPoint;endPoint;rect;frustum=new Mn.Frustum;constructor(n){super(n);let{config:{selectBox:{fill:t,stroke:e}}}=n;this.rect=ht(e,t),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(n){super.setEnable(n),k(this.rect,0,0,0,0),n?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}onPointerDown=n=>{if(!this.enable)return;let t=this.getIntersectByPointerEvent(n);t&&(this.startPoint=t),this.endPoint=void 0};onPointerMove=n=>{if(!this.enable||!this.startPoint)return;let t=this.getIntersectByPointerEvent(n);t&&(this.endPoint=t)};onPointerUp=n=>{if(!this.enable)return;let t=this.getIntersectByPointerEvent(n);t&&(this.endPoint=t),this.doSelect(),this.startPoint=void 0};onUpdate=()=>{if(this.startPoint){let n=this.getSvgCoordinate(this.startPoint),t={...n};this.endPoint&&(t=this.getSvgCoordinate(this.endPoint));let e={x:Math.min(n.x,t.x),y:Math.min(n.y,t.y)},r=Math.abs(t.x-n.x),i=Math.abs(t.y-n.y);k(this.rect,e.x,e.y,r,i)}else k(this.rect,0,0,0,0)};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:t,container:{clientWidth:e,clientHeight:r}}}=this,i=v(this.startPoint,t,e,r),s=v(this.endPoint,t,e,r),l={x:Math.min(i.x,s.x),y:Math.min(i.y,s.y)},u={x:Math.max(i.x,s.x),y:Math.max(i.y,s.y)},a=this.searchMapInFrustum(l,u);this.dispatchEvent({type:"selected",list:a})}}searchMapInFrustum(n,t){let{context:e}=this;return e.currentFloor?.graphicLayer.children.filter(r=>r instanceof I&&this.searchChildInFrustum(r,n,t))||[]}searchChildInFrustum(n,t,e){let{context:{camera:r,container:{clientWidth:i,clientHeight:s}}}=this;if(!n)return!1;if(!n.mesh){let d=n.getPosition();if(d){let h=v(d,r,i,s);return Tt(h,t,e)}return!1}n.mesh.geometry.boundingBox||n.mesh.geometry.computeBoundingBox();let l=n.mesh.geometry.boundingBox;if(!l)return!1;let{min:u,max:a}=l,c=v(u,r,i,s),p=v(a,r,i,s);return!(!Tt(c,t,e)||!Tt(p,t,e))}dispose(){this.unRegistryEvent()}};var Kt=class extends Sn.EventDispatcher{constructor(t){super();this.context=t;this.boxSelection=new Zt(t),this.boxSelection.setEnable(!1),this.registryEvent()}_list=new Set;boxSelection;prevPanStatus;prevRotateStatus;downPoint=null;isMultipleSelect=!1;get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}onPointerDown=t=>{this.downPoint={x:t.offsetX,y:t.offsetY}};onPointerUp=t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:r}=t,{x:i,y:s}=this.downPoint;if(Math.sqrt((i-e)**2+(s-r)**2)>3)return;let{graphics:l}=this.context.getGraphicsByDeviceXy(e,r),u=new Set(l.map(c=>c.options.id));this.context.getPoisByDeviceXy(e,r).forEach(c=>{if(!u.has(c.options.id)){let p=this.context.currentFloor?.graphicLayer.graphicMap.get(c.options.id)||null;p&&p.options.geometry.type==="point"&&(l.push(p),u.add(c.options.id))}}),(Nt?t.metaKey:t.ctrlKey)||this._list.clear(),l.forEach(c=>this._list.add(c)),this.selectEnd(),this.downPoint=null};onPointerOut=t=>{this.disableBoxSelection()};onKeyDown=t=>{he(t.key)&&this.enableBoxSelection()};onKeyUp=t=>{he(t.key)&&this.disableBoxSelection()};onBoxSelected=({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()};selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};var wn=y("three");var $t=class extends wn.EventDispatcher{constructor(t){super();this.context=t;this.registryEvent()}curGraphics=new Set;timer=new W;graphicTimerMap=new Map;onPointerMove=({graphics:t,pois:e,e:r})=>{let i=e.map(a=>this.context.currentFloor?.graphicLayer.graphicMap.get(a.options.id)).filter(a=>a&&a.options.geometry.type==="point");if(!t.length&&!i.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:s}=this.context.config.hover,l=new Set;if(i.length){let a,c=1e4;i.forEach(p=>{let d=e.find(m=>m.options.id===p.options.id),{x:h,y:f}=d.clientPos,_=Math.sqrt((h-r.offsetX)**2+(f-r.offsetY)**2);_<c&&(c=_,a=p)}),l.add(a)}l.size||t.forEach(a=>l.add(a)),l.forEach(a=>{if(this.graphicTimerMap.get(a)||this.curGraphics.has(a))return;let c=this.timer.setTimeout(()=>{this.curGraphics.add(a),this.graphicTimerMap.delete(a),this.timer.clearTimeout(c),this.handleHoverGraphicsChange()},s);this.graphicTimerMap.set(a,c)}),this.graphicTimerMap.forEach((a,c)=>{l.has(c)||(this.timer.clearTimeout(a),this.graphicTimerMap.delete(c))});let u=this.curGraphics.size;this.curGraphics.forEach(a=>{l.has(a)||this.curGraphics.delete(a)}),u!==this.curGraphics.size&&this.handleHoverGraphicsChange()};onPointerLevel=()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()};onBodyPointerMove=t=>{if(this.curGraphics.size){let e=this.context.container.getBoundingClientRect();(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this.onPointerLevel()}};handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel),document.body.addEventListener("pointermove",this.onBodyPointerMove)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel),document.body.removeEventListener("pointermove",this.onBodyPointerMove)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};var Cn=y("three/examples/jsm/lines/LineMaterial"),P=y("three");function Tn(o){return`${o.x}-${o.y}-${o.z}`}var Jt=class{constructor(n){this.context=n}lineMaterialMap=new Map;meshStandardMaterialMap=new Map;meshBasicMaterialMap=new Map;shaderMaterialMap=new Map;groundTextureMaterialMap=new Map;line2MaterialMap=new Map;generateLineMaterialKey({color:n,opacity:t}){return`${n}-${t}`}createLineMaterial({color:n,opacity:t}){let e=this.generateLineMaterialKey({color:n,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let r=new P.LineBasicMaterial({color:new P.Color(n).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,r),r}createMeshStandardMaterial({color:n,opacity:t}){let e=`${n}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let r=new P.MeshStandardMaterial({color:new P.Color(n).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,r),r}createMeshBasicMaterial({color:n,opacity:t}){let e=`${n}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let r=new P.MeshBasicMaterial({color:n,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,r),r}createShaderMaterial({gradualColor:n,center:t,maxValue:e,opacity:r,direction:i,max:s,min:l}){let u=`${n.toString()}-${Tn(t)}-${e}-${r}-${Tn(i)}`;if(this.shaderMaterialMap.has(u))return this.shaderMaterialMap.get(u);let a=`
28
28
  uniform vec3 uColor;
29
29
  uniform vec3 uGradualColor;
30
30
  uniform vec3 center;