gl-draw 0.14.30 → 0.14.31

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