gl-draw 0.14.28 → 0.14.29

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.
@@ -53,6 +53,7 @@ export default class BaseObject extends ResourceTracker {
53
53
  key?: string;
54
54
  target?: IBaseObject;
55
55
  create?: ((...args: any[]) => any) | boolean;
56
+ recursive?: boolean;
56
57
  }): Promise<this>;
57
58
  private setInstancedMatrix;
58
59
  erase(): void;
@@ -11,20 +11,20 @@ var H = Math.pow, Y = (a, t, e) => t in a ? dt(a, t, { enumerable: !0, configura
11
11
  return a;
12
12
  }, Z = (a, t) => pt(a, mt(t));
13
13
  var J = (a, t, e) => new Promise((i, s) => {
14
- var r = (l) => {
14
+ var n = (l) => {
15
15
  try {
16
- n(e.next(l));
17
- } catch (o) {
18
- s(o);
16
+ r(e.next(l));
17
+ } catch (c) {
18
+ s(c);
19
19
  }
20
- }, c = (l) => {
20
+ }, o = (l) => {
21
21
  try {
22
- n(e.throw(l));
23
- } catch (o) {
24
- s(o);
22
+ r(e.throw(l));
23
+ } catch (c) {
24
+ s(c);
25
25
  }
26
- }, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(r, c);
27
- n((e = e.apply(a, t)).next());
26
+ }, r = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(n, o);
27
+ r((e = e.apply(a, t)).next());
28
28
  });
29
29
  import * as h from "three";
30
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";
@@ -102,10 +102,10 @@ const Et = (a, t = 1) => {
102
102
  alphaTest: i.alphaTest,
103
103
  sizeAttenuation: !1
104
104
  });
105
- return s.onBeforeCompile = (r) => {
106
- r.vertexShader = `
105
+ return s.onBeforeCompile = (n) => {
106
+ n.vertexShader = `
107
107
  attribute float scaleAtt;
108
- ${r.vertexShader.replace(
108
+ ${n.vertexShader.replace(
109
109
  "gl_PointSize = size;",
110
110
  "gl_PointSize = size * scaleAtt;"
111
111
  )}
@@ -213,57 +213,58 @@ class Rt extends V {
213
213
  }
214
214
  instantiate(t, e) {
215
215
  return J(this, null, function* () {
216
- const i = t && t.length > 0, { objectType: s, objectOptions: r } = this, [, c] = s.split("#");
217
- let n = e == null ? void 0 : e.create;
218
- n === void 0 && (n = (o) => {
219
- var d;
216
+ var m;
217
+ const i = t && t.length > 0, s = (m = e == null ? void 0 : e.recursive) != null ? m : !0, { objectType: n, objectOptions: o } = this, [, r] = n.split("#");
218
+ let l = e == null ? void 0 : e.create;
219
+ l === void 0 && (l = (u) => {
220
+ var v;
220
221
  if (this.object3d) {
221
222
  if (i) {
222
223
  const f = t.length;
223
224
  if (this.object3d instanceof h.Sprite)
224
- o.object3d = Et(this.object3d, f);
225
+ u.object3d = Et(this.object3d, f);
225
226
  else {
226
- const u = this.object3d;
227
- o.object3d = new h.InstancedMesh(
228
- u.geometry,
229
- u.material,
227
+ const d = this.object3d;
228
+ u.object3d = new h.InstancedMesh(
229
+ d.geometry,
230
+ d.material,
230
231
  f
231
- ), o.setMaterialList("instantiate", "clone"), o.useMaterial("instantiate");
232
+ ), u.setMaterialList("instantiate", "clone"), u.useMaterial("instantiate");
232
233
  }
233
- const m = new h.Object3D();
234
- t.forEach((u, v) => {
235
- const p = et(u.position), b = et(u.scale || [1, 1, 1]);
236
- m.position.copy(p), m.scale.copy(b), m.updateMatrix(), o.setInstancedMatrix(v, m.matrix.clone());
234
+ const p = new h.Object3D();
235
+ t.forEach((d, b) => {
236
+ const P = et(d.position), z = et(d.scale || [1, 1, 1]);
237
+ p.position.copy(P), p.scale.copy(z), p.updateMatrix(), u.setInstancedMatrix(b, p.matrix.clone());
237
238
  });
238
239
  } else
239
- o.object3d = this.object3d.clone(!1), o.setMaterialList("instantiate", "clone"), o.useMaterial("instantiate");
240
- o.object3d.userData.bloom && ((d = this.pencil.composerController) == null || d.toggleBloomSelection(
241
- o.object3d,
240
+ u.object3d = this.object3d.clone(!1), u.setMaterialList("instantiate", "clone"), u.useMaterial("instantiate");
241
+ u.object3d.userData.bloom && ((v = this.pencil.composerController) == null || v.toggleBloomSelection(
242
+ u.object3d,
242
243
  !0
243
- )), o.object3d.userData.prefab && (o.object3d.userData.prefab = !1);
244
+ )), u.object3d.userData.prefab && (u.object3d.userData.prefab = !1);
244
245
  }
245
246
  });
246
- const l = yield this.lead.draw(c, Z(O({}, r || {}), {
247
- create: n,
247
+ const c = yield this.lead.draw(r, Z(O({}, o || {}), {
248
+ create: l,
248
249
  prefab: !1,
249
- key: (e == null ? void 0 : e.key) || (r == null ? void 0 : r.key),
250
- target: (e == null ? void 0 : e.target) || (r == null ? void 0 : r.target)
250
+ key: (e == null ? void 0 : e.key) || (o == null ? void 0 : o.key),
251
+ target: (e == null ? void 0 : e.target) || (o == null ? void 0 : o.target)
251
252
  }));
252
- return yield Promise.all(
253
+ return s && (yield Promise.all(
253
254
  this.children.map(
254
- (o) => o.instantiate(void 0, {
255
- target: l
255
+ (u) => u.instantiate(void 0, {
256
+ target: c
256
257
  })
257
258
  )
258
- ), l.isInstantiate = !0, l;
259
+ )), c.isInstantiate = !0, c;
259
260
  });
260
261
  }
261
262
  setInstancedMatrix(t, e) {
262
263
  if (this.object3d instanceof h.InstancedMesh || this.object3d.isInstantiate)
263
264
  this.object3d.setMatrixAt(t, e);
264
265
  else if (this.object3d instanceof h.Points || this.object3d.type === "Points") {
265
- const s = this.object3d.geometry, r = s.attributes.position.array, c = s.attributes.scaleAtt.array, n = new h.Vector3(), l = new h.Vector3(), o = new h.Quaternion(), d = t * 3, f = t * 1;
266
- e.decompose(n, o, l), r[d] = n.x, r[d + 1] = n.y, r[d + 2] = n.z, c[f] = Math.max(l.x, l.y, l.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
266
+ const s = this.object3d.geometry, n = s.attributes.position.array, o = s.attributes.scaleAtt.array, r = new h.Vector3(), l = new h.Vector3(), c = new h.Quaternion(), m = t * 3, u = t * 1;
267
+ e.decompose(r, c, l), n[m] = r.x, n[m + 1] = r.y, n[m + 2] = r.z, o[u] = Math.max(l.x, l.y, l.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
267
268
  }
268
269
  }
269
270
  erase() {
@@ -278,8 +279,8 @@ class Rt extends V {
278
279
  return e.map((i) => {
279
280
  const s = i.userData;
280
281
  i.userData = {};
281
- const r = i.clone();
282
- return i.userData = s, r;
282
+ const n = i.clone();
283
+ return i.userData = s, n;
283
284
  });
284
285
  {
285
286
  const i = e.userData;
@@ -294,12 +295,12 @@ class Rt extends V {
294
295
  return;
295
296
  if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t])
296
297
  if (i) {
297
- const c = this.materialList[t], n = new V();
298
- n.track(c), n.dispose();
298
+ const o = this.materialList[t], r = new V();
299
+ r.track(o), r.dispose();
299
300
  } else
300
301
  return this.materialList[t];
301
- const r = e === "clone" ? this.cloneMaterial() : e;
302
- return this.materialList[t] = r, r;
302
+ const n = e === "clone" ? this.cloneMaterial() : e;
303
+ return this.materialList[t] = n, n;
303
304
  }
304
305
  useMaterial(t) {
305
306
  const e = this.object3d;
@@ -326,55 +327,55 @@ class fe extends Rt {
326
327
  this.createGroup();
327
328
  }
328
329
  }
329
- const $ = new k(), nt = new B(), rt = new B(), y = new k(), x = new k(), I = new k(), q = new B(), N = new bt(), M = new yt(), at = new B(), R = new xt(), U = new Mt(), T = new k();
330
+ const $ = new k(), rt = new B(), nt = new B(), y = new k(), x = new k(), I = new k(), q = new B(), N = new bt(), M = new yt(), at = new B(), R = new xt(), U = new Mt(), T = new k();
330
331
  let W, L;
331
332
  function ot(a, t, e) {
332
333
  return T.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = L / e.width, T.y = L / e.height, T.applyMatrix4(a.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
333
334
  }
334
335
  function Ut(a, t) {
335
- const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, r = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
336
- for (let n = 0, l = c; n < l; n++) {
337
- M.start.fromBufferAttribute(s, n), M.end.fromBufferAttribute(r, n), M.applyMatrix4(e);
338
- const o = new B(), d = new B();
339
- W.distanceSqToSegment(M.start, M.end, d, o), d.distanceTo(o) < L * 0.5 && t.push({
340
- point: d,
341
- pointOnLine: o,
342
- distance: W.origin.distanceTo(d),
336
+ const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, n = i.attributes.instanceEnd, o = Math.min(i.instanceCount, s.count);
337
+ for (let r = 0, l = o; r < l; r++) {
338
+ M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(n, r), M.applyMatrix4(e);
339
+ const c = new B(), m = new B();
340
+ W.distanceSqToSegment(M.start, M.end, m, c), m.distanceTo(c) < L * 0.5 && t.push({
341
+ point: m,
342
+ pointOnLine: c,
343
+ distance: W.origin.distanceTo(m),
343
344
  object: a,
344
345
  face: null,
345
- faceIndex: n,
346
+ faceIndex: r,
346
347
  uv: null,
347
348
  uv1: null
348
349
  });
349
350
  }
350
351
  }
351
352
  function Gt(a, t, e) {
352
- const i = t.projectionMatrix, r = a.material.resolution, c = a.matrixWorld, n = a.geometry, l = n.attributes.instanceStart, o = n.attributes.instanceEnd, d = Math.min(n.instanceCount, l.count), f = -t.near;
353
- W.at(1, I), I.w = 1, I.applyMatrix4(t.matrixWorldInverse), I.applyMatrix4(i), I.multiplyScalar(1 / I.w), I.x *= r.x / 2, I.y *= r.y / 2, I.z = 0, q.copy(I), N.multiplyMatrices(t.matrixWorldInverse, c);
354
- for (let m = 0, u = d; m < u; m++) {
355
- if (y.fromBufferAttribute(l, m), x.fromBufferAttribute(o, m), y.w = 1, x.w = 1, y.applyMatrix4(N), x.applyMatrix4(N), y.z > f && x.z > f)
353
+ const i = t.projectionMatrix, n = a.material.resolution, o = a.matrixWorld, r = a.geometry, l = r.attributes.instanceStart, c = r.attributes.instanceEnd, m = Math.min(r.instanceCount, l.count), u = -t.near;
354
+ W.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, q.copy(I), N.multiplyMatrices(t.matrixWorldInverse, o);
355
+ for (let v = 0, f = m; v < f; v++) {
356
+ if (y.fromBufferAttribute(l, v), x.fromBufferAttribute(c, v), y.w = 1, x.w = 1, y.applyMatrix4(N), x.applyMatrix4(N), y.z > u && x.z > u)
356
357
  continue;
357
- if (y.z > f) {
358
- const D = y.z - x.z, P = (y.z - f) / D;
359
- y.lerp(x, P);
360
- } else if (x.z > f) {
361
- const D = x.z - y.z, P = (x.z - f) / D;
362
- x.lerp(y, P);
358
+ if (y.z > u) {
359
+ const D = y.z - x.z, A = (y.z - u) / D;
360
+ y.lerp(x, A);
361
+ } else if (x.z > u) {
362
+ const D = x.z - y.z, A = (x.z - u) / D;
363
+ x.lerp(y, A);
363
364
  }
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;
365
- const p = M.closestPointToPointParameter(q, !0);
366
- M.at(p, at);
367
- const b = At.lerp(y.z, x.z, p), C = b >= -1 && b <= 1, z = q.distanceTo(at) < L * 0.5;
368
- if (C && z) {
369
- M.start.fromBufferAttribute(l, m), M.end.fromBufferAttribute(o, m), M.start.applyMatrix4(c), M.end.applyMatrix4(c);
370
- const D = new B(), P = new B();
371
- W.distanceSqToSegment(M.start, M.end, P, D), e.push({
372
- point: P,
365
+ y.applyMatrix4(i), x.applyMatrix4(i), y.multiplyScalar(1 / y.w), x.multiplyScalar(1 / x.w), y.x *= n.x / 2, y.y *= n.y / 2, x.x *= n.x / 2, x.y *= n.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(x), M.end.z = 0;
366
+ const d = M.closestPointToPointParameter(q, !0);
367
+ M.at(d, at);
368
+ const b = At.lerp(y.z, x.z, d), P = b >= -1 && b <= 1, z = q.distanceTo(at) < L * 0.5;
369
+ if (P && z) {
370
+ M.start.fromBufferAttribute(l, v), M.end.fromBufferAttribute(c, v), M.start.applyMatrix4(o), M.end.applyMatrix4(o);
371
+ const D = new B(), A = new B();
372
+ W.distanceSqToSegment(M.start, M.end, A, D), e.push({
373
+ point: A,
373
374
  pointOnLine: D,
374
- distance: W.origin.distanceTo(P),
375
+ distance: W.origin.distanceTo(A),
375
376
  object: a,
376
377
  face: null,
377
- faceIndex: m,
378
+ faceIndex: v,
378
379
  uv: null,
379
380
  uv1: null
380
381
  });
@@ -388,19 +389,19 @@ class de extends wt {
388
389
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
389
390
  computeLineDistances() {
390
391
  const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
391
- for (let c = 0, n = 0, l = e.count; c < l; c++, n += 2)
392
- nt.fromBufferAttribute(e, c), rt.fromBufferAttribute(i, c), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + nt.distanceTo(rt);
393
- const r = new Pt(
392
+ for (let o = 0, r = 0, l = e.count; o < l; o++, r += 2)
393
+ rt.fromBufferAttribute(e, o), nt.fromBufferAttribute(i, o), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + rt.distanceTo(nt);
394
+ const n = new Pt(
394
395
  s,
395
396
  2,
396
397
  1
397
398
  );
398
399
  return t.setAttribute(
399
400
  "instanceDistanceStart",
400
- new tt(r, 1, 0)
401
+ new tt(n, 1, 0)
401
402
  ), t.setAttribute(
402
403
  "instanceDistanceEnd",
403
- new tt(r, 1, 1)
404
+ new tt(n, 1, 1)
404
405
  ), this;
405
406
  }
406
407
  raycast(t, e) {
@@ -408,42 +409,42 @@ class de extends wt {
408
409
  s === null && !i && console.error(
409
410
  'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
410
411
  );
411
- const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
412
+ const n = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
412
413
  W = t.ray;
413
- const c = this.matrixWorld, n = this.geometry, l = this.material;
414
- L = l.linewidth + r, n.boundingSphere === null && n.computeBoundingSphere(), U.copy(n.boundingSphere).applyMatrix4(c);
415
- let o;
414
+ const o = this.matrixWorld, r = this.geometry, l = this.material;
415
+ L = l.linewidth + n, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(o);
416
+ let c;
416
417
  if (i)
417
- o = L * 0.5;
418
+ c = L * 0.5;
418
419
  else {
419
- const f = Math.max(
420
+ const u = Math.max(
420
421
  s.near,
421
422
  U.distanceToPoint(W.origin)
422
423
  );
423
- o = ot(
424
+ c = ot(
424
425
  s,
425
- f,
426
+ u,
426
427
  l.resolution
427
428
  );
428
429
  }
429
- if (U.radius += o, W.intersectsSphere(U) === !1)
430
+ if (U.radius += c, W.intersectsSphere(U) === !1)
430
431
  return;
431
- n.boundingBox === null && n.computeBoundingBox(), R.copy(n.boundingBox).applyMatrix4(c);
432
- let d;
432
+ r.boundingBox === null && r.computeBoundingBox(), R.copy(r.boundingBox).applyMatrix4(o);
433
+ let m;
433
434
  if (i)
434
- d = L * 0.5;
435
+ m = L * 0.5;
435
436
  else {
436
- const f = Math.max(
437
+ const u = Math.max(
437
438
  s.near,
438
439
  R.distanceToPoint(W.origin)
439
440
  );
440
- d = ot(
441
+ m = ot(
441
442
  s,
442
- f,
443
+ u,
443
444
  l.resolution
444
445
  );
445
446
  }
446
- R.expandByScalar(d), W.intersectsBox(R) !== !1 && (i ? Ut(this, e) : Gt(this, s, e));
447
+ R.expandByScalar(m), W.intersectsBox(R) !== !1 && (i ? Ut(this, e) : Gt(this, s, e));
447
448
  }
448
449
  onBeforeRender(t) {
449
450
  const e = this.material.uniforms;
@@ -862,160 +863,160 @@ function $t(a, t) {
862
863
  return a.map((e) => {
863
864
  const i = [];
864
865
  let s;
865
- return e.forEach((r) => {
866
+ return e.forEach((n) => {
866
867
  if (s) {
867
- const c = Dt(r, s) * 180 / Math.PI;
868
- if (c > t) {
869
- const n = It(s, r), l = 1 / Math.ceil(c / t);
870
- let o = l;
871
- for (; o < 1; )
872
- i.push(n(o)), o += l;
868
+ const o = Dt(n, s) * 180 / Math.PI;
869
+ if (o > t) {
870
+ const r = It(s, n), l = 1 / Math.ceil(o / t);
871
+ let c = l;
872
+ for (; c < 1; )
873
+ i.push(r(c)), c += l;
873
874
  }
874
875
  }
875
- i.push(s = r);
876
+ i.push(s = n);
876
877
  }), i;
877
878
  });
878
879
  }
879
880
  function qt(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
880
- const r = Math.round(H(360 / a, 2) / Math.PI), c = (1 + Math.sqrt(5)) / 2, n = (u) => u / c * 360 % 360 - 180, l = (u) => Math.acos(2 * u / r - 1) / Math.PI * 180 - 90, o = (u) => r * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, d = [
881
- s !== void 0 ? Math.ceil(o(s)) : 0,
882
- i !== void 0 ? Math.floor(o(i)) : r - 1
883
- ], 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 = [];
884
- for (let u = d[0]; u <= d[1]; u++) {
885
- const v = n(u);
886
- f(v) && m.push([v, l(u)]);
881
+ const n = Math.round(H(360 / a, 2) / Math.PI), o = (1 + Math.sqrt(5)) / 2, r = (f) => f / o * 360 % 360 - 180, l = (f) => Math.acos(2 * f / n - 1) / Math.PI * 180 - 90, c = (f) => n * (Math.cos((f + 90) * Math.PI / 180) + 1) / 2, m = [
882
+ s !== void 0 ? Math.ceil(c(s)) : 0,
883
+ i !== void 0 ? Math.floor(c(i)) : n - 1
884
+ ], u = 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 = [];
885
+ for (let f = m[0]; f <= m[1]; f++) {
886
+ const p = r(f);
887
+ u(p) && v.push([p, l(f)]);
887
888
  }
888
- return m;
889
+ return v;
889
890
  }
890
891
  function Q(a, t, e = !1) {
891
892
  return e ? zt(t, a) : Vt(a, t);
892
893
  }
893
894
  function Nt(a, t) {
894
- const e = { type: "Polygon", coordinates: a }, [[i, s], [r, c]] = ht(e);
895
- if (Math.min(Math.abs(r - i), Math.abs(c - s)) < t)
895
+ const e = { type: "Polygon", coordinates: a }, [[i, s], [n, o]] = ht(e);
896
+ if (Math.min(Math.abs(n - i), Math.abs(o - s)) < t)
896
897
  return [];
897
- const n = i > r || c >= 89 || s <= -89;
898
+ const r = i > n || o >= 89 || s <= -89;
898
899
  return qt(t, {
899
900
  minLng: i,
900
- maxLng: r,
901
+ maxLng: n,
901
902
  minLat: s,
902
- maxLat: c
903
+ maxLat: o
903
904
  }).filter(
904
- (l) => Q(l, e, n)
905
+ (l) => Q(l, e, r)
905
906
  );
906
907
  }
907
908
  function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
908
- const s = $t(a, t), r = K(s), c = Nt(a, t), n = [...r, ...c], l = { type: "Polygon", coordinates: a }, [[o, d], [f, m]] = ht(l), u = o > f || // crosses antimeridian
909
- m >= 89 || // crosses north pole
910
- d <= -89;
911
- let v = [];
912
- if (u) {
913
- const g = kt(n).triangles(), w = new Map(
914
- n.map(([A, j], _) => [`${A}-${j}`, _])
909
+ const s = $t(a, t), n = K(s), o = Nt(a, t), r = [...n, ...o], l = { type: "Polygon", coordinates: a }, [[c, m], [u, v]] = ht(l), f = c > u || // crosses antimeridian
910
+ v >= 89 || // crosses north pole
911
+ m <= -89;
912
+ let p = [];
913
+ if (f) {
914
+ const g = kt(r).triangles(), w = new Map(
915
+ r.map(([j, S], _) => [`${j}-${S}`, _])
915
916
  );
916
- g.features.forEach((A) => {
917
- const j = A.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
918
- if (j.forEach(([S, F]) => {
919
- const E = `${S}-${F}`;
917
+ g.features.forEach((j) => {
918
+ const S = j.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
919
+ if (S.forEach(([C, F]) => {
920
+ const E = `${C}-${F}`;
920
921
  w.has(E) && _.push(w.get(E));
921
922
  }), _.length === 3) {
922
- if (_.some((S) => S < r.length)) {
923
- const S = A.properties.circumcenter;
923
+ if (_.some((C) => C < n.length)) {
924
+ const C = j.properties.circumcenter;
924
925
  if (!Q(
925
- S,
926
+ C,
926
927
  l,
927
- u
928
+ f
928
929
  ))
929
930
  return;
930
931
  }
931
- v.push(..._);
932
+ p.push(..._);
932
933
  }
933
934
  });
934
- } else if (c.length) {
935
- const g = Ot.from(n);
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)) {
939
- const S = [0, 1].map(
935
+ } else if (o.length) {
936
+ const g = Ot.from(r);
937
+ for (let w = 0, j = g.triangles.length; w < j; w += 3) {
938
+ const S = [2, 1, 0].map((C) => g.triangles[w + C]), _ = S.map((C) => r[C]);
939
+ if (S.some((C) => C < n.length)) {
940
+ const C = [0, 1].map(
940
941
  (F) => _t(_, (E) => E[F])
941
942
  );
942
943
  if (!Q(
943
- S,
944
+ C,
944
945
  l,
945
- u
946
+ f
946
947
  ))
947
948
  continue;
948
949
  }
949
- v.push(...j);
950
+ p.push(...S);
950
951
  }
951
952
  } else {
952
953
  const { vertices: g, holes: w = [] } = ft(s);
953
- v = Bt(g, w, 2);
954
+ p = Bt(g, w, 2);
954
955
  }
955
- let p = e ? [e[0], e[2]] : it(n, (g) => g[0]), b = e ? [e[1], e[3]] : it(n, (g) => g[1]);
956
+ let d = e ? [e[0], e[2]] : it(r, (g) => g[0]), b = e ? [e[1], e[3]] : it(r, (g) => g[1]);
956
957
  if (i) {
957
- const [g, w] = i([p[0], b[0]]), [A, j] = i([p[1], b[1]]);
958
- p = [g, A], b = [-w, -j];
958
+ const [g, w] = i([d[0], b[0]]), [j, S] = i([d[1], b[1]]);
959
+ d = [g, j], b = [-w, -S];
959
960
  }
960
- const C = st(p, [0, 1]), z = st(b, [0, 1]), D = n.map(([g, w]) => {
961
+ const P = st(d, [0, 1]), z = st(b, [0, 1]), D = r.map(([g, w]) => {
961
962
  if (i) {
962
- const [A, j] = i([g, w]);
963
- return [C(A), z(-j)];
963
+ const [j, S] = i([g, w]);
964
+ return [P(j), z(-S)];
964
965
  } else
965
- return [C(g), z(w)];
966
+ return [P(g), z(w)];
966
967
  });
967
- return { contour: s, triangles: { points: n, indices: v, uvs: D } };
968
+ return { contour: s, triangles: { points: r, indices: p, uvs: D } };
968
969
  }
969
970
  const ct = new h.BufferGeometry().setAttribute ? "setAttribute" : "addAttribute";
970
971
  function G(a, t, e, i) {
971
972
  const s = a.map(
972
- (r) => r.map(([c, n]) => {
973
+ (n) => n.map(([o, r]) => {
973
974
  if (i) {
974
- const [l, o] = i([c, n]);
975
- return [l, -o, t];
975
+ const [l, c] = i([o, r]);
976
+ return [l, -c, t];
976
977
  }
977
- return e ? Tt(c, n, t) : [c, n, t];
978
+ return e ? Tt(o, r, t) : [o, r, t];
978
979
  })
979
980
  );
980
981
  return ft(s);
981
982
  }
982
983
  function Kt(a, t, e, i, s) {
983
- const { vertices: r, holes: c } = G(
984
+ const { vertices: n, holes: o } = G(
984
985
  a,
985
986
  t,
986
987
  i,
987
988
  s
988
- ), { vertices: n } = G(
989
+ ), { vertices: r } = G(
989
990
  a,
990
991
  e,
991
992
  i,
992
993
  s
993
- ), l = K([n, r]), o = Math.round(n.length / 3), d = new Set(c);
994
- let f = 0;
995
- const m = [];
996
- for (let v = 0; v < o; v++) {
997
- let p = v + 1;
998
- if (p === o)
999
- p = f;
1000
- else if (d.has(p)) {
1001
- const b = p;
1002
- p = f, f = b;
994
+ ), l = K([r, n]), c = Math.round(r.length / 3), m = new Set(o);
995
+ let u = 0;
996
+ const v = [];
997
+ for (let p = 0; p < c; p++) {
998
+ let d = p + 1;
999
+ if (d === c)
1000
+ d = u;
1001
+ else if (m.has(d)) {
1002
+ const b = d;
1003
+ d = u, u = b;
1003
1004
  }
1004
- m.push(v, v + o, p + o), m.push(p + o, p, v);
1005
+ v.push(p, p + c, d + c), v.push(d + c, d, p);
1005
1006
  }
1006
- const u = [];
1007
- for (let v = 1; v >= 0; v--)
1008
- for (let p = 0; p < o; p += 1) u.push(p / (o - 1), v);
1009
- return { indices: m, vertices: l, uvs: u, topVerts: n };
1007
+ const f = [];
1008
+ for (let p = 1; p >= 0; p--)
1009
+ for (let d = 0; d < c; d += 1) f.push(d / (c - 1), p);
1010
+ return { indices: v, vertices: l, uvs: f, topVerts: r };
1010
1011
  }
1011
- function ut(a, t, e, i, s, r) {
1012
+ function ut(a, t, e, i, s, n) {
1012
1013
  return {
1013
1014
  indices: i ? a.indices : a.indices.slice().reverse(),
1014
1015
  vertices: G(
1015
1016
  [a.points],
1016
1017
  t,
1017
1018
  s,
1018
- r
1019
+ n
1019
1020
  ).vertices,
1020
1021
  uvs: e
1021
1022
  };
@@ -1026,48 +1027,48 @@ const Xt = ({
1026
1027
  endHeight: e,
1027
1028
  curvatureResolution: i = 1,
1028
1029
  cartesian: s = !0,
1029
- hasSide: r = !0,
1030
- hasBottom: c = !1,
1031
- hasTop: n = !1,
1030
+ hasSide: n = !0,
1031
+ hasBottom: o = !1,
1032
+ hasTop: r = !1,
1032
1033
  projection: l,
1033
- bbox: o
1034
+ bbox: c
1034
1035
  }) => {
1035
- a.forEach((C) => {
1036
- Lt(C) || C.reverse();
1036
+ a.forEach((P) => {
1037
+ Lt(P) || P.reverse();
1037
1038
  });
1038
- const { contour: d, triangles: f } = Qt(a, {
1039
+ const { contour: m, triangles: u } = Qt(a, {
1039
1040
  resolution: i,
1040
- bbox: o,
1041
+ bbox: c,
1041
1042
  projection: l
1042
1043
  });
1043
- let m = {}, u;
1044
- r && (m = Kt(
1045
- d,
1044
+ let v = {}, f;
1045
+ n && (v = Kt(
1046
+ m,
1046
1047
  t != null ? t : e,
1047
1048
  e != null ? e : t,
1048
1049
  s,
1049
1050
  l
1050
- ), u = m.topVerts);
1051
- let v = [];
1052
- (c || n) && (v = K(f.uvs));
1053
- let p = {};
1054
- c && (p = ut(
1055
- f,
1051
+ ), f = v.topVerts);
1052
+ let p = [];
1053
+ (o || r) && (p = K(u.uvs));
1054
+ let d = {};
1055
+ o && (d = ut(
1056
+ u,
1056
1057
  t,
1057
- v,
1058
+ p,
1058
1059
  !1,
1059
1060
  s,
1060
1061
  l
1061
1062
  ));
1062
1063
  let b = {};
1063
- return n && (b = ut(
1064
- f,
1064
+ return r && (b = ut(
1065
+ u,
1065
1066
  e,
1066
- v,
1067
+ p,
1067
1068
  !0,
1068
1069
  s,
1069
1070
  l
1070
- )), { contour: d, triangles: f, sideTorso: m, bottomCap: p, topCap: b, topVerts: u };
1071
+ )), { contour: m, triangles: u, sideTorso: v, bottomCap: d, topCap: b, topVerts: f };
1071
1072
  };
1072
1073
  class me extends h.BufferGeometry {
1073
1074
  constructor(t, e = {}) {
@@ -1086,29 +1087,29 @@ class me extends h.BufferGeometry {
1086
1087
  const {
1087
1088
  endHeight: i,
1088
1089
  hasTop: s,
1089
- topFirst: r,
1090
- hasBottom: c,
1091
- hasSide: n,
1090
+ topFirst: n,
1091
+ hasBottom: o,
1092
+ hasSide: r,
1092
1093
  cartesian: l,
1093
- userDataRsoOffset: o,
1094
- projection: d
1095
- } = this.parameters, { contour: f, sideTorso: m, topVerts: u, bottomCap: v, topCap: p } = Xt(O({}, this.parameters));
1096
- let b = [], C = [], z = [], D = 0;
1097
- const P = (g) => {
1098
- const w = Math.round(b.length / 3), A = z.length;
1099
- b = b.concat(g.vertices), C = C.concat(g.uvs), z = z.concat(
1100
- w ? g.indices.map((j) => j + w) : g.indices
1101
- ), this.addGroup(A, z.length - A, D++);
1094
+ userDataRsoOffset: c,
1095
+ projection: m
1096
+ } = this.parameters, { contour: u, sideTorso: v, topVerts: f, bottomCap: p, topCap: d } = Xt(O({}, this.parameters));
1097
+ let b = [], P = [], z = [], D = 0;
1098
+ const A = (g) => {
1099
+ const w = Math.round(b.length / 3), j = z.length;
1100
+ b = b.concat(g.vertices), P = P.concat(g.uvs), z = z.concat(
1101
+ w ? g.indices.map((S) => S + w) : g.indices
1102
+ ), this.addGroup(j, z.length - j, D++);
1102
1103
  };
1103
- s && r && P(p), n && (P(m), this.userData.topVerts = o ? G(
1104
- f,
1105
- i + o,
1104
+ s && n && A(d), r && (A(v), this.userData.topVerts = c ? G(
1105
+ u,
1106
+ i + c,
1106
1107
  l,
1107
- d
1108
- ).vertices : u), c && P(v), s && !r && P(p), this.setIndex(z), this[ct](
1108
+ m
1109
+ ).vertices : f), o && A(p), s && !n && A(d), this.setIndex(z), this[ct](
1109
1110
  "position",
1110
1111
  new h.Float32BufferAttribute(b, 3)
1111
- ), this[ct]("uv", new h.Float32BufferAttribute(C, 2)), this.computeVertexNormals();
1112
+ ), this[ct]("uv", new h.Float32BufferAttribute(P, 2)), this.computeVertexNormals();
1112
1113
  }
1113
1114
  }
1114
1115
  export {
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=(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=`
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(c){s(c)}},o=l=>{try{r(e.throw(l))}catch(c){s(c)}},r=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,o);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"),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(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 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=(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=`
2
2
  attribute float scaleAtt;
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.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 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=`
3
+ ${a.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*(){var m;const i=t&&t.length>0,s=(m=e==null?void 0:e.recursive)!=null?m:!0,{objectType:a,objectOptions:o}=this,[,r]=a.split("#");let l=e==null?void 0:e.create;l===void 0&&(l=u=>{var v;if(this.object3d){if(i){const f=t.length;if(this.object3d instanceof h.Sprite)u.object3d=At(this.object3d,f);else{const d=this.object3d;u.object3d=new h.InstancedMesh(d.geometry,d.material,f),u.setMaterialList("instantiate","clone"),u.useMaterial("instantiate")}const p=new h.Object3D;t.forEach((d,y)=>{const j=H.parseVector3(d.position),z=H.parseVector3(d.scale||[1,1,1]);p.position.copy(j),p.scale.copy(z),p.updateMatrix(),u.setInstancedMatrix(y,p.matrix.clone())})}else u.object3d=this.object3d.clone(!1),u.setMaterialList("instantiate","clone"),u.useMaterial("instantiate");u.object3d.userData.bloom&&((v=this.pencil.composerController)==null||v.toggleBloomSelection(u.object3d,!0)),u.object3d.userData.prefab&&(u.object3d.userData.prefab=!1)}});const c=yield this.lead.draw(r,Z(k({},o||{}),{create:l,prefab:!1,key:(e==null?void 0:e.key)||(o==null?void 0:o.key),target:(e==null?void 0:e.target)||(o==null?void 0:o.target)}));return s&&(yield Promise.all(this.children.map(u=>u.instantiate(void 0,{target:c})))),c.isInstantiate=!0,c})}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,o=s.attributes.scaleAtt.array,r=new h.Vector3,l=new h.Vector3,c=new h.Quaternion,m=t*3,u=t*1;e.decompose(r,c,l),a[m]=r.x,a[m+1]=r.y,a[m+2]=r.z,o[u]=Math.max(l.x,l.y,l.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 o=this.materialList[t],r=new O;r.track(o),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 _,W;function ot(n,t,e){return T.set(0,0,-t,1).applyMatrix4(n.projectionMatrix),T.multiplyScalar(1/T.w),T.x=W/e.width,T.y=W/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,o=Math.min(i.instanceCount,s.count);for(let r=0,l=o;r<l;r++){w.start.fromBufferAttribute(s,r),w.end.fromBufferAttribute(a,r),w.applyMatrix4(e);const c=new g.Vector3,m=new g.Vector3;_.distanceSqToSegment(w.start,w.end,m,c),m.distanceTo(c)<W*.5&&t.push({point:m,pointOnLine:c,distance:_.origin.distanceTo(m),object:n,face:null,faceIndex:r,uv:null,uv1:null})}}function Dt(n,t,e){const i=t.projectionMatrix,a=n.material.resolution,o=n.matrixWorld,r=n.geometry,l=r.attributes.instanceStart,c=r.attributes.instanceEnd,m=Math.min(r.instanceCount,l.count),u=-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,o);for(let v=0,f=m;v<f;v++){if(x.fromBufferAttribute(l,v),M.fromBufferAttribute(c,v),x.w=1,M.w=1,x.applyMatrix4(Q),M.applyMatrix4(Q),x.z>u&&M.z>u)continue;if(x.z>u){const V=x.z-M.z,A=(x.z-u)/V;x.lerp(M,A)}else if(M.z>u){const V=M.z-x.z,A=(M.z-u)/V;M.lerp(x,A)}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 d=w.closestPointToPointParameter(N,!0);w.at(d,at);const y=g.MathUtils.lerp(x.z,M.z,d),j=y>=-1&&y<=1,z=N.distanceTo(at)<W*.5;if(j&&z){w.start.fromBufferAttribute(l,v),w.end.fromBufferAttribute(c,v),w.start.applyMatrix4(o),w.end.applyMatrix4(o);const V=new g.Vector3,A=new g.Vector3;_.distanceSqToSegment(w.start,w.end,A,V),e.push({point:A,pointOnLine:V,distance:_.origin.distanceTo(A),object:n,face:null,faceIndex:v,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 o=0,r=0,l=e.count;o<l;o++,r+=2)rt.fromBufferAttribute(e,o),nt.fromBufferAttribute(i,o),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 o=this.matrixWorld,r=this.geometry,l=this.material;W=l.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),U.copy(r.boundingSphere).applyMatrix4(o);let c;if(i)c=W*.5;else{const u=Math.max(s.near,U.distanceToPoint(_.origin));c=ot(s,u,l.resolution)}if(U.radius+=c,_.intersectsSphere(U)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),R.copy(r.boundingBox).applyMatrix4(o);let m;if(i)m=W*.5;else{const u=Math.max(s.near,R.distanceToPoint(_.origin));m=ot(s,u,l.resolution)}R.expandByScalar(m),_.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(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;
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 o=E.geoDistance(a,s)*180/Math.PI;if(o>t){const r=E.geoInterpolate(s,a),l=1/Math.ceil(o/t);let c=l;for(;c<1;)i.push(r(c)),c+=l}}i.push(s=a)}),i})}function Lt(n,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const a=Math.round(tt(360/n,2)/Math.PI),o=(1+Math.sqrt(5))/2,r=f=>f/o*360%360-180,l=f=>Math.acos(2*f/a-1)/Math.PI*180-90,c=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,m=[s!==void 0?Math.ceil(c(s)):0,i!==void 0?Math.floor(c(i)):a-1],u=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=m[0];f<=m[1];f++){const p=r(f);u(p)&&v.push([p,l(f)])}return v}function X(n,t,e=!1){return e?E.geoContains(t,n):wt(n,t)}function Wt(n,t){const e={type:"Polygon",coordinates:n},[[i,s],[a,o]]=E.geoBounds(e);if(Math.min(Math.abs(a-i),Math.abs(o-s))<t)return[];const r=i>a||o>=89||s<=-89;return Lt(t,{minLng:i,maxLng:a,minLat:s,maxLat:o}).filter(l=>X(l,e,r))}function Bt(n,{resolution:t=1/0,bbox:e,projection:i}={}){const s=_t(n,t),a=B.merge(s),o=Wt(n,t),r=[...a,...o],l={type:"Polygon",coordinates:n},[[c,m],[u,v]]=E.geoBounds(l),f=c>u||v>=89||m<=-89;let p=[];if(f){const b=Pt.geoVoronoi(r).triangles(),P=new Map(r.map(([S,C],L)=>[`${S}-${C}`,L]));b.features.forEach(S=>{const C=S.geometry.coordinates[0].slice(0,3).reverse(),L=[];if(C.forEach(([D,F])=>{const G=`${D}-${F}`;P.has(G)&&L.push(P.get(G))}),L.length===3){if(L.some(D=>D<a.length)){const D=S.properties.circumcenter;if(!X(D,l,f))return}p.push(...L)}})}else if(o.length){const b=Mt.from(r);for(let P=0,S=b.triangles.length;P<S;P+=3){const C=[2,1,0].map(D=>b.triangles[P+D]),L=C.map(D=>r[D]);if(C.some(D=>D<a.length)){const D=[0,1].map(F=>B.mean(L,G=>G[F]));if(!X(D,l,f))continue}p.push(...C)}}else{const{vertices:b,holes:P=[]}=K.flatten(s);p=K(b,P,2)}let d=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([d[0],y[0]]),[S,C]=i([d[1],y[1]]);d=[b,S],y=[-P,-C]}const j=st.scaleLinear(d,[0,1]),z=st.scaleLinear(y,[0,1]),V=r.map(([b,P])=>{if(i){const[S,C]=i([b,P]);return[j(S),z(-C)]}else return[j(b),z(P)]});return{contour:s,triangles:{points:r,indices:p,uvs:V}}}const ct=new h.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(n,t,e,i){const s=n.map(a=>a.map(([o,r])=>{if(i){const[l,c]=i([o,r]);return[l,-c,t]}return e?H.polar2Cartesian(o,r,t):[o,r,t]}));return K.flatten(s)}function Ot(n,t,e,i,s){const{vertices:a,holes:o}=q(n,t,i,s),{vertices:r}=q(n,e,i,s),l=B.merge([r,a]),c=Math.round(r.length/3),m=new Set(o);let u=0;const v=[];for(let p=0;p<c;p++){let d=p+1;if(d===c)d=u;else if(m.has(d)){const y=d;d=u,u=y}v.push(p,p+c,d+c),v.push(d+c,d,p)}const f=[];for(let p=1;p>=0;p--)for(let d=0;d<c;d+=1)f.push(d/(c-1),p);return{indices:v,vertices:l,uvs:f,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:o=!1,hasTop:r=!1,projection:l,bbox:c})=>{n.forEach(j=>{xt(j)||j.reverse()});const{contour:m,triangles:u}=Bt(n,{resolution:i,bbox:c,projection:l});let v={},f;a&&(v=Ot(m,t!=null?t:e,e!=null?e:t,s,l),f=v.topVerts);let p=[];(o||r)&&(p=B.merge(u.uvs));let d={};o&&(d=ut(u,t,p,!1,s,l));let y={};return r&&(y=ut(u,e,p,!0,s,l)),{contour:m,triangles:u,sideTorso:v,bottomCap:d,topCap:y,topVerts:f}};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:o,hasSide:r,cartesian:l,userDataRsoOffset:c,projection:m}=this.parameters,{contour:u,sideTorso:v,topVerts:f,bottomCap:p,topCap:d}=ft(k({},this.parameters));let y=[],j=[],z=[],V=0;const A=b=>{const P=Math.round(y.length/3),S=z.length;y=y.concat(b.vertices),j=j.concat(b.uvs),z=z.concat(P?b.indices.map(C=>C+P):b.indices),this.addGroup(S,z.length-S,V++)};s&&a&&A(d),r&&(A(v),this.userData.topVerts=c?q(u,i+c,l,m).vertices:f),o&&A(p),s&&!a&&A(d),this.setIndex(z),this[ct]("position",new h.Float32BufferAttribute(y,3)),this[ct]("uv",new h.Float32BufferAttribute(j,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.28",
3
+ "version": "0.14.29",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",