gl-draw 0.17.0-beta.12 → 0.17.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 +1 -1
- package/dist/WebGPULineSegments2.module.js +18 -18
- package/dist/core/BaseObject/index.d.ts +1 -1
- package/dist/core/pass/OutputPass.d.ts +1 -2
- package/dist/objects/extrudePolygon/createGeometry.d.ts +2 -1
- package/dist/objects/pie/index.d.ts +2 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +35 -35
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(N)for(var t of N(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&&N)for(var i of N(n))e.indexOf(i)<0&&ee.call(n,i)&&(t[i]=n[i]);return t};var re=(n,e,t)=>new Promise((i,r)=>{var a=c=>{try{s(t.next(c))}catch(l){r(l)}},u=c=>{try{s(t.throw(c))}catch(l){r(l)}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,u);s((t=t.apply(n,e)).next())});const o=require("three"),ye=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),L=require("d3-array"),X=require("earcut"),be=require("@turf/boolean-clockwise"),ge=require("delaunator"),Me=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),se=require("d3-scale"),Se=require("three/examples/jsm/lines/LineSegmentsGeometry"),we=0,je=1,Ae=2,Ce=!1;class fe{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof o.Material)return e;if(e instanceof Y?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Y)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const i of Object.values(e))i instanceof o.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const r=i.value;(r instanceof o.Texture||Array.isArray(r))&&this.track(r)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Be=(n,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,r=new o.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return r.onBeforeCompile=a=>{a.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
3
|
${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
-
`},new o.Points(t,r)},Ie=(n,e)=>{const t=new o.Object3D;e.forEach((i,r)=>{const a=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof o.Points||n.type==="Points"){const l=n.geometry,v=l.attributes.position.array,d=l.attributes.scaleAtt.array,p=new o.Vector3,f=new o.Vector3,m=new o.Quaternion,h=r*3,y=r*1;s.decompose(p,m,f),v[h]=p.x,v[h+1]=p.y,v[h+2]=p.z,d[y]=Math.max(f.x,f.y,f.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})};class Pe{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class De extends Pe{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const r=i.userData;i.userData={};const a=i.clone();return i.userData=r,a});{const i=t.userData;t.userData={};const r=t.clone();return t.userData=i,r}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const r=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=r,r}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const r=this.object3d;Array.isArray(r.material)&&t!==void 0?r.material[t]=i:r.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends De{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}lookAt(e){const t=e instanceof o.Vector3?e:new o.Vector3(...e);this.object3d.lookAt(t)}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(we),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new ye.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ne.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ne.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return re(this,null,function*(){var l,v;const t=(l=e==null?void 0:e.recursive)!=null?l:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:r,objectOptions:a}=this;let u=e==null?void 0:e.create,s,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(u===void 0&&(u=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const f=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)d.object3d=Be(this.object3d,f);else{const m=this.object3d,h=i?this.cloneMaterial():m.material;d.object3d=new o.InstancedMesh(m.geometry,h,f)}Ie(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),s=yield this.lead.draw(r,R(_({},a||{}),{create:u,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:s})))),s.isInstantiate=!0,s})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new fe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Ve(n,e){return n.map(t=>{const i=[];let r;return t.forEach(a=>{if(r){const u=E.geoDistance(a,r)*180/Math.PI;if(u>e){const s=E.geoInterpolate(r,a),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=a)}),i})}function Te(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const a=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=f=>f/u*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,l=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,v=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):a-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,p=[];for(let f=v[0];f<=v[1];f++){const m=s(f);d(m)&&p.push([m,c(f)])}return p}function Z(n,e,t=!1){return t?E.geoContains(e,n):Me(n,e)}function Oe(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[a,u]]=E.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(u-r))<e)return[];const s=i>a||u>=89||r<=-89;return Te(e,{minLng:i,maxLng:a,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Ve(n,e),a=L.merge(r),u=Oe(n,e),s=[...a,...u],c={type:"Polygon",coordinates:n},[[l,v],[d,p]]=E.geoBounds(c),f=l>d||p>=89||v<=-89;let m=[];if(f){const b=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,B],O)=>[`${C}-${B}`,O]));b.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(B.forEach(([I,q])=>{const k=`${I}-${q}`;S.has(k)&&O.push(S.get(k))}),O.length===3){if(O.some(I=>I<a.length)){const I=C.properties.circumcenter;if(!Z(I,c,f))return}m.push(...O)}})}else if(u.length){const b=ge.from(s);for(let S=0,C=b.triangles.length;S<C;S+=3){const B=[2,1,0].map(I=>b.triangles[S+I]),O=B.map(I=>s[I]);if(B.some(I=>I<a.length)){const I=[0,1].map(q=>L.mean(O,k=>k[q]));if(!Z(I,c,f))continue}m.push(...B)}}else{const{vertices:b,holes:S=[]}=X.flatten(r);m=X(b,S,2)}let h=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([h[0],y[0]]),[C,B]=i([h[1],y[1]]);h=[b,C],y=[-S,-B]}const w=se.scaleLinear(h,[0,1]),j=se.scaleLinear(y,[0,1]),P=s.map(([b,S])=>{if(i){const[C,B]=i([b,S]);return[w(C),j(-B)]}else return[w(b),j(S)]});return{contour:r,triangles:{points:s,indices:m,uvs:P}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(a=>a.map(([u,s])=>{if(i){const[c,l]=i([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(r)}function Le(n,e,t,i,r){const{vertices:a,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,a]),l=Math.round(s.length/3),v=new Set(u);let d=0;const p=[];for(let m=0;m<l;m++){let h=m+1;if(h===l)h=d;else if(v.has(h)){const y=h;h=d,d=y}p.push(m,m+l,h+l),p.push(h+l,h,m)}const f=[];for(let m=1;m>=0;m--)for(let h=0;h<l;h+=1)f.push(h/(l-1),m);return{indices:p,vertices:c,uvs:f,topVerts:s}}function ae(n,e,t,i,r,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,a).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:a=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{be(w)||w.reverse()});const{contour:v,triangles:d}=ze(n,{resolution:i,bbox:l,projection:c});let p={},f;a&&(p=Le(v,e!=null?e:t,t!=null?t:e,r,c),f=p.topVerts);let m=[];(u||s)&&(m=L.merge(d.uvs));let h={};u&&(h=ae(d,e,m,!1,r,c));let y={};return s&&(y=ae(d,t,m,!0,r,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:h,topCap:y,topVerts:f}};class _e extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:r,topFirst:a,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:f,bottomCap:m,topCap:h}=he(_({},this.parameters));let y=[],w=[],j=[],P=0;const A=b=>{const S=Math.round(y.length/3),C=j.length;y=y.concat(b.vertices),w=w.concat(b.uvs),j=j.concat(S?b.indices.map(B=>B+S):b.indices),this.addGroup(C,j.length-C,P++)};r&&a&&A(h),s&&(A(p),this.userData.topVerts=l?G(d,i+l,c,v).vertices:f),u&&A(m),r&&!a&&A(h),this.setIndex(j),this[oe]("position",new o.Float32BufferAttribute(y,3)),this[oe]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Ee=`
|
|
4
|
+
`},new o.Points(t,r)},Ie=(n,e)=>{const t=new o.Object3D;e.forEach((i,r)=>{const a=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof o.Points||n.type==="Points"){const l=n.geometry,v=l.attributes.position.array,d=l.attributes.scaleAtt.array,p=new o.Vector3,f=new o.Vector3,m=new o.Quaternion,h=r*3,y=r*1;s.decompose(p,m,f),v[h]=p.x,v[h+1]=p.y,v[h+2]=p.z,d[y]=Math.max(f.x,f.y,f.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})};class Pe{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class De extends Pe{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const r=i.userData;i.userData={};const a=i.clone();return i.userData=r,a});{const i=t.userData;t.userData={};const r=t.clone();return t.userData=i,r}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const r=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=r,r}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const r=this.object3d;Array.isArray(r.material)&&t!==void 0?r.material[t]=i:r.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends De{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}lookAt(e){const t=e instanceof o.Vector3?e:new o.Vector3(...e);this.object3d.lookAt(t)}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(we),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new ye.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ne.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ne.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return re(this,null,function*(){var l,v;const t=(l=e==null?void 0:e.recursive)!=null?l:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:r,objectOptions:a}=this;let u=e==null?void 0:e.create,s,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(u===void 0&&(u=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const f=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)d.object3d=Be(this.object3d,f);else{const m=this.object3d,h=i?this.cloneMaterial():m.material;d.object3d=new o.InstancedMesh(m.geometry,h,f)}Ie(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),s=yield this.lead.draw(r,R(_({},a||{}),{create:u,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId&&d.keyName?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:s})))),s.isInstantiate=!0,s})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new fe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Ve(n,e){return n.map(t=>{const i=[];let r;return t.forEach(a=>{if(r){const u=E.geoDistance(a,r)*180/Math.PI;if(u>e){const s=E.geoInterpolate(r,a),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=a)}),i})}function Te(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const a=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=f=>f/u*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,l=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,v=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):a-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,p=[];for(let f=v[0];f<=v[1];f++){const m=s(f);d(m)&&p.push([m,c(f)])}return p}function Z(n,e,t=!1){return t?E.geoContains(e,n):Me(n,e)}function Oe(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[a,u]]=E.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(u-r))<e)return[];const s=i>a||u>=89||r<=-89;return Te(e,{minLng:i,maxLng:a,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Ve(n,e),a=L.merge(r),u=Oe(n,e),s=[...a,...u],c={type:"Polygon",coordinates:n},[[l,v],[d,p]]=E.geoBounds(c),f=l>d||p>=89||v<=-89;let m=[];if(f){const b=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,B],O)=>[`${C}-${B}`,O]));b.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(B.forEach(([I,q])=>{const k=`${I}-${q}`;S.has(k)&&O.push(S.get(k))}),O.length===3){if(O.some(I=>I<a.length)){const I=C.properties.circumcenter;if(!Z(I,c,f))return}m.push(...O)}})}else if(u.length){const b=ge.from(s);for(let S=0,C=b.triangles.length;S<C;S+=3){const B=[2,1,0].map(I=>b.triangles[S+I]),O=B.map(I=>s[I]);if(B.some(I=>I<a.length)){const I=[0,1].map(q=>L.mean(O,k=>k[q]));if(!Z(I,c,f))continue}m.push(...B)}}else{const{vertices:b,holes:S=[]}=X.flatten(r);m=X(b,S,2)}let h=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([h[0],y[0]]),[C,B]=i([h[1],y[1]]);h=[b,C],y=[-S,-B]}const w=se.scaleLinear(h,[0,1]),j=se.scaleLinear(y,[0,1]),P=s.map(([b,S])=>{if(i){const[C,B]=i([b,S]);return[w(C),j(-B)]}else return[w(b),j(S)]});return{contour:r,triangles:{points:s,indices:m,uvs:P}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(a=>a.map(([u,s])=>{if(i){const[c,l]=i([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(r)}function Le(n,e,t,i,r){const{vertices:a,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,a]),l=Math.round(s.length/3),v=new Set(u);let d=0;const p=[];for(let m=0;m<l;m++){let h=m+1;if(h===l)h=d;else if(v.has(h)){const y=h;h=d,d=y}p.push(m,m+l,h+l),p.push(h+l,h,m)}const f=[];for(let m=1;m>=0;m--)for(let h=0;h<l;h+=1)f.push(h/(l-1),m);return{indices:p,vertices:c,uvs:f,topVerts:s}}function ae(n,e,t,i,r,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,a).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:a=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{be(w)||w.reverse()});const{contour:v,triangles:d}=ze(n,{resolution:i,bbox:l,projection:c});let p={},f;a&&(p=Le(v,e!=null?e:t,t!=null?t:e,r,c),f=p.topVerts);let m=[];(u||s)&&(m=L.merge(d.uvs));let h={};u&&(h=ae(d,e,m,!1,r,c));let y={};return s&&(y=ae(d,t,m,!0,r,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:h,topCap:y,topVerts:f}};class _e extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:r,topFirst:a,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:f,bottomCap:m,topCap:h}=he(_({},this.parameters));let y=[],w=[],j=[],P=0;const A=b=>{const S=Math.round(y.length/3),C=j.length;y=y.concat(b.vertices),w=w.concat(b.uvs),j=j.concat(S?b.indices.map(B=>B+S):b.indices),this.addGroup(C,j.length-C,P++)};r&&a&&A(h),s&&(A(p),this.userData.topVerts=l?G(d,i+l,c,v).vertices:f),u&&A(m),r&&!a&&A(h),this.setIndex(j),this[oe]("position",new o.Float32BufferAttribute(y,3)),this[oe]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Ee=`
|
|
5
5
|
#include <fog_pars_fragment>
|
|
6
6
|
#include <logdepthbuf_pars_fragment>
|
|
7
7
|
|
|
@@ -35,10 +35,10 @@ var re = (n, e, t) => new Promise((i, s) => {
|
|
|
35
35
|
}, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, l);
|
|
36
36
|
r((t = t.apply(n, e)).next());
|
|
37
37
|
});
|
|
38
|
-
import { Material as ae, Object3D as
|
|
38
|
+
import { Material as ae, Object3D as W, Texture as oe, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Be, Points as J, InstancedMesh as xe, Vector3 as w, Quaternion as De, Group as Te, Mesh as we, Sprite as ce, Box3 as Se, ShaderMaterial as ze, Vector2 as q, Color as le, Vector4 as E, Matrix4 as Oe, Line3 as _e, Sphere as ke, InstancedInterleavedBuffer as Ee, InterleavedBufferAttribute as ue, MathUtils as Le } from "three";
|
|
39
39
|
import { CSS2DObject as Ve } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
40
|
-
import { CSS3DObject as
|
|
41
|
-
import { geoBounds as je, geoContains as
|
|
40
|
+
import { CSS3DObject as Ne, CSS3DSprite as Ue } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
41
|
+
import { geoBounds as je, geoContains as We, geoDistance as Re, geoInterpolate as Ge } from "d3-geo";
|
|
42
42
|
import "d3-geo-projection";
|
|
43
43
|
import { p as fe, a as Fe } from "./polar2Cartesian.module.js";
|
|
44
44
|
import { merge as H, mean as $e, extent as de } from "d3-array";
|
|
@@ -61,11 +61,11 @@ class et {
|
|
|
61
61
|
return e.forEach((t) => this.track(t)), e;
|
|
62
62
|
if (!this.disposeMaterial && e instanceof ae)
|
|
63
63
|
return e;
|
|
64
|
-
if (e instanceof pe ? (e.disposeTrack && e.object3d ? this.track(e.object3d) : this.resources.add(e), Object.values(e.materialList).map((t) => this.track(t))) : (e instanceof
|
|
64
|
+
if (e instanceof pe ? (e.disposeTrack && e.object3d ? this.track(e.object3d) : this.resources.add(e), Object.values(e.materialList).map((t) => this.track(t))) : (e instanceof W || Reflect.has(e, "dispose")) && this.resources.add(e), e instanceof pe)
|
|
65
65
|
e.children.forEach((t) => {
|
|
66
66
|
t.disposeTrack = !1;
|
|
67
67
|
}), this.track(e.children);
|
|
68
|
-
else if (e instanceof
|
|
68
|
+
else if (e instanceof W) {
|
|
69
69
|
const t = e;
|
|
70
70
|
this.track(t.geometry), this.track(t.material), this.track(t.children);
|
|
71
71
|
} else if (e instanceof ae) {
|
|
@@ -85,7 +85,7 @@ class et {
|
|
|
85
85
|
dispose() {
|
|
86
86
|
const e = [];
|
|
87
87
|
for (const t of this.resources)
|
|
88
|
-
t instanceof
|
|
88
|
+
t instanceof W ? e.push(t) : t instanceof HTMLVideoElement && t.pause(), Reflect.has(t, "dispose") && t.dispose();
|
|
89
89
|
e.forEach((t) => {
|
|
90
90
|
t.removeFromParent();
|
|
91
91
|
}), e.length = 0, this.resources.clear();
|
|
@@ -123,7 +123,7 @@ const tt = (n, e = 1) => {
|
|
|
123
123
|
`;
|
|
124
124
|
}, new J(t, s);
|
|
125
125
|
}, it = (n, e) => {
|
|
126
|
-
const t = new
|
|
126
|
+
const t = new W();
|
|
127
127
|
e.forEach((i, s) => {
|
|
128
128
|
const a = fe(i.position), l = fe(i.scale || [1, 1, 1]);
|
|
129
129
|
t.position.copy(a), t.scale.copy(l), t.updateMatrix();
|
|
@@ -303,10 +303,10 @@ class pe extends nt {
|
|
|
303
303
|
return this.object3d = new Ve(e), this;
|
|
304
304
|
}
|
|
305
305
|
createCSS3DObject(e) {
|
|
306
|
-
return this.object3d = new
|
|
306
|
+
return this.object3d = new Ne(e), this;
|
|
307
307
|
}
|
|
308
308
|
createCSS3DSprite(e) {
|
|
309
|
-
return this.object3d = new
|
|
309
|
+
return this.object3d = new Ue(e), this;
|
|
310
310
|
}
|
|
311
311
|
createSprite(e) {
|
|
312
312
|
return this.object3d = new ce(e), this;
|
|
@@ -370,7 +370,7 @@ class pe extends nt {
|
|
|
370
370
|
}))), this.isBloom && r.enableBloom(), t && (yield Promise.all(
|
|
371
371
|
this.children.map(
|
|
372
372
|
(u) => u.instantiate({
|
|
373
|
-
key: u.keyUId ? `${u.keyName}-${u.keyUId}` : u.keyName,
|
|
373
|
+
key: u.keyUId && u.keyName ? `${u.keyName}-${u.keyUId}` : u.keyName,
|
|
374
374
|
uId: e == null ? void 0 : e.uId,
|
|
375
375
|
cloneMaterial: i,
|
|
376
376
|
target: r
|
|
@@ -430,7 +430,7 @@ function at(n, { minLng: e, maxLng: t, minLat: i, maxLat: s } = {}) {
|
|
|
430
430
|
return h;
|
|
431
431
|
}
|
|
432
432
|
function Y(n, e, t = !1) {
|
|
433
|
-
return t ?
|
|
433
|
+
return t ? We(e, n) : Xe(n, e);
|
|
434
434
|
}
|
|
435
435
|
function ot(n, e) {
|
|
436
436
|
const t = { type: "Polygon", coordinates: n }, [[i, s], [a, l]] = je(t);
|
|
@@ -895,7 +895,7 @@ class Ot extends ze {
|
|
|
895
895
|
this.uniforms.sizeAttenuation.value = e ? 1 : 0;
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
const K = new E(), ye = new w(), be = new w(), b = new E(), g = new E(), D = new E(), Q = new w(), X = new Oe(), M = new _e(), ge = new w(),
|
|
898
|
+
const K = new E(), ye = new w(), be = new w(), b = new E(), g = new E(), D = new E(), Q = new w(), X = new Oe(), M = new _e(), ge = new w(), N = new Se(), U = new ke(), T = new E();
|
|
899
899
|
let z, _;
|
|
900
900
|
function Me(n, e, t) {
|
|
901
901
|
return T.set(0, 0, -e, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = _ / t.width, T.y = _ / t.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
|
|
@@ -980,14 +980,14 @@ class _t extends we {
|
|
|
980
980
|
const a = e.params.Line2 !== void 0 && e.params.Line2.threshold || 0;
|
|
981
981
|
z = e.ray;
|
|
982
982
|
const l = this.matrixWorld, r = this.geometry, o = this.material;
|
|
983
|
-
_ = o.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(),
|
|
983
|
+
_ = o.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(l);
|
|
984
984
|
let c;
|
|
985
985
|
if (i)
|
|
986
986
|
c = _ * 0.5;
|
|
987
987
|
else {
|
|
988
988
|
const u = Math.max(
|
|
989
989
|
s.near,
|
|
990
|
-
|
|
990
|
+
U.distanceToPoint(z.origin)
|
|
991
991
|
);
|
|
992
992
|
c = Me(
|
|
993
993
|
s,
|
|
@@ -995,16 +995,16 @@ class _t extends we {
|
|
|
995
995
|
o.resolution
|
|
996
996
|
);
|
|
997
997
|
}
|
|
998
|
-
if (
|
|
998
|
+
if (U.radius += c, z.intersectsSphere(U) === !1)
|
|
999
999
|
return;
|
|
1000
|
-
r.boundingBox === null && r.computeBoundingBox(),
|
|
1000
|
+
r.boundingBox === null && r.computeBoundingBox(), N.copy(r.boundingBox).applyMatrix4(l);
|
|
1001
1001
|
let m;
|
|
1002
1002
|
if (i)
|
|
1003
1003
|
m = _ * 0.5;
|
|
1004
1004
|
else {
|
|
1005
1005
|
const u = Math.max(
|
|
1006
1006
|
s.near,
|
|
1007
|
-
|
|
1007
|
+
N.distanceToPoint(z.origin)
|
|
1008
1008
|
);
|
|
1009
1009
|
m = Me(
|
|
1010
1010
|
s,
|
|
@@ -1012,7 +1012,7 @@ class _t extends we {
|
|
|
1012
1012
|
o.resolution
|
|
1013
1013
|
);
|
|
1014
1014
|
}
|
|
1015
|
-
|
|
1015
|
+
N.expandByScalar(m), z.intersectsBox(N) !== !1 && (i ? ht(this, t) : pt(this, s, t));
|
|
1016
1016
|
}
|
|
1017
1017
|
onBeforeRender(e) {
|
|
1018
1018
|
const t = this.material.uniforms;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Material, Mesh, type Object3D, Points, type SpriteMaterial, Vector3 } from 'three';
|
|
1
|
+
import { type Material, Mesh, type Object3D, Points, type SpriteMaterial, Vector3 } from 'three';
|
|
2
2
|
import type Lead from "../Lead/Lead";
|
|
3
3
|
import type MList from "../MList/MList";
|
|
4
4
|
import type Pencil from "../Pencil";
|
|
@@ -11,9 +11,8 @@ declare class OutputPassFix extends OutputPass {
|
|
|
11
11
|
value: number;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
fsQuad: FullScreenQuad | undefined;
|
|
15
15
|
_fsQuad: FullScreenQuad | undefined;
|
|
16
16
|
}
|
|
17
17
|
import { OutputPass } from 'three/examples/jsm/postprocessing/OutputPass';
|
|
18
|
-
import { RawShaderMaterial } from 'three';
|
|
19
18
|
import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass';
|
|
@@ -20,6 +20,7 @@ declare const _default: (options: Options) => {
|
|
|
20
20
|
name: string;
|
|
21
21
|
index: import("three").BufferAttribute | null;
|
|
22
22
|
indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
23
|
+
indirectOffset: number | number[];
|
|
23
24
|
attributes: import("three").NormalBufferAttributes;
|
|
24
25
|
morphAttributes: {
|
|
25
26
|
position?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
@@ -38,7 +39,7 @@ declare const _default: (options: Options) => {
|
|
|
38
39
|
readonly isBufferGeometry: true;
|
|
39
40
|
getIndex(): import("three").BufferAttribute | null;
|
|
40
41
|
setIndex(index: import("three").BufferAttribute | number[] | null): any;
|
|
41
|
-
setIndirect(indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null): any;
|
|
42
|
+
setIndirect(indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null, indirectOffset?: number | number[]): any;
|
|
42
43
|
getIndirect(): import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
43
44
|
setAttribute<K extends string>(name: K, attribute: import("three").BufferAttribute | import("three").InterleavedBufferAttribute): any;
|
|
44
45
|
getAttribute<K extends string>(name: K): import("three").BufferAttribute | import("three").InterleavedBufferAttribute;
|
|
@@ -26,6 +26,7 @@ export default class extends BaseObject {
|
|
|
26
26
|
name: string;
|
|
27
27
|
index: import("three").BufferAttribute | null;
|
|
28
28
|
indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
29
|
+
indirectOffset: number | number[];
|
|
29
30
|
attributes: import("three").NormalBufferAttributes;
|
|
30
31
|
morphAttributes: {
|
|
31
32
|
position?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
@@ -44,7 +45,7 @@ export default class extends BaseObject {
|
|
|
44
45
|
readonly isBufferGeometry: true;
|
|
45
46
|
getIndex(): import("three").BufferAttribute | null;
|
|
46
47
|
setIndex(index: import("three").BufferAttribute | number[] | null): any;
|
|
47
|
-
setIndirect(indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null): any;
|
|
48
|
+
setIndirect(indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null, indirectOffset?: number | number[]): any;
|
|
48
49
|
getIndirect(): import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
49
50
|
setAttribute<K extends string>(name: K, attribute: import("three").BufferAttribute | import("three").InterleavedBufferAttribute): any;
|
|
50
51
|
getAttribute<K extends string>(name: K): import("three").BufferAttribute | import("three").InterleavedBufferAttribute;
|