gl-draw 0.14.26 → 0.14.27

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.
@@ -50,6 +50,7 @@ export default class BaseObject extends ResourceTracker {
50
50
  position: THREE.Vector3 | number[] | [number, number, number];
51
51
  scale?: THREE.Vector3 | number[] | [number, number, number];
52
52
  }[], ops?: {
53
+ key?: string;
53
54
  target?: IBaseObject;
54
55
  create?: ((...args: any[]) => any) | boolean;
55
56
  }): Promise<this>;
@@ -27,8 +27,8 @@ var J = (a, t, e) => new Promise((i, s) => {
27
27
  n((e = e.apply(a, t)).next());
28
28
  });
29
29
  import * as h from "three";
30
- import { Vector4 as k, Vector3 as B, Matrix4 as bt, Line3 as yt, Box3 as xt, Sphere as Mt, Mesh as wt, InstancedInterleavedBuffer as Pt, InterleavedBufferAttribute as tt, MathUtils as jt } from "three";
31
- import { CSS2DObject as At } from "three/examples/jsm/renderers/CSS2DRenderer";
30
+ import { Vector4 as k, Vector3 as B, Matrix4 as bt, Line3 as yt, Box3 as xt, Sphere as Mt, Mesh as wt, InstancedInterleavedBuffer as Pt, InterleavedBufferAttribute as tt, MathUtils as At } from "three";
31
+ import { CSS2DObject as jt } from "three/examples/jsm/renderers/CSS2DRenderer";
32
32
  import { CSS3DObject as St, CSS3DSprite as Ct } from "three/examples/jsm/renderers/CSS3DRenderer";
33
33
  import { geoBounds as ht, geoContains as zt, geoDistance as Dt, geoInterpolate as It } from "d3-geo";
34
34
  import "d3-geo-projection";
@@ -178,7 +178,7 @@ class Rt extends V {
178
178
  return this.object3d = new h.Points(...t), this;
179
179
  }
180
180
  createCSS2DObject(t) {
181
- return this.object3d = new At(t), this;
181
+ return this.object3d = new jt(t), this;
182
182
  }
183
183
  createCSS3DObject(t) {
184
184
  return this.object3d = new St(t), this;
@@ -246,6 +246,7 @@ class Rt extends V {
246
246
  const l = yield this.lead.draw(c, Z(O({}, r || {}), {
247
247
  create: n,
248
248
  prefab: !1,
249
+ key: (e == null ? void 0 : e.key) || (r == null ? void 0 : r.key),
249
250
  target: (e == null ? void 0 : e.target) || (r == null ? void 0 : r.target)
250
251
  }));
251
252
  return yield Promise.all(
@@ -363,7 +364,7 @@ function Gt(a, t, e) {
363
364
  y.applyMatrix4(i), x.applyMatrix4(i), y.multiplyScalar(1 / y.w), x.multiplyScalar(1 / x.w), y.x *= r.x / 2, y.y *= r.y / 2, x.x *= r.x / 2, x.y *= r.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(x), M.end.z = 0;
364
365
  const p = M.closestPointToPointParameter(q, !0);
365
366
  M.at(p, at);
366
- const b = jt.lerp(y.z, x.z, p), C = b >= -1 && b <= 1, z = q.distanceTo(at) < L * 0.5;
367
+ const b = At.lerp(y.z, x.z, p), C = b >= -1 && b <= 1, z = q.distanceTo(at) < L * 0.5;
367
368
  if (C && z) {
368
369
  M.start.fromBufferAttribute(l, m), M.end.fromBufferAttribute(o, m), M.start.applyMatrix4(c), M.end.applyMatrix4(c);
369
370
  const D = new B(), P = new B();
@@ -910,16 +911,16 @@ function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
910
911
  let v = [];
911
912
  if (u) {
912
913
  const g = kt(n).triangles(), w = new Map(
913
- n.map(([j, A], _) => [`${j}-${A}`, _])
914
+ n.map(([A, j], _) => [`${A}-${j}`, _])
914
915
  );
915
- g.features.forEach((j) => {
916
- const A = j.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
917
- if (A.forEach(([S, F]) => {
916
+ g.features.forEach((A) => {
917
+ const j = A.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
918
+ if (j.forEach(([S, F]) => {
918
919
  const E = `${S}-${F}`;
919
920
  w.has(E) && _.push(w.get(E));
920
921
  }), _.length === 3) {
921
922
  if (_.some((S) => S < r.length)) {
922
- const S = j.properties.circumcenter;
923
+ const S = A.properties.circumcenter;
923
924
  if (!Q(
924
925
  S,
925
926
  l,
@@ -932,9 +933,9 @@ function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
932
933
  });
933
934
  } else if (c.length) {
934
935
  const g = Ot.from(n);
935
- for (let w = 0, j = g.triangles.length; w < j; w += 3) {
936
- const A = [2, 1, 0].map((S) => g.triangles[w + S]), _ = A.map((S) => n[S]);
937
- if (A.some((S) => S < r.length)) {
936
+ for (let w = 0, A = g.triangles.length; w < A; w += 3) {
937
+ const j = [2, 1, 0].map((S) => g.triangles[w + S]), _ = j.map((S) => n[S]);
938
+ if (j.some((S) => S < r.length)) {
938
939
  const S = [0, 1].map(
939
940
  (F) => _t(_, (E) => E[F])
940
941
  );
@@ -945,7 +946,7 @@ function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
945
946
  ))
946
947
  continue;
947
948
  }
948
- v.push(...A);
949
+ v.push(...j);
949
950
  }
950
951
  } else {
951
952
  const { vertices: g, holes: w = [] } = ft(s);
@@ -953,13 +954,13 @@ function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
953
954
  }
954
955
  let p = e ? [e[0], e[2]] : it(n, (g) => g[0]), b = e ? [e[1], e[3]] : it(n, (g) => g[1]);
955
956
  if (i) {
956
- const [g, w] = i([p[0], b[0]]), [j, A] = i([p[1], b[1]]);
957
- p = [g, j], b = [-w, -A];
957
+ const [g, w] = i([p[0], b[0]]), [A, j] = i([p[1], b[1]]);
958
+ p = [g, A], b = [-w, -j];
958
959
  }
959
960
  const C = st(p, [0, 1]), z = st(b, [0, 1]), D = n.map(([g, w]) => {
960
961
  if (i) {
961
- const [j, A] = i([g, w]);
962
- return [C(j), z(-A)];
962
+ const [A, j] = i([g, w]);
963
+ return [C(A), z(-j)];
963
964
  } else
964
965
  return [C(g), z(w)];
965
966
  });
@@ -1094,10 +1095,10 @@ class me extends h.BufferGeometry {
1094
1095
  } = this.parameters, { contour: f, sideTorso: m, topVerts: u, bottomCap: v, topCap: p } = Xt(O({}, this.parameters));
1095
1096
  let b = [], C = [], z = [], D = 0;
1096
1097
  const P = (g) => {
1097
- const w = Math.round(b.length / 3), j = z.length;
1098
+ const w = Math.round(b.length / 3), A = z.length;
1098
1099
  b = b.concat(g.vertices), C = C.concat(g.uvs), z = z.concat(
1099
- w ? g.indices.map((A) => A + w) : g.indices
1100
- ), this.addGroup(j, z.length - j, D++);
1100
+ w ? g.indices.map((j) => j + w) : g.indices
1101
+ ), this.addGroup(A, z.length - A, D++);
1101
1102
  };
1102
1103
  s && r && P(p), n && (P(m), this.userData.topVerts = o ? G(
1103
1104
  f,
package/dist/index2.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var dt=Object.defineProperty,pt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var tt=Math.pow,J=(n,t,e)=>t in n?dt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,k=(n,t)=>{for(var e in t||(t={}))vt.call(t,e)&&J(n,e,t[e]);if(Y)for(var e of Y(t))gt.call(t,e)&&J(n,e,t[e]);return n},Z=(n,t)=>pt(n,mt(t));var et=(n,t,e)=>new Promise((i,s)=>{var a=l=>{try{r(e.next(l))}catch(o){s(o)}},c=l=>{try{r(e.throw(l))}catch(o){s(o)}},r=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,c);r((e=e.apply(n,t)).next())});const g=require("three"),bt=require("three/examples/jsm/renderers/CSS2DRenderer"),it=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const H=require("./parseVector.js"),yt=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),xt=require("@turf/boolean-clockwise"),Mt=require("delaunator"),wt=require("@turf/boolean-point-in-polygon"),Pt=require("d3-geo-voronoi"),st=require("d3-scale");function jt(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const h=jt(g);class B{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 h.Material)return t;if(t instanceof B?(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 h.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof B)this.track(t.children);else if(t instanceof h.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof h.Material){for(const i of Object.values(t))i instanceof h.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 h.Texture||Array.isArray(s))&&this.track(s)}}}return t}dispose(){const t=[];for(const e of this.resources)e instanceof h.Object3D&&t.push(e),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const At=(n,t=1)=>{const e=new h.BufferGeometry;e.setAttribute("position",new h.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new h.Float32BufferAttribute(new Array(t).fill(1),1));const i=n.material,s=new h.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 dt=Object.defineProperty,pt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var tt=Math.pow,J=(a,t,e)=>t in a?dt(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,k=(a,t)=>{for(var e in t||(t={}))vt.call(t,e)&&J(a,e,t[e]);if(Y)for(var e of Y(t))gt.call(t,e)&&J(a,e,t[e]);return a},Z=(a,t)=>pt(a,mt(t));var et=(a,t,e)=>new Promise((i,s)=>{var n=l=>{try{r(e.next(l))}catch(o){s(o)}},c=l=>{try{r(e.throw(l))}catch(o){s(o)}},r=l=>l.done?i(l.value):Promise.resolve(l.value).then(n,c);r((e=e.apply(a,t)).next())});const g=require("three"),bt=require("three/examples/jsm/renderers/CSS2DRenderer"),it=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const H=require("./parseVector.js"),yt=require("three/examples/jsm/lines/LineSegmentsGeometry"),B=require("d3-array"),K=require("earcut"),xt=require("@turf/boolean-clockwise"),Mt=require("delaunator"),wt=require("@turf/boolean-point-in-polygon"),Pt=require("d3-geo-voronoi"),st=require("d3-scale");function jt(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const h=jt(g);class O{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 h.Material)return t;if(t instanceof O?(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 h.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof O)this.track(t.children);else if(t instanceof h.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof h.Material){for(const i of Object.values(t))i instanceof h.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 h.Texture||Array.isArray(s))&&this.track(s)}}}return t}dispose(){const t=[];for(const e of this.resources)e instanceof h.Object3D&&t.push(e),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const At=(a,t=1)=>{const e=new h.BufferGeometry;e.setAttribute("position",new h.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new h.Float32BufferAttribute(new Array(t).fill(1),1));const i=a.material,s=new h.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=n=>{n.vertexShader=`
2
2
  attribute float scaleAtt;
3
- ${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new h.Points(e,s)};class ht extends B{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!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 h.Mesh(...t),this}createGroup(){return this.object3d=new h.Group,this}createPoints(...t){return this.object3d=new h.Points(...t),this}createCSS2DObject(t){return this.object3d=new bt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new it.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new it.CSS3DSprite(t),this}createSprite(t){return this.object3d=new h.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new h.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new h.Vector3),center:t.getCenter(new h.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return et(this,null,function*(){const i=t&&t.length>0,{objectType:s,objectOptions:a}=this,[,c]=s.split("#");let r=e==null?void 0:e.create;r===void 0&&(r=o=>{var d;if(this.object3d){if(i){const f=t.length;if(this.object3d instanceof h.Sprite)o.object3d=At(this.object3d,f);else{const u=this.object3d;o.object3d=new h.InstancedMesh(u.geometry,u.material,f),o.setMaterialList("instantiate","clone"),o.useMaterial("instantiate")}const m=new h.Object3D;t.forEach((u,v)=>{const p=H.parseVector3(u.position),y=H.parseVector3(u.scale||[1,1,1]);m.position.copy(p),m.scale.copy(y),m.updateMatrix(),o.setInstancedMatrix(v,m.matrix.clone())})}else o.object3d=this.object3d.clone(!1),o.setMaterialList("instantiate","clone"),o.useMaterial("instantiate");o.object3d.userData.bloom&&((d=this.pencil.composerController)==null||d.toggleBloomSelection(o.object3d,!0)),o.object3d.userData.prefab&&(o.object3d.userData.prefab=!1)}});const l=yield this.lead.draw(c,Z(k({},a||{}),{create:r,prefab:!1,target:(e==null?void 0:e.target)||(a==null?void 0:a.target)}));return yield Promise.all(this.children.map(o=>o.instantiate(void 0,{target:l}))),l.isInstantiate=!0,l})}setInstancedMatrix(t,e){if(this.object3d instanceof h.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof h.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,c=s.attributes.scaleAtt.array,r=new h.Vector3,l=new h.Vector3,o=new h.Quaternion,d=t*3,f=t*1;e.decompose(r,o,l),a[d]=r.x,a[d+1]=r.y,a[d+2]=r.z,c[f]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.dispose()}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 c=this.materialList[t],r=new B;r.track(c),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)}dispose(){this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),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 St extends ht{create(){this.createGroup()}}const $=new g.Vector4,rt=new g.Vector3,nt=new g.Vector3,x=new g.Vector4,M=new g.Vector4,I=new g.Vector4,N=new g.Vector3,Q=new g.Matrix4,w=new g.Line3,at=new g.Vector3,R=new g.Box3,U=new g.Sphere,T=new g.Vector4;let _,L;function ot(n,t,e){return T.set(0,0,-t,1).applyMatrix4(n.projectionMatrix),T.multiplyScalar(1/T.w),T.x=L/e.width,T.y=L/e.height,T.applyMatrix4(n.projectionMatrixInverse),T.multiplyScalar(1/T.w),Math.abs(Math.max(T.x,T.y))}function Ct(n,t){const e=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let r=0,l=c;r<l;r++){w.start.fromBufferAttribute(s,r),w.end.fromBufferAttribute(a,r),w.applyMatrix4(e);const o=new g.Vector3,d=new g.Vector3;_.distanceSqToSegment(w.start,w.end,d,o),d.distanceTo(o)<L*.5&&t.push({point:d,pointOnLine:o,distance:_.origin.distanceTo(d),object:n,face:null,faceIndex:r,uv:null,uv1:null})}}function Dt(n,t,e){const i=t.projectionMatrix,a=n.material.resolution,c=n.matrixWorld,r=n.geometry,l=r.attributes.instanceStart,o=r.attributes.instanceEnd,d=Math.min(r.instanceCount,l.count),f=-t.near;_.at(1,I),I.w=1,I.applyMatrix4(t.matrixWorldInverse),I.applyMatrix4(i),I.multiplyScalar(1/I.w),I.x*=a.x/2,I.y*=a.y/2,I.z=0,N.copy(I),Q.multiplyMatrices(t.matrixWorldInverse,c);for(let m=0,u=d;m<u;m++){if(x.fromBufferAttribute(l,m),M.fromBufferAttribute(o,m),x.w=1,M.w=1,x.applyMatrix4(Q),M.applyMatrix4(Q),x.z>f&&M.z>f)continue;if(x.z>f){const V=x.z-M.z,j=(x.z-f)/V;x.lerp(M,j)}else if(M.z>f){const V=M.z-x.z,j=(M.z-f)/V;M.lerp(x,j)}x.applyMatrix4(i),M.applyMatrix4(i),x.multiplyScalar(1/x.w),M.multiplyScalar(1/M.w),x.x*=a.x/2,x.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,w.start.copy(x),w.start.z=0,w.end.copy(M),w.end.z=0;const p=w.closestPointToPointParameter(N,!0);w.at(p,at);const y=g.MathUtils.lerp(x.z,M.z,p),D=y>=-1&&y<=1,z=N.distanceTo(at)<L*.5;if(D&&z){w.start.fromBufferAttribute(l,m),w.end.fromBufferAttribute(o,m),w.start.applyMatrix4(c),w.end.applyMatrix4(c);const V=new g.Vector3,j=new g.Vector3;_.distanceSqToSegment(w.start,w.end,j,V),e.push({point:j,pointOnLine:V,distance:_.origin.distanceTo(j),object:n,face:null,faceIndex:m,uv:null,uv1:null})}}}class zt extends g.Mesh{constructor(t=new yt.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 c=0,r=0,l=e.count;c<l;c++,r+=2)rt.fromBufferAttribute(e,c),nt.fromBufferAttribute(i,c),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+rt.distanceTo(nt);const a=new g.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new g.InterleavedBufferAttribute(a,1,0)),t.setAttribute("instanceDistanceEnd",new g.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;_=t.ray;const c=this.matrixWorld,r=this.geometry,l=this.material;L=l.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),U.copy(r.boundingSphere).applyMatrix4(c);let o;if(i)o=L*.5;else{const f=Math.max(s.near,U.distanceToPoint(_.origin));o=ot(s,f,l.resolution)}if(U.radius+=o,_.intersectsSphere(U)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),R.copy(r.boundingBox).applyMatrix4(c);let d;if(i)d=L*.5;else{const f=Math.max(s.near,R.distanceToPoint(_.origin));d=ot(s,f,l.resolution)}R.expandByScalar(d),_.intersectsBox(R)!==!1&&(i?Ct(this,e):Dt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport($),this.material.uniforms.resolution.value.set($.z,$.w))}}const lt=["encodings_fragment","colorspace_fragment"],Vt=`
3
+ ${n.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
+ `},new h.Points(e,s)};class ht extends O{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!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 h.Mesh(...t),this}createGroup(){return this.object3d=new h.Group,this}createPoints(...t){return this.object3d=new h.Points(...t),this}createCSS2DObject(t){return this.object3d=new bt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new it.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new it.CSS3DSprite(t),this}createSprite(t){return this.object3d=new h.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new h.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new h.Vector3),center:t.getCenter(new h.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return et(this,null,function*(){const i=t&&t.length>0,{objectType:s,objectOptions:n}=this,[,c]=s.split("#");let r=e==null?void 0:e.create;r===void 0&&(r=o=>{var d;if(this.object3d){if(i){const f=t.length;if(this.object3d instanceof h.Sprite)o.object3d=At(this.object3d,f);else{const u=this.object3d;o.object3d=new h.InstancedMesh(u.geometry,u.material,f),o.setMaterialList("instantiate","clone"),o.useMaterial("instantiate")}const m=new h.Object3D;t.forEach((u,v)=>{const p=H.parseVector3(u.position),y=H.parseVector3(u.scale||[1,1,1]);m.position.copy(p),m.scale.copy(y),m.updateMatrix(),o.setInstancedMatrix(v,m.matrix.clone())})}else o.object3d=this.object3d.clone(!1),o.setMaterialList("instantiate","clone"),o.useMaterial("instantiate");o.object3d.userData.bloom&&((d=this.pencil.composerController)==null||d.toggleBloomSelection(o.object3d,!0)),o.object3d.userData.prefab&&(o.object3d.userData.prefab=!1)}});const l=yield this.lead.draw(c,Z(k({},n||{}),{create:r,prefab:!1,key:(e==null?void 0:e.key)||(n==null?void 0:n.key),target:(e==null?void 0:e.target)||(n==null?void 0:n.target)}));return yield Promise.all(this.children.map(o=>o.instantiate(void 0,{target:l}))),l.isInstantiate=!0,l})}setInstancedMatrix(t,e){if(this.object3d instanceof h.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof h.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,n=s.attributes.position.array,c=s.attributes.scaleAtt.array,r=new h.Vector3,l=new h.Vector3,o=new h.Quaternion,d=t*3,f=t*1;e.decompose(r,o,l),n[d]=r.x,n[d+1]=r.y,n[d+2]=r.z,c[f]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.dispose()}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 n=i.clone();return i.userData=s,n});{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 c=this.materialList[t],r=new O;r.track(c),r.dispose()}else return this.materialList[t];const n=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=n,n}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)}dispose(){this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),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 St extends ht{create(){this.createGroup()}}const $=new g.Vector4,rt=new g.Vector3,nt=new g.Vector3,x=new g.Vector4,M=new g.Vector4,I=new g.Vector4,N=new g.Vector3,Q=new g.Matrix4,w=new g.Line3,at=new g.Vector3,R=new g.Box3,U=new g.Sphere,T=new g.Vector4;let _,W;function ot(a,t,e){return T.set(0,0,-t,1).applyMatrix4(a.projectionMatrix),T.multiplyScalar(1/T.w),T.x=W/e.width,T.y=W/e.height,T.applyMatrix4(a.projectionMatrixInverse),T.multiplyScalar(1/T.w),Math.abs(Math.max(T.x,T.y))}function Ct(a,t){const e=a.matrixWorld,i=a.geometry,s=i.attributes.instanceStart,n=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let r=0,l=c;r<l;r++){w.start.fromBufferAttribute(s,r),w.end.fromBufferAttribute(n,r),w.applyMatrix4(e);const o=new g.Vector3,d=new g.Vector3;_.distanceSqToSegment(w.start,w.end,d,o),d.distanceTo(o)<W*.5&&t.push({point:d,pointOnLine:o,distance:_.origin.distanceTo(d),object:a,face:null,faceIndex:r,uv:null,uv1:null})}}function Dt(a,t,e){const i=t.projectionMatrix,n=a.material.resolution,c=a.matrixWorld,r=a.geometry,l=r.attributes.instanceStart,o=r.attributes.instanceEnd,d=Math.min(r.instanceCount,l.count),f=-t.near;_.at(1,I),I.w=1,I.applyMatrix4(t.matrixWorldInverse),I.applyMatrix4(i),I.multiplyScalar(1/I.w),I.x*=n.x/2,I.y*=n.y/2,I.z=0,N.copy(I),Q.multiplyMatrices(t.matrixWorldInverse,c);for(let m=0,u=d;m<u;m++){if(x.fromBufferAttribute(l,m),M.fromBufferAttribute(o,m),x.w=1,M.w=1,x.applyMatrix4(Q),M.applyMatrix4(Q),x.z>f&&M.z>f)continue;if(x.z>f){const V=x.z-M.z,j=(x.z-f)/V;x.lerp(M,j)}else if(M.z>f){const V=M.z-x.z,j=(M.z-f)/V;M.lerp(x,j)}x.applyMatrix4(i),M.applyMatrix4(i),x.multiplyScalar(1/x.w),M.multiplyScalar(1/M.w),x.x*=n.x/2,x.y*=n.y/2,M.x*=n.x/2,M.y*=n.y/2,w.start.copy(x),w.start.z=0,w.end.copy(M),w.end.z=0;const p=w.closestPointToPointParameter(N,!0);w.at(p,at);const y=g.MathUtils.lerp(x.z,M.z,p),D=y>=-1&&y<=1,z=N.distanceTo(at)<W*.5;if(D&&z){w.start.fromBufferAttribute(l,m),w.end.fromBufferAttribute(o,m),w.start.applyMatrix4(c),w.end.applyMatrix4(c);const V=new g.Vector3,j=new g.Vector3;_.distanceSqToSegment(w.start,w.end,j,V),e.push({point:j,pointOnLine:V,distance:_.origin.distanceTo(j),object:a,face:null,faceIndex:m,uv:null,uv1:null})}}}class zt extends g.Mesh{constructor(t=new yt.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 c=0,r=0,l=e.count;c<l;c++,r+=2)rt.fromBufferAttribute(e,c),nt.fromBufferAttribute(i,c),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+rt.distanceTo(nt);const n=new g.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new g.InterleavedBufferAttribute(n,1,0)),t.setAttribute("instanceDistanceEnd",new g.InterleavedBufferAttribute(n,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 n=t.params.Line2!==void 0&&t.params.Line2.threshold||0;_=t.ray;const c=this.matrixWorld,r=this.geometry,l=this.material;W=l.linewidth+n,r.boundingSphere===null&&r.computeBoundingSphere(),U.copy(r.boundingSphere).applyMatrix4(c);let o;if(i)o=W*.5;else{const f=Math.max(s.near,U.distanceToPoint(_.origin));o=ot(s,f,l.resolution)}if(U.radius+=o,_.intersectsSphere(U)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),R.copy(r.boundingBox).applyMatrix4(c);let d;if(i)d=W*.5;else{const f=Math.max(s.near,R.distanceToPoint(_.origin));d=ot(s,f,l.resolution)}R.expandByScalar(d),_.intersectsBox(R)!==!1&&(i?Ct(this,e):Dt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport($),this.material.uniforms.resolution.value.set($.z,$.w))}}const lt=["encodings_fragment","colorspace_fragment"],Vt=`
5
5
  #include <common>
6
6
  #include <logdepthbuf_pars_vertex>
7
7
  #include <fog_pars_vertex>
@@ -146,4 +146,4 @@
146
146
  #include <tonemapping_fragment>
147
147
  #include <${+h.REVISION<154?lt[0]:lt[1]}>
148
148
  }
149
- `;class Tt extends h.ShaderMaterial{constructor(t){super({uniforms:Z(k({},h.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new h.Color(16777215)},opacity:{value:1},resolution:{value:new h.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 h.Vector2(1,1)},offset:{value:new h.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new h.Vector2(0,0)},lightColor:{value:new h.Color(16777215)}}),vertexShader:Vt,fragmentShader:It}),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 _t(n,t){return n.map(e=>{const i=[];let s;return e.forEach(a=>{if(s){const c=E.geoDistance(a,s)*180/Math.PI;if(c>t){const r=E.geoInterpolate(s,a),l=1/Math.ceil(c/t);let o=l;for(;o<1;)i.push(r(o)),o+=l}}i.push(s=a)}),i})}function Ot(n,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const a=Math.round(tt(360/n,2)/Math.PI),c=(1+Math.sqrt(5))/2,r=u=>u/c*360%360-180,l=u=>Math.acos(2*u/a-1)/Math.PI*180-90,o=u=>a*(Math.cos((u+90)*Math.PI/180)+1)/2,d=[s!==void 0?Math.ceil(o(s)):0,i!==void 0?Math.floor(o(i)):a-1],f=t===void 0&&e===void 0?()=>!0:t===void 0?u=>u<=e:e===void 0?u=>u>=t:e>=t?u=>u>=t&&u<=e:u=>u>=t||u<=e,m=[];for(let u=d[0];u<=d[1];u++){const v=r(u);f(v)&&m.push([v,l(u)])}return m}function X(n,t,e=!1){return e?E.geoContains(t,n):wt(n,t)}function Lt(n,t){const e={type:"Polygon",coordinates:n},[[i,s],[a,c]]=E.geoBounds(e);if(Math.min(Math.abs(a-i),Math.abs(c-s))<t)return[];const r=i>a||c>=89||s<=-89;return Ot(t,{minLng:i,maxLng:a,minLat:s,maxLat:c}).filter(l=>X(l,e,r))}function Wt(n,{resolution:t=1/0,bbox:e,projection:i}={}){const s=_t(n,t),a=W.merge(s),c=Lt(n,t),r=[...a,...c],l={type:"Polygon",coordinates:n},[[o,d],[f,m]]=E.geoBounds(l),u=o>f||m>=89||d<=-89;let v=[];if(u){const b=Pt.geoVoronoi(r).triangles(),P=new Map(r.map(([A,S],O)=>[`${A}-${S}`,O]));b.features.forEach(A=>{const S=A.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(S.forEach(([C,F])=>{const G=`${C}-${F}`;P.has(G)&&O.push(P.get(G))}),O.length===3){if(O.some(C=>C<a.length)){const C=A.properties.circumcenter;if(!X(C,l,u))return}v.push(...O)}})}else if(c.length){const b=Mt.from(r);for(let P=0,A=b.triangles.length;P<A;P+=3){const S=[2,1,0].map(C=>b.triangles[P+C]),O=S.map(C=>r[C]);if(S.some(C=>C<a.length)){const C=[0,1].map(F=>W.mean(O,G=>G[F]));if(!X(C,l,u))continue}v.push(...S)}}else{const{vertices:b,holes:P=[]}=K.flatten(s);v=K(b,P,2)}let p=e?[e[0],e[2]]:W.extent(r,b=>b[0]),y=e?[e[1],e[3]]:W.extent(r,b=>b[1]);if(i){const[b,P]=i([p[0],y[0]]),[A,S]=i([p[1],y[1]]);p=[b,A],y=[-P,-S]}const D=st.scaleLinear(p,[0,1]),z=st.scaleLinear(y,[0,1]),V=r.map(([b,P])=>{if(i){const[A,S]=i([b,P]);return[D(A),z(-S)]}else return[D(b),z(P)]});return{contour:s,triangles:{points:r,indices:v,uvs:V}}}const ct=new h.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(n,t,e,i){const s=n.map(a=>a.map(([c,r])=>{if(i){const[l,o]=i([c,r]);return[l,-o,t]}return e?H.polar2Cartesian(c,r,t):[c,r,t]}));return K.flatten(s)}function Bt(n,t,e,i,s){const{vertices:a,holes:c}=q(n,t,i,s),{vertices:r}=q(n,e,i,s),l=W.merge([r,a]),o=Math.round(r.length/3),d=new Set(c);let f=0;const m=[];for(let v=0;v<o;v++){let p=v+1;if(p===o)p=f;else if(d.has(p)){const y=p;p=f,f=y}m.push(v,v+o,p+o),m.push(p+o,p,v)}const u=[];for(let v=1;v>=0;v--)for(let p=0;p<o;p+=1)u.push(p/(o-1),v);return{indices:m,vertices:l,uvs:u,topVerts:r}}function ut(n,t,e,i,s,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:q([n.points],t,s,a).vertices,uvs:e}}const ft=({polygonGeoJson:n,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:c=!1,hasTop:r=!1,projection:l,bbox:o})=>{n.forEach(D=>{xt(D)||D.reverse()});const{contour:d,triangles:f}=Wt(n,{resolution:i,bbox:o,projection:l});let m={},u;a&&(m=Bt(d,t!=null?t:e,e!=null?e:t,s,l),u=m.topVerts);let v=[];(c||r)&&(v=W.merge(f.uvs));let p={};c&&(p=ut(f,t,v,!1,s,l));let y={};return r&&(y=ut(f,e,v,!0,s,l)),{contour:d,triangles:f,sideTorso:m,bottomCap:p,topCap:y,topVerts:u}};class kt extends h.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({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:c,hasSide:r,cartesian:l,userDataRsoOffset:o,projection:d}=this.parameters,{contour:f,sideTorso:m,topVerts:u,bottomCap:v,topCap:p}=ft(k({},this.parameters));let y=[],D=[],z=[],V=0;const j=b=>{const P=Math.round(y.length/3),A=z.length;y=y.concat(b.vertices),D=D.concat(b.uvs),z=z.concat(P?b.indices.map(S=>S+P):b.indices),this.addGroup(A,z.length-A,V++)};s&&a&&j(p),r&&(j(m),this.userData.topVerts=o?q(f,i+o,l,d).vertices:u),c&&j(v),s&&!a&&j(p),this.setIndex(z),this[ct]("position",new h.Float32BufferAttribute(y,3)),this[ct]("uv",new h.Float32BufferAttribute(D,2)),this.computeVertexNormals()}}exports.BaseObject=ht;exports.Group=St;exports.LineSegments2=zt;exports.MeshLineMaterial=Tt;exports.PolygonGeometry=kt;exports.ResourceTracker=B;exports.getMetas=ft;
149
+ `;class Tt extends h.ShaderMaterial{constructor(t){super({uniforms:Z(k({},h.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new h.Color(16777215)},opacity:{value:1},resolution:{value:new h.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 h.Vector2(1,1)},offset:{value:new h.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new h.Vector2(0,0)},lightColor:{value:new h.Color(16777215)}}),vertexShader:Vt,fragmentShader:It}),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 _t(a,t){return a.map(e=>{const i=[];let s;return e.forEach(n=>{if(s){const c=E.geoDistance(n,s)*180/Math.PI;if(c>t){const r=E.geoInterpolate(s,n),l=1/Math.ceil(c/t);let o=l;for(;o<1;)i.push(r(o)),o+=l}}i.push(s=n)}),i})}function Lt(a,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const n=Math.round(tt(360/a,2)/Math.PI),c=(1+Math.sqrt(5))/2,r=u=>u/c*360%360-180,l=u=>Math.acos(2*u/n-1)/Math.PI*180-90,o=u=>n*(Math.cos((u+90)*Math.PI/180)+1)/2,d=[s!==void 0?Math.ceil(o(s)):0,i!==void 0?Math.floor(o(i)):n-1],f=t===void 0&&e===void 0?()=>!0:t===void 0?u=>u<=e:e===void 0?u=>u>=t:e>=t?u=>u>=t&&u<=e:u=>u>=t||u<=e,m=[];for(let u=d[0];u<=d[1];u++){const v=r(u);f(v)&&m.push([v,l(u)])}return m}function X(a,t,e=!1){return e?E.geoContains(t,a):wt(a,t)}function Wt(a,t){const e={type:"Polygon",coordinates:a},[[i,s],[n,c]]=E.geoBounds(e);if(Math.min(Math.abs(n-i),Math.abs(c-s))<t)return[];const r=i>n||c>=89||s<=-89;return Lt(t,{minLng:i,maxLng:n,minLat:s,maxLat:c}).filter(l=>X(l,e,r))}function Bt(a,{resolution:t=1/0,bbox:e,projection:i}={}){const s=_t(a,t),n=B.merge(s),c=Wt(a,t),r=[...n,...c],l={type:"Polygon",coordinates:a},[[o,d],[f,m]]=E.geoBounds(l),u=o>f||m>=89||d<=-89;let v=[];if(u){const b=Pt.geoVoronoi(r).triangles(),P=new Map(r.map(([A,S],L)=>[`${A}-${S}`,L]));b.features.forEach(A=>{const S=A.geometry.coordinates[0].slice(0,3).reverse(),L=[];if(S.forEach(([C,F])=>{const G=`${C}-${F}`;P.has(G)&&L.push(P.get(G))}),L.length===3){if(L.some(C=>C<n.length)){const C=A.properties.circumcenter;if(!X(C,l,u))return}v.push(...L)}})}else if(c.length){const b=Mt.from(r);for(let P=0,A=b.triangles.length;P<A;P+=3){const S=[2,1,0].map(C=>b.triangles[P+C]),L=S.map(C=>r[C]);if(S.some(C=>C<n.length)){const C=[0,1].map(F=>B.mean(L,G=>G[F]));if(!X(C,l,u))continue}v.push(...S)}}else{const{vertices:b,holes:P=[]}=K.flatten(s);v=K(b,P,2)}let p=e?[e[0],e[2]]:B.extent(r,b=>b[0]),y=e?[e[1],e[3]]:B.extent(r,b=>b[1]);if(i){const[b,P]=i([p[0],y[0]]),[A,S]=i([p[1],y[1]]);p=[b,A],y=[-P,-S]}const D=st.scaleLinear(p,[0,1]),z=st.scaleLinear(y,[0,1]),V=r.map(([b,P])=>{if(i){const[A,S]=i([b,P]);return[D(A),z(-S)]}else return[D(b),z(P)]});return{contour:s,triangles:{points:r,indices:v,uvs:V}}}const ct=new h.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(a,t,e,i){const s=a.map(n=>n.map(([c,r])=>{if(i){const[l,o]=i([c,r]);return[l,-o,t]}return e?H.polar2Cartesian(c,r,t):[c,r,t]}));return K.flatten(s)}function Ot(a,t,e,i,s){const{vertices:n,holes:c}=q(a,t,i,s),{vertices:r}=q(a,e,i,s),l=B.merge([r,n]),o=Math.round(r.length/3),d=new Set(c);let f=0;const m=[];for(let v=0;v<o;v++){let p=v+1;if(p===o)p=f;else if(d.has(p)){const y=p;p=f,f=y}m.push(v,v+o,p+o),m.push(p+o,p,v)}const u=[];for(let v=1;v>=0;v--)for(let p=0;p<o;p+=1)u.push(p/(o-1),v);return{indices:m,vertices:l,uvs:u,topVerts:r}}function ut(a,t,e,i,s,n){return{indices:i?a.indices:a.indices.slice().reverse(),vertices:q([a.points],t,s,n).vertices,uvs:e}}const ft=({polygonGeoJson:a,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:n=!0,hasBottom:c=!1,hasTop:r=!1,projection:l,bbox:o})=>{a.forEach(D=>{xt(D)||D.reverse()});const{contour:d,triangles:f}=Bt(a,{resolution:i,bbox:o,projection:l});let m={},u;n&&(m=Ot(d,t!=null?t:e,e!=null?e:t,s,l),u=m.topVerts);let v=[];(c||r)&&(v=B.merge(f.uvs));let p={};c&&(p=ut(f,t,v,!1,s,l));let y={};return r&&(y=ut(f,e,v,!0,s,l)),{contour:d,triangles:f,sideTorso:m,bottomCap:p,topCap:y,topVerts:u}};class kt extends h.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({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:n,hasBottom:c,hasSide:r,cartesian:l,userDataRsoOffset:o,projection:d}=this.parameters,{contour:f,sideTorso:m,topVerts:u,bottomCap:v,topCap:p}=ft(k({},this.parameters));let y=[],D=[],z=[],V=0;const j=b=>{const P=Math.round(y.length/3),A=z.length;y=y.concat(b.vertices),D=D.concat(b.uvs),z=z.concat(P?b.indices.map(S=>S+P):b.indices),this.addGroup(A,z.length-A,V++)};s&&n&&j(p),r&&(j(m),this.userData.topVerts=o?q(f,i+o,l,d).vertices:u),c&&j(v),s&&!n&&j(p),this.setIndex(z),this[ct]("position",new h.Float32BufferAttribute(y,3)),this[ct]("uv",new h.Float32BufferAttribute(D,2)),this.computeVertexNormals()}}exports.BaseObject=ht;exports.Group=St;exports.LineSegments2=zt;exports.MeshLineMaterial=Tt;exports.PolygonGeometry=kt;exports.ResourceTracker=O;exports.getMetas=ft;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.14.26",
3
+ "version": "0.14.27",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",