gl-draw 0.15.0-beta.33 → 0.15.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.module2.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
var Pt = Object.defineProperty, It = Object.defineProperties;
|
|
2
2
|
var Dt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var k = Object.getOwnPropertySymbols;
|
|
4
|
-
var it = Object.prototype.hasOwnProperty,
|
|
5
|
-
var
|
|
4
|
+
var it = Object.prototype.hasOwnProperty, st = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var nt = Math.pow, et = (n, t, e) => t in n ? Pt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, L = (n, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
|
-
it.call(t, e) && et(
|
|
7
|
+
it.call(t, e) && et(n, e, t[e]);
|
|
8
8
|
if (k)
|
|
9
9
|
for (var e of k(t))
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, q = (
|
|
13
|
-
var rt = (
|
|
10
|
+
st.call(t, e) && et(n, e, t[e]);
|
|
11
|
+
return n;
|
|
12
|
+
}, q = (n, t) => It(n, Dt(t));
|
|
13
|
+
var rt = (n, t) => {
|
|
14
14
|
var e = {};
|
|
15
|
-
for (var i in
|
|
16
|
-
it.call(
|
|
17
|
-
if (
|
|
18
|
-
for (var i of k(
|
|
19
|
-
t.indexOf(i) < 0 &&
|
|
15
|
+
for (var i in n)
|
|
16
|
+
it.call(n, i) && t.indexOf(i) < 0 && (e[i] = n[i]);
|
|
17
|
+
if (n != null && k)
|
|
18
|
+
for (var i of k(n))
|
|
19
|
+
t.indexOf(i) < 0 && st.call(n, i) && (e[i] = n[i]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var ot = (
|
|
22
|
+
var ot = (n, t, e) => new Promise((i, s) => {
|
|
23
23
|
var a = (c) => {
|
|
24
24
|
try {
|
|
25
25
|
r(e.next(c));
|
|
26
26
|
} catch (o) {
|
|
27
|
-
|
|
27
|
+
s(o);
|
|
28
28
|
}
|
|
29
29
|
}, l = (c) => {
|
|
30
30
|
try {
|
|
31
31
|
r(e.throw(c));
|
|
32
32
|
} catch (o) {
|
|
33
|
-
|
|
33
|
+
s(o);
|
|
34
34
|
}
|
|
35
35
|
}, r = (c) => c.done ? i(c.value) : Promise.resolve(c.value).then(a, l);
|
|
36
|
-
r((e = e.apply(
|
|
36
|
+
r((e = e.apply(n, t)).next());
|
|
37
37
|
});
|
|
38
38
|
import { Material as at, Object3D as R, Texture as ct, VideoTexture as Bt, BufferGeometry as J, Float32BufferAttribute as G, PointsMaterial as zt, Points as H, InstancedMesh as wt, Vector3 as D, Quaternion as Tt, Group as _t, Mesh as St, Sprite as lt, Box3 as jt, Vector4 as O, Matrix4 as Et, Line3 as Lt, Sphere as Ot, InstancedInterleavedBuffer as Vt, InterleavedBufferAttribute as ut, MathUtils as kt, REVISION as Wt, ShaderChunk as W, ShaderMaterial as Nt, Vector2 as K, Color as dt } from "three";
|
|
39
39
|
import { CSS2DObject as Ut } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
@@ -50,7 +50,7 @@ import Ht from "@turf/boolean-point-in-polygon";
|
|
|
50
50
|
import { geoVoronoi as te } from "d3-geo-voronoi";
|
|
51
51
|
import { scaleLinear as pt } from "d3-scale";
|
|
52
52
|
const ee = 0, _e = 1, ie = 2, Ee = !1;
|
|
53
|
-
class
|
|
53
|
+
class se {
|
|
54
54
|
constructor() {
|
|
55
55
|
this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
|
|
56
56
|
}
|
|
@@ -75,8 +75,8 @@ class ne {
|
|
|
75
75
|
if (e.uniforms) {
|
|
76
76
|
for (const i of Object.values(e.uniforms))
|
|
77
77
|
if (i) {
|
|
78
|
-
const
|
|
79
|
-
(
|
|
78
|
+
const s = i.value;
|
|
79
|
+
(s instanceof ct || Array.isArray(s)) && this.track(s);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
} else this.disposeVideo && t instanceof Bt && t.source.data && this.resources.add(t.source.data);
|
|
@@ -91,7 +91,7 @@ class ne {
|
|
|
91
91
|
}), t.length = 0, this.resources.clear();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
const
|
|
94
|
+
const ne = (n, t = 1) => {
|
|
95
95
|
const e = new J();
|
|
96
96
|
e.setAttribute(
|
|
97
97
|
"position",
|
|
@@ -100,7 +100,7 @@ const se = (s, t = 1) => {
|
|
|
100
100
|
"scaleAtt",
|
|
101
101
|
new G(new Array(t).fill(1), 1)
|
|
102
102
|
);
|
|
103
|
-
const i =
|
|
103
|
+
const i = n.material, s = new zt({
|
|
104
104
|
size: 10,
|
|
105
105
|
map: i.map,
|
|
106
106
|
alphaMap: i.alphaMap,
|
|
@@ -113,7 +113,7 @@ const se = (s, t = 1) => {
|
|
|
113
113
|
alphaTest: i.alphaTest,
|
|
114
114
|
sizeAttenuation: !1
|
|
115
115
|
});
|
|
116
|
-
return
|
|
116
|
+
return s.onBeforeCompile = (a) => {
|
|
117
117
|
a.vertexShader = `
|
|
118
118
|
attribute float scaleAtt;
|
|
119
119
|
${a.vertexShader.replace(
|
|
@@ -121,17 +121,17 @@ const se = (s, t = 1) => {
|
|
|
121
121
|
"gl_PointSize = size * scaleAtt;"
|
|
122
122
|
)}
|
|
123
123
|
`;
|
|
124
|
-
}, new H(e,
|
|
125
|
-
}, re = (
|
|
124
|
+
}, new H(e, s);
|
|
125
|
+
}, re = (n, t) => {
|
|
126
126
|
const e = new R();
|
|
127
|
-
t.forEach((i,
|
|
127
|
+
t.forEach((i, s) => {
|
|
128
128
|
const a = ft(i.position), l = ft(i.scale || [1, 1, 1]);
|
|
129
129
|
e.position.copy(a), e.scale.copy(l), e.updateMatrix();
|
|
130
130
|
const r = e.matrix.clone();
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
else if (
|
|
134
|
-
const o =
|
|
131
|
+
if (n instanceof wt || n.isInstantiate)
|
|
132
|
+
n.setMatrixAt(s, r);
|
|
133
|
+
else if (n instanceof H || n.type === "Points") {
|
|
134
|
+
const o = n.geometry, h = o.attributes.position.array, d = o.attributes.scaleAtt.array, p = new D(), u = new D(), m = new Tt(), f = s * 3, v = s * 1;
|
|
135
135
|
r.decompose(p, m, u), h[f] = p.x, h[f + 1] = p.y, h[f + 2] = p.z, d[v] = Math.max(u.x, u.y, u.z), o.attributes.position.needsUpdate = !0, o.attributes.scaleAtt.needsUpdate = !0;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
@@ -176,16 +176,16 @@ class ae extends oe {
|
|
|
176
176
|
const e = t.material;
|
|
177
177
|
if (Array.isArray(e))
|
|
178
178
|
return e.map((i) => {
|
|
179
|
-
const
|
|
179
|
+
const s = i.userData;
|
|
180
180
|
i.userData = {};
|
|
181
181
|
const a = i.clone();
|
|
182
|
-
return i.userData =
|
|
182
|
+
return i.userData = s, a;
|
|
183
183
|
});
|
|
184
184
|
{
|
|
185
185
|
const i = e.userData;
|
|
186
186
|
e.userData = {};
|
|
187
|
-
const
|
|
188
|
-
return e.userData = i,
|
|
187
|
+
const s = e.clone();
|
|
188
|
+
return e.userData = i, s;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
setMaterialList(t, e) {
|
|
@@ -193,8 +193,8 @@ class ae extends oe {
|
|
|
193
193
|
if (!i || !i.material)
|
|
194
194
|
return;
|
|
195
195
|
this.materialList.origin || (this.materialList.origin = i.material);
|
|
196
|
-
const
|
|
197
|
-
return this.materialList[t] =
|
|
196
|
+
const s = e === "clone" ? this.cloneMaterial() : Array.isArray(e) ? e.slice() : e;
|
|
197
|
+
return this.materialList[t] = s, s;
|
|
198
198
|
}
|
|
199
199
|
useMaterial(t) {
|
|
200
200
|
const e = this.object3d;
|
|
@@ -206,8 +206,8 @@ class ae extends oe {
|
|
|
206
206
|
const i = this.mList.get(t);
|
|
207
207
|
if (!i)
|
|
208
208
|
return;
|
|
209
|
-
const
|
|
210
|
-
Array.isArray(
|
|
209
|
+
const s = this.object3d;
|
|
210
|
+
Array.isArray(s.material) && e !== void 0 ? s.material[e] = i : s.material = i;
|
|
211
211
|
}
|
|
212
212
|
useMListByName(t, e) {
|
|
213
213
|
if (!this.mList)
|
|
@@ -335,7 +335,7 @@ class mt extends ae {
|
|
|
335
335
|
instantiate(t) {
|
|
336
336
|
return ot(this, null, function* () {
|
|
337
337
|
var c;
|
|
338
|
-
const e = (c = t == null ? void 0 : t.recursive) != null ? c : !0, { objectType: i, objectOptions:
|
|
338
|
+
const e = (c = t == null ? void 0 : t.recursive) != null ? c : !0, { objectType: i, objectOptions: s } = this, [, a] = i.split("#");
|
|
339
339
|
let l = t == null ? void 0 : t.create;
|
|
340
340
|
l === void 0 && (l = (o) => {
|
|
341
341
|
var h;
|
|
@@ -343,7 +343,7 @@ class mt extends ae {
|
|
|
343
343
|
if ((h = t == null ? void 0 : t.instancedAttr) != null && h.length) {
|
|
344
344
|
const d = t.instancedAttr.length;
|
|
345
345
|
if (this.object3d instanceof lt)
|
|
346
|
-
o.object3d =
|
|
346
|
+
o.object3d = ne(this.object3d, d);
|
|
347
347
|
else {
|
|
348
348
|
const p = this.object3d, u = this.cloneMaterial();
|
|
349
349
|
o.object3d = new wt(p.geometry, u, d);
|
|
@@ -354,11 +354,11 @@ class mt extends ae {
|
|
|
354
354
|
o.object3d.userData.prefab && delete o.object3d.userData.prefab;
|
|
355
355
|
}
|
|
356
356
|
});
|
|
357
|
-
const r = yield this.lead.draw(a, q(L({},
|
|
357
|
+
const r = yield this.lead.draw(a, q(L({}, s || {}), {
|
|
358
358
|
create: l,
|
|
359
359
|
prefab: !1,
|
|
360
|
-
key: (t == null ? void 0 : t.key) || (
|
|
361
|
-
target: (t == null ? void 0 : t.target) || (
|
|
360
|
+
key: (t == null ? void 0 : t.key) || (s == null ? void 0 : s.key),
|
|
361
|
+
target: (t == null ? void 0 : t.target) || (s == null ? void 0 : s.target)
|
|
362
362
|
}));
|
|
363
363
|
return this.isBloom && r.enableBloom(), e && (yield Promise.all(
|
|
364
364
|
this.children.map(
|
|
@@ -383,26 +383,26 @@ class mt extends ae {
|
|
|
383
383
|
dispose() {
|
|
384
384
|
var t;
|
|
385
385
|
if (super.dispose(), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.lead.objectWrapChindIdMap.delete(this), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
|
|
386
|
-
const e = new
|
|
386
|
+
const e = new se();
|
|
387
387
|
e.disposeMaterial = !1, e.track(this), e.dispose();
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
const Q = new O(), vt = new D(),
|
|
391
|
+
const Q = new O(), vt = new D(), yt = new D(), b = new O(), g = new O(), B = new O(), X = new D(), Y = new Et(), M = new Lt(), bt = new D(), N = new jt(), U = new Ot(), z = new O();
|
|
392
392
|
let T, E;
|
|
393
|
-
function
|
|
394
|
-
return z.set(0, 0, -t, 1).applyMatrix4(
|
|
393
|
+
function gt(n, t, e) {
|
|
394
|
+
return z.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), z.multiplyScalar(1 / z.w), z.x = E / e.width, z.y = E / e.height, z.applyMatrix4(n.projectionMatrixInverse), z.multiplyScalar(1 / z.w), Math.abs(Math.max(z.x, z.y));
|
|
395
395
|
}
|
|
396
|
-
function ce(
|
|
397
|
-
const e =
|
|
396
|
+
function ce(n, t) {
|
|
397
|
+
const e = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
|
|
398
398
|
for (let r = 0, c = l; r < c; r++) {
|
|
399
|
-
M.start.fromBufferAttribute(
|
|
399
|
+
M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(e);
|
|
400
400
|
const o = new D(), h = new D();
|
|
401
401
|
T.distanceSqToSegment(M.start, M.end, h, o), h.distanceTo(o) < E * 0.5 && t.push({
|
|
402
402
|
point: h,
|
|
403
403
|
pointOnLine: o,
|
|
404
404
|
distance: T.origin.distanceTo(h),
|
|
405
|
-
object:
|
|
405
|
+
object: n,
|
|
406
406
|
face: null,
|
|
407
407
|
faceIndex: r,
|
|
408
408
|
uv: null,
|
|
@@ -410,31 +410,31 @@ function ce(s, t) {
|
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
function le(
|
|
414
|
-
const i = t.projectionMatrix, a =
|
|
413
|
+
function le(n, t, e) {
|
|
414
|
+
const i = t.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, c = r.attributes.instanceStart, o = r.attributes.instanceEnd, h = Math.min(r.instanceCount, c.count), d = -t.near;
|
|
415
415
|
T.at(1, B), B.w = 1, B.applyMatrix4(t.matrixWorldInverse), B.applyMatrix4(i), B.multiplyScalar(1 / B.w), B.x *= a.x / 2, B.y *= a.y / 2, B.z = 0, X.copy(B), Y.multiplyMatrices(t.matrixWorldInverse, l);
|
|
416
416
|
for (let p = 0, u = h; p < u; p++) {
|
|
417
|
-
if (
|
|
417
|
+
if (b.fromBufferAttribute(c, p), g.fromBufferAttribute(o, p), b.w = 1, g.w = 1, b.applyMatrix4(Y), g.applyMatrix4(Y), b.z > d && g.z > d)
|
|
418
418
|
continue;
|
|
419
|
-
if (
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
} else if (
|
|
423
|
-
const
|
|
424
|
-
|
|
419
|
+
if (b.z > d) {
|
|
420
|
+
const S = b.z - g.z, j = (b.z - d) / S;
|
|
421
|
+
b.lerp(g, j);
|
|
422
|
+
} else if (g.z > d) {
|
|
423
|
+
const S = g.z - b.z, j = (g.z - d) / S;
|
|
424
|
+
g.lerp(b, j);
|
|
425
425
|
}
|
|
426
|
-
|
|
426
|
+
b.applyMatrix4(i), g.applyMatrix4(i), b.multiplyScalar(1 / b.w), g.multiplyScalar(1 / g.w), b.x *= a.x / 2, b.y *= a.y / 2, g.x *= a.x / 2, g.y *= a.y / 2, M.start.copy(b), M.start.z = 0, M.end.copy(g), M.end.z = 0;
|
|
427
427
|
const f = M.closestPointToPointParameter(X, !0);
|
|
428
|
-
M.at(f,
|
|
429
|
-
const v = kt.lerp(
|
|
430
|
-
if (w &&
|
|
428
|
+
M.at(f, bt);
|
|
429
|
+
const v = kt.lerp(b.z, g.z, f), w = v >= -1 && v <= 1, I = X.distanceTo(bt) < E * 0.5;
|
|
430
|
+
if (w && I) {
|
|
431
431
|
M.start.fromBufferAttribute(c, p), M.end.fromBufferAttribute(o, p), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
|
|
432
|
-
const
|
|
433
|
-
T.distanceSqToSegment(M.start, M.end,
|
|
434
|
-
point:
|
|
435
|
-
pointOnLine:
|
|
436
|
-
distance: T.origin.distanceTo(
|
|
437
|
-
object:
|
|
432
|
+
const S = new D(), j = new D();
|
|
433
|
+
T.distanceSqToSegment(M.start, M.end, j, S), e.push({
|
|
434
|
+
point: j,
|
|
435
|
+
pointOnLine: S,
|
|
436
|
+
distance: T.origin.distanceTo(j),
|
|
437
|
+
object: n,
|
|
438
438
|
face: null,
|
|
439
439
|
faceIndex: p,
|
|
440
440
|
uv: null,
|
|
@@ -449,11 +449,11 @@ class Le extends St {
|
|
|
449
449
|
}
|
|
450
450
|
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
451
451
|
computeLineDistances() {
|
|
452
|
-
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd,
|
|
452
|
+
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
|
|
453
453
|
for (let l = 0, r = 0, c = e.count; l < c; l++, r += 2)
|
|
454
|
-
vt.fromBufferAttribute(e, l),
|
|
454
|
+
vt.fromBufferAttribute(e, l), yt.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + vt.distanceTo(yt);
|
|
455
455
|
const a = new Vt(
|
|
456
|
-
|
|
456
|
+
s,
|
|
457
457
|
2,
|
|
458
458
|
1
|
|
459
459
|
);
|
|
@@ -466,8 +466,8 @@ class Le extends St {
|
|
|
466
466
|
), this;
|
|
467
467
|
}
|
|
468
468
|
raycast(t, e) {
|
|
469
|
-
const i = this.material.worldUnits,
|
|
470
|
-
|
|
469
|
+
const i = this.material.worldUnits, s = t.camera;
|
|
470
|
+
s === null && !i && console.error(
|
|
471
471
|
'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
|
|
472
472
|
);
|
|
473
473
|
const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
|
|
@@ -479,11 +479,11 @@ class Le extends St {
|
|
|
479
479
|
o = E * 0.5;
|
|
480
480
|
else {
|
|
481
481
|
const d = Math.max(
|
|
482
|
-
|
|
482
|
+
s.near,
|
|
483
483
|
U.distanceToPoint(T.origin)
|
|
484
484
|
);
|
|
485
|
-
o =
|
|
486
|
-
|
|
485
|
+
o = gt(
|
|
486
|
+
s,
|
|
487
487
|
d,
|
|
488
488
|
c.resolution
|
|
489
489
|
);
|
|
@@ -496,16 +496,16 @@ class Le extends St {
|
|
|
496
496
|
h = E * 0.5;
|
|
497
497
|
else {
|
|
498
498
|
const d = Math.max(
|
|
499
|
-
|
|
499
|
+
s.near,
|
|
500
500
|
N.distanceToPoint(T.origin)
|
|
501
501
|
);
|
|
502
|
-
h =
|
|
503
|
-
|
|
502
|
+
h = gt(
|
|
503
|
+
s,
|
|
504
504
|
d,
|
|
505
505
|
c.resolution
|
|
506
506
|
);
|
|
507
507
|
}
|
|
508
|
-
N.expandByScalar(h), T.intersectsBox(N) !== !1 && (i ? ce(this, e) : le(this,
|
|
508
|
+
N.expandByScalar(h), T.intersectsBox(N) !== !1 && (i ? ce(this, e) : le(this, s, e));
|
|
509
509
|
}
|
|
510
510
|
onBeforeRender(t) {
|
|
511
511
|
const e = this.material.uniforms;
|
|
@@ -599,7 +599,7 @@ void main() {
|
|
|
599
599
|
vec2 prevScreen = intoScreen(prevNormed);
|
|
600
600
|
vec2 nextScreen = intoScreen(nextNormed);
|
|
601
601
|
|
|
602
|
-
float actualWidth = lineWidth * width
|
|
602
|
+
float actualWidth = lineWidth * width;
|
|
603
603
|
|
|
604
604
|
vec2 dir;
|
|
605
605
|
if(nextScreen == currentScreen) {
|
|
@@ -650,26 +650,27 @@ void main() {
|
|
|
650
650
|
`;
|
|
651
651
|
class Oe extends Nt {
|
|
652
652
|
constructor(t = {}) {
|
|
653
|
-
var j;
|
|
654
653
|
const S = t, {
|
|
655
654
|
lineWidth: e = 1,
|
|
656
655
|
color: i = "#ffffff",
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
656
|
+
opacity: s = 1,
|
|
657
|
+
map: a = null,
|
|
658
|
+
useMap: l = 0,
|
|
659
|
+
dashOffset: r = 0,
|
|
660
|
+
dashArray: c = 0,
|
|
661
|
+
dashRatio: o = 0,
|
|
662
|
+
sizeAttenuation: h = !0,
|
|
663
|
+
offsetLoop: d = !0,
|
|
664
|
+
offset: p = new K(0, 0),
|
|
665
|
+
scaleDown: u = 0,
|
|
666
|
+
alphaMap: m = void 0,
|
|
667
|
+
alphaTest: f = 0,
|
|
668
|
+
repeat: v = new K(1, 1),
|
|
669
|
+
resolution: w = new K(1, 1)
|
|
670
|
+
} = S, I = rt(S, [
|
|
671
671
|
"lineWidth",
|
|
672
672
|
"color",
|
|
673
|
+
"opacity",
|
|
673
674
|
"map",
|
|
674
675
|
"useMap",
|
|
675
676
|
"dashOffset",
|
|
@@ -684,26 +685,26 @@ class Oe extends Nt {
|
|
|
684
685
|
"repeat",
|
|
685
686
|
"resolution"
|
|
686
687
|
]);
|
|
687
|
-
super(q(L({},
|
|
688
|
+
super(q(L({}, I), {
|
|
688
689
|
uniforms: {
|
|
689
690
|
lineWidth: { value: e },
|
|
690
691
|
color: { value: new dt(i) },
|
|
691
|
-
opacity: { value:
|
|
692
|
-
map: { value:
|
|
693
|
-
useMap: { value:
|
|
694
|
-
resolution: { value:
|
|
695
|
-
sizeAttenuation: { value:
|
|
696
|
-
offset: { value:
|
|
697
|
-
offsetLoop: { value:
|
|
698
|
-
dashArray: { value:
|
|
699
|
-
dashOffset: { value:
|
|
700
|
-
dashRatio: { value:
|
|
701
|
-
useDash: { value:
|
|
702
|
-
scaleDown: { value:
|
|
703
|
-
alphaTest: { value:
|
|
704
|
-
alphaMap: { value:
|
|
705
|
-
useAlphaMap: { value:
|
|
706
|
-
repeat: { value:
|
|
692
|
+
opacity: { value: s },
|
|
693
|
+
map: { value: a },
|
|
694
|
+
useMap: { value: a ? 1 : l },
|
|
695
|
+
resolution: { value: w },
|
|
696
|
+
sizeAttenuation: { value: h ? 1 : 0 },
|
|
697
|
+
offset: { value: p },
|
|
698
|
+
offsetLoop: { value: d ? 1 : 0 },
|
|
699
|
+
dashArray: { value: c },
|
|
700
|
+
dashOffset: { value: r },
|
|
701
|
+
dashRatio: { value: o },
|
|
702
|
+
useDash: { value: c > 0 ? 1 : 0 },
|
|
703
|
+
scaleDown: { value: u / 10 },
|
|
704
|
+
alphaTest: { value: f },
|
|
705
|
+
alphaMap: { value: m },
|
|
706
|
+
useAlphaMap: { value: m ? 1 : 0 },
|
|
707
|
+
repeat: { value: v }
|
|
707
708
|
},
|
|
708
709
|
vertexShader: de,
|
|
709
710
|
fragmentShader: ue
|
|
@@ -716,6 +717,12 @@ class Oe extends Nt {
|
|
|
716
717
|
set color(t) {
|
|
717
718
|
this.uniforms.color.value = new dt(t);
|
|
718
719
|
}
|
|
720
|
+
get opacity() {
|
|
721
|
+
return this.uniforms.opacity.value;
|
|
722
|
+
}
|
|
723
|
+
set opacity(t) {
|
|
724
|
+
this.uniforms.opacity.value = t;
|
|
725
|
+
}
|
|
719
726
|
// Getter and setter for map
|
|
720
727
|
get map() {
|
|
721
728
|
return this.uniforms.map.value;
|
|
@@ -738,27 +745,27 @@ class Oe extends Nt {
|
|
|
738
745
|
this.uniforms.sizeAttenuation.value = t ? 1 : 0;
|
|
739
746
|
}
|
|
740
747
|
}
|
|
741
|
-
function fe(
|
|
742
|
-
return
|
|
748
|
+
function fe(n, t) {
|
|
749
|
+
return n.map((e) => {
|
|
743
750
|
const i = [];
|
|
744
|
-
let
|
|
751
|
+
let s;
|
|
745
752
|
return e.forEach((a) => {
|
|
746
|
-
if (
|
|
747
|
-
const l = Ft(a,
|
|
753
|
+
if (s) {
|
|
754
|
+
const l = Ft(a, s) * 180 / Math.PI;
|
|
748
755
|
if (l > t) {
|
|
749
|
-
const r = qt(
|
|
756
|
+
const r = qt(s, a), c = 1 / Math.ceil(l / t);
|
|
750
757
|
let o = c;
|
|
751
758
|
for (; o < 1; )
|
|
752
759
|
i.push(r(o)), o += c;
|
|
753
760
|
}
|
|
754
761
|
}
|
|
755
|
-
i.push(
|
|
762
|
+
i.push(s = a);
|
|
756
763
|
}), i;
|
|
757
764
|
});
|
|
758
765
|
}
|
|
759
|
-
function he(
|
|
760
|
-
const a = Math.round(
|
|
761
|
-
|
|
766
|
+
function he(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
767
|
+
const a = Math.round(nt(360 / n, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, r = (u) => u / l * 360 % 360 - 180, c = (u) => Math.acos(2 * u / a - 1) / Math.PI * 180 - 90, o = (u) => a * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, h = [
|
|
768
|
+
s !== void 0 ? Math.ceil(o(s)) : 0,
|
|
762
769
|
i !== void 0 ? Math.floor(o(i)) : a - 1
|
|
763
770
|
], d = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (u) => u <= e : e === void 0 ? (u) => u >= t : e >= t ? (u) => u >= t && u <= e : (u) => u >= t || u <= e, p = [];
|
|
764
771
|
for (let u = h[0]; u <= h[1]; u++) {
|
|
@@ -767,42 +774,42 @@ function he(s, { minLng: t, maxLng: e, minLat: i, maxLat: n } = {}) {
|
|
|
767
774
|
}
|
|
768
775
|
return p;
|
|
769
776
|
}
|
|
770
|
-
function Z(
|
|
771
|
-
return e ? $t(t,
|
|
777
|
+
function Z(n, t, e = !1) {
|
|
778
|
+
return e ? $t(t, n) : Ht(n, t);
|
|
772
779
|
}
|
|
773
|
-
function pe(
|
|
774
|
-
const e = { type: "Polygon", coordinates:
|
|
775
|
-
if (Math.min(Math.abs(a - i), Math.abs(l -
|
|
780
|
+
function pe(n, t) {
|
|
781
|
+
const e = { type: "Polygon", coordinates: n }, [[i, s], [a, l]] = At(e);
|
|
782
|
+
if (Math.min(Math.abs(a - i), Math.abs(l - s)) < t)
|
|
776
783
|
return [];
|
|
777
|
-
const r = i > a || l >= 89 ||
|
|
784
|
+
const r = i > a || l >= 89 || s <= -89;
|
|
778
785
|
return he(t, {
|
|
779
786
|
minLng: i,
|
|
780
787
|
maxLng: a,
|
|
781
|
-
minLat:
|
|
788
|
+
minLat: s,
|
|
782
789
|
maxLat: l
|
|
783
790
|
}).filter(
|
|
784
791
|
(c) => Z(c, e, r)
|
|
785
792
|
);
|
|
786
793
|
}
|
|
787
|
-
function me(
|
|
788
|
-
const
|
|
794
|
+
function me(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
795
|
+
const s = fe(n, t), a = tt(s), l = pe(n, t), r = [...a, ...l], c = { type: "Polygon", coordinates: n }, [[o, h], [d, p]] = At(c), u = o > d || // crosses antimeridian
|
|
789
796
|
p >= 89 || // crosses north pole
|
|
790
797
|
h <= -89;
|
|
791
798
|
let m = [];
|
|
792
799
|
if (u) {
|
|
793
|
-
const
|
|
794
|
-
r.map(([
|
|
800
|
+
const y = te(r).triangles(), x = new Map(
|
|
801
|
+
r.map(([A, C], _) => [`${A}-${C}`, _])
|
|
795
802
|
);
|
|
796
|
-
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
799
|
-
const V = `${
|
|
803
|
+
y.features.forEach((A) => {
|
|
804
|
+
const C = A.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
|
|
805
|
+
if (C.forEach(([P, F]) => {
|
|
806
|
+
const V = `${P}-${F}`;
|
|
800
807
|
x.has(V) && _.push(x.get(V));
|
|
801
808
|
}), _.length === 3) {
|
|
802
|
-
if (_.some((
|
|
803
|
-
const
|
|
809
|
+
if (_.some((P) => P < a.length)) {
|
|
810
|
+
const P = A.properties.circumcenter;
|
|
804
811
|
if (!Z(
|
|
805
|
-
|
|
812
|
+
P,
|
|
806
813
|
c,
|
|
807
814
|
u
|
|
808
815
|
))
|
|
@@ -812,43 +819,43 @@ function me(s, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
812
819
|
}
|
|
813
820
|
});
|
|
814
821
|
} else if (l.length) {
|
|
815
|
-
const
|
|
816
|
-
for (let x = 0,
|
|
817
|
-
const
|
|
818
|
-
if (
|
|
819
|
-
const
|
|
822
|
+
const y = Jt.from(r);
|
|
823
|
+
for (let x = 0, A = y.triangles.length; x < A; x += 3) {
|
|
824
|
+
const C = [2, 1, 0].map((P) => y.triangles[x + P]), _ = C.map((P) => r[P]);
|
|
825
|
+
if (C.some((P) => P < a.length)) {
|
|
826
|
+
const P = [0, 1].map(
|
|
820
827
|
(F) => Xt(_, (V) => V[F])
|
|
821
828
|
);
|
|
822
829
|
if (!Z(
|
|
823
|
-
|
|
830
|
+
P,
|
|
824
831
|
c,
|
|
825
832
|
u
|
|
826
833
|
))
|
|
827
834
|
continue;
|
|
828
835
|
}
|
|
829
|
-
m.push(...
|
|
836
|
+
m.push(...C);
|
|
830
837
|
}
|
|
831
838
|
} else {
|
|
832
|
-
const { vertices:
|
|
833
|
-
m = Yt(
|
|
839
|
+
const { vertices: y, holes: x = [] } = Ct(s);
|
|
840
|
+
m = Yt(y, x, 2);
|
|
834
841
|
}
|
|
835
|
-
let f = e ? [e[0], e[2]] : ht(r, (
|
|
842
|
+
let f = e ? [e[0], e[2]] : ht(r, (y) => y[0]), v = e ? [e[1], e[3]] : ht(r, (y) => y[1]);
|
|
836
843
|
if (i) {
|
|
837
|
-
const [
|
|
838
|
-
f = [
|
|
844
|
+
const [y, x] = i([f[0], v[0]]), [A, C] = i([f[1], v[1]]);
|
|
845
|
+
f = [y, A], v = [-x, -C];
|
|
839
846
|
}
|
|
840
|
-
const w = pt(f, [0, 1]),
|
|
847
|
+
const w = pt(f, [0, 1]), I = pt(v, [0, 1]), S = r.map(([y, x]) => {
|
|
841
848
|
if (i) {
|
|
842
|
-
const [
|
|
843
|
-
return [w(
|
|
849
|
+
const [A, C] = i([y, x]);
|
|
850
|
+
return [w(A), I(-C)];
|
|
844
851
|
} else
|
|
845
|
-
return [w(
|
|
852
|
+
return [w(y), I(x)];
|
|
846
853
|
});
|
|
847
|
-
return { contour:
|
|
854
|
+
return { contour: s, triangles: { points: r, indices: m, uvs: S } };
|
|
848
855
|
}
|
|
849
856
|
const Mt = new J().setAttribute ? "setAttribute" : "addAttribute";
|
|
850
|
-
function $(
|
|
851
|
-
const
|
|
857
|
+
function $(n, t, e, i) {
|
|
858
|
+
const s = n.map(
|
|
852
859
|
(a) => a.map(([l, r]) => {
|
|
853
860
|
if (i) {
|
|
854
861
|
const [c, o] = i([l, r]);
|
|
@@ -857,19 +864,19 @@ function $(s, t, e, i) {
|
|
|
857
864
|
return e ? Kt(l, r, t) : [l, r, t];
|
|
858
865
|
})
|
|
859
866
|
);
|
|
860
|
-
return Ct(
|
|
867
|
+
return Ct(s);
|
|
861
868
|
}
|
|
862
|
-
function ve(
|
|
869
|
+
function ve(n, t, e, i, s) {
|
|
863
870
|
const { vertices: a, holes: l } = $(
|
|
864
|
-
|
|
871
|
+
n,
|
|
865
872
|
t,
|
|
866
873
|
i,
|
|
867
|
-
|
|
874
|
+
s
|
|
868
875
|
), { vertices: r } = $(
|
|
869
|
-
|
|
876
|
+
n,
|
|
870
877
|
e,
|
|
871
878
|
i,
|
|
872
|
-
|
|
879
|
+
s
|
|
873
880
|
), c = tt([r, a]), o = Math.round(r.length / 3), h = new Set(l);
|
|
874
881
|
let d = 0;
|
|
875
882
|
const p = [];
|
|
@@ -888,34 +895,34 @@ function ve(s, t, e, i, n) {
|
|
|
888
895
|
for (let f = 0; f < o; f += 1) u.push(f / (o - 1), m);
|
|
889
896
|
return { indices: p, vertices: c, uvs: u, topVerts: r };
|
|
890
897
|
}
|
|
891
|
-
function xt(
|
|
898
|
+
function xt(n, t, e, i, s, a) {
|
|
892
899
|
return {
|
|
893
|
-
indices: i ?
|
|
900
|
+
indices: i ? n.indices : n.indices.slice().reverse(),
|
|
894
901
|
vertices: $(
|
|
895
|
-
[
|
|
902
|
+
[n.points],
|
|
896
903
|
t,
|
|
897
|
-
|
|
904
|
+
s,
|
|
898
905
|
a
|
|
899
906
|
).vertices,
|
|
900
907
|
uvs: e
|
|
901
908
|
};
|
|
902
909
|
}
|
|
903
|
-
const
|
|
904
|
-
polygonGeoJson:
|
|
910
|
+
const ye = ({
|
|
911
|
+
polygonGeoJson: n,
|
|
905
912
|
startHeight: t,
|
|
906
913
|
endHeight: e,
|
|
907
914
|
curvatureResolution: i = 1,
|
|
908
|
-
cartesian:
|
|
915
|
+
cartesian: s = !0,
|
|
909
916
|
hasSide: a = !0,
|
|
910
917
|
hasBottom: l = !1,
|
|
911
918
|
hasTop: r = !1,
|
|
912
919
|
projection: c,
|
|
913
920
|
bbox: o
|
|
914
921
|
}) => {
|
|
915
|
-
|
|
922
|
+
n.forEach((w) => {
|
|
916
923
|
Zt(w) || w.reverse();
|
|
917
924
|
});
|
|
918
|
-
const { contour: h, triangles: d } = me(
|
|
925
|
+
const { contour: h, triangles: d } = me(n, {
|
|
919
926
|
resolution: i,
|
|
920
927
|
bbox: o,
|
|
921
928
|
projection: c
|
|
@@ -925,7 +932,7 @@ const be = ({
|
|
|
925
932
|
h,
|
|
926
933
|
t != null ? t : e,
|
|
927
934
|
e != null ? e : t,
|
|
928
|
-
|
|
935
|
+
s,
|
|
929
936
|
c
|
|
930
937
|
), u = p.topVerts);
|
|
931
938
|
let m = [];
|
|
@@ -936,7 +943,7 @@ const be = ({
|
|
|
936
943
|
t,
|
|
937
944
|
m,
|
|
938
945
|
!1,
|
|
939
|
-
|
|
946
|
+
s,
|
|
940
947
|
c
|
|
941
948
|
));
|
|
942
949
|
let v = {};
|
|
@@ -945,7 +952,7 @@ const be = ({
|
|
|
945
952
|
e,
|
|
946
953
|
m,
|
|
947
954
|
!0,
|
|
948
|
-
|
|
955
|
+
s,
|
|
949
956
|
c
|
|
950
957
|
)), { contour: h, triangles: d, sideTorso: p, bottomCap: f, topCap: v, topVerts: u };
|
|
951
958
|
};
|
|
@@ -965,27 +972,27 @@ class Ve extends J {
|
|
|
965
972
|
}, e);
|
|
966
973
|
const {
|
|
967
974
|
endHeight: i,
|
|
968
|
-
hasTop:
|
|
975
|
+
hasTop: s,
|
|
969
976
|
topFirst: a,
|
|
970
977
|
hasBottom: l,
|
|
971
978
|
hasSide: r,
|
|
972
979
|
cartesian: c,
|
|
973
980
|
userDataRsoOffset: o,
|
|
974
981
|
projection: h
|
|
975
|
-
} = this.parameters, { contour: d, sideTorso: p, topVerts: u, bottomCap: m, topCap: f } =
|
|
976
|
-
let v = [], w = [],
|
|
977
|
-
const
|
|
978
|
-
const x = Math.round(v.length / 3),
|
|
979
|
-
v = v.concat(
|
|
980
|
-
x ?
|
|
981
|
-
), this.addGroup(
|
|
982
|
+
} = this.parameters, { contour: d, sideTorso: p, topVerts: u, bottomCap: m, topCap: f } = ye(L({}, this.parameters));
|
|
983
|
+
let v = [], w = [], I = [], S = 0;
|
|
984
|
+
const j = (y) => {
|
|
985
|
+
const x = Math.round(v.length / 3), A = I.length;
|
|
986
|
+
v = v.concat(y.vertices), w = w.concat(y.uvs), I = I.concat(
|
|
987
|
+
x ? y.indices.map((C) => C + x) : y.indices
|
|
988
|
+
), this.addGroup(A, I.length - A, S++);
|
|
982
989
|
};
|
|
983
|
-
|
|
990
|
+
s && a && j(f), r && (j(p), this.userData.topVerts = o ? $(
|
|
984
991
|
d,
|
|
985
992
|
i + o,
|
|
986
993
|
c,
|
|
987
994
|
h
|
|
988
|
-
).vertices : u), l &&
|
|
995
|
+
).vertices : u), l && j(m), s && !a && j(f), this.setIndex(I), this[Mt]("position", new G(v, 3)), this[Mt]("uv", new G(w, 2)), this.computeVertexNormals();
|
|
989
996
|
}
|
|
990
997
|
}
|
|
991
998
|
export {
|
|
@@ -994,7 +1001,7 @@ export {
|
|
|
994
1001
|
Le as L,
|
|
995
1002
|
Oe as M,
|
|
996
1003
|
Ve as P,
|
|
997
|
-
|
|
1004
|
+
se as R,
|
|
998
1005
|
mt as a,
|
|
999
|
-
|
|
1006
|
+
ye as g
|
|
1000
1007
|
};
|
package/dist/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(
|
|
1
|
+
"use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(W)for(var t of W(e))ee.call(e,t)&&J(n,t,e[t]);return n},q=(n,e)=>me(n,ve(e));var re=(n,e)=>{var t={};for(var r in n)H.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&W)for(var r of W(n))e.indexOf(r)<0&&ee.call(n,r)&&(t[r]=n[r]);return t};var ie=(n,e,t)=>new Promise((r,i)=>{var c=l=>{try{s(t.next(l))}catch(a){i(a)}},u=l=>{try{s(t.throw(l))}catch(a){i(a)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(c,u);s((t=t.apply(n,e)).next())});const o=require("three"),be=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),O=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),ye=require("three/examples/jsm/lines/LineSegmentsGeometry"),L=require("d3-array"),X=require("earcut"),ge=require("@turf/boolean-clockwise"),Me=require("delaunator"),Se=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),se=require("d3-scale"),we=0,je=1,Ae=2,Ce=!1;class fe{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof o.Material)return e;if(e instanceof Y?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Y)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const r of Object.values(e))r instanceof o.Texture&&this.track(r);const t=e;if(t.uniforms){for(const r of Object.values(t.uniforms))if(r){const i=r.value;(i instanceof o.Texture||Array.isArray(i))&&this.track(i)}}}else this.disposeVideo&&e instanceof o.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const Pe=(n,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const r=n.material,i=new o.PointsMaterial({size:10,map:r.map,alphaMap:r.alphaMap,color:r.color,blending:r.blending,depthTest:r.depthTest,depthWrite:!1,opacity:r.opacity,transparent:!0,alphaTest:r.alphaTest,sizeAttenuation:!1});return i.onBeforeCompile=c=>{c.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
3
|
${c.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
-
`},new o.Points(t,
|
|
4
|
+
`},new o.Points(t,i)},Be=(n,e)=>{const t=new o.Object3D;e.forEach((r,i)=>{const c=Q.parseVector3(r.position),u=Q.parseVector3(r.scale||[1,1,1]);t.position.copy(c),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(i,s);else if(n instanceof o.Points||n.type==="Points"){const a=n.geometry,p=a.attributes.position.array,f=a.attributes.scaleAtt.array,m=new o.Vector3,d=new o.Vector3,v=new o.Quaternion,h=i*3,b=i*1;s.decompose(m,v,d),p[h]=m.x,p[h+1]=m.y,p[h+2]=m.z,f[b]=Math.max(d.x,d.y,d.z),a.attributes.position.needsUpdate=!0,a.attributes.scaleAtt.needsUpdate=!0}})};class Ie{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const r=this.lead.handlePick([this],e,t);this.onPointerIndex.push(r)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class De extends Ie{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(r=>{const i=r.userData;r.userData={};const c=r.clone();return r.userData=i,c});{const r=t.userData;t.userData={};const i=t.clone();return t.userData=r,i}}setMaterialList(e,t){const r=this.object3d;if(!r||!r.material)return;this.materialList.origin||(this.materialList.origin=r.material);const i=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=i,i}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 r=this.mList.get(e);if(!r)return;const i=this.object3d;Array.isArray(i.material)&&t!==void 0?i.material[t]=r:i.material=r}useMListByName(e,t){if(!this.mList)return;const r=this.mList.getKeyByName(e);r&&this.useMListById(r,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends De{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.disposeTrack=!0}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get lookAt(){return this.object3d.lookAt}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{var r;this.lead.objMap.get(t)?(r=this.lead.objMap.get(t))==null||r.erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(we),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new be.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ne.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ne.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return ie(this,null,function*(){var l;const t=(l=e==null?void 0:e.recursive)!=null?l:!0,{objectType:r,objectOptions:i}=this,[,c]=r.split("#");let u=e==null?void 0:e.create;u===void 0&&(u=a=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const f=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)a.object3d=Pe(this.object3d,f);else{const m=this.object3d,d=this.cloneMaterial();a.object3d=new o.InstancedMesh(m.geometry,d,f)}Be(a.object3d,e==null?void 0:e.instancedAttr)}else a.object3d=this.object3d.clone(!1),a.object3d.material&&(a.object3d.material=this.cloneMaterial());a.object3d.userData.prefab&&delete a.object3d.userData.prefab}});const s=yield this.lead.draw(c,q(_({},i||{}),{create:u,prefab:!1,key:(e==null?void 0:e.key)||(i==null?void 0:i.key),target:(e==null?void 0:e.target)||(i==null?void 0:i.target)}));return this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(a=>a.instantiate({target:s})))),s.isInstantiate=!0,s})}erase(){this.lead.erase(this)}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(super.dispose(),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new fe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}const F=new o.Vector4,oe=new o.Vector3,ae=new o.Vector3,g=new o.Vector4,M=new o.Vector4,D=new o.Vector4,$=new o.Vector3,K=new o.Matrix4,S=new o.Line3,ce=new o.Vector3,N=new o.Box3,U=new o.Sphere,V=new o.Vector4;let T,E;function le(n,e,t){return V.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),V.multiplyScalar(1/V.w),V.x=E/t.width,V.y=E/t.height,V.applyMatrix4(n.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ve(n,e){const t=n.matrixWorld,r=n.geometry,i=r.attributes.instanceStart,c=r.attributes.instanceEnd,u=Math.min(r.instanceCount,i.count);for(let s=0,l=u;s<l;s++){S.start.fromBufferAttribute(i,s),S.end.fromBufferAttribute(c,s),S.applyMatrix4(t);const a=new o.Vector3,p=new o.Vector3;T.distanceSqToSegment(S.start,S.end,p,a),p.distanceTo(a)<E*.5&&e.push({point:p,pointOnLine:a,distance:T.origin.distanceTo(p),object:n,face:null,faceIndex:s,uv:null,uv1:null})}}function Te(n,e,t){const r=e.projectionMatrix,c=n.material.resolution,u=n.matrixWorld,s=n.geometry,l=s.attributes.instanceStart,a=s.attributes.instanceEnd,p=Math.min(s.instanceCount,l.count),f=-e.near;T.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(r),D.multiplyScalar(1/D.w),D.x*=c.x/2,D.y*=c.y/2,D.z=0,$.copy(D),K.multiplyMatrices(e.matrixWorldInverse,u);for(let m=0,d=p;m<d;m++){if(g.fromBufferAttribute(l,m),M.fromBufferAttribute(a,m),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>f&&M.z>f)continue;if(g.z>f){const j=g.z-M.z,A=(g.z-f)/j;g.lerp(M,A)}else if(M.z>f){const j=M.z-g.z,A=(M.z-f)/j;M.lerp(g,A)}g.applyMatrix4(r),M.applyMatrix4(r),g.multiplyScalar(1/g.w),M.multiplyScalar(1/M.w),g.x*=c.x/2,g.y*=c.y/2,M.x*=c.x/2,M.y*=c.y/2,S.start.copy(g),S.start.z=0,S.end.copy(M),S.end.z=0;const h=S.closestPointToPointParameter($,!0);S.at(h,ce);const b=o.MathUtils.lerp(g.z,M.z,h),w=b>=-1&&b<=1,I=$.distanceTo(ce)<E*.5;if(w&&I){S.start.fromBufferAttribute(l,m),S.end.fromBufferAttribute(a,m),S.start.applyMatrix4(u),S.end.applyMatrix4(u);const j=new o.Vector3,A=new o.Vector3;T.distanceSqToSegment(S.start,S.end,A,j),t.push({point:A,pointOnLine:j,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:m,uv:null,uv1:null})}}}class ze extends o.Mesh{constructor(e=new ye.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let u=0,s=0,l=t.count;u<l;u++,s+=2)oe.fromBufferAttribute(t,u),ae.fromBufferAttribute(r,u),i[s]=s===0?0:i[s-1],i[s+1]=i[s]+oe.distanceTo(ae);const c=new o.InstancedInterleavedBuffer(i,2,1);return e.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(c,1,0)),e.setAttribute("instanceDistanceEnd",new o.InterleavedBufferAttribute(c,1,1)),this}raycast(e,t){const r=this.material.worldUnits,i=e.camera;i===null&&!r&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const c=e.params.Line2!==void 0&&e.params.Line2.threshold||0;T=e.ray;const u=this.matrixWorld,s=this.geometry,l=this.material;E=l.linewidth+c,s.boundingSphere===null&&s.computeBoundingSphere(),U.copy(s.boundingSphere).applyMatrix4(u);let a;if(r)a=E*.5;else{const f=Math.max(i.near,U.distanceToPoint(T.origin));a=le(i,f,l.resolution)}if(U.radius+=a,T.intersectsSphere(U)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),N.copy(s.boundingBox).applyMatrix4(u);let p;if(r)p=E*.5;else{const f=Math.max(i.near,N.distanceToPoint(T.origin));p=le(i,f,l.resolution)}N.expandByScalar(p),T.intersectsBox(N)!==!1&&(r?Ve(this,t):Te(this,i,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 Ee=`
|
|
5
5
|
#include <fog_pars_fragment>
|
|
6
6
|
#include <logdepthbuf_pars_fragment>
|
|
7
7
|
|
|
@@ -88,7 +88,7 @@ void main() {
|
|
|
88
88
|
vec2 prevScreen = intoScreen(prevNormed);
|
|
89
89
|
vec2 nextScreen = intoScreen(nextNormed);
|
|
90
90
|
|
|
91
|
-
float actualWidth = lineWidth * width
|
|
91
|
+
float actualWidth = lineWidth * width;
|
|
92
92
|
|
|
93
93
|
vec2 dir;
|
|
94
94
|
if(nextScreen == currentScreen) {
|
|
@@ -136,4 +136,4 @@ void main() {
|
|
|
136
136
|
${o.ShaderChunk.logdepthbuf_vertex}
|
|
137
137
|
${o.ShaderChunk.fog_vertex}
|
|
138
138
|
}
|
|
139
|
-
`;class _e extends o.ShaderMaterial{constructor(e={}){
|
|
139
|
+
`;class _e extends o.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:r="#ffffff",opacity:i=1,map:c=null,useMap:u=0,dashOffset:s=0,dashArray:l=0,dashRatio:a=0,sizeAttenuation:p=!0,offsetLoop:f=!0,offset:m=new o.Vector2(0,0),scaleDown:d=0,alphaMap:v=void 0,alphaTest:h=0,repeat:b=new o.Vector2(1,1),resolution:w=new o.Vector2(1,1)}=j,I=re(j,["lineWidth","color","opacity","map","useMap","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(q(_({},I),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(r)},opacity:{value:i},map:{value:c},useMap:{value:c?1:u},resolution:{value:w},sizeAttenuation:{value:p?1:0},offset:{value:m},offsetLoop:{value:f?1:0},dashArray:{value:l},dashOffset:{value:s},dashRatio:{value:a},useDash:{value:l>0?1:0},scaleDown:{value:d/10},alphaTest:{value:h},alphaMap:{value:v},useAlphaMap:{value:v?1:0},repeat:{value:b}},vertexShader:Le,fragmentShader:Ee})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms.opacity.value=e}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}function Oe(n,e){return n.map(t=>{const r=[];let i;return t.forEach(c=>{if(i){const u=O.geoDistance(c,i)*180/Math.PI;if(u>e){const s=O.geoInterpolate(i,c),l=1/Math.ceil(u/e);let a=l;for(;a<1;)r.push(s(a)),a+=l}}r.push(i=c)}),r})}function ke(n,{minLng:e,maxLng:t,minLat:r,maxLat:i}={}){const c=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=d=>d/u*360%360-180,l=d=>Math.acos(2*d/c-1)/Math.PI*180-90,a=d=>c*(Math.cos((d+90)*Math.PI/180)+1)/2,p=[i!==void 0?Math.ceil(a(i)):0,r!==void 0?Math.floor(a(r)):c-1],f=e===void 0&&t===void 0?()=>!0:e===void 0?d=>d<=t:t===void 0?d=>d>=e:t>=e?d=>d>=e&&d<=t:d=>d>=e||d<=t,m=[];for(let d=p[0];d<=p[1];d++){const v=s(d);f(v)&&m.push([v,l(d)])}return m}function Z(n,e,t=!1){return t?O.geoContains(e,n):Se(n,e)}function We(n,e){const t={type:"Polygon",coordinates:n},[[r,i],[c,u]]=O.geoBounds(t);if(Math.min(Math.abs(c-r),Math.abs(u-i))<e)return[];const s=r>c||u>=89||i<=-89;return ke(e,{minLng:r,maxLng:c,minLat:i,maxLat:u}).filter(l=>Z(l,t,s))}function Ne(n,{resolution:e=1/0,bbox:t,projection:r}={}){const i=Oe(n,e),c=L.merge(i),u=We(n,e),s=[...c,...u],l={type:"Polygon",coordinates:n},[[a,p],[f,m]]=O.geoBounds(l),d=a>f||m>=89||p<=-89;let v=[];if(d){const y=xe.geoVoronoi(s).triangles(),x=new Map(s.map(([C,P],z)=>[`${C}-${P}`,z]));y.features.forEach(C=>{const P=C.geometry.coordinates[0].slice(0,3).reverse(),z=[];if(P.forEach(([B,R])=>{const k=`${B}-${R}`;x.has(k)&&z.push(x.get(k))}),z.length===3){if(z.some(B=>B<c.length)){const B=C.properties.circumcenter;if(!Z(B,l,d))return}v.push(...z)}})}else if(u.length){const y=Me.from(s);for(let x=0,C=y.triangles.length;x<C;x+=3){const P=[2,1,0].map(B=>y.triangles[x+B]),z=P.map(B=>s[B]);if(P.some(B=>B<c.length)){const B=[0,1].map(R=>L.mean(z,k=>k[R]));if(!Z(B,l,d))continue}v.push(...P)}}else{const{vertices:y,holes:x=[]}=X.flatten(i);v=X(y,x,2)}let h=t?[t[0],t[2]]:L.extent(s,y=>y[0]),b=t?[t[1],t[3]]:L.extent(s,y=>y[1]);if(r){const[y,x]=r([h[0],b[0]]),[C,P]=r([h[1],b[1]]);h=[y,C],b=[-x,-P]}const w=se.scaleLinear(h,[0,1]),I=se.scaleLinear(b,[0,1]),j=s.map(([y,x])=>{if(r){const[C,P]=r([y,x]);return[w(C),I(-P)]}else return[w(y),I(x)]});return{contour:i,triangles:{points:s,indices:v,uvs:j}}}const ue=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,r){const i=n.map(c=>c.map(([u,s])=>{if(r){const[l,a]=r([u,s]);return[l,-a,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(i)}function Ue(n,e,t,r,i){const{vertices:c,holes:u}=G(n,e,r,i),{vertices:s}=G(n,t,r,i),l=L.merge([s,c]),a=Math.round(s.length/3),p=new Set(u);let f=0;const m=[];for(let v=0;v<a;v++){let h=v+1;if(h===a)h=f;else if(p.has(h)){const b=h;h=f,f=b}m.push(v,v+a,h+a),m.push(h+a,h,v)}const d=[];for(let v=1;v>=0;v--)for(let h=0;h<a;h+=1)d.push(h/(a-1),v);return{indices:m,vertices:l,uvs:d,topVerts:s}}function de(n,e,t,r,i,c){return{indices:r?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,i,c).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:r=1,cartesian:i=!0,hasSide:c=!0,hasBottom:u=!1,hasTop:s=!1,projection:l,bbox:a})=>{n.forEach(w=>{ge(w)||w.reverse()});const{contour:p,triangles:f}=Ne(n,{resolution:r,bbox:a,projection:l});let m={},d;c&&(m=Ue(p,e!=null?e:t,t!=null?t:e,i,l),d=m.topVerts);let v=[];(u||s)&&(v=L.merge(f.uvs));let h={};u&&(h=de(f,e,v,!1,i,l));let b={};return s&&(b=de(f,t,v,!0,i,l)),{contour:p,triangles:f,sideTorso:m,bottomCap:h,topCap:b,topVerts:d}};class Ge extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:r,hasTop:i,topFirst:c,hasBottom:u,hasSide:s,cartesian:l,userDataRsoOffset:a,projection:p}=this.parameters,{contour:f,sideTorso:m,topVerts:d,bottomCap:v,topCap:h}=he(_({},this.parameters));let b=[],w=[],I=[],j=0;const A=y=>{const x=Math.round(b.length/3),C=I.length;b=b.concat(y.vertices),w=w.concat(y.uvs),I=I.concat(x?y.indices.map(P=>P+x):y.indices),this.addGroup(C,I.length-C,j++)};i&&c&&A(h),s&&(A(m),this.userData.topVerts=a?G(f,r+a,l,p).vertices:d),u&&A(v),i&&!c&&A(h),this.setIndex(I),this[ue]("position",new o.Float32BufferAttribute(b,3)),this[ue]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}exports.BLOOM_SCENE=je;exports.BaseObject=Y;exports.IS_DEV=Ce;exports.LineSegments2=ze;exports.MeshLineMaterial=_e;exports.PolygonGeometry=Ge;exports.ResourceTracker=fe;exports.getMetas=he;
|
|
@@ -10,6 +10,7 @@ export interface MeshLineMaterialParameters extends ShaderMaterialParameters {
|
|
|
10
10
|
* @default '#ffffff'
|
|
11
11
|
*/
|
|
12
12
|
color?: ColorRepresentation;
|
|
13
|
+
opacity?: number;
|
|
13
14
|
/**
|
|
14
15
|
* Texture map
|
|
15
16
|
*/
|
|
@@ -66,6 +67,8 @@ export declare class MeshLineMaterial extends ShaderMaterial {
|
|
|
66
67
|
constructor(parameters?: MeshLineMaterialParameters);
|
|
67
68
|
get color(): Color;
|
|
68
69
|
set color(value: ColorRepresentation);
|
|
70
|
+
get opacity(): number;
|
|
71
|
+
set opacity(value: number);
|
|
69
72
|
get map(): Texture | null;
|
|
70
73
|
set map(value: Texture | null);
|
|
71
74
|
get lineWidth(): number;
|