gl-draw 0.17.0-beta.40 → 0.17.0-beta.42

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,21 +1,21 @@
1
- var _e = Object.defineProperty, Ne = Object.defineProperties;
2
- var Re = Object.getOwnPropertyDescriptors;
3
- var _ = Object.getOwnPropertySymbols;
1
+ var Re = Object.defineProperty, _e = Object.defineProperties;
2
+ var Ne = Object.getOwnPropertyDescriptors;
3
+ var R = Object.getOwnPropertySymbols;
4
4
  var oe = Object.prototype.hasOwnProperty, ae = Object.prototype.propertyIsEnumerable;
5
- var ce = Math.pow, re = (r, e, t) => e in r ? _e(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, k = (r, e) => {
5
+ var ce = Math.pow, re = (r, e, t) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, L = (r, e) => {
6
6
  for (var t in e || (e = {}))
7
7
  oe.call(e, t) && re(r, t, e[t]);
8
- if (_)
9
- for (var t of _(e))
8
+ if (R)
9
+ for (var t of R(e))
10
10
  ae.call(e, t) && re(r, t, e[t]);
11
11
  return r;
12
- }, X = (r, e) => Ne(r, Re(e));
12
+ }, X = (r, e) => _e(r, Ne(e));
13
13
  var le = (r, e) => {
14
14
  var t = {};
15
15
  for (var i in r)
16
16
  oe.call(r, i) && e.indexOf(i) < 0 && (t[i] = r[i]);
17
- if (r != null && _)
18
- for (var i of _(r))
17
+ if (r != null && R)
18
+ for (var i of R(r))
19
19
  e.indexOf(i) < 0 && ae.call(r, i) && (t[i] = r[i]);
20
20
  return t;
21
21
  };
@@ -37,7 +37,7 @@ var ue = (r, e, t) => new Promise((i, s) => {
37
37
  });
38
38
  import { merge as ie, mean as Ue, extent as he } from "d3-array";
39
39
  import Ge, { flatten as Oe } from "earcut";
40
- import { Material as de, Object3D as G, Texture as fe, Vector3 as S, Matrix4 as De, Ray as $e, Sphere as ze, BufferGeometry as se, Float32BufferAttribute as $, PointsMaterial as Fe, Points as ne, InstancedMesh as Ee, Quaternion as qe, Group as Xe, Mesh as Le, Sprite as pe, Box3 as ke, ShaderMaterial as Ke, Vector2 as K, Color as me, Vector4 as V, Line3 as Qe, InstancedInterleavedBuffer as Ye, InterleavedBufferAttribute as ve, MathUtils as Ze } from "three";
40
+ import { Material as de, Object3D as G, Texture as fe, Vector3 as S, Matrix4 as De, Ray as $e, Sphere as ke, BufferGeometry as se, Float32BufferAttribute as $, PointsMaterial as Fe, Points as ne, InstancedMesh as ze, Quaternion as qe, Group as Xe, Mesh as Ee, Sprite as pe, Box3 as Le, ShaderMaterial as Ke, Vector2 as K, Color as me, Vector4 as V, Line3 as Qe, InstancedInterleavedBuffer as Ye, InterleavedBufferAttribute as ve, MathUtils as Ze } from "three";
41
41
  import Je from "@turf/boolean-clockwise";
42
42
  import { p as be, W as Q, c as ye } from "./cartographicToCartesian.module.js";
43
43
  import He from "delaunator";
@@ -49,7 +49,7 @@ import { LineSegmentsGeometry as rt } from "three/examples/jsm/lines/LineSegment
49
49
  import { CSS2DObject as ot } from "three/examples/jsm/renderers/CSS2DRenderer";
50
50
  import { CSS3DObject as at, CSS3DSprite as ct } from "three/examples/jsm/renderers/CSS3DRenderer";
51
51
  import "d3-geo-projection";
52
- const Me = 0, xe = 1, Nt = !1;
52
+ const Me = 0, xe = 1, _t = !1;
53
53
  class lt {
54
54
  constructor() {
55
55
  this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
@@ -91,7 +91,7 @@ class lt {
91
91
  }), e.length = 0, this.resources.clear();
92
92
  }
93
93
  }
94
- const we = /* @__PURE__ */ new De(), We = /* @__PURE__ */ new $e(), Y = /* @__PURE__ */ new ze(), N = /* @__PURE__ */ new S();
94
+ const we = /* @__PURE__ */ new De(), We = /* @__PURE__ */ new $e(), Y = /* @__PURE__ */ new ke(), _ = /* @__PURE__ */ new S();
95
95
  function ut(r, e) {
96
96
  const t = this.geometry, i = this.matrixWorld, s = r.params.Points.threshold, o = t.drawRange;
97
97
  t.boundingSphere === null && t.computeBoundingSphere(), Y.copy(t.boundingSphere), Y.applyMatrix4(i), Y.radius += s, we.copy(i).invert(), We.copy(r.ray).applyMatrix4(we);
@@ -100,8 +100,8 @@ function ut(r, e) {
100
100
  const d = Math.max(0, o.start), u = Math.min(n.count, o.start + o.count);
101
101
  for (let f = d, l = u; f < l; f++) {
102
102
  const p = n.getX(f);
103
- N.fromBufferAttribute(h, p), Se(
104
- N,
103
+ _.fromBufferAttribute(h, p), Se(
104
+ _,
105
105
  p,
106
106
  c,
107
107
  i,
@@ -116,8 +116,8 @@ function ut(r, e) {
116
116
  o.start + o.count
117
117
  );
118
118
  for (let f = d, l = u; f < l; f++)
119
- N.fromBufferAttribute(h, f), Se(
120
- N,
119
+ _.fromBufferAttribute(h, f), Se(
120
+ _,
121
121
  f,
122
122
  c,
123
123
  i,
@@ -186,7 +186,7 @@ const ht = (r, e = 1) => {
186
186
  const o = be(i.position), c = be(i.scale || [1, 1, 1]);
187
187
  t.position.copy(o), t.scale.copy(c), t.updateMatrix();
188
188
  const n = t.matrix.clone();
189
- if (r instanceof Ee || r.isInstantiate)
189
+ if (r instanceof ze || r.isInstantiate)
190
190
  r.setMatrixAt(s, n);
191
191
  else if (r instanceof ne || r.type === "Points") {
192
192
  const h = r.geometry, d = h.attributes.position.array, u = h.attributes.scaleAtt.array, f = new S(), l = new S(), p = new qe(), m = s * 3, b = s * 1;
@@ -369,7 +369,7 @@ class ee extends pt {
369
369
  return this.object3d = new Xe(), this;
370
370
  }
371
371
  createMesh(...e) {
372
- return this.object3d = new Le(...e), this;
372
+ return this.object3d = new Ee(...e), this;
373
373
  }
374
374
  createPoints(...e) {
375
375
  return this.object3d = new ne(...e), this;
@@ -392,7 +392,7 @@ class ee extends pt {
392
392
  }), this;
393
393
  }
394
394
  getSize() {
395
- const e = new ke().setFromObject(this.object3d);
395
+ const e = new Le().setFromObject(this.object3d);
396
396
  return {
397
397
  min: e.min,
398
398
  max: e.max,
@@ -424,7 +424,7 @@ class ee extends pt {
424
424
  u.object3d = ht(this.object3d, l);
425
425
  else {
426
426
  const p = this.object3d, m = i ? this.cloneMaterial() : p.material;
427
- u.object3d = new Ee(
427
+ u.object3d = new ze(
428
428
  p.geometry,
429
429
  m,
430
430
  l
@@ -435,7 +435,7 @@ class ee extends pt {
435
435
  u.object3d = this.object3d.clone(!1), i && u.object3d.material && (u.object3d.material = this.cloneMaterial());
436
436
  u.object3d.userData.prefab && delete u.object3d.userData.prefab;
437
437
  }
438
- }), n = yield this.lead.draw(s, X(k({}, o || {}), {
438
+ }), n = yield this.lead.draw(s, X(L({}, o || {}), {
439
439
  create: c,
440
440
  prefab: !1,
441
441
  keyType: this.keyType,
@@ -548,15 +548,15 @@ function yt(r, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
548
548
  let p = [];
549
549
  if (l) {
550
550
  const y = nt(n).triangles(), w = new Map(
551
- n.map(([I, T], E) => [`${I}-${T}`, E])
551
+ n.map(([I, T], z) => [`${I}-${T}`, z])
552
552
  );
553
553
  y.features.forEach((I) => {
554
- const T = I.geometry.coordinates[0].slice(0, 3).reverse(), E = [];
554
+ const T = I.geometry.coordinates[0].slice(0, 3).reverse(), z = [];
555
555
  if (T.forEach(([A, q]) => {
556
556
  const W = `${A}-${q}`;
557
- w.has(W) && E.push(w.get(W));
558
- }), E.length === 3) {
559
- if (E.some((A) => A < o.length)) {
557
+ w.has(W) && z.push(w.get(W));
558
+ }), z.length === 3) {
559
+ if (z.some((A) => A < o.length)) {
560
560
  const A = I.properties.circumcenter;
561
561
  if (!te(
562
562
  A,
@@ -565,16 +565,16 @@ function yt(r, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
565
565
  ))
566
566
  return;
567
567
  }
568
- p.push(...E);
568
+ p.push(...z);
569
569
  }
570
570
  });
571
571
  } else if (c.length) {
572
572
  const y = He.from(n);
573
573
  for (let w = 0, I = y.triangles.length; w < I; w += 3) {
574
- const T = [2, 1, 0].map((A) => y.triangles[w + A]), E = T.map((A) => n[A]);
574
+ const T = [2, 1, 0].map((A) => y.triangles[w + A]), z = T.map((A) => n[A]);
575
575
  if (T.some((A) => A < o.length)) {
576
576
  const A = [0, 1].map(
577
- (q) => Ue(E, (W) => W[q])
577
+ (q) => Ue(z, (W) => W[q])
578
578
  );
579
579
  if (!te(
580
580
  A,
@@ -594,12 +594,12 @@ function yt(r, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
594
594
  const [y, w] = i([m[0], b[0]]), [I, T] = i([m[1], b[1]]);
595
595
  m = [y, I], b = [-w, -T];
596
596
  }
597
- const j = ge(m, [0, 1]), z = ge(b, [0, 1]), C = n.map(([y, w]) => {
597
+ const j = ge(m, [0, 1]), k = ge(b, [0, 1]), C = n.map(([y, w]) => {
598
598
  if (i) {
599
599
  const [I, T] = i([y, w]);
600
- return [j(I), z(-T)];
600
+ return [j(I), k(-T)];
601
601
  } else
602
- return [j(y), z(w)];
602
+ return [j(y), k(w)];
603
603
  });
604
604
  return { contour: s, triangles: { points: n, indices: p, uvs: C } };
605
605
  }
@@ -713,9 +713,9 @@ const Mt = ({
713
713
  n
714
714
  )), { contour: d, triangles: u, sideTorso: f, bottomCap: m, topCap: b, topVerts: l };
715
715
  };
716
- class Rt extends se {
716
+ class Nt extends se {
717
717
  constructor(e, t = {}) {
718
- super(), this.type = "PolygonBufferGeometry", this.parameters = k({
718
+ super(), this.type = "PolygonBufferGeometry", this.parameters = L({
719
719
  polygonGeoJson: e,
720
720
  startHeight: 0,
721
721
  endHeight: 1,
@@ -735,13 +735,13 @@ class Rt extends se {
735
735
  hasSide: n,
736
736
  userDataRsoOffset: a,
737
737
  projection: h
738
- } = this.parameters, { contour: d, sideTorso: u, topVerts: f, bottomCap: l, topCap: p } = Mt(k({}, this.parameters));
739
- let m = [], b = [], j = [], z = 0;
738
+ } = this.parameters, { contour: d, sideTorso: u, topVerts: f, bottomCap: l, topCap: p } = Mt(L({}, this.parameters));
739
+ let m = [], b = [], j = [], k = 0;
740
740
  const C = (P) => {
741
741
  const y = Math.round(m.length / 3), w = j.length;
742
742
  m = m.concat(P.vertices), b = b.concat(P.uvs), j = j.concat(
743
743
  y ? P.indices.map((I) => I + y) : P.indices
744
- ), this.addGroup(w, j.length - w, z++);
744
+ ), this.addGroup(w, j.length - w, k++);
745
745
  };
746
746
  s && o && C(p), n && (C(u), this.userData.topVerts = a ? F(
747
747
  d,
@@ -889,7 +889,7 @@ void main() {
889
889
  `;
890
890
  class Ut extends Ke {
891
891
  constructor(e = {}) {
892
- const z = e, {
892
+ const k = e, {
893
893
  lineWidth: t = 1,
894
894
  color: i = "#ffffff",
895
895
  opacity: s = 1,
@@ -905,7 +905,7 @@ class Ut extends Ke {
905
905
  alphaTest: p = 0,
906
906
  repeat: m = new K(1, 1),
907
907
  resolution: b = new K(1, 1)
908
- } = z, j = le(z, [
908
+ } = k, j = le(k, [
909
909
  "lineWidth",
910
910
  "color",
911
911
  "opacity",
@@ -922,7 +922,7 @@ class Ut extends Ke {
922
922
  "repeat",
923
923
  "resolution"
924
924
  ]);
925
- super(X(k({}, j), {
925
+ super(X(L({}, j), {
926
926
  uniforms: {
927
927
  lineWidth: { value: t },
928
928
  color: { value: new me(i) },
@@ -995,17 +995,17 @@ class Ut extends Ke {
995
995
  this.uniforms.sizeAttenuation.value = e ? 1 : 0;
996
996
  }
997
997
  }
998
- const Z = new V(), Pe = new S(), Ae = new S(), g = new V(), M = new V(), B = new V(), J = new S(), H = new De(), x = new Qe(), Ie = new S(), R = new ke(), U = new ze(), O = new V();
999
- let D, L;
998
+ const Z = new V(), Pe = new S(), Ae = new S(), g = new V(), M = new V(), B = new V(), J = new S(), H = new De(), x = new Qe(), Ie = new S(), N = new Le(), U = new ke(), O = new V();
999
+ let D, E;
1000
1000
  function Te(r, e, t) {
1001
- return O.set(0, 0, -e, 1).applyMatrix4(r.projectionMatrix), O.multiplyScalar(1 / O.w), O.x = L / t.width, O.y = L / t.height, O.applyMatrix4(r.projectionMatrixInverse), O.multiplyScalar(1 / O.w), Math.abs(Math.max(O.x, O.y));
1001
+ return O.set(0, 0, -e, 1).applyMatrix4(r.projectionMatrix), O.multiplyScalar(1 / O.w), O.x = E / t.width, O.y = E / t.height, O.applyMatrix4(r.projectionMatrixInverse), O.multiplyScalar(1 / O.w), Math.abs(Math.max(O.x, O.y));
1002
1002
  }
1003
1003
  function St(r, e) {
1004
1004
  const t = r.matrixWorld, i = r.geometry, s = i.attributes.instanceStart, o = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
1005
1005
  for (let n = 0, a = c; n < a; n++) {
1006
1006
  x.start.fromBufferAttribute(s, n), x.end.fromBufferAttribute(o, n), x.applyMatrix4(t);
1007
1007
  const h = new S(), d = new S();
1008
- D.distanceSqToSegment(x.start, x.end, d, h), d.distanceTo(h) < L * 0.5 && e.push({
1008
+ D.distanceSqToSegment(x.start, x.end, d, h), d.distanceTo(h) < E * 0.5 && e.push({
1009
1009
  point: d,
1010
1010
  pointOnLine: h,
1011
1011
  distance: D.origin.distanceTo(d),
@@ -1033,8 +1033,8 @@ function jt(r, e, t) {
1033
1033
  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, x.start.copy(g), x.start.z = 0, x.end.copy(M), x.end.z = 0;
1034
1034
  const m = x.closestPointToPointParameter(J, !0);
1035
1035
  x.at(m, Ie);
1036
- const b = Ze.lerp(g.z, M.z, m), j = b >= -1 && b <= 1, z = J.distanceTo(Ie) < L * 0.5;
1037
- if (j && z) {
1036
+ const b = Ze.lerp(g.z, M.z, m), j = b >= -1 && b <= 1, k = J.distanceTo(Ie) < E * 0.5;
1037
+ if (j && k) {
1038
1038
  x.start.fromBufferAttribute(a, f), x.end.fromBufferAttribute(h, f), x.start.applyMatrix4(c), x.end.applyMatrix4(c);
1039
1039
  const C = new S(), P = new S();
1040
1040
  D.distanceSqToSegment(x.start, x.end, P, C), t.push({
@@ -1050,7 +1050,7 @@ function jt(r, e, t) {
1050
1050
  }
1051
1051
  }
1052
1052
  }
1053
- class Gt extends Le {
1053
+ class Gt extends Ee {
1054
1054
  constructor(e = new rt(), t) {
1055
1055
  super(e, t), this.isLineSegments2 = !0, this.type = "LineSegments2";
1056
1056
  }
@@ -1080,10 +1080,10 @@ class Gt extends Le {
1080
1080
  const o = e.params.Line2 !== void 0 && e.params.Line2.threshold || 0;
1081
1081
  D = e.ray;
1082
1082
  const c = this.matrixWorld, n = this.geometry, a = this.material;
1083
- L = a.linewidth + o, n.boundingSphere === null && n.computeBoundingSphere(), U.copy(n.boundingSphere).applyMatrix4(c);
1083
+ E = a.linewidth + o, n.boundingSphere === null && n.computeBoundingSphere(), U.copy(n.boundingSphere).applyMatrix4(c);
1084
1084
  let h;
1085
1085
  if (i)
1086
- h = L * 0.5;
1086
+ h = E * 0.5;
1087
1087
  else {
1088
1088
  const u = Math.max(
1089
1089
  s.near,
@@ -1097,14 +1097,14 @@ class Gt extends Le {
1097
1097
  }
1098
1098
  if (U.radius += h, D.intersectsSphere(U) === !1)
1099
1099
  return;
1100
- n.boundingBox === null && n.computeBoundingBox(), R.copy(n.boundingBox).applyMatrix4(c);
1100
+ n.boundingBox === null && n.computeBoundingBox(), N.copy(n.boundingBox).applyMatrix4(c);
1101
1101
  let d;
1102
1102
  if (i)
1103
- d = L * 0.5;
1103
+ d = E * 0.5;
1104
1104
  else {
1105
1105
  const u = Math.max(
1106
1106
  s.near,
1107
- R.distanceToPoint(D.origin)
1107
+ N.distanceToPoint(D.origin)
1108
1108
  );
1109
1109
  d = Te(
1110
1110
  s,
@@ -1112,7 +1112,7 @@ class Gt extends Le {
1112
1112
  a.resolution
1113
1113
  );
1114
1114
  }
1115
- R.expandByScalar(d), D.intersectsBox(R) !== !1 && (i ? St(this, t) : jt(this, s, t));
1115
+ N.expandByScalar(d), D.intersectsBox(N) !== !1 && (i ? St(this, t) : jt(this, s, t));
1116
1116
  }
1117
1117
  onBeforeRender(e) {
1118
1118
  const t = this.material.uniforms;
@@ -1121,7 +1121,7 @@ class Gt extends Le {
1121
1121
  }
1122
1122
  const v = class v extends ee {
1123
1123
  constructor(e) {
1124
- super(), this.objectType = "Node", this.onNodePointerIndex = [], this.options = k({
1124
+ super(), this.objectType = "Node", this.onNodePointerIndex = [], this.options = L({
1125
1125
  type: "2d"
1126
1126
  }, e);
1127
1127
  }
@@ -1129,6 +1129,21 @@ const v = class v extends ee {
1129
1129
  const { position: e, children: t } = this.options, i = document.createElement("div");
1130
1130
  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);
1131
1131
  }
1132
+ /**
1133
+ * 启用碰撞检测跟踪
1134
+ * @param priority 优先级,数值越大越优先显示,默认 0
1135
+ */
1136
+ trackCollision(e = 0) {
1137
+ var t;
1138
+ (t = this.pencil.cssRendererController) == null || t.collisionManager.add(this, { priority: e });
1139
+ }
1140
+ /**
1141
+ * 停止碰撞检测跟踪
1142
+ */
1143
+ untrackCollision() {
1144
+ var e;
1145
+ (e = this.pencil.cssRendererController) == null || e.collisionManager.remove(this);
1146
+ }
1132
1147
  setChildren(e) {
1133
1148
  this.options.children = e, this.element.innerHTML = "", this.element.appendChild(e);
1134
1149
  }
@@ -1159,6 +1174,7 @@ const v = class v extends ee {
1159
1174
  this.onNodePointerIndex.push(i);
1160
1175
  }
1161
1176
  dispose() {
1177
+ this.untrackCollision();
1162
1178
  const e = this.options.children;
1163
1179
  e && v.sharedObserver && (v.observerMap.delete(e), v.sharedObserver.unobserve(e), v.observerMap.size === 0 && (v.sharedObserver.disconnect(), v.sharedObserver = void 0)), this.onNodePointerIndex.forEach((t) => {
1164
1180
  this.lead.removePickNode(t);
@@ -1169,11 +1185,11 @@ v.observerMap = /* @__PURE__ */ new Map();
1169
1185
  let Be = v;
1170
1186
  export {
1171
1187
  xe as B,
1172
- Nt as I,
1188
+ _t as I,
1173
1189
  Gt as L,
1174
1190
  Ut as M,
1175
1191
  Be as N,
1176
- Rt as P,
1192
+ Nt as P,
1177
1193
  lt as R,
1178
1194
  ee as a,
1179
1195
  Mt as g
package/dist/index2.js CHANGED
@@ -1,7 +1,7 @@
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},K=(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=a=>{try{r(t.next(a))}catch(d){s(d)}},l=a=>{try{r(t.throw(a))}catch(d){s(d)}},r=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,l);r((t=t.apply(n,e)).next())});const W=require("d3-array"),H=require("earcut"),c=require("three"),Ae=require("@turf/boolean-clockwise"),L=require("./cartographicToCartesian.js"),Pe=require("delaunator"),Be=require("@turf/boolean-point-in-polygon"),_=require("d3-geo"),Ie=require("d3-geo-voronoi"),le=require("d3-scale"),Te=require("three/examples/jsm/lines/LineSegmentsGeometry"),Oe=require("three/examples/jsm/renderers/CSS2DRenderer"),ue=require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo-projection");const he=0,ee=1,De=!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 c.Material)return e;if(e instanceof F?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof c.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof F)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof c.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof c.Material){for(const i of Object.values(e))i instanceof c.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 c.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 c.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 de=new c.Matrix4,xe=new c.Ray,Q=new c.Sphere,U=new c.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(),Q.copy(t.boundingSphere),Q.applyMatrix4(i),Q.radius+=s,de.copy(i).invert(),xe.copy(n.ray).applyMatrix4(de);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),r=t.index,d=t.attributes.position;if(r!==null){const f=Math.max(0,o.start),h=Math.min(r.count,o.start+o.count);for(let p=f,u=h;p<u;p++){const m=r.getX(p);U.fromBufferAttribute(d,m),fe(U,m,l,i,n,e,this)}}else{const f=Math.max(0,o.start),h=Math.min(d.count,o.start+o.count);for(let p=f,u=h;p<u;p++)U.fromBufferAttribute(d,p),fe(U,p,l,i,n,e,this)}}function fe(n,e,t,i,s,o,l){const r=new c.Vector3;xe.closestPointToPoint(n,r),r.applyMatrix4(i);const a=s.ray.origin.distanceTo(n),d=r.distanceTo(n),f=Math.asin(d/a);if(f<t){if(a<s.near||a>s.far)return;o.push({distance:a,distanceToRay:d,angleToRay:f,point:r,index:e,face:null,object:l})}}const Ee=(n,e=1)=>{const t=new c.BufferGeometry;t.setAttribute("position",new c.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new c.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,s=new c.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=`
1
+ "use strict";var Se=Object.defineProperty,je=Object.defineProperties;var Ce=Object.getOwnPropertyDescriptors;var N=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,z=(n,e)=>{for(var t in e||(e={}))re.call(e,t)&&se(n,t,e[t]);if(N)for(var t of N(e))ne.call(e,t)&&se(n,t,e[t]);return n},K=(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&&N)for(var i of N(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=a=>{try{r(t.next(a))}catch(d){s(d)}},l=a=>{try{r(t.throw(a))}catch(d){s(d)}},r=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,l);r((t=t.apply(n,e)).next())});const R=require("d3-array"),H=require("earcut"),c=require("three"),Ae=require("@turf/boolean-clockwise"),L=require("./cartographicToCartesian.js"),Pe=require("delaunator"),Be=require("@turf/boolean-point-in-polygon"),W=require("d3-geo"),Ie=require("d3-geo-voronoi"),le=require("d3-scale"),Te=require("three/examples/jsm/lines/LineSegmentsGeometry"),Oe=require("three/examples/jsm/renderers/CSS2DRenderer"),ue=require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo-projection");const he=0,ee=1,De=!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 c.Material)return e;if(e instanceof F?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof c.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof F)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof c.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof c.Material){for(const i of Object.values(e))i instanceof c.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 c.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 c.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 de=new c.Matrix4,xe=new c.Ray,Q=new c.Sphere,U=new c.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(),Q.copy(t.boundingSphere),Q.applyMatrix4(i),Q.radius+=s,de.copy(i).invert(),xe.copy(n.ray).applyMatrix4(de);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),r=t.index,d=t.attributes.position;if(r!==null){const f=Math.max(0,o.start),h=Math.min(r.count,o.start+o.count);for(let p=f,u=h;p<u;p++){const m=r.getX(p);U.fromBufferAttribute(d,m),fe(U,m,l,i,n,e,this)}}else{const f=Math.max(0,o.start),h=Math.min(d.count,o.start+o.count);for(let p=f,u=h;p<u;p++)U.fromBufferAttribute(d,p),fe(U,p,l,i,n,e,this)}}function fe(n,e,t,i,s,o,l){const r=new c.Vector3;xe.closestPointToPoint(n,r),r.applyMatrix4(i);const a=s.ray.origin.distanceTo(n),d=r.distanceTo(n),f=Math.asin(d/a);if(f<t){if(a<s.near||a>s.far)return;o.push({distance:a,distanceToRay:d,angleToRay:f,point:r,index:e,face:null,object:l})}}const Ee=(n,e=1)=>{const t=new c.BufferGeometry;t.setAttribute("position",new c.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new c.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,s=new c.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
3
  ${l.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `};const o=new c.Points(t,s);return o.raycast=Ve,o},Le=(n,e)=>{const t=new c.Object3D;e.forEach((i,s)=>{const o=L.parseVector3(i.position),l=L.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(l),t.updateMatrix();const r=t.matrix.clone();if(n instanceof c.InstancedMesh||n.isInstantiate)n.setMatrixAt(s,r);else if(n instanceof c.Points||n.type==="Points"){const d=n.geometry,f=d.attributes.position.array,h=d.attributes.scaleAtt.array,p=new c.Vector3,u=new c.Vector3,m=new c.Quaternion,v=s*3,y=s*1;r.decompose(p,m,u),f[v]=p.x,f[v+1]=p.y,f[v+2]=p.z,h[y]=Math.max(u.x,u.y,u.z),d.attributes.position.needsUpdate=!0,d.attributes.scaleAtt.needsUpdate=!0}})};class ze{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 ke extends ze{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 F extends ke{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 c.Vector3?e:new c.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(he),this.children.forEach(t=>{t._disableLayersRecursive()})}_enableLayersRecursive(){var e;this.object3d.visible&&((e=this.object3d)==null||e.layers.enable(he),this.children.forEach(t=>{t._enableLayersRecursive()}))}createGroup(){return this.object3d=new c.Group,this}createMesh(...e){return this.object3d=new c.Mesh(...e),this}createPoints(...e){return this.object3d=new c.Points(...e),this}createCSS2DObject(e){return this.object3d=new Oe.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 c.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new c.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new c.Vector3),center:e.getCenter(new c.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 d,f;const t=(d=e==null?void 0:e.recursive)!=null?d:!0,i=(f=e==null?void 0:e.cloneMaterial)!=null?f:!1,{objectType:s,objectOptions:o}=this;let l=e==null?void 0:e.create,r,a=(e==null?void 0:e.target)||this.parent;return a===this.lead.prefabGroup&&(a=this.lead.group),this.objectType==="BaseObject"?r=this.lead.createBaseObject(this.object3d.clone(!1),{target:a}):(l===void 0&&(l=h=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const u=e.instancedAttr.length;if(this.object3d instanceof c.Sprite)h.object3d=Ee(this.object3d,u);else{const m=this.object3d,v=i?this.cloneMaterial():m.material;h.object3d=new c.InstancedMesh(m.geometry,v,u)}Le(h.object3d,e==null?void 0:e.instancedAttr)}else h.object3d=this.object3d.clone(!1),i&&h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}}),r=yield this.lead.draw(s,K(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:a}))),this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(h=>h.instantiate({key:h.keyUId&&h.keyName?`${h.keyName}-${h.keyUId}`:h.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 We(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),a=1/Math.ceil(l/e);let d=a;for(;d<1;)i.push(r(d)),d+=a}}i.push(s=o)}),i})}function _e(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=u=>u/l*360%360-180,a=u=>Math.acos(2*u/o-1)/Math.PI*180-90,d=u=>o*(Math.cos((u+90)*Math.PI/180)+1)/2,f=[s!==void 0?Math.ceil(d(s)):0,i!==void 0?Math.floor(d(i)):o-1],h=e===void 0&&t===void 0?()=>!0:e===void 0?u=>u<=t:t===void 0?u=>u>=e:t>=e?u=>u>=e&&u<=t:u=>u>=e||u<=t,p=[];for(let u=f[0];u<=f[1];u++){const m=r(u);h(m)&&p.push([m,a(u)])}return p}function te(n,e,t=!1){return t?_.geoContains(e,n):Be(n,e)}function Ne(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 _e(e,{minLng:i,maxLng:o,minLat:s,maxLat:l}).filter(a=>te(a,t,r))}function Re(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=We(n,e),o=W.merge(s),l=Ne(n,e),r=[...o,...l],a={type:"Polygon",coordinates:n},[[d,f],[h,p]]=_.geoBounds(a),u=d>h||p>=89||f<=-89;let m=[];if(u){const g=Ie.geoVoronoi(r).triangles(),S=new Map(r.map(([B,I],E)=>[`${B}-${I}`,E]));g.features.forEach(B=>{const I=B.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(I.forEach(([P,X])=>{const N=`${P}-${X}`;S.has(N)&&E.push(S.get(N))}),E.length===3){if(E.some(P=>P<o.length)){const P=B.properties.circumcenter;if(!te(P,a,u))return}m.push(...E)}})}else if(l.length){const g=Pe.from(r);for(let S=0,B=g.triangles.length;S<B;S+=3){const I=[2,1,0].map(P=>g.triangles[S+P]),E=I.map(P=>r[P]);if(I.some(P=>P<o.length)){const P=[0,1].map(X=>W.mean(E,N=>N[X]));if(!te(P,a,u))continue}m.push(...I)}}else{const{vertices:g,holes:S=[]}=H.flatten(s);m=H(g,S,2)}let v=t?[t[0],t[2]]:W.extent(r,g=>g[0]),y=t?[t[1],t[3]]:W.extent(r,g=>g[1]);if(i){const[g,S]=i([v[0],y[0]]),[B,I]=i([v[1],y[1]]);v=[g,B],y=[-S,-I]}const j=le.scaleLinear(v,[0,1]),V=le.scaleLinear(y,[0,1]),C=r.map(([g,S])=>{if(i){const[B,I]=i([g,S]);return[j(B),V(-I)]}else return[j(g),V(S)]});return{contour:s,triangles:{points:r,indices:m,uvs:C}}}const pe=new c.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function $(n,e,t){const i=n.map(s=>s.map(([o,l])=>{if(t==="cesium"){const r=1/L.WGS84.a,a=e/r,d=Math.max(0,a-L.WGS84.a),f=L.cartographicToCartesian(o,l,d,r,!1);return[f.x,f.y,f.z]}if(t==="sphere"){const r=L.cartographicToCartesian(o,l,e-L.WGS84.a,1,!0);return[r.x,r.y,r.z]}if(typeof t=="function"){const[r,a]=t([o,l]);return[r,-a,e]}return[o,l,e]}));return H.flatten(i)}function Ue(n,e,t,i){const{vertices:s,holes:o}=$(n,e,i),{vertices:l}=$(n,t,i),r=W.merge([l,s]),a=Math.round(l.length/3),d=new Set(o);let f=0;const h=[];for(let u=0;u<a;u++){let m=u+1;if(m===a)m=f;else if(d.has(m)){const v=m;m=f,f=v}h.push(u,u+a,m+a),h.push(m+a,m,u)}const p=[];for(let u=1;u>=0;u--)for(let m=0;m<a;m+=1)p.push(m/(a-1),u);return{indices:h,vertices:r,uvs:p,topVerts:l}}function me(n,e,t,i,s){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:$([n.points],e,s).vertices,uvs:t}}const we=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,hasSide:s=!0,hasBottom:o=!1,hasTop:l=!1,projection:r="sphere",bbox:a})=>{n.forEach(j=>{Ae(j)||j.reverse()});const d=typeof r=="function"?r:void 0,{contour:f,triangles:h}=Re(n,{resolution:i,bbox:a,projection:d});let p={},u;s&&(p=Ue(f,e!=null?e:t,t!=null?t:e,r),u=p.topVerts);let m=[];(o||l)&&(m=W.merge(h.uvs));let v={};o&&(v=me(h,e,m,!1,r));let y={};return l&&(y=me(h,t,m,!0,r)),{contour:f,triangles:h,sideTorso:p,bottomCap:v,topCap:y,topVerts:u}};class Ge extends c.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,projection:"sphere",userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:o,hasBottom:l,hasSide:r,userDataRsoOffset:a,projection:d}=this.parameters,{contour:f,sideTorso:h,topVerts:p,bottomCap:u,topCap:m}=we(k({},this.parameters));let v=[],y=[],j=[],V=0;const C=A=>{const g=Math.round(v.length/3),S=j.length;v=v.concat(A.vertices),y=y.concat(A.uvs),j=j.concat(g?A.indices.map(B=>B+g):A.indices),this.addGroup(S,j.length-S,V++)};s&&o&&C(m),r&&(C(h),this.userData.topVerts=a?$(f,i+a,d).vertices:p),l&&C(u),s&&!o&&C(m),this.setIndex(j),this[pe]("position",new c.Float32BufferAttribute(v,3)),this[pe]("uv",new c.Float32BufferAttribute(y,2)),this.computeVertexNormals()}}const qe=`
4
+ `};const o=new c.Points(t,s);return o.raycast=Ve,o},Le=(n,e)=>{const t=new c.Object3D;e.forEach((i,s)=>{const o=L.parseVector3(i.position),l=L.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(l),t.updateMatrix();const r=t.matrix.clone();if(n instanceof c.InstancedMesh||n.isInstantiate)n.setMatrixAt(s,r);else if(n instanceof c.Points||n.type==="Points"){const d=n.geometry,f=d.attributes.position.array,h=d.attributes.scaleAtt.array,p=new c.Vector3,u=new c.Vector3,m=new c.Quaternion,v=s*3,y=s*1;r.decompose(p,m,u),f[v]=p.x,f[v+1]=p.y,f[v+2]=p.z,h[y]=Math.max(u.x,u.y,u.z),d.attributes.position.needsUpdate=!0,d.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 F 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 c.Vector3?e:new c.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(he),this.children.forEach(t=>{t._disableLayersRecursive()})}_enableLayersRecursive(){var e;this.object3d.visible&&((e=this.object3d)==null||e.layers.enable(he),this.children.forEach(t=>{t._enableLayersRecursive()}))}createGroup(){return this.object3d=new c.Group,this}createMesh(...e){return this.object3d=new c.Mesh(...e),this}createPoints(...e){return this.object3d=new c.Points(...e),this}createCSS2DObject(e){return this.object3d=new Oe.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 c.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new c.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new c.Vector3),center:e.getCenter(new c.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 d,f;const t=(d=e==null?void 0:e.recursive)!=null?d:!0,i=(f=e==null?void 0:e.cloneMaterial)!=null?f:!1,{objectType:s,objectOptions:o}=this;let l=e==null?void 0:e.create,r,a=(e==null?void 0:e.target)||this.parent;return a===this.lead.prefabGroup&&(a=this.lead.group),this.objectType==="BaseObject"?r=this.lead.createBaseObject(this.object3d.clone(!1),{target:a}):(l===void 0&&(l=h=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const u=e.instancedAttr.length;if(this.object3d instanceof c.Sprite)h.object3d=Ee(this.object3d,u);else{const m=this.object3d,v=i?this.cloneMaterial():m.material;h.object3d=new c.InstancedMesh(m.geometry,v,u)}Le(h.object3d,e==null?void 0:e.instancedAttr)}else h.object3d=this.object3d.clone(!1),i&&h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}}),r=yield this.lead.draw(s,K(z({},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:a}))),this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(h=>h.instantiate({key:h.keyUId&&h.keyName?`${h.keyName}-${h.keyUId}`:h.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 Re(n,e){return n.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const l=W.geoDistance(o,s)*180/Math.PI;if(l>e){const r=W.geoInterpolate(s,o),a=1/Math.ceil(l/e);let d=a;for(;d<1;)i.push(r(d)),d+=a}}i.push(s=o)}),i})}function We(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=u=>u/l*360%360-180,a=u=>Math.acos(2*u/o-1)/Math.PI*180-90,d=u=>o*(Math.cos((u+90)*Math.PI/180)+1)/2,f=[s!==void 0?Math.ceil(d(s)):0,i!==void 0?Math.floor(d(i)):o-1],h=e===void 0&&t===void 0?()=>!0:e===void 0?u=>u<=t:t===void 0?u=>u>=e:t>=e?u=>u>=e&&u<=t:u=>u>=e||u<=t,p=[];for(let u=f[0];u<=f[1];u++){const m=r(u);h(m)&&p.push([m,a(u)])}return p}function te(n,e,t=!1){return t?W.geoContains(e,n):Be(n,e)}function _e(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[o,l]]=W.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(l-s))<e)return[];const r=i>o||l>=89||s<=-89;return We(e,{minLng:i,maxLng:o,minLat:s,maxLat:l}).filter(a=>te(a,t,r))}function Ne(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Re(n,e),o=R.merge(s),l=_e(n,e),r=[...o,...l],a={type:"Polygon",coordinates:n},[[d,f],[h,p]]=W.geoBounds(a),u=d>h||p>=89||f<=-89;let m=[];if(u){const g=Ie.geoVoronoi(r).triangles(),S=new Map(r.map(([B,I],E)=>[`${B}-${I}`,E]));g.features.forEach(B=>{const I=B.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(I.forEach(([P,X])=>{const _=`${P}-${X}`;S.has(_)&&E.push(S.get(_))}),E.length===3){if(E.some(P=>P<o.length)){const P=B.properties.circumcenter;if(!te(P,a,u))return}m.push(...E)}})}else if(l.length){const g=Pe.from(r);for(let S=0,B=g.triangles.length;S<B;S+=3){const I=[2,1,0].map(P=>g.triangles[S+P]),E=I.map(P=>r[P]);if(I.some(P=>P<o.length)){const P=[0,1].map(X=>R.mean(E,_=>_[X]));if(!te(P,a,u))continue}m.push(...I)}}else{const{vertices:g,holes:S=[]}=H.flatten(s);m=H(g,S,2)}let v=t?[t[0],t[2]]:R.extent(r,g=>g[0]),y=t?[t[1],t[3]]:R.extent(r,g=>g[1]);if(i){const[g,S]=i([v[0],y[0]]),[B,I]=i([v[1],y[1]]);v=[g,B],y=[-S,-I]}const j=le.scaleLinear(v,[0,1]),V=le.scaleLinear(y,[0,1]),C=r.map(([g,S])=>{if(i){const[B,I]=i([g,S]);return[j(B),V(-I)]}else return[j(g),V(S)]});return{contour:s,triangles:{points:r,indices:m,uvs:C}}}const pe=new c.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function $(n,e,t){const i=n.map(s=>s.map(([o,l])=>{if(t==="cesium"){const r=1/L.WGS84.a,a=e/r,d=Math.max(0,a-L.WGS84.a),f=L.cartographicToCartesian(o,l,d,r,!1);return[f.x,f.y,f.z]}if(t==="sphere"){const r=L.cartographicToCartesian(o,l,e-L.WGS84.a,1,!0);return[r.x,r.y,r.z]}if(typeof t=="function"){const[r,a]=t([o,l]);return[r,-a,e]}return[o,l,e]}));return H.flatten(i)}function Ue(n,e,t,i){const{vertices:s,holes:o}=$(n,e,i),{vertices:l}=$(n,t,i),r=R.merge([l,s]),a=Math.round(l.length/3),d=new Set(o);let f=0;const h=[];for(let u=0;u<a;u++){let m=u+1;if(m===a)m=f;else if(d.has(m)){const v=m;m=f,f=v}h.push(u,u+a,m+a),h.push(m+a,m,u)}const p=[];for(let u=1;u>=0;u--)for(let m=0;m<a;m+=1)p.push(m/(a-1),u);return{indices:h,vertices:r,uvs:p,topVerts:l}}function me(n,e,t,i,s){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:$([n.points],e,s).vertices,uvs:t}}const we=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,hasSide:s=!0,hasBottom:o=!1,hasTop:l=!1,projection:r="sphere",bbox:a})=>{n.forEach(j=>{Ae(j)||j.reverse()});const d=typeof r=="function"?r:void 0,{contour:f,triangles:h}=Ne(n,{resolution:i,bbox:a,projection:d});let p={},u;s&&(p=Ue(f,e!=null?e:t,t!=null?t:e,r),u=p.topVerts);let m=[];(o||l)&&(m=R.merge(h.uvs));let v={};o&&(v=me(h,e,m,!1,r));let y={};return l&&(y=me(h,t,m,!0,r)),{contour:f,triangles:h,sideTorso:p,bottomCap:v,topCap:y,topVerts:u}};class Ge extends c.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=z({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,projection:"sphere",userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:o,hasBottom:l,hasSide:r,userDataRsoOffset:a,projection:d}=this.parameters,{contour:f,sideTorso:h,topVerts:p,bottomCap:u,topCap:m}=we(z({},this.parameters));let v=[],y=[],j=[],V=0;const C=A=>{const g=Math.round(v.length/3),S=j.length;v=v.concat(A.vertices),y=y.concat(A.uvs),j=j.concat(g?A.indices.map(B=>B+g):A.indices),this.addGroup(S,j.length-S,V++)};s&&o&&C(m),r&&(C(h),this.userData.topVerts=a?$(f,i+a,d).vertices:p),l&&C(u),s&&!o&&C(m),this.setIndex(j),this[pe]("position",new c.Float32BufferAttribute(v,3)),this[pe]("uv",new c.Float32BufferAttribute(y,2)),this.computeVertexNormals()}}const qe=`
5
5
  #include <fog_pars_fragment>
6
6
  #include <logdepthbuf_pars_fragment>
7
7
 
@@ -137,4 +137,4 @@ void main() {
137
137
  #include <logdepthbuf_vertex>
138
138
  #include <fog_vertex>
139
139
  }
140
- `;class $e extends c.ShaderMaterial{constructor(e={}){const V=e,{lineWidth:t=1,color:i="#ffffff",opacity:s=1,map:o=null,dashOffset:l=0,dashArray:r=0,dashRatio:a=0,sizeAttenuation:d=!0,offsetLoop:f=!0,offset:h=new c.Vector2(0,0),scaleDown:p=0,alphaMap:u=void 0,alphaTest:m=0,repeat:v=new c.Vector2(1,1),resolution:y=new c.Vector2(1,1)}=V,j=ae(V,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(K(k({},j),{uniforms:{lineWidth:{value:t},color:{value:new c.Color(i)},opacity:{value:s},map:{value:o},useMap:{value:o?1:0},resolution:{value:y},sizeAttenuation:{value:d?1:0},offset:{value:h},offsetLoop:{value:f?1:0},dashArray:{value:r},dashOffset:{value:l},dashRatio:{value:a},useDash:{value:r>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:u},useAlphaMap:{value:u?1:0},repeat:{value:v}},vertexShader:Fe,fragmentShader:qe})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new c.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 Y=new c.Vector4,ve=new c.Vector3,be=new c.Vector3,M=new c.Vector4,x=new c.Vector4,T=new c.Vector4,Z=new c.Vector3,J=new c.Matrix4,w=new c.Line3,ye=new c.Vector3,G=new c.Box3,q=new c.Sphere,O=new c.Vector4;let D,z;function ge(n,e,t){return O.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),O.multiplyScalar(1/O.w),O.x=z/t.width,O.y=z/t.height,O.applyMatrix4(n.projectionMatrixInverse),O.multiplyScalar(1/O.w),Math.abs(Math.max(O.x,O.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,a=l;r<a;r++){w.start.fromBufferAttribute(s,r),w.end.fromBufferAttribute(o,r),w.applyMatrix4(t);const d=new c.Vector3,f=new c.Vector3;D.distanceSqToSegment(w.start,w.end,f,d),f.distanceTo(d)<z*.5&&e.push({point:f,pointOnLine:d,distance:D.origin.distanceTo(f),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,a=r.attributes.instanceStart,d=r.attributes.instanceEnd,f=Math.min(r.instanceCount,a.count),h=-e.near;D.at(1,T),T.w=1,T.applyMatrix4(e.matrixWorldInverse),T.applyMatrix4(i),T.multiplyScalar(1/T.w),T.x*=o.x/2,T.y*=o.y/2,T.z=0,Z.copy(T),J.multiplyMatrices(e.matrixWorldInverse,l);for(let p=0,u=f;p<u;p++){if(M.fromBufferAttribute(a,p),x.fromBufferAttribute(d,p),M.w=1,x.w=1,M.applyMatrix4(J),x.applyMatrix4(J),M.z>h&&x.z>h)continue;if(M.z>h){const C=M.z-x.z,A=(M.z-h)/C;M.lerp(x,A)}else if(x.z>h){const C=x.z-M.z,A=(x.z-h)/C;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(Z,!0);w.at(v,ye);const y=c.MathUtils.lerp(M.z,x.z,v),j=y>=-1&&y<=1,V=Z.distanceTo(ye)<z*.5;if(j&&V){w.start.fromBufferAttribute(a,p),w.end.fromBufferAttribute(d,p),w.start.applyMatrix4(l),w.end.applyMatrix4(l);const C=new c.Vector3,A=new c.Vector3;D.distanceSqToSegment(w.start,w.end,A,C),t.push({point:A,pointOnLine:C,distance:D.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Qe extends c.Mesh{constructor(e=new Te.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,a=t.count;l<a;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 c.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new c.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;D=e.ray;const l=this.matrixWorld,r=this.geometry,a=this.material;z=a.linewidth+o,r.boundingSphere===null&&r.computeBoundingSphere(),q.copy(r.boundingSphere).applyMatrix4(l);let d;if(i)d=z*.5;else{const h=Math.max(s.near,q.distanceToPoint(D.origin));d=ge(s,h,a.resolution)}if(q.radius+=d,D.intersectsSphere(q)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),G.copy(r.boundingBox).applyMatrix4(l);let f;if(i)f=z*.5;else{const h=Math.max(s.near,G.distanceToPoint(D.origin));f=ge(s,h,a.resolution)}G.expandByScalar(f),D.intersectsBox(G)!==!1&&(i?Xe(this,t):Ke(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Y),this.material.uniforms.resolution.value.set(Y.z,Y.w))}}const b=class b extends F{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,a=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&&(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)`)}ensureVisible(){const e=this.options.children;e&&(e.style.transform&&(e.style.transform=""),!b.observerMap.has(e)&&(b.sharedObserver||(b.sharedObserver=new IntersectionObserver(t=>{t.forEach(i=>{const s=i.target,o=b.observerMap.get(s);o&&i.isIntersecting&&(o.moveElementToViewport(),b.observerMap.delete(s),b.sharedObserver&&(b.sharedObserver.unobserve(s),b.observerMap.size===0&&(b.sharedObserver.disconnect(),b.sharedObserver=void 0)))})})),b.observerMap.set(e,this),b.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&&b.sharedObserver&&(b.observerMap.delete(e),b.sharedObserver.unobserve(e),b.observerMap.size===0&&(b.sharedObserver.disconnect(),b.sharedObserver=void 0)),this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}};b.observerMap=new Map;let ie=b;exports.BLOOM_SCENE=ee;exports.BaseObject=F;exports.IS_DEV=De;exports.LineSegments2=Qe;exports.MeshLineMaterial=$e;exports.Node=ie;exports.PolygonGeometry=Ge;exports.ResourceTracker=Me;exports.getMetas=we;
140
+ `;class $e extends c.ShaderMaterial{constructor(e={}){const V=e,{lineWidth:t=1,color:i="#ffffff",opacity:s=1,map:o=null,dashOffset:l=0,dashArray:r=0,dashRatio:a=0,sizeAttenuation:d=!0,offsetLoop:f=!0,offset:h=new c.Vector2(0,0),scaleDown:p=0,alphaMap:u=void 0,alphaTest:m=0,repeat:v=new c.Vector2(1,1),resolution:y=new c.Vector2(1,1)}=V,j=ae(V,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(K(z({},j),{uniforms:{lineWidth:{value:t},color:{value:new c.Color(i)},opacity:{value:s},map:{value:o},useMap:{value:o?1:0},resolution:{value:y},sizeAttenuation:{value:d?1:0},offset:{value:h},offsetLoop:{value:f?1:0},dashArray:{value:r},dashOffset:{value:l},dashRatio:{value:a},useDash:{value:r>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:u},useAlphaMap:{value:u?1:0},repeat:{value:v}},vertexShader:Fe,fragmentShader:qe})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new c.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 Y=new c.Vector4,ve=new c.Vector3,be=new c.Vector3,M=new c.Vector4,x=new c.Vector4,T=new c.Vector4,Z=new c.Vector3,J=new c.Matrix4,w=new c.Line3,ye=new c.Vector3,G=new c.Box3,q=new c.Sphere,O=new c.Vector4;let D,k;function ge(n,e,t){return O.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),O.multiplyScalar(1/O.w),O.x=k/t.width,O.y=k/t.height,O.applyMatrix4(n.projectionMatrixInverse),O.multiplyScalar(1/O.w),Math.abs(Math.max(O.x,O.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,a=l;r<a;r++){w.start.fromBufferAttribute(s,r),w.end.fromBufferAttribute(o,r),w.applyMatrix4(t);const d=new c.Vector3,f=new c.Vector3;D.distanceSqToSegment(w.start,w.end,f,d),f.distanceTo(d)<k*.5&&e.push({point:f,pointOnLine:d,distance:D.origin.distanceTo(f),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,a=r.attributes.instanceStart,d=r.attributes.instanceEnd,f=Math.min(r.instanceCount,a.count),h=-e.near;D.at(1,T),T.w=1,T.applyMatrix4(e.matrixWorldInverse),T.applyMatrix4(i),T.multiplyScalar(1/T.w),T.x*=o.x/2,T.y*=o.y/2,T.z=0,Z.copy(T),J.multiplyMatrices(e.matrixWorldInverse,l);for(let p=0,u=f;p<u;p++){if(M.fromBufferAttribute(a,p),x.fromBufferAttribute(d,p),M.w=1,x.w=1,M.applyMatrix4(J),x.applyMatrix4(J),M.z>h&&x.z>h)continue;if(M.z>h){const C=M.z-x.z,A=(M.z-h)/C;M.lerp(x,A)}else if(x.z>h){const C=x.z-M.z,A=(x.z-h)/C;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(Z,!0);w.at(v,ye);const y=c.MathUtils.lerp(M.z,x.z,v),j=y>=-1&&y<=1,V=Z.distanceTo(ye)<k*.5;if(j&&V){w.start.fromBufferAttribute(a,p),w.end.fromBufferAttribute(d,p),w.start.applyMatrix4(l),w.end.applyMatrix4(l);const C=new c.Vector3,A=new c.Vector3;D.distanceSqToSegment(w.start,w.end,A,C),t.push({point:A,pointOnLine:C,distance:D.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Qe extends c.Mesh{constructor(e=new Te.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,a=t.count;l<a;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 c.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new c.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;D=e.ray;const l=this.matrixWorld,r=this.geometry,a=this.material;k=a.linewidth+o,r.boundingSphere===null&&r.computeBoundingSphere(),q.copy(r.boundingSphere).applyMatrix4(l);let d;if(i)d=k*.5;else{const h=Math.max(s.near,q.distanceToPoint(D.origin));d=ge(s,h,a.resolution)}if(q.radius+=d,D.intersectsSphere(q)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),G.copy(r.boundingBox).applyMatrix4(l);let f;if(i)f=k*.5;else{const h=Math.max(s.near,G.distanceToPoint(D.origin));f=ge(s,h,a.resolution)}G.expandByScalar(f),D.intersectsBox(G)!==!1&&(i?Xe(this,t):Ke(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Y),this.material.uniforms.resolution.value.set(Y.z,Y.w))}}const b=class b extends F{constructor(e){super(),this.objectType="Node",this.onNodePointerIndex=[],this.options=z({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)}trackCollision(e=0){var t;(t=this.pencil.cssRendererController)==null||t.collisionManager.add(this,{priority:e})}untrackCollision(){var e;(e=this.pencil.cssRendererController)==null||e.collisionManager.remove(this)}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,a=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&&(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)`)}ensureVisible(){const e=this.options.children;e&&(e.style.transform&&(e.style.transform=""),!b.observerMap.has(e)&&(b.sharedObserver||(b.sharedObserver=new IntersectionObserver(t=>{t.forEach(i=>{const s=i.target,o=b.observerMap.get(s);o&&i.isIntersecting&&(o.moveElementToViewport(),b.observerMap.delete(s),b.sharedObserver&&(b.sharedObserver.unobserve(s),b.observerMap.size===0&&(b.sharedObserver.disconnect(),b.sharedObserver=void 0)))})})),b.observerMap.set(e,this),b.sharedObserver.observe(e)))}onPointerEvent(e,t){const i=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){this.untrackCollision();const e=this.options.children;e&&b.sharedObserver&&(b.observerMap.delete(e),b.sharedObserver.unobserve(e),b.observerMap.size===0&&(b.sharedObserver.disconnect(),b.sharedObserver=void 0)),this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}};b.observerMap=new Map;let ie=b;exports.BLOOM_SCENE=ee;exports.BaseObject=F;exports.IS_DEV=De;exports.LineSegments2=Qe;exports.MeshLineMaterial=$e;exports.Node=ie;exports.PolygonGeometry=Ge;exports.ResourceTracker=Me;exports.getMetas=we;
@@ -11,5 +11,4 @@ export { default as Line } from './line';
11
11
  export { MeshLineGeometry, MeshLineMaterial, MeshLineRaycast, } from './line/meshLine';
12
12
  export { default as Line2 } from './line2';
13
13
  export { default as Node } from './node';
14
- export { default as CollisionManage } from './node/CollisionManager';
15
14
  export { default as Pie } from './pie';