"use strict";var D=Object.defineProperty;var T=(n,t,e)=>t in n?D(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var s=(n,t,e)=>T(n,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("d3-geo"),r=require("three"),g=require("three-mesh-bvh");require("three/examples/jsm/controls/OrbitControls");require("three/examples/jsm/loaders/GLTFLoader");require("three/examples/jsm/loaders/DRACOLoader.js");const O=require("../../../../utils/mini3d/utils/utils.js");require("three/examples/jsm/libs/lil-gui.module.min");require("three/examples/jsm/utils/BufferGeometryUtils");require("three/examples/jsm/renderers/CSS3DRenderer");require("lodash");r.BufferGeometry.prototype.computeBoundsTree=g.computeBoundsTree;r.BufferGeometry.prototype.disposeBoundsTree=g.disposeBoundsTree;r.Mesh.prototype.raycast=g.acceleratedRaycast;class L{constructor({assets:t,time:e,depth:o},c={}){s(this,"coordinates");s(this,"config");s(this,"mapGroup");s(this,"assets");s(this,"depth");s(this,"time");s(this,"geoProjection",t=>{const{center:e}=this.config;return b.geoMercator().center(e).scale(120).translate([0,0])(t)});this.mapGroup=new r.Group,this.assets=t,this.depth=o,this.time=e,this.coordinates=[],this.config=Object.assign({position:new r.Vector3(0,0,0),center:new r.Vector2(0,0),data:"",renderOrder:1,topFaceMaterial:new r.MeshBasicMaterial({color:1582651,transparent:!0,opacity:1}),sideMaterial:new r.MeshBasicMaterial({color:464171,transparent:!0,opacity:1}),lineMaterial:new r.LineBasicMaterial({color:2868444}),depth:.1},c),this.mapGroup.position.copy(this.config.position);const m=O.transfromMapGeoJSON(this.config.data);this.create(m)}create(t){t.features.forEach((e,o)=>{const{name:c,center:m=[],centroid:S=[],adcode:l,parent:f}=e.properties;this.coordinates.push({name:c,center:m,centroid:e.properties.centroid||e.properties.center,adcode:l,enName:"",value:0});const p=new r.Group;p.name="meshGroup"+o,p.userData={index:o,name:c,center:m,centroid:e.properties.centroid||e.properties.center,adcode:l,childrenNum:e.properties.childrenNum},p.userData.materialEmissiveHex=this.config.topFaceMaterial.emissive.getHex();const a=new r.Group;a.name="lineGroup",a.userData.index=o,a.userData.adcode=l,a.userData.parent=f;const q={depth:this.config.depth,bevelEnabled:!0,bevelSegments:1,bevelThickness:.1},v=[this.config.topFaceMaterial,this.config.sideMaterial];e.geometry.coordinates.forEach(M=>{M.forEach((d,w)=>{const h=new r.Shape;for(let u=0;u<d.length;u++){if(!d[u][0]||!d[u][1])return!1;const[B,E]=this.geoProjection(d[u]);u===0&&h.moveTo(B,-E),h.lineTo(B,-E)}const x=new r.ExtrudeGeometry(h,q),i=new r.Mesh(x,v);i.userData.depth=this.config.depth,i.userData.name=c,i.userData.adcode=l,i.userData.parent=f,i.userData.materialEmissiveHex=this.config.topFaceMaterial.emissive.getHex(),i.renderOrder=this.config.renderOrder,i.name="mapArea-"+c,i.geometry.computeBoundsTree(),p.add(i)});const G=[];let y=null;M[0].forEach(d=>{const[w,h]=this.geoProjection(d);G.push(new r.Vector3(w,-h,0)),y=this.createLine(G)}),a.add(y)}),a.position.set(0,0,this.config.depth+.21),p.add(a),this.mapGroup.add(p)})}createLine(t){const e=new r.BufferGeometry;e.setFromPoints(t);const o=new r.LineLoop(e,this.config.lineMaterial);return o.renderOrder=2,o.name="mapLine",o}getCoordinates(){return this.coordinates}setParent(t){t.add(this.mapGroup)}}exports.ExtrudeMap=L;
