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