gl-draw 0.17.0-beta.35 → 0.17.0-beta.36

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.
@@ -1,56 +1,56 @@
1
- var Oe = Object.defineProperty, De = Object.defineProperties;
2
- var Te = Object.getOwnPropertyDescriptors;
3
- var W = Object.getOwnPropertySymbols;
4
- var se = Object.prototype.hasOwnProperty, re = Object.prototype.propertyIsEnumerable;
5
- var ne = Math.pow, ie = (n, e, t) => e in n ? Oe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, z = (n, e) => {
1
+ var Ve = Object.defineProperty, _e = Object.defineProperties;
2
+ var Ne = Object.getOwnPropertyDescriptors;
3
+ var N = Object.getOwnPropertySymbols;
4
+ var re = Object.prototype.hasOwnProperty, oe = Object.prototype.propertyIsEnumerable;
5
+ var ae = Math.pow, ne = (r, e, t) => e in r ? Ve(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, k = (r, e) => {
6
6
  for (var t in e || (e = {}))
7
- se.call(e, t) && ie(n, t, e[t]);
8
- if (W)
9
- for (var t of W(e))
10
- re.call(e, t) && ie(n, t, e[t]);
11
- return n;
12
- }, q = (n, e) => De(n, Te(e));
13
- var oe = (n, e) => {
7
+ re.call(e, t) && ne(r, t, e[t]);
8
+ if (N)
9
+ for (var t of N(e))
10
+ oe.call(e, t) && ne(r, t, e[t]);
11
+ return r;
12
+ }, X = (r, e) => _e(r, Ne(e));
13
+ var ce = (r, e) => {
14
14
  var t = {};
15
- for (var i in n)
16
- se.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
17
- if (n != null && W)
18
- for (var i of W(n))
19
- e.indexOf(i) < 0 && re.call(n, i) && (t[i] = n[i]);
15
+ for (var i in r)
16
+ re.call(r, i) && e.indexOf(i) < 0 && (t[i] = r[i]);
17
+ if (r != null && N)
18
+ for (var i of N(r))
19
+ e.indexOf(i) < 0 && oe.call(r, i) && (t[i] = r[i]);
20
20
  return t;
21
21
  };
22
- var ae = (n, e, t) => new Promise((i, s) => {
22
+ var le = (r, e, t) => new Promise((i, s) => {
23
23
  var o = (a) => {
24
24
  try {
25
- r(t.next(a));
25
+ n(t.next(a));
26
26
  } catch (l) {
27
27
  s(l);
28
28
  }
29
29
  }, c = (a) => {
30
30
  try {
31
- r(t.throw(a));
31
+ n(t.throw(a));
32
32
  } catch (l) {
33
33
  s(l);
34
34
  }
35
- }, r = (a) => a.done ? i(a.value) : Promise.resolve(a.value).then(o, c);
36
- r((t = t.apply(n, e)).next());
35
+ }, n = (a) => a.done ? i(a.value) : Promise.resolve(a.value).then(o, c);
36
+ n((t = t.apply(r, e)).next());
37
37
  });
38
- import { merge as H, mean as Ee, extent as ce } from "d3-array";
39
- import Le, { flatten as Ce } from "earcut";
40
- import { Material as le, Object3D as R, Texture as ue, BufferGeometry as ee, Float32BufferAttribute as G, PointsMaterial as ke, Points as te, InstancedMesh as Ae, Vector3 as S, Quaternion as ze, Group as Ve, Mesh as Pe, Sprite as de, Box3 as Ie, ShaderMaterial as Ne, Vector2 as K, Color as he, Vector4 as V, Matrix4 as We, Line3 as _e, Sphere as Ue, InstancedInterleavedBuffer as Re, InterleavedBufferAttribute as fe, MathUtils as Ge } from "three";
41
- import $e from "@turf/boolean-clockwise";
42
- import { p as pe, a as Fe } from "./polar2Cartesian.module.js";
43
- import qe from "delaunator";
44
- import Ke from "@turf/boolean-point-in-polygon";
45
- import { geoBounds as Be, geoContains as Qe, geoDistance as Xe, geoInterpolate as Ye } from "d3-geo";
46
- import { geoVoronoi as Ze } from "d3-geo-voronoi";
47
- import { scaleLinear as me } from "d3-scale";
48
- import { LineSegmentsGeometry as Je } from "three/examples/jsm/lines/LineSegmentsGeometry";
49
- import { CSS2DObject as He } from "three/examples/jsm/renderers/CSS2DRenderer";
50
- import { CSS3DObject as et, CSS3DSprite as tt } from "three/examples/jsm/renderers/CSS3DRenderer";
38
+ import { merge as te, mean as We, extent as ue } from "d3-array";
39
+ import Re, { flatten as Te } from "earcut";
40
+ import { Material as he, Object3D as G, Texture as de, Vector3 as S, Matrix4 as Be, Ray as Ue, Sphere as Oe, BufferGeometry as ie, Float32BufferAttribute as $, PointsMaterial as Ge, Points as se, InstancedMesh as De, Quaternion as $e, Group as Fe, Mesh as Ee, Sprite as fe, Box3 as ze, ShaderMaterial as qe, Vector2 as K, Color as pe, Vector4 as V, Line3 as Xe, InstancedInterleavedBuffer as Ke, InterleavedBufferAttribute as me, MathUtils as Qe } from "three";
41
+ import Ye from "@turf/boolean-clockwise";
42
+ import { p as ve, a as Ze } from "./polar2Cartesian.module.js";
43
+ import Je from "delaunator";
44
+ import He from "@turf/boolean-point-in-polygon";
45
+ import { geoBounds as Le, geoContains as et, geoDistance as tt, geoInterpolate as it } from "d3-geo";
46
+ import { geoVoronoi as st } from "d3-geo-voronoi";
47
+ import { scaleLinear as be } from "d3-scale";
48
+ import { LineSegmentsGeometry as nt } from "three/examples/jsm/lines/LineSegmentsGeometry";
49
+ import { CSS2DObject as rt } from "three/examples/jsm/renderers/CSS2DRenderer";
50
+ import { CSS3DObject as ot, CSS3DSprite as at } from "three/examples/jsm/renderers/CSS3DRenderer";
51
51
  import "d3-geo-projection";
52
- const ve = 0, be = 1, Tt = !1;
53
- class it {
52
+ const ye = 0, ge = 1, Nt = !1;
53
+ class ct {
54
54
  constructor() {
55
55
  this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
56
56
  }
@@ -59,24 +59,24 @@ class it {
59
59
  return e;
60
60
  if (Array.isArray(e))
61
61
  return e.forEach((t) => this.track(t)), e;
62
- if (!this.disposeMaterial && e instanceof le)
62
+ if (!this.disposeMaterial && e instanceof he)
63
63
  return e;
64
- if (e instanceof Z ? (e.disposeTrack && e.object3d ? this.track(e.object3d) : this.resources.add(e), Object.values(e.materialList).map((t) => this.track(t))) : (e instanceof R || Reflect.has(e, "dispose")) && this.resources.add(e), e instanceof Z)
64
+ if (e instanceof H ? (e.disposeTrack && e.object3d ? this.track(e.object3d) : this.resources.add(e), Object.values(e.materialList).map((t) => this.track(t))) : (e instanceof G || Reflect.has(e, "dispose")) && this.resources.add(e), e instanceof H)
65
65
  e.children.forEach((t) => {
66
66
  t.disposeTrack = !1;
67
67
  }), this.track(e.children);
68
- else if (e instanceof R) {
68
+ else if (e instanceof G) {
69
69
  const t = e;
70
70
  this.track(t.geometry), this.track(t.material), this.track(t.children);
71
- } else if (e instanceof le) {
71
+ } else if (e instanceof he) {
72
72
  for (const i of Object.values(e))
73
- i instanceof ue && this.track(i);
73
+ i instanceof de && this.track(i);
74
74
  const t = e;
75
75
  if (t.uniforms) {
76
76
  for (const i of Object.values(t.uniforms))
77
77
  if (i) {
78
78
  const s = i.value;
79
- (s instanceof ue || Array.isArray(s)) && this.track(s);
79
+ (s instanceof de || Array.isArray(s)) && this.track(s);
80
80
  }
81
81
  }
82
82
  } else this.disposeVideo && e.isVideoTexture && e.source.data && this.resources.add(e.source.data);
@@ -85,22 +85,78 @@ class it {
85
85
  dispose() {
86
86
  const e = [];
87
87
  for (const t of this.resources)
88
- t instanceof R ? e.push(t) : t instanceof HTMLVideoElement && t.pause(), Reflect.has(t, "dispose") && t.dispose();
88
+ t instanceof G ? e.push(t) : t instanceof HTMLVideoElement && t.pause(), Reflect.has(t, "dispose") && t.dispose();
89
89
  e.forEach((t) => {
90
90
  t.removeFromParent();
91
91
  }), e.length = 0, this.resources.clear();
92
92
  }
93
93
  }
94
- const st = (n, e = 1) => {
95
- const t = new ee();
94
+ const Me = /* @__PURE__ */ new Be(), ke = /* @__PURE__ */ new Ue(), Q = /* @__PURE__ */ new Oe(), W = /* @__PURE__ */ new S();
95
+ function lt(r, e) {
96
+ const t = this.geometry, i = this.matrixWorld, s = r.params.Points.threshold, o = t.drawRange;
97
+ t.boundingSphere === null && t.computeBoundingSphere(), Q.copy(t.boundingSphere), Q.applyMatrix4(i), Q.radius += s, Me.copy(i).invert(), ke.copy(r.ray).applyMatrix4(Me);
98
+ const c = s / ((this.scale.x + this.scale.y + this.scale.z) / 3), n = t.index, l = t.attributes.position;
99
+ if (n !== null) {
100
+ const f = Math.max(0, o.start), u = Math.min(n.count, o.start + o.count);
101
+ for (let d = f, h = u; d < h; d++) {
102
+ const p = n.getX(d);
103
+ W.fromBufferAttribute(l, p), we(
104
+ W,
105
+ p,
106
+ c,
107
+ i,
108
+ r,
109
+ e,
110
+ this
111
+ );
112
+ }
113
+ } else {
114
+ const f = Math.max(0, o.start), u = Math.min(
115
+ l.count,
116
+ o.start + o.count
117
+ );
118
+ for (let d = f, h = u; d < h; d++)
119
+ W.fromBufferAttribute(l, d), we(
120
+ W,
121
+ d,
122
+ c,
123
+ i,
124
+ r,
125
+ e,
126
+ this
127
+ );
128
+ }
129
+ }
130
+ function we(r, e, t, i, s, o, c) {
131
+ const n = new S();
132
+ ke.closestPointToPoint(r, n), n.applyMatrix4(i);
133
+ const a = s.ray.origin.distanceTo(r), l = n.distanceTo(r), f = Math.asin(
134
+ l / a
135
+ );
136
+ if (f < t) {
137
+ if (a < s.near || a > s.far)
138
+ return;
139
+ o.push({
140
+ distance: a,
141
+ distanceToRay: l,
142
+ angleToRay: f,
143
+ point: n,
144
+ index: e,
145
+ face: null,
146
+ object: c
147
+ });
148
+ }
149
+ }
150
+ const ut = (r, e = 1) => {
151
+ const t = new ie();
96
152
  t.setAttribute(
97
153
  "position",
98
- new G(new Array(e * 3).fill(0), 3)
154
+ new $(new Array(e * 3).fill(0), 3)
99
155
  ), t.setAttribute(
100
156
  "scaleAtt",
101
- new G(new Array(e).fill(1), 1)
157
+ new $(new Array(e).fill(1), 1)
102
158
  );
103
- const i = n.material, s = new ke({
159
+ const i = r.material, s = new Ge({
104
160
  size: 10,
105
161
  map: i.map,
106
162
  alphaMap: i.alphaMap,
@@ -113,30 +169,32 @@ const st = (n, e = 1) => {
113
169
  alphaTest: i.alphaTest,
114
170
  sizeAttenuation: !1
115
171
  });
116
- return s.onBeforeCompile = (o) => {
117
- o.vertexShader = `
172
+ s.onBeforeCompile = (c) => {
173
+ c.vertexShader = `
118
174
  attribute float scaleAtt;
119
- ${o.vertexShader.replace(
175
+ ${c.vertexShader.replace(
120
176
  "gl_PointSize = size;",
121
177
  "gl_PointSize = size * scaleAtt;"
122
178
  )}
123
179
  `;
124
- }, new te(t, s);
125
- }, rt = (n, e) => {
126
- const t = new R();
180
+ };
181
+ const o = new se(t, s);
182
+ return o.raycast = lt, o;
183
+ }, ht = (r, e) => {
184
+ const t = new G();
127
185
  e.forEach((i, s) => {
128
- const o = pe(i.position), c = pe(i.scale || [1, 1, 1]);
186
+ const o = ve(i.position), c = ve(i.scale || [1, 1, 1]);
129
187
  t.position.copy(o), t.scale.copy(c), t.updateMatrix();
130
- const r = t.matrix.clone();
131
- if (n instanceof Ae || n.isInstantiate)
132
- n.setMatrixAt(s, r);
133
- else if (n instanceof te || n.type === "Points") {
134
- const l = n.geometry, m = l.attributes.position.array, u = l.attributes.scaleAtt.array, f = new S(), d = new S(), p = new ze(), h = s * 3, v = s * 1;
135
- r.decompose(f, p, d), m[h] = f.x, m[h + 1] = f.y, m[h + 2] = f.z, u[v] = Math.max(d.x, d.y, d.z), l.attributes.position.needsUpdate = !0, l.attributes.scaleAtt.needsUpdate = !0;
188
+ const n = t.matrix.clone();
189
+ if (r instanceof De || r.isInstantiate)
190
+ r.setMatrixAt(s, n);
191
+ else if (r instanceof se || r.type === "Points") {
192
+ const l = r.geometry, f = l.attributes.position.array, u = l.attributes.scaleAtt.array, d = new S(), h = new S(), p = new $e(), m = s * 3, v = s * 1;
193
+ n.decompose(d, p, h), f[m] = d.x, f[m + 1] = d.y, f[m + 2] = d.z, u[v] = Math.max(h.x, h.y, h.z), l.attributes.position.needsUpdate = !0, l.attributes.scaleAtt.needsUpdate = !0;
136
194
  }
137
195
  });
138
196
  };
139
- class nt {
197
+ class dt {
140
198
  constructor() {
141
199
  this.onPointerIndex = [];
142
200
  }
@@ -168,7 +226,7 @@ class nt {
168
226
  });
169
227
  }
170
228
  }
171
- class ot extends nt {
229
+ class ft extends dt {
172
230
  constructor() {
173
231
  super(...arguments), this.userData = {}, this.materialList = {}, this.useMaterialType = "origin", this.disposeMaterialIfNotUsed = !0;
174
232
  }
@@ -226,7 +284,7 @@ class ot extends nt {
226
284
  );
227
285
  }
228
286
  }
229
- class Z extends ot {
287
+ class H extends ft {
230
288
  constructor() {
231
289
  super(...arguments), this.key = "", this.objectType = "BaseObject", this.userData = {}, this.isPrefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.isBaseObject = !0, this.disposeTrack = !0, this.isDispose = !1;
232
290
  }
@@ -294,7 +352,7 @@ class Z extends ot {
294
352
  */
295
353
  _disableLayersRecursive() {
296
354
  var e;
297
- (e = this.object3d) == null || e.layers.disable(ve), this.children.forEach((t) => {
355
+ (e = this.object3d) == null || e.layers.disable(ye), this.children.forEach((t) => {
298
356
  t._disableLayersRecursive();
299
357
  });
300
358
  }
@@ -303,30 +361,30 @@ class Z extends ot {
303
361
  */
304
362
  _enableLayersRecursive() {
305
363
  var e;
306
- this.object3d.visible && ((e = this.object3d) == null || e.layers.enable(ve), this.children.forEach((t) => {
364
+ this.object3d.visible && ((e = this.object3d) == null || e.layers.enable(ye), this.children.forEach((t) => {
307
365
  t._enableLayersRecursive();
308
366
  }));
309
367
  }
310
368
  createGroup() {
311
- return this.object3d = new Ve(), this;
369
+ return this.object3d = new Fe(), this;
312
370
  }
313
371
  createMesh(...e) {
314
- return this.object3d = new Pe(...e), this;
372
+ return this.object3d = new Ee(...e), this;
315
373
  }
316
374
  createPoints(...e) {
317
- return this.object3d = new te(...e), this;
375
+ return this.object3d = new se(...e), this;
318
376
  }
319
377
  createCSS2DObject(e) {
320
- return this.object3d = new He(e), this;
378
+ return this.object3d = new rt(e), this;
321
379
  }
322
380
  createCSS3DObject(e) {
323
- return this.object3d = new et(e), this;
381
+ return this.object3d = new ot(e), this;
324
382
  }
325
383
  createCSS3DSprite(e) {
326
- return this.object3d = new tt(e), this;
384
+ return this.object3d = new at(e), this;
327
385
  }
328
386
  createSprite(e) {
329
- return this.object3d = new de(e), this;
387
+ return this.object3d = new fe(e), this;
330
388
  }
331
389
  attach(...e) {
332
390
  return [...e].forEach((t) => {
@@ -334,7 +392,7 @@ class Z extends ot {
334
392
  }), this;
335
393
  }
336
394
  getSize() {
337
- const e = new Ie().setFromObject(this.object3d);
395
+ const e = new ze().setFromObject(this.object3d);
338
396
  return {
339
397
  min: e.min,
340
398
  max: e.max,
@@ -351,49 +409,49 @@ class Z extends ot {
351
409
  });
352
410
  }
353
411
  instantiate(e) {
354
- return ae(this, null, function* () {
355
- var l, m;
356
- const t = (l = e == null ? void 0 : e.recursive) != null ? l : !0, i = (m = e == null ? void 0 : e.cloneMaterial) != null ? m : !1, { objectType: s, objectOptions: o } = this;
357
- let c = e == null ? void 0 : e.create, r, a = (e == null ? void 0 : e.target) || this.parent;
358
- return a === this.lead.prefabGroup && (a = this.lead.group), this.objectType === "BaseObject" ? r = this.lead.createBaseObject(this.object3d.clone(!1), {
412
+ return le(this, null, function* () {
413
+ var l, f;
414
+ const t = (l = e == null ? void 0 : e.recursive) != null ? l : !0, i = (f = e == null ? void 0 : e.cloneMaterial) != null ? f : !1, { objectType: s, objectOptions: o } = this;
415
+ let c = e == null ? void 0 : e.create, n, a = (e == null ? void 0 : e.target) || this.parent;
416
+ return a === this.lead.prefabGroup && (a = this.lead.group), this.objectType === "BaseObject" ? n = this.lead.createBaseObject(this.object3d.clone(!1), {
359
417
  target: a
360
418
  }) : (c === void 0 && (c = (u) => {
361
- var f;
419
+ var d;
362
420
  if (this.object3d) {
363
- if ((f = e == null ? void 0 : e.instancedAttr) != null && f.length) {
364
- const d = e.instancedAttr.length;
365
- if (this.object3d instanceof de)
366
- u.object3d = st(this.object3d, d);
421
+ if ((d = e == null ? void 0 : e.instancedAttr) != null && d.length) {
422
+ const h = e.instancedAttr.length;
423
+ if (this.object3d instanceof fe)
424
+ u.object3d = ut(this.object3d, h);
367
425
  else {
368
- const p = this.object3d, h = i ? this.cloneMaterial() : p.material;
369
- u.object3d = new Ae(
426
+ const p = this.object3d, m = i ? this.cloneMaterial() : p.material;
427
+ u.object3d = new De(
370
428
  p.geometry,
371
- h,
372
- d
429
+ m,
430
+ h
373
431
  );
374
432
  }
375
- rt(u.object3d, e == null ? void 0 : e.instancedAttr);
433
+ ht(u.object3d, e == null ? void 0 : e.instancedAttr);
376
434
  } else
377
435
  u.object3d = this.object3d.clone(!1), i && u.object3d.material && (u.object3d.material = this.cloneMaterial());
378
436
  u.object3d.userData.prefab && delete u.object3d.userData.prefab;
379
437
  }
380
- }), r = yield this.lead.draw(s, q(z({}, o || {}), {
438
+ }), n = yield this.lead.draw(s, X(k({}, o || {}), {
381
439
  create: c,
382
440
  prefab: !1,
383
441
  keyType: this.keyType,
384
442
  key: (e == null ? void 0 : e.key) || this.keyName,
385
443
  uId: (e == null ? void 0 : e.uId) || this.keyUId,
386
444
  target: a
387
- }))), this.isBloom && r.enableBloom(), t && (yield Promise.all(
445
+ }))), this.isBloom && n.enableBloom(), t && (yield Promise.all(
388
446
  this.children.map(
389
447
  (u) => u.instantiate({
390
448
  key: u.keyUId && u.keyName ? `${u.keyName}-${u.keyUId}` : u.keyName,
391
449
  uId: e == null ? void 0 : e.uId,
392
450
  cloneMaterial: i,
393
- target: r
451
+ target: n
394
452
  })
395
453
  )
396
- )), r.isInstantiate = !0, r;
454
+ )), n.isInstantiate = !0, n;
397
455
  });
398
456
  }
399
457
  erase() {
@@ -413,7 +471,7 @@ class Z extends ot {
413
471
  });
414
472
  return;
415
473
  }
416
- this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.add(this), this.object3d.layers.enable(be)), (s = this.pencil.composerController) == null || s.checkBloomComposerActive(), this.isBloom = !0;
474
+ this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.add(this), this.object3d.layers.enable(ge)), (s = this.pencil.composerController) == null || s.checkBloomComposerActive(), this.isBloom = !0;
417
475
  }
418
476
  disableBloom(e = !0) {
419
477
  var t, i, s;
@@ -427,171 +485,171 @@ class Z extends ot {
427
485
  });
428
486
  return;
429
487
  }
430
- this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.delete(this), this.object3d.layers.disable(be)), (s = this.pencil.composerController) == null || s.checkBloomComposerActive(), this.isBloom = !1;
488
+ this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.delete(this), this.object3d.layers.disable(ge)), (s = this.pencil.composerController) == null || s.checkBloomComposerActive(), this.isBloom = !1;
431
489
  }
432
490
  dispose() {
433
491
  var e, t;
434
492
  if (!this.isDispose && (this.isDispose = !0, super.dispose(), this.isBloom && (this.disableBloom(!1), (e = this.pencil.composerController) == null || e.checkBloomComposerActive()), (t = this.lead) == null || t.disableCursor(this), this.lead && (this.lead.objects.delete(this.key), this.lead.objectWrapChindIdMap.delete(this), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack)) {
435
- const i = new it();
493
+ const i = new ct();
436
494
  i.disposeMaterial = !1, i.track(this), i.dispose();
437
495
  }
438
496
  }
439
497
  }
440
- function at(n, e) {
441
- return n.map((t) => {
498
+ function pt(r, e) {
499
+ return r.map((t) => {
442
500
  const i = [];
443
501
  let s;
444
502
  return t.forEach((o) => {
445
503
  if (s) {
446
- const c = Xe(o, s) * 180 / Math.PI;
504
+ const c = tt(o, s) * 180 / Math.PI;
447
505
  if (c > e) {
448
- const r = Ye(s, o), a = 1 / Math.ceil(c / e);
506
+ const n = it(s, o), a = 1 / Math.ceil(c / e);
449
507
  let l = a;
450
508
  for (; l < 1; )
451
- i.push(r(l)), l += a;
509
+ i.push(n(l)), l += a;
452
510
  }
453
511
  }
454
512
  i.push(s = o);
455
513
  }), i;
456
514
  });
457
515
  }
458
- function ct(n, { minLng: e, maxLng: t, minLat: i, maxLat: s } = {}) {
459
- const o = Math.round(ne(360 / n, 2) / Math.PI), c = (1 + Math.sqrt(5)) / 2, r = (d) => d / c * 360 % 360 - 180, a = (d) => Math.acos(2 * d / o - 1) / Math.PI * 180 - 90, l = (d) => o * (Math.cos((d + 90) * Math.PI / 180) + 1) / 2, m = [
516
+ function mt(r, { minLng: e, maxLng: t, minLat: i, maxLat: s } = {}) {
517
+ const o = Math.round(ae(360 / r, 2) / Math.PI), c = (1 + Math.sqrt(5)) / 2, n = (h) => h / c * 360 % 360 - 180, a = (h) => Math.acos(2 * h / o - 1) / Math.PI * 180 - 90, l = (h) => o * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, f = [
460
518
  s !== void 0 ? Math.ceil(l(s)) : 0,
461
519
  i !== void 0 ? Math.floor(l(i)) : o - 1
462
- ], u = e === void 0 && t === void 0 ? () => !0 : e === void 0 ? (d) => d <= t : t === void 0 ? (d) => d >= e : t >= e ? (d) => d >= e && d <= t : (d) => d >= e || d <= t, f = [];
463
- for (let d = m[0]; d <= m[1]; d++) {
464
- const p = r(d);
465
- u(p) && f.push([p, a(d)]);
520
+ ], u = e === void 0 && t === void 0 ? () => !0 : e === void 0 ? (h) => h <= t : t === void 0 ? (h) => h >= e : t >= e ? (h) => h >= e && h <= t : (h) => h >= e || h <= t, d = [];
521
+ for (let h = f[0]; h <= f[1]; h++) {
522
+ const p = n(h);
523
+ u(p) && d.push([p, a(h)]);
466
524
  }
467
- return f;
525
+ return d;
468
526
  }
469
- function J(n, e, t = !1) {
470
- return t ? Qe(e, n) : Ke(n, e);
527
+ function ee(r, e, t = !1) {
528
+ return t ? et(e, r) : He(r, e);
471
529
  }
472
- function lt(n, e) {
473
- const t = { type: "Polygon", coordinates: n }, [[i, s], [o, c]] = Be(t);
530
+ function vt(r, e) {
531
+ const t = { type: "Polygon", coordinates: r }, [[i, s], [o, c]] = Le(t);
474
532
  if (Math.min(Math.abs(o - i), Math.abs(c - s)) < e)
475
533
  return [];
476
- const r = i > o || c >= 89 || s <= -89;
477
- return ct(e, {
534
+ const n = i > o || c >= 89 || s <= -89;
535
+ return mt(e, {
478
536
  minLng: i,
479
537
  maxLng: o,
480
538
  minLat: s,
481
539
  maxLat: c
482
540
  }).filter(
483
- (a) => J(a, t, r)
541
+ (a) => ee(a, t, n)
484
542
  );
485
543
  }
486
- function ut(n, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
487
- const s = at(n, e), o = H(s), c = lt(n, e), r = [...o, ...c], a = { type: "Polygon", coordinates: n }, [[l, m], [u, f]] = Be(a), d = l > u || // crosses antimeridian
488
- f >= 89 || // crosses north pole
489
- m <= -89;
544
+ function bt(r, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
545
+ const s = pt(r, e), o = te(s), c = vt(r, e), n = [...o, ...c], a = { type: "Polygon", coordinates: r }, [[l, f], [u, d]] = Le(a), h = l > u || // crosses antimeridian
546
+ d >= 89 || // crosses north pole
547
+ f <= -89;
490
548
  let p = [];
491
- if (d) {
492
- const y = Ze(r).triangles(), x = new Map(
493
- r.map(([P, I], L) => [`${P}-${I}`, L])
549
+ if (h) {
550
+ const y = st(n).triangles(), x = new Map(
551
+ n.map(([A, I], z) => [`${A}-${I}`, z])
494
552
  );
495
- y.features.forEach((P) => {
496
- const I = P.geometry.coordinates[0].slice(0, 3).reverse(), L = [];
497
- if (I.forEach(([B, F]) => {
498
- const N = `${B}-${F}`;
499
- x.has(N) && L.push(x.get(N));
500
- }), L.length === 3) {
501
- if (L.some((B) => B < o.length)) {
502
- const B = P.properties.circumcenter;
503
- if (!J(
504
- B,
553
+ y.features.forEach((A) => {
554
+ const I = A.geometry.coordinates[0].slice(0, 3).reverse(), z = [];
555
+ if (I.forEach(([T, q]) => {
556
+ const _ = `${T}-${q}`;
557
+ x.has(_) && z.push(x.get(_));
558
+ }), z.length === 3) {
559
+ if (z.some((T) => T < o.length)) {
560
+ const T = A.properties.circumcenter;
561
+ if (!ee(
562
+ T,
505
563
  a,
506
- d
564
+ h
507
565
  ))
508
566
  return;
509
567
  }
510
- p.push(...L);
568
+ p.push(...z);
511
569
  }
512
570
  });
513
571
  } else if (c.length) {
514
- const y = qe.from(r);
515
- for (let x = 0, P = y.triangles.length; x < P; x += 3) {
516
- const I = [2, 1, 0].map((B) => y.triangles[x + B]), L = I.map((B) => r[B]);
517
- if (I.some((B) => B < o.length)) {
518
- const B = [0, 1].map(
519
- (F) => Ee(L, (N) => N[F])
572
+ const y = Je.from(n);
573
+ for (let x = 0, A = y.triangles.length; x < A; x += 3) {
574
+ const I = [2, 1, 0].map((T) => y.triangles[x + T]), z = I.map((T) => n[T]);
575
+ if (I.some((T) => T < o.length)) {
576
+ const T = [0, 1].map(
577
+ (q) => We(z, (_) => _[q])
520
578
  );
521
- if (!J(
522
- B,
579
+ if (!ee(
580
+ T,
523
581
  a,
524
- d
582
+ h
525
583
  ))
526
584
  continue;
527
585
  }
528
586
  p.push(...I);
529
587
  }
530
588
  } else {
531
- const { vertices: y, holes: x = [] } = Ce(s);
532
- p = Le(y, x, 2);
589
+ const { vertices: y, holes: x = [] } = Te(s);
590
+ p = Re(y, x, 2);
533
591
  }
534
- let h = t ? [t[0], t[2]] : ce(r, (y) => y[0]), v = t ? [t[1], t[3]] : ce(r, (y) => y[1]);
592
+ let m = t ? [t[0], t[2]] : ue(n, (y) => y[0]), v = t ? [t[1], t[3]] : ue(n, (y) => y[1]);
535
593
  if (i) {
536
- const [y, x] = i([h[0], v[0]]), [P, I] = i([h[1], v[1]]);
537
- h = [y, P], v = [-x, -I];
594
+ const [y, x] = i([m[0], v[0]]), [A, I] = i([m[1], v[1]]);
595
+ m = [y, A], v = [-x, -I];
538
596
  }
539
- const j = me(h, [0, 1]), C = me(v, [0, 1]), O = r.map(([y, x]) => {
597
+ const j = be(m, [0, 1]), C = be(v, [0, 1]), B = n.map(([y, x]) => {
540
598
  if (i) {
541
- const [P, I] = i([y, x]);
542
- return [j(P), C(-I)];
599
+ const [A, I] = i([y, x]);
600
+ return [j(A), C(-I)];
543
601
  } else
544
602
  return [j(y), C(x)];
545
603
  });
546
- return { contour: s, triangles: { points: r, indices: p, uvs: O } };
604
+ return { contour: s, triangles: { points: n, indices: p, uvs: B } };
547
605
  }
548
- const ye = new ee().setAttribute ? "setAttribute" : "addAttribute";
549
- function $(n, e, t, i) {
550
- const s = n.map(
551
- (o) => o.map(([c, r]) => {
606
+ const xe = new ie().setAttribute ? "setAttribute" : "addAttribute";
607
+ function F(r, e, t, i) {
608
+ const s = r.map(
609
+ (o) => o.map(([c, n]) => {
552
610
  if (i) {
553
- const [a, l] = i([c, r]);
611
+ const [a, l] = i([c, n]);
554
612
  return [a, -l, e];
555
613
  }
556
- return t ? Fe(c, r, e) : [c, r, e];
614
+ return t ? Ze(c, n, e) : [c, n, e];
557
615
  })
558
616
  );
559
- return Ce(s);
617
+ return Te(s);
560
618
  }
561
- function dt(n, e, t, i, s) {
562
- const { vertices: o, holes: c } = $(
563
- n,
619
+ function yt(r, e, t, i, s) {
620
+ const { vertices: o, holes: c } = F(
621
+ r,
564
622
  e,
565
623
  i,
566
624
  s
567
- ), { vertices: r } = $(
568
- n,
625
+ ), { vertices: n } = F(
626
+ r,
569
627
  t,
570
628
  i,
571
629
  s
572
- ), a = H([r, o]), l = Math.round(r.length / 3), m = new Set(c);
630
+ ), a = te([n, o]), l = Math.round(n.length / 3), f = new Set(c);
573
631
  let u = 0;
574
- const f = [];
632
+ const d = [];
575
633
  for (let p = 0; p < l; p++) {
576
- let h = p + 1;
577
- if (h === l)
578
- h = u;
579
- else if (m.has(h)) {
580
- const v = h;
581
- h = u, u = v;
634
+ let m = p + 1;
635
+ if (m === l)
636
+ m = u;
637
+ else if (f.has(m)) {
638
+ const v = m;
639
+ m = u, u = v;
582
640
  }
583
- f.push(p, p + l, h + l), f.push(h + l, h, p);
641
+ d.push(p, p + l, m + l), d.push(m + l, m, p);
584
642
  }
585
- const d = [];
643
+ const h = [];
586
644
  for (let p = 1; p >= 0; p--)
587
- for (let h = 0; h < l; h += 1) d.push(h / (l - 1), p);
588
- return { indices: f, vertices: a, uvs: d, topVerts: r };
645
+ for (let m = 0; m < l; m += 1) h.push(m / (l - 1), p);
646
+ return { indices: d, vertices: a, uvs: h, topVerts: n };
589
647
  }
590
- function ge(n, e, t, i, s, o) {
648
+ function Se(r, e, t, i, s, o) {
591
649
  return {
592
- indices: i ? n.indices : n.indices.slice().reverse(),
593
- vertices: $(
594
- [n.points],
650
+ indices: i ? r.indices : r.indices.slice().reverse(),
651
+ vertices: F(
652
+ [r.points],
595
653
  e,
596
654
  s,
597
655
  o
@@ -599,38 +657,38 @@ function ge(n, e, t, i, s, o) {
599
657
  uvs: t
600
658
  };
601
659
  }
602
- const ht = ({
603
- polygonGeoJson: n,
660
+ const gt = ({
661
+ polygonGeoJson: r,
604
662
  startHeight: e,
605
663
  endHeight: t,
606
664
  curvatureResolution: i = 1,
607
665
  cartesian: s = !0,
608
666
  hasSide: o = !0,
609
667
  hasBottom: c = !1,
610
- hasTop: r = !1,
668
+ hasTop: n = !1,
611
669
  projection: a,
612
670
  bbox: l
613
671
  }) => {
614
- n.forEach((j) => {
615
- $e(j) || j.reverse();
672
+ r.forEach((j) => {
673
+ Ye(j) || j.reverse();
616
674
  });
617
- const { contour: m, triangles: u } = ut(n, {
675
+ const { contour: f, triangles: u } = bt(r, {
618
676
  resolution: i,
619
677
  bbox: l,
620
678
  projection: a
621
679
  });
622
- let f = {}, d;
623
- o && (f = dt(
624
- m,
680
+ let d = {}, h;
681
+ o && (d = yt(
682
+ f,
625
683
  e != null ? e : t,
626
684
  t != null ? t : e,
627
685
  s,
628
686
  a
629
- ), d = f.topVerts);
687
+ ), h = d.topVerts);
630
688
  let p = [];
631
- (c || r) && (p = H(u.uvs));
632
- let h = {};
633
- c && (h = ge(
689
+ (c || n) && (p = te(u.uvs));
690
+ let m = {};
691
+ c && (m = Se(
634
692
  u,
635
693
  e,
636
694
  p,
@@ -639,18 +697,18 @@ const ht = ({
639
697
  a
640
698
  ));
641
699
  let v = {};
642
- return r && (v = ge(
700
+ return n && (v = Se(
643
701
  u,
644
702
  t,
645
703
  p,
646
704
  !0,
647
705
  s,
648
706
  a
649
- )), { contour: m, triangles: u, sideTorso: f, bottomCap: h, topCap: v, topVerts: d };
707
+ )), { contour: f, triangles: u, sideTorso: d, bottomCap: m, topCap: v, topVerts: h };
650
708
  };
651
- class Et extends ee {
709
+ class Wt extends ie {
652
710
  constructor(e, t = {}) {
653
- super(), this.type = "PolygonBufferGeometry", this.parameters = z({
711
+ super(), this.type = "PolygonBufferGeometry", this.parameters = k({
654
712
  polygonGeoJson: e,
655
713
  startHeight: 0,
656
714
  endHeight: 1,
@@ -667,27 +725,27 @@ class Et extends ee {
667
725
  hasTop: s,
668
726
  topFirst: o,
669
727
  hasBottom: c,
670
- hasSide: r,
728
+ hasSide: n,
671
729
  cartesian: a,
672
730
  userDataRsoOffset: l,
673
- projection: m
674
- } = this.parameters, { contour: u, sideTorso: f, topVerts: d, bottomCap: p, topCap: h } = ht(z({}, this.parameters));
675
- let v = [], j = [], C = [], O = 0;
676
- const A = (y) => {
677
- const x = Math.round(v.length / 3), P = C.length;
731
+ projection: f
732
+ } = this.parameters, { contour: u, sideTorso: d, topVerts: h, bottomCap: p, topCap: m } = gt(k({}, this.parameters));
733
+ let v = [], j = [], C = [], B = 0;
734
+ const P = (y) => {
735
+ const x = Math.round(v.length / 3), A = C.length;
678
736
  v = v.concat(y.vertices), j = j.concat(y.uvs), C = C.concat(
679
737
  x ? y.indices.map((I) => I + x) : y.indices
680
- ), this.addGroup(P, C.length - P, O++);
738
+ ), this.addGroup(A, C.length - A, B++);
681
739
  };
682
- s && o && A(h), r && (A(f), this.userData.topVerts = l ? $(
740
+ s && o && P(m), n && (P(d), this.userData.topVerts = l ? F(
683
741
  u,
684
742
  i + l,
685
743
  a,
686
- m
687
- ).vertices : d), c && A(p), s && !o && A(h), this.setIndex(C), this[ye]("position", new G(v, 3)), this[ye]("uv", new G(j, 2)), this.computeVertexNormals();
744
+ f
745
+ ).vertices : h), c && P(p), s && !o && P(m), this.setIndex(C), this[xe]("position", new $(v, 3)), this[xe]("uv", new $(j, 2)), this.computeVertexNormals();
688
746
  }
689
747
  }
690
- const ft = `
748
+ const Mt = `
691
749
  #include <fog_pars_fragment>
692
750
  #include <logdepthbuf_pars_fragment>
693
751
 
@@ -731,7 +789,7 @@ void main() {
731
789
  #include <tonemapping_fragment>
732
790
  #include <colorspace_fragment>
733
791
  }
734
- `, pt = `
792
+ `, wt = `
735
793
  #include <common>
736
794
  #include <logdepthbuf_pars_vertex>
737
795
  #include <fog_pars_vertex>
@@ -824,7 +882,7 @@ void main() {
824
882
  #include <fog_vertex>
825
883
  }
826
884
  `;
827
- class Lt extends Ne {
885
+ class Rt extends qe {
828
886
  constructor(e = {}) {
829
887
  const C = e, {
830
888
  lineWidth: t = 1,
@@ -832,17 +890,17 @@ class Lt extends Ne {
832
890
  opacity: s = 1,
833
891
  map: o = null,
834
892
  dashOffset: c = 0,
835
- dashArray: r = 0,
893
+ dashArray: n = 0,
836
894
  dashRatio: a = 0,
837
895
  sizeAttenuation: l = !0,
838
- offsetLoop: m = !0,
896
+ offsetLoop: f = !0,
839
897
  offset: u = new K(0, 0),
840
- scaleDown: f = 0,
841
- alphaMap: d = void 0,
898
+ scaleDown: d = 0,
899
+ alphaMap: h = void 0,
842
900
  alphaTest: p = 0,
843
- repeat: h = new K(1, 1),
901
+ repeat: m = new K(1, 1),
844
902
  resolution: v = new K(1, 1)
845
- } = C, j = oe(C, [
903
+ } = C, j = ce(C, [
846
904
  "lineWidth",
847
905
  "color",
848
906
  "opacity",
@@ -859,29 +917,29 @@ class Lt extends Ne {
859
917
  "repeat",
860
918
  "resolution"
861
919
  ]);
862
- super(q(z({}, j), {
920
+ super(X(k({}, j), {
863
921
  uniforms: {
864
922
  lineWidth: { value: t },
865
- color: { value: new he(i) },
923
+ color: { value: new pe(i) },
866
924
  opacity: { value: s },
867
925
  map: { value: o },
868
926
  useMap: { value: o ? 1 : 0 },
869
927
  resolution: { value: v },
870
928
  sizeAttenuation: { value: l ? 1 : 0 },
871
929
  offset: { value: u },
872
- offsetLoop: { value: m ? 1 : 0 },
873
- dashArray: { value: r },
930
+ offsetLoop: { value: f ? 1 : 0 },
931
+ dashArray: { value: n },
874
932
  dashOffset: { value: c },
875
933
  dashRatio: { value: a },
876
- useDash: { value: r > 0 ? 1 : 0 },
877
- scaleDown: { value: f / 10 },
934
+ useDash: { value: n > 0 ? 1 : 0 },
935
+ scaleDown: { value: d / 10 },
878
936
  alphaTest: { value: p },
879
- alphaMap: { value: d },
880
- useAlphaMap: { value: d ? 1 : 0 },
881
- repeat: { value: h }
937
+ alphaMap: { value: h },
938
+ useAlphaMap: { value: h ? 1 : 0 },
939
+ repeat: { value: m }
882
940
  },
883
- vertexShader: pt,
884
- fragmentShader: ft
941
+ vertexShader: wt,
942
+ fragmentShader: Mt
885
943
  })), this.type = "MeshLineMaterial";
886
944
  }
887
945
  // Getter and setter for color
@@ -889,7 +947,7 @@ class Lt extends Ne {
889
947
  return this.uniforms.color.value;
890
948
  }
891
949
  set color(e) {
892
- this.uniforms.color.value = new he(e);
950
+ this.uniforms.color.value = new pe(e);
893
951
  }
894
952
  get opacity() {
895
953
  var e;
@@ -932,81 +990,81 @@ class Lt extends Ne {
932
990
  this.uniforms.sizeAttenuation.value = e ? 1 : 0;
933
991
  }
934
992
  }
935
- const Q = new V(), Me = new S(), we = new S(), g = new V(), M = new V(), D = new V(), X = new S(), Y = new We(), w = new _e(), xe = new S(), _ = new Ie(), U = new Ue(), T = new V();
936
- let E, k;
937
- function Se(n, e, t) {
938
- return T.set(0, 0, -e, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = k / t.width, T.y = k / t.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
993
+ const Y = new V(), je = new S(), Ce = new S(), g = new V(), M = new V(), O = new V(), Z = new S(), J = new Be(), w = new Xe(), Pe = new S(), R = new ze(), U = new Oe(), D = new V();
994
+ let E, L;
995
+ function Ae(r, e, t) {
996
+ return D.set(0, 0, -e, 1).applyMatrix4(r.projectionMatrix), D.multiplyScalar(1 / D.w), D.x = L / t.width, D.y = L / t.height, D.applyMatrix4(r.projectionMatrixInverse), D.multiplyScalar(1 / D.w), Math.abs(Math.max(D.x, D.y));
939
997
  }
940
- function mt(n, e) {
941
- const t = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, o = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
942
- for (let r = 0, a = c; r < a; r++) {
943
- w.start.fromBufferAttribute(s, r), w.end.fromBufferAttribute(o, r), w.applyMatrix4(t);
944
- const l = new S(), m = new S();
945
- E.distanceSqToSegment(w.start, w.end, m, l), m.distanceTo(l) < k * 0.5 && e.push({
946
- point: m,
998
+ function xt(r, e) {
999
+ const t = r.matrixWorld, i = r.geometry, s = i.attributes.instanceStart, o = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
1000
+ for (let n = 0, a = c; n < a; n++) {
1001
+ w.start.fromBufferAttribute(s, n), w.end.fromBufferAttribute(o, n), w.applyMatrix4(t);
1002
+ const l = new S(), f = new S();
1003
+ E.distanceSqToSegment(w.start, w.end, f, l), f.distanceTo(l) < L * 0.5 && e.push({
1004
+ point: f,
947
1005
  pointOnLine: l,
948
- distance: E.origin.distanceTo(m),
949
- object: n,
1006
+ distance: E.origin.distanceTo(f),
1007
+ object: r,
950
1008
  face: null,
951
- faceIndex: r,
1009
+ faceIndex: n,
952
1010
  uv: null,
953
1011
  uv1: null
954
1012
  });
955
1013
  }
956
1014
  }
957
- function vt(n, e, t) {
958
- const i = e.projectionMatrix, o = n.material.resolution, c = n.matrixWorld, r = n.geometry, a = r.attributes.instanceStart, l = r.attributes.instanceEnd, m = Math.min(r.instanceCount, a.count), u = -e.near;
959
- E.at(1, D), D.w = 1, D.applyMatrix4(e.matrixWorldInverse), D.applyMatrix4(i), D.multiplyScalar(1 / D.w), D.x *= o.x / 2, D.y *= o.y / 2, D.z = 0, X.copy(D), Y.multiplyMatrices(e.matrixWorldInverse, c);
960
- for (let f = 0, d = m; f < d; f++) {
961
- if (g.fromBufferAttribute(a, f), M.fromBufferAttribute(l, f), g.w = 1, M.w = 1, g.applyMatrix4(Y), M.applyMatrix4(Y), g.z > u && M.z > u)
1015
+ function St(r, e, t) {
1016
+ const i = e.projectionMatrix, o = r.material.resolution, c = r.matrixWorld, n = r.geometry, a = n.attributes.instanceStart, l = n.attributes.instanceEnd, f = Math.min(n.instanceCount, a.count), u = -e.near;
1017
+ E.at(1, O), O.w = 1, O.applyMatrix4(e.matrixWorldInverse), O.applyMatrix4(i), O.multiplyScalar(1 / O.w), O.x *= o.x / 2, O.y *= o.y / 2, O.z = 0, Z.copy(O), J.multiplyMatrices(e.matrixWorldInverse, c);
1018
+ for (let d = 0, h = f; d < h; d++) {
1019
+ if (g.fromBufferAttribute(a, d), M.fromBufferAttribute(l, d), g.w = 1, M.w = 1, g.applyMatrix4(J), M.applyMatrix4(J), g.z > u && M.z > u)
962
1020
  continue;
963
1021
  if (g.z > u) {
964
- const O = g.z - M.z, A = (g.z - u) / O;
965
- g.lerp(M, A);
1022
+ const B = g.z - M.z, P = (g.z - u) / B;
1023
+ g.lerp(M, P);
966
1024
  } else if (M.z > u) {
967
- const O = M.z - g.z, A = (M.z - u) / O;
968
- M.lerp(g, A);
1025
+ const B = M.z - g.z, P = (M.z - u) / B;
1026
+ M.lerp(g, P);
969
1027
  }
970
1028
  g.applyMatrix4(i), M.applyMatrix4(i), g.multiplyScalar(1 / g.w), M.multiplyScalar(1 / M.w), g.x *= o.x / 2, g.y *= o.y / 2, M.x *= o.x / 2, M.y *= o.y / 2, w.start.copy(g), w.start.z = 0, w.end.copy(M), w.end.z = 0;
971
- const h = w.closestPointToPointParameter(X, !0);
972
- w.at(h, xe);
973
- const v = Ge.lerp(g.z, M.z, h), j = v >= -1 && v <= 1, C = X.distanceTo(xe) < k * 0.5;
1029
+ const m = w.closestPointToPointParameter(Z, !0);
1030
+ w.at(m, Pe);
1031
+ const v = Qe.lerp(g.z, M.z, m), j = v >= -1 && v <= 1, C = Z.distanceTo(Pe) < L * 0.5;
974
1032
  if (j && C) {
975
- w.start.fromBufferAttribute(a, f), w.end.fromBufferAttribute(l, f), w.start.applyMatrix4(c), w.end.applyMatrix4(c);
976
- const O = new S(), A = new S();
977
- E.distanceSqToSegment(w.start, w.end, A, O), t.push({
978
- point: A,
979
- pointOnLine: O,
980
- distance: E.origin.distanceTo(A),
981
- object: n,
1033
+ w.start.fromBufferAttribute(a, d), w.end.fromBufferAttribute(l, d), w.start.applyMatrix4(c), w.end.applyMatrix4(c);
1034
+ const B = new S(), P = new S();
1035
+ E.distanceSqToSegment(w.start, w.end, P, B), t.push({
1036
+ point: P,
1037
+ pointOnLine: B,
1038
+ distance: E.origin.distanceTo(P),
1039
+ object: r,
982
1040
  face: null,
983
- faceIndex: f,
1041
+ faceIndex: d,
984
1042
  uv: null,
985
1043
  uv1: null
986
1044
  });
987
1045
  }
988
1046
  }
989
1047
  }
990
- class kt extends Pe {
991
- constructor(e = new Je(), t) {
1048
+ class Ut extends Ee {
1049
+ constructor(e = new nt(), t) {
992
1050
  super(e, t), this.isLineSegments2 = !0, this.type = "LineSegments2";
993
1051
  }
994
1052
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
995
1053
  computeLineDistances() {
996
1054
  const e = this.geometry, t = e.attributes.instanceStart, i = e.attributes.instanceEnd, s = new Float32Array(2 * t.count);
997
- for (let c = 0, r = 0, a = t.count; c < a; c++, r += 2)
998
- Me.fromBufferAttribute(t, c), we.fromBufferAttribute(i, c), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + Me.distanceTo(we);
999
- const o = new Re(
1055
+ for (let c = 0, n = 0, a = t.count; c < a; c++, n += 2)
1056
+ je.fromBufferAttribute(t, c), Ce.fromBufferAttribute(i, c), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + je.distanceTo(Ce);
1057
+ const o = new Ke(
1000
1058
  s,
1001
1059
  2,
1002
1060
  1
1003
1061
  );
1004
1062
  return e.setAttribute(
1005
1063
  "instanceDistanceStart",
1006
- new fe(o, 1, 0)
1064
+ new me(o, 1, 0)
1007
1065
  ), e.setAttribute(
1008
1066
  "instanceDistanceEnd",
1009
- new fe(o, 1, 1)
1067
+ new me(o, 1, 1)
1010
1068
  ), this;
1011
1069
  }
1012
1070
  raycast(e, t) {
@@ -1016,17 +1074,17 @@ class kt extends Pe {
1016
1074
  );
1017
1075
  const o = e.params.Line2 !== void 0 && e.params.Line2.threshold || 0;
1018
1076
  E = e.ray;
1019
- const c = this.matrixWorld, r = this.geometry, a = this.material;
1020
- k = a.linewidth + o, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(c);
1077
+ const c = this.matrixWorld, n = this.geometry, a = this.material;
1078
+ L = a.linewidth + o, n.boundingSphere === null && n.computeBoundingSphere(), U.copy(n.boundingSphere).applyMatrix4(c);
1021
1079
  let l;
1022
1080
  if (i)
1023
- l = k * 0.5;
1081
+ l = L * 0.5;
1024
1082
  else {
1025
1083
  const u = Math.max(
1026
1084
  s.near,
1027
1085
  U.distanceToPoint(E.origin)
1028
1086
  );
1029
- l = Se(
1087
+ l = Ae(
1030
1088
  s,
1031
1089
  u,
1032
1090
  a.resolution
@@ -1034,31 +1092,31 @@ class kt extends Pe {
1034
1092
  }
1035
1093
  if (U.radius += l, E.intersectsSphere(U) === !1)
1036
1094
  return;
1037
- r.boundingBox === null && r.computeBoundingBox(), _.copy(r.boundingBox).applyMatrix4(c);
1038
- let m;
1095
+ n.boundingBox === null && n.computeBoundingBox(), R.copy(n.boundingBox).applyMatrix4(c);
1096
+ let f;
1039
1097
  if (i)
1040
- m = k * 0.5;
1098
+ f = L * 0.5;
1041
1099
  else {
1042
1100
  const u = Math.max(
1043
1101
  s.near,
1044
- _.distanceToPoint(E.origin)
1102
+ R.distanceToPoint(E.origin)
1045
1103
  );
1046
- m = Se(
1104
+ f = Ae(
1047
1105
  s,
1048
1106
  u,
1049
1107
  a.resolution
1050
1108
  );
1051
1109
  }
1052
- _.expandByScalar(m), E.intersectsBox(_) !== !1 && (i ? mt(this, t) : vt(this, s, t));
1110
+ R.expandByScalar(f), E.intersectsBox(R) !== !1 && (i ? xt(this, t) : St(this, s, t));
1053
1111
  }
1054
1112
  onBeforeRender(e) {
1055
1113
  const t = this.material.uniforms;
1056
- t && t.resolution && (e.getViewport(Q), this.material.uniforms.resolution.value.set(Q.z, Q.w));
1114
+ t && t.resolution && (e.getViewport(Y), this.material.uniforms.resolution.value.set(Y.z, Y.w));
1057
1115
  }
1058
1116
  }
1059
- const b = class b extends Z {
1117
+ const b = class b extends H {
1060
1118
  constructor(e) {
1061
- super(), this.objectType = "Node", this.onNodePointerIndex = [], this.options = z({
1119
+ super(), this.objectType = "Node", this.onNodePointerIndex = [], this.options = k({
1062
1120
  type: "2d"
1063
1121
  }, e);
1064
1122
  }
@@ -1079,8 +1137,8 @@ const b = class b extends Z {
1079
1137
  const e = this.options.children;
1080
1138
  if (!e) return;
1081
1139
  const t = e.getBoundingClientRect(), i = window.innerWidth, s = window.innerHeight, o = t.width, c = t.height;
1082
- let r = 0, a = 0;
1083
- o > i ? t.left > 0 && (r = -t.left) : t.left < 0 ? r = -t.left : t.right > i && (r = i - t.right, t.left + r < 0 && (r = -t.left)), c > s ? t.top > 0 && (a = -t.top) : t.top < 0 ? a = -t.top : t.bottom > s && (a = s - t.bottom, t.top + a < 0 && (a = -t.top)), (r !== 0 || a !== 0) && (e.style.transform = `translate(${r}px, ${a}px)`);
1140
+ let n = 0, a = 0;
1141
+ o > i ? t.left > 0 && (n = -t.left) : t.left < 0 ? n = -t.left : t.right > i && (n = i - t.right, t.left + n < 0 && (n = -t.left)), c > s ? t.top > 0 && (a = -t.top) : t.top < 0 ? a = -t.top : t.bottom > s && (a = s - t.bottom, t.top + a < 0 && (a = -t.top)), (n !== 0 || a !== 0) && (e.style.transform = `translate(${n}px, ${a}px)`);
1084
1142
  }
1085
1143
  ensureVisible() {
1086
1144
  const e = this.options.children;
@@ -1103,15 +1161,15 @@ const b = class b extends Z {
1103
1161
  }
1104
1162
  };
1105
1163
  b.observerMap = /* @__PURE__ */ new Map();
1106
- let je = b;
1164
+ let Ie = b;
1107
1165
  export {
1108
- be as B,
1109
- Tt as I,
1110
- kt as L,
1111
- Lt as M,
1112
- je as N,
1113
- Et as P,
1114
- it as R,
1115
- Z as a,
1116
- ht as g
1166
+ ge as B,
1167
+ Nt as I,
1168
+ Ut as L,
1169
+ Rt as M,
1170
+ Ie as N,
1171
+ Wt as P,
1172
+ ct as R,
1173
+ H as a,
1174
+ gt as g
1117
1175
  };
package/dist/index2.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var ye=Object.defineProperty,ge=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var re=Math.pow,te=(n,e,t)=>e in n?ye(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,k=(n,e)=>{for(var t in e||(e={}))ie.call(e,t)&&te(n,t,e[t]);if(W)for(var t of W(e))se.call(e,t)&&te(n,t,e[t]);return n},$=(n,e)=>ge(n,Me(e));var ne=(n,e)=>{var t={};for(var i in n)ie.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&W)for(var i of W(n))e.indexOf(i)<0&&se.call(n,i)&&(t[i]=n[i]);return t};var oe=(n,e,t)=>new Promise((i,s)=>{var o=c=>{try{r(t.next(c))}catch(u){s(u)}},l=c=>{try{r(t.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,l);r((t=t.apply(n,e)).next())});const z=require("d3-array"),Y=require("earcut"),a=require("three"),we=require("@turf/boolean-clockwise"),Z=require("./polar2Cartesian.js"),xe=require("delaunator"),Se=require("@turf/boolean-point-in-polygon"),N=require("d3-geo"),je=require("d3-geo-voronoi"),ae=require("d3-scale"),Ce=require("three/examples/jsm/lines/LineSegmentsGeometry"),Ae=require("three/examples/jsm/renderers/CSS2DRenderer"),ce=require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo-projection");const le=0,J=1,Pe=!1;class ve{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof a.Material)return e;if(e instanceof G?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof a.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof G)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof a.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof a.Material){for(const i of Object.values(e))i instanceof a.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof a.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof a.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Be=(n,e=1)=>{const t=new a.BufferGeometry;t.setAttribute("position",new a.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new a.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,s=new a.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=o=>{o.vertexShader=`
1
+ "use strict";var Se=Object.defineProperty,je=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var oe=Math.pow,se=(n,e,t)=>e in n?Se(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,k=(n,e)=>{for(var t in e||(e={}))re.call(e,t)&&se(n,t,e[t]);if(R)for(var t of R(e))ne.call(e,t)&&se(n,t,e[t]);return n},X=(n,e)=>je(n,Ce(e));var ae=(n,e)=>{var t={};for(var i in n)re.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&R)for(var i of R(n))e.indexOf(i)<0&&ne.call(n,i)&&(t[i]=n[i]);return t};var ce=(n,e,t)=>new Promise((i,s)=>{var o=c=>{try{r(t.next(c))}catch(u){s(u)}},l=c=>{try{r(t.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,l);r((t=t.apply(n,e)).next())});const z=require("d3-array"),J=require("earcut"),a=require("three"),Ae=require("@turf/boolean-clockwise"),H=require("./polar2Cartesian.js"),Pe=require("delaunator"),Be=require("@turf/boolean-point-in-polygon"),_=require("d3-geo"),Ie=require("d3-geo-voronoi"),le=require("d3-scale"),Oe=require("three/examples/jsm/lines/LineSegmentsGeometry"),De=require("three/examples/jsm/renderers/CSS2DRenderer"),ue=require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo-projection");const de=0,ee=1,Te=!1;class Me{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof a.Material)return e;if(e instanceof q?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof a.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof q)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof a.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof a.Material){for(const i of Object.values(e))i instanceof a.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof a.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof a.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const he=new a.Matrix4,xe=new a.Ray,K=new a.Sphere,W=new a.Vector3;function Ve(n,e){const t=this.geometry,i=this.matrixWorld,s=n.params.Points.threshold,o=t.drawRange;t.boundingSphere===null&&t.computeBoundingSphere(),K.copy(t.boundingSphere),K.applyMatrix4(i),K.radius+=s,he.copy(i).invert(),xe.copy(n.ray).applyMatrix4(he);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),r=t.index,u=t.attributes.position;if(r!==null){const p=Math.max(0,o.start),d=Math.min(r.count,o.start+o.count);for(let f=p,h=d;f<h;f++){const m=r.getX(f);W.fromBufferAttribute(u,m),fe(W,m,l,i,n,e,this)}}else{const p=Math.max(0,o.start),d=Math.min(u.count,o.start+o.count);for(let f=p,h=d;f<h;f++)W.fromBufferAttribute(u,f),fe(W,f,l,i,n,e,this)}}function fe(n,e,t,i,s,o,l){const r=new a.Vector3;xe.closestPointToPoint(n,r),r.applyMatrix4(i);const c=s.ray.origin.distanceTo(n),u=r.distanceTo(n),p=Math.asin(u/c);if(p<t){if(c<s.near||c>s.far)return;o.push({distance:c,distanceToRay:u,angleToRay:p,point:r,index:e,face:null,object:l})}}const Ee=(n,e=1)=>{const t=new a.BufferGeometry;t.setAttribute("position",new a.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new a.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,s=new a.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});s.onBeforeCompile=l=>{l.vertexShader=`
2
2
  attribute float scaleAtt;
3
- ${o.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new a.Points(t,s)},Ie=(n,e)=>{const t=new a.Object3D;e.forEach((i,s)=>{const o=Z.parseVector3(i.position),l=Z.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(l),t.updateMatrix();const r=t.matrix.clone();if(n instanceof a.InstancedMesh||n.isInstantiate)n.setMatrixAt(s,r);else if(n instanceof a.Points||n.type==="Points"){const u=n.geometry,v=u.attributes.position.array,d=u.attributes.scaleAtt.array,p=new a.Vector3,h=new a.Vector3,m=new a.Quaternion,f=s*3,b=s*1;r.decompose(p,m,h),v[f]=p.x,v[f+1]=p.y,v[f+2]=p.z,d[b]=Math.max(h.x,h.y,h.z),u.attributes.position.needsUpdate=!0,u.attributes.scaleAtt.needsUpdate=!0}})};class Oe{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerEnterOnStop(e){this.onPointerEvent("enterOnStop",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class De extends Oe{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const o=i.clone();return i.userData=s,o});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const s=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=s,s}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class G extends De{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0,this.isDispose=!1}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}lookAt(e){const t=e instanceof a.Vector3?e:new a.Vector3(...e);this.object3d.lookAt(t)}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}isActuallyVisible(){if(!this.object3d.visible)return!1;const e=this.parent;return e?e.isActuallyVisible():!0}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.isActuallyVisible()&&this._enableLayersRecursive(),this}hide(){return this.object3d.visible=!1,this._disableLayersRecursive(),this}_disableLayersRecursive(){var e;(e=this.object3d)==null||e.layers.disable(le),this.children.forEach(t=>{t._disableLayersRecursive()})}_enableLayersRecursive(){var e;this.object3d.visible&&((e=this.object3d)==null||e.layers.enable(le),this.children.forEach(t=>{t._enableLayersRecursive()}))}createGroup(){return this.object3d=new a.Group,this}createMesh(...e){return this.object3d=new a.Mesh(...e),this}createPoints(...e){return this.object3d=new a.Points(...e),this}createCSS2DObject(e){return this.object3d=new Ae.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ce.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ce.CSS3DSprite(e),this}createSprite(e){return this.object3d=new a.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new a.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new a.Vector3),center:e.getCenter(new a.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return oe(this,null,function*(){var u,v;const t=(u=e==null?void 0:e.recursive)!=null?u:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:s,objectOptions:o}=this;let l=e==null?void 0:e.create,r,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?r=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(l===void 0&&(l=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const h=e.instancedAttr.length;if(this.object3d instanceof a.Sprite)d.object3d=Be(this.object3d,h);else{const m=this.object3d,f=i?this.cloneMaterial():m.material;d.object3d=new a.InstancedMesh(m.geometry,f,h)}Ie(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),r=yield this.lead.draw(s,$(k({},o||{}),{create:l,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId&&d.keyName?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:r})))),r.isInstantiate=!0,r})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(e=!0){var t,i,s;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(o=>{o.enableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.add(this),this.object3d.layers.enable(J)),(s=this.pencil.composerController)==null||s.checkBloomComposerActive(),this.isBloom=!0}disableBloom(e=!0){var t,i,s;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(o=>{o.disableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.delete(this),this.object3d.layers.disable(J)),(s=this.pencil.composerController)==null||s.checkBloomComposerActive(),this.isBloom=!1}dispose(){var e,t;if(!this.isDispose&&(this.isDispose=!0,super.dispose(),this.isBloom&&(this.disableBloom(!1),(e=this.pencil.composerController)==null||e.checkBloomComposerActive()),(t=this.lead)==null||t.disableCursor(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack)){const i=new ve;i.disposeMaterial=!1,i.track(this),i.dispose()}}}function Ve(n,e){return n.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const l=N.geoDistance(o,s)*180/Math.PI;if(l>e){const r=N.geoInterpolate(s,o),c=1/Math.ceil(l/e);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=o)}),i})}function Te(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const o=Math.round(re(360/n,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=h=>h/l*360%360-180,c=h=>Math.acos(2*h/o-1)/Math.PI*180-90,u=h=>o*(Math.cos((h+90)*Math.PI/180)+1)/2,v=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):o-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,p=[];for(let h=v[0];h<=v[1];h++){const m=r(h);d(m)&&p.push([m,c(h)])}return p}function H(n,e,t=!1){return t?N.geoContains(e,n):Se(n,e)}function Ee(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[o,l]]=N.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(l-s))<e)return[];const r=i>o||l>=89||s<=-89;return Te(e,{minLng:i,maxLng:o,minLat:s,maxLat:l}).filter(c=>H(c,t,r))}function Le(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Ve(n,e),o=z.merge(s),l=Ee(n,e),r=[...o,...l],c={type:"Polygon",coordinates:n},[[u,v],[d,p]]=N.geoBounds(c),h=u>d||p>=89||v<=-89;let m=[];if(h){const g=je.geoVoronoi(r).triangles(),S=new Map(r.map(([P,B],E)=>[`${P}-${B}`,E]));g.features.forEach(P=>{const B=P.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(B.forEach(([I,F])=>{const _=`${I}-${F}`;S.has(_)&&E.push(S.get(_))}),E.length===3){if(E.some(I=>I<o.length)){const I=P.properties.circumcenter;if(!H(I,c,h))return}m.push(...E)}})}else if(l.length){const g=xe.from(r);for(let S=0,P=g.triangles.length;S<P;S+=3){const B=[2,1,0].map(I=>g.triangles[S+I]),E=B.map(I=>r[I]);if(B.some(I=>I<o.length)){const I=[0,1].map(F=>z.mean(E,_=>_[F]));if(!H(I,c,h))continue}m.push(...B)}}else{const{vertices:g,holes:S=[]}=Y.flatten(s);m=Y(g,S,2)}let f=t?[t[0],t[2]]:z.extent(r,g=>g[0]),b=t?[t[1],t[3]]:z.extent(r,g=>g[1]);if(i){const[g,S]=i([f[0],b[0]]),[P,B]=i([f[1],b[1]]);f=[g,P],b=[-S,-B]}const j=ae.scaleLinear(f,[0,1]),C=ae.scaleLinear(b,[0,1]),O=r.map(([g,S])=>{if(i){const[P,B]=i([g,S]);return[j(P),C(-B)]}else return[j(g),C(S)]});return{contour:s,triangles:{points:r,indices:m,uvs:O}}}const ue=new a.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(n,e,t,i){const s=n.map(o=>o.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,e]}return t?Z.polar2Cartesian(l,r,e):[l,r,e]}));return Y.flatten(s)}function ke(n,e,t,i,s){const{vertices:o,holes:l}=q(n,e,i,s),{vertices:r}=q(n,t,i,s),c=z.merge([r,o]),u=Math.round(r.length/3),v=new Set(l);let d=0;const p=[];for(let m=0;m<u;m++){let f=m+1;if(f===u)f=d;else if(v.has(f)){const b=f;f=d,d=b}p.push(m,m+u,f+u),p.push(f+u,f,m)}const h=[];for(let m=1;m>=0;m--)for(let f=0;f<u;f+=1)h.push(f/(u-1),m);return{indices:p,vertices:c,uvs:h,topVerts:r}}function de(n,e,t,i,s,o){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:q([n.points],e,s,o).vertices,uvs:t}}const be=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{n.forEach(j=>{we(j)||j.reverse()});const{contour:v,triangles:d}=Le(n,{resolution:i,bbox:u,projection:c});let p={},h;o&&(p=ke(v,e!=null?e:t,t!=null?t:e,s,c),h=p.topVerts);let m=[];(l||r)&&(m=z.merge(d.uvs));let f={};l&&(f=de(d,e,m,!1,s,c));let b={};return r&&(b=de(d,t,m,!0,s,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:f,topCap:b,topVerts:h}};class ze extends a.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:o,hasBottom:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:h,bottomCap:m,topCap:f}=be(k({},this.parameters));let b=[],j=[],C=[],O=0;const A=g=>{const S=Math.round(b.length/3),P=C.length;b=b.concat(g.vertices),j=j.concat(g.uvs),C=C.concat(S?g.indices.map(B=>B+S):g.indices),this.addGroup(P,C.length-P,O++)};s&&o&&A(f),r&&(A(p),this.userData.topVerts=u?q(d,i+u,c,v).vertices:h),l&&A(m),s&&!o&&A(f),this.setIndex(C),this[ue]("position",new a.Float32BufferAttribute(b,3)),this[ue]("uv",new a.Float32BufferAttribute(j,2)),this.computeVertexNormals()}}const Ne=`
3
+ ${l.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
+ `};const o=new a.Points(t,s);return o.raycast=Ve,o},Le=(n,e)=>{const t=new a.Object3D;e.forEach((i,s)=>{const o=H.parseVector3(i.position),l=H.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(l),t.updateMatrix();const r=t.matrix.clone();if(n instanceof a.InstancedMesh||n.isInstantiate)n.setMatrixAt(s,r);else if(n instanceof a.Points||n.type==="Points"){const u=n.geometry,p=u.attributes.position.array,d=u.attributes.scaleAtt.array,f=new a.Vector3,h=new a.Vector3,m=new a.Quaternion,v=s*3,b=s*1;r.decompose(f,m,h),p[v]=f.x,p[v+1]=f.y,p[v+2]=f.z,d[b]=Math.max(h.x,h.y,h.z),u.attributes.position.needsUpdate=!0,u.attributes.scaleAtt.needsUpdate=!0}})};class ke{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerEnterOnStop(e){this.onPointerEvent("enterOnStop",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class ze extends ke{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const o=i.clone();return i.userData=s,o});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const s=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=s,s}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class q extends ze{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0,this.isDispose=!1}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}lookAt(e){const t=e instanceof a.Vector3?e:new a.Vector3(...e);this.object3d.lookAt(t)}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}isActuallyVisible(){if(!this.object3d.visible)return!1;const e=this.parent;return e?e.isActuallyVisible():!0}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.isActuallyVisible()&&this._enableLayersRecursive(),this}hide(){return this.object3d.visible=!1,this._disableLayersRecursive(),this}_disableLayersRecursive(){var e;(e=this.object3d)==null||e.layers.disable(de),this.children.forEach(t=>{t._disableLayersRecursive()})}_enableLayersRecursive(){var e;this.object3d.visible&&((e=this.object3d)==null||e.layers.enable(de),this.children.forEach(t=>{t._enableLayersRecursive()}))}createGroup(){return this.object3d=new a.Group,this}createMesh(...e){return this.object3d=new a.Mesh(...e),this}createPoints(...e){return this.object3d=new a.Points(...e),this}createCSS2DObject(e){return this.object3d=new De.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ue.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ue.CSS3DSprite(e),this}createSprite(e){return this.object3d=new a.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new a.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new a.Vector3),center:e.getCenter(new a.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return ce(this,null,function*(){var u,p;const t=(u=e==null?void 0:e.recursive)!=null?u:!0,i=(p=e==null?void 0:e.cloneMaterial)!=null?p:!1,{objectType:s,objectOptions:o}=this;let l=e==null?void 0:e.create,r,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?r=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(l===void 0&&(l=d=>{var f;if(this.object3d){if((f=e==null?void 0:e.instancedAttr)!=null&&f.length){const h=e.instancedAttr.length;if(this.object3d instanceof a.Sprite)d.object3d=Ee(this.object3d,h);else{const m=this.object3d,v=i?this.cloneMaterial():m.material;d.object3d=new a.InstancedMesh(m.geometry,v,h)}Le(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),r=yield this.lead.draw(s,X(k({},o||{}),{create:l,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId&&d.keyName?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:r})))),r.isInstantiate=!0,r})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(e=!0){var t,i,s;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(o=>{o.enableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.add(this),this.object3d.layers.enable(ee)),(s=this.pencil.composerController)==null||s.checkBloomComposerActive(),this.isBloom=!0}disableBloom(e=!0){var t,i,s;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(o=>{o.disableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.delete(this),this.object3d.layers.disable(ee)),(s=this.pencil.composerController)==null||s.checkBloomComposerActive(),this.isBloom=!1}dispose(){var e,t;if(!this.isDispose&&(this.isDispose=!0,super.dispose(),this.isBloom&&(this.disableBloom(!1),(e=this.pencil.composerController)==null||e.checkBloomComposerActive()),(t=this.lead)==null||t.disableCursor(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack)){const i=new Me;i.disposeMaterial=!1,i.track(this),i.dispose()}}}function _e(n,e){return n.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const l=_.geoDistance(o,s)*180/Math.PI;if(l>e){const r=_.geoInterpolate(s,o),c=1/Math.ceil(l/e);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=o)}),i})}function Ne(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const o=Math.round(oe(360/n,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=h=>h/l*360%360-180,c=h=>Math.acos(2*h/o-1)/Math.PI*180-90,u=h=>o*(Math.cos((h+90)*Math.PI/180)+1)/2,p=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):o-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,f=[];for(let h=p[0];h<=p[1];h++){const m=r(h);d(m)&&f.push([m,c(h)])}return f}function te(n,e,t=!1){return t?_.geoContains(e,n):Be(n,e)}function Re(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[o,l]]=_.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(l-s))<e)return[];const r=i>o||l>=89||s<=-89;return Ne(e,{minLng:i,maxLng:o,minLat:s,maxLat:l}).filter(c=>te(c,t,r))}function We(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=_e(n,e),o=z.merge(s),l=Re(n,e),r=[...o,...l],c={type:"Polygon",coordinates:n},[[u,p],[d,f]]=_.geoBounds(c),h=u>d||f>=89||p<=-89;let m=[];if(h){const g=Ie.geoVoronoi(r).triangles(),S=new Map(r.map(([P,B],E)=>[`${P}-${B}`,E]));g.features.forEach(P=>{const B=P.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(B.forEach(([I,F])=>{const N=`${I}-${F}`;S.has(N)&&E.push(S.get(N))}),E.length===3){if(E.some(I=>I<o.length)){const I=P.properties.circumcenter;if(!te(I,c,h))return}m.push(...E)}})}else if(l.length){const g=Pe.from(r);for(let S=0,P=g.triangles.length;S<P;S+=3){const B=[2,1,0].map(I=>g.triangles[S+I]),E=B.map(I=>r[I]);if(B.some(I=>I<o.length)){const I=[0,1].map(F=>z.mean(E,N=>N[F]));if(!te(I,c,h))continue}m.push(...B)}}else{const{vertices:g,holes:S=[]}=J.flatten(s);m=J(g,S,2)}let v=t?[t[0],t[2]]:z.extent(r,g=>g[0]),b=t?[t[1],t[3]]:z.extent(r,g=>g[1]);if(i){const[g,S]=i([v[0],b[0]]),[P,B]=i([v[1],b[1]]);v=[g,P],b=[-S,-B]}const j=le.scaleLinear(v,[0,1]),C=le.scaleLinear(b,[0,1]),O=r.map(([g,S])=>{if(i){const[P,B]=i([g,S]);return[j(P),C(-B)]}else return[j(g),C(S)]});return{contour:s,triangles:{points:r,indices:m,uvs:O}}}const pe=new a.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function $(n,e,t,i){const s=n.map(o=>o.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,e]}return t?H.polar2Cartesian(l,r,e):[l,r,e]}));return J.flatten(s)}function Ue(n,e,t,i,s){const{vertices:o,holes:l}=$(n,e,i,s),{vertices:r}=$(n,t,i,s),c=z.merge([r,o]),u=Math.round(r.length/3),p=new Set(l);let d=0;const f=[];for(let m=0;m<u;m++){let v=m+1;if(v===u)v=d;else if(p.has(v)){const b=v;v=d,d=b}f.push(m,m+u,v+u),f.push(v+u,v,m)}const h=[];for(let m=1;m>=0;m--)for(let v=0;v<u;v+=1)h.push(v/(u-1),m);return{indices:f,vertices:c,uvs:h,topVerts:r}}function me(n,e,t,i,s,o){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:$([n.points],e,s,o).vertices,uvs:t}}const we=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{n.forEach(j=>{Ae(j)||j.reverse()});const{contour:p,triangles:d}=We(n,{resolution:i,bbox:u,projection:c});let f={},h;o&&(f=Ue(p,e!=null?e:t,t!=null?t:e,s,c),h=f.topVerts);let m=[];(l||r)&&(m=z.merge(d.uvs));let v={};l&&(v=me(d,e,m,!1,s,c));let b={};return r&&(b=me(d,t,m,!0,s,c)),{contour:p,triangles:d,sideTorso:f,bottomCap:v,topCap:b,topVerts:h}};class Ge extends a.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:o,hasBottom:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:p}=this.parameters,{contour:d,sideTorso:f,topVerts:h,bottomCap:m,topCap:v}=we(k({},this.parameters));let b=[],j=[],C=[],O=0;const A=g=>{const S=Math.round(b.length/3),P=C.length;b=b.concat(g.vertices),j=j.concat(g.uvs),C=C.concat(S?g.indices.map(B=>B+S):g.indices),this.addGroup(P,C.length-P,O++)};s&&o&&A(v),r&&(A(f),this.userData.topVerts=u?$(d,i+u,c,p).vertices:h),l&&A(m),s&&!o&&A(v),this.setIndex(C),this[pe]("position",new a.Float32BufferAttribute(b,3)),this[pe]("uv",new a.Float32BufferAttribute(j,2)),this.computeVertexNormals()}}const qe=`
5
5
  #include <fog_pars_fragment>
6
6
  #include <logdepthbuf_pars_fragment>
7
7
 
@@ -45,7 +45,7 @@ void main() {
45
45
  #include <tonemapping_fragment>
46
46
  #include <colorspace_fragment>
47
47
  }
48
- `,_e=`
48
+ `,$e=`
49
49
  #include <common>
50
50
  #include <logdepthbuf_pars_vertex>
51
51
  #include <fog_pars_vertex>
@@ -137,4 +137,4 @@ void main() {
137
137
  #include <logdepthbuf_vertex>
138
138
  #include <fog_vertex>
139
139
  }
140
- `;class We extends a.ShaderMaterial{constructor(e={}){const C=e,{lineWidth:t=1,color:i="#ffffff",opacity:s=1,map:o=null,dashOffset:l=0,dashArray:r=0,dashRatio:c=0,sizeAttenuation:u=!0,offsetLoop:v=!0,offset:d=new a.Vector2(0,0),scaleDown:p=0,alphaMap:h=void 0,alphaTest:m=0,repeat:f=new a.Vector2(1,1),resolution:b=new a.Vector2(1,1)}=C,j=ne(C,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super($(k({},j),{uniforms:{lineWidth:{value:t},color:{value:new a.Color(i)},opacity:{value:s},map:{value:o},useMap:{value:o?1:0},resolution:{value:b},sizeAttenuation:{value:u?1:0},offset:{value:d},offsetLoop:{value:v?1:0},dashArray:{value:r},dashOffset:{value:l},dashRatio:{value:c},useDash:{value:r>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:h},useAlphaMap:{value:h?1:0},repeat:{value:f}},vertexShader:_e,fragmentShader:Ne})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new a.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const K=new a.Vector4,he=new a.Vector3,fe=new a.Vector3,M=new a.Vector4,w=new a.Vector4,D=new a.Vector4,Q=new a.Vector3,X=new a.Matrix4,x=new a.Line3,pe=new a.Vector3,U=new a.Box3,R=new a.Sphere,V=new a.Vector4;let T,L;function me(n,e,t){return V.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),V.multiplyScalar(1/V.w),V.x=L/t.width,V.y=L/t.height,V.applyMatrix4(n.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ue(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){x.start.fromBufferAttribute(s,r),x.end.fromBufferAttribute(o,r),x.applyMatrix4(t);const u=new a.Vector3,v=new a.Vector3;T.distanceSqToSegment(x.start,x.end,v,u),v.distanceTo(u)<L*.5&&e.push({point:v,pointOnLine:u,distance:T.origin.distanceTo(v),object:n,face:null,faceIndex:r,uv:null,uv1:null})}}function Re(n,e,t){const i=e.projectionMatrix,o=n.material.resolution,l=n.matrixWorld,r=n.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,v=Math.min(r.instanceCount,c.count),d=-e.near;T.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=o.x/2,D.y*=o.y/2,D.z=0,Q.copy(D),X.multiplyMatrices(e.matrixWorldInverse,l);for(let p=0,h=v;p<h;p++){if(M.fromBufferAttribute(c,p),w.fromBufferAttribute(u,p),M.w=1,w.w=1,M.applyMatrix4(X),w.applyMatrix4(X),M.z>d&&w.z>d)continue;if(M.z>d){const O=M.z-w.z,A=(M.z-d)/O;M.lerp(w,A)}else if(w.z>d){const O=w.z-M.z,A=(w.z-d)/O;w.lerp(M,A)}M.applyMatrix4(i),w.applyMatrix4(i),M.multiplyScalar(1/M.w),w.multiplyScalar(1/w.w),M.x*=o.x/2,M.y*=o.y/2,w.x*=o.x/2,w.y*=o.y/2,x.start.copy(M),x.start.z=0,x.end.copy(w),x.end.z=0;const f=x.closestPointToPointParameter(Q,!0);x.at(f,pe);const b=a.MathUtils.lerp(M.z,w.z,f),j=b>=-1&&b<=1,C=Q.distanceTo(pe)<L*.5;if(j&&C){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(u,p),x.start.applyMatrix4(l),x.end.applyMatrix4(l);const O=new a.Vector3,A=new a.Vector3;T.distanceSqToSegment(x.start,x.end,A,O),t.push({point:A,pointOnLine:O,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ge extends a.Mesh{constructor(e=new Ce.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let l=0,r=0,c=t.count;l<c;l++,r+=2)he.fromBufferAttribute(t,l),fe.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+he.distanceTo(fe);const o=new a.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new a.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new a.InterleavedBufferAttribute(o,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.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 o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;T=e.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;L=c.linewidth+o,r.boundingSphere===null&&r.computeBoundingSphere(),R.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=L*.5;else{const d=Math.max(s.near,R.distanceToPoint(T.origin));u=me(s,d,c.resolution)}if(R.radius+=u,T.intersectsSphere(R)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),U.copy(r.boundingBox).applyMatrix4(l);let v;if(i)v=L*.5;else{const d=Math.max(s.near,U.distanceToPoint(T.origin));v=me(s,d,c.resolution)}U.expandByScalar(v),T.intersectsBox(U)!==!1&&(i?Ue(this,t):Re(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(K),this.material.uniforms.resolution.value.set(K.z,K.w))}}const y=class y extends G{constructor(e){super(),this.objectType="Node",this.onNodePointerIndex=[],this.options=k({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,o=t.width,l=t.height;let r=0,c=0;o>i?t.left>0&&(r=-t.left):t.left<0?r=-t.left:t.right>i&&(r=i-t.right,t.left+r<0&&(r=-t.left)),l>s?t.top>0&&(c=-t.top):t.top<0?c=-t.top:t.bottom>s&&(c=s-t.bottom,t.top+c<0&&(c=-t.top)),(r!==0||c!==0)&&(e.style.transform=`translate(${r}px, ${c}px)`)}ensureVisible(){const e=this.options.children;e&&(e.style.transform&&(e.style.transform=""),!y.observerMap.has(e)&&(y.sharedObserver||(y.sharedObserver=new IntersectionObserver(t=>{t.forEach(i=>{const s=i.target,o=y.observerMap.get(s);o&&i.isIntersecting&&(o.moveElementToViewport(),y.observerMap.delete(s),y.sharedObserver&&(y.sharedObserver.unobserve(s),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)))})})),y.observerMap.set(e,this),y.sharedObserver.observe(e)))}onPointerEvent(e,t){const i=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){const e=this.options.children;e&&y.sharedObserver&&(y.observerMap.delete(e),y.sharedObserver.unobserve(e),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)),this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}};y.observerMap=new Map;let ee=y;exports.BLOOM_SCENE=J;exports.BaseObject=G;exports.IS_DEV=Pe;exports.LineSegments2=Ge;exports.MeshLineMaterial=We;exports.Node=ee;exports.PolygonGeometry=ze;exports.ResourceTracker=ve;exports.getMetas=be;
140
+ `;class Fe extends a.ShaderMaterial{constructor(e={}){const C=e,{lineWidth:t=1,color:i="#ffffff",opacity:s=1,map:o=null,dashOffset:l=0,dashArray:r=0,dashRatio:c=0,sizeAttenuation:u=!0,offsetLoop:p=!0,offset:d=new a.Vector2(0,0),scaleDown:f=0,alphaMap:h=void 0,alphaTest:m=0,repeat:v=new a.Vector2(1,1),resolution:b=new a.Vector2(1,1)}=C,j=ae(C,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(X(k({},j),{uniforms:{lineWidth:{value:t},color:{value:new a.Color(i)},opacity:{value:s},map:{value:o},useMap:{value:o?1:0},resolution:{value:b},sizeAttenuation:{value:u?1:0},offset:{value:d},offsetLoop:{value:p?1:0},dashArray:{value:r},dashOffset:{value:l},dashRatio:{value:c},useDash:{value:r>0?1:0},scaleDown:{value:f/10},alphaTest:{value:m},alphaMap:{value:h},useAlphaMap:{value:h?1:0},repeat:{value:v}},vertexShader:$e,fragmentShader:qe})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new a.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const Q=new a.Vector4,ve=new a.Vector3,be=new a.Vector3,M=new a.Vector4,x=new a.Vector4,D=new a.Vector4,Y=new a.Vector3,Z=new a.Matrix4,w=new a.Line3,ye=new a.Vector3,U=new a.Box3,G=new a.Sphere,T=new a.Vector4;let V,L;function ge(n,e,t){return T.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),T.multiplyScalar(1/T.w),T.x=L/t.width,T.y=L/t.height,T.applyMatrix4(n.projectionMatrixInverse),T.multiplyScalar(1/T.w),Math.abs(Math.max(T.x,T.y))}function Xe(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){w.start.fromBufferAttribute(s,r),w.end.fromBufferAttribute(o,r),w.applyMatrix4(t);const u=new a.Vector3,p=new a.Vector3;V.distanceSqToSegment(w.start,w.end,p,u),p.distanceTo(u)<L*.5&&e.push({point:p,pointOnLine:u,distance:V.origin.distanceTo(p),object:n,face:null,faceIndex:r,uv:null,uv1:null})}}function Ke(n,e,t){const i=e.projectionMatrix,o=n.material.resolution,l=n.matrixWorld,r=n.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,p=Math.min(r.instanceCount,c.count),d=-e.near;V.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=o.x/2,D.y*=o.y/2,D.z=0,Y.copy(D),Z.multiplyMatrices(e.matrixWorldInverse,l);for(let f=0,h=p;f<h;f++){if(M.fromBufferAttribute(c,f),x.fromBufferAttribute(u,f),M.w=1,x.w=1,M.applyMatrix4(Z),x.applyMatrix4(Z),M.z>d&&x.z>d)continue;if(M.z>d){const O=M.z-x.z,A=(M.z-d)/O;M.lerp(x,A)}else if(x.z>d){const O=x.z-M.z,A=(x.z-d)/O;x.lerp(M,A)}M.applyMatrix4(i),x.applyMatrix4(i),M.multiplyScalar(1/M.w),x.multiplyScalar(1/x.w),M.x*=o.x/2,M.y*=o.y/2,x.x*=o.x/2,x.y*=o.y/2,w.start.copy(M),w.start.z=0,w.end.copy(x),w.end.z=0;const v=w.closestPointToPointParameter(Y,!0);w.at(v,ye);const b=a.MathUtils.lerp(M.z,x.z,v),j=b>=-1&&b<=1,C=Y.distanceTo(ye)<L*.5;if(j&&C){w.start.fromBufferAttribute(c,f),w.end.fromBufferAttribute(u,f),w.start.applyMatrix4(l),w.end.applyMatrix4(l);const O=new a.Vector3,A=new a.Vector3;V.distanceSqToSegment(w.start,w.end,A,O),t.push({point:A,pointOnLine:O,distance:V.origin.distanceTo(A),object:n,face:null,faceIndex:f,uv:null,uv1:null})}}}class Qe extends a.Mesh{constructor(e=new Oe.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let l=0,r=0,c=t.count;l<c;l++,r+=2)ve.fromBufferAttribute(t,l),be.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+ve.distanceTo(be);const o=new a.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new a.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new a.InterleavedBufferAttribute(o,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.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 o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;V=e.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;L=c.linewidth+o,r.boundingSphere===null&&r.computeBoundingSphere(),G.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=L*.5;else{const d=Math.max(s.near,G.distanceToPoint(V.origin));u=ge(s,d,c.resolution)}if(G.radius+=u,V.intersectsSphere(G)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),U.copy(r.boundingBox).applyMatrix4(l);let p;if(i)p=L*.5;else{const d=Math.max(s.near,U.distanceToPoint(V.origin));p=ge(s,d,c.resolution)}U.expandByScalar(p),V.intersectsBox(U)!==!1&&(i?Xe(this,t):Ke(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Q),this.material.uniforms.resolution.value.set(Q.z,Q.w))}}const y=class y extends q{constructor(e){super(),this.objectType="Node",this.onNodePointerIndex=[],this.options=k({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,o=t.width,l=t.height;let r=0,c=0;o>i?t.left>0&&(r=-t.left):t.left<0?r=-t.left:t.right>i&&(r=i-t.right,t.left+r<0&&(r=-t.left)),l>s?t.top>0&&(c=-t.top):t.top<0?c=-t.top:t.bottom>s&&(c=s-t.bottom,t.top+c<0&&(c=-t.top)),(r!==0||c!==0)&&(e.style.transform=`translate(${r}px, ${c}px)`)}ensureVisible(){const e=this.options.children;e&&(e.style.transform&&(e.style.transform=""),!y.observerMap.has(e)&&(y.sharedObserver||(y.sharedObserver=new IntersectionObserver(t=>{t.forEach(i=>{const s=i.target,o=y.observerMap.get(s);o&&i.isIntersecting&&(o.moveElementToViewport(),y.observerMap.delete(s),y.sharedObserver&&(y.sharedObserver.unobserve(s),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)))})})),y.observerMap.set(e,this),y.sharedObserver.observe(e)))}onPointerEvent(e,t){const i=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){const e=this.options.children;e&&y.sharedObserver&&(y.observerMap.delete(e),y.sharedObserver.unobserve(e),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)),this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}};y.observerMap=new Map;let ie=y;exports.BLOOM_SCENE=ee;exports.BaseObject=q;exports.IS_DEV=Te;exports.LineSegments2=Qe;exports.MeshLineMaterial=Fe;exports.Node=ie;exports.PolygonGeometry=Ge;exports.ResourceTracker=Me;exports.getMetas=we;
@@ -1,3 +1,3 @@
1
- import { Sprite, BufferGeometry, PointsMaterial, Points } from 'three';
1
+ import { BufferGeometry, Points, PointsMaterial, type Sprite } from 'three';
2
2
  declare const _default: (object3d: Sprite, count?: number) => Points<BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, PointsMaterial, import("three").Object3DEventMap>;
3
3
  export default _default;
@@ -0,0 +1 @@
1
+ export declare function proposedRaycast(raycaster: any, intersects: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.17.0-beta.35",
3
+ "version": "0.17.0-beta.36",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",