gl-draw 0.17.0-beta.16 → 0.17.0-beta.17
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.
- package/dist/index.module2.js +211 -211
- package/dist/index2.js +5 -5
- package/package.json +1 -1
package/dist/index.module2.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
var Ie = Object.defineProperty,
|
|
2
|
-
var
|
|
1
|
+
var Ie = Object.defineProperty, Oe = Object.defineProperties;
|
|
2
|
+
var Be = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var W = Object.getOwnPropertySymbols;
|
|
4
4
|
var se = Object.prototype.hasOwnProperty, ne = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var re = Math.pow, ie = (
|
|
5
|
+
var re = Math.pow, ie = (r, e, t) => e in r ? Ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, L = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
se.call(e, t) && ie(
|
|
7
|
+
se.call(e, t) && ie(r, t, e[t]);
|
|
8
8
|
if (W)
|
|
9
9
|
for (var t of W(e))
|
|
10
|
-
ne.call(e, t) && ie(
|
|
11
|
-
return
|
|
12
|
-
}, q = (
|
|
13
|
-
var oe = (
|
|
10
|
+
ne.call(e, t) && ie(r, t, e[t]);
|
|
11
|
+
return r;
|
|
12
|
+
}, q = (r, e) => Oe(r, Be(e));
|
|
13
|
+
var oe = (r, e) => {
|
|
14
14
|
var t = {};
|
|
15
|
-
for (var i in
|
|
16
|
-
se.call(
|
|
17
|
-
if (
|
|
18
|
-
for (var i of W(
|
|
19
|
-
e.indexOf(i) < 0 && ne.call(
|
|
15
|
+
for (var i in r)
|
|
16
|
+
se.call(r, i) && e.indexOf(i) < 0 && (t[i] = r[i]);
|
|
17
|
+
if (r != null && W)
|
|
18
|
+
for (var i of W(r))
|
|
19
|
+
e.indexOf(i) < 0 && ne.call(r, i) && (t[i] = r[i]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var ae = (
|
|
23
|
-
var o = (
|
|
22
|
+
var ae = (r, e, t) => new Promise((i, s) => {
|
|
23
|
+
var o = (a) => {
|
|
24
24
|
try {
|
|
25
|
-
|
|
25
|
+
n(t.next(a));
|
|
26
26
|
} catch (l) {
|
|
27
27
|
s(l);
|
|
28
28
|
}
|
|
29
|
-
},
|
|
29
|
+
}, c = (a) => {
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
n(t.throw(a));
|
|
32
32
|
} catch (l) {
|
|
33
33
|
s(l);
|
|
34
34
|
}
|
|
35
|
-
},
|
|
36
|
-
|
|
35
|
+
}, n = (a) => a.done ? i(a.value) : Promise.resolve(a.value).then(o, c);
|
|
36
|
+
n((t = t.apply(r, e)).next());
|
|
37
37
|
});
|
|
38
|
-
import { merge as
|
|
39
|
-
import
|
|
40
|
-
import { Material as le, Object3D as R, Texture as ue, BufferGeometry as ee, Float32BufferAttribute as G, PointsMaterial as Ee, Points as te, InstancedMesh as je, Vector3 as S, Quaternion as
|
|
38
|
+
import { merge as J, mean as Te, extent as ce } from "d3-array";
|
|
39
|
+
import De, { flatten as Se } from "earcut";
|
|
40
|
+
import { Material as le, Object3D as R, Texture as ue, BufferGeometry as ee, Float32BufferAttribute as G, PointsMaterial as Ee, Points as te, InstancedMesh as je, Vector3 as S, Quaternion as ze, Group as ke, Mesh as Ce, Sprite as de, Box3 as Pe, ShaderMaterial as Le, Vector2 as K, Color as he, Vector4 as V, Matrix4 as Ve, Line3 as Ne, Sphere as We, InstancedInterleavedBuffer as Ue, InterleavedBufferAttribute as fe, MathUtils as _e } from "three";
|
|
41
41
|
import Re from "@turf/boolean-clockwise";
|
|
42
42
|
import { p as pe, a as Ge } from "./polar2Cartesian.module.js";
|
|
43
43
|
import $e from "delaunator";
|
|
@@ -47,9 +47,9 @@ import { geoVoronoi as Xe } from "d3-geo-voronoi";
|
|
|
47
47
|
import { scaleLinear as me } from "d3-scale";
|
|
48
48
|
import { LineSegmentsGeometry as Ye } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
49
49
|
import { CSS2DObject as Ze } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
50
|
-
import { CSS3DObject as
|
|
50
|
+
import { CSS3DObject as He, CSS3DSprite as Je } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
51
51
|
import "d3-geo-projection";
|
|
52
|
-
const et = 0,
|
|
52
|
+
const et = 0, Dt = 1, tt = 2, Et = !1;
|
|
53
53
|
class it {
|
|
54
54
|
constructor() {
|
|
55
55
|
this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
|
|
@@ -91,7 +91,7 @@ class it {
|
|
|
91
91
|
}), e.length = 0, this.resources.clear();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
const st = (
|
|
94
|
+
const st = (r, e = 1) => {
|
|
95
95
|
const t = new ee();
|
|
96
96
|
t.setAttribute(
|
|
97
97
|
"position",
|
|
@@ -100,7 +100,7 @@ const st = (n, e = 1) => {
|
|
|
100
100
|
"scaleAtt",
|
|
101
101
|
new G(new Array(e).fill(1), 1)
|
|
102
102
|
);
|
|
103
|
-
const i =
|
|
103
|
+
const i = r.material, s = new Ee({
|
|
104
104
|
size: 10,
|
|
105
105
|
map: i.map,
|
|
106
106
|
alphaMap: i.alphaMap,
|
|
@@ -122,17 +122,17 @@ const st = (n, e = 1) => {
|
|
|
122
122
|
)}
|
|
123
123
|
`;
|
|
124
124
|
}, new te(t, s);
|
|
125
|
-
}, nt = (
|
|
125
|
+
}, nt = (r, e) => {
|
|
126
126
|
const t = new R();
|
|
127
127
|
e.forEach((i, s) => {
|
|
128
|
-
const o = pe(i.position),
|
|
129
|
-
t.position.copy(o), t.scale.copy(
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
else if (
|
|
134
|
-
const l =
|
|
135
|
-
|
|
128
|
+
const o = pe(i.position), c = pe(i.scale || [1, 1, 1]);
|
|
129
|
+
t.position.copy(o), t.scale.copy(c), t.updateMatrix();
|
|
130
|
+
const n = t.matrix.clone();
|
|
131
|
+
if (r instanceof je || r.isInstantiate)
|
|
132
|
+
r.setMatrixAt(s, n);
|
|
133
|
+
else if (r instanceof te || r.type === "Points") {
|
|
134
|
+
const l = r.geometry, m = l.attributes.position.array, u = l.attributes.scaleAtt.array, f = new S(), d = new S(), p = new ze(), h = s * 3, v = s * 1;
|
|
135
|
+
n.decompose(f, p, d), m[h] = f.x, m[h + 1] = f.y, m[h + 2] = f.z, u[v] = Math.max(d.x, d.y, d.z), l.attributes.position.needsUpdate = !0, l.attributes.scaleAtt.needsUpdate = !0;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
};
|
|
@@ -291,7 +291,7 @@ class Z extends ot {
|
|
|
291
291
|
return this.object3d.visible = !1, this.object3d.layers.set(tt), this;
|
|
292
292
|
}
|
|
293
293
|
createGroup() {
|
|
294
|
-
return this.object3d = new
|
|
294
|
+
return this.object3d = new ke(), this;
|
|
295
295
|
}
|
|
296
296
|
createMesh(...e) {
|
|
297
297
|
return this.object3d = new Ce(...e), this;
|
|
@@ -303,10 +303,10 @@ class Z extends ot {
|
|
|
303
303
|
return this.object3d = new Ze(e), this;
|
|
304
304
|
}
|
|
305
305
|
createCSS3DObject(e) {
|
|
306
|
-
return this.object3d = new
|
|
306
|
+
return this.object3d = new He(e), this;
|
|
307
307
|
}
|
|
308
308
|
createCSS3DSprite(e) {
|
|
309
|
-
return this.object3d = new
|
|
309
|
+
return this.object3d = new Je(e), this;
|
|
310
310
|
}
|
|
311
311
|
createSprite(e) {
|
|
312
312
|
return this.object3d = new de(e), this;
|
|
@@ -337,10 +337,10 @@ class Z extends ot {
|
|
|
337
337
|
return ae(this, null, function* () {
|
|
338
338
|
var l, m;
|
|
339
339
|
const t = (l = e == null ? void 0 : e.recursive) != null ? l : !0, i = (m = e == null ? void 0 : e.cloneMaterial) != null ? m : !1, { objectType: s, objectOptions: o } = this;
|
|
340
|
-
let
|
|
341
|
-
return
|
|
342
|
-
target:
|
|
343
|
-
}) : (
|
|
340
|
+
let c = e == null ? void 0 : e.create, n, a = (e == null ? void 0 : e.target) || this.parent;
|
|
341
|
+
return a === this.lead.prefabGroup && (a = this.lead.group), this.objectType === "BaseObject" ? n = this.lead.createBaseObject(this.object3d.clone(!1), {
|
|
342
|
+
target: a
|
|
343
|
+
}) : (c === void 0 && (c = (u) => {
|
|
344
344
|
var f;
|
|
345
345
|
if (this.object3d) {
|
|
346
346
|
if ((f = e == null ? void 0 : e.instancedAttr) != null && f.length) {
|
|
@@ -360,23 +360,23 @@ class Z extends ot {
|
|
|
360
360
|
u.object3d = this.object3d.clone(!1), i && u.object3d.material && (u.object3d.material = this.cloneMaterial());
|
|
361
361
|
u.object3d.userData.prefab && delete u.object3d.userData.prefab;
|
|
362
362
|
}
|
|
363
|
-
}),
|
|
364
|
-
create:
|
|
363
|
+
}), n = yield this.lead.draw(s, q(L({}, o || {}), {
|
|
364
|
+
create: c,
|
|
365
365
|
prefab: !1,
|
|
366
366
|
keyType: this.keyType,
|
|
367
367
|
key: (e == null ? void 0 : e.key) || this.keyName,
|
|
368
368
|
uId: (e == null ? void 0 : e.uId) || this.keyUId,
|
|
369
|
-
target:
|
|
370
|
-
}))), this.isBloom &&
|
|
369
|
+
target: a
|
|
370
|
+
}))), this.isBloom && n.enableBloom(), t && (yield Promise.all(
|
|
371
371
|
this.children.map(
|
|
372
372
|
(u) => u.instantiate({
|
|
373
373
|
key: u.keyUId && u.keyName ? `${u.keyName}-${u.keyUId}` : u.keyName,
|
|
374
374
|
uId: e == null ? void 0 : e.uId,
|
|
375
375
|
cloneMaterial: i,
|
|
376
|
-
target:
|
|
376
|
+
target: n
|
|
377
377
|
})
|
|
378
378
|
)
|
|
379
|
-
)),
|
|
379
|
+
)), n.isInstantiate = !0, n;
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
382
|
erase() {
|
|
@@ -400,90 +400,90 @@ class Z extends ot {
|
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function at(
|
|
404
|
-
return
|
|
403
|
+
function at(r, e) {
|
|
404
|
+
return r.map((t) => {
|
|
405
405
|
const i = [];
|
|
406
406
|
let s;
|
|
407
407
|
return t.forEach((o) => {
|
|
408
408
|
if (s) {
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
411
|
-
const
|
|
412
|
-
let l =
|
|
409
|
+
const c = Ke(o, s) * 180 / Math.PI;
|
|
410
|
+
if (c > e) {
|
|
411
|
+
const n = Qe(s, o), a = 1 / Math.ceil(c / e);
|
|
412
|
+
let l = a;
|
|
413
413
|
for (; l < 1; )
|
|
414
|
-
i.push(
|
|
414
|
+
i.push(n(l)), l += a;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
i.push(s = o);
|
|
418
418
|
}), i;
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
|
-
function ct(
|
|
422
|
-
const o = Math.round(re(360 /
|
|
421
|
+
function ct(r, { minLng: e, maxLng: t, minLat: i, maxLat: s } = {}) {
|
|
422
|
+
const o = Math.round(re(360 / r, 2) / Math.PI), c = (1 + Math.sqrt(5)) / 2, n = (d) => d / c * 360 % 360 - 180, a = (d) => Math.acos(2 * d / o - 1) / Math.PI * 180 - 90, l = (d) => o * (Math.cos((d + 90) * Math.PI / 180) + 1) / 2, m = [
|
|
423
423
|
s !== void 0 ? Math.ceil(l(s)) : 0,
|
|
424
424
|
i !== void 0 ? Math.floor(l(i)) : o - 1
|
|
425
425
|
], u = e === void 0 && t === void 0 ? () => !0 : e === void 0 ? (d) => d <= t : t === void 0 ? (d) => d >= e : t >= e ? (d) => d >= e && d <= t : (d) => d >= e || d <= t, f = [];
|
|
426
426
|
for (let d = m[0]; d <= m[1]; d++) {
|
|
427
|
-
const p =
|
|
428
|
-
u(p) && f.push([p,
|
|
427
|
+
const p = n(d);
|
|
428
|
+
u(p) && f.push([p, a(d)]);
|
|
429
429
|
}
|
|
430
430
|
return f;
|
|
431
431
|
}
|
|
432
|
-
function
|
|
433
|
-
return t ? qe(e,
|
|
432
|
+
function H(r, e, t = !1) {
|
|
433
|
+
return t ? qe(e, r) : Fe(r, e);
|
|
434
434
|
}
|
|
435
|
-
function lt(
|
|
436
|
-
const t = { type: "Polygon", coordinates:
|
|
437
|
-
if (Math.min(Math.abs(o - i), Math.abs(
|
|
435
|
+
function lt(r, e) {
|
|
436
|
+
const t = { type: "Polygon", coordinates: r }, [[i, s], [o, c]] = Ae(t);
|
|
437
|
+
if (Math.min(Math.abs(o - i), Math.abs(c - s)) < e)
|
|
438
438
|
return [];
|
|
439
|
-
const
|
|
439
|
+
const n = i > o || c >= 89 || s <= -89;
|
|
440
440
|
return ct(e, {
|
|
441
441
|
minLng: i,
|
|
442
442
|
maxLng: o,
|
|
443
443
|
minLat: s,
|
|
444
|
-
maxLat:
|
|
444
|
+
maxLat: c
|
|
445
445
|
}).filter(
|
|
446
|
-
(
|
|
446
|
+
(a) => H(a, t, n)
|
|
447
447
|
);
|
|
448
448
|
}
|
|
449
|
-
function ut(
|
|
450
|
-
const s = at(
|
|
449
|
+
function ut(r, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
|
|
450
|
+
const s = at(r, e), o = J(s), c = lt(r, e), n = [...o, ...c], a = { type: "Polygon", coordinates: r }, [[l, m], [u, f]] = Ae(a), d = l > u || // crosses antimeridian
|
|
451
451
|
f >= 89 || // crosses north pole
|
|
452
452
|
m <= -89;
|
|
453
453
|
let p = [];
|
|
454
454
|
if (d) {
|
|
455
|
-
const
|
|
456
|
-
|
|
455
|
+
const y = Xe(n).triangles(), x = new Map(
|
|
456
|
+
n.map(([A, I], z) => [`${A}-${I}`, z])
|
|
457
457
|
);
|
|
458
|
-
|
|
459
|
-
const I = A.geometry.coordinates[0].slice(0, 3).reverse(),
|
|
460
|
-
if (I.forEach(([
|
|
461
|
-
const N = `${
|
|
462
|
-
|
|
463
|
-
}),
|
|
464
|
-
if (
|
|
465
|
-
const
|
|
466
|
-
if (!
|
|
467
|
-
|
|
468
|
-
|
|
458
|
+
y.features.forEach((A) => {
|
|
459
|
+
const I = A.geometry.coordinates[0].slice(0, 3).reverse(), z = [];
|
|
460
|
+
if (I.forEach(([O, F]) => {
|
|
461
|
+
const N = `${O}-${F}`;
|
|
462
|
+
x.has(N) && z.push(x.get(N));
|
|
463
|
+
}), z.length === 3) {
|
|
464
|
+
if (z.some((O) => O < o.length)) {
|
|
465
|
+
const O = A.properties.circumcenter;
|
|
466
|
+
if (!H(
|
|
467
|
+
O,
|
|
468
|
+
a,
|
|
469
469
|
d
|
|
470
470
|
))
|
|
471
471
|
return;
|
|
472
472
|
}
|
|
473
|
-
p.push(...
|
|
473
|
+
p.push(...z);
|
|
474
474
|
}
|
|
475
475
|
});
|
|
476
|
-
} else if (
|
|
477
|
-
const
|
|
478
|
-
for (let
|
|
479
|
-
const I = [2, 1, 0].map((
|
|
480
|
-
if (I.some((
|
|
481
|
-
const
|
|
482
|
-
(F) =>
|
|
476
|
+
} else if (c.length) {
|
|
477
|
+
const y = $e.from(n);
|
|
478
|
+
for (let x = 0, A = y.triangles.length; x < A; x += 3) {
|
|
479
|
+
const I = [2, 1, 0].map((O) => y.triangles[x + O]), z = I.map((O) => n[O]);
|
|
480
|
+
if (I.some((O) => O < o.length)) {
|
|
481
|
+
const O = [0, 1].map(
|
|
482
|
+
(F) => Te(z, (N) => N[F])
|
|
483
483
|
);
|
|
484
|
-
if (!
|
|
485
|
-
|
|
486
|
-
|
|
484
|
+
if (!H(
|
|
485
|
+
O,
|
|
486
|
+
a,
|
|
487
487
|
d
|
|
488
488
|
))
|
|
489
489
|
continue;
|
|
@@ -491,48 +491,48 @@ function ut(n, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
|
|
|
491
491
|
p.push(...I);
|
|
492
492
|
}
|
|
493
493
|
} else {
|
|
494
|
-
const { vertices:
|
|
495
|
-
p =
|
|
494
|
+
const { vertices: y, holes: x = [] } = Se(s);
|
|
495
|
+
p = De(y, x, 2);
|
|
496
496
|
}
|
|
497
|
-
let h = t ? [t[0], t[2]] : ce(
|
|
497
|
+
let h = t ? [t[0], t[2]] : ce(n, (y) => y[0]), v = t ? [t[1], t[3]] : ce(n, (y) => y[1]);
|
|
498
498
|
if (i) {
|
|
499
|
-
const [
|
|
500
|
-
h = [
|
|
499
|
+
const [y, x] = i([h[0], v[0]]), [A, I] = i([h[1], v[1]]);
|
|
500
|
+
h = [y, A], v = [-x, -I];
|
|
501
501
|
}
|
|
502
|
-
const j = me(h, [0, 1]), C = me(v, [0, 1]),
|
|
502
|
+
const j = me(h, [0, 1]), C = me(v, [0, 1]), B = n.map(([y, x]) => {
|
|
503
503
|
if (i) {
|
|
504
|
-
const [A, I] = i([
|
|
504
|
+
const [A, I] = i([y, x]);
|
|
505
505
|
return [j(A), C(-I)];
|
|
506
506
|
} else
|
|
507
|
-
return [j(
|
|
507
|
+
return [j(y), C(x)];
|
|
508
508
|
});
|
|
509
|
-
return { contour: s, triangles: { points:
|
|
509
|
+
return { contour: s, triangles: { points: n, indices: p, uvs: B } };
|
|
510
510
|
}
|
|
511
511
|
const ve = new ee().setAttribute ? "setAttribute" : "addAttribute";
|
|
512
|
-
function $(
|
|
513
|
-
const s =
|
|
514
|
-
(o) => o.map(([
|
|
512
|
+
function $(r, e, t, i) {
|
|
513
|
+
const s = r.map(
|
|
514
|
+
(o) => o.map(([c, n]) => {
|
|
515
515
|
if (i) {
|
|
516
|
-
const [
|
|
517
|
-
return [
|
|
516
|
+
const [a, l] = i([c, n]);
|
|
517
|
+
return [a, -l, e];
|
|
518
518
|
}
|
|
519
|
-
return t ? Ge(
|
|
519
|
+
return t ? Ge(c, n, e) : [c, n, e];
|
|
520
520
|
})
|
|
521
521
|
);
|
|
522
522
|
return Se(s);
|
|
523
523
|
}
|
|
524
|
-
function dt(
|
|
525
|
-
const { vertices: o, holes:
|
|
526
|
-
|
|
524
|
+
function dt(r, e, t, i, s) {
|
|
525
|
+
const { vertices: o, holes: c } = $(
|
|
526
|
+
r,
|
|
527
527
|
e,
|
|
528
528
|
i,
|
|
529
529
|
s
|
|
530
|
-
), { vertices:
|
|
531
|
-
|
|
530
|
+
), { vertices: n } = $(
|
|
531
|
+
r,
|
|
532
532
|
t,
|
|
533
533
|
i,
|
|
534
534
|
s
|
|
535
|
-
),
|
|
535
|
+
), a = J([n, o]), l = Math.round(n.length / 3), m = new Set(c);
|
|
536
536
|
let u = 0;
|
|
537
537
|
const f = [];
|
|
538
538
|
for (let p = 0; p < l; p++) {
|
|
@@ -548,13 +548,13 @@ function dt(n, e, t, i, s) {
|
|
|
548
548
|
const d = [];
|
|
549
549
|
for (let p = 1; p >= 0; p--)
|
|
550
550
|
for (let h = 0; h < l; h += 1) d.push(h / (l - 1), p);
|
|
551
|
-
return { indices: f, vertices:
|
|
551
|
+
return { indices: f, vertices: a, uvs: d, topVerts: n };
|
|
552
552
|
}
|
|
553
|
-
function be(
|
|
553
|
+
function be(r, e, t, i, s, o) {
|
|
554
554
|
return {
|
|
555
|
-
indices: i ?
|
|
555
|
+
indices: i ? r.indices : r.indices.slice().reverse(),
|
|
556
556
|
vertices: $(
|
|
557
|
-
[
|
|
557
|
+
[r.points],
|
|
558
558
|
e,
|
|
559
559
|
s,
|
|
560
560
|
o
|
|
@@ -563,24 +563,24 @@ function be(n, e, t, i, s, o) {
|
|
|
563
563
|
};
|
|
564
564
|
}
|
|
565
565
|
const ht = ({
|
|
566
|
-
polygonGeoJson:
|
|
566
|
+
polygonGeoJson: r,
|
|
567
567
|
startHeight: e,
|
|
568
568
|
endHeight: t,
|
|
569
569
|
curvatureResolution: i = 1,
|
|
570
570
|
cartesian: s = !0,
|
|
571
571
|
hasSide: o = !0,
|
|
572
|
-
hasBottom:
|
|
573
|
-
hasTop:
|
|
574
|
-
projection:
|
|
572
|
+
hasBottom: c = !1,
|
|
573
|
+
hasTop: n = !1,
|
|
574
|
+
projection: a,
|
|
575
575
|
bbox: l
|
|
576
576
|
}) => {
|
|
577
|
-
|
|
577
|
+
r.forEach((j) => {
|
|
578
578
|
Re(j) || j.reverse();
|
|
579
579
|
});
|
|
580
|
-
const { contour: m, triangles: u } = ut(
|
|
580
|
+
const { contour: m, triangles: u } = ut(r, {
|
|
581
581
|
resolution: i,
|
|
582
582
|
bbox: l,
|
|
583
|
-
projection:
|
|
583
|
+
projection: a
|
|
584
584
|
});
|
|
585
585
|
let f = {}, d;
|
|
586
586
|
o && (f = dt(
|
|
@@ -588,30 +588,30 @@ const ht = ({
|
|
|
588
588
|
e != null ? e : t,
|
|
589
589
|
t != null ? t : e,
|
|
590
590
|
s,
|
|
591
|
-
|
|
591
|
+
a
|
|
592
592
|
), d = f.topVerts);
|
|
593
593
|
let p = [];
|
|
594
|
-
(
|
|
594
|
+
(c || n) && (p = J(u.uvs));
|
|
595
595
|
let h = {};
|
|
596
|
-
|
|
596
|
+
c && (h = be(
|
|
597
597
|
u,
|
|
598
598
|
e,
|
|
599
599
|
p,
|
|
600
600
|
!1,
|
|
601
601
|
s,
|
|
602
|
-
|
|
602
|
+
a
|
|
603
603
|
));
|
|
604
604
|
let v = {};
|
|
605
|
-
return
|
|
605
|
+
return n && (v = be(
|
|
606
606
|
u,
|
|
607
607
|
t,
|
|
608
608
|
p,
|
|
609
609
|
!0,
|
|
610
610
|
s,
|
|
611
|
-
|
|
611
|
+
a
|
|
612
612
|
)), { contour: m, triangles: u, sideTorso: f, bottomCap: h, topCap: v, topVerts: d };
|
|
613
613
|
};
|
|
614
|
-
class
|
|
614
|
+
class zt extends ee {
|
|
615
615
|
constructor(e, t = {}) {
|
|
616
616
|
super(), this.type = "PolygonBufferGeometry", this.parameters = L({
|
|
617
617
|
polygonGeoJson: e,
|
|
@@ -629,25 +629,25 @@ class kt extends ee {
|
|
|
629
629
|
endHeight: i,
|
|
630
630
|
hasTop: s,
|
|
631
631
|
topFirst: o,
|
|
632
|
-
hasBottom:
|
|
633
|
-
hasSide:
|
|
634
|
-
cartesian:
|
|
632
|
+
hasBottom: c,
|
|
633
|
+
hasSide: n,
|
|
634
|
+
cartesian: a,
|
|
635
635
|
userDataRsoOffset: l,
|
|
636
636
|
projection: m
|
|
637
637
|
} = this.parameters, { contour: u, sideTorso: f, topVerts: d, bottomCap: p, topCap: h } = ht(L({}, this.parameters));
|
|
638
|
-
let v = [], j = [], C = [],
|
|
639
|
-
const P = (
|
|
640
|
-
const
|
|
641
|
-
v = v.concat(
|
|
642
|
-
|
|
643
|
-
), this.addGroup(A, C.length - A,
|
|
638
|
+
let v = [], j = [], C = [], B = 0;
|
|
639
|
+
const P = (y) => {
|
|
640
|
+
const x = Math.round(v.length / 3), A = C.length;
|
|
641
|
+
v = v.concat(y.vertices), j = j.concat(y.uvs), C = C.concat(
|
|
642
|
+
x ? y.indices.map((I) => I + x) : y.indices
|
|
643
|
+
), this.addGroup(A, C.length - A, B++);
|
|
644
644
|
};
|
|
645
|
-
s && o && P(h),
|
|
645
|
+
s && o && P(h), n && (P(f), this.userData.topVerts = l ? $(
|
|
646
646
|
u,
|
|
647
647
|
i + l,
|
|
648
|
-
|
|
648
|
+
a,
|
|
649
649
|
m
|
|
650
|
-
).vertices : d),
|
|
650
|
+
).vertices : d), c && P(p), s && !o && P(h), this.setIndex(C), this[ve]("position", new G(v, 3)), this[ve]("uv", new G(j, 2)), this.computeVertexNormals();
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
const ft = `
|
|
@@ -787,16 +787,16 @@ void main() {
|
|
|
787
787
|
#include <fog_vertex>
|
|
788
788
|
}
|
|
789
789
|
`;
|
|
790
|
-
class
|
|
790
|
+
class kt extends Le {
|
|
791
791
|
constructor(e = {}) {
|
|
792
792
|
const C = e, {
|
|
793
793
|
lineWidth: t = 1,
|
|
794
794
|
color: i = "#ffffff",
|
|
795
795
|
opacity: s = 1,
|
|
796
796
|
map: o = null,
|
|
797
|
-
dashOffset:
|
|
798
|
-
dashArray:
|
|
799
|
-
dashRatio:
|
|
797
|
+
dashOffset: c = 0,
|
|
798
|
+
dashArray: n = 0,
|
|
799
|
+
dashRatio: a = 0,
|
|
800
800
|
sizeAttenuation: l = !0,
|
|
801
801
|
offsetLoop: m = !0,
|
|
802
802
|
offset: u = new K(0, 0),
|
|
@@ -833,10 +833,10 @@ class zt extends Le {
|
|
|
833
833
|
sizeAttenuation: { value: l ? 1 : 0 },
|
|
834
834
|
offset: { value: u },
|
|
835
835
|
offsetLoop: { value: m ? 1 : 0 },
|
|
836
|
-
dashArray: { value:
|
|
837
|
-
dashOffset: { value:
|
|
838
|
-
dashRatio: { value:
|
|
839
|
-
useDash: { value:
|
|
836
|
+
dashArray: { value: n },
|
|
837
|
+
dashOffset: { value: c },
|
|
838
|
+
dashRatio: { value: a },
|
|
839
|
+
useDash: { value: n > 0 ? 1 : 0 },
|
|
840
840
|
scaleDown: { value: f / 10 },
|
|
841
841
|
alphaTest: { value: p },
|
|
842
842
|
alphaMap: { value: d },
|
|
@@ -895,53 +895,53 @@ class zt extends Le {
|
|
|
895
895
|
this.uniforms.sizeAttenuation.value = e ? 1 : 0;
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
|
-
const Q = new V(), ye = new S(), ge = new S(),
|
|
899
|
-
let E,
|
|
900
|
-
function we(
|
|
901
|
-
return
|
|
898
|
+
const Q = new V(), ye = new S(), ge = new S(), g = new V(), M = new V(), T = new V(), X = new S(), Y = new Ve(), w = new Ne(), Me = new S(), U = new Pe(), _ = new We(), D = new V();
|
|
899
|
+
let E, k;
|
|
900
|
+
function we(r, e, t) {
|
|
901
|
+
return D.set(0, 0, -e, 1).applyMatrix4(r.projectionMatrix), D.multiplyScalar(1 / D.w), D.x = k / t.width, D.y = k / t.height, D.applyMatrix4(r.projectionMatrixInverse), D.multiplyScalar(1 / D.w), Math.abs(Math.max(D.x, D.y));
|
|
902
902
|
}
|
|
903
|
-
function mt(
|
|
904
|
-
const t =
|
|
905
|
-
for (let
|
|
906
|
-
|
|
903
|
+
function mt(r, e) {
|
|
904
|
+
const t = r.matrixWorld, i = r.geometry, s = i.attributes.instanceStart, o = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
|
|
905
|
+
for (let n = 0, a = c; n < a; n++) {
|
|
906
|
+
w.start.fromBufferAttribute(s, n), w.end.fromBufferAttribute(o, n), w.applyMatrix4(t);
|
|
907
907
|
const l = new S(), m = new S();
|
|
908
|
-
E.distanceSqToSegment(
|
|
908
|
+
E.distanceSqToSegment(w.start, w.end, m, l), m.distanceTo(l) < k * 0.5 && e.push({
|
|
909
909
|
point: m,
|
|
910
910
|
pointOnLine: l,
|
|
911
911
|
distance: E.origin.distanceTo(m),
|
|
912
|
-
object:
|
|
912
|
+
object: r,
|
|
913
913
|
face: null,
|
|
914
|
-
faceIndex:
|
|
914
|
+
faceIndex: n,
|
|
915
915
|
uv: null,
|
|
916
916
|
uv1: null
|
|
917
917
|
});
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
function vt(
|
|
921
|
-
const i = e.projectionMatrix, o =
|
|
922
|
-
E.at(1,
|
|
920
|
+
function vt(r, e, t) {
|
|
921
|
+
const i = e.projectionMatrix, o = r.material.resolution, c = r.matrixWorld, n = r.geometry, a = n.attributes.instanceStart, l = n.attributes.instanceEnd, m = Math.min(n.instanceCount, a.count), u = -e.near;
|
|
922
|
+
E.at(1, T), T.w = 1, T.applyMatrix4(e.matrixWorldInverse), T.applyMatrix4(i), T.multiplyScalar(1 / T.w), T.x *= o.x / 2, T.y *= o.y / 2, T.z = 0, X.copy(T), Y.multiplyMatrices(e.matrixWorldInverse, c);
|
|
923
923
|
for (let f = 0, d = m; f < d; f++) {
|
|
924
|
-
if (
|
|
924
|
+
if (g.fromBufferAttribute(a, f), M.fromBufferAttribute(l, f), g.w = 1, M.w = 1, g.applyMatrix4(Y), M.applyMatrix4(Y), g.z > u && M.z > u)
|
|
925
925
|
continue;
|
|
926
|
-
if (
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
} else if (
|
|
930
|
-
const
|
|
931
|
-
|
|
926
|
+
if (g.z > u) {
|
|
927
|
+
const B = g.z - M.z, P = (g.z - u) / B;
|
|
928
|
+
g.lerp(M, P);
|
|
929
|
+
} else if (M.z > u) {
|
|
930
|
+
const B = M.z - g.z, P = (M.z - u) / B;
|
|
931
|
+
M.lerp(g, P);
|
|
932
932
|
}
|
|
933
|
-
|
|
934
|
-
const h =
|
|
935
|
-
|
|
936
|
-
const v =
|
|
933
|
+
g.applyMatrix4(i), M.applyMatrix4(i), g.multiplyScalar(1 / g.w), M.multiplyScalar(1 / M.w), g.x *= o.x / 2, g.y *= o.y / 2, M.x *= o.x / 2, M.y *= o.y / 2, w.start.copy(g), w.start.z = 0, w.end.copy(M), w.end.z = 0;
|
|
934
|
+
const h = w.closestPointToPointParameter(X, !0);
|
|
935
|
+
w.at(h, Me);
|
|
936
|
+
const v = _e.lerp(g.z, M.z, h), j = v >= -1 && v <= 1, C = X.distanceTo(Me) < k * 0.5;
|
|
937
937
|
if (j && C) {
|
|
938
|
-
|
|
939
|
-
const
|
|
940
|
-
E.distanceSqToSegment(
|
|
938
|
+
w.start.fromBufferAttribute(a, f), w.end.fromBufferAttribute(l, f), w.start.applyMatrix4(c), w.end.applyMatrix4(c);
|
|
939
|
+
const B = new S(), P = new S();
|
|
940
|
+
E.distanceSqToSegment(w.start, w.end, P, B), t.push({
|
|
941
941
|
point: P,
|
|
942
|
-
pointOnLine:
|
|
942
|
+
pointOnLine: B,
|
|
943
943
|
distance: E.origin.distanceTo(P),
|
|
944
|
-
object:
|
|
944
|
+
object: r,
|
|
945
945
|
face: null,
|
|
946
946
|
faceIndex: f,
|
|
947
947
|
uv: null,
|
|
@@ -957,9 +957,9 @@ class Lt extends Ce {
|
|
|
957
957
|
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
958
958
|
computeLineDistances() {
|
|
959
959
|
const e = this.geometry, t = e.attributes.instanceStart, i = e.attributes.instanceEnd, s = new Float32Array(2 * t.count);
|
|
960
|
-
for (let
|
|
961
|
-
ye.fromBufferAttribute(t,
|
|
962
|
-
const o = new
|
|
960
|
+
for (let c = 0, n = 0, a = t.count; c < a; c++, n += 2)
|
|
961
|
+
ye.fromBufferAttribute(t, c), ge.fromBufferAttribute(i, c), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + ye.distanceTo(ge);
|
|
962
|
+
const o = new Ue(
|
|
963
963
|
s,
|
|
964
964
|
2,
|
|
965
965
|
1
|
|
@@ -979,47 +979,47 @@ class Lt extends Ce {
|
|
|
979
979
|
);
|
|
980
980
|
const o = e.params.Line2 !== void 0 && e.params.Line2.threshold || 0;
|
|
981
981
|
E = e.ray;
|
|
982
|
-
const
|
|
983
|
-
|
|
982
|
+
const c = this.matrixWorld, n = this.geometry, a = this.material;
|
|
983
|
+
k = a.linewidth + o, n.boundingSphere === null && n.computeBoundingSphere(), _.copy(n.boundingSphere).applyMatrix4(c);
|
|
984
984
|
let l;
|
|
985
985
|
if (i)
|
|
986
|
-
l =
|
|
986
|
+
l = k * 0.5;
|
|
987
987
|
else {
|
|
988
988
|
const u = Math.max(
|
|
989
989
|
s.near,
|
|
990
|
-
|
|
990
|
+
_.distanceToPoint(E.origin)
|
|
991
991
|
);
|
|
992
992
|
l = we(
|
|
993
993
|
s,
|
|
994
994
|
u,
|
|
995
|
-
|
|
995
|
+
a.resolution
|
|
996
996
|
);
|
|
997
997
|
}
|
|
998
|
-
if (
|
|
998
|
+
if (_.radius += l, E.intersectsSphere(_) === !1)
|
|
999
999
|
return;
|
|
1000
|
-
|
|
1000
|
+
n.boundingBox === null && n.computeBoundingBox(), U.copy(n.boundingBox).applyMatrix4(c);
|
|
1001
1001
|
let m;
|
|
1002
1002
|
if (i)
|
|
1003
|
-
m =
|
|
1003
|
+
m = k * 0.5;
|
|
1004
1004
|
else {
|
|
1005
1005
|
const u = Math.max(
|
|
1006
1006
|
s.near,
|
|
1007
|
-
|
|
1007
|
+
U.distanceToPoint(E.origin)
|
|
1008
1008
|
);
|
|
1009
1009
|
m = we(
|
|
1010
1010
|
s,
|
|
1011
1011
|
u,
|
|
1012
|
-
|
|
1012
|
+
a.resolution
|
|
1013
1013
|
);
|
|
1014
1014
|
}
|
|
1015
|
-
|
|
1015
|
+
U.expandByScalar(m), E.intersectsBox(U) !== !1 && (i ? mt(this, t) : vt(this, s, t));
|
|
1016
1016
|
}
|
|
1017
1017
|
onBeforeRender(e) {
|
|
1018
1018
|
const t = this.material.uniforms;
|
|
1019
1019
|
t && t.resolution && (e.getViewport(Q), this.material.uniforms.resolution.value.set(Q.z, Q.w));
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
1022
|
-
const
|
|
1022
|
+
const b = class b extends Z {
|
|
1023
1023
|
constructor(e) {
|
|
1024
1024
|
super(), this.objectType = "Node", this.onNodePointerIndex = [], this.options = L({
|
|
1025
1025
|
type: "2d"
|
|
@@ -1041,18 +1041,18 @@ const x = class x extends Z {
|
|
|
1041
1041
|
moveElementToViewport() {
|
|
1042
1042
|
const e = this.options.children;
|
|
1043
1043
|
if (!e) return;
|
|
1044
|
-
const t = e.getBoundingClientRect(), i = window.innerWidth, s = window.innerHeight;
|
|
1045
|
-
let
|
|
1046
|
-
t.left < 0 ?
|
|
1044
|
+
const t = e.getBoundingClientRect(), i = window.innerWidth, s = window.innerHeight, o = t.width, c = t.height;
|
|
1045
|
+
let n = 0, a = 0;
|
|
1046
|
+
o > i ? t.left > 0 && (n = -t.left) : t.left < 0 ? n = -t.left : t.right > i && (n = i - t.right, t.left + n < 0 && (n = -t.left)), c > s ? t.top > 0 && (a = -t.top) : t.top < 0 ? a = -t.top : t.bottom > s && (a = s - t.bottom, t.top + a < 0 && (a = -t.top)), (n !== 0 || a !== 0) && (e.style.transform = `translate(${n}px, ${a}px)`);
|
|
1047
1047
|
}
|
|
1048
1048
|
ensureVisible() {
|
|
1049
1049
|
const e = this.options.children;
|
|
1050
|
-
e && (e.style.transform && (e.style.transform = ""),
|
|
1050
|
+
e && (e.style.transform && (e.style.transform = ""), !b.observerMap.has(e) && (b.sharedObserver || (b.sharedObserver = new IntersectionObserver((t) => {
|
|
1051
1051
|
t.forEach((i) => {
|
|
1052
|
-
const s = i.target, o =
|
|
1053
|
-
o && i.isIntersecting && (o.moveElementToViewport(),
|
|
1052
|
+
const s = i.target, o = b.observerMap.get(s);
|
|
1053
|
+
o && i.isIntersecting && (o.moveElementToViewport(), b.observerMap.delete(s), b.sharedObserver && (b.sharedObserver.unobserve(s), b.observerMap.size === 0 && (b.sharedObserver.disconnect(), b.sharedObserver = void 0)));
|
|
1054
1054
|
});
|
|
1055
|
-
})),
|
|
1055
|
+
})), b.observerMap.set(e, this), b.sharedObserver.observe(e)));
|
|
1056
1056
|
}
|
|
1057
1057
|
onPointerEvent(e, t) {
|
|
1058
1058
|
const i = this.lead.handlePickNode([this], e, t);
|
|
@@ -1060,20 +1060,20 @@ const x = class x extends Z {
|
|
|
1060
1060
|
}
|
|
1061
1061
|
dispose() {
|
|
1062
1062
|
const e = this.options.children;
|
|
1063
|
-
e &&
|
|
1063
|
+
e && b.sharedObserver && (b.observerMap.delete(e), b.sharedObserver.unobserve(e), b.observerMap.size === 0 && (b.sharedObserver.disconnect(), b.sharedObserver = void 0)), this.onNodePointerIndex.forEach((t) => {
|
|
1064
1064
|
this.lead.removePickNode(t);
|
|
1065
1065
|
}), super.dispose();
|
|
1066
1066
|
}
|
|
1067
1067
|
};
|
|
1068
|
-
|
|
1069
|
-
let xe =
|
|
1068
|
+
b.observerMap = /* @__PURE__ */ new Map();
|
|
1069
|
+
let xe = b;
|
|
1070
1070
|
export {
|
|
1071
|
-
|
|
1071
|
+
Dt as B,
|
|
1072
1072
|
Et as I,
|
|
1073
1073
|
Lt as L,
|
|
1074
|
-
|
|
1074
|
+
kt as M,
|
|
1075
1075
|
xe as N,
|
|
1076
|
-
|
|
1076
|
+
zt as P,
|
|
1077
1077
|
it as R,
|
|
1078
1078
|
Z as a,
|
|
1079
1079
|
ht as g
|
package/dist/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var ve=Object.defineProperty,be=Object.defineProperties;var ye=Object.getOwnPropertyDescriptors;var
|
|
1
|
+
"use strict";var ve=Object.defineProperty,be=Object.defineProperties;var ye=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var se=Math.pow,ee=(n,e,t)=>e in n?ve(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,L=(n,e)=>{for(var t in e||(e={}))te.call(e,t)&&ee(n,t,e[t]);if(U)for(var t of U(e))ie.call(e,t)&&ee(n,t,e[t]);return n},$=(n,e)=>be(n,ye(e));var re=(n,e)=>{var t={};for(var i in n)te.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&U)for(var i of U(n))e.indexOf(i)<0&&ie.call(n,i)&&(t[i]=n[i]);return t};var ne=(n,e,t)=>new Promise((i,s)=>{var a=c=>{try{r(t.next(c))}catch(u){s(u)}},l=c=>{try{r(t.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,l);r((t=t.apply(n,e)).next())});const k=require("d3-array"),Y=require("earcut"),o=require("three"),ge=require("@turf/boolean-clockwise"),Z=require("./polar2Cartesian.js"),Me=require("delaunator"),we=require("@turf/boolean-point-in-polygon"),N=require("d3-geo"),xe=require("d3-geo-voronoi"),oe=require("d3-scale"),Se=require("three/examples/jsm/lines/LineSegmentsGeometry"),je=require("three/examples/jsm/renderers/CSS2DRenderer"),ae=require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo-projection");const Ce=0,Ae=1,Pe=2,Ie=!1;class pe{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof o.Material)return e;if(e instanceof R?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof R)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const i of Object.values(e))i instanceof o.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof o.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Be=(n,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,s=new o.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=a=>{a.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
|
-
${
|
|
4
|
-
`},new a.Points(t,s)},De=(r,e)=>{const t=new a.Object3D;e.forEach((i,s)=>{const o=Z.parseVector3(i.position),c=Z.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(c),t.updateMatrix();const n=t.matrix.clone();if(r instanceof a.InstancedMesh||r.isInstantiate)r.setMatrixAt(s,n);else if(r instanceof a.Points||r.type==="Points"){const u=r.geometry,v=u.attributes.position.array,d=u.attributes.scaleAtt.array,p=new a.Vector3,h=new a.Vector3,m=new a.Quaternion,f=s*3,b=s*1;n.decompose(p,m,h),v[f]=p.x,v[f+1]=p.y,v[f+2]=p.z,d[b]=Math.max(h.x,h.y,h.z),u.attributes.position.needsUpdate=!0,u.attributes.scaleAtt.needsUpdate=!0}})};class Ve{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class Oe extends Ve{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const o=i.clone();return i.userData=s,o});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const s=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=s,s}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class R extends Oe{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}lookAt(e){const t=e instanceof a.Vector3?e:new a.Vector3(...e);this.object3d.lookAt(t)}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(Ce),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Pe),this}createGroup(){return this.object3d=new a.Group,this}createMesh(...e){return this.object3d=new a.Mesh(...e),this}createPoints(...e){return this.object3d=new a.Points(...e),this}createCSS2DObject(e){return this.object3d=new je.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ae.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ae.CSS3DSprite(e),this}createSprite(e){return this.object3d=new a.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new a.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new a.Vector3),center:e.getCenter(new a.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return ne(this,null,function*(){var u,v;const t=(u=e==null?void 0:e.recursive)!=null?u:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:s,objectOptions:o}=this;let c=e==null?void 0:e.create,n,l=(e==null?void 0:e.target)||this.parent;return l===this.lead.prefabGroup&&(l=this.lead.group),this.objectType==="BaseObject"?n=this.lead.createBaseObject(this.object3d.clone(!1),{target:l}):(c===void 0&&(c=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const h=e.instancedAttr.length;if(this.object3d instanceof a.Sprite)d.object3d=Be(this.object3d,h);else{const m=this.object3d,f=i?this.cloneMaterial():m.material;d.object3d=new a.InstancedMesh(m.geometry,f,h)}De(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),n=yield this.lead.draw(s,$(L({},o||{}),{create:c,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:l}))),this.isBloom&&n.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId&&d.keyName?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:n})))),n.isInstantiate=!0,n})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new pe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Te(r,e){return r.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const c=N.geoDistance(o,s)*180/Math.PI;if(c>e){const n=N.geoInterpolate(s,o),l=1/Math.ceil(c/e);let u=l;for(;u<1;)i.push(n(u)),u+=l}}i.push(s=o)}),i})}function Ee(r,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const o=Math.round(se(360/r,2)/Math.PI),c=(1+Math.sqrt(5))/2,n=h=>h/c*360%360-180,l=h=>Math.acos(2*h/o-1)/Math.PI*180-90,u=h=>o*(Math.cos((h+90)*Math.PI/180)+1)/2,v=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):o-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,p=[];for(let h=v[0];h<=v[1];h++){const m=n(h);d(m)&&p.push([m,l(h)])}return p}function J(r,e,t=!1){return t?N.geoContains(e,r):we(r,e)}function ke(r,e){const t={type:"Polygon",coordinates:r},[[i,s],[o,c]]=N.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(c-s))<e)return[];const n=i>o||c>=89||s<=-89;return Ee(e,{minLng:i,maxLng:o,minLat:s,maxLat:c}).filter(l=>J(l,t,n))}function Le(r,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Te(r,e),o=z.merge(s),c=ke(r,e),n=[...o,...c],l={type:"Polygon",coordinates:r},[[u,v],[d,p]]=N.geoBounds(l),h=u>d||p>=89||v<=-89;let m=[];if(h){const y=xe.geoVoronoi(n).triangles(),x=new Map(n.map(([P,I],E)=>[`${P}-${I}`,E]));y.features.forEach(P=>{const I=P.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(I.forEach(([B,F])=>{const _=`${B}-${F}`;x.has(_)&&E.push(x.get(_))}),E.length===3){if(E.some(B=>B<o.length)){const B=P.properties.circumcenter;if(!J(B,l,h))return}m.push(...E)}})}else if(c.length){const y=Me.from(n);for(let x=0,P=y.triangles.length;x<P;x+=3){const I=[2,1,0].map(B=>y.triangles[x+B]),E=I.map(B=>n[B]);if(I.some(B=>B<o.length)){const B=[0,1].map(F=>z.mean(E,_=>_[F]));if(!J(B,l,h))continue}m.push(...I)}}else{const{vertices:y,holes:x=[]}=Y.flatten(s);m=Y(y,x,2)}let f=t?[t[0],t[2]]:z.extent(n,y=>y[0]),b=t?[t[1],t[3]]:z.extent(n,y=>y[1]);if(i){const[y,x]=i([f[0],b[0]]),[P,I]=i([f[1],b[1]]);f=[y,P],b=[-x,-I]}const j=oe.scaleLinear(f,[0,1]),C=oe.scaleLinear(b,[0,1]),D=n.map(([y,x])=>{if(i){const[P,I]=i([y,x]);return[j(P),C(-I)]}else return[j(y),C(x)]});return{contour:s,triangles:{points:n,indices:m,uvs:D}}}const ce=new a.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(r,e,t,i){const s=r.map(o=>o.map(([c,n])=>{if(i){const[l,u]=i([c,n]);return[l,-u,e]}return t?Z.polar2Cartesian(c,n,e):[c,n,e]}));return Y.flatten(s)}function ze(r,e,t,i,s){const{vertices:o,holes:c}=q(r,e,i,s),{vertices:n}=q(r,t,i,s),l=z.merge([n,o]),u=Math.round(n.length/3),v=new Set(c);let d=0;const p=[];for(let m=0;m<u;m++){let f=m+1;if(f===u)f=d;else if(v.has(f)){const b=f;f=d,d=b}p.push(m,m+u,f+u),p.push(f+u,f,m)}const h=[];for(let m=1;m>=0;m--)for(let f=0;f<u;f+=1)h.push(f/(u-1),m);return{indices:p,vertices:l,uvs:h,topVerts:n}}function le(r,e,t,i,s,o){return{indices:i?r.indices:r.indices.slice().reverse(),vertices:q([r.points],e,s,o).vertices,uvs:t}}const me=({polygonGeoJson:r,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:c=!1,hasTop:n=!1,projection:l,bbox:u})=>{r.forEach(j=>{ge(j)||j.reverse()});const{contour:v,triangles:d}=Le(r,{resolution:i,bbox:u,projection:l});let p={},h;o&&(p=ze(v,e!=null?e:t,t!=null?t:e,s,l),h=p.topVerts);let m=[];(c||n)&&(m=z.merge(d.uvs));let f={};c&&(f=le(d,e,m,!1,s,l));let b={};return n&&(b=le(d,t,m,!0,s,l)),{contour:v,triangles:d,sideTorso:p,bottomCap:f,topCap:b,topVerts:h}};class Ne extends a.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=L({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:o,hasBottom:c,hasSide:n,cartesian:l,userDataRsoOffset:u,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:h,bottomCap:m,topCap:f}=me(L({},this.parameters));let b=[],j=[],C=[],D=0;const A=y=>{const x=Math.round(b.length/3),P=C.length;b=b.concat(y.vertices),j=j.concat(y.uvs),C=C.concat(x?y.indices.map(I=>I+x):y.indices),this.addGroup(P,C.length-P,D++)};s&&o&&A(f),n&&(A(p),this.userData.topVerts=u?q(d,i+u,l,v).vertices:h),c&&A(m),s&&!o&&A(f),this.setIndex(C),this[ce]("position",new a.Float32BufferAttribute(b,3)),this[ce]("uv",new a.Float32BufferAttribute(j,2)),this.computeVertexNormals()}}const _e=`
|
|
3
|
+
${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
+
`},new o.Points(t,s)},Oe=(n,e)=>{const t=new o.Object3D;e.forEach((i,s)=>{const a=Z.parseVector3(i.position),l=Z.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(l),t.updateMatrix();const r=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(s,r);else if(n instanceof o.Points||n.type==="Points"){const u=n.geometry,v=u.attributes.position.array,d=u.attributes.scaleAtt.array,p=new o.Vector3,h=new o.Vector3,m=new o.Quaternion,f=s*3,b=s*1;r.decompose(p,m,h),v[f]=p.x,v[f+1]=p.y,v[f+2]=p.z,d[b]=Math.max(h.x,h.y,h.z),u.attributes.position.needsUpdate=!0,u.attributes.scaleAtt.needsUpdate=!0}})};class De{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class Ve extends De{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const s=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=s,s}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class R extends Ve{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}lookAt(e){const t=e instanceof o.Vector3?e:new o.Vector3(...e);this.object3d.lookAt(t)}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(Ce),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Pe),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new je.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ae.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ae.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return ne(this,null,function*(){var u,v;const t=(u=e==null?void 0:e.recursive)!=null?u:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:s,objectOptions:a}=this;let l=e==null?void 0:e.create,r,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?r=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(l===void 0&&(l=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const h=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)d.object3d=Be(this.object3d,h);else{const m=this.object3d,f=i?this.cloneMaterial():m.material;d.object3d=new o.InstancedMesh(m.geometry,f,h)}Oe(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),r=yield this.lead.draw(s,$(L({},a||{}),{create:l,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId&&d.keyName?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:r})))),r.isInstantiate=!0,r})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new pe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Te(n,e){return n.map(t=>{const i=[];let s;return t.forEach(a=>{if(s){const l=N.geoDistance(a,s)*180/Math.PI;if(l>e){const r=N.geoInterpolate(s,a),c=1/Math.ceil(l/e);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=a)}),i})}function Ee(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const a=Math.round(se(360/n,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=h=>h/l*360%360-180,c=h=>Math.acos(2*h/a-1)/Math.PI*180-90,u=h=>a*(Math.cos((h+90)*Math.PI/180)+1)/2,v=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,p=[];for(let h=v[0];h<=v[1];h++){const m=r(h);d(m)&&p.push([m,c(h)])}return p}function H(n,e,t=!1){return t?N.geoContains(e,n):we(n,e)}function ze(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[a,l]]=N.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(l-s))<e)return[];const r=i>a||l>=89||s<=-89;return Ee(e,{minLng:i,maxLng:a,minLat:s,maxLat:l}).filter(c=>H(c,t,r))}function Le(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Te(n,e),a=k.merge(s),l=ze(n,e),r=[...a,...l],c={type:"Polygon",coordinates:n},[[u,v],[d,p]]=N.geoBounds(c),h=u>d||p>=89||v<=-89;let m=[];if(h){const g=xe.geoVoronoi(r).triangles(),S=new Map(r.map(([P,I],E)=>[`${P}-${I}`,E]));g.features.forEach(P=>{const I=P.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(I.forEach(([B,F])=>{const W=`${B}-${F}`;S.has(W)&&E.push(S.get(W))}),E.length===3){if(E.some(B=>B<a.length)){const B=P.properties.circumcenter;if(!H(B,c,h))return}m.push(...E)}})}else if(l.length){const g=Me.from(r);for(let S=0,P=g.triangles.length;S<P;S+=3){const I=[2,1,0].map(B=>g.triangles[S+B]),E=I.map(B=>r[B]);if(I.some(B=>B<a.length)){const B=[0,1].map(F=>k.mean(E,W=>W[F]));if(!H(B,c,h))continue}m.push(...I)}}else{const{vertices:g,holes:S=[]}=Y.flatten(s);m=Y(g,S,2)}let f=t?[t[0],t[2]]:k.extent(r,g=>g[0]),b=t?[t[1],t[3]]:k.extent(r,g=>g[1]);if(i){const[g,S]=i([f[0],b[0]]),[P,I]=i([f[1],b[1]]);f=[g,P],b=[-S,-I]}const j=oe.scaleLinear(f,[0,1]),C=oe.scaleLinear(b,[0,1]),O=r.map(([g,S])=>{if(i){const[P,I]=i([g,S]);return[j(P),C(-I)]}else return[j(g),C(S)]});return{contour:s,triangles:{points:r,indices:m,uvs:O}}}const ce=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(n,e,t,i){const s=n.map(a=>a.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,e]}return t?Z.polar2Cartesian(l,r,e):[l,r,e]}));return Y.flatten(s)}function ke(n,e,t,i,s){const{vertices:a,holes:l}=q(n,e,i,s),{vertices:r}=q(n,t,i,s),c=k.merge([r,a]),u=Math.round(r.length/3),v=new Set(l);let d=0;const p=[];for(let m=0;m<u;m++){let f=m+1;if(f===u)f=d;else if(v.has(f)){const b=f;f=d,d=b}p.push(m,m+u,f+u),p.push(f+u,f,m)}const h=[];for(let m=1;m>=0;m--)for(let f=0;f<u;f+=1)h.push(f/(u-1),m);return{indices:p,vertices:c,uvs:h,topVerts:r}}function le(n,e,t,i,s,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:q([n.points],e,s,a).vertices,uvs:t}}const me=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{n.forEach(j=>{ge(j)||j.reverse()});const{contour:v,triangles:d}=Le(n,{resolution:i,bbox:u,projection:c});let p={},h;a&&(p=ke(v,e!=null?e:t,t!=null?t:e,s,c),h=p.topVerts);let m=[];(l||r)&&(m=k.merge(d.uvs));let f={};l&&(f=le(d,e,m,!1,s,c));let b={};return r&&(b=le(d,t,m,!0,s,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:f,topCap:b,topVerts:h}};class Ne extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=L({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:a,hasBottom:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:h,bottomCap:m,topCap:f}=me(L({},this.parameters));let b=[],j=[],C=[],O=0;const A=g=>{const S=Math.round(b.length/3),P=C.length;b=b.concat(g.vertices),j=j.concat(g.uvs),C=C.concat(S?g.indices.map(I=>I+S):g.indices),this.addGroup(P,C.length-P,O++)};s&&a&&A(f),r&&(A(p),this.userData.topVerts=u?q(d,i+u,c,v).vertices:h),l&&A(m),s&&!a&&A(f),this.setIndex(C),this[ce]("position",new o.Float32BufferAttribute(b,3)),this[ce]("uv",new o.Float32BufferAttribute(j,2)),this.computeVertexNormals()}}const We=`
|
|
5
5
|
#include <fog_pars_fragment>
|
|
6
6
|
#include <logdepthbuf_pars_fragment>
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ void main() {
|
|
|
45
45
|
#include <tonemapping_fragment>
|
|
46
46
|
#include <colorspace_fragment>
|
|
47
47
|
}
|
|
48
|
-
`,
|
|
48
|
+
`,Ue=`
|
|
49
49
|
#include <common>
|
|
50
50
|
#include <logdepthbuf_pars_vertex>
|
|
51
51
|
#include <fog_pars_vertex>
|
|
@@ -137,4 +137,4 @@ void main() {
|
|
|
137
137
|
#include <logdepthbuf_vertex>
|
|
138
138
|
#include <fog_vertex>
|
|
139
139
|
}
|
|
140
|
-
`;class
|
|
140
|
+
`;class _e extends o.ShaderMaterial{constructor(e={}){const C=e,{lineWidth:t=1,color:i="#ffffff",opacity:s=1,map:a=null,dashOffset:l=0,dashArray:r=0,dashRatio:c=0,sizeAttenuation:u=!0,offsetLoop:v=!0,offset:d=new o.Vector2(0,0),scaleDown:p=0,alphaMap:h=void 0,alphaTest:m=0,repeat:f=new o.Vector2(1,1),resolution:b=new o.Vector2(1,1)}=C,j=re(C,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super($(L({},j),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(i)},opacity:{value:s},map:{value:a},useMap:{value:a?1:0},resolution:{value:b},sizeAttenuation:{value:u?1:0},offset:{value:d},offsetLoop:{value:v?1:0},dashArray:{value:r},dashOffset:{value:l},dashRatio:{value:c},useDash:{value:r>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:h},useAlphaMap:{value:h?1:0},repeat:{value:f}},vertexShader:Ue,fragmentShader:We})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const K=new o.Vector4,ue=new o.Vector3,de=new o.Vector3,M=new o.Vector4,w=new o.Vector4,D=new o.Vector4,Q=new o.Vector3,X=new o.Matrix4,x=new o.Line3,he=new o.Vector3,_=new o.Box3,G=new o.Sphere,V=new o.Vector4;let T,z;function fe(n,e,t){return V.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),V.multiplyScalar(1/V.w),V.x=z/t.width,V.y=z/t.height,V.applyMatrix4(n.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ge(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){x.start.fromBufferAttribute(s,r),x.end.fromBufferAttribute(a,r),x.applyMatrix4(t);const u=new o.Vector3,v=new o.Vector3;T.distanceSqToSegment(x.start,x.end,v,u),v.distanceTo(u)<z*.5&&e.push({point:v,pointOnLine:u,distance:T.origin.distanceTo(v),object:n,face:null,faceIndex:r,uv:null,uv1:null})}}function Re(n,e,t){const i=e.projectionMatrix,a=n.material.resolution,l=n.matrixWorld,r=n.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,v=Math.min(r.instanceCount,c.count),d=-e.near;T.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=a.x/2,D.y*=a.y/2,D.z=0,Q.copy(D),X.multiplyMatrices(e.matrixWorldInverse,l);for(let p=0,h=v;p<h;p++){if(M.fromBufferAttribute(c,p),w.fromBufferAttribute(u,p),M.w=1,w.w=1,M.applyMatrix4(X),w.applyMatrix4(X),M.z>d&&w.z>d)continue;if(M.z>d){const O=M.z-w.z,A=(M.z-d)/O;M.lerp(w,A)}else if(w.z>d){const O=w.z-M.z,A=(w.z-d)/O;w.lerp(M,A)}M.applyMatrix4(i),w.applyMatrix4(i),M.multiplyScalar(1/M.w),w.multiplyScalar(1/w.w),M.x*=a.x/2,M.y*=a.y/2,w.x*=a.x/2,w.y*=a.y/2,x.start.copy(M),x.start.z=0,x.end.copy(w),x.end.z=0;const f=x.closestPointToPointParameter(Q,!0);x.at(f,he);const b=o.MathUtils.lerp(M.z,w.z,f),j=b>=-1&&b<=1,C=Q.distanceTo(he)<z*.5;if(j&&C){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(u,p),x.start.applyMatrix4(l),x.end.applyMatrix4(l);const O=new o.Vector3,A=new o.Vector3;T.distanceSqToSegment(x.start,x.end,A,O),t.push({point:A,pointOnLine:O,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class qe extends o.Mesh{constructor(e=new Se.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let l=0,r=0,c=t.count;l<c;l++,r+=2)ue.fromBufferAttribute(t,l),de.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+ue.distanceTo(de);const a=new o.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;T=e.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;z=c.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),G.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=z*.5;else{const d=Math.max(s.near,G.distanceToPoint(T.origin));u=fe(s,d,c.resolution)}if(G.radius+=u,T.intersectsSphere(G)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),_.copy(r.boundingBox).applyMatrix4(l);let v;if(i)v=z*.5;else{const d=Math.max(s.near,_.distanceToPoint(T.origin));v=fe(s,d,c.resolution)}_.expandByScalar(v),T.intersectsBox(_)!==!1&&(i?Ge(this,t):Re(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(K),this.material.uniforms.resolution.value.set(K.z,K.w))}}const y=class y extends R{constructor(e){super(),this.objectType="Node",this.onNodePointerIndex=[],this.options=L({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,a=t.width,l=t.height;let r=0,c=0;a>i?t.left>0&&(r=-t.left):t.left<0?r=-t.left:t.right>i&&(r=i-t.right,t.left+r<0&&(r=-t.left)),l>s?t.top>0&&(c=-t.top):t.top<0?c=-t.top:t.bottom>s&&(c=s-t.bottom,t.top+c<0&&(c=-t.top)),(r!==0||c!==0)&&(e.style.transform=`translate(${r}px, ${c}px)`)}ensureVisible(){const e=this.options.children;e&&(e.style.transform&&(e.style.transform=""),!y.observerMap.has(e)&&(y.sharedObserver||(y.sharedObserver=new IntersectionObserver(t=>{t.forEach(i=>{const s=i.target,a=y.observerMap.get(s);a&&i.isIntersecting&&(a.moveElementToViewport(),y.observerMap.delete(s),y.sharedObserver&&(y.sharedObserver.unobserve(s),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)))})})),y.observerMap.set(e,this),y.sharedObserver.observe(e)))}onPointerEvent(e,t){const i=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){const e=this.options.children;e&&y.sharedObserver&&(y.observerMap.delete(e),y.sharedObserver.unobserve(e),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)),this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}};y.observerMap=new Map;let J=y;exports.BLOOM_SCENE=Ae;exports.BaseObject=R;exports.IS_DEV=Ie;exports.LineSegments2=qe;exports.MeshLineMaterial=_e;exports.Node=J;exports.PolygonGeometry=Ne;exports.ResourceTracker=pe;exports.getMetas=me;
|