gl-draw 0.16.0-beta.30 → 0.16.0-beta.31

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.
@@ -1,7 +1,7 @@
1
- "use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(W)for(var t of W(e))ee.call(e,t)&&J(n,t,e[t]);return n},R=(n,e)=>me(n,ve(e));var ie=(n,e)=>{var t={};for(var i in n)H.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&W)for(var i of W(n))e.indexOf(i)<0&&ee.call(n,i)&&(t[i]=n[i]);return t};var re=(n,e,t)=>new Promise((i,r)=>{var a=c=>{try{s(t.next(c))}catch(l){r(l)}},u=c=>{try{s(t.throw(c))}catch(l){r(l)}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,u);s((t=t.apply(n,e)).next())});const o=require("three"),be=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),L=require("d3-array"),X=require("earcut"),ye=require("@turf/boolean-clockwise"),ge=require("delaunator"),Me=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),se=require("d3-scale"),Se=require("three/examples/jsm/lines/LineSegmentsGeometry"),we=0,je=1,Ae=2,Ce=!1;class fe{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof o.Material)return e;if(e instanceof Y?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Y)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const i of Object.values(e))i instanceof o.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const r=i.value;(r instanceof o.Texture||Array.isArray(r))&&this.track(r)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Be=(n,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,r=new o.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return r.onBeforeCompile=a=>{a.vertexShader=`
1
+ "use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(U)for(var t of U(e))ee.call(e,t)&&J(n,t,e[t]);return n},R=(n,e)=>me(n,ve(e));var ie=(n,e)=>{var t={};for(var i in n)H.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&U)for(var i of U(n))e.indexOf(i)<0&&ee.call(n,i)&&(t[i]=n[i]);return t};var re=(n,e,t)=>new Promise((i,r)=>{var a=c=>{try{s(t.next(c))}catch(l){r(l)}},u=c=>{try{s(t.throw(c))}catch(l){r(l)}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,u);s((t=t.apply(n,e)).next())});const o=require("three"),ye=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),L=require("d3-array"),X=require("earcut"),be=require("@turf/boolean-clockwise"),ge=require("delaunator"),Me=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),se=require("d3-scale"),Se=require("three/examples/jsm/lines/LineSegmentsGeometry"),we=0,je=1,Ae=2,Ce=!1;class fe{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof o.Material)return e;if(e instanceof Y?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Y)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const i of Object.values(e))i instanceof o.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const r=i.value;(r instanceof o.Texture||Array.isArray(r))&&this.track(r)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Be=(n,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,r=new o.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return r.onBeforeCompile=a=>{a.vertexShader=`
2
2
  attribute float scaleAtt;
3
3
  ${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new o.Points(t,r)},Pe=(n,e)=>{const t=new o.Object3D;e.forEach((i,r)=>{const a=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof o.Points||n.type==="Points"){const l=n.geometry,f=l.attributes.position.array,h=l.attributes.scaleAtt.array,p=new o.Vector3,d=new o.Vector3,v=new o.Quaternion,m=r*3,b=r*1;s.decompose(p,v,d),f[m]=p.x,f[m+1]=p.y,f[m+2]=p.z,h[b]=Math.max(d.x,d.y,d.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})};class Ie{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class De extends Ie{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const r=i.userData;i.userData={};const a=i.clone();return i.userData=r,a});{const i=t.userData;t.userData={};const r=t.clone();return t.userData=i,r}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const r=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=r,r}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const r=this.object3d;Array.isArray(r.material)&&t!==void 0?r.material[t]=i:r.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends De{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get lookAt(){return this.object3d.lookAt}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(we),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new be.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ne.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ne.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return re(this,null,function*(){var c,l;const t=(c=e==null?void 0:e.recursive)!=null?c:!0,i=(l=e==null?void 0:e.cloneMaterial)!=null?l:!1,{objectType:r,objectOptions:a}=this;let u=e==null?void 0:e.create,s;return this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:(e==null?void 0:e.target)||this.parent}):(u===void 0&&(u=f=>{var h;if(this.object3d){if((h=e==null?void 0:e.instancedAttr)!=null&&h.length){const p=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)f.object3d=Be(this.object3d,p);else{const d=this.object3d,v=i?this.cloneMaterial():d.material;f.object3d=new o.InstancedMesh(d.geometry,v,p)}Pe(f.object3d,e==null?void 0:e.instancedAttr)}else f.object3d=this.object3d.clone(!1),i&&f.object3d.material&&(f.object3d.material=this.cloneMaterial());f.object3d.userData.prefab&&delete f.object3d.userData.prefab}}),s=yield this.lead.draw(r,R(_({},a||{}),{create:u,prefab:!1,keyType:this.keyType,key:this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:(e==null?void 0:e.target)||this.parent}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(f=>f.instantiate({uId:e==null?void 0:e.uId,cloneMaterial:i,target:s})))),s.isInstantiate=!0,s})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new fe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Te(n,e){return n.map(t=>{const i=[];let r;return t.forEach(a=>{if(r){const u=E.geoDistance(a,r)*180/Math.PI;if(u>e){const s=E.geoInterpolate(r,a),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=a)}),i})}function Ve(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const a=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=d=>d/u*360%360-180,c=d=>Math.acos(2*d/a-1)/Math.PI*180-90,l=d=>a*(Math.cos((d+90)*Math.PI/180)+1)/2,f=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):a-1],h=e===void 0&&t===void 0?()=>!0:e===void 0?d=>d<=t:t===void 0?d=>d>=e:t>=e?d=>d>=e&&d<=t:d=>d>=e||d<=t,p=[];for(let d=f[0];d<=f[1];d++){const v=s(d);h(v)&&p.push([v,c(d)])}return p}function Z(n,e,t=!1){return t?E.geoContains(e,n):Me(n,e)}function Oe(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[a,u]]=E.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(u-r))<e)return[];const s=i>a||u>=89||r<=-89;return Ve(e,{minLng:i,maxLng:a,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Te(n,e),a=L.merge(r),u=Oe(n,e),s=[...a,...u],c={type:"Polygon",coordinates:n},[[l,f],[h,p]]=E.geoBounds(c),d=l>h||p>=89||f<=-89;let v=[];if(d){const y=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,B],O)=>[`${C}-${B}`,O]));y.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(B.forEach(([P,q])=>{const k=`${P}-${q}`;S.has(k)&&O.push(S.get(k))}),O.length===3){if(O.some(P=>P<a.length)){const P=C.properties.circumcenter;if(!Z(P,c,d))return}v.push(...O)}})}else if(u.length){const y=ge.from(s);for(let S=0,C=y.triangles.length;S<C;S+=3){const B=[2,1,0].map(P=>y.triangles[S+P]),O=B.map(P=>s[P]);if(B.some(P=>P<a.length)){const P=[0,1].map(q=>L.mean(O,k=>k[q]));if(!Z(P,c,d))continue}v.push(...B)}}else{const{vertices:y,holes:S=[]}=X.flatten(r);v=X(y,S,2)}let m=t?[t[0],t[2]]:L.extent(s,y=>y[0]),b=t?[t[1],t[3]]:L.extent(s,y=>y[1]);if(i){const[y,S]=i([m[0],b[0]]),[C,B]=i([m[1],b[1]]);m=[y,C],b=[-S,-B]}const w=se.scaleLinear(m,[0,1]),j=se.scaleLinear(b,[0,1]),I=s.map(([y,S])=>{if(i){const[C,B]=i([y,S]);return[w(C),j(-B)]}else return[w(y),j(S)]});return{contour:r,triangles:{points:s,indices:v,uvs:I}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(a=>a.map(([u,s])=>{if(i){const[c,l]=i([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(r)}function Le(n,e,t,i,r){const{vertices:a,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,a]),l=Math.round(s.length/3),f=new Set(u);let h=0;const p=[];for(let v=0;v<l;v++){let m=v+1;if(m===l)m=h;else if(f.has(m)){const b=m;m=h,h=b}p.push(v,v+l,m+l),p.push(m+l,m,v)}const d=[];for(let v=1;v>=0;v--)for(let m=0;m<l;m+=1)d.push(m/(l-1),v);return{indices:p,vertices:c,uvs:d,topVerts:s}}function ae(n,e,t,i,r,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,a).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:a=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{ye(w)||w.reverse()});const{contour:f,triangles:h}=ze(n,{resolution:i,bbox:l,projection:c});let p={},d;a&&(p=Le(f,e!=null?e:t,t!=null?t:e,r,c),d=p.topVerts);let v=[];(u||s)&&(v=L.merge(h.uvs));let m={};u&&(m=ae(h,e,v,!1,r,c));let b={};return s&&(b=ae(h,t,v,!0,r,c)),{contour:f,triangles:h,sideTorso:p,bottomCap:m,topCap:b,topVerts:d}};class _e extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:r,topFirst:a,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:f}=this.parameters,{contour:h,sideTorso:p,topVerts:d,bottomCap:v,topCap:m}=he(_({},this.parameters));let b=[],w=[],j=[],I=0;const A=y=>{const S=Math.round(b.length/3),C=j.length;b=b.concat(y.vertices),w=w.concat(y.uvs),j=j.concat(S?y.indices.map(B=>B+S):y.indices),this.addGroup(C,j.length-C,I++)};r&&a&&A(m),s&&(A(p),this.userData.topVerts=l?G(h,i+l,c,f).vertices:d),u&&A(v),r&&!a&&A(m),this.setIndex(j),this[oe]("position",new o.Float32BufferAttribute(b,3)),this[oe]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Ee=`
4
+ `},new o.Points(t,r)},Ie=(n,e)=>{const t=new o.Object3D;e.forEach((i,r)=>{const a=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof o.Points||n.type==="Points"){const l=n.geometry,f=l.attributes.position.array,h=l.attributes.scaleAtt.array,p=new o.Vector3,d=new o.Vector3,v=new o.Quaternion,m=r*3,y=r*1;s.decompose(p,v,d),f[m]=p.x,f[m+1]=p.y,f[m+2]=p.z,h[y]=Math.max(d.x,d.y,d.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})};class Pe{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class De extends Pe{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const r=i.userData;i.userData={};const a=i.clone();return i.userData=r,a});{const i=t.userData;t.userData={};const r=t.clone();return t.userData=i,r}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const r=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=r,r}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const r=this.object3d;Array.isArray(r.material)&&t!==void 0?r.material[t]=i:r.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends De{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get lookAt(){return this.object3d.lookAt}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(we),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new ye.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ne.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ne.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return re(this,null,function*(){var c,l;const t=(c=e==null?void 0:e.recursive)!=null?c:!0,i=(l=e==null?void 0:e.cloneMaterial)!=null?l:!1,{objectType:r,objectOptions:a}=this;let u=e==null?void 0:e.create,s;return this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:(e==null?void 0:e.target)||this.parent}):(u===void 0&&(u=f=>{var h;if(this.object3d){if((h=e==null?void 0:e.instancedAttr)!=null&&h.length){const p=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)f.object3d=Be(this.object3d,p);else{const d=this.object3d,v=i?this.cloneMaterial():d.material;f.object3d=new o.InstancedMesh(d.geometry,v,p)}Ie(f.object3d,e==null?void 0:e.instancedAttr)}else f.object3d=this.object3d.clone(!1),i&&f.object3d.material&&(f.object3d.material=this.cloneMaterial());f.object3d.userData.prefab&&delete f.object3d.userData.prefab}}),s=yield this.lead.draw(r,R(_({},a||{}),{create:u,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:(e==null?void 0:e.target)||this.parent}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(f=>f.instantiate({key:f.keyUId?`${f.keyName}-${f.keyUId}`:f.key,uId:e==null?void 0:e.uId,cloneMaterial:i,target:s})))),s.isInstantiate=!0,s})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new fe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Te(n,e){return n.map(t=>{const i=[];let r;return t.forEach(a=>{if(r){const u=E.geoDistance(a,r)*180/Math.PI;if(u>e){const s=E.geoInterpolate(r,a),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=a)}),i})}function Ve(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const a=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=d=>d/u*360%360-180,c=d=>Math.acos(2*d/a-1)/Math.PI*180-90,l=d=>a*(Math.cos((d+90)*Math.PI/180)+1)/2,f=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):a-1],h=e===void 0&&t===void 0?()=>!0:e===void 0?d=>d<=t:t===void 0?d=>d>=e:t>=e?d=>d>=e&&d<=t:d=>d>=e||d<=t,p=[];for(let d=f[0];d<=f[1];d++){const v=s(d);h(v)&&p.push([v,c(d)])}return p}function Z(n,e,t=!1){return t?E.geoContains(e,n):Me(n,e)}function Oe(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[a,u]]=E.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(u-r))<e)return[];const s=i>a||u>=89||r<=-89;return Ve(e,{minLng:i,maxLng:a,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Te(n,e),a=L.merge(r),u=Oe(n,e),s=[...a,...u],c={type:"Polygon",coordinates:n},[[l,f],[h,p]]=E.geoBounds(c),d=l>h||p>=89||f<=-89;let v=[];if(d){const b=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,B],O)=>[`${C}-${B}`,O]));b.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(B.forEach(([I,q])=>{const k=`${I}-${q}`;S.has(k)&&O.push(S.get(k))}),O.length===3){if(O.some(I=>I<a.length)){const I=C.properties.circumcenter;if(!Z(I,c,d))return}v.push(...O)}})}else if(u.length){const b=ge.from(s);for(let S=0,C=b.triangles.length;S<C;S+=3){const B=[2,1,0].map(I=>b.triangles[S+I]),O=B.map(I=>s[I]);if(B.some(I=>I<a.length)){const I=[0,1].map(q=>L.mean(O,k=>k[q]));if(!Z(I,c,d))continue}v.push(...B)}}else{const{vertices:b,holes:S=[]}=X.flatten(r);v=X(b,S,2)}let m=t?[t[0],t[2]]:L.extent(s,b=>b[0]),y=t?[t[1],t[3]]:L.extent(s,b=>b[1]);if(i){const[b,S]=i([m[0],y[0]]),[C,B]=i([m[1],y[1]]);m=[b,C],y=[-S,-B]}const w=se.scaleLinear(m,[0,1]),j=se.scaleLinear(y,[0,1]),P=s.map(([b,S])=>{if(i){const[C,B]=i([b,S]);return[w(C),j(-B)]}else return[w(b),j(S)]});return{contour:r,triangles:{points:s,indices:v,uvs:P}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(a=>a.map(([u,s])=>{if(i){const[c,l]=i([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(r)}function Le(n,e,t,i,r){const{vertices:a,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,a]),l=Math.round(s.length/3),f=new Set(u);let h=0;const p=[];for(let v=0;v<l;v++){let m=v+1;if(m===l)m=h;else if(f.has(m)){const y=m;m=h,h=y}p.push(v,v+l,m+l),p.push(m+l,m,v)}const d=[];for(let v=1;v>=0;v--)for(let m=0;m<l;m+=1)d.push(m/(l-1),v);return{indices:p,vertices:c,uvs:d,topVerts:s}}function ae(n,e,t,i,r,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,a).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:a=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{be(w)||w.reverse()});const{contour:f,triangles:h}=ze(n,{resolution:i,bbox:l,projection:c});let p={},d;a&&(p=Le(f,e!=null?e:t,t!=null?t:e,r,c),d=p.topVerts);let v=[];(u||s)&&(v=L.merge(h.uvs));let m={};u&&(m=ae(h,e,v,!1,r,c));let y={};return s&&(y=ae(h,t,v,!0,r,c)),{contour:f,triangles:h,sideTorso:p,bottomCap:m,topCap:y,topVerts:d}};class _e extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:r,topFirst:a,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:f}=this.parameters,{contour:h,sideTorso:p,topVerts:d,bottomCap:v,topCap:m}=he(_({},this.parameters));let y=[],w=[],j=[],P=0;const A=b=>{const S=Math.round(y.length/3),C=j.length;y=y.concat(b.vertices),w=w.concat(b.uvs),j=j.concat(S?b.indices.map(B=>B+S):b.indices),this.addGroup(C,j.length-C,P++)};r&&a&&A(m),s&&(A(p),this.userData.topVerts=l?G(h,i+l,c,f).vertices:d),u&&A(v),r&&!a&&A(m),this.setIndex(j),this[oe]("position",new o.Float32BufferAttribute(y,3)),this[oe]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Ee=`
5
5
  #include <fog_pars_fragment>
6
6
  #include <logdepthbuf_pars_fragment>
7
7
 
@@ -137,4 +137,4 @@ void main() {
137
137
  #include <logdepthbuf_vertex>
138
138
  #include <fog_vertex>
139
139
  }
140
- `;class We extends o.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:i="#ffffff",opacity:r=1,map:a=null,dashOffset:u=0,dashArray:s=0,dashRatio:c=0,sizeAttenuation:l=!0,offsetLoop:f=!0,offset:h=new o.Vector2(0,0),scaleDown:p=0,alphaMap:d=void 0,alphaTest:v=0,repeat:m=new o.Vector2(1,1),resolution:b=new o.Vector2(1,1)}=j,w=ie(j,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(R(_({},w),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(i)},opacity:{value:r},map:{value:a},useMap:{value:a?1:0},resolution:{value:b},sizeAttenuation:{value:l?1:0},offset:{value:h},offsetLoop:{value:f?1:0},dashArray:{value:s},dashOffset:{value:u},dashRatio:{value:c},useDash:{value:s>0?1:0},scaleDown:{value:p/10},alphaTest:{value:v},alphaMap:{value:d},useAlphaMap:{value:d?1:0},repeat:{value:m}},vertexShader:ke,fragmentShader:Ee})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const F=new o.Vector4,ce=new o.Vector3,le=new o.Vector3,g=new o.Vector4,M=new o.Vector4,D=new o.Vector4,$=new o.Vector3,K=new o.Matrix4,x=new o.Line3,ue=new o.Vector3,N=new o.Box3,U=new o.Sphere,T=new o.Vector4;let V,z;function de(n,e,t){return T.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),T.multiplyScalar(1/T.w),T.x=z/t.width,T.y=z/t.height,T.applyMatrix4(n.projectionMatrixInverse),T.multiplyScalar(1/T.w),Math.abs(Math.max(T.x,T.y))}function Ne(n,e){const t=n.matrixWorld,i=n.geometry,r=i.attributes.instanceStart,a=i.attributes.instanceEnd,u=Math.min(i.instanceCount,r.count);for(let s=0,c=u;s<c;s++){x.start.fromBufferAttribute(r,s),x.end.fromBufferAttribute(a,s),x.applyMatrix4(t);const l=new o.Vector3,f=new o.Vector3;V.distanceSqToSegment(x.start,x.end,f,l),f.distanceTo(l)<z*.5&&e.push({point:f,pointOnLine:l,distance:V.origin.distanceTo(f),object:n,face:null,faceIndex:s,uv:null,uv1:null})}}function Ue(n,e,t){const i=e.projectionMatrix,a=n.material.resolution,u=n.matrixWorld,s=n.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,f=Math.min(s.instanceCount,c.count),h=-e.near;V.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=a.x/2,D.y*=a.y/2,D.z=0,$.copy(D),K.multiplyMatrices(e.matrixWorldInverse,u);for(let p=0,d=f;p<d;p++){if(g.fromBufferAttribute(c,p),M.fromBufferAttribute(l,p),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>h&&M.z>h)continue;if(g.z>h){const I=g.z-M.z,A=(g.z-h)/I;g.lerp(M,A)}else if(M.z>h){const I=M.z-g.z,A=(M.z-h)/I;M.lerp(g,A)}g.applyMatrix4(i),M.applyMatrix4(i),g.multiplyScalar(1/g.w),M.multiplyScalar(1/M.w),g.x*=a.x/2,g.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,x.start.copy(g),x.start.z=0,x.end.copy(M),x.end.z=0;const m=x.closestPointToPointParameter($,!0);x.at(m,ue);const b=o.MathUtils.lerp(g.z,M.z,m),w=b>=-1&&b<=1,j=$.distanceTo(ue)<z*.5;if(w&&j){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(l,p),x.start.applyMatrix4(u),x.end.applyMatrix4(u);const I=new o.Vector3,A=new o.Vector3;V.distanceSqToSegment(x.start,x.end,A,I),t.push({point:A,pointOnLine:I,distance:V.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ge extends o.Mesh{constructor(e=new Se.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let u=0,s=0,c=t.count;u<c;u++,s+=2)ce.fromBufferAttribute(t,u),le.fromBufferAttribute(i,u),r[s]=s===0?0:r[s-1],r[s+1]=r[s]+ce.distanceTo(le);const a=new o.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,r=e.camera;r===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;V=e.ray;const u=this.matrixWorld,s=this.geometry,c=this.material;z=c.linewidth+a,s.boundingSphere===null&&s.computeBoundingSphere(),U.copy(s.boundingSphere).applyMatrix4(u);let l;if(i)l=z*.5;else{const h=Math.max(r.near,U.distanceToPoint(V.origin));l=de(r,h,c.resolution)}if(U.radius+=l,V.intersectsSphere(U)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),N.copy(s.boundingBox).applyMatrix4(u);let f;if(i)f=z*.5;else{const h=Math.max(r.near,N.distanceToPoint(V.origin));f=de(r,h,c.resolution)}N.expandByScalar(f),V.intersectsBox(N)!==!1&&(i?Ne(this,t):Ue(this,r,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}exports.BLOOM_SCENE=je;exports.BaseObject=Y;exports.IS_DEV=Ce;exports.LineSegments2=Ge;exports.MeshLineMaterial=We;exports.PolygonGeometry=_e;exports.ResourceTracker=fe;exports.getMetas=he;
140
+ `;class Ue extends o.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:i="#ffffff",opacity:r=1,map:a=null,dashOffset:u=0,dashArray:s=0,dashRatio:c=0,sizeAttenuation:l=!0,offsetLoop:f=!0,offset:h=new o.Vector2(0,0),scaleDown:p=0,alphaMap:d=void 0,alphaTest:v=0,repeat:m=new o.Vector2(1,1),resolution:y=new o.Vector2(1,1)}=j,w=ie(j,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(R(_({},w),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(i)},opacity:{value:r},map:{value:a},useMap:{value:a?1:0},resolution:{value:y},sizeAttenuation:{value:l?1:0},offset:{value:h},offsetLoop:{value:f?1:0},dashArray:{value:s},dashOffset:{value:u},dashRatio:{value:c},useDash:{value:s>0?1:0},scaleDown:{value:p/10},alphaTest:{value:v},alphaMap:{value:d},useAlphaMap:{value:d?1:0},repeat:{value:m}},vertexShader:ke,fragmentShader:Ee})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const F=new o.Vector4,ce=new o.Vector3,le=new o.Vector3,g=new o.Vector4,M=new o.Vector4,D=new o.Vector4,$=new o.Vector3,K=new o.Matrix4,x=new o.Line3,ue=new o.Vector3,W=new o.Box3,N=new o.Sphere,T=new o.Vector4;let V,z;function de(n,e,t){return T.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),T.multiplyScalar(1/T.w),T.x=z/t.width,T.y=z/t.height,T.applyMatrix4(n.projectionMatrixInverse),T.multiplyScalar(1/T.w),Math.abs(Math.max(T.x,T.y))}function We(n,e){const t=n.matrixWorld,i=n.geometry,r=i.attributes.instanceStart,a=i.attributes.instanceEnd,u=Math.min(i.instanceCount,r.count);for(let s=0,c=u;s<c;s++){x.start.fromBufferAttribute(r,s),x.end.fromBufferAttribute(a,s),x.applyMatrix4(t);const l=new o.Vector3,f=new o.Vector3;V.distanceSqToSegment(x.start,x.end,f,l),f.distanceTo(l)<z*.5&&e.push({point:f,pointOnLine:l,distance:V.origin.distanceTo(f),object:n,face:null,faceIndex:s,uv:null,uv1:null})}}function Ne(n,e,t){const i=e.projectionMatrix,a=n.material.resolution,u=n.matrixWorld,s=n.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,f=Math.min(s.instanceCount,c.count),h=-e.near;V.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=a.x/2,D.y*=a.y/2,D.z=0,$.copy(D),K.multiplyMatrices(e.matrixWorldInverse,u);for(let p=0,d=f;p<d;p++){if(g.fromBufferAttribute(c,p),M.fromBufferAttribute(l,p),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>h&&M.z>h)continue;if(g.z>h){const P=g.z-M.z,A=(g.z-h)/P;g.lerp(M,A)}else if(M.z>h){const P=M.z-g.z,A=(M.z-h)/P;M.lerp(g,A)}g.applyMatrix4(i),M.applyMatrix4(i),g.multiplyScalar(1/g.w),M.multiplyScalar(1/M.w),g.x*=a.x/2,g.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,x.start.copy(g),x.start.z=0,x.end.copy(M),x.end.z=0;const m=x.closestPointToPointParameter($,!0);x.at(m,ue);const y=o.MathUtils.lerp(g.z,M.z,m),w=y>=-1&&y<=1,j=$.distanceTo(ue)<z*.5;if(w&&j){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(l,p),x.start.applyMatrix4(u),x.end.applyMatrix4(u);const P=new o.Vector3,A=new o.Vector3;V.distanceSqToSegment(x.start,x.end,A,P),t.push({point:A,pointOnLine:P,distance:V.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ge extends o.Mesh{constructor(e=new Se.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let u=0,s=0,c=t.count;u<c;u++,s+=2)ce.fromBufferAttribute(t,u),le.fromBufferAttribute(i,u),r[s]=s===0?0:r[s-1],r[s+1]=r[s]+ce.distanceTo(le);const a=new o.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,r=e.camera;r===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;V=e.ray;const u=this.matrixWorld,s=this.geometry,c=this.material;z=c.linewidth+a,s.boundingSphere===null&&s.computeBoundingSphere(),N.copy(s.boundingSphere).applyMatrix4(u);let l;if(i)l=z*.5;else{const h=Math.max(r.near,N.distanceToPoint(V.origin));l=de(r,h,c.resolution)}if(N.radius+=l,V.intersectsSphere(N)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),W.copy(s.boundingBox).applyMatrix4(u);let f;if(i)f=z*.5;else{const h=Math.max(r.near,W.distanceToPoint(V.origin));f=de(r,h,c.resolution)}W.expandByScalar(f),V.intersectsBox(W)!==!1&&(i?We(this,t):Ne(this,r,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}exports.BLOOM_SCENE=je;exports.BaseObject=Y;exports.IS_DEV=Ce;exports.LineSegments2=Ge;exports.MeshLineMaterial=Ue;exports.PolygonGeometry=_e;exports.ResourceTracker=fe;exports.getMetas=he;
@@ -1,47 +1,47 @@
1
- var Ct = Object.defineProperty, Pt = Object.defineProperties;
2
- var It = Object.getOwnPropertyDescriptors;
1
+ var Ct = Object.defineProperty, It = Object.defineProperties;
2
+ var Pt = Object.getOwnPropertyDescriptors;
3
3
  var V = Object.getOwnPropertySymbols;
4
4
  var et = Object.prototype.hasOwnProperty, it = Object.prototype.propertyIsEnumerable;
5
- var st = Math.pow, tt = (n, t, e) => t in n ? Ct(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, E = (n, t) => {
5
+ var nt = Math.pow, tt = (s, t, e) => t in s ? Ct(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, k = (s, t) => {
6
6
  for (var e in t || (t = {}))
7
- et.call(t, e) && tt(n, e, t[e]);
7
+ et.call(t, e) && tt(s, e, t[e]);
8
8
  if (V)
9
9
  for (var e of V(t))
10
- it.call(t, e) && tt(n, e, t[e]);
11
- return n;
12
- }, $ = (n, t) => Pt(n, It(t));
13
- var nt = (n, t) => {
10
+ it.call(t, e) && tt(s, e, t[e]);
11
+ return s;
12
+ }, $ = (s, t) => It(s, Pt(t));
13
+ var st = (s, t) => {
14
14
  var e = {};
15
- for (var i in n)
16
- et.call(n, i) && t.indexOf(i) < 0 && (e[i] = n[i]);
17
- if (n != null && V)
18
- for (var i of V(n))
19
- t.indexOf(i) < 0 && it.call(n, i) && (e[i] = n[i]);
15
+ for (var i in s)
16
+ et.call(s, i) && t.indexOf(i) < 0 && (e[i] = s[i]);
17
+ if (s != null && V)
18
+ for (var i of V(s))
19
+ t.indexOf(i) < 0 && it.call(s, i) && (e[i] = s[i]);
20
20
  return e;
21
21
  };
22
- var rt = (n, t, e) => new Promise((i, s) => {
22
+ var rt = (s, t, e) => new Promise((i, n) => {
23
23
  var a = (o) => {
24
24
  try {
25
25
  r(e.next(o));
26
26
  } catch (c) {
27
- s(c);
27
+ n(c);
28
28
  }
29
29
  }, l = (o) => {
30
30
  try {
31
31
  r(e.throw(o));
32
32
  } catch (c) {
33
- s(c);
33
+ n(c);
34
34
  }
35
35
  }, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, l);
36
- r((e = e.apply(n, t)).next());
36
+ r((e = e.apply(s, t)).next());
37
37
  });
38
- import { Material as at, Object3D as N, Texture as ot, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Bt, Points as J, InstancedMesh as xt, Vector3 as I, Quaternion as Dt, Group as Tt, Mesh as wt, Sprite as ct, Box3 as St, ShaderMaterial as zt, Vector2 as q, Color as lt, Vector4 as L, Matrix4 as Ot, Line3 as _t, Sphere as Et, InstancedInterleavedBuffer as Lt, InterleavedBufferAttribute as ut, MathUtils as kt } from "three";
38
+ import { Material as at, Object3D as N, Texture as ot, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Bt, Points as J, InstancedMesh as xt, Vector3 as P, Quaternion as Dt, Group as Tt, Mesh as wt, Sprite as ct, Box3 as St, ShaderMaterial as zt, Vector2 as q, Color as lt, Vector4 as E, Matrix4 as Ot, Line3 as _t, Sphere as kt, InstancedInterleavedBuffer as Et, InterleavedBufferAttribute as ut, MathUtils as Lt } from "three";
39
39
  import { CSS2DObject as Vt } from "three/examples/jsm/renderers/CSS2DRenderer";
40
- import { CSS3DObject as Wt, CSS3DSprite as Ut } from "three/examples/jsm/renderers/CSS3DRenderer";
40
+ import { CSS3DObject as Ut, CSS3DSprite as Wt } from "three/examples/jsm/renderers/CSS3DRenderer";
41
41
  import { geoBounds as jt, geoContains as Nt, geoDistance as Rt, geoInterpolate as Gt } from "d3-geo";
42
42
  import "d3-geo-projection";
43
- import { p as dt, a as Ft } from "./polar2Cartesian.module.js";
44
- import { merge as H, mean as $t, extent as ft } from "d3-array";
43
+ import { p as ft, a as Ft } from "./polar2Cartesian.module.js";
44
+ import { merge as H, mean as $t, extent as dt } from "d3-array";
45
45
  import qt, { flatten as At } from "earcut";
46
46
  import Kt from "@turf/boolean-clockwise";
47
47
  import Qt from "delaunator";
@@ -75,8 +75,8 @@ class te {
75
75
  if (e.uniforms) {
76
76
  for (const i of Object.values(e.uniforms))
77
77
  if (i) {
78
- const s = i.value;
79
- (s instanceof ot || Array.isArray(s)) && this.track(s);
78
+ const n = i.value;
79
+ (n instanceof ot || Array.isArray(n)) && this.track(n);
80
80
  }
81
81
  }
82
82
  } else this.disposeVideo && t.isVideoTexture && t.source.data && this.resources.add(t.source.data);
@@ -91,7 +91,7 @@ class te {
91
91
  }), t.length = 0, this.resources.clear();
92
92
  }
93
93
  }
94
- const ee = (n, t = 1) => {
94
+ const ee = (s, t = 1) => {
95
95
  const e = new Z();
96
96
  e.setAttribute(
97
97
  "position",
@@ -100,7 +100,7 @@ const ee = (n, t = 1) => {
100
100
  "scaleAtt",
101
101
  new R(new Array(t).fill(1), 1)
102
102
  );
103
- const i = n.material, s = new Bt({
103
+ const i = s.material, n = new Bt({
104
104
  size: 10,
105
105
  map: i.map,
106
106
  alphaMap: i.alphaMap,
@@ -113,7 +113,7 @@ const ee = (n, t = 1) => {
113
113
  alphaTest: i.alphaTest,
114
114
  sizeAttenuation: !1
115
115
  });
116
- return s.onBeforeCompile = (a) => {
116
+ return n.onBeforeCompile = (a) => {
117
117
  a.vertexShader = `
118
118
  attribute float scaleAtt;
119
119
  ${a.vertexShader.replace(
@@ -121,22 +121,22 @@ const ee = (n, t = 1) => {
121
121
  "gl_PointSize = size * scaleAtt;"
122
122
  )}
123
123
  `;
124
- }, new J(e, s);
125
- }, ie = (n, t) => {
124
+ }, new J(e, n);
125
+ }, ie = (s, t) => {
126
126
  const e = new N();
127
- t.forEach((i, s) => {
128
- const a = dt(i.position), l = dt(i.scale || [1, 1, 1]);
127
+ t.forEach((i, n) => {
128
+ const a = ft(i.position), l = ft(i.scale || [1, 1, 1]);
129
129
  e.position.copy(a), e.scale.copy(l), e.updateMatrix();
130
130
  const r = e.matrix.clone();
131
- if (n instanceof xt || n.isInstantiate)
132
- n.setMatrixAt(s, r);
133
- else if (n instanceof J || n.type === "Points") {
134
- const c = n.geometry, d = c.attributes.position.array, f = c.attributes.scaleAtt.array, h = new I(), u = new I(), m = new Dt(), p = s * 3, v = s * 1;
135
- r.decompose(h, m, u), d[p] = h.x, d[p + 1] = h.y, d[p + 2] = h.z, f[v] = Math.max(u.x, u.y, u.z), c.attributes.position.needsUpdate = !0, c.attributes.scaleAtt.needsUpdate = !0;
131
+ if (s instanceof xt || s.isInstantiate)
132
+ s.setMatrixAt(n, r);
133
+ else if (s instanceof J || s.type === "Points") {
134
+ const c = s.geometry, f = c.attributes.position.array, d = c.attributes.scaleAtt.array, h = new P(), u = new P(), m = new Dt(), p = n * 3, v = n * 1;
135
+ r.decompose(h, m, u), f[p] = h.x, f[p + 1] = h.y, f[p + 2] = h.z, d[v] = Math.max(u.x, u.y, u.z), c.attributes.position.needsUpdate = !0, c.attributes.scaleAtt.needsUpdate = !0;
136
136
  }
137
137
  });
138
138
  };
139
- class se {
139
+ class ne {
140
140
  constructor() {
141
141
  this.onPointerIndex = [];
142
142
  }
@@ -165,7 +165,7 @@ class se {
165
165
  });
166
166
  }
167
167
  }
168
- class ne extends se {
168
+ class se extends ne {
169
169
  constructor() {
170
170
  super(...arguments), this.userData = {}, this.materialList = {}, this.useMaterialType = "origin", this.disposeMaterialIfNotUsed = !0;
171
171
  }
@@ -176,16 +176,16 @@ class ne extends se {
176
176
  const e = t.material;
177
177
  if (Array.isArray(e))
178
178
  return e.map((i) => {
179
- const s = i.userData;
179
+ const n = i.userData;
180
180
  i.userData = {};
181
181
  const a = i.clone();
182
- return i.userData = s, a;
182
+ return i.userData = n, a;
183
183
  });
184
184
  {
185
185
  const i = e.userData;
186
186
  e.userData = {};
187
- const s = e.clone();
188
- return e.userData = i, s;
187
+ const n = e.clone();
188
+ return e.userData = i, n;
189
189
  }
190
190
  }
191
191
  setMaterialList(t, e) {
@@ -193,8 +193,8 @@ class ne extends se {
193
193
  if (!i || !i.material)
194
194
  return;
195
195
  this.materialList.origin || (this.materialList.origin = i.material);
196
- const s = e === "clone" ? this.cloneMaterial() : Array.isArray(e) ? e.slice() : e;
197
- return this.materialList[t] = s, s;
196
+ const n = e === "clone" ? this.cloneMaterial() : Array.isArray(e) ? e.slice() : e;
197
+ return this.materialList[t] = n, n;
198
198
  }
199
199
  useMaterial(t) {
200
200
  const e = this.object3d;
@@ -206,8 +206,8 @@ class ne extends se {
206
206
  const i = this.mList.get(t);
207
207
  if (!i)
208
208
  return;
209
- const s = this.object3d;
210
- Array.isArray(s.material) && e !== void 0 ? s.material[e] = i : s.material = i;
209
+ const n = this.object3d;
210
+ Array.isArray(n.material) && e !== void 0 ? n.material[e] = i : n.material = i;
211
211
  }
212
212
  useMListByName(t, e) {
213
213
  if (!this.mList)
@@ -223,7 +223,7 @@ class ne extends se {
223
223
  );
224
224
  }
225
225
  }
226
- class pt extends ne {
226
+ class pt extends se {
227
227
  constructor() {
228
228
  super(...arguments), this.key = "", this.objectType = "BaseObject", this.userData = {}, this.isPrefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.isBaseObject = !0, this.disposeTrack = !0;
229
229
  }
@@ -302,10 +302,10 @@ class pt extends ne {
302
302
  return this.object3d = new Vt(t), this;
303
303
  }
304
304
  createCSS3DObject(t) {
305
- return this.object3d = new Wt(t), this;
305
+ return this.object3d = new Ut(t), this;
306
306
  }
307
307
  createCSS3DSprite(t) {
308
- return this.object3d = new Ut(t), this;
308
+ return this.object3d = new Wt(t), this;
309
309
  }
310
310
  createSprite(t) {
311
311
  return this.object3d = new ct(t), this;
@@ -320,8 +320,8 @@ class pt extends ne {
320
320
  return {
321
321
  min: t.min,
322
322
  max: t.max,
323
- size: t.getSize(new I()),
324
- center: t.getCenter(new I())
323
+ size: t.getSize(new P()),
324
+ center: t.getCenter(new P())
325
325
  };
326
326
  }
327
327
  setTop(t) {
@@ -335,40 +335,41 @@ class pt extends ne {
335
335
  instantiate(t) {
336
336
  return rt(this, null, function* () {
337
337
  var o, c;
338
- const e = (o = t == null ? void 0 : t.recursive) != null ? o : !0, i = (c = t == null ? void 0 : t.cloneMaterial) != null ? c : !1, { objectType: s, objectOptions: a } = this;
338
+ const e = (o = t == null ? void 0 : t.recursive) != null ? o : !0, i = (c = t == null ? void 0 : t.cloneMaterial) != null ? c : !1, { objectType: n, objectOptions: a } = this;
339
339
  let l = t == null ? void 0 : t.create, r;
340
340
  return this.objectType === "BaseObject" ? r = this.lead.createBaseObject(this.object3d.clone(!1), {
341
341
  target: (t == null ? void 0 : t.target) || this.parent
342
- }) : (l === void 0 && (l = (d) => {
343
- var f;
342
+ }) : (l === void 0 && (l = (f) => {
343
+ var d;
344
344
  if (this.object3d) {
345
- if ((f = t == null ? void 0 : t.instancedAttr) != null && f.length) {
345
+ if ((d = t == null ? void 0 : t.instancedAttr) != null && d.length) {
346
346
  const h = t.instancedAttr.length;
347
347
  if (this.object3d instanceof ct)
348
- d.object3d = ee(this.object3d, h);
348
+ f.object3d = ee(this.object3d, h);
349
349
  else {
350
350
  const u = this.object3d, m = i ? this.cloneMaterial() : u.material;
351
- d.object3d = new xt(
351
+ f.object3d = new xt(
352
352
  u.geometry,
353
353
  m,
354
354
  h
355
355
  );
356
356
  }
357
- ie(d.object3d, t == null ? void 0 : t.instancedAttr);
357
+ ie(f.object3d, t == null ? void 0 : t.instancedAttr);
358
358
  } else
359
- d.object3d = this.object3d.clone(!1), i && d.object3d.material && (d.object3d.material = this.cloneMaterial());
360
- d.object3d.userData.prefab && delete d.object3d.userData.prefab;
359
+ f.object3d = this.object3d.clone(!1), i && f.object3d.material && (f.object3d.material = this.cloneMaterial());
360
+ f.object3d.userData.prefab && delete f.object3d.userData.prefab;
361
361
  }
362
- }), r = yield this.lead.draw(s, $(E({}, a || {}), {
362
+ }), r = yield this.lead.draw(n, $(k({}, a || {}), {
363
363
  create: l,
364
364
  prefab: !1,
365
365
  keyType: this.keyType,
366
- key: this.keyName,
366
+ key: (t == null ? void 0 : t.key) || this.keyName,
367
367
  uId: (t == null ? void 0 : t.uId) || this.keyUId,
368
368
  target: (t == null ? void 0 : t.target) || this.parent
369
369
  }))), this.isBloom && r.enableBloom(), e && (yield Promise.all(
370
370
  this.children.map(
371
- (d) => d.instantiate({
371
+ (f) => f.instantiate({
372
+ key: f.keyUId ? `${f.keyName}-${f.keyUId}` : f.key,
372
373
  uId: t == null ? void 0 : t.uId,
373
374
  cloneMaterial: i,
374
375
  target: r
@@ -398,71 +399,71 @@ class pt extends ne {
398
399
  }
399
400
  }
400
401
  }
401
- function re(n, t) {
402
- return n.map((e) => {
402
+ function re(s, t) {
403
+ return s.map((e) => {
403
404
  const i = [];
404
- let s;
405
+ let n;
405
406
  return e.forEach((a) => {
406
- if (s) {
407
- const l = Rt(a, s) * 180 / Math.PI;
407
+ if (n) {
408
+ const l = Rt(a, n) * 180 / Math.PI;
408
409
  if (l > t) {
409
- const r = Gt(s, a), o = 1 / Math.ceil(l / t);
410
+ const r = Gt(n, a), o = 1 / Math.ceil(l / t);
410
411
  let c = o;
411
412
  for (; c < 1; )
412
413
  i.push(r(c)), c += o;
413
414
  }
414
415
  }
415
- i.push(s = a);
416
+ i.push(n = a);
416
417
  }), i;
417
418
  });
418
419
  }
419
- function ae(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
420
- const a = Math.round(st(360 / n, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, r = (u) => u / l * 360 % 360 - 180, o = (u) => Math.acos(2 * u / a - 1) / Math.PI * 180 - 90, c = (u) => a * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, d = [
421
- s !== void 0 ? Math.ceil(c(s)) : 0,
420
+ function ae(s, { minLng: t, maxLng: e, minLat: i, maxLat: n } = {}) {
421
+ const a = Math.round(nt(360 / s, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, r = (u) => u / l * 360 % 360 - 180, o = (u) => Math.acos(2 * u / a - 1) / Math.PI * 180 - 90, c = (u) => a * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, f = [
422
+ n !== void 0 ? Math.ceil(c(n)) : 0,
422
423
  i !== void 0 ? Math.floor(c(i)) : a - 1
423
- ], f = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (u) => u <= e : e === void 0 ? (u) => u >= t : e >= t ? (u) => u >= t && u <= e : (u) => u >= t || u <= e, h = [];
424
- for (let u = d[0]; u <= d[1]; u++) {
424
+ ], d = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (u) => u <= e : e === void 0 ? (u) => u >= t : e >= t ? (u) => u >= t && u <= e : (u) => u >= t || u <= e, h = [];
425
+ for (let u = f[0]; u <= f[1]; u++) {
425
426
  const m = r(u);
426
- f(m) && h.push([m, o(u)]);
427
+ d(m) && h.push([m, o(u)]);
427
428
  }
428
429
  return h;
429
430
  }
430
- function Y(n, t, e = !1) {
431
- return e ? Nt(t, n) : Xt(n, t);
431
+ function Y(s, t, e = !1) {
432
+ return e ? Nt(t, s) : Xt(s, t);
432
433
  }
433
- function oe(n, t) {
434
- const e = { type: "Polygon", coordinates: n }, [[i, s], [a, l]] = jt(e);
435
- if (Math.min(Math.abs(a - i), Math.abs(l - s)) < t)
434
+ function oe(s, t) {
435
+ const e = { type: "Polygon", coordinates: s }, [[i, n], [a, l]] = jt(e);
436
+ if (Math.min(Math.abs(a - i), Math.abs(l - n)) < t)
436
437
  return [];
437
- const r = i > a || l >= 89 || s <= -89;
438
+ const r = i > a || l >= 89 || n <= -89;
438
439
  return ae(t, {
439
440
  minLng: i,
440
441
  maxLng: a,
441
- minLat: s,
442
+ minLat: n,
442
443
  maxLat: l
443
444
  }).filter(
444
445
  (o) => Y(o, e, r)
445
446
  );
446
447
  }
447
- function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
448
- const s = re(n, t), a = H(s), l = oe(n, t), r = [...a, ...l], o = { type: "Polygon", coordinates: n }, [[c, d], [f, h]] = jt(o), u = c > f || // crosses antimeridian
448
+ function ce(s, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
449
+ const n = re(s, t), a = H(n), l = oe(s, t), r = [...a, ...l], o = { type: "Polygon", coordinates: s }, [[c, f], [d, h]] = jt(o), u = c > d || // crosses antimeridian
449
450
  h >= 89 || // crosses north pole
450
- d <= -89;
451
+ f <= -89;
451
452
  let m = [];
452
453
  if (u) {
453
- const b = Yt(r).triangles(), x = new Map(
454
+ const y = Yt(r).triangles(), x = new Map(
454
455
  r.map(([A, C], O) => [`${A}-${C}`, O])
455
456
  );
456
- b.features.forEach((A) => {
457
+ y.features.forEach((A) => {
457
458
  const C = A.geometry.coordinates[0].slice(0, 3).reverse(), O = [];
458
- if (C.forEach(([P, F]) => {
459
- const k = `${P}-${F}`;
460
- x.has(k) && O.push(x.get(k));
459
+ if (C.forEach(([I, F]) => {
460
+ const L = `${I}-${F}`;
461
+ x.has(L) && O.push(x.get(L));
461
462
  }), O.length === 3) {
462
- if (O.some((P) => P < a.length)) {
463
- const P = A.properties.circumcenter;
463
+ if (O.some((I) => I < a.length)) {
464
+ const I = A.properties.circumcenter;
464
465
  if (!Y(
465
- P,
466
+ I,
466
467
  o,
467
468
  u
468
469
  ))
@@ -472,15 +473,15 @@ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
472
473
  }
473
474
  });
474
475
  } else if (l.length) {
475
- const b = Qt.from(r);
476
- for (let x = 0, A = b.triangles.length; x < A; x += 3) {
477
- const C = [2, 1, 0].map((P) => b.triangles[x + P]), O = C.map((P) => r[P]);
478
- if (C.some((P) => P < a.length)) {
479
- const P = [0, 1].map(
480
- (F) => $t(O, (k) => k[F])
476
+ const y = Qt.from(r);
477
+ for (let x = 0, A = y.triangles.length; x < A; x += 3) {
478
+ const C = [2, 1, 0].map((I) => y.triangles[x + I]), O = C.map((I) => r[I]);
479
+ if (C.some((I) => I < a.length)) {
480
+ const I = [0, 1].map(
481
+ (F) => $t(O, (L) => L[F])
481
482
  );
482
483
  if (!Y(
483
- P,
484
+ I,
484
485
  o,
485
486
  u
486
487
  ))
@@ -489,26 +490,26 @@ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
489
490
  m.push(...C);
490
491
  }
491
492
  } else {
492
- const { vertices: b, holes: x = [] } = At(s);
493
- m = qt(b, x, 2);
493
+ const { vertices: y, holes: x = [] } = At(n);
494
+ m = qt(y, x, 2);
494
495
  }
495
- let p = e ? [e[0], e[2]] : ft(r, (b) => b[0]), v = e ? [e[1], e[3]] : ft(r, (b) => b[1]);
496
+ let p = e ? [e[0], e[2]] : dt(r, (y) => y[0]), v = e ? [e[1], e[3]] : dt(r, (y) => y[1]);
496
497
  if (i) {
497
- const [b, x] = i([p[0], v[0]]), [A, C] = i([p[1], v[1]]);
498
- p = [b, A], v = [-x, -C];
498
+ const [y, x] = i([p[0], v[0]]), [A, C] = i([p[1], v[1]]);
499
+ p = [y, A], v = [-x, -C];
499
500
  }
500
- const w = ht(p, [0, 1]), S = ht(v, [0, 1]), B = r.map(([b, x]) => {
501
+ const w = ht(p, [0, 1]), S = ht(v, [0, 1]), B = r.map(([y, x]) => {
501
502
  if (i) {
502
- const [A, C] = i([b, x]);
503
+ const [A, C] = i([y, x]);
503
504
  return [w(A), S(-C)];
504
505
  } else
505
- return [w(b), S(x)];
506
+ return [w(y), S(x)];
506
507
  });
507
- return { contour: s, triangles: { points: r, indices: m, uvs: B } };
508
+ return { contour: n, triangles: { points: r, indices: m, uvs: B } };
508
509
  }
509
510
  const mt = new Z().setAttribute ? "setAttribute" : "addAttribute";
510
- function G(n, t, e, i) {
511
- const s = n.map(
511
+ function G(s, t, e, i) {
512
+ const n = s.map(
512
513
  (a) => a.map(([l, r]) => {
513
514
  if (i) {
514
515
  const [o, c] = i([l, r]);
@@ -517,29 +518,29 @@ function G(n, t, e, i) {
517
518
  return e ? Ft(l, r, t) : [l, r, t];
518
519
  })
519
520
  );
520
- return At(s);
521
+ return At(n);
521
522
  }
522
- function le(n, t, e, i, s) {
523
+ function le(s, t, e, i, n) {
523
524
  const { vertices: a, holes: l } = G(
524
- n,
525
+ s,
525
526
  t,
526
527
  i,
527
- s
528
+ n
528
529
  ), { vertices: r } = G(
529
- n,
530
+ s,
530
531
  e,
531
532
  i,
532
- s
533
- ), o = H([r, a]), c = Math.round(r.length / 3), d = new Set(l);
534
- let f = 0;
533
+ n
534
+ ), o = H([r, a]), c = Math.round(r.length / 3), f = new Set(l);
535
+ let d = 0;
535
536
  const h = [];
536
537
  for (let m = 0; m < c; m++) {
537
538
  let p = m + 1;
538
539
  if (p === c)
539
- p = f;
540
- else if (d.has(p)) {
540
+ p = d;
541
+ else if (f.has(p)) {
541
542
  const v = p;
542
- p = f, f = v;
543
+ p = d, d = v;
543
544
  }
544
545
  h.push(m, m + c, p + c), h.push(p + c, p, m);
545
546
  }
@@ -548,70 +549,70 @@ function le(n, t, e, i, s) {
548
549
  for (let p = 0; p < c; p += 1) u.push(p / (c - 1), m);
549
550
  return { indices: h, vertices: o, uvs: u, topVerts: r };
550
551
  }
551
- function vt(n, t, e, i, s, a) {
552
+ function vt(s, t, e, i, n, a) {
552
553
  return {
553
- indices: i ? n.indices : n.indices.slice().reverse(),
554
+ indices: i ? s.indices : s.indices.slice().reverse(),
554
555
  vertices: G(
555
- [n.points],
556
+ [s.points],
556
557
  t,
557
- s,
558
+ n,
558
559
  a
559
560
  ).vertices,
560
561
  uvs: e
561
562
  };
562
563
  }
563
564
  const ue = ({
564
- polygonGeoJson: n,
565
+ polygonGeoJson: s,
565
566
  startHeight: t,
566
567
  endHeight: e,
567
568
  curvatureResolution: i = 1,
568
- cartesian: s = !0,
569
+ cartesian: n = !0,
569
570
  hasSide: a = !0,
570
571
  hasBottom: l = !1,
571
572
  hasTop: r = !1,
572
573
  projection: o,
573
574
  bbox: c
574
575
  }) => {
575
- n.forEach((w) => {
576
+ s.forEach((w) => {
576
577
  Kt(w) || w.reverse();
577
578
  });
578
- const { contour: d, triangles: f } = ce(n, {
579
+ const { contour: f, triangles: d } = ce(s, {
579
580
  resolution: i,
580
581
  bbox: c,
581
582
  projection: o
582
583
  });
583
584
  let h = {}, u;
584
585
  a && (h = le(
585
- d,
586
+ f,
586
587
  t != null ? t : e,
587
588
  e != null ? e : t,
588
- s,
589
+ n,
589
590
  o
590
591
  ), u = h.topVerts);
591
592
  let m = [];
592
- (l || r) && (m = H(f.uvs));
593
+ (l || r) && (m = H(d.uvs));
593
594
  let p = {};
594
595
  l && (p = vt(
595
- f,
596
+ d,
596
597
  t,
597
598
  m,
598
599
  !1,
599
- s,
600
+ n,
600
601
  o
601
602
  ));
602
603
  let v = {};
603
604
  return r && (v = vt(
604
- f,
605
+ d,
605
606
  e,
606
607
  m,
607
608
  !0,
608
- s,
609
+ n,
609
610
  o
610
- )), { contour: d, triangles: f, sideTorso: h, bottomCap: p, topCap: v, topVerts: u };
611
+ )), { contour: f, triangles: d, sideTorso: h, bottomCap: p, topCap: v, topVerts: u };
611
612
  };
612
613
  class ze extends Z {
613
614
  constructor(t, e = {}) {
614
- super(), this.type = "PolygonBufferGeometry", this.parameters = E({
615
+ super(), this.type = "PolygonBufferGeometry", this.parameters = k({
615
616
  polygonGeoJson: t,
616
617
  startHeight: 0,
617
618
  endHeight: 1,
@@ -625,30 +626,30 @@ class ze extends Z {
625
626
  }, e);
626
627
  const {
627
628
  endHeight: i,
628
- hasTop: s,
629
+ hasTop: n,
629
630
  topFirst: a,
630
631
  hasBottom: l,
631
632
  hasSide: r,
632
633
  cartesian: o,
633
634
  userDataRsoOffset: c,
634
- projection: d
635
- } = this.parameters, { contour: f, sideTorso: h, topVerts: u, bottomCap: m, topCap: p } = ue(E({}, this.parameters));
635
+ projection: f
636
+ } = this.parameters, { contour: d, sideTorso: h, topVerts: u, bottomCap: m, topCap: p } = ue(k({}, this.parameters));
636
637
  let v = [], w = [], S = [], B = 0;
637
- const j = (b) => {
638
+ const j = (y) => {
638
639
  const x = Math.round(v.length / 3), A = S.length;
639
- v = v.concat(b.vertices), w = w.concat(b.uvs), S = S.concat(
640
- x ? b.indices.map((C) => C + x) : b.indices
640
+ v = v.concat(y.vertices), w = w.concat(y.uvs), S = S.concat(
641
+ x ? y.indices.map((C) => C + x) : y.indices
641
642
  ), this.addGroup(A, S.length - A, B++);
642
643
  };
643
- s && a && j(p), r && (j(h), this.userData.topVerts = c ? G(
644
- f,
644
+ n && a && j(p), r && (j(h), this.userData.topVerts = c ? G(
645
+ d,
645
646
  i + c,
646
647
  o,
647
- d
648
- ).vertices : u), l && j(m), s && !a && j(p), this.setIndex(S), this[mt]("position", new R(v, 3)), this[mt]("uv", new R(w, 2)), this.computeVertexNormals();
648
+ f
649
+ ).vertices : u), l && j(m), n && !a && j(p), this.setIndex(S), this[mt]("position", new R(v, 3)), this[mt]("uv", new R(w, 2)), this.computeVertexNormals();
649
650
  }
650
651
  }
651
- const de = `
652
+ const fe = `
652
653
  #include <fog_pars_fragment>
653
654
  #include <logdepthbuf_pars_fragment>
654
655
 
@@ -692,7 +693,7 @@ void main() {
692
693
  #include <tonemapping_fragment>
693
694
  #include <colorspace_fragment>
694
695
  }
695
- `, fe = `
696
+ `, de = `
696
697
  #include <common>
697
698
  #include <logdepthbuf_pars_vertex>
698
699
  #include <fog_pars_vertex>
@@ -790,20 +791,20 @@ class Oe extends zt {
790
791
  const S = t, {
791
792
  lineWidth: e = 1,
792
793
  color: i = "#ffffff",
793
- opacity: s = 1,
794
+ opacity: n = 1,
794
795
  map: a = null,
795
796
  dashOffset: l = 0,
796
797
  dashArray: r = 0,
797
798
  dashRatio: o = 0,
798
799
  sizeAttenuation: c = !0,
799
- offsetLoop: d = !0,
800
- offset: f = new q(0, 0),
800
+ offsetLoop: f = !0,
801
+ offset: d = new q(0, 0),
801
802
  scaleDown: h = 0,
802
803
  alphaMap: u = void 0,
803
804
  alphaTest: m = 0,
804
805
  repeat: p = new q(1, 1),
805
806
  resolution: v = new q(1, 1)
806
- } = S, w = nt(S, [
807
+ } = S, w = st(S, [
807
808
  "lineWidth",
808
809
  "color",
809
810
  "opacity",
@@ -820,17 +821,17 @@ class Oe extends zt {
820
821
  "repeat",
821
822
  "resolution"
822
823
  ]);
823
- super($(E({}, w), {
824
+ super($(k({}, w), {
824
825
  uniforms: {
825
826
  lineWidth: { value: e },
826
827
  color: { value: new lt(i) },
827
- opacity: { value: s },
828
+ opacity: { value: n },
828
829
  map: { value: a },
829
830
  useMap: { value: a ? 1 : 0 },
830
831
  resolution: { value: v },
831
832
  sizeAttenuation: { value: c ? 1 : 0 },
832
- offset: { value: f },
833
- offsetLoop: { value: d ? 1 : 0 },
833
+ offset: { value: d },
834
+ offsetLoop: { value: f ? 1 : 0 },
834
835
  dashArray: { value: r },
835
836
  dashOffset: { value: l },
836
837
  dashRatio: { value: o },
@@ -841,8 +842,8 @@ class Oe extends zt {
841
842
  useAlphaMap: { value: u ? 1 : 0 },
842
843
  repeat: { value: p }
843
844
  },
844
- vertexShader: fe,
845
- fragmentShader: de
845
+ vertexShader: de,
846
+ fragmentShader: fe
846
847
  })), this.type = "MeshLineMaterial";
847
848
  }
848
849
  // Getter and setter for color
@@ -893,21 +894,21 @@ class Oe extends zt {
893
894
  this.uniforms.sizeAttenuation.value = t ? 1 : 0;
894
895
  }
895
896
  }
896
- const K = new L(), bt = new I(), yt = new I(), y = new L(), g = new L(), D = new L(), Q = new I(), X = new Ot(), M = new _t(), gt = new I(), W = new St(), U = new Et(), T = new L();
897
+ const K = new E(), yt = new P(), bt = new P(), b = new E(), g = new E(), D = new E(), Q = new P(), X = new Ot(), M = new _t(), gt = new P(), U = new St(), W = new kt(), T = new E();
897
898
  let z, _;
898
- function Mt(n, t, e) {
899
- return T.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = _ / e.width, T.y = _ / e.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
899
+ function Mt(s, t, e) {
900
+ return T.set(0, 0, -t, 1).applyMatrix4(s.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = _ / e.width, T.y = _ / e.height, T.applyMatrix4(s.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
900
901
  }
901
- function he(n, t) {
902
- const e = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
902
+ function he(s, t) {
903
+ const e = s.matrixWorld, i = s.geometry, n = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, n.count);
903
904
  for (let r = 0, o = l; r < o; r++) {
904
- M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(e);
905
- const c = new I(), d = new I();
906
- z.distanceSqToSegment(M.start, M.end, d, c), d.distanceTo(c) < _ * 0.5 && t.push({
907
- point: d,
905
+ M.start.fromBufferAttribute(n, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(e);
906
+ const c = new P(), f = new P();
907
+ z.distanceSqToSegment(M.start, M.end, f, c), f.distanceTo(c) < _ * 0.5 && t.push({
908
+ point: f,
908
909
  pointOnLine: c,
909
- distance: z.origin.distanceTo(d),
910
- object: n,
910
+ distance: z.origin.distanceTo(f),
911
+ object: s,
911
912
  face: null,
912
913
  faceIndex: r,
913
914
  uv: null,
@@ -915,31 +916,31 @@ function he(n, t) {
915
916
  });
916
917
  }
917
918
  }
918
- function pe(n, t, e) {
919
- const i = t.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, o = r.attributes.instanceStart, c = r.attributes.instanceEnd, d = Math.min(r.instanceCount, o.count), f = -t.near;
919
+ function pe(s, t, e) {
920
+ const i = t.projectionMatrix, a = s.material.resolution, l = s.matrixWorld, r = s.geometry, o = r.attributes.instanceStart, c = r.attributes.instanceEnd, f = Math.min(r.instanceCount, o.count), d = -t.near;
920
921
  z.at(1, D), D.w = 1, D.applyMatrix4(t.matrixWorldInverse), D.applyMatrix4(i), D.multiplyScalar(1 / D.w), D.x *= a.x / 2, D.y *= a.y / 2, D.z = 0, Q.copy(D), X.multiplyMatrices(t.matrixWorldInverse, l);
921
- for (let h = 0, u = d; h < u; h++) {
922
- if (y.fromBufferAttribute(o, h), g.fromBufferAttribute(c, h), y.w = 1, g.w = 1, y.applyMatrix4(X), g.applyMatrix4(X), y.z > f && g.z > f)
922
+ for (let h = 0, u = f; h < u; h++) {
923
+ if (b.fromBufferAttribute(o, h), g.fromBufferAttribute(c, h), b.w = 1, g.w = 1, b.applyMatrix4(X), g.applyMatrix4(X), b.z > d && g.z > d)
923
924
  continue;
924
- if (y.z > f) {
925
- const B = y.z - g.z, j = (y.z - f) / B;
926
- y.lerp(g, j);
927
- } else if (g.z > f) {
928
- const B = g.z - y.z, j = (g.z - f) / B;
929
- g.lerp(y, j);
925
+ if (b.z > d) {
926
+ const B = b.z - g.z, j = (b.z - d) / B;
927
+ b.lerp(g, j);
928
+ } else if (g.z > d) {
929
+ const B = g.z - b.z, j = (g.z - d) / B;
930
+ g.lerp(b, j);
930
931
  }
931
- y.applyMatrix4(i), g.applyMatrix4(i), y.multiplyScalar(1 / y.w), g.multiplyScalar(1 / g.w), y.x *= a.x / 2, y.y *= a.y / 2, g.x *= a.x / 2, g.y *= a.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(g), M.end.z = 0;
932
+ b.applyMatrix4(i), g.applyMatrix4(i), b.multiplyScalar(1 / b.w), g.multiplyScalar(1 / g.w), b.x *= a.x / 2, b.y *= a.y / 2, g.x *= a.x / 2, g.y *= a.y / 2, M.start.copy(b), M.start.z = 0, M.end.copy(g), M.end.z = 0;
932
933
  const p = M.closestPointToPointParameter(Q, !0);
933
934
  M.at(p, gt);
934
- const v = kt.lerp(y.z, g.z, p), w = v >= -1 && v <= 1, S = Q.distanceTo(gt) < _ * 0.5;
935
+ const v = Lt.lerp(b.z, g.z, p), w = v >= -1 && v <= 1, S = Q.distanceTo(gt) < _ * 0.5;
935
936
  if (w && S) {
936
937
  M.start.fromBufferAttribute(o, h), M.end.fromBufferAttribute(c, h), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
937
- const B = new I(), j = new I();
938
+ const B = new P(), j = new P();
938
939
  z.distanceSqToSegment(M.start, M.end, j, B), e.push({
939
940
  point: j,
940
941
  pointOnLine: B,
941
942
  distance: z.origin.distanceTo(j),
942
- object: n,
943
+ object: s,
943
944
  face: null,
944
945
  faceIndex: h,
945
946
  uv: null,
@@ -954,11 +955,11 @@ class _e extends wt {
954
955
  }
955
956
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
956
957
  computeLineDistances() {
957
- const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
958
+ const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, n = new Float32Array(2 * e.count);
958
959
  for (let l = 0, r = 0, o = e.count; l < o; l++, r += 2)
959
- bt.fromBufferAttribute(e, l), yt.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + bt.distanceTo(yt);
960
- const a = new Lt(
961
- s,
960
+ yt.fromBufferAttribute(e, l), bt.fromBufferAttribute(i, l), n[r] = r === 0 ? 0 : n[r - 1], n[r + 1] = n[r] + yt.distanceTo(bt);
961
+ const a = new Et(
962
+ n,
962
963
  2,
963
964
  1
964
965
  );
@@ -971,46 +972,46 @@ class _e extends wt {
971
972
  ), this;
972
973
  }
973
974
  raycast(t, e) {
974
- const i = this.material.worldUnits, s = t.camera;
975
- s === null && !i && console.error(
975
+ const i = this.material.worldUnits, n = t.camera;
976
+ n === null && !i && console.error(
976
977
  'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
977
978
  );
978
979
  const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
979
980
  z = t.ray;
980
981
  const l = this.matrixWorld, r = this.geometry, o = this.material;
981
- _ = o.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(l);
982
+ _ = o.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(), W.copy(r.boundingSphere).applyMatrix4(l);
982
983
  let c;
983
984
  if (i)
984
985
  c = _ * 0.5;
985
986
  else {
986
- const f = Math.max(
987
- s.near,
988
- U.distanceToPoint(z.origin)
987
+ const d = Math.max(
988
+ n.near,
989
+ W.distanceToPoint(z.origin)
989
990
  );
990
991
  c = Mt(
991
- s,
992
- f,
992
+ n,
993
+ d,
993
994
  o.resolution
994
995
  );
995
996
  }
996
- if (U.radius += c, z.intersectsSphere(U) === !1)
997
+ if (W.radius += c, z.intersectsSphere(W) === !1)
997
998
  return;
998
- r.boundingBox === null && r.computeBoundingBox(), W.copy(r.boundingBox).applyMatrix4(l);
999
- let d;
999
+ r.boundingBox === null && r.computeBoundingBox(), U.copy(r.boundingBox).applyMatrix4(l);
1000
+ let f;
1000
1001
  if (i)
1001
- d = _ * 0.5;
1002
+ f = _ * 0.5;
1002
1003
  else {
1003
- const f = Math.max(
1004
- s.near,
1005
- W.distanceToPoint(z.origin)
1004
+ const d = Math.max(
1005
+ n.near,
1006
+ U.distanceToPoint(z.origin)
1006
1007
  );
1007
- d = Mt(
1008
- s,
1009
- f,
1008
+ f = Mt(
1009
+ n,
1010
+ d,
1010
1011
  o.resolution
1011
1012
  );
1012
1013
  }
1013
- W.expandByScalar(d), z.intersectsBox(W) !== !1 && (i ? he(this, e) : pe(this, s, e));
1014
+ U.expandByScalar(f), z.intersectsBox(U) !== !1 && (i ? he(this, e) : pe(this, n, e));
1014
1015
  }
1015
1016
  onBeforeRender(t) {
1016
1017
  const e = this.material.uniforms;
@@ -57,6 +57,7 @@ export default class BaseObject extends UseMaterial {
57
57
  setTop(onTop: number): void;
58
58
  traverse(fn: (o: IBaseObject) => void): void;
59
59
  instantiate(ops?: {
60
+ key?: string;
60
61
  uId?: string;
61
62
  target?: IBaseObject;
62
63
  create?: ((...args: any[]) => any) | boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.16.0-beta.30",
3
+ "version": "0.16.0-beta.31",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",