gl-draw 0.14.41 → 0.15.0-beta.10

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,37 +1,37 @@
1
- var At = Object.defineProperty, jt = Object.defineProperties;
1
+ var jt = Object.defineProperty, At = Object.defineProperties;
2
2
  var St = Object.getOwnPropertyDescriptors;
3
3
  var tt = Object.getOwnPropertySymbols;
4
4
  var Ct = Object.prototype.hasOwnProperty, zt = Object.prototype.propertyIsEnumerable;
5
- var it = Math.pow, et = (a, t, e) => t in a ? At(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e, L = (a, t) => {
5
+ var it = Math.pow, et = (r, t, e) => t in r ? jt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, W = (r, t) => {
6
6
  for (var e in t || (t = {}))
7
- Ct.call(t, e) && et(a, e, t[e]);
7
+ Ct.call(t, e) && et(r, e, t[e]);
8
8
  if (tt)
9
9
  for (var e of tt(t))
10
- zt.call(t, e) && et(a, e, t[e]);
11
- return a;
12
- }, q = (a, t) => jt(a, St(t));
13
- var st = (a, t, e) => new Promise((i, s) => {
14
- var r = (l) => {
10
+ zt.call(t, e) && et(r, e, t[e]);
11
+ return r;
12
+ }, $ = (r, t) => At(r, St(t));
13
+ var st = (r, t, e) => new Promise((i, s) => {
14
+ var a = (o) => {
15
15
  try {
16
- n(e.next(l));
16
+ n(e.next(o));
17
17
  } catch (c) {
18
18
  s(c);
19
19
  }
20
- }, o = (l) => {
20
+ }, l = (o) => {
21
21
  try {
22
- n(e.throw(l));
22
+ n(e.throw(o));
23
23
  } catch (c) {
24
24
  s(c);
25
25
  }
26
- }, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(r, o);
27
- n((e = e.apply(a, t)).next());
26
+ }, n = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, l);
27
+ n((e = e.apply(r, t)).next());
28
28
  });
29
- import { Material as nt, Object3D as G, Texture as rt, VideoTexture as Dt, BufferGeometry as H, Float32BufferAttribute as F, PointsMaterial as It, Points as X, Mesh as xt, Group as Tt, Sprite as at, Box3 as Mt, Vector3 as C, InstancedMesh as ot, Quaternion as Wt, Vector4 as V, Matrix4 as Bt, Line3 as _t, Sphere as Lt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as lt, MathUtils as Vt, ShaderMaterial as kt, UniformsLib as Et, Color as ct, Vector2 as E, REVISION as Ut } from "three";
29
+ import { BufferGeometry as H, Float32BufferAttribute as G, PointsMaterial as It, Points as K, Mesh as xt, Group as Dt, Sprite as nt, Box3 as Mt, Vector3 as C, InstancedMesh as rt, Quaternion as Tt, Object3D as R, Material as at, Texture as ot, VideoTexture as _t, Vector4 as O, Matrix4 as Bt, Line3 as Lt, Sphere as Wt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as lt, MathUtils as Vt, ShaderMaterial as kt, UniformsLib as Ut, Color as ct, Vector2 as k, REVISION as Et } from "three";
30
30
  import { CSS2DObject as Rt } from "three/examples/jsm/renderers/CSS2DRenderer";
31
31
  import { CSS3DObject as Gt, CSS3DSprite as Ft } from "three/examples/jsm/renderers/CSS3DRenderer";
32
- import { geoBounds as wt, geoContains as Zt, geoDistance as $t, geoInterpolate as qt } from "d3-geo";
32
+ import { geoBounds as wt, geoContains as Zt, geoDistance as $t, geoInterpolate as Nt } from "d3-geo";
33
33
  import "d3-geo-projection";
34
- import { p as ut, a as Nt } from "./parseVector.module.js";
34
+ import { p as ut, a as qt } from "./parseVector.module.js";
35
35
  import { LineSegmentsGeometry as Qt } from "three/examples/jsm/lines/LineSegmentsGeometry";
36
36
  import { merge as J, mean as Kt, extent as ht } from "d3-array";
37
37
  import Xt, { flatten as Pt } from "earcut";
@@ -40,55 +40,16 @@ import Ht from "delaunator";
40
40
  import Jt from "@turf/boolean-point-in-polygon";
41
41
  import { geoVoronoi as te } from "d3-geo-voronoi";
42
42
  import { scaleLinear as ft } from "d3-scale";
43
- class O {
44
- constructor() {
45
- this.resources = /* @__PURE__ */ new Set(), this.disposeWithMaterial = !0, this.disposeVideo = !0, this.materialList = {}, this.disposeTrack = !0;
46
- }
47
- track(t) {
48
- if (!t || this.disposeTrack === !1)
49
- return t;
50
- if (Array.isArray(t))
51
- return t.forEach((e) => this.track(e)), t;
52
- if (!this.disposeWithMaterial && t instanceof nt)
53
- return t;
54
- if (t instanceof O ? (t === this && t.object3d ? this.track(t.object3d) : (t.disposeTrack = !1, this.resources.add(t)), Object.values(t.materialList).map((e) => this.track(e))) : (t instanceof G || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof O)
55
- this.track(t.children);
56
- else if (t instanceof G) {
57
- const e = t;
58
- this.track(e.geometry), this.track(e.material), this.track(e.children);
59
- } else if (t instanceof nt) {
60
- for (const i of Object.values(t))
61
- i instanceof rt && this.track(i);
62
- const e = t;
63
- if (e.uniforms) {
64
- for (const i of Object.values(e.uniforms))
65
- if (i) {
66
- const s = i.value;
67
- (s instanceof rt || Array.isArray(s)) && this.track(s);
68
- }
69
- }
70
- } else this.disposeVideo && t instanceof Dt && t.source.data && this.resources.add(t.source.data);
71
- return t;
72
- }
73
- dispose() {
74
- const t = [];
75
- for (const e of this.resources)
76
- e instanceof G ? t.push(e) : e instanceof HTMLVideoElement && e.pause(), Reflect.has(e, "dispose") && e.dispose();
77
- t.forEach((e) => {
78
- e.removeFromParent();
79
- }), t.length = 0, this.resources.clear();
80
- }
81
- }
82
- const ee = (a, t = 1) => {
43
+ const ee = (r, t = 1) => {
83
44
  const e = new H();
84
45
  e.setAttribute(
85
46
  "position",
86
- new F(new Array(t * 3).fill(0), 3)
47
+ new G(new Array(t * 3).fill(0), 3)
87
48
  ), e.setAttribute(
88
49
  "scaleAtt",
89
- new F(new Array(t).fill(1), 1)
50
+ new G(new Array(t).fill(1), 1)
90
51
  );
91
- const i = a.material, s = new It({
52
+ const i = r.material, s = new It({
92
53
  size: 10,
93
54
  map: i.map,
94
55
  alphaMap: i.alphaMap,
@@ -101,19 +62,19 @@ const ee = (a, t = 1) => {
101
62
  alphaTest: i.alphaTest,
102
63
  sizeAttenuation: !1
103
64
  });
104
- return s.onBeforeCompile = (r) => {
105
- r.vertexShader = `
65
+ return s.onBeforeCompile = (a) => {
66
+ a.vertexShader = `
106
67
  attribute float scaleAtt;
107
- ${r.vertexShader.replace(
68
+ ${a.vertexShader.replace(
108
69
  "gl_PointSize = size;",
109
70
  "gl_PointSize = size * scaleAtt;"
110
71
  )}
111
72
  `;
112
- }, new X(e, s);
73
+ }, new K(e, s);
113
74
  };
114
- class ie extends O {
75
+ class X {
115
76
  constructor() {
116
- super(...arguments), this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.materialList = {}, this.useMaterialType = "origin", this.onPointerIndex = [];
77
+ this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.materialList = {}, this.useMaterialType = "origin", this.onPointerIndex = [], this.disposeTrack = !0, this.disposeMaterialIfNotUsed = !0;
117
78
  }
118
79
  get parent() {
119
80
  const t = this.object3d.parent;
@@ -171,10 +132,10 @@ class ie extends O {
171
132
  return this.object3d = new xt(...t), this;
172
133
  }
173
134
  createGroup() {
174
- return this.object3d = new Tt(), this;
135
+ return this.object3d = new Dt(), this;
175
136
  }
176
137
  createPoints(...t) {
177
- return this.object3d = new X(...t), this;
138
+ return this.object3d = new K(...t), this;
178
139
  }
179
140
  createCSS2DObject(t) {
180
141
  return this.object3d = new Rt(t), this;
@@ -186,7 +147,7 @@ class ie extends O {
186
147
  return this.object3d = new Ft(t), this;
187
148
  }
188
149
  createSprite(t) {
189
- return this.object3d = new at(t), this;
150
+ return this.object3d = new nt(t), this;
190
151
  }
191
152
  attach(...t) {
192
153
  return [...t].forEach((e) => {
@@ -213,23 +174,23 @@ class ie extends O {
213
174
  instantiate(t, e) {
214
175
  return st(this, null, function* () {
215
176
  var d;
216
- const i = t && t.length > 0, s = (d = e == null ? void 0 : e.recursive) != null ? d : !0, { objectType: r, objectOptions: o } = this, [, n] = r.split("#");
217
- let l = e == null ? void 0 : e.create;
218
- l === void 0 && (l = (u) => {
177
+ const i = t && t.length > 0, s = (d = e == null ? void 0 : e.recursive) != null ? d : !0, { objectType: a, objectOptions: l } = this, [, n] = a.split("#");
178
+ let o = e == null ? void 0 : e.create;
179
+ o === void 0 && (o = (u) => {
219
180
  if (this.object3d) {
220
181
  if (i) {
221
182
  const m = t.length;
222
- if (this.object3d instanceof at)
183
+ if (this.object3d instanceof nt)
223
184
  u.object3d = ee(this.object3d, m);
224
185
  else {
225
186
  const f = this.object3d;
226
- u.object3d = new ot(
187
+ u.object3d = new rt(
227
188
  f.geometry,
228
189
  f.material,
229
190
  m
230
191
  ), u.setMaterialList("instantiate", "clone"), u.useMaterial("instantiate");
231
192
  }
232
- const h = new G();
193
+ const h = new R();
233
194
  t.forEach((f, p) => {
234
195
  const g = ut(f.position), w = ut(f.scale || [1, 1, 1]);
235
196
  h.position.copy(g), h.scale.copy(w), h.updateMatrix(), u.setInstancedMatrix(p, h.matrix.clone());
@@ -239,11 +200,11 @@ class ie extends O {
239
200
  u.object3d.userData.prefab && delete u.object3d.userData.prefab;
240
201
  }
241
202
  });
242
- const c = yield this.lead.draw(n, q(L({}, o || {}), {
243
- create: l,
203
+ const c = yield this.lead.draw(n, $(W({}, l || {}), {
204
+ create: o,
244
205
  prefab: !1,
245
- key: (e == null ? void 0 : e.key) || (o == null ? void 0 : o.key),
246
- target: (e == null ? void 0 : e.target) || (o == null ? void 0 : o.target)
206
+ key: (e == null ? void 0 : e.key) || (l == null ? void 0 : l.key),
207
+ target: (e == null ? void 0 : e.target) || (l == null ? void 0 : l.target)
247
208
  }));
248
209
  return this.isBloom && c.enableBloom(), s && (yield Promise.all(
249
210
  this.children.map(
@@ -255,11 +216,11 @@ class ie extends O {
255
216
  });
256
217
  }
257
218
  setInstancedMatrix(t, e) {
258
- if (this.object3d instanceof ot || this.object3d.isInstantiate)
219
+ if (this.object3d instanceof rt || this.object3d.isInstantiate)
259
220
  this.object3d.setMatrixAt(t, e);
260
- else if (this.object3d instanceof X || this.object3d.type === "Points") {
261
- const s = this.object3d.geometry, r = s.attributes.position.array, o = s.attributes.scaleAtt.array, n = new C(), l = new C(), c = new Wt(), d = t * 3, u = t * 1;
262
- e.decompose(n, c, l), r[d] = n.x, r[d + 1] = n.y, r[d + 2] = n.z, o[u] = Math.max(l.x, l.y, l.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
221
+ else if (this.object3d instanceof K || this.object3d.type === "Points") {
222
+ const s = this.object3d.geometry, a = s.attributes.position.array, l = s.attributes.scaleAtt.array, n = new C(), o = new C(), c = new Tt(), d = t * 3, u = t * 1;
223
+ e.decompose(n, c, o), a[d] = n.x, a[d + 1] = n.y, a[d + 2] = n.z, l[u] = Math.max(o.x, o.y, o.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
263
224
  }
264
225
  }
265
226
  erase() {
@@ -274,8 +235,8 @@ class ie extends O {
274
235
  return e.map((i) => {
275
236
  const s = i.userData;
276
237
  i.userData = {};
277
- const r = i.clone();
278
- return i.userData = s, r;
238
+ const a = i.clone();
239
+ return i.userData = s, a;
279
240
  });
280
241
  {
281
242
  const i = e.userData;
@@ -288,14 +249,10 @@ class ie extends O {
288
249
  const s = this.object3d;
289
250
  if (!s || !s.material)
290
251
  return;
291
- if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t])
292
- if (i) {
293
- const o = this.materialList[t], n = new O();
294
- n.track(o), n.dispose();
295
- } else
296
- return this.materialList[t];
297
- const r = e === "clone" ? this.cloneMaterial() : e;
298
- return this.materialList[t] = r, r;
252
+ if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t] && !i)
253
+ return this.materialList[t];
254
+ const a = e === "clone" ? this.cloneMaterial() : e;
255
+ return this.materialList[t] = a, a;
299
256
  }
300
257
  useMaterial(t) {
301
258
  const e = this.object3d;
@@ -318,34 +275,75 @@ class ie extends O {
318
275
  }
319
276
  dispose() {
320
277
  var t;
321
- this.onPointerIndex.forEach((e) => {
278
+ if (this.onPointerIndex.forEach((e) => {
322
279
  this.lead.removePick(e);
323
- }), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.object3d && this.lead.objMap.delete(this.object3d)), this.track(this), super.dispose();
280
+ }), this.mList.rmBaseObjectMap(this, void 0, this.disposeMaterialIfNotUsed), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
281
+ const e = new ie();
282
+ e.disposeMaterial = !1, e.track(this), e.dispose();
283
+ }
284
+ }
285
+ }
286
+ class ie {
287
+ constructor() {
288
+ this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
324
289
  }
325
- disposeWithOutMaterial() {
326
- this.disposeWithMaterial = !1, this.dispose();
290
+ track(t) {
291
+ if (!t)
292
+ return t;
293
+ if (Array.isArray(t))
294
+ return t.forEach((e) => this.track(e)), t;
295
+ if (!this.disposeMaterial && t instanceof at)
296
+ return t;
297
+ if (t instanceof X ? (t.disposeTrack && t.object3d ? this.track(t.object3d) : this.resources.add(t), Object.values(t.materialList).map((e) => this.track(e))) : (t instanceof R || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof X)
298
+ t.children.forEach((e) => {
299
+ e.disposeTrack = !1;
300
+ }), this.track(t.children);
301
+ else if (t instanceof R) {
302
+ const e = t;
303
+ this.track(e.geometry), this.track(e.material), this.track(e.children);
304
+ } else if (t instanceof at) {
305
+ for (const i of Object.values(t))
306
+ i instanceof ot && this.track(i);
307
+ const e = t;
308
+ if (e.uniforms) {
309
+ for (const i of Object.values(e.uniforms))
310
+ if (i) {
311
+ const s = i.value;
312
+ (s instanceof ot || Array.isArray(s)) && this.track(s);
313
+ }
314
+ }
315
+ } else this.disposeVideo && t instanceof _t && t.source.data && this.resources.add(t.source.data);
316
+ return t;
317
+ }
318
+ dispose() {
319
+ const t = [];
320
+ for (const e of this.resources)
321
+ e instanceof R ? t.push(e) : e instanceof HTMLVideoElement && e.pause(), Reflect.has(e, "dispose") && e.dispose();
322
+ t.forEach((e) => {
323
+ e.removeFromParent();
324
+ }), t.length = 0, this.resources.clear();
327
325
  }
328
326
  }
329
- class ze extends ie {
327
+ class ze extends X {
330
328
  create() {
331
329
  this.createGroup();
332
330
  }
333
331
  }
334
- const N = new V(), dt = new C(), pt = new C(), b = new V(), y = new V(), I = new V(), Q = new C(), K = new Bt(), x = new _t(), mt = new C(), U = new Mt(), R = new Lt(), T = new V();
335
- let W, _;
336
- function vt(a, t, e) {
337
- return T.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = _ / e.width, T.y = _ / e.height, T.applyMatrix4(a.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
332
+ const N = new O(), dt = new C(), pt = new C(), b = new O(), y = new O(), D = new O(), q = new C(), Q = new Bt(), x = new Lt(), mt = new C(), U = new Mt(), E = new Wt(), T = new O();
333
+ let _, L;
334
+ function vt(r, t, e) {
335
+ return T.set(0, 0, -t, 1).applyMatrix4(r.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = L / e.width, T.y = L / e.height, T.applyMatrix4(r.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
338
336
  }
339
- function se(a, t) {
340
- const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, r = i.attributes.instanceEnd, o = Math.min(i.instanceCount, s.count);
341
- for (let n = 0, l = o; n < l; n++) {
342
- x.start.fromBufferAttribute(s, n), x.end.fromBufferAttribute(r, n), x.applyMatrix4(e);
337
+ function se(r, t) {
338
+ const e = r.matrixWorld, i = r.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
339
+ for (let n = 0, o = l; n < o; n++) {
340
+ x.start.fromBufferAttribute(s, n), x.end.fromBufferAttribute(a, n), x.applyMatrix4(e);
343
341
  const c = new C(), d = new C();
344
- W.distanceSqToSegment(x.start, x.end, d, c), d.distanceTo(c) < _ * 0.5 && t.push({
342
+ _.distanceSqToSegment(x.start, x.end, d, c), d.distanceTo(c) < L * 0.5 && t.push({
345
343
  point: d,
346
344
  pointOnLine: c,
347
- distance: W.origin.distanceTo(d),
348
- object: a,
345
+ distance: _.origin.distanceTo(d),
346
+ object: r,
349
347
  face: null,
350
348
  faceIndex: n,
351
349
  uv: null,
@@ -353,31 +351,31 @@ function se(a, t) {
353
351
  });
354
352
  }
355
353
  }
356
- function ne(a, t, e) {
357
- const i = t.projectionMatrix, r = a.material.resolution, o = a.matrixWorld, n = a.geometry, l = n.attributes.instanceStart, c = n.attributes.instanceEnd, d = Math.min(n.instanceCount, l.count), u = -t.near;
358
- W.at(1, I), I.w = 1, I.applyMatrix4(t.matrixWorldInverse), I.applyMatrix4(i), I.multiplyScalar(1 / I.w), I.x *= r.x / 2, I.y *= r.y / 2, I.z = 0, Q.copy(I), K.multiplyMatrices(t.matrixWorldInverse, o);
354
+ function ne(r, t, e) {
355
+ const i = t.projectionMatrix, a = r.material.resolution, l = r.matrixWorld, n = r.geometry, o = n.attributes.instanceStart, c = n.attributes.instanceEnd, d = Math.min(n.instanceCount, o.count), u = -t.near;
356
+ _.at(1, D), D.w = 1, D.applyMatrix4(t.matrixWorldInverse), D.applyMatrix4(i), D.multiplyScalar(1 / D.w), D.x *= a.x / 2, D.y *= a.y / 2, D.z = 0, q.copy(D), Q.multiplyMatrices(t.matrixWorldInverse, l);
359
357
  for (let m = 0, h = d; m < h; m++) {
360
- if (b.fromBufferAttribute(l, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(K), y.applyMatrix4(K), b.z > u && y.z > u)
358
+ if (b.fromBufferAttribute(o, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(Q), y.applyMatrix4(Q), b.z > u && y.z > u)
361
359
  continue;
362
360
  if (b.z > u) {
363
- const D = b.z - y.z, P = (b.z - u) / D;
361
+ const I = b.z - y.z, P = (b.z - u) / I;
364
362
  b.lerp(y, P);
365
363
  } else if (y.z > u) {
366
- const D = y.z - b.z, P = (y.z - u) / D;
364
+ const I = y.z - b.z, P = (y.z - u) / I;
367
365
  y.lerp(b, P);
368
366
  }
369
- b.applyMatrix4(i), y.applyMatrix4(i), b.multiplyScalar(1 / b.w), y.multiplyScalar(1 / y.w), b.x *= r.x / 2, b.y *= r.y / 2, y.x *= r.x / 2, y.y *= r.y / 2, x.start.copy(b), x.start.z = 0, x.end.copy(y), x.end.z = 0;
370
- const p = x.closestPointToPointParameter(Q, !0);
367
+ b.applyMatrix4(i), y.applyMatrix4(i), b.multiplyScalar(1 / b.w), y.multiplyScalar(1 / y.w), b.x *= a.x / 2, b.y *= a.y / 2, y.x *= a.x / 2, y.y *= a.y / 2, x.start.copy(b), x.start.z = 0, x.end.copy(y), x.end.z = 0;
368
+ const p = x.closestPointToPointParameter(q, !0);
371
369
  x.at(p, mt);
372
- const g = Vt.lerp(b.z, y.z, p), w = g >= -1 && g <= 1, z = Q.distanceTo(mt) < _ * 0.5;
370
+ const g = Vt.lerp(b.z, y.z, p), w = g >= -1 && g <= 1, z = q.distanceTo(mt) < L * 0.5;
373
371
  if (w && z) {
374
- x.start.fromBufferAttribute(l, m), x.end.fromBufferAttribute(c, m), x.start.applyMatrix4(o), x.end.applyMatrix4(o);
375
- const D = new C(), P = new C();
376
- W.distanceSqToSegment(x.start, x.end, P, D), e.push({
372
+ x.start.fromBufferAttribute(o, m), x.end.fromBufferAttribute(c, m), x.start.applyMatrix4(l), x.end.applyMatrix4(l);
373
+ const I = new C(), P = new C();
374
+ _.distanceSqToSegment(x.start, x.end, P, I), e.push({
377
375
  point: P,
378
- pointOnLine: D,
379
- distance: W.origin.distanceTo(P),
380
- object: a,
376
+ pointOnLine: I,
377
+ distance: _.origin.distanceTo(P),
378
+ object: r,
381
379
  face: null,
382
380
  faceIndex: m,
383
381
  uv: null,
@@ -386,26 +384,26 @@ function ne(a, t, e) {
386
384
  }
387
385
  }
388
386
  }
389
- class De extends xt {
387
+ class Ie extends xt {
390
388
  constructor(t = new Qt(), e) {
391
389
  super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
392
390
  }
393
391
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
394
392
  computeLineDistances() {
395
393
  const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
396
- for (let o = 0, n = 0, l = e.count; o < l; o++, n += 2)
397
- dt.fromBufferAttribute(e, o), pt.fromBufferAttribute(i, o), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + dt.distanceTo(pt);
398
- const r = new Ot(
394
+ for (let l = 0, n = 0, o = e.count; l < o; l++, n += 2)
395
+ dt.fromBufferAttribute(e, l), pt.fromBufferAttribute(i, l), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + dt.distanceTo(pt);
396
+ const a = new Ot(
399
397
  s,
400
398
  2,
401
399
  1
402
400
  );
403
401
  return t.setAttribute(
404
402
  "instanceDistanceStart",
405
- new lt(r, 1, 0)
403
+ new lt(a, 1, 0)
406
404
  ), t.setAttribute(
407
405
  "instanceDistanceEnd",
408
- new lt(r, 1, 1)
406
+ new lt(a, 1, 1)
409
407
  ), this;
410
408
  }
411
409
  raycast(t, e) {
@@ -413,42 +411,42 @@ class De extends xt {
413
411
  s === null && !i && console.error(
414
412
  'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
415
413
  );
416
- const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
417
- W = t.ray;
418
- const o = this.matrixWorld, n = this.geometry, l = this.material;
419
- _ = l.linewidth + r, n.boundingSphere === null && n.computeBoundingSphere(), R.copy(n.boundingSphere).applyMatrix4(o);
414
+ const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
415
+ _ = t.ray;
416
+ const l = this.matrixWorld, n = this.geometry, o = this.material;
417
+ L = o.linewidth + a, n.boundingSphere === null && n.computeBoundingSphere(), E.copy(n.boundingSphere).applyMatrix4(l);
420
418
  let c;
421
419
  if (i)
422
- c = _ * 0.5;
420
+ c = L * 0.5;
423
421
  else {
424
422
  const u = Math.max(
425
423
  s.near,
426
- R.distanceToPoint(W.origin)
424
+ E.distanceToPoint(_.origin)
427
425
  );
428
426
  c = vt(
429
427
  s,
430
428
  u,
431
- l.resolution
429
+ o.resolution
432
430
  );
433
431
  }
434
- if (R.radius += c, W.intersectsSphere(R) === !1)
432
+ if (E.radius += c, _.intersectsSphere(E) === !1)
435
433
  return;
436
- n.boundingBox === null && n.computeBoundingBox(), U.copy(n.boundingBox).applyMatrix4(o);
434
+ n.boundingBox === null && n.computeBoundingBox(), U.copy(n.boundingBox).applyMatrix4(l);
437
435
  let d;
438
436
  if (i)
439
- d = _ * 0.5;
437
+ d = L * 0.5;
440
438
  else {
441
439
  const u = Math.max(
442
440
  s.near,
443
- U.distanceToPoint(W.origin)
441
+ U.distanceToPoint(_.origin)
444
442
  );
445
443
  d = vt(
446
444
  s,
447
445
  u,
448
- l.resolution
446
+ o.resolution
449
447
  );
450
448
  }
451
- U.expandByScalar(d), W.intersectsBox(U) !== !1 && (i ? se(this, e) : ne(this, s, e));
449
+ U.expandByScalar(d), _.intersectsBox(U) !== !1 && (i ? se(this, e) : ne(this, s, e));
452
450
  }
453
451
  onBeforeRender(t) {
454
452
  const e = this.material.uniforms;
@@ -603,14 +601,14 @@ const gt = ["encodings_fragment", "colorspace_fragment"], re = (
603
601
 
604
602
  #include <fog_fragment>
605
603
  #include <tonemapping_fragment>
606
- #include <${+Ut < 154 ? gt[0] : gt[1]}>
604
+ #include <${+Et < 154 ? gt[0] : gt[1]}>
607
605
  }
608
606
  `
609
607
  );
610
- class Ie extends kt {
608
+ class De extends kt {
611
609
  constructor(t) {
612
610
  super({
613
- uniforms: q(L({}, Et.fog), {
611
+ uniforms: $(W({}, Ut.fog), {
614
612
  lineWidth: { value: 1 },
615
613
  map: { value: null },
616
614
  useMap: { value: 0 },
@@ -618,7 +616,7 @@ class Ie extends kt {
618
616
  useAlphaMap: { value: 0 },
619
617
  color: { value: new ct(16777215) },
620
618
  opacity: { value: 1 },
621
- resolution: { value: new E(1, 1) },
619
+ resolution: { value: new k(1, 1) },
622
620
  sizeAttenuation: { value: 1 },
623
621
  dashArray: { value: 0 },
624
622
  dashOffset: { value: 0 },
@@ -627,15 +625,15 @@ class Ie extends kt {
627
625
  useDepth: { value: 0 },
628
626
  visibility: { value: 1 },
629
627
  alphaTest: { value: 0 },
630
- repeat: { value: new E(1, 1) },
631
- offset: { value: new E(0, 0) },
628
+ repeat: { value: new k(1, 1) },
629
+ offset: { value: new k(0, 0) },
632
630
  offsetLoop: { value: 1 },
633
631
  lineLightAnimation: { value: 0 },
634
632
  time: { value: 0 },
635
633
  size: { value: 300 },
636
634
  speed: { value: 0.3 },
637
635
  lightWidth: { value: 0.1 },
638
- uCenter: { value: new E(0, 0) },
636
+ uCenter: { value: new k(0, 0) },
639
637
  lightColor: { value: new ct(16777215) }
640
638
  }),
641
639
  vertexShader: re,
@@ -863,72 +861,72 @@ class Ie extends kt {
863
861
  return super.copy(t), this.lineWidth = t.lineWidth, this.map = t.map, this.useMap = t.useMap, this.alphaMap = t.alphaMap, this.useAlphaMap = t.useAlphaMap, this.color.copy(t.color), this.opacity = t.opacity, this.resolution.copy(t.resolution), this.sizeAttenuation = t.sizeAttenuation, this.dashArray = t.dashArray, this.dashOffset = t.dashOffset, this.dashRatio = t.dashRatio, this.useDash = t.useDash, this.visibility = t.visibility, this.alphaTest = t.alphaTest, this.repeat.copy(t.repeat), this;
864
862
  }
865
863
  }
866
- function oe(a, t) {
867
- return a.map((e) => {
864
+ function oe(r, t) {
865
+ return r.map((e) => {
868
866
  const i = [];
869
867
  let s;
870
- return e.forEach((r) => {
868
+ return e.forEach((a) => {
871
869
  if (s) {
872
- const o = $t(r, s) * 180 / Math.PI;
873
- if (o > t) {
874
- const n = qt(s, r), l = 1 / Math.ceil(o / t);
875
- let c = l;
870
+ const l = $t(a, s) * 180 / Math.PI;
871
+ if (l > t) {
872
+ const n = Nt(s, a), o = 1 / Math.ceil(l / t);
873
+ let c = o;
876
874
  for (; c < 1; )
877
- i.push(n(c)), c += l;
875
+ i.push(n(c)), c += o;
878
876
  }
879
877
  }
880
- i.push(s = r);
878
+ i.push(s = a);
881
879
  }), i;
882
880
  });
883
881
  }
884
- function le(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
885
- const r = Math.round(it(360 / a, 2) / Math.PI), o = (1 + Math.sqrt(5)) / 2, n = (h) => h / o * 360 % 360 - 180, l = (h) => Math.acos(2 * h / r - 1) / Math.PI * 180 - 90, c = (h) => r * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, d = [
882
+ function le(r, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
883
+ const a = Math.round(it(360 / r, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, n = (h) => h / l * 360 % 360 - 180, o = (h) => Math.acos(2 * h / a - 1) / Math.PI * 180 - 90, c = (h) => a * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, d = [
886
884
  s !== void 0 ? Math.ceil(c(s)) : 0,
887
- i !== void 0 ? Math.floor(c(i)) : r - 1
885
+ i !== void 0 ? Math.floor(c(i)) : a - 1
888
886
  ], u = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (h) => h <= e : e === void 0 ? (h) => h >= t : e >= t ? (h) => h >= t && h <= e : (h) => h >= t || h <= e, m = [];
889
887
  for (let h = d[0]; h <= d[1]; h++) {
890
888
  const f = n(h);
891
- u(f) && m.push([f, l(h)]);
889
+ u(f) && m.push([f, o(h)]);
892
890
  }
893
891
  return m;
894
892
  }
895
- function Y(a, t, e = !1) {
896
- return e ? Zt(t, a) : Jt(a, t);
893
+ function Y(r, t, e = !1) {
894
+ return e ? Zt(t, r) : Jt(r, t);
897
895
  }
898
- function ce(a, t) {
899
- const e = { type: "Polygon", coordinates: a }, [[i, s], [r, o]] = wt(e);
900
- if (Math.min(Math.abs(r - i), Math.abs(o - s)) < t)
896
+ function ce(r, t) {
897
+ const e = { type: "Polygon", coordinates: r }, [[i, s], [a, l]] = wt(e);
898
+ if (Math.min(Math.abs(a - i), Math.abs(l - s)) < t)
901
899
  return [];
902
- const n = i > r || o >= 89 || s <= -89;
900
+ const n = i > a || l >= 89 || s <= -89;
903
901
  return le(t, {
904
902
  minLng: i,
905
- maxLng: r,
903
+ maxLng: a,
906
904
  minLat: s,
907
- maxLat: o
905
+ maxLat: l
908
906
  }).filter(
909
- (l) => Y(l, e, n)
907
+ (o) => Y(o, e, n)
910
908
  );
911
909
  }
912
- function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
913
- const s = oe(a, t), r = J(s), o = ce(a, t), n = [...r, ...o], l = { type: "Polygon", coordinates: a }, [[c, d], [u, m]] = wt(l), h = c > u || // crosses antimeridian
910
+ function ue(r, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
911
+ const s = oe(r, t), a = J(s), l = ce(r, t), n = [...a, ...l], o = { type: "Polygon", coordinates: r }, [[c, d], [u, m]] = wt(o), h = c > u || // crosses antimeridian
914
912
  m >= 89 || // crosses north pole
915
913
  d <= -89;
916
914
  let f = [];
917
915
  if (h) {
918
916
  const v = te(n).triangles(), M = new Map(
919
- n.map(([A, j], B) => [`${A}-${j}`, B])
917
+ n.map(([j, A], B) => [`${j}-${A}`, B])
920
918
  );
921
- v.features.forEach((A) => {
922
- const j = A.geometry.coordinates[0].slice(0, 3).reverse(), B = [];
923
- if (j.forEach(([S, $]) => {
924
- const k = `${S}-${$}`;
925
- M.has(k) && B.push(M.get(k));
919
+ v.features.forEach((j) => {
920
+ const A = j.geometry.coordinates[0].slice(0, 3).reverse(), B = [];
921
+ if (A.forEach(([S, Z]) => {
922
+ const V = `${S}-${Z}`;
923
+ M.has(V) && B.push(M.get(V));
926
924
  }), B.length === 3) {
927
- if (B.some((S) => S < r.length)) {
928
- const S = A.properties.circumcenter;
925
+ if (B.some((S) => S < a.length)) {
926
+ const S = j.properties.circumcenter;
929
927
  if (!Y(
930
928
  S,
931
- l,
929
+ o,
932
930
  h
933
931
  ))
934
932
  return;
@@ -936,22 +934,22 @@ function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
936
934
  f.push(...B);
937
935
  }
938
936
  });
939
- } else if (o.length) {
937
+ } else if (l.length) {
940
938
  const v = Ht.from(n);
941
- for (let M = 0, A = v.triangles.length; M < A; M += 3) {
942
- const j = [2, 1, 0].map((S) => v.triangles[M + S]), B = j.map((S) => n[S]);
943
- if (j.some((S) => S < r.length)) {
939
+ for (let M = 0, j = v.triangles.length; M < j; M += 3) {
940
+ const A = [2, 1, 0].map((S) => v.triangles[M + S]), B = A.map((S) => n[S]);
941
+ if (A.some((S) => S < a.length)) {
944
942
  const S = [0, 1].map(
945
- ($) => Kt(B, (k) => k[$])
943
+ (Z) => Kt(B, (V) => V[Z])
946
944
  );
947
945
  if (!Y(
948
946
  S,
949
- l,
947
+ o,
950
948
  h
951
949
  ))
952
950
  continue;
953
951
  }
954
- f.push(...j);
952
+ f.push(...A);
955
953
  }
956
954
  } else {
957
955
  const { vertices: v, holes: M = [] } = Pt(s);
@@ -959,43 +957,43 @@ function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
959
957
  }
960
958
  let p = e ? [e[0], e[2]] : ht(n, (v) => v[0]), g = e ? [e[1], e[3]] : ht(n, (v) => v[1]);
961
959
  if (i) {
962
- const [v, M] = i([p[0], g[0]]), [A, j] = i([p[1], g[1]]);
963
- p = [v, A], g = [-M, -j];
960
+ const [v, M] = i([p[0], g[0]]), [j, A] = i([p[1], g[1]]);
961
+ p = [v, j], g = [-M, -A];
964
962
  }
965
- const w = ft(p, [0, 1]), z = ft(g, [0, 1]), D = n.map(([v, M]) => {
963
+ const w = ft(p, [0, 1]), z = ft(g, [0, 1]), I = n.map(([v, M]) => {
966
964
  if (i) {
967
- const [A, j] = i([v, M]);
968
- return [w(A), z(-j)];
965
+ const [j, A] = i([v, M]);
966
+ return [w(j), z(-A)];
969
967
  } else
970
968
  return [w(v), z(M)];
971
969
  });
972
- return { contour: s, triangles: { points: n, indices: f, uvs: D } };
970
+ return { contour: s, triangles: { points: n, indices: f, uvs: I } };
973
971
  }
974
972
  const bt = new H().setAttribute ? "setAttribute" : "addAttribute";
975
- function Z(a, t, e, i) {
976
- const s = a.map(
977
- (r) => r.map(([o, n]) => {
973
+ function F(r, t, e, i) {
974
+ const s = r.map(
975
+ (a) => a.map(([l, n]) => {
978
976
  if (i) {
979
- const [l, c] = i([o, n]);
980
- return [l, -c, t];
977
+ const [o, c] = i([l, n]);
978
+ return [o, -c, t];
981
979
  }
982
- return e ? Nt(o, n, t) : [o, n, t];
980
+ return e ? qt(l, n, t) : [l, n, t];
983
981
  })
984
982
  );
985
983
  return Pt(s);
986
984
  }
987
- function he(a, t, e, i, s) {
988
- const { vertices: r, holes: o } = Z(
989
- a,
985
+ function he(r, t, e, i, s) {
986
+ const { vertices: a, holes: l } = F(
987
+ r,
990
988
  t,
991
989
  i,
992
990
  s
993
- ), { vertices: n } = Z(
994
- a,
991
+ ), { vertices: n } = F(
992
+ r,
995
993
  e,
996
994
  i,
997
995
  s
998
- ), l = J([n, r]), c = Math.round(n.length / 3), d = new Set(o);
996
+ ), o = J([n, a]), c = Math.round(n.length / 3), d = new Set(l);
999
997
  let u = 0;
1000
998
  const m = [];
1001
999
  for (let f = 0; f < c; f++) {
@@ -1011,58 +1009,58 @@ function he(a, t, e, i, s) {
1011
1009
  const h = [];
1012
1010
  for (let f = 1; f >= 0; f--)
1013
1011
  for (let p = 0; p < c; p += 1) h.push(p / (c - 1), f);
1014
- return { indices: m, vertices: l, uvs: h, topVerts: n };
1012
+ return { indices: m, vertices: o, uvs: h, topVerts: n };
1015
1013
  }
1016
- function yt(a, t, e, i, s, r) {
1014
+ function yt(r, t, e, i, s, a) {
1017
1015
  return {
1018
- indices: i ? a.indices : a.indices.slice().reverse(),
1019
- vertices: Z(
1020
- [a.points],
1016
+ indices: i ? r.indices : r.indices.slice().reverse(),
1017
+ vertices: F(
1018
+ [r.points],
1021
1019
  t,
1022
1020
  s,
1023
- r
1021
+ a
1024
1022
  ).vertices,
1025
1023
  uvs: e
1026
1024
  };
1027
1025
  }
1028
1026
  const fe = ({
1029
- polygonGeoJson: a,
1027
+ polygonGeoJson: r,
1030
1028
  startHeight: t,
1031
1029
  endHeight: e,
1032
1030
  curvatureResolution: i = 1,
1033
1031
  cartesian: s = !0,
1034
- hasSide: r = !0,
1035
- hasBottom: o = !1,
1032
+ hasSide: a = !0,
1033
+ hasBottom: l = !1,
1036
1034
  hasTop: n = !1,
1037
- projection: l,
1035
+ projection: o,
1038
1036
  bbox: c
1039
1037
  }) => {
1040
- a.forEach((w) => {
1038
+ r.forEach((w) => {
1041
1039
  Yt(w) || w.reverse();
1042
1040
  });
1043
- const { contour: d, triangles: u } = ue(a, {
1041
+ const { contour: d, triangles: u } = ue(r, {
1044
1042
  resolution: i,
1045
1043
  bbox: c,
1046
- projection: l
1044
+ projection: o
1047
1045
  });
1048
1046
  let m = {}, h;
1049
- r && (m = he(
1047
+ a && (m = he(
1050
1048
  d,
1051
1049
  t != null ? t : e,
1052
1050
  e != null ? e : t,
1053
1051
  s,
1054
- l
1052
+ o
1055
1053
  ), h = m.topVerts);
1056
1054
  let f = [];
1057
- (o || n) && (f = J(u.uvs));
1055
+ (l || n) && (f = J(u.uvs));
1058
1056
  let p = {};
1059
- o && (p = yt(
1057
+ l && (p = yt(
1060
1058
  u,
1061
1059
  t,
1062
1060
  f,
1063
1061
  !1,
1064
1062
  s,
1065
- l
1063
+ o
1066
1064
  ));
1067
1065
  let g = {};
1068
1066
  return n && (g = yt(
@@ -1071,12 +1069,12 @@ const fe = ({
1071
1069
  f,
1072
1070
  !0,
1073
1071
  s,
1074
- l
1072
+ o
1075
1073
  )), { contour: d, triangles: u, sideTorso: m, bottomCap: p, topCap: g, topVerts: h };
1076
1074
  };
1077
1075
  class Te extends H {
1078
1076
  constructor(t, e = {}) {
1079
- super(), this.type = "PolygonBufferGeometry", this.parameters = L({
1077
+ super(), this.type = "PolygonBufferGeometry", this.parameters = W({
1080
1078
  polygonGeoJson: t,
1081
1079
  startHeight: 0,
1082
1080
  endHeight: 1,
@@ -1091,34 +1089,34 @@ class Te extends H {
1091
1089
  const {
1092
1090
  endHeight: i,
1093
1091
  hasTop: s,
1094
- topFirst: r,
1095
- hasBottom: o,
1092
+ topFirst: a,
1093
+ hasBottom: l,
1096
1094
  hasSide: n,
1097
- cartesian: l,
1095
+ cartesian: o,
1098
1096
  userDataRsoOffset: c,
1099
1097
  projection: d
1100
- } = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: p } = fe(L({}, this.parameters));
1101
- let g = [], w = [], z = [], D = 0;
1098
+ } = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: p } = fe(W({}, this.parameters));
1099
+ let g = [], w = [], z = [], I = 0;
1102
1100
  const P = (v) => {
1103
- const M = Math.round(g.length / 3), A = z.length;
1101
+ const M = Math.round(g.length / 3), j = z.length;
1104
1102
  g = g.concat(v.vertices), w = w.concat(v.uvs), z = z.concat(
1105
- M ? v.indices.map((j) => j + M) : v.indices
1106
- ), this.addGroup(A, z.length - A, D++);
1103
+ M ? v.indices.map((A) => A + M) : v.indices
1104
+ ), this.addGroup(j, z.length - j, I++);
1107
1105
  };
1108
- s && r && P(p), n && (P(m), this.userData.topVerts = c ? Z(
1106
+ s && a && P(p), n && (P(m), this.userData.topVerts = c ? F(
1109
1107
  u,
1110
1108
  i + c,
1111
- l,
1109
+ o,
1112
1110
  d
1113
- ).vertices : h), o && P(f), s && !r && P(p), this.setIndex(z), this[bt]("position", new F(g, 3)), this[bt]("uv", new F(w, 2)), this.computeVertexNormals();
1111
+ ).vertices : h), l && P(f), s && !a && P(p), this.setIndex(z), this[bt]("position", new G(g, 3)), this[bt]("uv", new G(w, 2)), this.computeVertexNormals();
1114
1112
  }
1115
1113
  }
1116
1114
  export {
1117
- ie as B,
1115
+ X as B,
1118
1116
  ze as G,
1119
- De as L,
1120
- Ie as M,
1117
+ Ie as L,
1118
+ De as M,
1121
1119
  Te as P,
1122
- O as R,
1120
+ ie as R,
1123
1121
  fe as g
1124
1122
  };