gl-draw 0.14.15 → 0.14.16

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.
@@ -49,7 +49,7 @@ export default class BaseObject extends ResourceTracker {
49
49
  instantiate(meta?: {
50
50
  position: THREE.Vector3 | number[] | [number, number, number];
51
51
  scale?: THREE.Vector3 | number[] | [number, number, number];
52
- }[]): Promise<this>;
52
+ }[], target?: IBaseObject): Promise<this>;
53
53
  private setInstancedMatrix;
54
54
  erase(): void;
55
55
  cloneMaterial(): THREE.Material | THREE.Material[] | undefined;
@@ -2,29 +2,29 @@ var pt = Object.defineProperty, dt = Object.defineProperties;
2
2
  var mt = Object.getOwnPropertyDescriptors;
3
3
  var X = Object.getOwnPropertySymbols;
4
4
  var vt = Object.prototype.hasOwnProperty, gt = Object.prototype.propertyIsEnumerable;
5
- var H = Math.pow, Y = (a, t, e) => t in a ? pt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e, O = (a, t) => {
5
+ var H = Math.pow, Y = (o, t, e) => t in o ? pt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, O = (o, t) => {
6
6
  for (var e in t || (t = {}))
7
- vt.call(t, e) && Y(a, e, t[e]);
7
+ vt.call(t, e) && Y(o, e, t[e]);
8
8
  if (X)
9
9
  for (var e of X(t))
10
- gt.call(t, e) && Y(a, e, t[e]);
11
- return a;
12
- }, Z = (a, t) => dt(a, mt(t));
13
- var J = (a, t, e) => new Promise((s, n) => {
14
- var r = (o) => {
10
+ gt.call(t, e) && Y(o, e, t[e]);
11
+ return o;
12
+ }, Z = (o, t) => dt(o, mt(t));
13
+ var J = (o, t, e) => new Promise((i, s) => {
14
+ var a = (r) => {
15
15
  try {
16
- i(e.next(o));
16
+ n(e.next(r));
17
17
  } catch (c) {
18
- n(c);
18
+ s(c);
19
19
  }
20
- }, l = (o) => {
20
+ }, l = (r) => {
21
21
  try {
22
- i(e.throw(o));
22
+ n(e.throw(r));
23
23
  } catch (c) {
24
- n(c);
24
+ s(c);
25
25
  }
26
- }, i = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(r, l);
27
- i((e = e.apply(a, t)).next());
26
+ }, n = (r) => r.done ? i(r.value) : Promise.resolve(r.value).then(a, l);
27
+ n((e = e.apply(o, t)).next());
28
28
  });
29
29
  import * as u from "three";
30
30
  import { Vector4 as k, Vector3 as B, Matrix4 as bt, Line3 as yt, Box3 as xt, Sphere as Mt, Mesh as wt, InstancedInterleavedBuffer as Pt, InterleavedBufferAttribute as tt, MathUtils as jt } from "three";
@@ -58,14 +58,14 @@ class V {
58
58
  const e = t;
59
59
  this.track(e.geometry), this.track(e.material), this.track(e.children);
60
60
  } else if (t instanceof u.Material) {
61
- for (const s of Object.values(t))
62
- s instanceof u.Texture && this.track(s);
61
+ for (const i of Object.values(t))
62
+ i instanceof u.Texture && this.track(i);
63
63
  const e = t;
64
64
  if (e.uniforms) {
65
- for (const s of Object.values(e.uniforms))
66
- if (s) {
67
- const n = s.value;
68
- (n instanceof u.Texture || Array.isArray(n)) && this.track(n);
65
+ for (const i of Object.values(e.uniforms))
66
+ if (i) {
67
+ const s = i.value;
68
+ (s instanceof u.Texture || Array.isArray(s)) && this.track(s);
69
69
  }
70
70
  }
71
71
  }
@@ -80,7 +80,7 @@ class V {
80
80
  }), t.length = 0, this.resources.clear();
81
81
  }
82
82
  }
83
- const Et = (a, t = 1) => {
83
+ const Et = (o, t = 1) => {
84
84
  const e = new u.BufferGeometry();
85
85
  e.setAttribute(
86
86
  "position",
@@ -89,28 +89,28 @@ const Et = (a, t = 1) => {
89
89
  "scaleAtt",
90
90
  new u.Float32BufferAttribute(new Array(t).fill(1), 1)
91
91
  );
92
- const s = a.material, n = new u.PointsMaterial({
92
+ const i = o.material, s = new u.PointsMaterial({
93
93
  size: 10,
94
- map: s.map,
95
- alphaMap: s.alphaMap,
96
- color: s.color,
97
- blending: s.blending,
98
- depthTest: s.depthTest,
94
+ map: i.map,
95
+ alphaMap: i.alphaMap,
96
+ color: i.color,
97
+ blending: i.blending,
98
+ depthTest: i.depthTest,
99
99
  depthWrite: !1,
100
- opacity: s.opacity,
100
+ opacity: i.opacity,
101
101
  transparent: !0,
102
- alphaTest: s.alphaTest,
102
+ alphaTest: i.alphaTest,
103
103
  sizeAttenuation: !1
104
104
  });
105
- return n.onBeforeCompile = (r) => {
106
- r.vertexShader = `
105
+ return s.onBeforeCompile = (a) => {
106
+ a.vertexShader = `
107
107
  attribute float scaleAtt;
108
- ${r.vertexShader.replace(
108
+ ${a.vertexShader.replace(
109
109
  "gl_PointSize = size;",
110
110
  "gl_PointSize = size * scaleAtt;"
111
111
  )}
112
112
  `;
113
- }, new u.Points(e, n);
113
+ }, new u.Points(e, s);
114
114
  };
115
115
  class Rt extends V {
116
116
  constructor() {
@@ -211,52 +211,51 @@ class Rt extends V {
211
211
  clone() {
212
212
  return this.instantiate();
213
213
  }
214
- instantiate(t) {
214
+ instantiate(t, e) {
215
215
  return J(this, null, function* () {
216
- const e = t && t.length > 0, { objectType: s, objectOptions: n } = this, [, r] = s.split("#"), l = yield this.lead.draw(r, Z(O({}, n || {}), {
217
- create: (i) => {
218
- var o;
216
+ const i = t && t.length > 0, { objectType: s, objectOptions: a } = this, [, l] = s.split("#"), n = yield this.lead.draw(l, Z(O({}, a || {}), {
217
+ create: (r) => {
218
+ var c;
219
219
  if (this.object3d) {
220
- if (e) {
221
- const c = t.length;
220
+ if (i) {
221
+ const p = t.length;
222
222
  if (this.object3d instanceof u.Sprite)
223
- i.object3d = Et(this.object3d, c);
223
+ r.object3d = Et(this.object3d, p);
224
224
  else {
225
- const f = this.object3d;
226
- i.object3d = new u.InstancedMesh(
227
- f.geometry,
228
- f.material,
229
- c
230
- ), i.setMaterialList("instantiate", "clone"), i.useMaterial("instantiate");
225
+ const d = this.object3d;
226
+ r.object3d = new u.InstancedMesh(
227
+ d.geometry,
228
+ d.material,
229
+ p
230
+ ), r.setMaterialList("instantiate", "clone"), r.useMaterial("instantiate");
231
231
  }
232
- const p = new u.Object3D();
233
- t.forEach((f, v) => {
234
- const h = et(f.position), d = et(f.scale || [1, 1, 1]);
235
- p.position.copy(h), p.scale.copy(d), p.updateMatrix(), i.setInstancedMatrix(v, p.matrix.clone());
232
+ const f = new u.Object3D();
233
+ t.forEach((d, h) => {
234
+ const v = et(d.position), m = et(d.scale || [1, 1, 1]);
235
+ f.position.copy(v), f.scale.copy(m), f.updateMatrix(), r.setInstancedMatrix(h, f.matrix.clone());
236
236
  });
237
237
  } else
238
- i.object3d = this.object3d.clone(), i.setMaterialList("instantiate", "clone"), i.useMaterial("instantiate");
239
- i.object3d.userData.bloom && ((o = this.pencil.composerController) == null || o.toggleBloomSelection(
240
- i.object3d,
238
+ r.object3d = this.object3d.clone(!1), r.setMaterialList("instantiate", "clone"), r.useMaterial("instantiate");
239
+ r.object3d.userData.bloom && ((c = this.pencil.composerController) == null || c.toggleBloomSelection(
240
+ r.object3d,
241
241
  !0
242
- )), i.object3d.userData.prefab && (i.object3d.userData.prefab = !1);
242
+ )), r.object3d.userData.prefab && (r.object3d.userData.prefab = !1);
243
243
  }
244
244
  },
245
- prefab: !1
245
+ prefab: !1,
246
+ target: e || (a == null ? void 0 : a.target)
246
247
  }));
247
- for (let i = 0; i < this.children.length; i++) {
248
- const c = yield this.children[i].instantiate();
249
- l.add(c);
250
- }
251
- return l.isInstantiate = !0, l;
248
+ return yield Promise.all(
249
+ this.children.map((r) => r.instantiate(void 0, n))
250
+ ), n.isInstantiate = !0, n;
252
251
  });
253
252
  }
254
253
  setInstancedMatrix(t, e) {
255
254
  if (this.object3d instanceof u.InstancedMesh || this.object3d.isInstantiate)
256
255
  this.object3d.setMatrixAt(t, e);
257
256
  else if (this.object3d instanceof u.Points || this.object3d.type === "Points") {
258
- const n = this.object3d.geometry, r = n.attributes.position.array, l = n.attributes.scaleAtt.array, i = new u.Vector3(), o = new u.Vector3(), c = new u.Quaternion(), p = t * 3, f = t * 1;
259
- e.decompose(i, c, o), r[p] = i.x, r[p + 1] = i.y, r[p + 2] = i.z, l[f] = Math.max(o.x, o.y, o.z), n.attributes.position.needsUpdate = !0, n.attributes.scaleAtt.needsUpdate = !0;
257
+ const s = this.object3d.geometry, a = s.attributes.position.array, l = s.attributes.scaleAtt.array, n = new u.Vector3(), r = new u.Vector3(), c = new u.Quaternion(), p = t * 3, f = t * 1;
258
+ e.decompose(n, c, r), a[p] = n.x, a[p + 1] = n.y, a[p + 2] = n.z, l[f] = Math.max(r.x, r.y, r.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
260
259
  }
261
260
  }
262
261
  erase() {
@@ -268,31 +267,31 @@ class Rt extends V {
268
267
  return;
269
268
  const e = t.material;
270
269
  if (Array.isArray(e))
271
- return e.map((s) => {
272
- const n = s.userData;
273
- s.userData = {};
274
- const r = s.clone();
275
- return s.userData = n, r;
270
+ return e.map((i) => {
271
+ const s = i.userData;
272
+ i.userData = {};
273
+ const a = i.clone();
274
+ return i.userData = s, a;
276
275
  });
277
276
  {
278
- const s = e.userData;
277
+ const i = e.userData;
279
278
  e.userData = {};
280
- const n = e.clone();
281
- return e.userData = s, n;
279
+ const s = e.clone();
280
+ return e.userData = i, s;
282
281
  }
283
282
  }
284
- setMaterialList(t, e, s = !0) {
285
- const n = this.object3d;
286
- if (!n || !n.material)
283
+ setMaterialList(t, e, i = !0) {
284
+ const s = this.object3d;
285
+ if (!s || !s.material)
287
286
  return;
288
- if (this.materialList.origin || (this.materialList.origin = n.material), this.materialList[t])
289
- if (s) {
290
- const l = this.materialList[t], i = new V();
291
- i.track(l), i.dispose();
287
+ if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t])
288
+ if (i) {
289
+ const l = this.materialList[t], n = new V();
290
+ n.track(l), n.dispose();
292
291
  } else
293
292
  return this.materialList[t];
294
- const r = e === "clone" ? this.cloneMaterial() : e;
295
- return this.materialList[t] = r, r;
293
+ const a = e === "clone" ? this.cloneMaterial() : e;
294
+ return this.materialList[t] = a, a;
296
295
  }
297
296
  useMaterial(t) {
298
297
  const e = this.object3d;
@@ -302,8 +301,8 @@ class Rt extends V {
302
301
  this.object3d && (this.object3d.renderOrder = t);
303
302
  }
304
303
  onPointerEvent(t, e) {
305
- const s = this.lead.handlePick([this], t, e);
306
- this.onPointerIndex.push(s);
304
+ const i = this.lead.handlePick([this], t, e);
305
+ this.onPointerIndex.push(i);
307
306
  }
308
307
  dispose() {
309
308
  this.onPointerIndex.forEach((t) => {
@@ -321,31 +320,31 @@ class fe extends Rt {
321
320
  }
322
321
  const $ = new k(), nt = new B(), rt = new B(), y = new k(), x = new k(), I = new k(), q = new B(), N = new bt(), M = new yt(), at = new B(), R = new xt(), U = new Mt(), T = new k();
323
322
  let W, L;
324
- function ot(a, t, e) {
325
- return T.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = L / e.width, T.y = L / e.height, T.applyMatrix4(a.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
323
+ function ot(o, t, e) {
324
+ return T.set(0, 0, -t, 1).applyMatrix4(o.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = L / e.width, T.y = L / e.height, T.applyMatrix4(o.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
326
325
  }
327
- function Ut(a, t) {
328
- const e = a.matrixWorld, s = a.geometry, n = s.attributes.instanceStart, r = s.attributes.instanceEnd, l = Math.min(s.instanceCount, n.count);
329
- for (let i = 0, o = l; i < o; i++) {
330
- M.start.fromBufferAttribute(n, i), M.end.fromBufferAttribute(r, i), M.applyMatrix4(e);
326
+ function Ut(o, t) {
327
+ const e = o.matrixWorld, i = o.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
328
+ for (let n = 0, r = l; n < r; n++) {
329
+ M.start.fromBufferAttribute(s, n), M.end.fromBufferAttribute(a, n), M.applyMatrix4(e);
331
330
  const c = new B(), p = new B();
332
331
  W.distanceSqToSegment(M.start, M.end, p, c), p.distanceTo(c) < L * 0.5 && t.push({
333
332
  point: p,
334
333
  pointOnLine: c,
335
334
  distance: W.origin.distanceTo(p),
336
- object: a,
335
+ object: o,
337
336
  face: null,
338
- faceIndex: i,
337
+ faceIndex: n,
339
338
  uv: null,
340
339
  uv1: null
341
340
  });
342
341
  }
343
342
  }
344
- function Gt(a, t, e) {
345
- const s = t.projectionMatrix, r = a.material.resolution, l = a.matrixWorld, i = a.geometry, o = i.attributes.instanceStart, c = i.attributes.instanceEnd, p = Math.min(i.instanceCount, o.count), f = -t.near;
346
- W.at(1, I), I.w = 1, I.applyMatrix4(t.matrixWorldInverse), I.applyMatrix4(s), I.multiplyScalar(1 / I.w), I.x *= r.x / 2, I.y *= r.y / 2, I.z = 0, q.copy(I), N.multiplyMatrices(t.matrixWorldInverse, l);
347
- for (let v = 0, h = p; v < h; v++) {
348
- if (y.fromBufferAttribute(o, v), x.fromBufferAttribute(c, v), y.w = 1, x.w = 1, y.applyMatrix4(N), x.applyMatrix4(N), y.z > f && x.z > f)
343
+ function Gt(o, t, e) {
344
+ const i = t.projectionMatrix, a = o.material.resolution, l = o.matrixWorld, n = o.geometry, r = n.attributes.instanceStart, c = n.attributes.instanceEnd, p = Math.min(n.instanceCount, r.count), f = -t.near;
345
+ W.at(1, I), I.w = 1, I.applyMatrix4(t.matrixWorldInverse), I.applyMatrix4(i), I.multiplyScalar(1 / I.w), I.x *= a.x / 2, I.y *= a.y / 2, I.z = 0, q.copy(I), N.multiplyMatrices(t.matrixWorldInverse, l);
346
+ for (let d = 0, h = p; d < h; d++) {
347
+ if (y.fromBufferAttribute(r, d), x.fromBufferAttribute(c, d), y.w = 1, x.w = 1, y.applyMatrix4(N), x.applyMatrix4(N), y.z > f && x.z > f)
349
348
  continue;
350
349
  if (y.z > f) {
351
350
  const D = y.z - x.z, P = (y.z - f) / D;
@@ -354,20 +353,20 @@ function Gt(a, t, e) {
354
353
  const D = x.z - y.z, P = (x.z - f) / D;
355
354
  x.lerp(y, P);
356
355
  }
357
- y.applyMatrix4(s), x.applyMatrix4(s), y.multiplyScalar(1 / y.w), x.multiplyScalar(1 / x.w), y.x *= r.x / 2, y.y *= r.y / 2, x.x *= r.x / 2, x.y *= r.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(x), M.end.z = 0;
356
+ y.applyMatrix4(i), x.applyMatrix4(i), y.multiplyScalar(1 / y.w), x.multiplyScalar(1 / x.w), y.x *= a.x / 2, y.y *= a.y / 2, x.x *= a.x / 2, x.y *= a.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(x), M.end.z = 0;
358
357
  const m = M.closestPointToPointParameter(q, !0);
359
358
  M.at(m, at);
360
359
  const b = jt.lerp(y.z, x.z, m), C = b >= -1 && b <= 1, z = q.distanceTo(at) < L * 0.5;
361
360
  if (C && z) {
362
- M.start.fromBufferAttribute(o, v), M.end.fromBufferAttribute(c, v), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
361
+ M.start.fromBufferAttribute(r, d), M.end.fromBufferAttribute(c, d), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
363
362
  const D = new B(), P = new B();
364
363
  W.distanceSqToSegment(M.start, M.end, P, D), e.push({
365
364
  point: P,
366
365
  pointOnLine: D,
367
366
  distance: W.origin.distanceTo(P),
368
- object: a,
367
+ object: o,
369
368
  face: null,
370
- faceIndex: v,
369
+ faceIndex: d,
371
370
  uv: null,
372
371
  uv1: null
373
372
  });
@@ -380,63 +379,63 @@ class pe extends wt {
380
379
  }
381
380
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
382
381
  computeLineDistances() {
383
- const t = this.geometry, e = t.attributes.instanceStart, s = t.attributes.instanceEnd, n = new Float32Array(2 * e.count);
384
- for (let l = 0, i = 0, o = e.count; l < o; l++, i += 2)
385
- nt.fromBufferAttribute(e, l), rt.fromBufferAttribute(s, l), n[i] = i === 0 ? 0 : n[i - 1], n[i + 1] = n[i] + nt.distanceTo(rt);
386
- const r = new Pt(
387
- n,
382
+ const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
383
+ for (let l = 0, n = 0, r = e.count; l < r; l++, n += 2)
384
+ nt.fromBufferAttribute(e, l), rt.fromBufferAttribute(i, l), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + nt.distanceTo(rt);
385
+ const a = new Pt(
386
+ s,
388
387
  2,
389
388
  1
390
389
  );
391
390
  return t.setAttribute(
392
391
  "instanceDistanceStart",
393
- new tt(r, 1, 0)
392
+ new tt(a, 1, 0)
394
393
  ), t.setAttribute(
395
394
  "instanceDistanceEnd",
396
- new tt(r, 1, 1)
395
+ new tt(a, 1, 1)
397
396
  ), this;
398
397
  }
399
398
  raycast(t, e) {
400
- const s = this.material.worldUnits, n = t.camera;
401
- n === null && !s && console.error(
399
+ const i = this.material.worldUnits, s = t.camera;
400
+ s === null && !i && console.error(
402
401
  'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
403
402
  );
404
- const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
403
+ const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
405
404
  W = t.ray;
406
- const l = this.matrixWorld, i = this.geometry, o = this.material;
407
- L = o.linewidth + r, i.boundingSphere === null && i.computeBoundingSphere(), U.copy(i.boundingSphere).applyMatrix4(l);
405
+ const l = this.matrixWorld, n = this.geometry, r = this.material;
406
+ L = r.linewidth + a, n.boundingSphere === null && n.computeBoundingSphere(), U.copy(n.boundingSphere).applyMatrix4(l);
408
407
  let c;
409
- if (s)
408
+ if (i)
410
409
  c = L * 0.5;
411
410
  else {
412
411
  const f = Math.max(
413
- n.near,
412
+ s.near,
414
413
  U.distanceToPoint(W.origin)
415
414
  );
416
415
  c = ot(
417
- n,
416
+ s,
418
417
  f,
419
- o.resolution
418
+ r.resolution
420
419
  );
421
420
  }
422
421
  if (U.radius += c, W.intersectsSphere(U) === !1)
423
422
  return;
424
- i.boundingBox === null && i.computeBoundingBox(), R.copy(i.boundingBox).applyMatrix4(l);
423
+ n.boundingBox === null && n.computeBoundingBox(), R.copy(n.boundingBox).applyMatrix4(l);
425
424
  let p;
426
- if (s)
425
+ if (i)
427
426
  p = L * 0.5;
428
427
  else {
429
428
  const f = Math.max(
430
- n.near,
429
+ s.near,
431
430
  R.distanceToPoint(W.origin)
432
431
  );
433
432
  p = ot(
434
- n,
433
+ s,
435
434
  f,
436
- o.resolution
435
+ r.resolution
437
436
  );
438
437
  }
439
- R.expandByScalar(p), W.intersectsBox(R) !== !1 && (s ? Ut(this, e) : Gt(this, n, e));
438
+ R.expandByScalar(p), W.intersectsBox(R) !== !1 && (i ? Ut(this, e) : Gt(this, s, e));
440
439
  }
441
440
  onBeforeRender(t) {
442
441
  const e = this.material.uniforms;
@@ -851,60 +850,60 @@ class de extends u.ShaderMaterial {
851
850
  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;
852
851
  }
853
852
  }
854
- function $t(a, t) {
855
- return a.map((e) => {
856
- const s = [];
857
- let n;
858
- return e.forEach((r) => {
859
- if (n) {
860
- const l = Dt(r, n) * 180 / Math.PI;
853
+ function $t(o, t) {
854
+ return o.map((e) => {
855
+ const i = [];
856
+ let s;
857
+ return e.forEach((a) => {
858
+ if (s) {
859
+ const l = Dt(a, s) * 180 / Math.PI;
861
860
  if (l > t) {
862
- const i = It(n, r), o = 1 / Math.ceil(l / t);
863
- let c = o;
861
+ const n = It(s, a), r = 1 / Math.ceil(l / t);
862
+ let c = r;
864
863
  for (; c < 1; )
865
- s.push(i(c)), c += o;
864
+ i.push(n(c)), c += r;
866
865
  }
867
866
  }
868
- s.push(n = r);
869
- }), s;
867
+ i.push(s = a);
868
+ }), i;
870
869
  });
871
870
  }
872
- function qt(a, { minLng: t, maxLng: e, minLat: s, maxLat: n } = {}) {
873
- const r = Math.round(H(360 / a, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, i = (h) => h / l * 360 % 360 - 180, o = (h) => Math.acos(2 * h / r - 1) / Math.PI * 180 - 90, c = (h) => r * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, p = [
874
- n !== void 0 ? Math.ceil(c(n)) : 0,
875
- s !== void 0 ? Math.floor(c(s)) : r - 1
876
- ], f = 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, v = [];
871
+ function qt(o, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
872
+ const a = Math.round(H(360 / o, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, n = (h) => h / l * 360 % 360 - 180, r = (h) => Math.acos(2 * h / a - 1) / Math.PI * 180 - 90, c = (h) => a * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, p = [
873
+ s !== void 0 ? Math.ceil(c(s)) : 0,
874
+ i !== void 0 ? Math.floor(c(i)) : a - 1
875
+ ], f = 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, d = [];
877
876
  for (let h = p[0]; h <= p[1]; h++) {
878
- const d = i(h);
879
- f(d) && v.push([d, o(h)]);
877
+ const v = n(h);
878
+ f(v) && d.push([v, r(h)]);
880
879
  }
881
- return v;
880
+ return d;
882
881
  }
883
- function Q(a, t, e = !1) {
884
- return e ? zt(t, a) : Vt(a, t);
882
+ function Q(o, t, e = !1) {
883
+ return e ? zt(t, o) : Vt(o, t);
885
884
  }
886
- function Nt(a, t) {
887
- const e = { type: "Polygon", coordinates: a }, [[s, n], [r, l]] = ht(e);
888
- if (Math.min(Math.abs(r - s), Math.abs(l - n)) < t)
885
+ function Nt(o, t) {
886
+ const e = { type: "Polygon", coordinates: o }, [[i, s], [a, l]] = ht(e);
887
+ if (Math.min(Math.abs(a - i), Math.abs(l - s)) < t)
889
888
  return [];
890
- const i = s > r || l >= 89 || n <= -89;
889
+ const n = i > a || l >= 89 || s <= -89;
891
890
  return qt(t, {
892
- minLng: s,
893
- maxLng: r,
894
- minLat: n,
891
+ minLng: i,
892
+ maxLng: a,
893
+ minLat: s,
895
894
  maxLat: l
896
895
  }).filter(
897
- (o) => Q(o, e, i)
896
+ (r) => Q(r, e, n)
898
897
  );
899
898
  }
900
- function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: s } = {}) {
901
- const n = $t(a, t), r = K(n), l = Nt(a, t), i = [...r, ...l], o = { type: "Polygon", coordinates: a }, [[c, p], [f, v]] = ht(o), h = c > f || // crosses antimeridian
902
- v >= 89 || // crosses north pole
899
+ function Qt(o, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
900
+ const s = $t(o, t), a = K(s), l = Nt(o, t), n = [...a, ...l], r = { type: "Polygon", coordinates: o }, [[c, p], [f, d]] = ht(r), h = c > f || // crosses antimeridian
901
+ d >= 89 || // crosses north pole
903
902
  p <= -89;
904
- let d = [];
903
+ let v = [];
905
904
  if (h) {
906
- const g = kt(i).triangles(), w = new Map(
907
- i.map(([j, A], _) => [`${j}-${A}`, _])
905
+ const g = kt(n).triangles(), w = new Map(
906
+ n.map(([j, A], _) => [`${j}-${A}`, _])
908
907
  );
909
908
  g.features.forEach((j) => {
910
909
  const A = j.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
@@ -912,155 +911,155 @@ function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: s } = {}) {
912
911
  const E = `${S}-${F}`;
913
912
  w.has(E) && _.push(w.get(E));
914
913
  }), _.length === 3) {
915
- if (_.some((S) => S < r.length)) {
914
+ if (_.some((S) => S < a.length)) {
916
915
  const S = j.properties.circumcenter;
917
916
  if (!Q(
918
917
  S,
919
- o,
918
+ r,
920
919
  h
921
920
  ))
922
921
  return;
923
922
  }
924
- d.push(..._);
923
+ v.push(..._);
925
924
  }
926
925
  });
927
926
  } else if (l.length) {
928
- const g = Ot.from(i);
927
+ const g = Ot.from(n);
929
928
  for (let w = 0, j = g.triangles.length; w < j; w += 3) {
930
- const A = [2, 1, 0].map((S) => g.triangles[w + S]), _ = A.map((S) => i[S]);
931
- if (A.some((S) => S < r.length)) {
929
+ const A = [2, 1, 0].map((S) => g.triangles[w + S]), _ = A.map((S) => n[S]);
930
+ if (A.some((S) => S < a.length)) {
932
931
  const S = [0, 1].map(
933
932
  (F) => _t(_, (E) => E[F])
934
933
  );
935
934
  if (!Q(
936
935
  S,
937
- o,
936
+ r,
938
937
  h
939
938
  ))
940
939
  continue;
941
940
  }
942
- d.push(...A);
941
+ v.push(...A);
943
942
  }
944
943
  } else {
945
- const { vertices: g, holes: w = [] } = ft(n);
946
- d = Bt(g, w, 2);
944
+ const { vertices: g, holes: w = [] } = ft(s);
945
+ v = Bt(g, w, 2);
947
946
  }
948
- let m = e ? [e[0], e[2]] : it(i, (g) => g[0]), b = e ? [e[1], e[3]] : it(i, (g) => g[1]);
949
- if (s) {
950
- const [g, w] = s([m[0], b[0]]), [j, A] = s([m[1], b[1]]);
947
+ let m = e ? [e[0], e[2]] : it(n, (g) => g[0]), b = e ? [e[1], e[3]] : it(n, (g) => g[1]);
948
+ if (i) {
949
+ const [g, w] = i([m[0], b[0]]), [j, A] = i([m[1], b[1]]);
951
950
  m = [g, j], b = [-w, -A];
952
951
  }
953
- const C = st(m, [0, 1]), z = st(b, [0, 1]), D = i.map(([g, w]) => {
954
- if (s) {
955
- const [j, A] = s([g, w]);
952
+ const C = st(m, [0, 1]), z = st(b, [0, 1]), D = n.map(([g, w]) => {
953
+ if (i) {
954
+ const [j, A] = i([g, w]);
956
955
  return [C(j), z(-A)];
957
956
  } else
958
957
  return [C(g), z(w)];
959
958
  });
960
- return { contour: n, triangles: { points: i, indices: d, uvs: D } };
959
+ return { contour: s, triangles: { points: n, indices: v, uvs: D } };
961
960
  }
962
961
  const ct = new u.BufferGeometry().setAttribute ? "setAttribute" : "addAttribute";
963
- function G(a, t, e, s) {
964
- const n = a.map(
965
- (r) => r.map(([l, i]) => {
966
- if (s) {
967
- const [o, c] = s([l, i]);
968
- return [o, -c, t];
962
+ function G(o, t, e, i) {
963
+ const s = o.map(
964
+ (a) => a.map(([l, n]) => {
965
+ if (i) {
966
+ const [r, c] = i([l, n]);
967
+ return [r, -c, t];
969
968
  }
970
- return e ? Tt(l, i, t) : [l, i, t];
969
+ return e ? Tt(l, n, t) : [l, n, t];
971
970
  })
972
971
  );
973
- return ft(n);
972
+ return ft(s);
974
973
  }
975
- function Kt(a, t, e, s, n) {
976
- const { vertices: r, holes: l } = G(
977
- a,
974
+ function Kt(o, t, e, i, s) {
975
+ const { vertices: a, holes: l } = G(
976
+ o,
978
977
  t,
979
- s,
980
- n
981
- ), { vertices: i } = G(
982
- a,
978
+ i,
979
+ s
980
+ ), { vertices: n } = G(
981
+ o,
983
982
  e,
984
- s,
985
- n
986
- ), o = K([i, r]), c = Math.round(i.length / 3), p = new Set(l);
983
+ i,
984
+ s
985
+ ), r = K([n, a]), c = Math.round(n.length / 3), p = new Set(l);
987
986
  let f = 0;
988
- const v = [];
989
- for (let d = 0; d < c; d++) {
990
- let m = d + 1;
987
+ const d = [];
988
+ for (let v = 0; v < c; v++) {
989
+ let m = v + 1;
991
990
  if (m === c)
992
991
  m = f;
993
992
  else if (p.has(m)) {
994
993
  const b = m;
995
994
  m = f, f = b;
996
995
  }
997
- v.push(d, d + c, m + c), v.push(m + c, m, d);
996
+ d.push(v, v + c, m + c), d.push(m + c, m, v);
998
997
  }
999
998
  const h = [];
1000
- for (let d = 1; d >= 0; d--)
1001
- for (let m = 0; m < c; m += 1) h.push(m / (c - 1), d);
1002
- return { indices: v, vertices: o, uvs: h, topVerts: i };
999
+ for (let v = 1; v >= 0; v--)
1000
+ for (let m = 0; m < c; m += 1) h.push(m / (c - 1), v);
1001
+ return { indices: d, vertices: r, uvs: h, topVerts: n };
1003
1002
  }
1004
- function ut(a, t, e, s, n, r) {
1003
+ function ut(o, t, e, i, s, a) {
1005
1004
  return {
1006
- indices: s ? a.indices : a.indices.slice().reverse(),
1005
+ indices: i ? o.indices : o.indices.slice().reverse(),
1007
1006
  vertices: G(
1008
- [a.points],
1007
+ [o.points],
1009
1008
  t,
1010
- n,
1011
- r
1009
+ s,
1010
+ a
1012
1011
  ).vertices,
1013
1012
  uvs: e
1014
1013
  };
1015
1014
  }
1016
1015
  const Xt = ({
1017
- polygonGeoJson: a,
1016
+ polygonGeoJson: o,
1018
1017
  startHeight: t,
1019
1018
  endHeight: e,
1020
- curvatureResolution: s = 1,
1021
- cartesian: n = !0,
1022
- hasSide: r = !0,
1019
+ curvatureResolution: i = 1,
1020
+ cartesian: s = !0,
1021
+ hasSide: a = !0,
1023
1022
  hasBottom: l = !1,
1024
- hasTop: i = !1,
1025
- projection: o,
1023
+ hasTop: n = !1,
1024
+ projection: r,
1026
1025
  bbox: c
1027
1026
  }) => {
1028
- a.forEach((C) => {
1027
+ o.forEach((C) => {
1029
1028
  Lt(C) || C.reverse();
1030
1029
  });
1031
- const { contour: p, triangles: f } = Qt(a, {
1032
- resolution: s,
1030
+ const { contour: p, triangles: f } = Qt(o, {
1031
+ resolution: i,
1033
1032
  bbox: c,
1034
- projection: o
1033
+ projection: r
1035
1034
  });
1036
- let v = {}, h;
1037
- r && (v = Kt(
1035
+ let d = {}, h;
1036
+ a && (d = Kt(
1038
1037
  p,
1039
1038
  t != null ? t : e,
1040
1039
  e != null ? e : t,
1041
- n,
1042
- o
1043
- ), h = v.topVerts);
1044
- let d = [];
1045
- (l || i) && (d = K(f.uvs));
1040
+ s,
1041
+ r
1042
+ ), h = d.topVerts);
1043
+ let v = [];
1044
+ (l || n) && (v = K(f.uvs));
1046
1045
  let m = {};
1047
1046
  l && (m = ut(
1048
1047
  f,
1049
1048
  t,
1050
- d,
1049
+ v,
1051
1050
  !1,
1052
- n,
1053
- o
1051
+ s,
1052
+ r
1054
1053
  ));
1055
1054
  let b = {};
1056
- return i && (b = ut(
1055
+ return n && (b = ut(
1057
1056
  f,
1058
1057
  e,
1059
- d,
1058
+ v,
1060
1059
  !0,
1061
- n,
1062
- o
1063
- )), { contour: p, triangles: f, sideTorso: v, bottomCap: m, topCap: b, topVerts: h };
1060
+ s,
1061
+ r
1062
+ )), { contour: p, triangles: f, sideTorso: d, bottomCap: m, topCap: b, topVerts: h };
1064
1063
  };
1065
1064
  class me extends u.BufferGeometry {
1066
1065
  constructor(t, e = {}) {
@@ -1077,15 +1076,15 @@ class me extends u.BufferGeometry {
1077
1076
  userDataRsoOffset: 0
1078
1077
  }, e);
1079
1078
  const {
1080
- endHeight: s,
1081
- hasTop: n,
1082
- topFirst: r,
1079
+ endHeight: i,
1080
+ hasTop: s,
1081
+ topFirst: a,
1083
1082
  hasBottom: l,
1084
- hasSide: i,
1085
- cartesian: o,
1083
+ hasSide: n,
1084
+ cartesian: r,
1086
1085
  userDataRsoOffset: c,
1087
1086
  projection: p
1088
- } = this.parameters, { contour: f, sideTorso: v, topVerts: h, bottomCap: d, topCap: m } = Xt(O({}, this.parameters));
1087
+ } = this.parameters, { contour: f, sideTorso: d, topVerts: h, bottomCap: v, topCap: m } = Xt(O({}, this.parameters));
1089
1088
  let b = [], C = [], z = [], D = 0;
1090
1089
  const P = (g) => {
1091
1090
  const w = Math.round(b.length / 3), j = z.length;
@@ -1093,12 +1092,12 @@ class me extends u.BufferGeometry {
1093
1092
  w ? g.indices.map((A) => A + w) : g.indices
1094
1093
  ), this.addGroup(j, z.length - j, D++);
1095
1094
  };
1096
- n && r && P(m), i && (P(v), this.userData.topVerts = c ? G(
1095
+ s && a && P(m), n && (P(d), this.userData.topVerts = c ? G(
1097
1096
  f,
1098
- s + c,
1099
- o,
1097
+ i + c,
1098
+ r,
1100
1099
  p
1101
- ).vertices : h), l && P(d), n && !r && P(m), this.setIndex(z), this[ct](
1100
+ ).vertices : h), l && P(v), s && !a && P(m), this.setIndex(z), this[ct](
1102
1101
  "position",
1103
1102
  new u.Float32BufferAttribute(b, 3)
1104
1103
  ), this[ct]("uv", new u.Float32BufferAttribute(C, 2)), this.computeVertexNormals();
package/dist/index2.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var dt=Object.defineProperty,pt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var tt=Math.pow,J=(r,t,e)=>t in r?dt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k=(r,t)=>{for(var e in t||(t={}))vt.call(t,e)&&J(r,e,t[e]);if(Y)for(var e of Y(t))gt.call(t,e)&&J(r,e,t[e]);return r},Z=(r,t)=>pt(r,mt(t));var et=(r,t,e)=>new Promise((s,n)=>{var o=a=>{try{i(e.next(a))}catch(c){n(c)}},l=a=>{try{i(e.throw(a))}catch(c){n(c)}},i=a=>a.done?s(a.value):Promise.resolve(a.value).then(o,l);i((e=e.apply(r,t)).next())});const g=require("three"),bt=require("three/examples/jsm/renderers/CSS2DRenderer"),it=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const H=require("./parseVector.js"),yt=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),xt=require("@turf/boolean-clockwise"),Mt=require("delaunator"),wt=require("@turf/boolean-point-in-polygon"),Pt=require("d3-geo-voronoi"),st=require("d3-scale");function jt(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const u=jt(g);class B{constructor(){this.resources=new Set,this.disposeWithMaterial=!0,this.materialList={},this.disposeTrack=!0}track(t){if(!t||this.disposeTrack===!1)return t;if(Array.isArray(t))return t.forEach(e=>this.track(e)),t;if(!this.disposeWithMaterial&&t instanceof u.Material)return t;if(t instanceof B?(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 u.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof B)this.track(t.children);else if(t instanceof u.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof u.Material){for(const s of Object.values(t))s instanceof u.Texture&&this.track(s);const e=t;if(e.uniforms){for(const s of Object.values(e.uniforms))if(s){const n=s.value;(n instanceof u.Texture||Array.isArray(n))&&this.track(n)}}}return t}dispose(){const t=[];for(const e of this.resources)e instanceof u.Object3D&&t.push(e),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const At=(r,t=1)=>{const e=new u.BufferGeometry;e.setAttribute("position",new u.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new u.Float32BufferAttribute(new Array(t).fill(1),1));const s=r.material,n=new u.PointsMaterial({size:10,map:s.map,alphaMap:s.alphaMap,color:s.color,blending:s.blending,depthTest:s.depthTest,depthWrite:!1,opacity:s.opacity,transparent:!0,alphaTest:s.alphaTest,sizeAttenuation:!1});return n.onBeforeCompile=o=>{o.vertexShader=`
1
+ "use strict";var dt=Object.defineProperty,pt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var tt=Math.pow,J=(r,t,e)=>t in r?dt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k=(r,t)=>{for(var e in t||(t={}))vt.call(t,e)&&J(r,e,t[e]);if(Y)for(var e of Y(t))gt.call(t,e)&&J(r,e,t[e]);return r},Z=(r,t)=>pt(r,mt(t));var et=(r,t,e)=>new Promise((i,s)=>{var o=a=>{try{n(e.next(a))}catch(c){s(c)}},l=a=>{try{n(e.throw(a))}catch(c){s(c)}},n=a=>a.done?i(a.value):Promise.resolve(a.value).then(o,l);n((e=e.apply(r,t)).next())});const g=require("three"),bt=require("three/examples/jsm/renderers/CSS2DRenderer"),it=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const H=require("./parseVector.js"),yt=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),xt=require("@turf/boolean-clockwise"),Mt=require("delaunator"),wt=require("@turf/boolean-point-in-polygon"),Pt=require("d3-geo-voronoi"),st=require("d3-scale");function jt(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const u=jt(g);class B{constructor(){this.resources=new Set,this.disposeWithMaterial=!0,this.materialList={},this.disposeTrack=!0}track(t){if(!t||this.disposeTrack===!1)return t;if(Array.isArray(t))return t.forEach(e=>this.track(e)),t;if(!this.disposeWithMaterial&&t instanceof u.Material)return t;if(t instanceof B?(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 u.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof B)this.track(t.children);else if(t instanceof u.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof u.Material){for(const i of Object.values(t))i instanceof u.Texture&&this.track(i);const e=t;if(e.uniforms){for(const i of Object.values(e.uniforms))if(i){const s=i.value;(s instanceof u.Texture||Array.isArray(s))&&this.track(s)}}}return t}dispose(){const t=[];for(const e of this.resources)e instanceof u.Object3D&&t.push(e),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const At=(r,t=1)=>{const e=new u.BufferGeometry;e.setAttribute("position",new u.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new u.Float32BufferAttribute(new Array(t).fill(1),1));const i=r.material,s=new u.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return s.onBeforeCompile=o=>{o.vertexShader=`
2
2
  attribute float scaleAtt;
3
3
  ${o.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new u.Points(e,n)};class ht extends B{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}get parent(){const t=this.object3d.parent;return t&&this.lead.objMap.get(t)||null}get children(){return this.object3d.children.map(t=>this.lead.objMap.get(t)).filter(t=>!!t)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get add(){return this.object3d.add.bind(this.object3d)}get remove(){return this.object3d.remove.bind(this.object3d)}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let t=this.parent;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(t,e){}resize(t,e){}show(){return this.object3d.visible=!0,this}hide(){return this.object3d.visible=!1,this}createMesh(...t){return this.object3d=new u.Mesh(...t),this}createGroup(){return this.object3d=new u.Group,this}createPoints(...t){return this.object3d=new u.Points(...t),this}createCSS2DObject(t){return this.object3d=new bt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new it.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new it.CSS3DSprite(t),this}createSprite(t){return this.object3d=new u.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new u.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new u.Vector3),center:t.getCenter(new u.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t){return et(this,null,function*(){const e=t&&t.length>0,{objectType:s,objectOptions:n}=this,[,o]=s.split("#"),l=yield this.lead.draw(o,Z(k({},n||{}),{create:i=>{var a;if(this.object3d){if(e){const c=t.length;if(this.object3d instanceof u.Sprite)i.object3d=At(this.object3d,c);else{const f=this.object3d;i.object3d=new u.InstancedMesh(f.geometry,f.material,c),i.setMaterialList("instantiate","clone"),i.useMaterial("instantiate")}const d=new u.Object3D;t.forEach((f,v)=>{const h=H.parseVector3(f.position),p=H.parseVector3(f.scale||[1,1,1]);d.position.copy(h),d.scale.copy(p),d.updateMatrix(),i.setInstancedMatrix(v,d.matrix.clone())})}else i.object3d=this.object3d.clone(),i.setMaterialList("instantiate","clone"),i.useMaterial("instantiate");i.object3d.userData.bloom&&((a=this.pencil.composerController)==null||a.toggleBloomSelection(i.object3d,!0)),i.object3d.userData.prefab&&(i.object3d.userData.prefab=!1)}},prefab:!1}));for(let i=0;i<this.children.length;i++){const c=yield this.children[i].instantiate();l.add(c)}return l.isInstantiate=!0,l})}setInstancedMatrix(t,e){if(this.object3d instanceof u.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof u.Points||this.object3d.type==="Points"){const n=this.object3d.geometry,o=n.attributes.position.array,l=n.attributes.scaleAtt.array,i=new u.Vector3,a=new u.Vector3,c=new u.Quaternion,d=t*3,f=t*1;e.decompose(i,c,a),o[d]=i.x,o[d+1]=i.y,o[d+2]=i.z,l[f]=Math.max(a.x,a.y,a.z),n.attributes.position.needsUpdate=!0,n.attributes.scaleAtt.needsUpdate=!0}}erase(){this.dispose()}cloneMaterial(){const t=this.object3d;if(!t||!t.material)return;const e=t.material;if(Array.isArray(e))return e.map(s=>{const n=s.userData;s.userData={};const o=s.clone();return s.userData=n,o});{const s=e.userData;e.userData={};const n=e.clone();return e.userData=s,n}}setMaterialList(t,e,s=!0){const n=this.object3d;if(!n||!n.material)return;if(this.materialList.origin||(this.materialList.origin=n.material),this.materialList[t])if(s){const l=this.materialList[t],i=new B;i.track(l),i.dispose()}else return this.materialList[t];const o=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=o,o}useMaterial(t){const e=this.object3d;!e||!e.material||this.useMaterialType===t||!this.materialList[t]||(this.useMaterialType=t,e.material=this.materialList[t])}setTop(t){this.object3d&&(this.object3d.renderOrder=t)}onPointerEvent(t,e){const s=this.lead.handlePick([this],t,e);this.onPointerIndex.push(s)}dispose(){this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.track(this),super.dispose()}disposeWithOutMaterial(){this.disposeWithMaterial=!1,this.dispose()}}class St extends ht{create(){this.createGroup()}}const $=new g.Vector4,nt=new g.Vector3,rt=new g.Vector3,x=new g.Vector4,M=new g.Vector4,I=new g.Vector4,N=new g.Vector3,Q=new g.Matrix4,w=new g.Line3,ot=new g.Vector3,R=new g.Box3,U=new g.Sphere,O=new g.Vector4;let T,L;function at(r,t,e){return O.set(0,0,-t,1).applyMatrix4(r.projectionMatrix),O.multiplyScalar(1/O.w),O.x=L/e.width,O.y=L/e.height,O.applyMatrix4(r.projectionMatrixInverse),O.multiplyScalar(1/O.w),Math.abs(Math.max(O.x,O.y))}function Ct(r,t){const e=r.matrixWorld,s=r.geometry,n=s.attributes.instanceStart,o=s.attributes.instanceEnd,l=Math.min(s.instanceCount,n.count);for(let i=0,a=l;i<a;i++){w.start.fromBufferAttribute(n,i),w.end.fromBufferAttribute(o,i),w.applyMatrix4(e);const c=new g.Vector3,d=new g.Vector3;T.distanceSqToSegment(w.start,w.end,d,c),d.distanceTo(c)<L*.5&&t.push({point:d,pointOnLine:c,distance:T.origin.distanceTo(d),object:r,face:null,faceIndex:i,uv:null,uv1:null})}}function Dt(r,t,e){const s=t.projectionMatrix,o=r.material.resolution,l=r.matrixWorld,i=r.geometry,a=i.attributes.instanceStart,c=i.attributes.instanceEnd,d=Math.min(i.instanceCount,a.count),f=-t.near;T.at(1,I),I.w=1,I.applyMatrix4(t.matrixWorldInverse),I.applyMatrix4(s),I.multiplyScalar(1/I.w),I.x*=o.x/2,I.y*=o.y/2,I.z=0,N.copy(I),Q.multiplyMatrices(t.matrixWorldInverse,l);for(let v=0,h=d;v<h;v++){if(x.fromBufferAttribute(a,v),M.fromBufferAttribute(c,v),x.w=1,M.w=1,x.applyMatrix4(Q),M.applyMatrix4(Q),x.z>f&&M.z>f)continue;if(x.z>f){const V=x.z-M.z,j=(x.z-f)/V;x.lerp(M,j)}else if(M.z>f){const V=M.z-x.z,j=(M.z-f)/V;M.lerp(x,j)}x.applyMatrix4(s),M.applyMatrix4(s),x.multiplyScalar(1/x.w),M.multiplyScalar(1/M.w),x.x*=o.x/2,x.y*=o.y/2,M.x*=o.x/2,M.y*=o.y/2,w.start.copy(x),w.start.z=0,w.end.copy(M),w.end.z=0;const m=w.closestPointToPointParameter(N,!0);w.at(m,ot);const y=g.MathUtils.lerp(x.z,M.z,m),D=y>=-1&&y<=1,z=N.distanceTo(ot)<L*.5;if(D&&z){w.start.fromBufferAttribute(a,v),w.end.fromBufferAttribute(c,v),w.start.applyMatrix4(l),w.end.applyMatrix4(l);const V=new g.Vector3,j=new g.Vector3;T.distanceSqToSegment(w.start,w.end,j,V),e.push({point:j,pointOnLine:V,distance:T.origin.distanceTo(j),object:r,face:null,faceIndex:v,uv:null,uv1:null})}}}class zt extends g.Mesh{constructor(t=new yt.LineSegmentsGeometry,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,s=t.attributes.instanceEnd,n=new Float32Array(2*e.count);for(let l=0,i=0,a=e.count;l<a;l++,i+=2)nt.fromBufferAttribute(e,l),rt.fromBufferAttribute(s,l),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+nt.distanceTo(rt);const o=new g.InstancedInterleavedBuffer(n,2,1);return t.setAttribute("instanceDistanceStart",new g.InterleavedBufferAttribute(o,1,0)),t.setAttribute("instanceDistanceEnd",new g.InterleavedBufferAttribute(o,1,1)),this}raycast(t,e){const s=this.material.worldUnits,n=t.camera;n===null&&!s&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=t.params.Line2!==void 0&&t.params.Line2.threshold||0;T=t.ray;const l=this.matrixWorld,i=this.geometry,a=this.material;L=a.linewidth+o,i.boundingSphere===null&&i.computeBoundingSphere(),U.copy(i.boundingSphere).applyMatrix4(l);let c;if(s)c=L*.5;else{const f=Math.max(n.near,U.distanceToPoint(T.origin));c=at(n,f,a.resolution)}if(U.radius+=c,T.intersectsSphere(U)===!1)return;i.boundingBox===null&&i.computeBoundingBox(),R.copy(i.boundingBox).applyMatrix4(l);let d;if(s)d=L*.5;else{const f=Math.max(n.near,R.distanceToPoint(T.origin));d=at(n,f,a.resolution)}R.expandByScalar(d),T.intersectsBox(R)!==!1&&(s?Ct(this,e):Dt(this,n,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport($),this.material.uniforms.resolution.value.set($.z,$.w))}}const lt=["encodings_fragment","colorspace_fragment"],Vt=`
4
+ `},new u.Points(e,s)};class ht extends B{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}get parent(){const t=this.object3d.parent;return t&&this.lead.objMap.get(t)||null}get children(){return this.object3d.children.map(t=>this.lead.objMap.get(t)).filter(t=>!!t)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get add(){return this.object3d.add.bind(this.object3d)}get remove(){return this.object3d.remove.bind(this.object3d)}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let t=this.parent;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(t,e){}resize(t,e){}show(){return this.object3d.visible=!0,this}hide(){return this.object3d.visible=!1,this}createMesh(...t){return this.object3d=new u.Mesh(...t),this}createGroup(){return this.object3d=new u.Group,this}createPoints(...t){return this.object3d=new u.Points(...t),this}createCSS2DObject(t){return this.object3d=new bt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new it.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new it.CSS3DSprite(t),this}createSprite(t){return this.object3d=new u.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new u.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new u.Vector3),center:t.getCenter(new u.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return et(this,null,function*(){const i=t&&t.length>0,{objectType:s,objectOptions:o}=this,[,l]=s.split("#"),n=yield this.lead.draw(l,Z(k({},o||{}),{create:a=>{var c;if(this.object3d){if(i){const d=t.length;if(this.object3d instanceof u.Sprite)a.object3d=At(this.object3d,d);else{const p=this.object3d;a.object3d=new u.InstancedMesh(p.geometry,p.material,d),a.setMaterialList("instantiate","clone"),a.useMaterial("instantiate")}const f=new u.Object3D;t.forEach((p,h)=>{const v=H.parseVector3(p.position),m=H.parseVector3(p.scale||[1,1,1]);f.position.copy(v),f.scale.copy(m),f.updateMatrix(),a.setInstancedMatrix(h,f.matrix.clone())})}else a.object3d=this.object3d.clone(!1),a.setMaterialList("instantiate","clone"),a.useMaterial("instantiate");a.object3d.userData.bloom&&((c=this.pencil.composerController)==null||c.toggleBloomSelection(a.object3d,!0)),a.object3d.userData.prefab&&(a.object3d.userData.prefab=!1)}},prefab:!1,target:e||(o==null?void 0:o.target)}));return yield Promise.all(this.children.map(a=>a.instantiate(void 0,n))),n.isInstantiate=!0,n})}setInstancedMatrix(t,e){if(this.object3d instanceof u.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof u.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,o=s.attributes.position.array,l=s.attributes.scaleAtt.array,n=new u.Vector3,a=new u.Vector3,c=new u.Quaternion,d=t*3,f=t*1;e.decompose(n,c,a),o[d]=n.x,o[d+1]=n.y,o[d+2]=n.z,l[f]=Math.max(a.x,a.y,a.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.dispose()}cloneMaterial(){const t=this.object3d;if(!t||!t.material)return;const e=t.material;if(Array.isArray(e))return e.map(i=>{const s=i.userData;i.userData={};const o=i.clone();return i.userData=s,o});{const i=e.userData;e.userData={};const s=e.clone();return e.userData=i,s}}setMaterialList(t,e,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[t])if(i){const l=this.materialList[t],n=new B;n.track(l),n.dispose()}else return this.materialList[t];const o=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=o,o}useMaterial(t){const e=this.object3d;!e||!e.material||this.useMaterialType===t||!this.materialList[t]||(this.useMaterialType=t,e.material=this.materialList[t])}setTop(t){this.object3d&&(this.object3d.renderOrder=t)}onPointerEvent(t,e){const i=this.lead.handlePick([this],t,e);this.onPointerIndex.push(i)}dispose(){this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.track(this),super.dispose()}disposeWithOutMaterial(){this.disposeWithMaterial=!1,this.dispose()}}class St extends ht{create(){this.createGroup()}}const $=new g.Vector4,nt=new g.Vector3,rt=new g.Vector3,x=new g.Vector4,M=new g.Vector4,I=new g.Vector4,N=new g.Vector3,Q=new g.Matrix4,w=new g.Line3,at=new g.Vector3,R=new g.Box3,U=new g.Sphere,T=new g.Vector4;let _,L;function ot(r,t,e){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))}function Ct(r,t){const e=r.matrixWorld,i=r.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let n=0,a=l;n<a;n++){w.start.fromBufferAttribute(s,n),w.end.fromBufferAttribute(o,n),w.applyMatrix4(e);const c=new g.Vector3,d=new g.Vector3;_.distanceSqToSegment(w.start,w.end,d,c),d.distanceTo(c)<L*.5&&t.push({point:d,pointOnLine:c,distance:_.origin.distanceTo(d),object:r,face:null,faceIndex:n,uv:null,uv1:null})}}function Dt(r,t,e){const i=t.projectionMatrix,o=r.material.resolution,l=r.matrixWorld,n=r.geometry,a=n.attributes.instanceStart,c=n.attributes.instanceEnd,d=Math.min(n.instanceCount,a.count),f=-t.near;_.at(1,I),I.w=1,I.applyMatrix4(t.matrixWorldInverse),I.applyMatrix4(i),I.multiplyScalar(1/I.w),I.x*=o.x/2,I.y*=o.y/2,I.z=0,N.copy(I),Q.multiplyMatrices(t.matrixWorldInverse,l);for(let p=0,h=d;p<h;p++){if(x.fromBufferAttribute(a,p),M.fromBufferAttribute(c,p),x.w=1,M.w=1,x.applyMatrix4(Q),M.applyMatrix4(Q),x.z>f&&M.z>f)continue;if(x.z>f){const V=x.z-M.z,j=(x.z-f)/V;x.lerp(M,j)}else if(M.z>f){const V=M.z-x.z,j=(M.z-f)/V;M.lerp(x,j)}x.applyMatrix4(i),M.applyMatrix4(i),x.multiplyScalar(1/x.w),M.multiplyScalar(1/M.w),x.x*=o.x/2,x.y*=o.y/2,M.x*=o.x/2,M.y*=o.y/2,w.start.copy(x),w.start.z=0,w.end.copy(M),w.end.z=0;const m=w.closestPointToPointParameter(N,!0);w.at(m,at);const y=g.MathUtils.lerp(x.z,M.z,m),D=y>=-1&&y<=1,z=N.distanceTo(at)<L*.5;if(D&&z){w.start.fromBufferAttribute(a,p),w.end.fromBufferAttribute(c,p),w.start.applyMatrix4(l),w.end.applyMatrix4(l);const V=new g.Vector3,j=new g.Vector3;_.distanceSqToSegment(w.start,w.end,j,V),e.push({point:j,pointOnLine:V,distance:_.origin.distanceTo(j),object:r,face:null,faceIndex:p,uv:null,uv1:null})}}}class zt extends g.Mesh{constructor(t=new yt.LineSegmentsGeometry,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,s=new Float32Array(2*e.count);for(let l=0,n=0,a=e.count;l<a;l++,n+=2)nt.fromBufferAttribute(e,l),rt.fromBufferAttribute(i,l),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+nt.distanceTo(rt);const o=new g.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new g.InterleavedBufferAttribute(o,1,0)),t.setAttribute("instanceDistanceEnd",new g.InterleavedBufferAttribute(o,1,1)),this}raycast(t,e){const i=this.material.worldUnits,s=t.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=t.params.Line2!==void 0&&t.params.Line2.threshold||0;_=t.ray;const l=this.matrixWorld,n=this.geometry,a=this.material;L=a.linewidth+o,n.boundingSphere===null&&n.computeBoundingSphere(),U.copy(n.boundingSphere).applyMatrix4(l);let c;if(i)c=L*.5;else{const f=Math.max(s.near,U.distanceToPoint(_.origin));c=ot(s,f,a.resolution)}if(U.radius+=c,_.intersectsSphere(U)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),R.copy(n.boundingBox).applyMatrix4(l);let d;if(i)d=L*.5;else{const f=Math.max(s.near,R.distanceToPoint(_.origin));d=ot(s,f,a.resolution)}R.expandByScalar(d),_.intersectsBox(R)!==!1&&(i?Ct(this,e):Dt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport($),this.material.uniforms.resolution.value.set($.z,$.w))}}const lt=["encodings_fragment","colorspace_fragment"],Vt=`
5
5
  #include <common>
6
6
  #include <logdepthbuf_pars_vertex>
7
7
  #include <fog_pars_vertex>
@@ -146,4 +146,4 @@
146
146
  #include <tonemapping_fragment>
147
147
  #include <${+u.REVISION<154?lt[0]:lt[1]}>
148
148
  }
149
- `;class Ot extends u.ShaderMaterial{constructor(t){super({uniforms:Z(k({},u.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new u.Color(16777215)},opacity:{value:1},resolution:{value:new u.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new u.Vector2(1,1)},offset:{value:new u.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new u.Vector2(0,0)},lightColor:{value:new u.Color(16777215)}}),vertexShader:Vt,fragmentShader:It}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(e){this.uniforms.useDash.value=e}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(e){this.uniforms.useDepth.value=e}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(e){this.uniforms.repeat.value.copy(e)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(e){this.uniforms.lineLightAnimation.value=e}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(e){this.uniforms.time.value=e}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(e){this.uniforms.speed.value=e}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(e){this.uniforms.lightWidth.value=e}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(e){this.uniforms.uCenter.value=e}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(e){e&&(this.uniforms.lightColor.value=e)}}}),this.setValues(t)}copy(t){return super.copy(t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray=t.dashArray,this.dashOffset=t.dashOffset,this.dashRatio=t.dashRatio,this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this}}function Tt(r,t){return r.map(e=>{const s=[];let n;return e.forEach(o=>{if(n){const l=E.geoDistance(o,n)*180/Math.PI;if(l>t){const i=E.geoInterpolate(n,o),a=1/Math.ceil(l/t);let c=a;for(;c<1;)s.push(i(c)),c+=a}}s.push(n=o)}),s})}function _t(r,{minLng:t,maxLng:e,minLat:s,maxLat:n}={}){const o=Math.round(tt(360/r,2)/Math.PI),l=(1+Math.sqrt(5))/2,i=h=>h/l*360%360-180,a=h=>Math.acos(2*h/o-1)/Math.PI*180-90,c=h=>o*(Math.cos((h+90)*Math.PI/180)+1)/2,d=[n!==void 0?Math.ceil(c(n)):0,s!==void 0?Math.floor(c(s)):o-1],f=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,v=[];for(let h=d[0];h<=d[1];h++){const p=i(h);f(p)&&v.push([p,a(h)])}return v}function X(r,t,e=!1){return e?E.geoContains(t,r):wt(r,t)}function Lt(r,t){const e={type:"Polygon",coordinates:r},[[s,n],[o,l]]=E.geoBounds(e);if(Math.min(Math.abs(o-s),Math.abs(l-n))<t)return[];const i=s>o||l>=89||n<=-89;return _t(t,{minLng:s,maxLng:o,minLat:n,maxLat:l}).filter(a=>X(a,e,i))}function Wt(r,{resolution:t=1/0,bbox:e,projection:s}={}){const n=Tt(r,t),o=W.merge(n),l=Lt(r,t),i=[...o,...l],a={type:"Polygon",coordinates:r},[[c,d],[f,v]]=E.geoBounds(a),h=c>f||v>=89||d<=-89;let p=[];if(h){const b=Pt.geoVoronoi(i).triangles(),P=new Map(i.map(([A,S],_)=>[`${A}-${S}`,_]));b.features.forEach(A=>{const S=A.geometry.coordinates[0].slice(0,3).reverse(),_=[];if(S.forEach(([C,F])=>{const G=`${C}-${F}`;P.has(G)&&_.push(P.get(G))}),_.length===3){if(_.some(C=>C<o.length)){const C=A.properties.circumcenter;if(!X(C,a,h))return}p.push(..._)}})}else if(l.length){const b=Mt.from(i);for(let P=0,A=b.triangles.length;P<A;P+=3){const S=[2,1,0].map(C=>b.triangles[P+C]),_=S.map(C=>i[C]);if(S.some(C=>C<o.length)){const C=[0,1].map(F=>W.mean(_,G=>G[F]));if(!X(C,a,h))continue}p.push(...S)}}else{const{vertices:b,holes:P=[]}=K.flatten(n);p=K(b,P,2)}let m=e?[e[0],e[2]]:W.extent(i,b=>b[0]),y=e?[e[1],e[3]]:W.extent(i,b=>b[1]);if(s){const[b,P]=s([m[0],y[0]]),[A,S]=s([m[1],y[1]]);m=[b,A],y=[-P,-S]}const D=st.scaleLinear(m,[0,1]),z=st.scaleLinear(y,[0,1]),V=i.map(([b,P])=>{if(s){const[A,S]=s([b,P]);return[D(A),z(-S)]}else return[D(b),z(P)]});return{contour:n,triangles:{points:i,indices:p,uvs:V}}}const ct=new u.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(r,t,e,s){const n=r.map(o=>o.map(([l,i])=>{if(s){const[a,c]=s([l,i]);return[a,-c,t]}return e?H.polar2Cartesian(l,i,t):[l,i,t]}));return K.flatten(n)}function Bt(r,t,e,s,n){const{vertices:o,holes:l}=q(r,t,s,n),{vertices:i}=q(r,e,s,n),a=W.merge([i,o]),c=Math.round(i.length/3),d=new Set(l);let f=0;const v=[];for(let p=0;p<c;p++){let m=p+1;if(m===c)m=f;else if(d.has(m)){const y=m;m=f,f=y}v.push(p,p+c,m+c),v.push(m+c,m,p)}const h=[];for(let p=1;p>=0;p--)for(let m=0;m<c;m+=1)h.push(m/(c-1),p);return{indices:v,vertices:a,uvs:h,topVerts:i}}function ut(r,t,e,s,n,o){return{indices:s?r.indices:r.indices.slice().reverse(),vertices:q([r.points],t,n,o).vertices,uvs:e}}const ft=({polygonGeoJson:r,startHeight:t,endHeight:e,curvatureResolution:s=1,cartesian:n=!0,hasSide:o=!0,hasBottom:l=!1,hasTop:i=!1,projection:a,bbox:c})=>{r.forEach(D=>{xt(D)||D.reverse()});const{contour:d,triangles:f}=Wt(r,{resolution:s,bbox:c,projection:a});let v={},h;o&&(v=Bt(d,t!=null?t:e,e!=null?e:t,n,a),h=v.topVerts);let p=[];(l||i)&&(p=W.merge(f.uvs));let m={};l&&(m=ut(f,t,p,!1,n,a));let y={};return i&&(y=ut(f,e,p,!0,n,a)),{contour:d,triangles:f,sideTorso:v,bottomCap:m,topCap:y,topVerts:h}};class kt extends u.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({polygonGeoJson:t,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},e);const{endHeight:s,hasTop:n,topFirst:o,hasBottom:l,hasSide:i,cartesian:a,userDataRsoOffset:c,projection:d}=this.parameters,{contour:f,sideTorso:v,topVerts:h,bottomCap:p,topCap:m}=ft(k({},this.parameters));let y=[],D=[],z=[],V=0;const j=b=>{const P=Math.round(y.length/3),A=z.length;y=y.concat(b.vertices),D=D.concat(b.uvs),z=z.concat(P?b.indices.map(S=>S+P):b.indices),this.addGroup(A,z.length-A,V++)};n&&o&&j(m),i&&(j(v),this.userData.topVerts=c?q(f,s+c,a,d).vertices:h),l&&j(p),n&&!o&&j(m),this.setIndex(z),this[ct]("position",new u.Float32BufferAttribute(y,3)),this[ct]("uv",new u.Float32BufferAttribute(D,2)),this.computeVertexNormals()}}exports.BaseObject=ht;exports.Group=St;exports.LineSegments2=zt;exports.MeshLineMaterial=Ot;exports.PolygonGeometry=kt;exports.ResourceTracker=B;exports.getMetas=ft;
149
+ `;class Tt extends u.ShaderMaterial{constructor(t){super({uniforms:Z(k({},u.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new u.Color(16777215)},opacity:{value:1},resolution:{value:new u.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new u.Vector2(1,1)},offset:{value:new u.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new u.Vector2(0,0)},lightColor:{value:new u.Color(16777215)}}),vertexShader:Vt,fragmentShader:It}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(e){this.uniforms.useDash.value=e}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(e){this.uniforms.useDepth.value=e}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(e){this.uniforms.repeat.value.copy(e)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(e){this.uniforms.lineLightAnimation.value=e}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(e){this.uniforms.time.value=e}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(e){this.uniforms.speed.value=e}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(e){this.uniforms.lightWidth.value=e}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(e){this.uniforms.uCenter.value=e}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(e){e&&(this.uniforms.lightColor.value=e)}}}),this.setValues(t)}copy(t){return super.copy(t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray=t.dashArray,this.dashOffset=t.dashOffset,this.dashRatio=t.dashRatio,this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this}}function _t(r,t){return r.map(e=>{const i=[];let s;return e.forEach(o=>{if(s){const l=E.geoDistance(o,s)*180/Math.PI;if(l>t){const n=E.geoInterpolate(s,o),a=1/Math.ceil(l/t);let c=a;for(;c<1;)i.push(n(c)),c+=a}}i.push(s=o)}),i})}function Ot(r,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const o=Math.round(tt(360/r,2)/Math.PI),l=(1+Math.sqrt(5))/2,n=h=>h/l*360%360-180,a=h=>Math.acos(2*h/o-1)/Math.PI*180-90,c=h=>o*(Math.cos((h+90)*Math.PI/180)+1)/2,d=[s!==void 0?Math.ceil(c(s)):0,i!==void 0?Math.floor(c(i)):o-1],f=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,p=[];for(let h=d[0];h<=d[1];h++){const v=n(h);f(v)&&p.push([v,a(h)])}return p}function X(r,t,e=!1){return e?E.geoContains(t,r):wt(r,t)}function Lt(r,t){const e={type:"Polygon",coordinates:r},[[i,s],[o,l]]=E.geoBounds(e);if(Math.min(Math.abs(o-i),Math.abs(l-s))<t)return[];const n=i>o||l>=89||s<=-89;return Ot(t,{minLng:i,maxLng:o,minLat:s,maxLat:l}).filter(a=>X(a,e,n))}function Wt(r,{resolution:t=1/0,bbox:e,projection:i}={}){const s=_t(r,t),o=W.merge(s),l=Lt(r,t),n=[...o,...l],a={type:"Polygon",coordinates:r},[[c,d],[f,p]]=E.geoBounds(a),h=c>f||p>=89||d<=-89;let v=[];if(h){const b=Pt.geoVoronoi(n).triangles(),P=new Map(n.map(([A,S],O)=>[`${A}-${S}`,O]));b.features.forEach(A=>{const S=A.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(S.forEach(([C,F])=>{const G=`${C}-${F}`;P.has(G)&&O.push(P.get(G))}),O.length===3){if(O.some(C=>C<o.length)){const C=A.properties.circumcenter;if(!X(C,a,h))return}v.push(...O)}})}else if(l.length){const b=Mt.from(n);for(let P=0,A=b.triangles.length;P<A;P+=3){const S=[2,1,0].map(C=>b.triangles[P+C]),O=S.map(C=>n[C]);if(S.some(C=>C<o.length)){const C=[0,1].map(F=>W.mean(O,G=>G[F]));if(!X(C,a,h))continue}v.push(...S)}}else{const{vertices:b,holes:P=[]}=K.flatten(s);v=K(b,P,2)}let m=e?[e[0],e[2]]:W.extent(n,b=>b[0]),y=e?[e[1],e[3]]:W.extent(n,b=>b[1]);if(i){const[b,P]=i([m[0],y[0]]),[A,S]=i([m[1],y[1]]);m=[b,A],y=[-P,-S]}const D=st.scaleLinear(m,[0,1]),z=st.scaleLinear(y,[0,1]),V=n.map(([b,P])=>{if(i){const[A,S]=i([b,P]);return[D(A),z(-S)]}else return[D(b),z(P)]});return{contour:s,triangles:{points:n,indices:v,uvs:V}}}const ct=new u.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(r,t,e,i){const s=r.map(o=>o.map(([l,n])=>{if(i){const[a,c]=i([l,n]);return[a,-c,t]}return e?H.polar2Cartesian(l,n,t):[l,n,t]}));return K.flatten(s)}function Bt(r,t,e,i,s){const{vertices:o,holes:l}=q(r,t,i,s),{vertices:n}=q(r,e,i,s),a=W.merge([n,o]),c=Math.round(n.length/3),d=new Set(l);let f=0;const p=[];for(let v=0;v<c;v++){let m=v+1;if(m===c)m=f;else if(d.has(m)){const y=m;m=f,f=y}p.push(v,v+c,m+c),p.push(m+c,m,v)}const h=[];for(let v=1;v>=0;v--)for(let m=0;m<c;m+=1)h.push(m/(c-1),v);return{indices:p,vertices:a,uvs:h,topVerts:n}}function ut(r,t,e,i,s,o){return{indices:i?r.indices:r.indices.slice().reverse(),vertices:q([r.points],t,s,o).vertices,uvs:e}}const ft=({polygonGeoJson:r,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:l=!1,hasTop:n=!1,projection:a,bbox:c})=>{r.forEach(D=>{xt(D)||D.reverse()});const{contour:d,triangles:f}=Wt(r,{resolution:i,bbox:c,projection:a});let p={},h;o&&(p=Bt(d,t!=null?t:e,e!=null?e:t,s,a),h=p.topVerts);let v=[];(l||n)&&(v=W.merge(f.uvs));let m={};l&&(m=ut(f,t,v,!1,s,a));let y={};return n&&(y=ut(f,e,v,!0,s,a)),{contour:d,triangles:f,sideTorso:p,bottomCap:m,topCap:y,topVerts:h}};class kt extends u.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({polygonGeoJson:t,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},e);const{endHeight:i,hasTop:s,topFirst:o,hasBottom:l,hasSide:n,cartesian:a,userDataRsoOffset:c,projection:d}=this.parameters,{contour:f,sideTorso:p,topVerts:h,bottomCap:v,topCap:m}=ft(k({},this.parameters));let y=[],D=[],z=[],V=0;const j=b=>{const P=Math.round(y.length/3),A=z.length;y=y.concat(b.vertices),D=D.concat(b.uvs),z=z.concat(P?b.indices.map(S=>S+P):b.indices),this.addGroup(A,z.length-A,V++)};s&&o&&j(m),n&&(j(p),this.userData.topVerts=c?q(f,i+c,a,d).vertices:h),l&&j(v),s&&!o&&j(m),this.setIndex(z),this[ct]("position",new u.Float32BufferAttribute(y,3)),this[ct]("uv",new u.Float32BufferAttribute(D,2)),this.computeVertexNormals()}}exports.BaseObject=ht;exports.Group=St;exports.LineSegments2=zt;exports.MeshLineMaterial=Tt;exports.PolygonGeometry=kt;exports.ResourceTracker=B;exports.getMetas=ft;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.14.15",
3
+ "version": "0.14.16",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",