@aibee/crc-bmap 0.0.100 → 0.0.101

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
@@ -3723,5 +3723,5 @@ three/build/three.module.js:
3723
3723
  */
3724
3724
  `)}var M=g("three");var p=g("three"),L=class extends p.BufferGeometry{constructor(){super(),this.isMeshLine=!0,this.type="MeshLine",this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this._points=[],this._geom=null,this.widthCallback=null,this.matrixWorld=new p.Matrix4,Object.defineProperties(this,{geometry:{enumerable:!0,get:function(){return this}},geom:{enumerable:!0,get:function(){return this._geom},set:function(n){this.setGeometry(n,this.widthCallback)}},points:{enumerable:!0,get:function(){return this._points},set:function(n){this.setPoints(n,this.widthCallback)}}})}};L.prototype.setMatrixWorld=function(i){this.matrixWorld=i};L.prototype.setGeometry=function(i,n){this._geometry=i,this.setPoints(i.getAttribute("position").array,n)};L.prototype.setPoints=function(i,n){if(!(i instanceof Float32Array)&&!(i instanceof Array)){console.error("ERROR: The BufferArray of points is not instancied correctly.");return}if(this._points=i,this.widthCallback=n,this.positions=[],this.counters=[],i.length&&i[0]instanceof p.Vector3)for(var t=0;t<i.length;t++){var e=i[t],r=t/i.length;this.positions.push(e.x,e.y,e.z),this.positions.push(e.x,e.y,e.z),this.counters.push(r),this.counters.push(r)}else for(var t=0;t<i.length;t+=3){var r=t/i.length;this.positions.push(i[t],i[t+1],i[t+2]),this.positions.push(i[t],i[t+1],i[t+2]),this.counters.push(r),this.counters.push(r)}this.process()};function cn(i,n){var t=new p.Matrix4,e=new p.Ray,r=new p.Sphere,o=new p.Vector3,s=this.geometry;if(s.boundingSphere||s.computeBoundingSphere(),r.copy(s.boundingSphere),r.applyMatrix4(this.matrixWorld),i.ray.intersectSphere(r,o)!==!1){t.copy(this.matrixWorld).invert(),e.copy(i.ray).applyMatrix4(t);var u=new p.Vector3,l=new p.Vector3,a=new p.Vector3,h=this instanceof p.LineSegments?2:1,c=s.index,f=s.attributes;if(c!==null)for(var m=c.array,d=f.position.array,x=f.width.array,v=0,A=m.length-1;v<A;v+=h){var R=m[v],G=m[v+1];u.fromArray(d,R*3),l.fromArray(d,G*3);var T=x[Math.floor(v/3)]!==void 0?x[Math.floor(v/3)]:1,tt=i.params.Line.threshold+this.material.lineWidth*T/2,ot=tt*tt,st=e.distanceSqToSegment(u,l,o,a);if(!(st>ot)){o.applyMatrix4(this.matrixWorld);var at=i.ray.origin.distanceTo(o);at<i.near||at>i.far||(n.push({distance:at,point:a.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this}),v=A)}}}}L.prototype.raycast=cn;L.prototype.compareV3=function(i,n){var t=i*6,e=n*6;return this.positions[t]===this.positions[e]&&this.positions[t+1]===this.positions[e+1]&&this.positions[t+2]===this.positions[e+2]};L.prototype.copyV3=function(i){var n=i*6;return[this.positions[n],this.positions[n+1],this.positions[n+2]]};L.prototype.getDistance=function(i){let n=0;for(let t=0;t<i;t++){let e=6*t,r=new p.Vector3(this.positions[e],this.positions[e+1],this.positions[e+2]),o=new p.Vector3(this.positions[e+6],this.positions[e+7],this.positions[e+8]),s=r.distanceTo(o);n+=s}return n};L.prototype.process=function(){var i=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];var n;let t=this.getDistance(i-1);var e;this.compareV3(0,i-1)?e=this.copyV3(i-2):e=this.copyV3(0),this.previous.push(e[0],e[1],e[2]),this.previous.push(e[0],e[1],e[2]);for(var r=0;r<i;r++){if(this.side.push(1),this.side.push(-1),this.widthCallback?n=this.widthCallback(r/(i-1)):n=1,this.width.push(n),this.width.push(n),r===0)this.uvs.push(0,0),this.uvs.push(0,1);else if(r===i-1)this.uvs.push(1,0),this.uvs.push(1,1);else{let s=this.getDistance(r)/t;this.uvs.push(s,0),this.uvs.push(s,1)}if(r<i-1){e=this.copyV3(r),this.previous.push(e[0],e[1],e[2]),this.previous.push(e[0],e[1],e[2]);var o=r*2;this.indices_array.push(o,o+1,o+2),this.indices_array.push(o+2,o+1,o+3)}r>0&&(e=this.copyV3(r),this.next.push(e[0],e[1],e[2]),this.next.push(e[0],e[1],e[2]))}this.compareV3(i-1,0)?e=this.copyV3(1):e=this.copyV3(i-1),this.next.push(e[0],e[1],e[2]),this.next.push(e[0],e[1],e[2]),!this._attributes||this._attributes.position.count!==this.positions.length?this._attributes={position:new p.BufferAttribute(new Float32Array(this.positions),3),previous:new p.BufferAttribute(new Float32Array(this.previous),3),next:new p.BufferAttribute(new Float32Array(this.next),3),side:new p.BufferAttribute(new Float32Array(this.side),1),width:new p.BufferAttribute(new Float32Array(this.width),1),uv:new p.BufferAttribute(new Float32Array(this.uvs),2),index:new p.BufferAttribute(new Uint16Array(this.indices_array),1),counters:new p.BufferAttribute(new Float32Array(this.counters),1)}:(this._attributes.position.copyArray(new Float32Array(this.positions)),this._attributes.position.needsUpdate=!0,this._attributes.previous.copyArray(new Float32Array(this.previous)),this._attributes.previous.needsUpdate=!0,this._attributes.next.copyArray(new Float32Array(this.next)),this._attributes.next.needsUpdate=!0,this._attributes.side.copyArray(new Float32Array(this.side)),this._attributes.side.needsUpdate=!0,this._attributes.width.copyArray(new Float32Array(this.width)),this._attributes.width.needsUpdate=!0,this._attributes.uv.copyArray(new Float32Array(this.uvs)),this._attributes.uv.needsUpdate=!0,this._attributes.index.copyArray(new Uint16Array(this.indices_array)),this._attributes.index.needsUpdate=!0),this.setAttribute("position",this._attributes.position),this.setAttribute("previous",this._attributes.previous),this.setAttribute("next",this._attributes.next),this.setAttribute("side",this._attributes.side),this.setAttribute("width",this._attributes.width),this.setAttribute("uv",this._attributes.uv),this.setAttribute("counters",this._attributes.counters),this.setIndex(this._attributes.index),this.computeBoundingSphere(),this.computeBoundingBox()};function qt(i,n,t,e,r){var o;if(i=i.subarray||i.slice?i:i.buffer,t=t.subarray||t.slice?t:t.buffer,i=n?i.subarray?i.subarray(n,r&&n+r):i.slice(n,r&&n+r):i,t.set)t.set(i,e);else for(o=0;o<i.length;o++)t[o+e]=i[o];return t}L.prototype.advance=function(i){var n=this._attributes.position.array,t=this._attributes.previous.array,e=this._attributes.next.array,r=n.length;qt(n,0,t,0,r),qt(n,6,n,0,r-6),n[r-6]=i.x,n[r-5]=i.y,n[r-4]=i.z,n[r-3]=i.x,n[r-2]=i.y,n[r-1]=i.z,qt(n,6,e,0,r-6),e[r-6]=i.x,e[r-5]=i.y,e[r-4]=i.z,e[r-3]=i.x,e[r-2]=i.y,e[r-1]=i.z,this._attributes.position.needsUpdate=!0,this._attributes.previous.needsUpdate=!0,this._attributes.next.needsUpdate=!0};p.ShaderChunk.meshline_vert=["",p.ShaderChunk.logdepthbuf_pars_vertex,p.ShaderChunk.fog_pars_vertex,"","attribute vec3 previous;","attribute vec3 next;","attribute float side;","attribute float width;","attribute float counters;","","uniform vec2 resolution;","uniform float lineWidth;","uniform vec3 color;","uniform float opacity;","uniform float sizeAttenuation;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","vec2 fix( vec4 i, float aspect ) {",""," vec2 res = i.xy / i.w;"," res.x *= aspect;"," vCounters = counters;"," return res;","","}","","void main() {",""," float aspect = resolution.x / resolution.y;",""," vColor = vec4( color, opacity );"," vUV = uv;",""," mat4 m = projectionMatrix * modelViewMatrix;"," vec4 finalPosition = m * vec4( position, 1.0 );"," vec4 prevPos = m * vec4( previous, 1.0 );"," vec4 nextPos = m * vec4( next, 1.0 );",""," vec2 currentP = fix( finalPosition, aspect );"," vec2 prevP = fix( prevPos, aspect );"," vec2 nextP = fix( nextPos, aspect );",""," float w = lineWidth * width;",""," vec2 dir;"," if( nextP == currentP ) dir = normalize( currentP - prevP );"," else if( prevP == currentP ) dir = normalize( nextP - currentP );"," else {"," vec2 dir1 = normalize( currentP - prevP );"," vec2 dir2 = normalize( nextP - currentP );"," dir = normalize( dir1 + dir2 );",""," vec2 perp = vec2( -dir1.y, dir1.x );"," vec2 miter = vec2( -dir.y, dir.x );"," //w = clamp( w / dot( miter, perp ), 0., 4. * lineWidth * width );",""," }",""," //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;"," vec4 normal = vec4( -dir.y, dir.x, 0., 1. );"," normal.xy *= .5 * w;"," normal *= projectionMatrix;"," if( sizeAttenuation == 0. ) {"," normal.xy *= finalPosition.w;"," normal.xy /= ( vec4( resolution, 0., 1. ) * projectionMatrix ).xy;"," }",""," finalPosition.xy += normal.xy * side;",""," gl_Position = finalPosition;","",p.ShaderChunk.logdepthbuf_vertex,p.ShaderChunk.fog_vertex&&" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",p.ShaderChunk.fog_vertex,"}"].join(`
3725
3725
  `);p.ShaderChunk.meshline_frag=["",p.ShaderChunk.fog_pars_fragment,p.ShaderChunk.logdepthbuf_pars_fragment,"","uniform sampler2D map;","uniform sampler2D alphaMap;","uniform float useMap;","uniform float useAlphaMap;","uniform float useDash;","uniform float dashArray;","uniform float dashOffset;","uniform float dashRatio;","uniform float visibility;","uniform float alphaTest;","uniform vec2 repeat;","","varying vec2 vUV;","varying vec4 vColor;","varying float vCounters;","","void main() {","",p.ShaderChunk.logdepthbuf_fragment,""," vec4 c = vColor;"," if( useMap == 1. ) c *= texture2D( map, vUV * repeat );"," if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).a;"," if( c.a < alphaTest ) discard;"," if( useDash == 1. ){"," c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));"," }"," gl_FragColor = c;"," gl_FragColor.a *= step(vCounters, visibility);","",p.ShaderChunk.fog_fragment,"}"].join(`
3726
- `);var it=class extends p.ShaderMaterial{constructor(n){super({uniforms:Object.assign({},p.UniformsLib.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new p.Color(16777215)},opacity:{value:1},resolution:{value:new p.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new p.Vector2(1,1)}}),vertexShader:p.ShaderChunk.meshline_vert,fragmentShader:p.ShaderChunk.meshline_frag}),this.isMeshLineMaterial=!0,this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(t){this.uniforms.useDash.value=t}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(t){this.uniforms.repeat.value.copy(t)}}}),this.setValues(n)}};it.prototype.copy=function(i){return p.ShaderMaterial.prototype.copy.call(this,i),this.lineWidth=i.lineWidth,this.map=i.map,this.useMap=i.useMap,this.alphaMap=i.alphaMap,this.useAlphaMap=i.useAlphaMap,this.color.copy(i.color),this.opacity=i.opacity,this.resolution.copy(i.resolution),this.sizeAttenuation=i.sizeAttenuation,this.dashArray.copy(i.dashArray),this.dashOffset.copy(i.dashOffset),this.dashRatio.copy(i.dashRatio),this.useDash=i.useDash,this.visibility=i.visibility,this.alphaTest=i.alphaTest,this.repeat.copy(i.repeat),this};var Ie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAMAAACROYkbAAABrVBMVEVsjPdsjPdqi/doifdpivdrjPdsjPdsjPd/m/igtfqTq/lykfdri/dsjPdtjfe/zPv8/f/w8/6zw/p0kvdri/dsjPdtjffU3vz////////3+f62xfpzkfdri/dsjPdsjPeZr/nr8P7////////4+f62xfp0kvdri/dsjPdsjPdujveXrvne5v3////////3+f63x/t2lPdri/dsjPdsjPdsjPdri/eMpfjb4/3+/v/////4+v+7yft1k/dri/dsjPdsjPdri/eJovjl6/3////////3+f6Jo/lqivdsjPdri/dvjveluPry9f7////////i6f2BnPhqi/dsjPdrjPdvjveluPrv8v7////////l6/6Uq/lsjPdsjPdsjPdvjveluPrv8v7////////m6/6Uq/lsjPdsjPdsjPdsjPeZr/nv8v7////////s8f6XrvlsjPdsjPdtjffS2/z////////w9P6bsfltjfdsjPdtjffBz/v7/P/y9f6svvpxkPdrjPdsjPdsjPd+mviftPqVrPlykfdri/dsjPdsjPdri/doifdpifdrjPdsjPclkRlrAAAAx0lEQVQ4y2NgwAsYmZhZWNkYyAfsHJxc3Dy85BvAxy8gKCQsIkq2AWLiEpJS0jKycuQaIK+gqKSsoqqmrkGmAZpa2jq6evoGhkbG5BlgYmpmbmFpZW1ja0emE+wdHJ2cXVzd3D3INMDTy9vH188/IDCIPP3BIaFh4RGRUdExseQZEBefkJiUnJKalp5BngGZWdk5uXn5BemFZAZBUXFJaVl5RSWZ9jMwVFXX1NbVNzSSq5+hqbmlta29g2z9DJ1d3T29ffhUAABKPSh5Xst3GwAAAABJRU5ErkJggg==";var Le={texture_url:Ie,lineWidth:16,color:16777215},Gt=class extends M.Object3D{constructor(t,e){super();this.navigation=t;this.config=Object.assign({},Le,e),this.registryEvent()}mesh=null;geometry=null;material=null;texture=null;config=Le;points=[];basicRepeat=1;registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate)}onControlChange=()=>{this.changeRepeat()};onUpdate=()=>{this.texture};getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:r,height:o}}}}}=this,s=t.map(([l,a])=>y(new M.Vector3(l,a,0),e,r,o)).map(({x:l,y:a})=>[l,a]);return ae(s)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new M.Vector2(t,1)}loadTexture(t){return new Promise((e,r)=>{new M.TextureLoader().load(t,e,void 0,r)})}transformPoints(t){let e=[];for(let r=0;r<t.length;r++)e.push(...t[r],0);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}async create(t){let e=this.geometry=new L;if(this.updatePoints(t),!this.texture){let s=this.texture=await this.loadTexture(this.config.texture_url);s.wrapS=s.wrapT=M.RepeatWrapping}let r=this.material=new it({useMap:!0,color:new M.Color(this.config.color),transparent:!0,resolution:new M.Vector2(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:this.config.lineWidth,map:this.texture,blending:M.NormalBlending,repeat:new M.Vector2(this.getRepeat(),1)}),o=this.mesh=new M.Mesh(e,r);return this.add(o),o}dispose(){this.unRegistryEvent(),this.clear(),this.geometry?.dispose(),this.material?.dispose(),this.texture?.dispose()}};var Ne=(s=>(s.FETCH_PROJECT_ROAD="fetch_project_road",s.GET_DIRECTION_PATH="get_direction_path",s.DIRECTION_PATH_RESULT="direction_path_result",s.FETCH_PROJECT_ROAD_RESULT="fetch_project_road_result",s.GET_PATH="get_path",s.GET_PATH_RESULT="get_path_result",s))(Ne||{}),fn=(a=>(a.START="start",a.END="end",a.FRONT="front",a.RIGHT="right",a.LEFT="left",a.RIGHT_FRONT="right_front",a.LEFT_FRONT="left_front",a.RIGHT_BACK="right_back",a.LEFT_BACK="left_back",a))(fn||{});var Q=g("three"),Ge=tn(Be(),1);function dn(i,n){let t=i.clone().normalize(),e=n.clone().normalize();return Math.acos(t.dot(e))}function gn(i){let n=0;return i.reduce(([t,e],[r,o])=>(n+=Math.sqrt((r-t)**2+(o-e)**2),[r,o])),n/i.length}function ze(i,n=.25){if(gn(i)<n)return i;let t=(0,Ge.default)(i);return ze(t,n)}function ke(i,n=!1,t=!0,e=5,r=150,o=3){let s=[],u=!n;if(s.push(i[0]),i.length<2)return s;for(let c=0;c<i.length-2;c+=1){let f=i[c],m=i[c+1],d=i[c+2],x=new Q.Vector2(f[0]-m[0],f[1]-m[1]),v=new Q.Vector2(d[0]-m[0],d[1]-m[1]),A=dn(x,v)/Math.PI*180,R=x.length()+v.length();(!u||A<r&&R>.01||R>e)&&(s.push(i[c+1]),u=!0)}if(s.push(i[i.length-1]),!t)return s;let l=[];l.push(s[0]);for(let c=0;c<s.length-2;c+=1){let f=new Q.Vector2(s[c][0],s[c][1]),m=new Q.Vector2(s[c+1][0],s[c+1][1]),d=new Q.Vector2(s[c+2][0],s[c+2][1]),x=f.distanceTo(m)/2,v=d.distanceTo(m)/2,A=m.clone(),R=m.clone();A.add(f.clone().sub(m).normalize().multiplyScalar(x>o?o/2:x)),R.add(d.clone().sub(m).normalize().multiplyScalar(v>o?o/2:v));let G=[[A.x,A.y],[m.x,m.y],[R.x,R.y]];l.push(...ze(G,o/25))}l.push(s[s.length-1]);let a=[],h;return l.forEach(([c,f])=>{h?c===h[0]&&f===h[0]||(h=[c,f],a.push([c,f])):(h=[c,f],a.push([c,f]))}),a}var Ve=class extends V{path=null;worker=Xt();fetchRoadStatus=!1;uniqueKey=new _t;paths=[];constructor(n,t){super(n);let{apiDomain:e,apiPath:{roadNetwork:r},apiInfo:o}=this.bmap.config;this.triggerWorker("fetch_project_road",{fetchOption:{url:`${e||location.origin}${r}?project=${t}`,...o}}),this.worker.addEventListener("message",({data:s})=>{s.type==="fetch_project_road_result"&&s.data.result&&(this.fetchRoadStatus=!0,this.dispatchEvent({type:"fetch-road-status",status:!0}))}),this.bmap.addEventListener("switch_floor_after",this.onSwitchFloor)}triggerWorker(n,t){this.worker.postMessage({type:n,data:t})}onSwitchFloor=({data:{curFloor:n}})=>{if(this.paths.length){let t=this.paths.find(e=>e.floor===n.name);t?this.renderPath(this.translatePoints(t.points)):this.path&&(this.bmap.context.scene.remove(this.path),this.path=null)}};getDirectionPath(n){return new Promise(t=>{let e=this.uniqueKey.genUniqueKey(),r=o=>{o.data.type==="direction_path_result"&&o.data.data.key===e&&(t(o.data.data.path),this.worker.removeEventListener("message",r),this.uniqueKey.removeKey(e))};this.worker.addEventListener("message",r),this.triggerWorker("get_direction_path",{points:n,key:e})})}addPath(n){this.paths=n;let t=this.bmap.context.currentFloor?.name,e=n.find(r=>r.floor===t);if(e)if(this.bmap.currentBuildGround)this.renderPath(this.translatePoints(e.points));else{let r=()=>{this.bmap.removeEventListener("center-change",r),this.renderPath(this.translatePoints(e.points))};this.bmap.addEventListener("center-change",r)}}translatePoints(n){let[t,e]=this.bmap.buildingCenter;return n.map(r=>[r[0]-t,r[1]-e])}getPath(n,t){return new Promise(e=>{let r=this.uniqueKey.genUniqueKey(),o=({data:s})=>{s.type==="get_path_result"&&s.data.key===r&&e(s.data.path)};if(this.worker.addEventListener("message",o),this.fetchRoadStatus)this.triggerWorker("get_path",{start:n,end:t,key:r});else{let s=({status:u})=>{u&&(this.removeEventListener("fetch-road-status",s),this.triggerWorker("get_path",{start:n,end:t,key:r}))};this.addEventListener("fetch-road-status",s)}})}renderPath(n){let t=this.catmullRomCurve3(n).map(([e,r])=>[e,r]);this.path?this.path.updatePoints(t):(this.path=new Gt(this,{}),this.path.create(t),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.1,this.bmap.context.scene.add(this.path))}catmullRomCurve3(n){return ke(n,!0,!0,10,150,3)}dispose(){this.worker.terminate(),this.bmap.removeEventListener("switch_floor_after",this.onSwitchFloor),this.path?.dispose(),this.uniqueKey.dispose()}};var He=class extends V{cacheData=new Map;floorDataLengthMap=new Map;async load(n){let t=F(n);if(this.cacheData.has(t))return this.cacheData.get(t);console.time("floor/get\u8BF7\u6C42"+n.resource_type_list);let[,e]=await Promise.all([this.loadBuildGround(n),Ut(n,this.bmap.config)]);console.timeEnd("floor/get\u8BF7\u6C42"+n.resource_type_list);let r=F({floor:n.floor,ts:n.ts});this.bmap.transformGraphicData(e,this.bmap.buildingCenter,this.floorDataLengthMap.get(r)||0),e.forEach(s=>s.info.transformToBuildingGround=!1),this.cacheData.set(t,e);let o=this.floorDataLengthMap.get(r)||0;return this.floorDataLengthMap.set(r,o+e.length),e}isSameFloor(n){return this.bmap.context.currentFloor?.key===F(n)}switchFloorByData(n,t){if(this.isSameFloor(t)){if(!n.length)return;let e=this.bmap.context.currentFloor,r=e.userData.legacyToGraphicMap,o=e.userData.graphicMap,s=[];for(let u of n){if(u.info.group==="ground")e.createGround(u.info);else{let l=e.addGraphic(u.info);l.userData.data=u,r.set(u.legacy_id,l),s.push(l)}o.set(u.element_uuid,u)}this.bmap.triggerHooks("switch_floor_before",{curFloor:e,graphics:s}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks("switch_floor_after",{curFloor:e,graphics:s})}else{let e=F(t),{curFloor:r,graphics:o}=this.bmap.createFloor(n);r.name=t.floor,r.key=e;let s=new Map;n.forEach(u=>{s.set(u.element_uuid,u)}),r.userData.graphicMap=s,this.bmap.triggerHooks("switch_floor_before",{curFloor:r,graphics:o}),this.bmap.context.switchFloor(r),this.bmap.initialFloorCamera(),this.bmap.triggerHooks("switch_floor_after",{curFloor:r,graphics:o})}}filterData(n,t){if(!this.isSameFloor(t))return n;let e=this.bmap.context.currentFloor.userData.graphicMap;return n.filter(r=>!e.has(r.element_uuid))}async switchFloorByStoreData(n){let t=await this.load({...n,resource_type_list:"6"}),e=this.filterData(t,n);this.switchFloorByData(e,n)}async switchFloorByOtherData(n){let t=await this.load({...n,resource_type_list:"1,2,3,4"}),e=this.filterData(t,n);this.switchFloorByData(e,n)}async loadBuildGround({brand:n,project:t}){let e=F({brand:n,project:t});return await this.bmap.loadBuildingGround({brand:n,project:t}),this.bmap.currentBuildGround=this.bmap.buildingGroundMap.get(e)||null,this.bmap.currentBuildGround}async changeFloor(n){return await Promise.all([this.switchFloorByStoreData(n),this.switchFloorByOtherData(n)]),Array.from(this.bmap.context.currentFloor.userData.graphicMap.values())}};})();
3726
+ `);var it=class extends p.ShaderMaterial{constructor(n){super({uniforms:Object.assign({},p.UniformsLib.fog,{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new p.Color(16777215)},opacity:{value:1},resolution:{value:new p.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new p.Vector2(1,1)}}),vertexShader:p.ShaderChunk.meshline_vert,fragmentShader:p.ShaderChunk.meshline_frag}),this.isMeshLineMaterial=!0,this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get:function(){return this.uniforms.lineWidth.value},set:function(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get:function(){return this.uniforms.useMap.value},set:function(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get:function(){return this.uniforms.alphaMap.value},set:function(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get:function(){return this.uniforms.useAlphaMap.value},set:function(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get:function(){return this.uniforms.color.value},set:function(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get:function(){return this.uniforms.sizeAttenuation.value},set:function(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get:function(){return this.uniforms.dashArray.value},set:function(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get:function(){return this.uniforms.dashRatio.value},set:function(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get:function(){return this.uniforms.useDash.value},set:function(t){this.uniforms.useDash.value=t}},visibility:{enumerable:!0,get:function(){return this.uniforms.visibility.value},set:function(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get:function(){return this.uniforms.alphaTest.value},set:function(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(t){this.uniforms.repeat.value.copy(t)}}}),this.setValues(n)}};it.prototype.copy=function(i){return p.ShaderMaterial.prototype.copy.call(this,i),this.lineWidth=i.lineWidth,this.map=i.map,this.useMap=i.useMap,this.alphaMap=i.alphaMap,this.useAlphaMap=i.useAlphaMap,this.color.copy(i.color),this.opacity=i.opacity,this.resolution.copy(i.resolution),this.sizeAttenuation=i.sizeAttenuation,this.dashArray.copy(i.dashArray),this.dashOffset.copy(i.dashOffset),this.dashRatio.copy(i.dashRatio),this.useDash=i.useDash,this.visibility=i.visibility,this.alphaTest=i.alphaTest,this.repeat.copy(i.repeat),this};var Ie="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAMAAACROYkbAAABrVBMVEVsjPdsjPdqi/doifdpivdrjPdsjPdsjPd/m/igtfqTq/lykfdri/dsjPdtjfe/zPv8/f/w8/6zw/p0kvdri/dsjPdtjffU3vz////////3+f62xfpzkfdri/dsjPdsjPeZr/nr8P7////////4+f62xfp0kvdri/dsjPdsjPdujveXrvne5v3////////3+f63x/t2lPdri/dsjPdsjPdsjPdri/eMpfjb4/3+/v/////4+v+7yft1k/dri/dsjPdsjPdri/eJovjl6/3////////3+f6Jo/lqivdsjPdri/dvjveluPry9f7////////i6f2BnPhqi/dsjPdrjPdvjveluPrv8v7////////l6/6Uq/lsjPdsjPdsjPdvjveluPrv8v7////////m6/6Uq/lsjPdsjPdsjPdsjPeZr/nv8v7////////s8f6XrvlsjPdsjPdtjffS2/z////////w9P6bsfltjfdsjPdtjffBz/v7/P/y9f6svvpxkPdrjPdsjPdsjPd+mviftPqVrPlykfdri/dsjPdsjPdri/doifdpifdrjPdsjPclkRlrAAAAx0lEQVQ4y2NgwAsYmZhZWNkYyAfsHJxc3Dy85BvAxy8gKCQsIkq2AWLiEpJS0jKycuQaIK+gqKSsoqqmrkGmAZpa2jq6evoGhkbG5BlgYmpmbmFpZW1ja0emE+wdHJ2cXVzd3D3INMDTy9vH188/IDCIPP3BIaFh4RGRUdExseQZEBefkJiUnJKalp5BngGZWdk5uXn5BemFZAZBUXFJaVl5RSWZ9jMwVFXX1NbVNzSSq5+hqbmlta29g2z9DJ1d3T29ffhUAABKPSh5Xst3GwAAAABJRU5ErkJggg==";var Le={texture_url:Ie,lineWidth:16,color:16777215},Gt=class extends M.Object3D{constructor(t,e){super();this.navigation=t;this.config=Object.assign({},Le,e),this.registryEvent()}mesh=null;geometry=null;material=null;texture=null;config=Le;points=[];basicRepeat=1;registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate)}onControlChange=()=>{this.changeRepeat()};onUpdate=()=>{this.texture};getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:r,height:o}}}}}=this,s=t.map(([l,a])=>y(new M.Vector3(l,a,0),e,r,o)).map(({x:l,y:a})=>[l,a]);return ae(s)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new M.Vector2(t,1)}loadTexture(t){return new Promise((e,r)=>{new M.TextureLoader().load(t,e,void 0,r)})}transformPoints(t){let e=[];for(let r=0;r<t.length;r++)e.push(...t[r],0);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}async create(t){let e=this.geometry=new L;if(this.updatePoints(t),!this.texture){let s=this.texture=await this.loadTexture(this.config.texture_url);s.wrapS=s.wrapT=M.RepeatWrapping}let r=this.material=new it({useMap:!0,color:new M.Color(this.config.color),transparent:!0,resolution:new M.Vector2(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:this.config.lineWidth,map:this.texture,blending:M.NormalBlending,repeat:new M.Vector2(this.getRepeat(),1)}),o=this.mesh=new M.Mesh(e,r);return this.add(o),o}dispose(){this.unRegistryEvent(),this.clear(),this.geometry?.dispose(),this.material?.dispose(),this.texture?.dispose()}};var Ne=(s=>(s.FETCH_PROJECT_ROAD="fetch_project_road",s.GET_DIRECTION_PATH="get_direction_path",s.DIRECTION_PATH_RESULT="direction_path_result",s.FETCH_PROJECT_ROAD_RESULT="fetch_project_road_result",s.GET_PATH="get_path",s.GET_PATH_RESULT="get_path_result",s))(Ne||{}),fn=(a=>(a.START="start",a.END="end",a.FRONT="front",a.RIGHT="right",a.LEFT="left",a.RIGHT_FRONT="right_front",a.LEFT_FRONT="left_front",a.RIGHT_BACK="right_back",a.LEFT_BACK="left_back",a))(fn||{});var Q=g("three"),Ge=tn(Be(),1);function dn(i,n){let t=i.clone().normalize(),e=n.clone().normalize();return Math.acos(t.dot(e))}function gn(i){let n=0;return i.reduce(([t,e],[r,o])=>(n+=Math.sqrt((r-t)**2+(o-e)**2),[r,o])),n/i.length}function ze(i,n=.25){if(gn(i)<n)return i;let t=(0,Ge.default)(i);return ze(t,n)}function ke(i,n=!1,t=!0,e=5,r=150,o=3){let s=[],u=!n;if(s.push(i[0]),i.length<2)return s;for(let c=0;c<i.length-2;c+=1){let f=i[c],m=i[c+1],d=i[c+2],x=new Q.Vector2(f[0]-m[0],f[1]-m[1]),v=new Q.Vector2(d[0]-m[0],d[1]-m[1]),A=dn(x,v)/Math.PI*180,R=x.length()+v.length();(!u||A<r&&R>.01||R>e)&&(s.push(i[c+1]),u=!0)}if(s.push(i[i.length-1]),!t)return s;let l=[];l.push(s[0]);for(let c=0;c<s.length-2;c+=1){let f=new Q.Vector2(s[c][0],s[c][1]),m=new Q.Vector2(s[c+1][0],s[c+1][1]),d=new Q.Vector2(s[c+2][0],s[c+2][1]),x=f.distanceTo(m)/2,v=d.distanceTo(m)/2,A=m.clone(),R=m.clone();A.add(f.clone().sub(m).normalize().multiplyScalar(x>o?o/2:x)),R.add(d.clone().sub(m).normalize().multiplyScalar(v>o?o/2:v));let G=[[A.x,A.y],[m.x,m.y],[R.x,R.y]];l.push(...ze(G,o/25))}l.push(s[s.length-1]);let a=[],h;return l.forEach(([c,f])=>{h?c===h[0]&&f===h[0]||(h=[c,f],a.push([c,f])):(h=[c,f],a.push([c,f]))}),a}var Ve=class extends V{path=null;worker=Xt();fetchRoadStatus=!1;uniqueKey=new _t;paths=[];constructor(n,t){super(n);let{apiDomain:e,apiPath:{roadNetwork:r},apiInfo:o}=this.bmap.config;this.triggerWorker("fetch_project_road",{fetchOption:{url:`${e||location.origin}${r}?project=${t}`,...o}}),this.worker.addEventListener("message",({data:s})=>{s.type==="fetch_project_road_result"&&s.data.result&&(this.fetchRoadStatus=!0,this.dispatchEvent({type:"fetch-road-status",status:!0}))}),this.bmap.addEventListener("switch_floor_after",this.onSwitchFloor)}triggerWorker(n,t){this.worker.postMessage({type:n,data:t})}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path=null)}onSwitchFloor=({data:{curFloor:n}})=>{if(this.paths.length){let t=this.paths.find(e=>e.floor===n.name);t?this.renderPath(this.translatePoints(t.points)):this.clearPath()}else this.clearPath()};getDirectionPath(n){return new Promise(t=>{let e=this.uniqueKey.genUniqueKey(),r=o=>{o.data.type==="direction_path_result"&&o.data.data.key===e&&(t(o.data.data.path),this.worker.removeEventListener("message",r),this.uniqueKey.removeKey(e))};this.worker.addEventListener("message",r),this.triggerWorker("get_direction_path",{points:n,key:e})})}addPath(n){this.paths=n;let t=this.bmap.context.currentFloor?.name,e=n.find(r=>r.floor===t);if(e)if(this.bmap.currentBuildGround)this.renderPath(this.translatePoints(e.points));else{let r=()=>{this.bmap.removeEventListener("center-change",r),this.renderPath(this.translatePoints(e.points))};this.bmap.addEventListener("center-change",r)}else this.clearPath()}translatePoints(n){let[t,e]=this.bmap.buildingCenter;return n.map(r=>[r[0]-t,r[1]-e])}getPath(n,t){return new Promise(e=>{let r=this.uniqueKey.genUniqueKey(),o=({data:s})=>{s.type==="get_path_result"&&s.data.key===r&&e(s.data.path)};if(this.worker.addEventListener("message",o),this.fetchRoadStatus)this.triggerWorker("get_path",{start:n,end:t,key:r});else{let s=({status:u})=>{u&&(this.removeEventListener("fetch-road-status",s),this.triggerWorker("get_path",{start:n,end:t,key:r}))};this.addEventListener("fetch-road-status",s)}})}renderPath(n){let t=this.catmullRomCurve3(n).map(([e,r])=>[e,r]);this.path?this.path.updatePoints(t):(this.path=new Gt(this,{}),this.path.create(t),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.1,this.bmap.context.scene.add(this.path))}catmullRomCurve3(n){return ke(n,!0,!0,10,150,3)}dispose(){this.worker.terminate(),this.bmap.removeEventListener("switch_floor_after",this.onSwitchFloor),this.path?.dispose(),this.uniqueKey.dispose()}};var He=class extends V{cacheData=new Map;floorDataLengthMap=new Map;async load(n){let t=F(n);if(this.cacheData.has(t))return this.cacheData.get(t);console.time("floor/get\u8BF7\u6C42"+n.resource_type_list);let[,e]=await Promise.all([this.loadBuildGround(n),Ut(n,this.bmap.config)]);console.timeEnd("floor/get\u8BF7\u6C42"+n.resource_type_list);let r=F({floor:n.floor,ts:n.ts});this.bmap.transformGraphicData(e,this.bmap.buildingCenter,this.floorDataLengthMap.get(r)||0),e.forEach(s=>s.info.transformToBuildingGround=!1),this.cacheData.set(t,e);let o=this.floorDataLengthMap.get(r)||0;return this.floorDataLengthMap.set(r,o+e.length),e}isSameFloor(n){return this.bmap.context.currentFloor?.key===F(n)}switchFloorByData(n,t){if(this.isSameFloor(t)){if(!n.length)return;let e=this.bmap.context.currentFloor,r=e.userData.legacyToGraphicMap,o=e.userData.graphicMap,s=[];for(let u of n){if(u.info.group==="ground")e.createGround(u.info);else{let l=e.addGraphic(u.info);l.userData.data=u,r.set(u.legacy_id,l),s.push(l)}o.set(u.element_uuid,u)}this.bmap.triggerHooks("switch_floor_before",{curFloor:e,graphics:s}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks("switch_floor_after",{curFloor:e,graphics:s})}else{let e=F(t),{curFloor:r,graphics:o}=this.bmap.createFloor(n);r.name=t.floor,r.key=e;let s=new Map;n.forEach(u=>{s.set(u.element_uuid,u)}),r.userData.graphicMap=s,this.bmap.triggerHooks("switch_floor_before",{curFloor:r,graphics:o}),this.bmap.context.switchFloor(r),this.bmap.initialFloorCamera(),this.bmap.triggerHooks("switch_floor_after",{curFloor:r,graphics:o})}}filterData(n,t){if(!this.isSameFloor(t))return n;let e=this.bmap.context.currentFloor.userData.graphicMap;return n.filter(r=>!e.has(r.element_uuid))}async switchFloorByStoreData(n){let t=await this.load({...n,resource_type_list:"6"}),e=this.filterData(t,n);this.switchFloorByData(e,n)}async switchFloorByOtherData(n){let t=await this.load({...n,resource_type_list:"1,2,3,4"}),e=this.filterData(t,n);this.switchFloorByData(e,n)}async loadBuildGround({brand:n,project:t}){let e=F({brand:n,project:t});return await this.bmap.loadBuildingGround({brand:n,project:t}),this.bmap.currentBuildGround=this.bmap.buildingGroundMap.get(e)||null,this.bmap.currentBuildGround}async changeFloor(n){return await Promise.all([this.switchFloorByStoreData(n),this.switchFloorByOtherData(n)]),Array.from(this.bmap.context.currentFloor.userData.graphicMap.values())}};})();
3727
3727
  //# sourceMappingURL=bmap.min.js.map