gl-draw 0.16.0-beta.13 → 0.16.0-beta.14
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/dist/WebGPULineSegments2.js +4 -4
- package/dist/WebGPULineSegments2.module.js +106 -104
- package/dist/core/BaseObject/index.d.ts +0 -1
- package/dist/index.js +2 -2
- package/dist/index.module.js +212 -216
- package/package.json +1 -1
|
@@ -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=(
|
|
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=(s,e,t)=>e in s?pe(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,L=(s,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(s,t,e[t]);if(W)for(var t of W(e))ee.call(e,t)&&J(s,t,e[t]);return s},R=(s,e)=>me(s,ve(e));var ie=(s,e)=>{var t={};for(var i in s)H.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&W)for(var i of W(s))e.indexOf(i)<0&&ee.call(s,i)&&(t[i]=s[i]);return t};var re=(s,e,t)=>new Promise((i,r)=>{var a=c=>{try{n(t.next(c))}catch(l){r(l)}},u=c=>{try{n(t.throw(c))}catch(l){r(l)}},n=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,u);n((t=t.apply(s,e)).next())});const o=require("three"),be=require("three/examples/jsm/renderers/CSS2DRenderer"),se=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),z=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"),ne=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=(s,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=s.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
|
-
${
|
|
4
|
-
`},new a.Points(t,r)},Pe=(n,e)=>{const t=new a.Object3D;e.forEach((i,r)=>{const o=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof a.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof a.Points||n.type==="Points"){const l=n.geometry,f=l.attributes.position.array,h=l.attributes.scaleAtt.array,p=new a.Vector3,d=new a.Vector3,v=new a.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 De{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 Ie extends De{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 o=i.clone();return i.userData=r,o});{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 Ie{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get key(){return this._key}set key(e){this.lead&&this.lead.updateBaseObjectKey(this,e)}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 a.Group,this}createMesh(...e){return this.object3d=new a.Mesh(...e),this}createPoints(...e){return this.object3d=new a.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 a.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new a.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new a.Vector3),center:e.getCenter(new a.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:o}=this;let u=e==null?void 0:e.create;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 a.Sprite)f.object3d=Be(this.object3d,p);else{const d=this.object3d,v=i?this.cloneMaterial():d.material;f.object3d=new a.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}});const s=yield this.lead.draw(r,R(E({},o||{}),{create:u,prefab:!1,key:(e==null?void 0:e.key)||(o==null?void 0:o.key),target:(e==null?void 0:e.target)||(o==null?void 0:o.target)}));return this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(f=>f.instantiate({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 Ve(n,e){return n.map(t=>{const i=[];let r;return t.forEach(o=>{if(r){const u=O.geoDistance(o,r)*180/Math.PI;if(u>e){const s=O.geoInterpolate(r,o),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=o)}),i})}function Te(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const o=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/o-1)/Math.PI*180-90,l=d=>o*(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)):o-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?O.geoContains(e,n):Me(n,e)}function _e(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[o,u]]=O.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(u-r))<e)return[];const s=i>o||u>=89||r<=-89;return Te(e,{minLng:i,maxLng:o,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Ve(n,e),o=L.merge(r),u=_e(n,e),s=[...o,...u],c={type:"Polygon",coordinates:n},[[l,f],[h,p]]=O.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],_)=>[`${C}-${B}`,_]));b.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),_=[];if(B.forEach(([P,q])=>{const k=`${P}-${q}`;S.has(k)&&_.push(S.get(k))}),_.length===3){if(_.some(P=>P<o.length)){const P=C.properties.circumcenter;if(!Z(P,c,d))return}v.push(..._)}})}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(P=>b.triangles[S+P]),_=B.map(P=>s[P]);if(B.some(P=>P<o.length)){const P=[0,1].map(q=>L.mean(_,k=>k[q]));if(!Z(P,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]),D=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:D}}}const oe=new a.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(o=>o.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:o,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,o]),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,o){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,o).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:o=!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;o&&(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 Ee extends a.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=E({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:o,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:f}=this.parameters,{contour:h,sideTorso:p,topVerts:d,bottomCap:v,topCap:m}=he(E({},this.parameters));let y=[],w=[],j=[],D=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,D++)};r&&o&&A(m),s&&(A(p),this.userData.topVerts=l?G(h,i+l,c,f).vertices:d),u&&A(v),r&&!o&&A(m),this.setIndex(j),this[oe]("position",new a.Float32BufferAttribute(y,3)),this[oe]("uv",new a.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Oe=`
|
|
3
|
+
${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
+
`},new o.Points(t,r)},Pe=(s,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 n=t.matrix.clone();if(s instanceof o.InstancedMesh||s.isInstantiate)s.setMatrixAt(r,n);else if(s instanceof o.Points||s.type==="Points"){const l=s.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;n.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 De{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 Ie extends De{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 Ie{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get key(){return this._key}set key(e){this.lead&&this.lead.updateBaseObjectKey(this,e)}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 se.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new se.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,n;return this.objectType==="BaseObject"?n=this.lead.createBaseObject(this.object3d.clone(!1),{target:this.parent===this.lead.prefabGroup?this.lead.group: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}}),n=yield this.lead.draw(r,R(L({},a||{}),{create:u,key:(e==null?void 0:e.key)||(a==null?void 0:a.key),target:this.parent===this.lead.prefabGroup?this.lead.group:this.parent}))),this.isBloom&&n.enableBloom(),t&&(yield Promise.all(this.children.map(f=>f.instantiate({cloneMaterial:i})))),n.isInstantiate=!0,n})}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 Ve(s,e){return s.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 n=E.geoInterpolate(r,a),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(n(l)),l+=c}}i.push(r=a)}),i})}function Te(s,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const a=Math.round(te(360/s,2)/Math.PI),u=(1+Math.sqrt(5))/2,n=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=n(d);h(v)&&p.push([v,c(d)])}return p}function Z(s,e,t=!1){return t?E.geoContains(e,s):Me(s,e)}function Oe(s,e){const t={type:"Polygon",coordinates:s},[[i,r],[a,u]]=E.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(u-r))<e)return[];const n=i>a||u>=89||r<=-89;return Te(e,{minLng:i,maxLng:a,minLat:r,maxLat:u}).filter(c=>Z(c,t,n))}function _e(s,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Ve(s,e),a=z.merge(r),u=Oe(s,e),n=[...a,...u],c={type:"Polygon",coordinates:s},[[l,f],[h,p]]=E.geoBounds(c),d=l>h||p>=89||f<=-89;let v=[];if(d){const y=xe.geoVoronoi(n).triangles(),S=new Map(n.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(n);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=>n[P]);if(B.some(P=>P<a.length)){const P=[0,1].map(q=>z.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]]:z.extent(n,y=>y[0]),b=t?[t[1],t[3]]:z.extent(n,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=ne.scaleLinear(m,[0,1]),j=ne.scaleLinear(b,[0,1]),D=n.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:n,indices:v,uvs:D}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(s,e,t,i){const r=s.map(a=>a.map(([u,n])=>{if(i){const[c,l]=i([u,n]);return[c,-l,e]}return t?Q.polar2Cartesian(u,n,e):[u,n,e]}));return X.flatten(r)}function ze(s,e,t,i,r){const{vertices:a,holes:u}=G(s,e,i,r),{vertices:n}=G(s,t,i,r),c=z.merge([n,a]),l=Math.round(n.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:n}}function ae(s,e,t,i,r,a){return{indices:i?s.indices:s.indices.slice().reverse(),vertices:G([s.points],e,r,a).vertices,uvs:t}}const he=({polygonGeoJson:s,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:a=!0,hasBottom:u=!1,hasTop:n=!1,projection:c,bbox:l})=>{s.forEach(w=>{ye(w)||w.reverse()});const{contour:f,triangles:h}=_e(s,{resolution:i,bbox:l,projection:c});let p={},d;a&&(p=ze(f,e!=null?e:t,t!=null?t:e,r,c),d=p.topVerts);let v=[];(u||n)&&(v=z.merge(h.uvs));let m={};u&&(m=ae(h,e,v,!1,r,c));let b={};return n&&(b=ae(h,t,v,!0,r,c)),{contour:f,triangles:h,sideTorso:p,bottomCap:m,topCap:b,topVerts:d}};class Le extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=L({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:n,cartesian:c,userDataRsoOffset:l,projection:f}=this.parameters,{contour:h,sideTorso:p,topVerts:d,bottomCap:v,topCap:m}=he(L({},this.parameters));let b=[],w=[],j=[],D=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,D++)};r&&a&&A(m),n&&(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=`
|
|
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
|
|
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:n=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(L({},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:n},dashOffset:{value:u},dashRatio:{value:c},useDash:{value:n>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,I=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,V=new o.Vector4;let T,_;function de(s,e,t){return V.set(0,0,-e,1).applyMatrix4(s.projectionMatrix),V.multiplyScalar(1/V.w),V.x=_/t.width,V.y=_/t.height,V.applyMatrix4(s.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ne(s,e){const t=s.matrixWorld,i=s.geometry,r=i.attributes.instanceStart,a=i.attributes.instanceEnd,u=Math.min(i.instanceCount,r.count);for(let n=0,c=u;n<c;n++){x.start.fromBufferAttribute(r,n),x.end.fromBufferAttribute(a,n),x.applyMatrix4(t);const l=new o.Vector3,f=new o.Vector3;T.distanceSqToSegment(x.start,x.end,f,l),f.distanceTo(l)<_*.5&&e.push({point:f,pointOnLine:l,distance:T.origin.distanceTo(f),object:s,face:null,faceIndex:n,uv:null,uv1:null})}}function Ue(s,e,t){const i=e.projectionMatrix,a=s.material.resolution,u=s.matrixWorld,n=s.geometry,c=n.attributes.instanceStart,l=n.attributes.instanceEnd,f=Math.min(n.instanceCount,c.count),h=-e.near;T.at(1,I),I.w=1,I.applyMatrix4(e.matrixWorldInverse),I.applyMatrix4(i),I.multiplyScalar(1/I.w),I.x*=a.x/2,I.y*=a.y/2,I.z=0,$.copy(I),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 D=g.z-M.z,A=(g.z-h)/D;g.lerp(M,A)}else if(M.z>h){const D=M.z-g.z,A=(M.z-h)/D;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)<_*.5;if(w&&j){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(l,p),x.start.applyMatrix4(u),x.end.applyMatrix4(u);const D=new o.Vector3,A=new o.Vector3;T.distanceSqToSegment(x.start,x.end,A,D),t.push({point:A,pointOnLine:D,distance:T.origin.distanceTo(A),object:s,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,n=0,c=t.count;u<c;u++,n+=2)ce.fromBufferAttribute(t,u),le.fromBufferAttribute(i,u),r[n]=n===0?0:r[n-1],r[n+1]=r[n]+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;T=e.ray;const u=this.matrixWorld,n=this.geometry,c=this.material;_=c.linewidth+a,n.boundingSphere===null&&n.computeBoundingSphere(),U.copy(n.boundingSphere).applyMatrix4(u);let l;if(i)l=_*.5;else{const h=Math.max(r.near,U.distanceToPoint(T.origin));l=de(r,h,c.resolution)}if(U.radius+=l,T.intersectsSphere(U)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),N.copy(n.boundingBox).applyMatrix4(u);let f;if(i)f=_*.5;else{const h=Math.max(r.near,N.distanceToPoint(T.origin));f=de(r,h,c.resolution)}N.expandByScalar(f),T.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=Le;exports.ResourceTracker=fe;exports.getMetas=he;
|
|
@@ -2,7 +2,7 @@ var Ct = Object.defineProperty, Pt = Object.defineProperties;
|
|
|
2
2
|
var Bt = 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,
|
|
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) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
7
|
et.call(t, e) && tt(n, e, t[e]);
|
|
8
8
|
if (V)
|
|
@@ -35,13 +35,13 @@ var rt = (n, t, e) => new Promise((i, s) => {
|
|
|
35
35
|
}, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, l);
|
|
36
36
|
r((e = e.apply(n, t)).next());
|
|
37
37
|
});
|
|
38
|
-
import { Material as at, Object3D as N, Texture as ot, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as It, Points as J, InstancedMesh as xt, Vector3 as B, 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
|
|
38
|
+
import { Material as at, Object3D as N, Texture as ot, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as It, Points as J, InstancedMesh as xt, Vector3 as B, 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 _t, Line3 as Ot, Sphere as Et, InstancedInterleavedBuffer as Lt, InterleavedBufferAttribute as ut, MathUtils as kt } from "three";
|
|
39
39
|
import { CSS2DObject as Vt } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
40
40
|
import { CSS3DObject as Wt, CSS3DSprite as Ut } 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
|
|
44
|
-
import { merge as H, mean as $t, extent as
|
|
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";
|
|
45
45
|
import qt, { flatten as At } from "earcut";
|
|
46
46
|
import Kt from "@turf/boolean-clockwise";
|
|
47
47
|
import Qt from "delaunator";
|
|
@@ -125,14 +125,14 @@ const ee = (n, t = 1) => {
|
|
|
125
125
|
}, ie = (n, t) => {
|
|
126
126
|
const e = new N();
|
|
127
127
|
t.forEach((i, s) => {
|
|
128
|
-
const a =
|
|
128
|
+
const a = dt(i.position), l = dt(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
131
|
if (n instanceof xt || n.isInstantiate)
|
|
132
132
|
n.setMatrixAt(s, r);
|
|
133
133
|
else if (n instanceof J || n.type === "Points") {
|
|
134
|
-
const c = n.geometry,
|
|
135
|
-
r.decompose(h, m, u),
|
|
134
|
+
const c = n.geometry, d = c.attributes.position.array, f = c.attributes.scaleAtt.array, h = new B(), u = new B(), 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;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
};
|
|
@@ -342,35 +342,37 @@ class pt extends ne {
|
|
|
342
342
|
return rt(this, null, function* () {
|
|
343
343
|
var o, c;
|
|
344
344
|
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;
|
|
345
|
-
let l = t == null ? void 0 : t.create;
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
let l = t == null ? void 0 : t.create, r;
|
|
346
|
+
return this.objectType === "BaseObject" ? r = this.lead.createBaseObject(this.object3d.clone(!1), {
|
|
347
|
+
target: this.parent === this.lead.prefabGroup ? this.lead.group : this.parent
|
|
348
|
+
}) : (l === void 0 && (l = (d) => {
|
|
349
|
+
var f;
|
|
348
350
|
if (this.object3d) {
|
|
349
|
-
if ((
|
|
351
|
+
if ((f = t == null ? void 0 : t.instancedAttr) != null && f.length) {
|
|
350
352
|
const h = t.instancedAttr.length;
|
|
351
353
|
if (this.object3d instanceof ct)
|
|
352
|
-
|
|
354
|
+
d.object3d = ee(this.object3d, h);
|
|
353
355
|
else {
|
|
354
356
|
const u = this.object3d, m = i ? this.cloneMaterial() : u.material;
|
|
355
|
-
|
|
357
|
+
d.object3d = new xt(
|
|
358
|
+
u.geometry,
|
|
359
|
+
m,
|
|
360
|
+
h
|
|
361
|
+
);
|
|
356
362
|
}
|
|
357
|
-
ie(
|
|
363
|
+
ie(d.object3d, t == null ? void 0 : t.instancedAttr);
|
|
358
364
|
} else
|
|
359
|
-
|
|
360
|
-
|
|
365
|
+
d.object3d = this.object3d.clone(!1), i && d.object3d.material && (d.object3d.material = this.cloneMaterial());
|
|
366
|
+
d.object3d.userData.prefab && delete d.object3d.userData.prefab;
|
|
361
367
|
}
|
|
362
|
-
})
|
|
363
|
-
const r = yield this.lead.draw(s, $(L({}, a || {}), {
|
|
368
|
+
}), r = yield this.lead.draw(s, $(E({}, a || {}), {
|
|
364
369
|
create: l,
|
|
365
|
-
prefab: !1,
|
|
366
370
|
key: (t == null ? void 0 : t.key) || (a == null ? void 0 : a.key),
|
|
367
|
-
target:
|
|
368
|
-
}))
|
|
369
|
-
return this.isBloom && r.enableBloom(), e && (yield Promise.all(
|
|
371
|
+
target: this.parent === this.lead.prefabGroup ? this.lead.group : this.parent
|
|
372
|
+
}))), this.isBloom && r.enableBloom(), e && (yield Promise.all(
|
|
370
373
|
this.children.map(
|
|
371
|
-
(
|
|
372
|
-
cloneMaterial: i
|
|
373
|
-
target: r
|
|
374
|
+
(d) => d.instantiate({
|
|
375
|
+
cloneMaterial: i
|
|
374
376
|
})
|
|
375
377
|
)
|
|
376
378
|
)), r.isInstantiate = !0, r;
|
|
@@ -416,13 +418,13 @@ function re(n, t) {
|
|
|
416
418
|
});
|
|
417
419
|
}
|
|
418
420
|
function ae(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
419
|
-
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,
|
|
421
|
+
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 = [
|
|
420
422
|
s !== void 0 ? Math.ceil(c(s)) : 0,
|
|
421
423
|
i !== void 0 ? Math.floor(c(i)) : a - 1
|
|
422
|
-
],
|
|
423
|
-
for (let u =
|
|
424
|
+
], 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 = [];
|
|
425
|
+
for (let u = d[0]; u <= d[1]; u++) {
|
|
424
426
|
const m = r(u);
|
|
425
|
-
|
|
427
|
+
f(m) && h.push([m, o(u)]);
|
|
426
428
|
}
|
|
427
429
|
return h;
|
|
428
430
|
}
|
|
@@ -444,15 +446,15 @@ function oe(n, t) {
|
|
|
444
446
|
);
|
|
445
447
|
}
|
|
446
448
|
function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
447
|
-
const s = re(n, t), a = H(s), l = oe(n, t), r = [...a, ...l], o = { type: "Polygon", coordinates: n }, [[c,
|
|
449
|
+
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
450
|
h >= 89 || // crosses north pole
|
|
449
|
-
|
|
451
|
+
d <= -89;
|
|
450
452
|
let m = [];
|
|
451
453
|
if (u) {
|
|
452
|
-
const
|
|
454
|
+
const b = Yt(r).triangles(), x = new Map(
|
|
453
455
|
r.map(([A, C], _) => [`${A}-${C}`, _])
|
|
454
456
|
);
|
|
455
|
-
|
|
457
|
+
b.features.forEach((A) => {
|
|
456
458
|
const C = A.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
|
|
457
459
|
if (C.forEach(([P, F]) => {
|
|
458
460
|
const k = `${P}-${F}`;
|
|
@@ -471,9 +473,9 @@ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
471
473
|
}
|
|
472
474
|
});
|
|
473
475
|
} else if (l.length) {
|
|
474
|
-
const
|
|
475
|
-
for (let x = 0, A =
|
|
476
|
-
const C = [2, 1, 0].map((P) =>
|
|
476
|
+
const b = Qt.from(r);
|
|
477
|
+
for (let x = 0, A = b.triangles.length; x < A; x += 3) {
|
|
478
|
+
const C = [2, 1, 0].map((P) => b.triangles[x + P]), _ = C.map((P) => r[P]);
|
|
477
479
|
if (C.some((P) => P < a.length)) {
|
|
478
480
|
const P = [0, 1].map(
|
|
479
481
|
(F) => $t(_, (k) => k[F])
|
|
@@ -488,20 +490,20 @@ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
488
490
|
m.push(...C);
|
|
489
491
|
}
|
|
490
492
|
} else {
|
|
491
|
-
const { vertices:
|
|
492
|
-
m = qt(
|
|
493
|
+
const { vertices: b, holes: x = [] } = At(s);
|
|
494
|
+
m = qt(b, x, 2);
|
|
493
495
|
}
|
|
494
|
-
let p = e ? [e[0], e[2]] :
|
|
496
|
+
let p = e ? [e[0], e[2]] : ft(r, (b) => b[0]), v = e ? [e[1], e[3]] : ft(r, (b) => b[1]);
|
|
495
497
|
if (i) {
|
|
496
|
-
const [
|
|
497
|
-
p = [
|
|
498
|
+
const [b, x] = i([p[0], v[0]]), [A, C] = i([p[1], v[1]]);
|
|
499
|
+
p = [b, A], v = [-x, -C];
|
|
498
500
|
}
|
|
499
|
-
const w = ht(p, [0, 1]), S = ht(v, [0, 1]), I = r.map(([
|
|
501
|
+
const w = ht(p, [0, 1]), S = ht(v, [0, 1]), I = r.map(([b, x]) => {
|
|
500
502
|
if (i) {
|
|
501
|
-
const [A, C] = i([
|
|
503
|
+
const [A, C] = i([b, x]);
|
|
502
504
|
return [w(A), S(-C)];
|
|
503
505
|
} else
|
|
504
|
-
return [w(
|
|
506
|
+
return [w(b), S(x)];
|
|
505
507
|
});
|
|
506
508
|
return { contour: s, triangles: { points: r, indices: m, uvs: I } };
|
|
507
509
|
}
|
|
@@ -529,16 +531,16 @@ function le(n, t, e, i, s) {
|
|
|
529
531
|
e,
|
|
530
532
|
i,
|
|
531
533
|
s
|
|
532
|
-
), o = H([r, a]), c = Math.round(r.length / 3),
|
|
533
|
-
let
|
|
534
|
+
), o = H([r, a]), c = Math.round(r.length / 3), d = new Set(l);
|
|
535
|
+
let f = 0;
|
|
534
536
|
const h = [];
|
|
535
537
|
for (let m = 0; m < c; m++) {
|
|
536
538
|
let p = m + 1;
|
|
537
539
|
if (p === c)
|
|
538
|
-
p =
|
|
539
|
-
else if (
|
|
540
|
+
p = f;
|
|
541
|
+
else if (d.has(p)) {
|
|
540
542
|
const v = p;
|
|
541
|
-
p =
|
|
543
|
+
p = f, f = v;
|
|
542
544
|
}
|
|
543
545
|
h.push(m, m + c, p + c), h.push(p + c, p, m);
|
|
544
546
|
}
|
|
@@ -574,24 +576,24 @@ const ue = ({
|
|
|
574
576
|
n.forEach((w) => {
|
|
575
577
|
Kt(w) || w.reverse();
|
|
576
578
|
});
|
|
577
|
-
const { contour:
|
|
579
|
+
const { contour: d, triangles: f } = ce(n, {
|
|
578
580
|
resolution: i,
|
|
579
581
|
bbox: c,
|
|
580
582
|
projection: o
|
|
581
583
|
});
|
|
582
584
|
let h = {}, u;
|
|
583
585
|
a && (h = le(
|
|
584
|
-
|
|
586
|
+
d,
|
|
585
587
|
t != null ? t : e,
|
|
586
588
|
e != null ? e : t,
|
|
587
589
|
s,
|
|
588
590
|
o
|
|
589
591
|
), u = h.topVerts);
|
|
590
592
|
let m = [];
|
|
591
|
-
(l || r) && (m = H(
|
|
593
|
+
(l || r) && (m = H(f.uvs));
|
|
592
594
|
let p = {};
|
|
593
595
|
l && (p = vt(
|
|
594
|
-
|
|
596
|
+
f,
|
|
595
597
|
t,
|
|
596
598
|
m,
|
|
597
599
|
!1,
|
|
@@ -600,17 +602,17 @@ const ue = ({
|
|
|
600
602
|
));
|
|
601
603
|
let v = {};
|
|
602
604
|
return r && (v = vt(
|
|
603
|
-
|
|
605
|
+
f,
|
|
604
606
|
e,
|
|
605
607
|
m,
|
|
606
608
|
!0,
|
|
607
609
|
s,
|
|
608
610
|
o
|
|
609
|
-
)), { contour:
|
|
611
|
+
)), { contour: d, triangles: f, sideTorso: h, bottomCap: p, topCap: v, topVerts: u };
|
|
610
612
|
};
|
|
611
613
|
class ze extends Z {
|
|
612
614
|
constructor(t, e = {}) {
|
|
613
|
-
super(), this.type = "PolygonBufferGeometry", this.parameters =
|
|
615
|
+
super(), this.type = "PolygonBufferGeometry", this.parameters = E({
|
|
614
616
|
polygonGeoJson: t,
|
|
615
617
|
startHeight: 0,
|
|
616
618
|
endHeight: 1,
|
|
@@ -630,24 +632,24 @@ class ze extends Z {
|
|
|
630
632
|
hasSide: r,
|
|
631
633
|
cartesian: o,
|
|
632
634
|
userDataRsoOffset: c,
|
|
633
|
-
projection:
|
|
634
|
-
} = this.parameters, { contour:
|
|
635
|
+
projection: d
|
|
636
|
+
} = this.parameters, { contour: f, sideTorso: h, topVerts: u, bottomCap: m, topCap: p } = ue(E({}, this.parameters));
|
|
635
637
|
let v = [], w = [], S = [], I = 0;
|
|
636
|
-
const j = (
|
|
638
|
+
const j = (b) => {
|
|
637
639
|
const x = Math.round(v.length / 3), A = S.length;
|
|
638
|
-
v = v.concat(
|
|
639
|
-
x ?
|
|
640
|
+
v = v.concat(b.vertices), w = w.concat(b.uvs), S = S.concat(
|
|
641
|
+
x ? b.indices.map((C) => C + x) : b.indices
|
|
640
642
|
), this.addGroup(A, S.length - A, I++);
|
|
641
643
|
};
|
|
642
644
|
s && a && j(p), r && (j(h), this.userData.topVerts = c ? G(
|
|
643
|
-
|
|
645
|
+
f,
|
|
644
646
|
i + c,
|
|
645
647
|
o,
|
|
646
|
-
|
|
648
|
+
d
|
|
647
649
|
).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
650
|
}
|
|
649
651
|
}
|
|
650
|
-
const
|
|
652
|
+
const de = `
|
|
651
653
|
#include <fog_pars_fragment>
|
|
652
654
|
#include <logdepthbuf_pars_fragment>
|
|
653
655
|
|
|
@@ -691,7 +693,7 @@ void main() {
|
|
|
691
693
|
#include <tonemapping_fragment>
|
|
692
694
|
#include <colorspace_fragment>
|
|
693
695
|
}
|
|
694
|
-
`,
|
|
696
|
+
`, fe = `
|
|
695
697
|
#include <common>
|
|
696
698
|
#include <logdepthbuf_pars_vertex>
|
|
697
699
|
#include <fog_pars_vertex>
|
|
@@ -795,8 +797,8 @@ class _e extends zt {
|
|
|
795
797
|
dashArray: r = 0,
|
|
796
798
|
dashRatio: o = 0,
|
|
797
799
|
sizeAttenuation: c = !0,
|
|
798
|
-
offsetLoop:
|
|
799
|
-
offset:
|
|
800
|
+
offsetLoop: d = !0,
|
|
801
|
+
offset: f = new q(0, 0),
|
|
800
802
|
scaleDown: h = 0,
|
|
801
803
|
alphaMap: u = void 0,
|
|
802
804
|
alphaTest: m = 0,
|
|
@@ -819,7 +821,7 @@ class _e extends zt {
|
|
|
819
821
|
"repeat",
|
|
820
822
|
"resolution"
|
|
821
823
|
]);
|
|
822
|
-
super($(
|
|
824
|
+
super($(E({}, w), {
|
|
823
825
|
uniforms: {
|
|
824
826
|
lineWidth: { value: e },
|
|
825
827
|
color: { value: new lt(i) },
|
|
@@ -828,8 +830,8 @@ class _e extends zt {
|
|
|
828
830
|
useMap: { value: a ? 1 : 0 },
|
|
829
831
|
resolution: { value: v },
|
|
830
832
|
sizeAttenuation: { value: c ? 1 : 0 },
|
|
831
|
-
offset: { value:
|
|
832
|
-
offsetLoop: { value:
|
|
833
|
+
offset: { value: f },
|
|
834
|
+
offsetLoop: { value: d ? 1 : 0 },
|
|
833
835
|
dashArray: { value: r },
|
|
834
836
|
dashOffset: { value: l },
|
|
835
837
|
dashRatio: { value: o },
|
|
@@ -840,8 +842,8 @@ class _e extends zt {
|
|
|
840
842
|
useAlphaMap: { value: u ? 1 : 0 },
|
|
841
843
|
repeat: { value: p }
|
|
842
844
|
},
|
|
843
|
-
vertexShader:
|
|
844
|
-
fragmentShader:
|
|
845
|
+
vertexShader: fe,
|
|
846
|
+
fragmentShader: de
|
|
845
847
|
})), this.type = "MeshLineMaterial";
|
|
846
848
|
}
|
|
847
849
|
// Getter and setter for color
|
|
@@ -892,20 +894,20 @@ class _e extends zt {
|
|
|
892
894
|
this.uniforms.sizeAttenuation.value = t ? 1 : 0;
|
|
893
895
|
}
|
|
894
896
|
}
|
|
895
|
-
const K = new
|
|
896
|
-
let z,
|
|
897
|
+
const K = new L(), bt = new B(), yt = new B(), y = new L(), g = new L(), D = new L(), Q = new B(), X = new _t(), M = new Ot(), gt = new B(), W = new St(), U = new Et(), T = new L();
|
|
898
|
+
let z, O;
|
|
897
899
|
function Mt(n, t, e) {
|
|
898
|
-
return T.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x =
|
|
900
|
+
return T.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = O / e.width, T.y = O / e.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
|
|
899
901
|
}
|
|
900
902
|
function he(n, t) {
|
|
901
903
|
const e = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
|
|
902
904
|
for (let r = 0, o = l; r < o; r++) {
|
|
903
905
|
M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(e);
|
|
904
|
-
const c = new B(),
|
|
905
|
-
z.distanceSqToSegment(M.start, M.end,
|
|
906
|
-
point:
|
|
906
|
+
const c = new B(), d = new B();
|
|
907
|
+
z.distanceSqToSegment(M.start, M.end, d, c), d.distanceTo(c) < O * 0.5 && t.push({
|
|
908
|
+
point: d,
|
|
907
909
|
pointOnLine: c,
|
|
908
|
-
distance: z.origin.distanceTo(
|
|
910
|
+
distance: z.origin.distanceTo(d),
|
|
909
911
|
object: n,
|
|
910
912
|
face: null,
|
|
911
913
|
faceIndex: r,
|
|
@@ -915,22 +917,22 @@ function he(n, t) {
|
|
|
915
917
|
}
|
|
916
918
|
}
|
|
917
919
|
function pe(n, t, e) {
|
|
918
|
-
const i = t.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, o = r.attributes.instanceStart, c = r.attributes.instanceEnd,
|
|
920
|
+
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
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);
|
|
920
|
-
for (let h = 0, u =
|
|
921
|
-
if (
|
|
922
|
+
for (let h = 0, u = d; h < u; h++) {
|
|
923
|
+
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
924
|
continue;
|
|
923
|
-
if (
|
|
924
|
-
const I =
|
|
925
|
-
|
|
926
|
-
} else if (g.z >
|
|
927
|
-
const I = g.z -
|
|
928
|
-
g.lerp(
|
|
925
|
+
if (y.z > f) {
|
|
926
|
+
const I = y.z - g.z, j = (y.z - f) / I;
|
|
927
|
+
y.lerp(g, j);
|
|
928
|
+
} else if (g.z > f) {
|
|
929
|
+
const I = g.z - y.z, j = (g.z - f) / I;
|
|
930
|
+
g.lerp(y, j);
|
|
929
931
|
}
|
|
930
|
-
|
|
932
|
+
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;
|
|
931
933
|
const p = M.closestPointToPointParameter(Q, !0);
|
|
932
934
|
M.at(p, gt);
|
|
933
|
-
const v = kt.lerp(
|
|
935
|
+
const v = kt.lerp(y.z, g.z, p), w = v >= -1 && v <= 1, S = Q.distanceTo(gt) < O * 0.5;
|
|
934
936
|
if (w && S) {
|
|
935
937
|
M.start.fromBufferAttribute(o, h), M.end.fromBufferAttribute(c, h), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
|
|
936
938
|
const I = new B(), j = new B();
|
|
@@ -947,7 +949,7 @@ function pe(n, t, e) {
|
|
|
947
949
|
}
|
|
948
950
|
}
|
|
949
951
|
}
|
|
950
|
-
class
|
|
952
|
+
class Oe extends wt {
|
|
951
953
|
constructor(t = new Zt(), e) {
|
|
952
954
|
super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
|
|
953
955
|
}
|
|
@@ -955,8 +957,8 @@ class Ee extends wt {
|
|
|
955
957
|
computeLineDistances() {
|
|
956
958
|
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
|
|
957
959
|
for (let l = 0, r = 0, o = e.count; l < o; l++, r += 2)
|
|
958
|
-
|
|
959
|
-
const a = new
|
|
960
|
+
bt.fromBufferAttribute(e, l), yt.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + bt.distanceTo(yt);
|
|
961
|
+
const a = new Lt(
|
|
960
962
|
s,
|
|
961
963
|
2,
|
|
962
964
|
1
|
|
@@ -977,39 +979,39 @@ class Ee extends wt {
|
|
|
977
979
|
const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
|
|
978
980
|
z = t.ray;
|
|
979
981
|
const l = this.matrixWorld, r = this.geometry, o = this.material;
|
|
980
|
-
|
|
982
|
+
O = o.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(l);
|
|
981
983
|
let c;
|
|
982
984
|
if (i)
|
|
983
|
-
c =
|
|
985
|
+
c = O * 0.5;
|
|
984
986
|
else {
|
|
985
|
-
const
|
|
987
|
+
const f = Math.max(
|
|
986
988
|
s.near,
|
|
987
989
|
U.distanceToPoint(z.origin)
|
|
988
990
|
);
|
|
989
991
|
c = Mt(
|
|
990
992
|
s,
|
|
991
|
-
|
|
993
|
+
f,
|
|
992
994
|
o.resolution
|
|
993
995
|
);
|
|
994
996
|
}
|
|
995
997
|
if (U.radius += c, z.intersectsSphere(U) === !1)
|
|
996
998
|
return;
|
|
997
999
|
r.boundingBox === null && r.computeBoundingBox(), W.copy(r.boundingBox).applyMatrix4(l);
|
|
998
|
-
let
|
|
1000
|
+
let d;
|
|
999
1001
|
if (i)
|
|
1000
|
-
|
|
1002
|
+
d = O * 0.5;
|
|
1001
1003
|
else {
|
|
1002
|
-
const
|
|
1004
|
+
const f = Math.max(
|
|
1003
1005
|
s.near,
|
|
1004
1006
|
W.distanceToPoint(z.origin)
|
|
1005
1007
|
);
|
|
1006
|
-
|
|
1008
|
+
d = Mt(
|
|
1007
1009
|
s,
|
|
1008
|
-
|
|
1010
|
+
f,
|
|
1009
1011
|
o.resolution
|
|
1010
1012
|
);
|
|
1011
1013
|
}
|
|
1012
|
-
W.expandByScalar(
|
|
1014
|
+
W.expandByScalar(d), z.intersectsBox(W) !== !1 && (i ? he(this, e) : pe(this, s, e));
|
|
1013
1015
|
}
|
|
1014
1016
|
onBeforeRender(t) {
|
|
1015
1017
|
const e = this.material.uniforms;
|
|
@@ -1019,7 +1021,7 @@ class Ee extends wt {
|
|
|
1019
1021
|
export {
|
|
1020
1022
|
De as B,
|
|
1021
1023
|
Te as I,
|
|
1022
|
-
|
|
1024
|
+
Oe as L,
|
|
1023
1025
|
_e as M,
|
|
1024
1026
|
ze as P,
|
|
1025
1027
|
te as R,
|