gl-draw 0.16.0-beta.5 → 0.16.0-beta.7
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,E=(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
|
|
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,E=(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 o=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(o,u);s((t=t.apply(n,e)).next())});const a=require("three"),be=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),O=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),_=require("d3-array"),X=require("earcut"),ge=require("@turf/boolean-clockwise"),ye=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 a.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 a.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 a.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof a.Material){for(const i of Object.values(e))i instanceof a.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 a.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 a.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 Pe=(n,e=1)=>{const t=new a.BufferGeometry;t.setAttribute("position",new a.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new a.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,r=new a.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=o=>{o.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
3
|
${o.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
-
`},new a.Points(t,i)},Be=(n,e)=>{const t=new a.Object3D;e.forEach((r,i)=>{const o=Q.parseVector3(r.position),u=Q.parseVector3(r.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(i,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=i*3,b=i*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 De{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const r=this.lead.handlePick([this],e,t);this.onPointerIndex.push(r)}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(r=>{const i=r.userData;r.userData={};const o=r.clone();return r.userData=i,o});{const r=t.userData;t.userData={};const i=t.clone();return t.userData=r,i}}setMaterialList(e,t){const r=this.object3d;if(!r||!r.material)return;this.materialList.origin||(this.materialList.origin=r.material);const i=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=i,i}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 r=this.mList.get(e);if(!r)return;const i=this.object3d;Array.isArray(i.material)&&t!==void 0?i.material[t]=r:i.material=r}useMListByName(e,t){if(!this.mList)return;const r=this.mList.getKeyByName(e);r&&this.useMListById(r,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 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 r;this.lead.objMap.get(t)?(r=this.lead.objMap.get(t))==null||r.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}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 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 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 ie(this,null,function*(){var c,l;const t=(c=e==null?void 0:e.recursive)!=null?c:!0,r=(l=e==null?void 0:e.cloneMaterial)!=null?l:!1,{objectType:i,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=Pe(this.object3d,p);else{const d=this.object3d,v=r?this.cloneMaterial():d.material;f.object3d=new a.InstancedMesh(d.geometry,v,p)}Be(f.object3d,e==null?void 0:e.instancedAttr)}else f.object3d=this.object3d.clone(!1),r&&f.object3d.material&&(f.object3d.material=this.cloneMaterial());f.object3d.userData.prefab&&delete f.object3d.userData.prefab}});const s=yield this.lead.draw(i,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:r,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 r=[];let i;return t.forEach(o=>{if(i){const u=O.geoDistance(o,i)*180/Math.PI;if(u>e){const s=O.geoInterpolate(i,o),c=1/Math.ceil(u/e);let l=c;for(;l<1;)r.push(s(l)),l+=c}}r.push(i=o)}),r})}function Te(n,{minLng:e,maxLng:t,minLat:r,maxLat:i}={}){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=[i!==void 0?Math.ceil(l(i)):0,r!==void 0?Math.floor(l(r)):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 ze(n,e){const t={type:"Polygon",coordinates:n},[[r,i],[o,u]]=O.geoBounds(t);if(Math.min(Math.abs(o-r),Math.abs(u-i))<e)return[];const s=r>o||u>=89||i<=-89;return Te(e,{minLng:r,maxLng:o,minLat:i,maxLat:u}).filter(c=>Z(c,t,s))}function Le(n,{resolution:e=1/0,bbox:t,projection:r}={}){const i=Ve(n,e),o=_.merge(i),u=ze(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 g=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,P],z)=>[`${C}-${P}`,z]));g.features.forEach(C=>{const P=C.geometry.coordinates[0].slice(0,3).reverse(),z=[];if(P.forEach(([B,q])=>{const k=`${B}-${q}`;S.has(k)&&z.push(S.get(k))}),z.length===3){if(z.some(B=>B<o.length)){const B=C.properties.circumcenter;if(!Z(B,c,d))return}v.push(...z)}})}else if(u.length){const g=ye.from(s);for(let S=0,C=g.triangles.length;S<C;S+=3){const P=[2,1,0].map(B=>g.triangles[S+B]),z=P.map(B=>s[B]);if(P.some(B=>B<o.length)){const B=[0,1].map(q=>_.mean(z,k=>k[q]));if(!Z(B,c,d))continue}v.push(...P)}}else{const{vertices:g,holes:S=[]}=X.flatten(i);v=X(g,S,2)}let m=t?[t[0],t[2]]:_.extent(s,g=>g[0]),b=t?[t[1],t[3]]:_.extent(s,g=>g[1]);if(r){const[g,S]=r([m[0],b[0]]),[C,P]=r([m[1],b[1]]);m=[g,C],b=[-S,-P]}const w=se.scaleLinear(m,[0,1]),j=se.scaleLinear(b,[0,1]),D=s.map(([g,S])=>{if(r){const[C,P]=r([g,S]);return[w(C),j(-P)]}else return[w(g),j(S)]});return{contour:i,triangles:{points:s,indices:v,uvs:D}}}const oe=new a.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,r){const i=n.map(o=>o.map(([u,s])=>{if(r){const[c,l]=r([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(i)}function _e(n,e,t,r,i){const{vertices:o,holes:u}=G(n,e,r,i),{vertices:s}=G(n,t,r,i),c=_.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 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,r,i,o){return{indices:r?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,i,o).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:r=1,cartesian:i=!0,hasSide:o=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{ge(w)||w.reverse()});const{contour:f,triangles:h}=Le(n,{resolution:r,bbox:l,projection:c});let p={},d;o&&(p=_e(f,e!=null?e:t,t!=null?t:e,i,c),d=p.topVerts);let v=[];(u||s)&&(v=_.merge(h.uvs));let m={};u&&(m=ae(h,e,v,!1,i,c));let b={};return s&&(b=ae(h,t,v,!0,i,c)),{contour:f,triangles:h,sideTorso:p,bottomCap:m,topCap:b,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:r,hasTop:i,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 b=[],w=[],j=[],D=0;const A=g=>{const S=Math.round(b.length/3),C=j.length;b=b.concat(g.vertices),w=w.concat(g.uvs),j=j.concat(S?g.indices.map(P=>P+S):g.indices),this.addGroup(C,j.length-C,D++)};i&&o&&A(m),s&&(A(p),this.userData.topVerts=l?G(h,r+l,c,f).vertices:d),u&&A(v),i&&!o&&A(m),this.setIndex(j),this[oe]("position",new a.Float32BufferAttribute(b,3)),this[oe]("uv",new a.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Oe=`
|
|
4
|
+
`},new a.Points(t,r)},Be=(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,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 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 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 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 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=Pe(this.object3d,p);else{const d=this.object3d,v=i?this.cloneMaterial():d.material;f.object3d=new a.InstancedMesh(d.geometry,v,p)}Be(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 ze(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 Le(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Ve(n,e),o=_.merge(r),u=ze(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 g=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,P],z)=>[`${C}-${P}`,z]));g.features.forEach(C=>{const P=C.geometry.coordinates[0].slice(0,3).reverse(),z=[];if(P.forEach(([B,q])=>{const k=`${B}-${q}`;S.has(k)&&z.push(S.get(k))}),z.length===3){if(z.some(B=>B<o.length)){const B=C.properties.circumcenter;if(!Z(B,c,d))return}v.push(...z)}})}else if(u.length){const g=ye.from(s);for(let S=0,C=g.triangles.length;S<C;S+=3){const P=[2,1,0].map(B=>g.triangles[S+B]),z=P.map(B=>s[B]);if(P.some(B=>B<o.length)){const B=[0,1].map(q=>_.mean(z,k=>k[q]));if(!Z(B,c,d))continue}v.push(...P)}}else{const{vertices:g,holes:S=[]}=X.flatten(r);v=X(g,S,2)}let m=t?[t[0],t[2]]:_.extent(s,g=>g[0]),b=t?[t[1],t[3]]:_.extent(s,g=>g[1]);if(i){const[g,S]=i([m[0],b[0]]),[C,P]=i([m[1],b[1]]);m=[g,C],b=[-S,-P]}const w=se.scaleLinear(m,[0,1]),j=se.scaleLinear(b,[0,1]),D=s.map(([g,S])=>{if(i){const[C,P]=i([g,S]);return[w(C),j(-P)]}else return[w(g),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 _e(n,e,t,i,r){const{vertices:o,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=_.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 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,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=>{ge(w)||w.reverse()});const{contour:f,triangles:h}=Le(n,{resolution:i,bbox:l,projection:c});let p={},d;o&&(p=_e(f,e!=null?e:t,t!=null?t:e,r,c),d=p.topVerts);let v=[];(u||s)&&(v=_.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 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 b=[],w=[],j=[],D=0;const A=g=>{const S=Math.round(b.length/3),C=j.length;b=b.concat(g.vertices),w=w.concat(g.uvs),j=j.concat(S?g.indices.map(P=>P+S):g.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(b,3)),this[oe]("uv",new a.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Oe=`
|
|
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 a.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:
|
|
140
|
+
`;class We extends a.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:i="#ffffff",opacity:r=1,map:o=null,dashOffset:u=0,dashArray:s=0,dashRatio:c=0,sizeAttenuation:l=!0,offsetLoop:f=!0,offset:h=new a.Vector2(0,0),scaleDown:p=0,alphaMap:d=void 0,alphaTest:v=0,repeat:m=new a.Vector2(1,1),resolution:b=new a.Vector2(1,1)}=j,w=ie(j,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(R(E({},w),{uniforms:{lineWidth:{value:t},color:{value:new a.Color(i)},opacity:{value:r},map:{value:o},useMap:{value:o?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:Oe})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new a.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 a.Vector4,ce=new a.Vector3,le=new a.Vector3,y=new a.Vector4,M=new a.Vector4,I=new a.Vector4,$=new a.Vector3,K=new a.Matrix4,x=new a.Line3,ue=new a.Vector3,N=new a.Box3,U=new a.Sphere,V=new a.Vector4;let T,L;function de(n,e,t){return V.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),V.multiplyScalar(1/V.w),V.x=L/t.width,V.y=L/t.height,V.applyMatrix4(n.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ne(n,e){const t=n.matrixWorld,i=n.geometry,r=i.attributes.instanceStart,o=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(o,s),x.applyMatrix4(t);const l=new a.Vector3,f=new a.Vector3;T.distanceSqToSegment(x.start,x.end,f,l),f.distanceTo(l)<L*.5&&e.push({point:f,pointOnLine:l,distance:T.origin.distanceTo(f),object:n,face:null,faceIndex:s,uv:null,uv1:null})}}function Ue(n,e,t){const i=e.projectionMatrix,o=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;T.at(1,I),I.w=1,I.applyMatrix4(e.matrixWorldInverse),I.applyMatrix4(i),I.multiplyScalar(1/I.w),I.x*=o.x/2,I.y*=o.y/2,I.z=0,$.copy(I),K.multiplyMatrices(e.matrixWorldInverse,u);for(let p=0,d=f;p<d;p++){if(y.fromBufferAttribute(c,p),M.fromBufferAttribute(l,p),y.w=1,M.w=1,y.applyMatrix4(K),M.applyMatrix4(K),y.z>h&&M.z>h)continue;if(y.z>h){const D=y.z-M.z,A=(y.z-h)/D;y.lerp(M,A)}else if(M.z>h){const D=M.z-y.z,A=(M.z-h)/D;M.lerp(y,A)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=o.x/2,y.y*=o.y/2,M.x*=o.x/2,M.y*=o.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const m=x.closestPointToPointParameter($,!0);x.at(m,ue);const b=a.MathUtils.lerp(y.z,M.z,m),w=b>=-1&&b<=1,j=$.distanceTo(ue)<L*.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 a.Vector3,A=new a.Vector3;T.distanceSqToSegment(x.start,x.end,A,D),t.push({point:A,pointOnLine:D,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ge extends a.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 o=new a.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new a.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new a.InterleavedBufferAttribute(o,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 o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;T=e.ray;const u=this.matrixWorld,s=this.geometry,c=this.material;L=c.linewidth+o,s.boundingSphere===null&&s.computeBoundingSphere(),U.copy(s.boundingSphere).applyMatrix4(u);let l;if(i)l=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;s.boundingBox===null&&s.computeBoundingBox(),N.copy(s.boundingBox).applyMatrix4(u);let f;if(i)f=L*.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=Ee;exports.ResourceTracker=fe;exports.getMetas=he;
|
|
@@ -35,7 +35,7 @@ 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
|
|
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 O, Matrix4 as _t, Line3 as Et, Sphere as Lt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as ut, MathUtils as Vt } from "three";
|
|
39
39
|
import { CSS2DObject as kt } 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";
|
|
@@ -49,7 +49,7 @@ import Xt from "@turf/boolean-point-in-polygon";
|
|
|
49
49
|
import { geoVoronoi as Yt } from "d3-geo-voronoi";
|
|
50
50
|
import { scaleLinear as ht } from "d3-scale";
|
|
51
51
|
import { LineSegmentsGeometry as Zt } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
52
|
-
const Jt = 0,
|
|
52
|
+
const Jt = 0, De = 1, Ht = 2, Te = !1;
|
|
53
53
|
class te {
|
|
54
54
|
constructor() {
|
|
55
55
|
this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
|
|
@@ -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
|
|
103
|
+
const i = n.material, s = new Bt({
|
|
104
104
|
size: 10,
|
|
105
105
|
map: i.map,
|
|
106
106
|
alphaMap: i.alphaMap,
|
|
@@ -131,7 +131,7 @@ const ee = (n, t = 1) => {
|
|
|
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, f = c.attributes.position.array, d = c.attributes.scaleAtt.array, h = new I(), u = new I(), m = new
|
|
134
|
+
const c = n.geometry, f = c.attributes.position.array, d = c.attributes.scaleAtt.array, h = new I(), u = new I(), m = new Dt(), p = s * 3, v = s * 1;
|
|
135
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
|
});
|
|
@@ -284,7 +284,7 @@ class pt extends ne {
|
|
|
284
284
|
resize(t, e) {
|
|
285
285
|
}
|
|
286
286
|
show() {
|
|
287
|
-
return this.object3d.visible = !0, this.object3d.layers.set(Jt), this;
|
|
287
|
+
return this.object3d.visible = !0, this.object3d.layers.set(Jt), this.isBloom && this.enableBloom(), this;
|
|
288
288
|
}
|
|
289
289
|
hide() {
|
|
290
290
|
return this.object3d.visible = !1, this.object3d.layers.set(Ht), this;
|
|
@@ -443,10 +443,10 @@ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
443
443
|
f <= -89;
|
|
444
444
|
let m = [];
|
|
445
445
|
if (u) {
|
|
446
|
-
const
|
|
446
|
+
const b = Yt(r).triangles(), x = new Map(
|
|
447
447
|
r.map(([A, C], _) => [`${A}-${C}`, _])
|
|
448
448
|
);
|
|
449
|
-
|
|
449
|
+
b.features.forEach((A) => {
|
|
450
450
|
const C = A.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
|
|
451
451
|
if (C.forEach(([P, F]) => {
|
|
452
452
|
const V = `${P}-${F}`;
|
|
@@ -465,9 +465,9 @@ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
465
465
|
}
|
|
466
466
|
});
|
|
467
467
|
} else if (l.length) {
|
|
468
|
-
const
|
|
469
|
-
for (let x = 0, A =
|
|
470
|
-
const C = [2, 1, 0].map((P) =>
|
|
468
|
+
const b = Qt.from(r);
|
|
469
|
+
for (let x = 0, A = b.triangles.length; x < A; x += 3) {
|
|
470
|
+
const C = [2, 1, 0].map((P) => b.triangles[x + P]), _ = C.map((P) => r[P]);
|
|
471
471
|
if (C.some((P) => P < a.length)) {
|
|
472
472
|
const P = [0, 1].map(
|
|
473
473
|
(F) => $t(_, (V) => V[F])
|
|
@@ -482,22 +482,22 @@ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
482
482
|
m.push(...C);
|
|
483
483
|
}
|
|
484
484
|
} else {
|
|
485
|
-
const { vertices:
|
|
486
|
-
m = qt(
|
|
485
|
+
const { vertices: b, holes: x = [] } = At(s);
|
|
486
|
+
m = qt(b, x, 2);
|
|
487
487
|
}
|
|
488
|
-
let p = e ? [e[0], e[2]] : dt(r, (
|
|
488
|
+
let p = e ? [e[0], e[2]] : dt(r, (b) => b[0]), v = e ? [e[1], e[3]] : dt(r, (b) => b[1]);
|
|
489
489
|
if (i) {
|
|
490
|
-
const [
|
|
491
|
-
p = [
|
|
490
|
+
const [b, x] = i([p[0], v[0]]), [A, C] = i([p[1], v[1]]);
|
|
491
|
+
p = [b, A], v = [-x, -C];
|
|
492
492
|
}
|
|
493
|
-
const w = ht(p, [0, 1]), S = ht(v, [0, 1]),
|
|
493
|
+
const w = ht(p, [0, 1]), S = ht(v, [0, 1]), B = r.map(([b, x]) => {
|
|
494
494
|
if (i) {
|
|
495
|
-
const [A, C] = i([
|
|
495
|
+
const [A, C] = i([b, x]);
|
|
496
496
|
return [w(A), S(-C)];
|
|
497
497
|
} else
|
|
498
|
-
return [w(
|
|
498
|
+
return [w(b), S(x)];
|
|
499
499
|
});
|
|
500
|
-
return { contour: s, triangles: { points: r, indices: m, uvs:
|
|
500
|
+
return { contour: s, triangles: { points: r, indices: m, uvs: B } };
|
|
501
501
|
}
|
|
502
502
|
const mt = new Z().setAttribute ? "setAttribute" : "addAttribute";
|
|
503
503
|
function G(n, t, e, i) {
|
|
@@ -626,12 +626,12 @@ class ze extends Z {
|
|
|
626
626
|
userDataRsoOffset: c,
|
|
627
627
|
projection: f
|
|
628
628
|
} = this.parameters, { contour: d, sideTorso: h, topVerts: u, bottomCap: m, topCap: p } = ue(L({}, this.parameters));
|
|
629
|
-
let v = [], w = [], S = [],
|
|
630
|
-
const j = (
|
|
629
|
+
let v = [], w = [], S = [], B = 0;
|
|
630
|
+
const j = (b) => {
|
|
631
631
|
const x = Math.round(v.length / 3), A = S.length;
|
|
632
|
-
v = v.concat(
|
|
633
|
-
x ?
|
|
634
|
-
), this.addGroup(A, S.length - A,
|
|
632
|
+
v = v.concat(b.vertices), w = w.concat(b.uvs), S = S.concat(
|
|
633
|
+
x ? b.indices.map((C) => C + x) : b.indices
|
|
634
|
+
), this.addGroup(A, S.length - A, B++);
|
|
635
635
|
};
|
|
636
636
|
s && a && j(p), r && (j(h), this.userData.topVerts = c ? G(
|
|
637
637
|
d,
|
|
@@ -886,7 +886,7 @@ class _e extends zt {
|
|
|
886
886
|
this.uniforms.sizeAttenuation.value = t ? 1 : 0;
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
|
-
const K = new O(),
|
|
889
|
+
const K = new O(), bt = new I(), gt = new I(), g = new O(), y = new O(), D = new O(), Q = new I(), X = new _t(), M = new Et(), yt = new I(), W = new St(), U = new Lt(), T = new O();
|
|
890
890
|
let z, E;
|
|
891
891
|
function Mt(n, t, e) {
|
|
892
892
|
return T.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = E / e.width, T.y = E / e.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
|
|
@@ -910,27 +910,27 @@ function he(n, t) {
|
|
|
910
910
|
}
|
|
911
911
|
function pe(n, t, e) {
|
|
912
912
|
const i = t.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, o = r.attributes.instanceStart, c = r.attributes.instanceEnd, f = Math.min(r.instanceCount, o.count), d = -t.near;
|
|
913
|
-
z.at(1,
|
|
913
|
+
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);
|
|
914
914
|
for (let h = 0, u = f; h < u; h++) {
|
|
915
|
-
if (
|
|
915
|
+
if (g.fromBufferAttribute(o, h), y.fromBufferAttribute(c, h), g.w = 1, y.w = 1, g.applyMatrix4(X), y.applyMatrix4(X), g.z > d && y.z > d)
|
|
916
916
|
continue;
|
|
917
|
-
if (
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
} else if (
|
|
921
|
-
const
|
|
922
|
-
|
|
917
|
+
if (g.z > d) {
|
|
918
|
+
const B = g.z - y.z, j = (g.z - d) / B;
|
|
919
|
+
g.lerp(y, j);
|
|
920
|
+
} else if (y.z > d) {
|
|
921
|
+
const B = y.z - g.z, j = (y.z - d) / B;
|
|
922
|
+
y.lerp(g, j);
|
|
923
923
|
}
|
|
924
|
-
|
|
924
|
+
g.applyMatrix4(i), y.applyMatrix4(i), g.multiplyScalar(1 / g.w), y.multiplyScalar(1 / y.w), g.x *= a.x / 2, g.y *= a.y / 2, y.x *= a.x / 2, y.y *= a.y / 2, M.start.copy(g), M.start.z = 0, M.end.copy(y), M.end.z = 0;
|
|
925
925
|
const p = M.closestPointToPointParameter(Q, !0);
|
|
926
|
-
M.at(p,
|
|
927
|
-
const v = Vt.lerp(
|
|
926
|
+
M.at(p, yt);
|
|
927
|
+
const v = Vt.lerp(g.z, y.z, p), w = v >= -1 && v <= 1, S = Q.distanceTo(yt) < E * 0.5;
|
|
928
928
|
if (w && S) {
|
|
929
929
|
M.start.fromBufferAttribute(o, h), M.end.fromBufferAttribute(c, h), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
|
|
930
|
-
const
|
|
931
|
-
z.distanceSqToSegment(M.start, M.end, j,
|
|
930
|
+
const B = new I(), j = new I();
|
|
931
|
+
z.distanceSqToSegment(M.start, M.end, j, B), e.push({
|
|
932
932
|
point: j,
|
|
933
|
-
pointOnLine:
|
|
933
|
+
pointOnLine: B,
|
|
934
934
|
distance: z.origin.distanceTo(j),
|
|
935
935
|
object: n,
|
|
936
936
|
face: null,
|
|
@@ -949,7 +949,7 @@ class Ee extends wt {
|
|
|
949
949
|
computeLineDistances() {
|
|
950
950
|
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
|
|
951
951
|
for (let l = 0, r = 0, o = e.count; l < o; l++, r += 2)
|
|
952
|
-
|
|
952
|
+
bt.fromBufferAttribute(e, l), gt.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + bt.distanceTo(gt);
|
|
953
953
|
const a = new Ot(
|
|
954
954
|
s,
|
|
955
955
|
2,
|
|
@@ -1011,7 +1011,7 @@ class Ee extends wt {
|
|
|
1011
1011
|
}
|
|
1012
1012
|
}
|
|
1013
1013
|
export {
|
|
1014
|
-
|
|
1014
|
+
De as B,
|
|
1015
1015
|
Te as I,
|
|
1016
1016
|
Ee as L,
|
|
1017
1017
|
_e as M,
|