import{Vector3 as e,Line as t,BufferGeometry as n,LineBasicMaterial as i}from"three";function r(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{c(i.next(e))}catch(t){o(t)}}function s(e){try{c(i.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}))}class o{constructor(){var e;Object.defineProperty(this,"emitter",{enumerable:!0,configurable:!0,writable:!0,value:{all:e=e||new Map,on:function(t,n){var i=e.get(t);i?i.push(n):e.set(t,[n])},off:function(t,n){var i=e.get(t);i&&(n?i.splice(i.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var i=e.get(t);i&&i.slice().map((function(e){e(n)})),(i=e.get("*"))&&i.slice().map((function(e){e(t,n)}))}}})}on(e,t){return this.emitter.on(e,t),this}off(e,t){return this.emitter.off(e,t),this}}class a extends o{constructor(){super(),Object.defineProperty(this,"map",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}__inject(e){return this.map=e,this}}class s extends a{constructor(e){super(),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e})}__init(){console.log("RoadNetLayer init success"),this.initData(this.drawRoadNet.bind(this))}initData(e){return r(this,void 0,void 0,(function*(){const{data:t}=this.options;if("function"==typeof t)try{const n=yield t();console.log("resresresres :>> ",n),null==e||e(n)}catch(n){}else null==e||e(t)}))}drawRoadNet(t){const{map:n}=this;for(const i of t){i.begin[0]=+i.begin[0],i.begin[1]=+i.begin[1],i.end[0]=+i.end[0],i.end[1]=+i.end[1];const{begin:t,end:n}=i;this.drawNormalLine([new e(...t,0),new e(...n,0)],{name:"ar_roadNetPath",color:"red"})}n.reDraw()}drawNormalLine(e,r){const{map:o}=this,a=new t((new n).setFromPoints(e),new i({color:(null==r?void 0:r.color)||"red",opacity:1,transparent:!0,depthTest:!1}));a.name=(null==r?void 0:r.name)||"",a.userData={},o.scene.add(a)}}Object.defineProperty(s,"NAME",{enumerable:!0,configurable:!0,writable:!0,value:"RoadNetLayer"});export{s as RoadNetLayer};
