gl-draw 0.14.38 → 0.14.40

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.
@@ -3,6 +3,7 @@ type Resource = Object3D | Material | Texture | BufferGeometry | ResourceTracker
3
3
  export default class ResourceTracker {
4
4
  resources: Set<Resource>;
5
5
  disposeWithMaterial: boolean;
6
+ disposeVideo: boolean;
6
7
  object3d: Object3D;
7
8
  materialList: Record<string, Material | Material[]>;
8
9
  disposeTrack: boolean;
@@ -42,7 +42,7 @@ import { geoVoronoi as te } from "d3-geo-voronoi";
42
42
  import { scaleLinear as ft } from "d3-scale";
43
43
  class O {
44
44
  constructor() {
45
- this.resources = /* @__PURE__ */ new Set(), this.disposeWithMaterial = !0, this.materialList = {}, this.disposeTrack = !0;
45
+ this.resources = /* @__PURE__ */ new Set(), this.disposeWithMaterial = !0, this.disposeVideo = !0, this.materialList = {}, this.disposeTrack = !0;
46
46
  }
47
47
  track(t) {
48
48
  if (!t || this.disposeTrack === !1)
@@ -67,13 +67,13 @@ class O {
67
67
  (s instanceof rt || Array.isArray(s)) && this.track(s);
68
68
  }
69
69
  }
70
- } else t instanceof Dt && t.source.data && this.resources.add(t.source.data);
70
+ } else this.disposeVideo && t instanceof Dt && t.source.data && this.resources.add(t.source.data);
71
71
  return t;
72
72
  }
73
73
  dispose() {
74
74
  const t = [];
75
75
  for (const e of this.resources)
76
- e instanceof G ? t.push(e) : e instanceof HTMLVideoElement && (e.pause(), e.src = "", e.remove()), Reflect.has(e, "dispose") && e.dispose();
76
+ e instanceof G ? t.push(e) : e instanceof HTMLVideoElement && e.pause(), Reflect.has(e, "dispose") && e.dispose();
77
77
  t.forEach((e) => {
78
78
  e.removeFromParent();
79
79
  }), t.length = 0, this.resources.clear();
package/dist/index2.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var ft=Object.defineProperty,dt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var J=Math.pow,H=(o,t,e)=>t in o?ft(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,O=(o,t)=>{for(var e in t||(t={}))mt.call(t,e)&&H(o,e,t[e]);if(Y)for(var e of Y(t))vt.call(t,e)&&H(o,e,t[e]);return o},F=(o,t)=>dt(o,pt(t));var tt=(o,t,e)=>new Promise((i,s)=>{var a=c=>{try{r(e.next(c))}catch(u){s(u)}},l=c=>{try{r(e.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,l);r((e=e.apply(o,t)).next())});const n=require("three"),gt=require("three/examples/jsm/renderers/CSS2DRenderer"),et=require("three/examples/jsm/renderers/CSS3DRenderer"),k=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),bt=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),yt=require("@turf/boolean-clockwise"),xt=require("delaunator"),Mt=require("@turf/boolean-point-in-polygon"),wt=require("d3-geo-voronoi"),it=require("d3-scale");class _{constructor(){this.resources=new Set,this.disposeWithMaterial=!0,this.materialList={},this.disposeTrack=!0}track(t){if(!t||this.disposeTrack===!1)return t;if(Array.isArray(t))return t.forEach(e=>this.track(e)),t;if(!this.disposeWithMaterial&&t instanceof n.Material)return t;if(t instanceof _?(t===this&&t.object3d?this.track(t.object3d):(t.disposeTrack=!1,this.resources.add(t)),Object.values(t.materialList).map(e=>this.track(e))):(t instanceof n.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof _)this.track(t.children);else if(t instanceof n.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof n.Material){for(const i of Object.values(t))i instanceof n.Texture&&this.track(i);const e=t;if(e.uniforms){for(const i of Object.values(e.uniforms))if(i){const s=i.value;(s instanceof n.Texture||Array.isArray(s))&&this.track(s)}}}else t instanceof n.VideoTexture&&t.source.data&&this.resources.add(t.source.data);return t}dispose(){const t=[];for(const e of this.resources)e instanceof n.Object3D?t.push(e):e instanceof HTMLVideoElement&&(e.pause(),e.src="",e.remove()),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const Pt=(o,t=1)=>{const e=new n.BufferGeometry;e.setAttribute("position",new n.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new n.Float32BufferAttribute(new Array(t).fill(1),1));const i=o.material,s=new n.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 s.onBeforeCompile=a=>{a.vertexShader=`
1
+ "use strict";var ft=Object.defineProperty,dt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var J=Math.pow,H=(o,t,e)=>t in o?ft(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,O=(o,t)=>{for(var e in t||(t={}))mt.call(t,e)&&H(o,e,t[e]);if(Y)for(var e of Y(t))vt.call(t,e)&&H(o,e,t[e]);return o},F=(o,t)=>dt(o,pt(t));var tt=(o,t,e)=>new Promise((i,s)=>{var a=c=>{try{r(e.next(c))}catch(u){s(u)}},l=c=>{try{r(e.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,l);r((e=e.apply(o,t)).next())});const n=require("three"),gt=require("three/examples/jsm/renderers/CSS2DRenderer"),et=require("three/examples/jsm/renderers/CSS3DRenderer"),k=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),bt=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),yt=require("@turf/boolean-clockwise"),xt=require("delaunator"),Mt=require("@turf/boolean-point-in-polygon"),wt=require("d3-geo-voronoi"),it=require("d3-scale");class _{constructor(){this.resources=new Set,this.disposeWithMaterial=!0,this.disposeVideo=!0,this.materialList={},this.disposeTrack=!0}track(t){if(!t||this.disposeTrack===!1)return t;if(Array.isArray(t))return t.forEach(e=>this.track(e)),t;if(!this.disposeWithMaterial&&t instanceof n.Material)return t;if(t instanceof _?(t===this&&t.object3d?this.track(t.object3d):(t.disposeTrack=!1,this.resources.add(t)),Object.values(t.materialList).map(e=>this.track(e))):(t instanceof n.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof _)this.track(t.children);else if(t instanceof n.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof n.Material){for(const i of Object.values(t))i instanceof n.Texture&&this.track(i);const e=t;if(e.uniforms){for(const i of Object.values(e.uniforms))if(i){const s=i.value;(s instanceof n.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&t instanceof n.VideoTexture&&t.source.data&&this.resources.add(t.source.data);return t}dispose(){const t=[];for(const e of this.resources)e instanceof n.Object3D?t.push(e):e instanceof HTMLVideoElement&&e.pause(),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const Pt=(o,t=1)=>{const e=new n.BufferGeometry;e.setAttribute("position",new n.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new n.Float32BufferAttribute(new Array(t).fill(1),1));const i=o.material,s=new n.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 s.onBeforeCompile=a=>{a.vertexShader=`
2
2
  attribute float scaleAtt;
3
3
  ${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new n.Points(e,s)};class ut extends _{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}get parent(){const t=this.object3d.parent;return t&&this.lead.objMap.get(t)||null}get children(){return this.object3d.children.map(t=>this.lead.objMap.get(t)).filter(t=>!!t)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get add(){return this.object3d.add.bind(this.object3d)}get remove(){return this.object3d.remove.bind(this.object3d)}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let t=this.parent;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(t,e){}resize(t,e){}show(){return this.object3d.visible=!0,this}hide(){return this.object3d.visible=!1,this}createMesh(...t){return this.object3d=new n.Mesh(...t),this}createGroup(){return this.object3d=new n.Group,this}createPoints(...t){return this.object3d=new n.Points(...t),this}createCSS2DObject(t){return this.object3d=new gt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new et.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new et.CSS3DSprite(t),this}createSprite(t){return this.object3d=new n.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new n.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new n.Vector3),center:t.getCenter(new n.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return tt(this,null,function*(){var p;const i=t&&t.length>0,s=(p=e==null?void 0:e.recursive)!=null?p:!0,{objectType:a,objectOptions:l}=this,[,r]=a.split("#");let c=e==null?void 0:e.create;c===void 0&&(c=h=>{if(this.object3d){if(i){const v=t.length;if(this.object3d instanceof n.Sprite)h.object3d=Pt(this.object3d,v);else{const d=this.object3d;h.object3d=new n.InstancedMesh(d.geometry,d.material,v),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate")}const f=new n.Object3D;t.forEach((d,m)=>{const b=Q.parseVector3(d.position),P=Q.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(m,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate");h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(r,F(O({},l||{}),{create:c,prefab:!1,key:(e==null?void 0:e.key)||(l==null?void 0:l.key),target:(e==null?void 0:e.target)||(l==null?void 0:l.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(t,e){if(this.object3d instanceof n.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof n.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,l=s.attributes.scaleAtt.array,r=new n.Vector3,c=new n.Vector3,u=new n.Quaternion,p=t*3,h=t*1;e.decompose(r,u,c),a[p]=r.x,a[p+1]=r.y,a[p+2]=r.z,l[h]=Math.max(c.x,c.y,c.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}cloneMaterial(){const t=this.object3d;if(!t||!t.material)return;const e=t.material;if(Array.isArray(e))return e.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=e.userData;e.userData={};const s=e.clone();return e.userData=i,s}}setMaterialList(t,e,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[t])if(i){const l=this.materialList[t],r=new _;r.track(l),r.dispose()}else return this.materialList[t];const a=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=a,a}useMaterial(t){const e=this.object3d;!e||!e.material||this.useMaterialType===t||!this.materialList[t]||(this.useMaterialType=t,e.material=this.materialList[t])}setTop(t){this.object3d&&(this.object3d.renderOrder=t)}onPointerEvent(t,e){const i=this.lead.handlePick([this],t,e);this.onPointerIndex.push(i)}enableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var t;this.onPointerIndex.forEach(e=>{this.lead.removePick(e)}),(t=this.pencil.composerController)==null||t.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.track(this),super.dispose()}disposeWithOutMaterial(){this.disposeWithMaterial=!1,this.dispose()}}class At extends ut{create(){this.createGroup()}}const Z=new n.Vector4,st=new n.Vector3,rt=new n.Vector3,y=new n.Vector4,x=new n.Vector4,z=new n.Vector4,$=new n.Vector3,N=new n.Matrix4,M=new n.Line3,nt=new n.Vector3,R=new n.Box3,E=new n.Sphere,B=new n.Vector4;let I,L;function at(o,t,e){return B.set(0,0,-t,1).applyMatrix4(o.projectionMatrix),B.multiplyScalar(1/B.w),B.x=L/e.width,B.y=L/e.height,B.applyMatrix4(o.projectionMatrixInverse),B.multiplyScalar(1/B.w),Math.abs(Math.max(B.x,B.y))}function St(o,t){const e=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){M.start.fromBufferAttribute(s,r),M.end.fromBufferAttribute(a,r),M.applyMatrix4(e);const u=new n.Vector3,p=new n.Vector3;I.distanceSqToSegment(M.start,M.end,p,u),p.distanceTo(u)<L*.5&&t.push({point:p,pointOnLine:u,distance:I.origin.distanceTo(p),object:o,face:null,faceIndex:r,uv:null,uv1:null})}}function jt(o,t,e){const i=t.projectionMatrix,a=o.material.resolution,l=o.matrixWorld,r=o.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,p=Math.min(r.instanceCount,c.count),h=-t.near;I.at(1,z),z.w=1,z.applyMatrix4(t.matrixWorldInverse),z.applyMatrix4(i),z.multiplyScalar(1/z.w),z.x*=a.x/2,z.y*=a.y/2,z.z=0,$.copy(z),N.multiplyMatrices(t.matrixWorldInverse,l);for(let v=0,f=p;v<f;v++){if(y.fromBufferAttribute(c,v),x.fromBufferAttribute(u,v),y.w=1,x.w=1,y.applyMatrix4(N),x.applyMatrix4(N),y.z>h&&x.z>h)continue;if(y.z>h){const V=y.z-x.z,A=(y.z-h)/V;y.lerp(x,A)}else if(x.z>h){const V=x.z-y.z,A=(x.z-h)/V;x.lerp(y,A)}y.applyMatrix4(i),x.applyMatrix4(i),y.multiplyScalar(1/y.w),x.multiplyScalar(1/x.w),y.x*=a.x/2,y.y*=a.y/2,x.x*=a.x/2,x.y*=a.y/2,M.start.copy(y),M.start.z=0,M.end.copy(x),M.end.z=0;const m=M.closestPointToPointParameter($,!0);M.at(m,nt);const b=n.MathUtils.lerp(y.z,x.z,m),P=b>=-1&&b<=1,D=$.distanceTo(nt)<L*.5;if(P&&D){M.start.fromBufferAttribute(c,v),M.end.fromBufferAttribute(u,v),M.start.applyMatrix4(l),M.end.applyMatrix4(l);const V=new n.Vector3,A=new n.Vector3;I.distanceSqToSegment(M.start,M.end,A,V),e.push({point:A,pointOnLine:V,distance:I.origin.distanceTo(A),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ct extends n.Mesh{constructor(t=new bt.LineSegmentsGeometry,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,s=new Float32Array(2*e.count);for(let l=0,r=0,c=e.count;l<c;l++,r+=2)st.fromBufferAttribute(e,l),rt.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+st.distanceTo(rt);const a=new n.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(a,1,0)),t.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(a,1,1)),this}raycast(t,e){const i=this.material.worldUnits,s=t.camera;s===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=t.params.Line2!==void 0&&t.params.Line2.threshold||0;I=t.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;L=c.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),E.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=L*.5;else{const h=Math.max(s.near,E.distanceToPoint(I.origin));u=at(s,h,c.resolution)}if(E.radius+=u,I.intersectsSphere(E)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),R.copy(r.boundingBox).applyMatrix4(l);let p;if(i)p=L*.5;else{const h=Math.max(s.near,R.distanceToPoint(I.origin));p=at(s,h,c.resolution)}R.expandByScalar(p),I.intersectsBox(R)!==!1&&(i?St(this,e):jt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(Z),this.material.uniforms.resolution.value.set(Z.z,Z.w))}}const ot=["encodings_fragment","colorspace_fragment"],Dt=`
4
+ `},new n.Points(e,s)};class ut extends _{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}get parent(){const t=this.object3d.parent;return t&&this.lead.objMap.get(t)||null}get children(){return this.object3d.children.map(t=>this.lead.objMap.get(t)).filter(t=>!!t)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get add(){return this.object3d.add.bind(this.object3d)}get remove(){return this.object3d.remove.bind(this.object3d)}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let t=this.parent;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(t,e){}resize(t,e){}show(){return this.object3d.visible=!0,this}hide(){return this.object3d.visible=!1,this}createMesh(...t){return this.object3d=new n.Mesh(...t),this}createGroup(){return this.object3d=new n.Group,this}createPoints(...t){return this.object3d=new n.Points(...t),this}createCSS2DObject(t){return this.object3d=new gt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new et.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new et.CSS3DSprite(t),this}createSprite(t){return this.object3d=new n.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new n.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new n.Vector3),center:t.getCenter(new n.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return tt(this,null,function*(){var p;const i=t&&t.length>0,s=(p=e==null?void 0:e.recursive)!=null?p:!0,{objectType:a,objectOptions:l}=this,[,r]=a.split("#");let c=e==null?void 0:e.create;c===void 0&&(c=h=>{if(this.object3d){if(i){const v=t.length;if(this.object3d instanceof n.Sprite)h.object3d=Pt(this.object3d,v);else{const d=this.object3d;h.object3d=new n.InstancedMesh(d.geometry,d.material,v),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate")}const f=new n.Object3D;t.forEach((d,m)=>{const b=Q.parseVector3(d.position),P=Q.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(m,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate");h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(r,F(O({},l||{}),{create:c,prefab:!1,key:(e==null?void 0:e.key)||(l==null?void 0:l.key),target:(e==null?void 0:e.target)||(l==null?void 0:l.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(t,e){if(this.object3d instanceof n.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof n.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,l=s.attributes.scaleAtt.array,r=new n.Vector3,c=new n.Vector3,u=new n.Quaternion,p=t*3,h=t*1;e.decompose(r,u,c),a[p]=r.x,a[p+1]=r.y,a[p+2]=r.z,l[h]=Math.max(c.x,c.y,c.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}cloneMaterial(){const t=this.object3d;if(!t||!t.material)return;const e=t.material;if(Array.isArray(e))return e.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=e.userData;e.userData={};const s=e.clone();return e.userData=i,s}}setMaterialList(t,e,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[t])if(i){const l=this.materialList[t],r=new _;r.track(l),r.dispose()}else return this.materialList[t];const a=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=a,a}useMaterial(t){const e=this.object3d;!e||!e.material||this.useMaterialType===t||!this.materialList[t]||(this.useMaterialType=t,e.material=this.materialList[t])}setTop(t){this.object3d&&(this.object3d.renderOrder=t)}onPointerEvent(t,e){const i=this.lead.handlePick([this],t,e);this.onPointerIndex.push(i)}enableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var t;this.onPointerIndex.forEach(e=>{this.lead.removePick(e)}),(t=this.pencil.composerController)==null||t.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.track(this),super.dispose()}disposeWithOutMaterial(){this.disposeWithMaterial=!1,this.dispose()}}class At extends ut{create(){this.createGroup()}}const Z=new n.Vector4,st=new n.Vector3,rt=new n.Vector3,y=new n.Vector4,x=new n.Vector4,z=new n.Vector4,$=new n.Vector3,N=new n.Matrix4,M=new n.Line3,nt=new n.Vector3,R=new n.Box3,E=new n.Sphere,B=new n.Vector4;let I,L;function at(o,t,e){return B.set(0,0,-t,1).applyMatrix4(o.projectionMatrix),B.multiplyScalar(1/B.w),B.x=L/e.width,B.y=L/e.height,B.applyMatrix4(o.projectionMatrixInverse),B.multiplyScalar(1/B.w),Math.abs(Math.max(B.x,B.y))}function St(o,t){const e=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){M.start.fromBufferAttribute(s,r),M.end.fromBufferAttribute(a,r),M.applyMatrix4(e);const u=new n.Vector3,p=new n.Vector3;I.distanceSqToSegment(M.start,M.end,p,u),p.distanceTo(u)<L*.5&&t.push({point:p,pointOnLine:u,distance:I.origin.distanceTo(p),object:o,face:null,faceIndex:r,uv:null,uv1:null})}}function jt(o,t,e){const i=t.projectionMatrix,a=o.material.resolution,l=o.matrixWorld,r=o.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,p=Math.min(r.instanceCount,c.count),h=-t.near;I.at(1,z),z.w=1,z.applyMatrix4(t.matrixWorldInverse),z.applyMatrix4(i),z.multiplyScalar(1/z.w),z.x*=a.x/2,z.y*=a.y/2,z.z=0,$.copy(z),N.multiplyMatrices(t.matrixWorldInverse,l);for(let v=0,f=p;v<f;v++){if(y.fromBufferAttribute(c,v),x.fromBufferAttribute(u,v),y.w=1,x.w=1,y.applyMatrix4(N),x.applyMatrix4(N),y.z>h&&x.z>h)continue;if(y.z>h){const D=y.z-x.z,A=(y.z-h)/D;y.lerp(x,A)}else if(x.z>h){const D=x.z-y.z,A=(x.z-h)/D;x.lerp(y,A)}y.applyMatrix4(i),x.applyMatrix4(i),y.multiplyScalar(1/y.w),x.multiplyScalar(1/x.w),y.x*=a.x/2,y.y*=a.y/2,x.x*=a.x/2,x.y*=a.y/2,M.start.copy(y),M.start.z=0,M.end.copy(x),M.end.z=0;const m=M.closestPointToPointParameter($,!0);M.at(m,nt);const b=n.MathUtils.lerp(y.z,x.z,m),P=b>=-1&&b<=1,V=$.distanceTo(nt)<L*.5;if(P&&V){M.start.fromBufferAttribute(c,v),M.end.fromBufferAttribute(u,v),M.start.applyMatrix4(l),M.end.applyMatrix4(l);const D=new n.Vector3,A=new n.Vector3;I.distanceSqToSegment(M.start,M.end,A,D),e.push({point:A,pointOnLine:D,distance:I.origin.distanceTo(A),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ct extends n.Mesh{constructor(t=new bt.LineSegmentsGeometry,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,s=new Float32Array(2*e.count);for(let l=0,r=0,c=e.count;l<c;l++,r+=2)st.fromBufferAttribute(e,l),rt.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+st.distanceTo(rt);const a=new n.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(a,1,0)),t.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(a,1,1)),this}raycast(t,e){const i=this.material.worldUnits,s=t.camera;s===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=t.params.Line2!==void 0&&t.params.Line2.threshold||0;I=t.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;L=c.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),E.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=L*.5;else{const h=Math.max(s.near,E.distanceToPoint(I.origin));u=at(s,h,c.resolution)}if(E.radius+=u,I.intersectsSphere(E)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),R.copy(r.boundingBox).applyMatrix4(l);let p;if(i)p=L*.5;else{const h=Math.max(s.near,R.distanceToPoint(I.origin));p=at(s,h,c.resolution)}R.expandByScalar(p),I.intersectsBox(R)!==!1&&(i?St(this,e):jt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(Z),this.material.uniforms.resolution.value.set(Z.z,Z.w))}}const ot=["encodings_fragment","colorspace_fragment"],Vt=`
5
5
  #include <common>
6
6
  #include <logdepthbuf_pars_vertex>
7
7
  #include <fog_pars_vertex>
@@ -94,7 +94,7 @@
94
94
  vHighPrecisionZW = finalPosition.zw;
95
95
  #include <fog_vertex>
96
96
  }
97
- `,Vt=`
97
+ `,Dt=`
98
98
  #include <packing>
99
99
  #include <fog_pars_fragment>
100
100
  #include <logdepthbuf_pars_fragment>
@@ -146,4 +146,4 @@
146
146
  #include <tonemapping_fragment>
147
147
  #include <${+n.REVISION<154?ot[0]:ot[1]}>
148
148
  }
149
- `;class zt extends n.ShaderMaterial{constructor(t){super({uniforms:F(O({},n.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new n.Color(16777215)},opacity:{value:1},resolution:{value:new n.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new n.Vector2(1,1)},offset:{value:new n.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new n.Vector2(0,0)},lightColor:{value:new n.Color(16777215)}}),vertexShader:Dt,fragmentShader:Vt}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(e){this.uniforms.useDash.value=e}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(e){this.uniforms.useDepth.value=e}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(e){this.uniforms.repeat.value.copy(e)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(e){this.uniforms.lineLightAnimation.value=e}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(e){this.uniforms.time.value=e}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(e){this.uniforms.speed.value=e}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(e){this.uniforms.lightWidth.value=e}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(e){this.uniforms.uCenter.value=e}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(e){e&&(this.uniforms.lightColor.value=e)}}}),this.setValues(t)}copy(t){return super.copy(t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray=t.dashArray,this.dashOffset=t.dashOffset,this.dashRatio=t.dashRatio,this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this}}function Bt(o,t){return o.map(e=>{const i=[];let s;return e.forEach(a=>{if(s){const l=k.geoDistance(a,s)*180/Math.PI;if(l>t){const r=k.geoInterpolate(s,a),c=1/Math.ceil(l/t);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=a)}),i})}function It(o,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const a=Math.round(J(360/o,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=f=>f/l*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,u=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,p=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],h=t===void 0&&e===void 0?()=>!0:t===void 0?f=>f<=e:e===void 0?f=>f>=t:e>=t?f=>f>=t&&f<=e:f=>f>=t||f<=e,v=[];for(let f=p[0];f<=p[1];f++){const d=r(f);h(d)&&v.push([d,c(f)])}return v}function X(o,t,e=!1){return e?k.geoContains(t,o):Mt(o,t)}function Tt(o,t){const e={type:"Polygon",coordinates:o},[[i,s],[a,l]]=k.geoBounds(e);if(Math.min(Math.abs(a-i),Math.abs(l-s))<t)return[];const r=i>a||l>=89||s<=-89;return It(t,{minLng:i,maxLng:a,minLat:s,maxLat:l}).filter(c=>X(c,e,r))}function Lt(o,{resolution:t=1/0,bbox:e,projection:i}={}){const s=Bt(o,t),a=W.merge(s),l=Tt(o,t),r=[...a,...l],c={type:"Polygon",coordinates:o},[[u,p],[h,v]]=k.geoBounds(c),f=u>h||v>=89||p<=-89;let d=[];if(f){const g=wt.geoVoronoi(r).triangles(),w=new Map(r.map(([S,j],T)=>[`${S}-${j}`,T]));g.features.forEach(S=>{const j=S.geometry.coordinates[0].slice(0,3).reverse(),T=[];if(j.forEach(([C,q])=>{const G=`${C}-${q}`;w.has(G)&&T.push(w.get(G))}),T.length===3){if(T.some(C=>C<a.length)){const C=S.properties.circumcenter;if(!X(C,c,f))return}d.push(...T)}})}else if(l.length){const g=xt.from(r);for(let w=0,S=g.triangles.length;w<S;w+=3){const j=[2,1,0].map(C=>g.triangles[w+C]),T=j.map(C=>r[C]);if(j.some(C=>C<a.length)){const C=[0,1].map(q=>W.mean(T,G=>G[q]));if(!X(C,c,f))continue}d.push(...j)}}else{const{vertices:g,holes:w=[]}=K.flatten(s);d=K(g,w,2)}let m=e?[e[0],e[2]]:W.extent(r,g=>g[0]),b=e?[e[1],e[3]]:W.extent(r,g=>g[1]);if(i){const[g,w]=i([m[0],b[0]]),[S,j]=i([m[1],b[1]]);m=[g,S],b=[-w,-j]}const P=it.scaleLinear(m,[0,1]),D=it.scaleLinear(b,[0,1]),V=r.map(([g,w])=>{if(i){const[S,j]=i([g,w]);return[P(S),D(-j)]}else return[P(g),D(w)]});return{contour:s,triangles:{points:r,indices:d,uvs:V}}}const lt=new n.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function U(o,t,e,i){const s=o.map(a=>a.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,t]}return e?Q.polar2Cartesian(l,r,t):[l,r,t]}));return K.flatten(s)}function Wt(o,t,e,i,s){const{vertices:a,holes:l}=U(o,t,i,s),{vertices:r}=U(o,e,i,s),c=W.merge([r,a]),u=Math.round(r.length/3),p=new Set(l);let h=0;const v=[];for(let d=0;d<u;d++){let m=d+1;if(m===u)m=h;else if(p.has(m)){const b=m;m=h,h=b}v.push(d,d+u,m+u),v.push(m+u,m,d)}const f=[];for(let d=1;d>=0;d--)for(let m=0;m<u;m+=1)f.push(m/(u-1),d);return{indices:v,vertices:c,uvs:f,topVerts:r}}function ct(o,t,e,i,s,a){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:U([o.points],t,s,a).vertices,uvs:e}}const ht=({polygonGeoJson:o,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{o.forEach(P=>{yt(P)||P.reverse()});const{contour:p,triangles:h}=Lt(o,{resolution:i,bbox:u,projection:c});let v={},f;a&&(v=Wt(p,t!=null?t:e,e!=null?e:t,s,c),f=v.topVerts);let d=[];(l||r)&&(d=W.merge(h.uvs));let m={};l&&(m=ct(h,t,d,!1,s,c));let b={};return r&&(b=ct(h,e,d,!0,s,c)),{contour:p,triangles:h,sideTorso:v,bottomCap:m,topCap:b,topVerts:f}};class _t extends n.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=O({polygonGeoJson:t,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},e);const{endHeight:i,hasTop:s,topFirst:a,hasBottom:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:p}=this.parameters,{contour:h,sideTorso:v,topVerts:f,bottomCap:d,topCap:m}=ht(O({},this.parameters));let b=[],P=[],D=[],V=0;const A=g=>{const w=Math.round(b.length/3),S=D.length;b=b.concat(g.vertices),P=P.concat(g.uvs),D=D.concat(w?g.indices.map(j=>j+w):g.indices),this.addGroup(S,D.length-S,V++)};s&&a&&A(m),r&&(A(v),this.userData.topVerts=u?U(h,i+u,c,p).vertices:f),l&&A(d),s&&!a&&A(m),this.setIndex(D),this[lt]("position",new n.Float32BufferAttribute(b,3)),this[lt]("uv",new n.Float32BufferAttribute(P,2)),this.computeVertexNormals()}}exports.BaseObject=ut;exports.Group=At;exports.LineSegments2=Ct;exports.MeshLineMaterial=zt;exports.PolygonGeometry=_t;exports.ResourceTracker=_;exports.getMetas=ht;
149
+ `;class zt extends n.ShaderMaterial{constructor(t){super({uniforms:F(O({},n.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new n.Color(16777215)},opacity:{value:1},resolution:{value:new n.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new n.Vector2(1,1)},offset:{value:new n.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new n.Vector2(0,0)},lightColor:{value:new n.Color(16777215)}}),vertexShader:Vt,fragmentShader:Dt}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(e){this.uniforms.useDash.value=e}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(e){this.uniforms.useDepth.value=e}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(e){this.uniforms.repeat.value.copy(e)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(e){this.uniforms.lineLightAnimation.value=e}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(e){this.uniforms.time.value=e}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(e){this.uniforms.speed.value=e}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(e){this.uniforms.lightWidth.value=e}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(e){this.uniforms.uCenter.value=e}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(e){e&&(this.uniforms.lightColor.value=e)}}}),this.setValues(t)}copy(t){return super.copy(t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray=t.dashArray,this.dashOffset=t.dashOffset,this.dashRatio=t.dashRatio,this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this}}function Bt(o,t){return o.map(e=>{const i=[];let s;return e.forEach(a=>{if(s){const l=k.geoDistance(a,s)*180/Math.PI;if(l>t){const r=k.geoInterpolate(s,a),c=1/Math.ceil(l/t);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=a)}),i})}function It(o,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const a=Math.round(J(360/o,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=f=>f/l*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,u=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,p=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],h=t===void 0&&e===void 0?()=>!0:t===void 0?f=>f<=e:e===void 0?f=>f>=t:e>=t?f=>f>=t&&f<=e:f=>f>=t||f<=e,v=[];for(let f=p[0];f<=p[1];f++){const d=r(f);h(d)&&v.push([d,c(f)])}return v}function X(o,t,e=!1){return e?k.geoContains(t,o):Mt(o,t)}function Tt(o,t){const e={type:"Polygon",coordinates:o},[[i,s],[a,l]]=k.geoBounds(e);if(Math.min(Math.abs(a-i),Math.abs(l-s))<t)return[];const r=i>a||l>=89||s<=-89;return It(t,{minLng:i,maxLng:a,minLat:s,maxLat:l}).filter(c=>X(c,e,r))}function Lt(o,{resolution:t=1/0,bbox:e,projection:i}={}){const s=Bt(o,t),a=W.merge(s),l=Tt(o,t),r=[...a,...l],c={type:"Polygon",coordinates:o},[[u,p],[h,v]]=k.geoBounds(c),f=u>h||v>=89||p<=-89;let d=[];if(f){const g=wt.geoVoronoi(r).triangles(),w=new Map(r.map(([S,j],T)=>[`${S}-${j}`,T]));g.features.forEach(S=>{const j=S.geometry.coordinates[0].slice(0,3).reverse(),T=[];if(j.forEach(([C,q])=>{const G=`${C}-${q}`;w.has(G)&&T.push(w.get(G))}),T.length===3){if(T.some(C=>C<a.length)){const C=S.properties.circumcenter;if(!X(C,c,f))return}d.push(...T)}})}else if(l.length){const g=xt.from(r);for(let w=0,S=g.triangles.length;w<S;w+=3){const j=[2,1,0].map(C=>g.triangles[w+C]),T=j.map(C=>r[C]);if(j.some(C=>C<a.length)){const C=[0,1].map(q=>W.mean(T,G=>G[q]));if(!X(C,c,f))continue}d.push(...j)}}else{const{vertices:g,holes:w=[]}=K.flatten(s);d=K(g,w,2)}let m=e?[e[0],e[2]]:W.extent(r,g=>g[0]),b=e?[e[1],e[3]]:W.extent(r,g=>g[1]);if(i){const[g,w]=i([m[0],b[0]]),[S,j]=i([m[1],b[1]]);m=[g,S],b=[-w,-j]}const P=it.scaleLinear(m,[0,1]),V=it.scaleLinear(b,[0,1]),D=r.map(([g,w])=>{if(i){const[S,j]=i([g,w]);return[P(S),V(-j)]}else return[P(g),V(w)]});return{contour:s,triangles:{points:r,indices:d,uvs:D}}}const lt=new n.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function U(o,t,e,i){const s=o.map(a=>a.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,t]}return e?Q.polar2Cartesian(l,r,t):[l,r,t]}));return K.flatten(s)}function Wt(o,t,e,i,s){const{vertices:a,holes:l}=U(o,t,i,s),{vertices:r}=U(o,e,i,s),c=W.merge([r,a]),u=Math.round(r.length/3),p=new Set(l);let h=0;const v=[];for(let d=0;d<u;d++){let m=d+1;if(m===u)m=h;else if(p.has(m)){const b=m;m=h,h=b}v.push(d,d+u,m+u),v.push(m+u,m,d)}const f=[];for(let d=1;d>=0;d--)for(let m=0;m<u;m+=1)f.push(m/(u-1),d);return{indices:v,vertices:c,uvs:f,topVerts:r}}function ct(o,t,e,i,s,a){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:U([o.points],t,s,a).vertices,uvs:e}}const ht=({polygonGeoJson:o,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{o.forEach(P=>{yt(P)||P.reverse()});const{contour:p,triangles:h}=Lt(o,{resolution:i,bbox:u,projection:c});let v={},f;a&&(v=Wt(p,t!=null?t:e,e!=null?e:t,s,c),f=v.topVerts);let d=[];(l||r)&&(d=W.merge(h.uvs));let m={};l&&(m=ct(h,t,d,!1,s,c));let b={};return r&&(b=ct(h,e,d,!0,s,c)),{contour:p,triangles:h,sideTorso:v,bottomCap:m,topCap:b,topVerts:f}};class _t extends n.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=O({polygonGeoJson:t,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},e);const{endHeight:i,hasTop:s,topFirst:a,hasBottom:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:p}=this.parameters,{contour:h,sideTorso:v,topVerts:f,bottomCap:d,topCap:m}=ht(O({},this.parameters));let b=[],P=[],V=[],D=0;const A=g=>{const w=Math.round(b.length/3),S=V.length;b=b.concat(g.vertices),P=P.concat(g.uvs),V=V.concat(w?g.indices.map(j=>j+w):g.indices),this.addGroup(S,V.length-S,D++)};s&&a&&A(m),r&&(A(v),this.userData.topVerts=u?U(h,i+u,c,p).vertices:f),l&&A(d),s&&!a&&A(m),this.setIndex(V),this[lt]("position",new n.Float32BufferAttribute(b,3)),this[lt]("uv",new n.Float32BufferAttribute(P,2)),this.computeVertexNormals()}}exports.BaseObject=ut;exports.Group=At;exports.LineSegments2=Ct;exports.MeshLineMaterial=zt;exports.PolygonGeometry=_t;exports.ResourceTracker=_;exports.getMetas=ht;
@@ -13,10 +13,9 @@ export interface ConicPolygonOptions {
13
13
  curvatureResolution?: number;
14
14
  projection?: ProjectionOptions;
15
15
  bbox?: number[];
16
- bboxOffset?: number[];
17
16
  splitPolygons?: number;
18
17
  }
19
- declare const getAttributes: ({ coordinatesArr, start, depth, useGroups, hasTop, topFirst, hasBottom, hasSide, cartesian, projection: projectionOptions, curvatureResolution, bbox, bboxOffset, }: ConicPolygonOptions) => {
18
+ declare const getAttributes: ({ coordinatesArr, start, depth, useGroups, hasTop, topFirst, hasBottom, hasSide, cartesian, projection: projectionOptions, curvatureResolution, bbox, }: ConicPolygonOptions) => {
20
19
  message: Record<string, import("three").GeometryGroup[] | {
21
20
  array: ArrayLike<number>;
22
21
  itemSize: number;
@@ -5,7 +5,6 @@ export interface ExtrudePolygonOptions {
5
5
  split?: number;
6
6
  sideRepeat?: number;
7
7
  bbox?: number[];
8
- bboxOffset?: number[];
9
8
  depth: number[];
10
9
  projection?: ProjectionOptions;
11
10
  useGroups?: 0 | 1 | 2;
@@ -15,7 +14,7 @@ export interface ExtrudePolygonOptions {
15
14
  splitPolygons?: number;
16
15
  topSegments?: number;
17
16
  }
18
- declare const getAttributes: ({ coordinatesArr, split, sideRepeat, bbox, bboxOffset, depth, projection: projectionOptions, useGroups, hasTop, hasBottom, hasSide, splitPolygons, topSegments, }: ExtrudePolygonOptions) => {
17
+ declare const getAttributes: ({ coordinatesArr, split, sideRepeat, bbox, depth, projection: projectionOptions, useGroups, hasTop, hasBottom, hasSide, splitPolygons, topSegments, }: ExtrudePolygonOptions) => {
19
18
  message: Record<string, import("three").GeometryGroup[] | {
20
19
  array: ArrayLike<number>;
21
20
  itemSize: number;