gl-draw 0.15.0 → 0.15.2
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/core/BaseObject.d.ts +2 -1
- package/dist/core/MList/MList.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.module.js +42 -26
- package/dist/index.module2.js +72 -66
- package/dist/index2.js +4 -4
- package/dist/objects/extrudePolygon/createGeometry.d.ts +5 -1
- package/dist/objects/pie/index.d.ts +5 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +13 -13
- package/package.json +1 -1
package/dist/index.module2.js
CHANGED
|
@@ -9,7 +9,7 @@ var et = Math.pow, tt = (a, t, e) => t in a ? jt(a, t, { enumerable: !0, configu
|
|
|
9
9
|
for (var e of J(t))
|
|
10
10
|
zt.call(t, e) && tt(a, e, t[e]);
|
|
11
11
|
return a;
|
|
12
|
-
},
|
|
12
|
+
}, Z = (a, t) => At(a, St(t));
|
|
13
13
|
var it = (a, t, e) => new Promise((i, s) => {
|
|
14
14
|
var r = (o) => {
|
|
15
15
|
try {
|
|
@@ -26,14 +26,14 @@ var it = (a, t, e) => new Promise((i, s) => {
|
|
|
26
26
|
}, n = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(r, l);
|
|
27
27
|
n((e = e.apply(a, t)).next());
|
|
28
28
|
});
|
|
29
|
-
import { BufferGeometry as Y, Float32BufferAttribute as G, PointsMaterial as It, Points as
|
|
29
|
+
import { BufferGeometry as Y, Float32BufferAttribute as G, PointsMaterial as It, Points as Q, Mesh as Mt, Group as Bt, Sprite as st, Box3 as xt, Vector3 as C, InstancedMesh as nt, Quaternion as Lt, Object3D as R, Material as rt, Texture as at, VideoTexture as Dt, Vector4 as O, Matrix4 as Tt, Line3 as _t, Sphere as Wt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as ot, MathUtils as Vt, ShaderMaterial as kt, UniformsLib as Ut, Color as lt, Vector2 as k, REVISION as Et } from "three";
|
|
30
30
|
import { CSS2DObject as Rt } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
31
31
|
import { CSS3DObject as Gt, CSS3DSprite as Ft } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
32
|
-
import { geoBounds as wt, geoContains as
|
|
32
|
+
import { geoBounds as wt, geoContains as Nt, geoDistance as Zt, geoInterpolate as $t } from "d3-geo";
|
|
33
33
|
import "d3-geo-projection";
|
|
34
34
|
import { p as ct, a as qt } from "./parseVector.module.js";
|
|
35
|
-
import { LineSegmentsGeometry as
|
|
36
|
-
import { merge as H, mean as
|
|
35
|
+
import { LineSegmentsGeometry as Kt } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
36
|
+
import { merge as H, mean as Qt, extent as ut } from "d3-array";
|
|
37
37
|
import Xt, { flatten as Pt } from "earcut";
|
|
38
38
|
import Yt from "@turf/boolean-clockwise";
|
|
39
39
|
import Ht from "delaunator";
|
|
@@ -70,7 +70,7 @@ const ee = (a, t = 1) => {
|
|
|
70
70
|
"gl_PointSize = size * scaleAtt;"
|
|
71
71
|
)}
|
|
72
72
|
`;
|
|
73
|
-
}, new
|
|
73
|
+
}, new Q(e, s);
|
|
74
74
|
};
|
|
75
75
|
class ft {
|
|
76
76
|
constructor() {
|
|
@@ -129,13 +129,13 @@ class ft {
|
|
|
129
129
|
return this.object3d.visible = !1, this;
|
|
130
130
|
}
|
|
131
131
|
createMesh(...t) {
|
|
132
|
-
return this.object3d = new
|
|
132
|
+
return this.object3d = new Mt(...t), this;
|
|
133
133
|
}
|
|
134
134
|
createGroup() {
|
|
135
|
-
return this.object3d = new
|
|
135
|
+
return this.object3d = new Bt(), this;
|
|
136
136
|
}
|
|
137
137
|
createPoints(...t) {
|
|
138
|
-
return this.object3d = new
|
|
138
|
+
return this.object3d = new Q(...t), this;
|
|
139
139
|
}
|
|
140
140
|
createCSS2DObject(t) {
|
|
141
141
|
return this.object3d = new Rt(t), this;
|
|
@@ -155,7 +155,7 @@ class ft {
|
|
|
155
155
|
}), this;
|
|
156
156
|
}
|
|
157
157
|
getSize() {
|
|
158
|
-
const t = new
|
|
158
|
+
const t = new xt().setFromObject(this.object3d);
|
|
159
159
|
return {
|
|
160
160
|
min: t.min,
|
|
161
161
|
max: t.max,
|
|
@@ -196,7 +196,7 @@ class ft {
|
|
|
196
196
|
u.object3d.userData.prefab && delete u.object3d.userData.prefab;
|
|
197
197
|
}
|
|
198
198
|
});
|
|
199
|
-
const c = yield this.lead.draw(n,
|
|
199
|
+
const c = yield this.lead.draw(n, Z(W({}, l || {}), {
|
|
200
200
|
create: o,
|
|
201
201
|
prefab: !1,
|
|
202
202
|
key: (e == null ? void 0 : e.key) || (l == null ? void 0 : l.key),
|
|
@@ -214,8 +214,8 @@ class ft {
|
|
|
214
214
|
setInstancedMatrix(t, e) {
|
|
215
215
|
if (this.object3d instanceof nt || this.object3d.isInstantiate)
|
|
216
216
|
this.object3d.setMatrixAt(t, e);
|
|
217
|
-
else if (this.object3d instanceof
|
|
218
|
-
const s = this.object3d.geometry, r = s.attributes.position.array, l = s.attributes.scaleAtt.array, n = new C(), o = new C(), c = new
|
|
217
|
+
else if (this.object3d instanceof Q || this.object3d.type === "Points") {
|
|
218
|
+
const s = this.object3d.geometry, r = s.attributes.position.array, l = s.attributes.scaleAtt.array, n = new C(), o = new C(), c = new Lt(), p = t * 3, u = t * 1;
|
|
219
219
|
e.decompose(n, c, o), r[p] = n.x, r[p + 1] = n.y, r[p + 2] = n.z, l[u] = Math.max(o.x, o.y, o.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -254,7 +254,7 @@ class ft {
|
|
|
254
254
|
const e = this.object3d;
|
|
255
255
|
!e || !e.material || this.useMaterialType === t || !this.materialList[t] || (this.useMaterialType = t, e.material = this.materialList[t]);
|
|
256
256
|
}
|
|
257
|
-
|
|
257
|
+
useMListById(t, e) {
|
|
258
258
|
if (!this.mList)
|
|
259
259
|
return;
|
|
260
260
|
const i = this.mList.get(t);
|
|
@@ -263,6 +263,12 @@ class ft {
|
|
|
263
263
|
const s = this.object3d;
|
|
264
264
|
Array.isArray(s.material) && e !== void 0 ? s.material[e] = i : s.material = i;
|
|
265
265
|
}
|
|
266
|
+
useMListByName(t, e) {
|
|
267
|
+
if (!this.mList)
|
|
268
|
+
return;
|
|
269
|
+
const i = this.mList.getKeyByName(t);
|
|
270
|
+
i && this.useMListById(i, e);
|
|
271
|
+
}
|
|
266
272
|
setTop(t) {
|
|
267
273
|
this.object3d && (this.object3d.renderOrder = t);
|
|
268
274
|
}
|
|
@@ -321,7 +327,7 @@ class ie {
|
|
|
321
327
|
(s instanceof at || Array.isArray(s)) && this.track(s);
|
|
322
328
|
}
|
|
323
329
|
}
|
|
324
|
-
} else this.disposeVideo && t instanceof
|
|
330
|
+
} else this.disposeVideo && t instanceof Dt && t.source.data && this.resources.add(t.source.data);
|
|
325
331
|
return t;
|
|
326
332
|
}
|
|
327
333
|
dispose() {
|
|
@@ -333,20 +339,20 @@ class ie {
|
|
|
333
339
|
}), t.length = 0, this.resources.clear();
|
|
334
340
|
}
|
|
335
341
|
}
|
|
336
|
-
const $ = new O(), dt = new C(), pt = new C(), b = new O(), y = new O(),
|
|
337
|
-
let
|
|
342
|
+
const $ = new O(), dt = new C(), pt = new C(), b = new O(), y = new O(), B = new O(), q = new C(), K = new Tt(), M = new _t(), mt = new C(), U = new xt(), E = new Wt(), L = new O();
|
|
343
|
+
let D, _;
|
|
338
344
|
function vt(a, t, e) {
|
|
339
|
-
return
|
|
345
|
+
return L.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), L.multiplyScalar(1 / L.w), L.x = _ / e.width, L.y = _ / e.height, L.applyMatrix4(a.projectionMatrixInverse), L.multiplyScalar(1 / L.w), Math.abs(Math.max(L.x, L.y));
|
|
340
346
|
}
|
|
341
347
|
function se(a, t) {
|
|
342
348
|
const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, r = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
|
|
343
349
|
for (let n = 0, o = l; n < o; n++) {
|
|
344
|
-
|
|
350
|
+
M.start.fromBufferAttribute(s, n), M.end.fromBufferAttribute(r, n), M.applyMatrix4(e);
|
|
345
351
|
const c = new C(), p = new C();
|
|
346
|
-
|
|
352
|
+
D.distanceSqToSegment(M.start, M.end, p, c), p.distanceTo(c) < _ * 0.5 && t.push({
|
|
347
353
|
point: p,
|
|
348
354
|
pointOnLine: c,
|
|
349
|
-
distance:
|
|
355
|
+
distance: D.origin.distanceTo(p),
|
|
350
356
|
object: a,
|
|
351
357
|
face: null,
|
|
352
358
|
faceIndex: n,
|
|
@@ -357,9 +363,9 @@ function se(a, t) {
|
|
|
357
363
|
}
|
|
358
364
|
function ne(a, t, e) {
|
|
359
365
|
const i = t.projectionMatrix, r = a.material.resolution, l = a.matrixWorld, n = a.geometry, o = n.attributes.instanceStart, c = n.attributes.instanceEnd, p = Math.min(n.instanceCount, o.count), u = -t.near;
|
|
360
|
-
|
|
366
|
+
D.at(1, B), B.w = 1, B.applyMatrix4(t.matrixWorldInverse), B.applyMatrix4(i), B.multiplyScalar(1 / B.w), B.x *= r.x / 2, B.y *= r.y / 2, B.z = 0, q.copy(B), K.multiplyMatrices(t.matrixWorldInverse, l);
|
|
361
367
|
for (let m = 0, h = p; m < h; m++) {
|
|
362
|
-
if (b.fromBufferAttribute(o, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(
|
|
368
|
+
if (b.fromBufferAttribute(o, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(K), y.applyMatrix4(K), b.z > u && y.z > u)
|
|
363
369
|
continue;
|
|
364
370
|
if (b.z > u) {
|
|
365
371
|
const I = b.z - y.z, P = (b.z - u) / I;
|
|
@@ -368,17 +374,17 @@ function ne(a, t, e) {
|
|
|
368
374
|
const I = y.z - b.z, P = (y.z - u) / I;
|
|
369
375
|
y.lerp(b, P);
|
|
370
376
|
}
|
|
371
|
-
b.applyMatrix4(i), y.applyMatrix4(i), b.multiplyScalar(1 / b.w), y.multiplyScalar(1 / y.w), b.x *= r.x / 2, b.y *= r.y / 2, y.x *= r.x / 2, y.y *= r.y / 2,
|
|
372
|
-
const d =
|
|
373
|
-
|
|
374
|
-
const g = Vt.lerp(b.z, y.z, d), w = g >= -1 && g <= 1, z = q.distanceTo(mt) <
|
|
377
|
+
b.applyMatrix4(i), y.applyMatrix4(i), b.multiplyScalar(1 / b.w), y.multiplyScalar(1 / y.w), b.x *= r.x / 2, b.y *= r.y / 2, y.x *= r.x / 2, y.y *= r.y / 2, M.start.copy(b), M.start.z = 0, M.end.copy(y), M.end.z = 0;
|
|
378
|
+
const d = M.closestPointToPointParameter(q, !0);
|
|
379
|
+
M.at(d, mt);
|
|
380
|
+
const g = Vt.lerp(b.z, y.z, d), w = g >= -1 && g <= 1, z = q.distanceTo(mt) < _ * 0.5;
|
|
375
381
|
if (w && z) {
|
|
376
|
-
|
|
382
|
+
M.start.fromBufferAttribute(o, m), M.end.fromBufferAttribute(c, m), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
|
|
377
383
|
const I = new C(), P = new C();
|
|
378
|
-
|
|
384
|
+
D.distanceSqToSegment(M.start, M.end, P, I), e.push({
|
|
379
385
|
point: P,
|
|
380
386
|
pointOnLine: I,
|
|
381
|
-
distance:
|
|
387
|
+
distance: D.origin.distanceTo(P),
|
|
382
388
|
object: a,
|
|
383
389
|
face: null,
|
|
384
390
|
faceIndex: m,
|
|
@@ -388,8 +394,8 @@ function ne(a, t, e) {
|
|
|
388
394
|
}
|
|
389
395
|
}
|
|
390
396
|
}
|
|
391
|
-
class ze extends
|
|
392
|
-
constructor(t = new
|
|
397
|
+
class ze extends Mt {
|
|
398
|
+
constructor(t = new Kt(), e) {
|
|
393
399
|
super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
|
|
394
400
|
}
|
|
395
401
|
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
@@ -416,16 +422,16 @@ class ze extends xt {
|
|
|
416
422
|
'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
|
|
417
423
|
);
|
|
418
424
|
const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
|
|
419
|
-
|
|
425
|
+
D = t.ray;
|
|
420
426
|
const l = this.matrixWorld, n = this.geometry, o = this.material;
|
|
421
|
-
|
|
427
|
+
_ = o.linewidth + r, n.boundingSphere === null && n.computeBoundingSphere(), E.copy(n.boundingSphere).applyMatrix4(l);
|
|
422
428
|
let c;
|
|
423
429
|
if (i)
|
|
424
|
-
c =
|
|
430
|
+
c = _ * 0.5;
|
|
425
431
|
else {
|
|
426
432
|
const u = Math.max(
|
|
427
433
|
s.near,
|
|
428
|
-
E.distanceToPoint(
|
|
434
|
+
E.distanceToPoint(D.origin)
|
|
429
435
|
);
|
|
430
436
|
c = vt(
|
|
431
437
|
s,
|
|
@@ -433,16 +439,16 @@ class ze extends xt {
|
|
|
433
439
|
o.resolution
|
|
434
440
|
);
|
|
435
441
|
}
|
|
436
|
-
if (E.radius += c,
|
|
442
|
+
if (E.radius += c, D.intersectsSphere(E) === !1)
|
|
437
443
|
return;
|
|
438
444
|
n.boundingBox === null && n.computeBoundingBox(), U.copy(n.boundingBox).applyMatrix4(l);
|
|
439
445
|
let p;
|
|
440
446
|
if (i)
|
|
441
|
-
p =
|
|
447
|
+
p = _ * 0.5;
|
|
442
448
|
else {
|
|
443
449
|
const u = Math.max(
|
|
444
450
|
s.near,
|
|
445
|
-
U.distanceToPoint(
|
|
451
|
+
U.distanceToPoint(D.origin)
|
|
446
452
|
);
|
|
447
453
|
p = vt(
|
|
448
454
|
s,
|
|
@@ -450,7 +456,7 @@ class ze extends xt {
|
|
|
450
456
|
o.resolution
|
|
451
457
|
);
|
|
452
458
|
}
|
|
453
|
-
U.expandByScalar(p),
|
|
459
|
+
U.expandByScalar(p), D.intersectsBox(U) !== !1 && (i ? se(this, e) : ne(this, s, e));
|
|
454
460
|
}
|
|
455
461
|
onBeforeRender(t) {
|
|
456
462
|
const e = this.material.uniforms;
|
|
@@ -612,7 +618,7 @@ const gt = ["encodings_fragment", "colorspace_fragment"], re = (
|
|
|
612
618
|
class Ie extends kt {
|
|
613
619
|
constructor(t) {
|
|
614
620
|
super({
|
|
615
|
-
uniforms:
|
|
621
|
+
uniforms: Z(W({}, Ut.fog), {
|
|
616
622
|
lineWidth: { value: 1 },
|
|
617
623
|
map: { value: null },
|
|
618
624
|
useMap: { value: 0 },
|
|
@@ -871,7 +877,7 @@ function oe(a, t) {
|
|
|
871
877
|
let s;
|
|
872
878
|
return e.forEach((r) => {
|
|
873
879
|
if (s) {
|
|
874
|
-
const l =
|
|
880
|
+
const l = Zt(r, s) * 180 / Math.PI;
|
|
875
881
|
if (l > t) {
|
|
876
882
|
const n = $t(s, r), o = 1 / Math.ceil(l / t);
|
|
877
883
|
let c = o;
|
|
@@ -895,7 +901,7 @@ function le(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
|
895
901
|
return m;
|
|
896
902
|
}
|
|
897
903
|
function X(a, t, e = !1) {
|
|
898
|
-
return e ?
|
|
904
|
+
return e ? Nt(t, a) : Jt(a, t);
|
|
899
905
|
}
|
|
900
906
|
function ce(a, t) {
|
|
901
907
|
const e = { type: "Polygon", coordinates: a }, [[i, s], [r, l]] = wt(e);
|
|
@@ -917,16 +923,16 @@ function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
917
923
|
p <= -89;
|
|
918
924
|
let f = [];
|
|
919
925
|
if (h) {
|
|
920
|
-
const v = te(n).triangles(),
|
|
921
|
-
n.map(([j, A],
|
|
926
|
+
const v = te(n).triangles(), x = new Map(
|
|
927
|
+
n.map(([j, A], T) => [`${j}-${A}`, T])
|
|
922
928
|
);
|
|
923
929
|
v.features.forEach((j) => {
|
|
924
|
-
const A = j.geometry.coordinates[0].slice(0, 3).reverse(),
|
|
925
|
-
if (A.forEach(([S,
|
|
926
|
-
const V = `${S}-${
|
|
927
|
-
|
|
928
|
-
}),
|
|
929
|
-
if (
|
|
930
|
+
const A = j.geometry.coordinates[0].slice(0, 3).reverse(), T = [];
|
|
931
|
+
if (A.forEach(([S, N]) => {
|
|
932
|
+
const V = `${S}-${N}`;
|
|
933
|
+
x.has(V) && T.push(x.get(V));
|
|
934
|
+
}), T.length === 3) {
|
|
935
|
+
if (T.some((S) => S < r.length)) {
|
|
930
936
|
const S = j.properties.circumcenter;
|
|
931
937
|
if (!X(
|
|
932
938
|
S,
|
|
@@ -935,16 +941,16 @@ function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
935
941
|
))
|
|
936
942
|
return;
|
|
937
943
|
}
|
|
938
|
-
f.push(...
|
|
944
|
+
f.push(...T);
|
|
939
945
|
}
|
|
940
946
|
});
|
|
941
947
|
} else if (l.length) {
|
|
942
948
|
const v = Ht.from(n);
|
|
943
|
-
for (let
|
|
944
|
-
const A = [2, 1, 0].map((S) => v.triangles[
|
|
949
|
+
for (let x = 0, j = v.triangles.length; x < j; x += 3) {
|
|
950
|
+
const A = [2, 1, 0].map((S) => v.triangles[x + S]), T = A.map((S) => n[S]);
|
|
945
951
|
if (A.some((S) => S < r.length)) {
|
|
946
952
|
const S = [0, 1].map(
|
|
947
|
-
(
|
|
953
|
+
(N) => Qt(T, (V) => V[N])
|
|
948
954
|
);
|
|
949
955
|
if (!X(
|
|
950
956
|
S,
|
|
@@ -956,20 +962,20 @@ function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
956
962
|
f.push(...A);
|
|
957
963
|
}
|
|
958
964
|
} else {
|
|
959
|
-
const { vertices: v, holes:
|
|
960
|
-
f = Xt(v,
|
|
965
|
+
const { vertices: v, holes: x = [] } = Pt(s);
|
|
966
|
+
f = Xt(v, x, 2);
|
|
961
967
|
}
|
|
962
968
|
let d = e ? [e[0], e[2]] : ut(n, (v) => v[0]), g = e ? [e[1], e[3]] : ut(n, (v) => v[1]);
|
|
963
969
|
if (i) {
|
|
964
|
-
const [v,
|
|
965
|
-
d = [v, j], g = [-
|
|
970
|
+
const [v, x] = i([d[0], g[0]]), [j, A] = i([d[1], g[1]]);
|
|
971
|
+
d = [v, j], g = [-x, -A];
|
|
966
972
|
}
|
|
967
|
-
const w = ht(d, [0, 1]), z = ht(g, [0, 1]), I = n.map(([v,
|
|
973
|
+
const w = ht(d, [0, 1]), z = ht(g, [0, 1]), I = n.map(([v, x]) => {
|
|
968
974
|
if (i) {
|
|
969
|
-
const [j, A] = i([v,
|
|
975
|
+
const [j, A] = i([v, x]);
|
|
970
976
|
return [w(j), z(-A)];
|
|
971
977
|
} else
|
|
972
|
-
return [w(v), z(
|
|
978
|
+
return [w(v), z(x)];
|
|
973
979
|
});
|
|
974
980
|
return { contour: s, triangles: { points: n, indices: f, uvs: I } };
|
|
975
981
|
}
|
|
@@ -1076,7 +1082,7 @@ const fe = ({
|
|
|
1076
1082
|
o
|
|
1077
1083
|
)), { contour: p, triangles: u, sideTorso: m, bottomCap: d, topCap: g, topVerts: h };
|
|
1078
1084
|
};
|
|
1079
|
-
class
|
|
1085
|
+
class Be extends Y {
|
|
1080
1086
|
constructor(t, e = {}) {
|
|
1081
1087
|
super(), this.type = "PolygonBufferGeometry", this.parameters = W({
|
|
1082
1088
|
polygonGeoJson: t,
|
|
@@ -1102,9 +1108,9 @@ class De extends Y {
|
|
|
1102
1108
|
} = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: d } = fe(W({}, this.parameters));
|
|
1103
1109
|
let g = [], w = [], z = [], I = 0;
|
|
1104
1110
|
const P = (v) => {
|
|
1105
|
-
const
|
|
1111
|
+
const x = Math.round(g.length / 3), j = z.length;
|
|
1106
1112
|
g = g.concat(v.vertices), w = w.concat(v.uvs), z = z.concat(
|
|
1107
|
-
|
|
1113
|
+
x ? v.indices.map((A) => A + x) : v.indices
|
|
1108
1114
|
), this.addGroup(j, z.length - j, I++);
|
|
1109
1115
|
};
|
|
1110
1116
|
s && r && P(d), n && (P(m), this.userData.topVerts = c ? F(
|
|
@@ -1119,7 +1125,7 @@ export {
|
|
|
1119
1125
|
ft as B,
|
|
1120
1126
|
ze as L,
|
|
1121
1127
|
Ie as M,
|
|
1122
|
-
|
|
1128
|
+
Be as P,
|
|
1123
1129
|
ie as R,
|
|
1124
1130
|
fe as g
|
|
1125
1131
|
};
|
package/dist/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var fe=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var J=Math.pow,H=(a,e,t)=>e in a?fe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,W=(a,e)=>{for(var t in e||(e={}))me.call(e,t)&&H(a,t,e[t]);if(Y)for(var t of Y(e))ve.call(e,t)&&H(a,t,e[t]);return a},q=(a,e)=>de(a,pe(e));var ee=(a,e,t)=>new Promise((i,s)=>{var o=l=>{try{n(t.next(l))}catch(u){s(u)}},c=l=>{try{n(t.throw(l))}catch(u){s(u)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,c);n((t=t.apply(a,e)).next())});const r=require("three"),ge=require("three/examples/jsm/renderers/CSS2DRenderer"),te=require("three/examples/jsm/renderers/CSS3DRenderer"),O=require("d3-geo");require("d3-geo-projection");const $=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),_=require("d3-array"),
|
|
1
|
+
"use strict";var fe=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var J=Math.pow,H=(a,e,t)=>e in a?fe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,W=(a,e)=>{for(var t in e||(e={}))me.call(e,t)&&H(a,t,e[t]);if(Y)for(var t of Y(e))ve.call(e,t)&&H(a,t,e[t]);return a},q=(a,e)=>de(a,pe(e));var ee=(a,e,t)=>new Promise((i,s)=>{var o=l=>{try{n(t.next(l))}catch(u){s(u)}},c=l=>{try{n(t.throw(l))}catch(u){s(u)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,c);n((t=t.apply(a,e)).next())});const r=require("three"),ge=require("three/examples/jsm/renderers/CSS2DRenderer"),te=require("three/examples/jsm/renderers/CSS3DRenderer"),O=require("d3-geo");require("d3-geo-projection");const $=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),_=require("d3-array"),K=require("earcut"),ye=require("@turf/boolean-clockwise"),Me=require("delaunator"),xe=require("@turf/boolean-point-in-polygon"),we=require("d3-geo-voronoi"),ie=require("d3-scale"),Pe=(a,e=1)=>{const t=new r.BufferGeometry;t.setAttribute("position",new r.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new r.Float32BufferAttribute(new Array(e).fill(1),1));const i=a.material,s=new r.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 r.Points(t,s)};class K{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[],this.disposeTrack=!0,this.disposeMaterialIfNotUsed=!0}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}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 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}hide(){return this.object3d.visible=!1,this}createMesh(...e){return this.object3d=new r.Mesh(...e),this}createGroup(){return this.object3d=new r.Group,this}createPoints(...e){return this.object3d=new r.Points(...e),this}createCSS2DObject(e){return this.object3d=new ge.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new te.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new te.CSS3DSprite(e),this}createSprite(e){return this.object3d=new r.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new r.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new r.Vector3),center:e.getCenter(new r.Vector3)}}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}clone(){return this.instantiate()}instantiate(e,t){return ee(this,null,function*(){var m;const i=e&&e.length>0,s=(m=t==null?void 0:t.recursive)!=null?m:!0,{objectType:o,objectOptions:c}=this,[,n]=o.split("#");let l=t==null?void 0:t.create;l===void 0&&(l=h=>{if(this.object3d){if(i){const v=e.length;if(this.object3d instanceof r.Sprite)h.object3d=Pe(this.object3d,v);else{const d=this.object3d,p=this.cloneMaterial();h.object3d=new r.InstancedMesh(d.geometry,p,v)}const f=new r.Object3D;e.forEach((d,p)=>{const b=$.parseVector3(d.position),P=$.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(p,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(n,q(W({},c||{}),{create:l,prefab:!1,key:(t==null?void 0:t.key)||(c==null?void 0:c.key),target:(t==null?void 0:t.target)||(c==null?void 0:c.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(e,t){if(this.object3d instanceof r.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(e,t);else if(this.object3d instanceof r.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,o=s.attributes.position.array,c=s.attributes.scaleAtt.array,n=new r.Vector3,l=new r.Vector3,u=new r.Quaternion,m=e*3,h=e*1;t.decompose(n,u,l),o[m]=n.x,o[m+1]=n.y,o[m+2]=n.z,c[h]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}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,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e]&&!i)return this.materialList[e];const o=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=o,o}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMList(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}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}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(this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.pencil.options.mList&&this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new ue;t.disposeMaterial=!this.pencil.options.mList,t.track(this),t.dispose()}}}class ue{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 r.Material)return e;if(e instanceof K?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof r.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof K)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof r.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof r.Material){for(const i of Object.values(e))i instanceof r.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 r.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e instanceof r.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof r.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 F=new r.Vector4,se=new r.Vector3,re=new r.Vector3,y=new r.Vector4,M=new r.Vector4,D=new r.Vector4,Z=new r.Vector3,N=new r.Matrix4,x=new r.Line3,ne=new r.Vector3,R=new r.Box3,U=new r.Sphere,z=new r.Vector4;let I,L;function oe(a,e,t){return z.set(0,0,-e,1).applyMatrix4(a.projectionMatrix),z.multiplyScalar(1/z.w),z.x=L/t.width,z.y=L/t.height,z.applyMatrix4(a.projectionMatrixInverse),z.multiplyScalar(1/z.w),Math.abs(Math.max(z.x,z.y))}function je(a,e){const t=a.matrixWorld,i=a.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let n=0,l=c;n<l;n++){x.start.fromBufferAttribute(s,n),x.end.fromBufferAttribute(o,n),x.applyMatrix4(t);const u=new r.Vector3,m=new r.Vector3;I.distanceSqToSegment(x.start,x.end,m,u),m.distanceTo(u)<L*.5&&e.push({point:m,pointOnLine:u,distance:I.origin.distanceTo(m),object:a,face:null,faceIndex:n,uv:null,uv1:null})}}function Ae(a,e,t){const i=e.projectionMatrix,o=a.material.resolution,c=a.matrixWorld,n=a.geometry,l=n.attributes.instanceStart,u=n.attributes.instanceEnd,m=Math.min(n.instanceCount,l.count),h=-e.near;I.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=o.x/2,D.y*=o.y/2,D.z=0,Z.copy(D),N.multiplyMatrices(e.matrixWorldInverse,c);for(let v=0,f=m;v<f;v++){if(y.fromBufferAttribute(l,v),M.fromBufferAttribute(u,v),y.w=1,M.w=1,y.applyMatrix4(N),M.applyMatrix4(N),y.z>h&&M.z>h)continue;if(y.z>h){const B=y.z-M.z,j=(y.z-h)/B;y.lerp(M,j)}else if(M.z>h){const B=M.z-y.z,j=(M.z-h)/B;M.lerp(y,j)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=o.x/2,y.y*=o.y/2,M.x*=o.x/2,M.y*=o.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const p=x.closestPointToPointParameter(Z,!0);x.at(p,ne);const b=r.MathUtils.lerp(y.z,M.z,p),P=b>=-1&&b<=1,V=Z.distanceTo(ne)<L*.5;if(P&&V){x.start.fromBufferAttribute(l,v),x.end.fromBufferAttribute(u,v),x.start.applyMatrix4(c),x.end.applyMatrix4(c);const B=new r.Vector3,j=new r.Vector3;I.distanceSqToSegment(x.start,x.end,j,B),t.push({point:j,pointOnLine:B,distance:I.origin.distanceTo(j),object:a,face:null,faceIndex:v,uv:null,uv1:null})}}}class Se extends r.Mesh{constructor(e=new be.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 c=0,n=0,l=t.count;c<l;c++,n+=2)se.fromBufferAttribute(t,c),re.fromBufferAttribute(i,c),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+se.distanceTo(re);const o=new r.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(o,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;I=e.ray;const c=this.matrixWorld,n=this.geometry,l=this.material;L=l.linewidth+o,n.boundingSphere===null&&n.computeBoundingSphere(),U.copy(n.boundingSphere).applyMatrix4(c);let u;if(i)u=L*.5;else{const h=Math.max(s.near,U.distanceToPoint(I.origin));u=oe(s,h,l.resolution)}if(U.radius+=u,I.intersectsSphere(U)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),R.copy(n.boundingBox).applyMatrix4(c);let m;if(i)m=L*.5;else{const h=Math.max(s.near,R.distanceToPoint(I.origin));m=oe(s,h,l.resolution)}R.expandByScalar(m),I.intersectsBox(R)!==!1&&(i?je(this,t):Ae(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}const ae=["encodings_fragment","colorspace_fragment"],Ce=`
|
|
4
|
+
`},new r.Points(t,s)};class Q{constructor(){this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[],this.disposeTrack=!0,this.disposeMaterialIfNotUsed=!0}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}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 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}hide(){return this.object3d.visible=!1,this}createMesh(...e){return this.object3d=new r.Mesh(...e),this}createGroup(){return this.object3d=new r.Group,this}createPoints(...e){return this.object3d=new r.Points(...e),this}createCSS2DObject(e){return this.object3d=new ge.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new te.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new te.CSS3DSprite(e),this}createSprite(e){return this.object3d=new r.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new r.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new r.Vector3),center:e.getCenter(new r.Vector3)}}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}clone(){return this.instantiate()}instantiate(e,t){return ee(this,null,function*(){var m;const i=e&&e.length>0,s=(m=t==null?void 0:t.recursive)!=null?m:!0,{objectType:o,objectOptions:c}=this,[,n]=o.split("#");let l=t==null?void 0:t.create;l===void 0&&(l=h=>{if(this.object3d){if(i){const v=e.length;if(this.object3d instanceof r.Sprite)h.object3d=Pe(this.object3d,v);else{const d=this.object3d,p=this.cloneMaterial();h.object3d=new r.InstancedMesh(d.geometry,p,v)}const f=new r.Object3D;e.forEach((d,p)=>{const b=$.parseVector3(d.position),P=$.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(p,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(n,q(W({},c||{}),{create:l,prefab:!1,key:(t==null?void 0:t.key)||(c==null?void 0:c.key),target:(t==null?void 0:t.target)||(c==null?void 0:c.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(e,t){if(this.object3d instanceof r.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(e,t);else if(this.object3d instanceof r.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,o=s.attributes.position.array,c=s.attributes.scaleAtt.array,n=new r.Vector3,l=new r.Vector3,u=new r.Quaternion,m=e*3,h=e*1;t.decompose(n,u,l),o[m]=n.x,o[m+1]=n.y,o[m+2]=n.z,c[h]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}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,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e]&&!i)return this.materialList[e];const o=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=o,o}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)}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}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(this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.pencil.options.mList&&this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new ue;t.disposeMaterial=!this.pencil.options.mList,t.track(this),t.dispose()}}}class ue{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 r.Material)return e;if(e instanceof Q?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof r.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Q)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof r.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof r.Material){for(const i of Object.values(e))i instanceof r.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 r.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e instanceof r.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof r.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 F=new r.Vector4,se=new r.Vector3,re=new r.Vector3,y=new r.Vector4,M=new r.Vector4,D=new r.Vector4,N=new r.Vector3,Z=new r.Matrix4,x=new r.Line3,ne=new r.Vector3,R=new r.Box3,U=new r.Sphere,I=new r.Vector4;let z,T;function oe(a,e,t){return I.set(0,0,-e,1).applyMatrix4(a.projectionMatrix),I.multiplyScalar(1/I.w),I.x=T/t.width,I.y=T/t.height,I.applyMatrix4(a.projectionMatrixInverse),I.multiplyScalar(1/I.w),Math.abs(Math.max(I.x,I.y))}function je(a,e){const t=a.matrixWorld,i=a.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let n=0,l=c;n<l;n++){x.start.fromBufferAttribute(s,n),x.end.fromBufferAttribute(o,n),x.applyMatrix4(t);const u=new r.Vector3,m=new r.Vector3;z.distanceSqToSegment(x.start,x.end,m,u),m.distanceTo(u)<T*.5&&e.push({point:m,pointOnLine:u,distance:z.origin.distanceTo(m),object:a,face:null,faceIndex:n,uv:null,uv1:null})}}function Ae(a,e,t){const i=e.projectionMatrix,o=a.material.resolution,c=a.matrixWorld,n=a.geometry,l=n.attributes.instanceStart,u=n.attributes.instanceEnd,m=Math.min(n.instanceCount,l.count),h=-e.near;z.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=o.x/2,D.y*=o.y/2,D.z=0,N.copy(D),Z.multiplyMatrices(e.matrixWorldInverse,c);for(let v=0,f=m;v<f;v++){if(y.fromBufferAttribute(l,v),M.fromBufferAttribute(u,v),y.w=1,M.w=1,y.applyMatrix4(Z),M.applyMatrix4(Z),y.z>h&&M.z>h)continue;if(y.z>h){const V=y.z-M.z,j=(y.z-h)/V;y.lerp(M,j)}else if(M.z>h){const V=M.z-y.z,j=(M.z-h)/V;M.lerp(y,j)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=o.x/2,y.y*=o.y/2,M.x*=o.x/2,M.y*=o.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const p=x.closestPointToPointParameter(N,!0);x.at(p,ne);const b=r.MathUtils.lerp(y.z,M.z,p),P=b>=-1&&b<=1,B=N.distanceTo(ne)<T*.5;if(P&&B){x.start.fromBufferAttribute(l,v),x.end.fromBufferAttribute(u,v),x.start.applyMatrix4(c),x.end.applyMatrix4(c);const V=new r.Vector3,j=new r.Vector3;z.distanceSqToSegment(x.start,x.end,j,V),t.push({point:j,pointOnLine:V,distance:z.origin.distanceTo(j),object:a,face:null,faceIndex:v,uv:null,uv1:null})}}}class Se extends r.Mesh{constructor(e=new be.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 c=0,n=0,l=t.count;c<l;c++,n+=2)se.fromBufferAttribute(t,c),re.fromBufferAttribute(i,c),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+se.distanceTo(re);const o=new r.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(o,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;z=e.ray;const c=this.matrixWorld,n=this.geometry,l=this.material;T=l.linewidth+o,n.boundingSphere===null&&n.computeBoundingSphere(),U.copy(n.boundingSphere).applyMatrix4(c);let u;if(i)u=T*.5;else{const h=Math.max(s.near,U.distanceToPoint(z.origin));u=oe(s,h,l.resolution)}if(U.radius+=u,z.intersectsSphere(U)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),R.copy(n.boundingBox).applyMatrix4(c);let m;if(i)m=T*.5;else{const h=Math.max(s.near,R.distanceToPoint(z.origin));m=oe(s,h,l.resolution)}R.expandByScalar(m),z.intersectsBox(R)!==!1&&(i?je(this,t):Ae(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}const ae=["encodings_fragment","colorspace_fragment"],Ce=`
|
|
5
5
|
#include <common>
|
|
6
6
|
#include <logdepthbuf_pars_vertex>
|
|
7
7
|
#include <fog_pars_vertex>
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
vHighPrecisionZW = finalPosition.zw;
|
|
95
95
|
#include <fog_vertex>
|
|
96
96
|
}
|
|
97
|
-
`,
|
|
97
|
+
`,Be=`
|
|
98
98
|
#include <packing>
|
|
99
99
|
#include <fog_pars_fragment>
|
|
100
100
|
#include <logdepthbuf_pars_fragment>
|
|
@@ -146,4 +146,4 @@
|
|
|
146
146
|
#include <tonemapping_fragment>
|
|
147
147
|
#include <${+r.REVISION<154?ae[0]:ae[1]}>
|
|
148
148
|
}
|
|
149
|
-
`;class
|
|
149
|
+
`;class Ve extends r.ShaderMaterial{constructor(e){super({uniforms:q(W({},r.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new r.Color(16777215)},opacity:{value:1},resolution:{value:new r.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 r.Vector2(1,1)},offset:{value:new r.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new r.Vector2(0,0)},lightColor:{value:new r.Color(16777215)}}),vertexShader:Ce,fragmentShader:Be}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(t){this.uniforms.useDash.value=t}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(t){this.uniforms.useDepth.value=t}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(t){this.uniforms.repeat.value.copy(t)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(t){this.uniforms.lineLightAnimation.value=t}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(t){this.uniforms.size.value=t}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(t){this.uniforms.speed.value=t}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(t){this.uniforms.lightWidth.value=t}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(t){this.uniforms.uCenter.value=t}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(t){t&&(this.uniforms.lightColor.value=t)}}}),this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray=e.dashArray,this.dashOffset=e.dashOffset,this.dashRatio=e.dashRatio,this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}function De(a,e){return a.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const c=O.geoDistance(o,s)*180/Math.PI;if(c>e){const n=O.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 Ie(a,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const o=Math.round(J(360/a,2)/Math.PI),c=(1+Math.sqrt(5))/2,n=f=>f/c*360%360-180,l=f=>Math.acos(2*f/o-1)/Math.PI*180-90,u=f=>o*(Math.cos((f+90)*Math.PI/180)+1)/2,m=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):o-1],h=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,v=[];for(let f=m[0];f<=m[1];f++){const d=n(f);h(d)&&v.push([d,l(f)])}return v}function X(a,e,t=!1){return t?O.geoContains(e,a):xe(a,e)}function ze(a,e){const t={type:"Polygon",coordinates:a},[[i,s],[o,c]]=O.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(c-s))<e)return[];const n=i>o||c>=89||s<=-89;return Ie(e,{minLng:i,maxLng:o,minLat:s,maxLat:c}).filter(l=>X(l,t,n))}function Le(a,{resolution:e=1/0,bbox:t,projection:i}={}){const s=De(a,e),o=_.merge(s),c=ze(a,e),n=[...o,...c],l={type:"Polygon",coordinates:a},[[u,m],[h,v]]=O.geoBounds(l),f=u>h||v>=89||m<=-89;let d=[];if(f){const g=we.geoVoronoi(n).triangles(),w=new Map(n.map(([A,S],L)=>[`${A}-${S}`,L]));g.features.forEach(A=>{const S=A.geometry.coordinates[0].slice(0,3).reverse(),L=[];if(S.forEach(([C,G])=>{const k=`${C}-${G}`;w.has(k)&&L.push(w.get(k))}),L.length===3){if(L.some(C=>C<o.length)){const C=A.properties.circumcenter;if(!X(C,l,f))return}d.push(...L)}})}else if(c.length){const g=Me.from(n);for(let w=0,A=g.triangles.length;w<A;w+=3){const S=[2,1,0].map(C=>g.triangles[w+C]),L=S.map(C=>n[C]);if(S.some(C=>C<o.length)){const C=[0,1].map(G=>_.mean(L,k=>k[G]));if(!X(C,l,f))continue}d.push(...S)}}else{const{vertices:g,holes:w=[]}=K.flatten(s);d=K(g,w,2)}let p=t?[t[0],t[2]]:_.extent(n,g=>g[0]),b=t?[t[1],t[3]]:_.extent(n,g=>g[1]);if(i){const[g,w]=i([p[0],b[0]]),[A,S]=i([p[1],b[1]]);p=[g,A],b=[-w,-S]}const P=ie.scaleLinear(p,[0,1]),B=ie.scaleLinear(b,[0,1]),V=n.map(([g,w])=>{if(i){const[A,S]=i([g,w]);return[P(A),B(-S)]}else return[P(g),B(w)]});return{contour:s,triangles:{points:n,indices:d,uvs:V}}}const le=new r.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function E(a,e,t,i){const s=a.map(o=>o.map(([c,n])=>{if(i){const[l,u]=i([c,n]);return[l,-u,e]}return t?$.polar2Cartesian(c,n,e):[c,n,e]}));return K.flatten(s)}function Te(a,e,t,i,s){const{vertices:o,holes:c}=E(a,e,i,s),{vertices:n}=E(a,t,i,s),l=_.merge([n,o]),u=Math.round(n.length/3),m=new Set(c);let h=0;const v=[];for(let d=0;d<u;d++){let p=d+1;if(p===u)p=h;else if(m.has(p)){const b=p;p=h,h=b}v.push(d,d+u,p+u),v.push(p+u,p,d)}const f=[];for(let d=1;d>=0;d--)for(let p=0;p<u;p+=1)f.push(p/(u-1),d);return{indices:v,vertices:l,uvs:f,topVerts:n}}function ce(a,e,t,i,s,o){return{indices:i?a.indices:a.indices.slice().reverse(),vertices:E([a.points],e,s,o).vertices,uvs:t}}const he=({polygonGeoJson:a,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:c=!1,hasTop:n=!1,projection:l,bbox:u})=>{a.forEach(P=>{ye(P)||P.reverse()});const{contour:m,triangles:h}=Le(a,{resolution:i,bbox:u,projection:l});let v={},f;o&&(v=Te(m,e!=null?e:t,t!=null?t:e,s,l),f=v.topVerts);let d=[];(c||n)&&(d=_.merge(h.uvs));let p={};c&&(p=ce(h,e,d,!1,s,l));let b={};return n&&(b=ce(h,t,d,!0,s,l)),{contour:m,triangles:h,sideTorso:v,bottomCap:p,topCap:b,topVerts:f}};class _e extends r.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=W({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:m}=this.parameters,{contour:h,sideTorso:v,topVerts:f,bottomCap:d,topCap:p}=he(W({},this.parameters));let b=[],P=[],B=[],V=0;const j=g=>{const w=Math.round(b.length/3),A=B.length;b=b.concat(g.vertices),P=P.concat(g.uvs),B=B.concat(w?g.indices.map(S=>S+w):g.indices),this.addGroup(A,B.length-A,V++)};s&&o&&j(p),n&&(j(v),this.userData.topVerts=u?E(h,i+u,l,m).vertices:f),c&&j(d),s&&!o&&j(p),this.setIndex(B),this[le]("position",new r.Float32BufferAttribute(b,3)),this[le]("uv",new r.Float32BufferAttribute(P,2)),this.computeVertexNormals()}}exports.BaseObject=Q;exports.LineSegments2=Se;exports.MeshLineMaterial=Ve;exports.PolygonGeometry=_e;exports.ResourceTracker=ue;exports.getMetas=he;
|
|
@@ -21,7 +21,11 @@ declare const _default: (options: Options) => {
|
|
|
21
21
|
index: import("three").BufferAttribute | null;
|
|
22
22
|
indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
23
23
|
attributes: import("three").NormalBufferAttributes;
|
|
24
|
-
morphAttributes:
|
|
24
|
+
morphAttributes: {
|
|
25
|
+
position?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
26
|
+
normal?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
27
|
+
color?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
28
|
+
};
|
|
25
29
|
morphTargetsRelative: boolean;
|
|
26
30
|
groups: import("three").GeometryGroup[];
|
|
27
31
|
boundingBox: Box3 | null;
|
|
@@ -27,7 +27,11 @@ export default class extends BaseObject {
|
|
|
27
27
|
index: import("three").BufferAttribute | null;
|
|
28
28
|
indirect: import("three/src/renderers/common/IndirectStorageBufferAttribute").default | null;
|
|
29
29
|
attributes: import("three").NormalBufferAttributes;
|
|
30
|
-
morphAttributes:
|
|
30
|
+
morphAttributes: {
|
|
31
|
+
position?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
32
|
+
normal?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
33
|
+
color?: Array<import("three").BufferAttribute | import("three").InterleavedBufferAttribute> | undefined;
|
|
34
|
+
};
|
|
31
35
|
morphTargetsRelative: boolean;
|
|
32
36
|
groups: import("three").GeometryGroup[];
|
|
33
37
|
boundingBox: import("three").Box3 | null;
|