gl-draw 0.14.36 → 0.14.38
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/ResourceTracker.d.ts +1 -1
- package/dist/index.module2.js +93 -93
- package/dist/index2.js +4 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Material, Object3D, Texture, BufferGeometry } from 'three';
|
|
2
|
-
type Resource = Object3D | Material | Texture | BufferGeometry | ResourceTracker;
|
|
2
|
+
type Resource = Object3D | Material | Texture | BufferGeometry | ResourceTracker | HTMLVideoElement;
|
|
3
3
|
export default class ResourceTracker {
|
|
4
4
|
resources: Set<Resource>;
|
|
5
5
|
disposeWithMaterial: boolean;
|
package/dist/index.module2.js
CHANGED
|
@@ -26,19 +26,19 @@ var st = (a, t, e) => new Promise((i, s) => {
|
|
|
26
26
|
}, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(r, o);
|
|
27
27
|
n((e = e.apply(a, t)).next());
|
|
28
28
|
});
|
|
29
|
-
import { Material as nt, Object3D as G, Texture as rt, BufferGeometry as
|
|
30
|
-
import { CSS2DObject as
|
|
31
|
-
import { CSS3DObject as
|
|
32
|
-
import { geoBounds as wt, geoContains as
|
|
29
|
+
import { Material as nt, Object3D as G, Texture as rt, VideoTexture as Dt, BufferGeometry as H, Float32BufferAttribute as F, PointsMaterial as It, Points as X, Mesh as xt, Group as Tt, Sprite as at, Box3 as Mt, Vector3 as C, InstancedMesh as ot, Quaternion as Wt, Vector4 as V, Matrix4 as Bt, Line3 as _t, Sphere as Lt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as lt, MathUtils as Vt, ShaderMaterial as kt, UniformsLib as Et, Color as ct, Vector2 as E, REVISION as Ut } from "three";
|
|
30
|
+
import { CSS2DObject as Rt } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
31
|
+
import { CSS3DObject as Gt, CSS3DSprite as Ft } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
32
|
+
import { geoBounds as wt, geoContains as Zt, geoDistance as $t, geoInterpolate as qt } from "d3-geo";
|
|
33
33
|
import "d3-geo-projection";
|
|
34
|
-
import { p as ut, a as
|
|
35
|
-
import { LineSegmentsGeometry as
|
|
36
|
-
import { merge as
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
34
|
+
import { p as ut, a as Nt } from "./parseVector.module.js";
|
|
35
|
+
import { LineSegmentsGeometry as Qt } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
36
|
+
import { merge as J, mean as Kt, extent as ht } from "d3-array";
|
|
37
|
+
import Xt, { flatten as Pt } from "earcut";
|
|
38
|
+
import Yt from "@turf/boolean-clockwise";
|
|
39
|
+
import Ht from "delaunator";
|
|
40
40
|
import Jt from "@turf/boolean-point-in-polygon";
|
|
41
|
-
import { geoVoronoi as
|
|
41
|
+
import { geoVoronoi as te } from "d3-geo-voronoi";
|
|
42
42
|
import { scaleLinear as ft } from "d3-scale";
|
|
43
43
|
class O {
|
|
44
44
|
constructor() {
|
|
@@ -67,20 +67,20 @@ class O {
|
|
|
67
67
|
(s instanceof rt || Array.isArray(s)) && this.track(s);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
} else t instanceof Dt && t.source.data && this.resources.add(t.source.data);
|
|
71
71
|
return t;
|
|
72
72
|
}
|
|
73
73
|
dispose() {
|
|
74
74
|
const t = [];
|
|
75
75
|
for (const e of this.resources)
|
|
76
|
-
e instanceof G
|
|
76
|
+
e instanceof G ? t.push(e) : e instanceof HTMLVideoElement && (e.pause(), e.src = "", e.remove()), Reflect.has(e, "dispose") && e.dispose();
|
|
77
77
|
t.forEach((e) => {
|
|
78
78
|
e.removeFromParent();
|
|
79
79
|
}), t.length = 0, this.resources.clear();
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
const e = new
|
|
82
|
+
const ee = (a, t = 1) => {
|
|
83
|
+
const e = new H();
|
|
84
84
|
e.setAttribute(
|
|
85
85
|
"position",
|
|
86
86
|
new F(new Array(t * 3).fill(0), 3)
|
|
@@ -88,7 +88,7 @@ const te = (a, t = 1) => {
|
|
|
88
88
|
"scaleAtt",
|
|
89
89
|
new F(new Array(t).fill(1), 1)
|
|
90
90
|
);
|
|
91
|
-
const i = a.material, s = new
|
|
91
|
+
const i = a.material, s = new It({
|
|
92
92
|
size: 10,
|
|
93
93
|
map: i.map,
|
|
94
94
|
alphaMap: i.alphaMap,
|
|
@@ -111,7 +111,7 @@ const te = (a, t = 1) => {
|
|
|
111
111
|
`;
|
|
112
112
|
}, new X(e, s);
|
|
113
113
|
};
|
|
114
|
-
class
|
|
114
|
+
class ie extends O {
|
|
115
115
|
constructor() {
|
|
116
116
|
super(...arguments), this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.materialList = {}, this.useMaterialType = "origin", this.onPointerIndex = [];
|
|
117
117
|
}
|
|
@@ -171,19 +171,19 @@ class ee extends O {
|
|
|
171
171
|
return this.object3d = new xt(...t), this;
|
|
172
172
|
}
|
|
173
173
|
createGroup() {
|
|
174
|
-
return this.object3d = new
|
|
174
|
+
return this.object3d = new Tt(), this;
|
|
175
175
|
}
|
|
176
176
|
createPoints(...t) {
|
|
177
177
|
return this.object3d = new X(...t), this;
|
|
178
178
|
}
|
|
179
179
|
createCSS2DObject(t) {
|
|
180
|
-
return this.object3d = new
|
|
180
|
+
return this.object3d = new Rt(t), this;
|
|
181
181
|
}
|
|
182
182
|
createCSS3DObject(t) {
|
|
183
|
-
return this.object3d = new
|
|
183
|
+
return this.object3d = new Gt(t), this;
|
|
184
184
|
}
|
|
185
185
|
createCSS3DSprite(t) {
|
|
186
|
-
return this.object3d = new
|
|
186
|
+
return this.object3d = new Ft(t), this;
|
|
187
187
|
}
|
|
188
188
|
createSprite(t) {
|
|
189
189
|
return this.object3d = new at(t), this;
|
|
@@ -220,7 +220,7 @@ class ee extends O {
|
|
|
220
220
|
if (i) {
|
|
221
221
|
const m = t.length;
|
|
222
222
|
if (this.object3d instanceof at)
|
|
223
|
-
u.object3d =
|
|
223
|
+
u.object3d = ee(this.object3d, m);
|
|
224
224
|
else {
|
|
225
225
|
const f = this.object3d;
|
|
226
226
|
u.object3d = new ot(
|
|
@@ -326,25 +326,25 @@ class ee extends O {
|
|
|
326
326
|
this.disposeWithMaterial = !1, this.dispose();
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
class
|
|
329
|
+
class ze extends ie {
|
|
330
330
|
create() {
|
|
331
331
|
this.createGroup();
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
const N = new V(), dt = new C(), pt = new C(), b = new V(), y = new V(), I = new V(), Q = new C(), K = new Bt(), x = new _t(), mt = new C(),
|
|
335
|
-
let
|
|
334
|
+
const N = new V(), dt = new C(), pt = new C(), b = new V(), y = new V(), I = new V(), Q = new C(), K = new Bt(), x = new _t(), mt = new C(), U = new Mt(), R = new Lt(), T = new V();
|
|
335
|
+
let W, _;
|
|
336
336
|
function vt(a, t, e) {
|
|
337
|
-
return
|
|
337
|
+
return T.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = _ / e.width, T.y = _ / e.height, T.applyMatrix4(a.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function se(a, t) {
|
|
340
340
|
const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, r = i.attributes.instanceEnd, o = Math.min(i.instanceCount, s.count);
|
|
341
341
|
for (let n = 0, l = o; n < l; n++) {
|
|
342
342
|
x.start.fromBufferAttribute(s, n), x.end.fromBufferAttribute(r, n), x.applyMatrix4(e);
|
|
343
343
|
const c = new C(), d = new C();
|
|
344
|
-
|
|
344
|
+
W.distanceSqToSegment(x.start, x.end, d, c), d.distanceTo(c) < _ * 0.5 && t.push({
|
|
345
345
|
point: d,
|
|
346
346
|
pointOnLine: c,
|
|
347
|
-
distance:
|
|
347
|
+
distance: W.origin.distanceTo(d),
|
|
348
348
|
object: a,
|
|
349
349
|
face: null,
|
|
350
350
|
faceIndex: n,
|
|
@@ -353,9 +353,9 @@ function ie(a, t) {
|
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function ne(a, t, e) {
|
|
357
357
|
const i = t.projectionMatrix, r = a.material.resolution, o = a.matrixWorld, n = a.geometry, l = n.attributes.instanceStart, c = n.attributes.instanceEnd, d = Math.min(n.instanceCount, l.count), u = -t.near;
|
|
358
|
-
|
|
358
|
+
W.at(1, I), I.w = 1, I.applyMatrix4(t.matrixWorldInverse), I.applyMatrix4(i), I.multiplyScalar(1 / I.w), I.x *= r.x / 2, I.y *= r.y / 2, I.z = 0, Q.copy(I), K.multiplyMatrices(t.matrixWorldInverse, o);
|
|
359
359
|
for (let m = 0, h = d; m < h; m++) {
|
|
360
360
|
if (b.fromBufferAttribute(l, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(K), y.applyMatrix4(K), b.z > u && y.z > u)
|
|
361
361
|
continue;
|
|
@@ -369,14 +369,14 @@ function se(a, t, e) {
|
|
|
369
369
|
b.applyMatrix4(i), y.applyMatrix4(i), b.multiplyScalar(1 / b.w), y.multiplyScalar(1 / y.w), b.x *= r.x / 2, b.y *= r.y / 2, y.x *= r.x / 2, y.y *= r.y / 2, x.start.copy(b), x.start.z = 0, x.end.copy(y), x.end.z = 0;
|
|
370
370
|
const p = x.closestPointToPointParameter(Q, !0);
|
|
371
371
|
x.at(p, mt);
|
|
372
|
-
const g =
|
|
372
|
+
const g = Vt.lerp(b.z, y.z, p), w = g >= -1 && g <= 1, z = Q.distanceTo(mt) < _ * 0.5;
|
|
373
373
|
if (w && z) {
|
|
374
374
|
x.start.fromBufferAttribute(l, m), x.end.fromBufferAttribute(c, m), x.start.applyMatrix4(o), x.end.applyMatrix4(o);
|
|
375
375
|
const D = new C(), P = new C();
|
|
376
|
-
|
|
376
|
+
W.distanceSqToSegment(x.start, x.end, P, D), e.push({
|
|
377
377
|
point: P,
|
|
378
378
|
pointOnLine: D,
|
|
379
|
-
distance:
|
|
379
|
+
distance: W.origin.distanceTo(P),
|
|
380
380
|
object: a,
|
|
381
381
|
face: null,
|
|
382
382
|
faceIndex: m,
|
|
@@ -386,8 +386,8 @@ function se(a, t, e) {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
class
|
|
390
|
-
constructor(t = new
|
|
389
|
+
class De extends xt {
|
|
390
|
+
constructor(t = new Qt(), e) {
|
|
391
391
|
super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
|
|
392
392
|
}
|
|
393
393
|
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
@@ -395,7 +395,7 @@ class ze extends xt {
|
|
|
395
395
|
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
|
|
396
396
|
for (let o = 0, n = 0, l = e.count; o < l; o++, n += 2)
|
|
397
397
|
dt.fromBufferAttribute(e, o), pt.fromBufferAttribute(i, o), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + dt.distanceTo(pt);
|
|
398
|
-
const r = new
|
|
398
|
+
const r = new Ot(
|
|
399
399
|
s,
|
|
400
400
|
2,
|
|
401
401
|
1
|
|
@@ -414,16 +414,16 @@ class ze extends xt {
|
|
|
414
414
|
'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
|
|
415
415
|
);
|
|
416
416
|
const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
|
|
417
|
-
|
|
417
|
+
W = t.ray;
|
|
418
418
|
const o = this.matrixWorld, n = this.geometry, l = this.material;
|
|
419
|
-
|
|
419
|
+
_ = l.linewidth + r, n.boundingSphere === null && n.computeBoundingSphere(), R.copy(n.boundingSphere).applyMatrix4(o);
|
|
420
420
|
let c;
|
|
421
421
|
if (i)
|
|
422
|
-
c =
|
|
422
|
+
c = _ * 0.5;
|
|
423
423
|
else {
|
|
424
424
|
const u = Math.max(
|
|
425
425
|
s.near,
|
|
426
|
-
R.distanceToPoint(
|
|
426
|
+
R.distanceToPoint(W.origin)
|
|
427
427
|
);
|
|
428
428
|
c = vt(
|
|
429
429
|
s,
|
|
@@ -431,16 +431,16 @@ class ze extends xt {
|
|
|
431
431
|
l.resolution
|
|
432
432
|
);
|
|
433
433
|
}
|
|
434
|
-
if (R.radius += c,
|
|
434
|
+
if (R.radius += c, W.intersectsSphere(R) === !1)
|
|
435
435
|
return;
|
|
436
|
-
n.boundingBox === null && n.computeBoundingBox(),
|
|
436
|
+
n.boundingBox === null && n.computeBoundingBox(), U.copy(n.boundingBox).applyMatrix4(o);
|
|
437
437
|
let d;
|
|
438
438
|
if (i)
|
|
439
|
-
d =
|
|
439
|
+
d = _ * 0.5;
|
|
440
440
|
else {
|
|
441
441
|
const u = Math.max(
|
|
442
442
|
s.near,
|
|
443
|
-
|
|
443
|
+
U.distanceToPoint(W.origin)
|
|
444
444
|
);
|
|
445
445
|
d = vt(
|
|
446
446
|
s,
|
|
@@ -448,14 +448,14 @@ class ze extends xt {
|
|
|
448
448
|
l.resolution
|
|
449
449
|
);
|
|
450
450
|
}
|
|
451
|
-
|
|
451
|
+
U.expandByScalar(d), W.intersectsBox(U) !== !1 && (i ? se(this, e) : ne(this, s, e));
|
|
452
452
|
}
|
|
453
453
|
onBeforeRender(t) {
|
|
454
454
|
const e = this.material.uniforms;
|
|
455
455
|
e && e.resolution && (t.getViewport(N), this.material.uniforms.resolution.value.set(N.z, N.w));
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
const gt = ["encodings_fragment", "colorspace_fragment"],
|
|
458
|
+
const gt = ["encodings_fragment", "colorspace_fragment"], re = (
|
|
459
459
|
/* glsl */
|
|
460
460
|
`
|
|
461
461
|
#include <common>
|
|
@@ -551,7 +551,7 @@ const gt = ["encodings_fragment", "colorspace_fragment"], ne = (
|
|
|
551
551
|
#include <fog_vertex>
|
|
552
552
|
}
|
|
553
553
|
`
|
|
554
|
-
),
|
|
554
|
+
), ae = (
|
|
555
555
|
/* glsl */
|
|
556
556
|
`
|
|
557
557
|
#include <packing>
|
|
@@ -607,10 +607,10 @@ const gt = ["encodings_fragment", "colorspace_fragment"], ne = (
|
|
|
607
607
|
}
|
|
608
608
|
`
|
|
609
609
|
);
|
|
610
|
-
class
|
|
610
|
+
class Ie extends kt {
|
|
611
611
|
constructor(t) {
|
|
612
612
|
super({
|
|
613
|
-
uniforms: q(L({},
|
|
613
|
+
uniforms: q(L({}, Et.fog), {
|
|
614
614
|
lineWidth: { value: 1 },
|
|
615
615
|
map: { value: null },
|
|
616
616
|
useMap: { value: 0 },
|
|
@@ -618,7 +618,7 @@ class De extends Vt {
|
|
|
618
618
|
useAlphaMap: { value: 0 },
|
|
619
619
|
color: { value: new ct(16777215) },
|
|
620
620
|
opacity: { value: 1 },
|
|
621
|
-
resolution: { value: new
|
|
621
|
+
resolution: { value: new E(1, 1) },
|
|
622
622
|
sizeAttenuation: { value: 1 },
|
|
623
623
|
dashArray: { value: 0 },
|
|
624
624
|
dashOffset: { value: 0 },
|
|
@@ -627,19 +627,19 @@ class De extends Vt {
|
|
|
627
627
|
useDepth: { value: 0 },
|
|
628
628
|
visibility: { value: 1 },
|
|
629
629
|
alphaTest: { value: 0 },
|
|
630
|
-
repeat: { value: new
|
|
631
|
-
offset: { value: new
|
|
630
|
+
repeat: { value: new E(1, 1) },
|
|
631
|
+
offset: { value: new E(0, 0) },
|
|
632
632
|
offsetLoop: { value: 1 },
|
|
633
633
|
lineLightAnimation: { value: 0 },
|
|
634
634
|
time: { value: 0 },
|
|
635
635
|
size: { value: 300 },
|
|
636
636
|
speed: { value: 0.3 },
|
|
637
637
|
lightWidth: { value: 0.1 },
|
|
638
|
-
uCenter: { value: new
|
|
638
|
+
uCenter: { value: new E(0, 0) },
|
|
639
639
|
lightColor: { value: new ct(16777215) }
|
|
640
640
|
}),
|
|
641
|
-
vertexShader:
|
|
642
|
-
fragmentShader:
|
|
641
|
+
vertexShader: re,
|
|
642
|
+
fragmentShader: ae
|
|
643
643
|
}), this.type = "MeshLineMaterial", Object.defineProperties(this, {
|
|
644
644
|
lineWidth: {
|
|
645
645
|
enumerable: !0,
|
|
@@ -863,15 +863,15 @@ class De extends Vt {
|
|
|
863
863
|
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;
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
-
function
|
|
866
|
+
function oe(a, t) {
|
|
867
867
|
return a.map((e) => {
|
|
868
868
|
const i = [];
|
|
869
869
|
let s;
|
|
870
870
|
return e.forEach((r) => {
|
|
871
871
|
if (s) {
|
|
872
|
-
const o =
|
|
872
|
+
const o = $t(r, s) * 180 / Math.PI;
|
|
873
873
|
if (o > t) {
|
|
874
|
-
const n =
|
|
874
|
+
const n = qt(s, r), l = 1 / Math.ceil(o / t);
|
|
875
875
|
let c = l;
|
|
876
876
|
for (; c < 1; )
|
|
877
877
|
i.push(n(c)), c += l;
|
|
@@ -881,7 +881,7 @@ function ae(a, t) {
|
|
|
881
881
|
}), i;
|
|
882
882
|
});
|
|
883
883
|
}
|
|
884
|
-
function
|
|
884
|
+
function le(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
885
885
|
const r = Math.round(it(360 / a, 2) / Math.PI), o = (1 + Math.sqrt(5)) / 2, n = (h) => h / o * 360 % 360 - 180, l = (h) => Math.acos(2 * h / r - 1) / Math.PI * 180 - 90, c = (h) => r * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, d = [
|
|
886
886
|
s !== void 0 ? Math.ceil(c(s)) : 0,
|
|
887
887
|
i !== void 0 ? Math.floor(c(i)) : r - 1
|
|
@@ -893,14 +893,14 @@ function oe(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
|
893
893
|
return m;
|
|
894
894
|
}
|
|
895
895
|
function Y(a, t, e = !1) {
|
|
896
|
-
return e ?
|
|
896
|
+
return e ? Zt(t, a) : Jt(a, t);
|
|
897
897
|
}
|
|
898
|
-
function
|
|
898
|
+
function ce(a, t) {
|
|
899
899
|
const e = { type: "Polygon", coordinates: a }, [[i, s], [r, o]] = wt(e);
|
|
900
900
|
if (Math.min(Math.abs(r - i), Math.abs(o - s)) < t)
|
|
901
901
|
return [];
|
|
902
902
|
const n = i > r || o >= 89 || s <= -89;
|
|
903
|
-
return
|
|
903
|
+
return le(t, {
|
|
904
904
|
minLng: i,
|
|
905
905
|
maxLng: r,
|
|
906
906
|
minLat: s,
|
|
@@ -909,22 +909,22 @@ function le(a, t) {
|
|
|
909
909
|
(l) => Y(l, e, n)
|
|
910
910
|
);
|
|
911
911
|
}
|
|
912
|
-
function
|
|
913
|
-
const s =
|
|
912
|
+
function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
913
|
+
const s = oe(a, t), r = J(s), o = ce(a, t), n = [...r, ...o], l = { type: "Polygon", coordinates: a }, [[c, d], [u, m]] = wt(l), h = c > u || // crosses antimeridian
|
|
914
914
|
m >= 89 || // crosses north pole
|
|
915
915
|
d <= -89;
|
|
916
916
|
let f = [];
|
|
917
917
|
if (h) {
|
|
918
|
-
const v =
|
|
919
|
-
n.map(([A, j],
|
|
918
|
+
const v = te(n).triangles(), M = new Map(
|
|
919
|
+
n.map(([A, j], B) => [`${A}-${j}`, B])
|
|
920
920
|
);
|
|
921
921
|
v.features.forEach((A) => {
|
|
922
|
-
const j = A.geometry.coordinates[0].slice(0, 3).reverse(),
|
|
922
|
+
const j = A.geometry.coordinates[0].slice(0, 3).reverse(), B = [];
|
|
923
923
|
if (j.forEach(([S, $]) => {
|
|
924
924
|
const k = `${S}-${$}`;
|
|
925
|
-
M.has(k) &&
|
|
926
|
-
}),
|
|
927
|
-
if (
|
|
925
|
+
M.has(k) && B.push(M.get(k));
|
|
926
|
+
}), B.length === 3) {
|
|
927
|
+
if (B.some((S) => S < r.length)) {
|
|
928
928
|
const S = A.properties.circumcenter;
|
|
929
929
|
if (!Y(
|
|
930
930
|
S,
|
|
@@ -933,16 +933,16 @@ function ce(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
933
933
|
))
|
|
934
934
|
return;
|
|
935
935
|
}
|
|
936
|
-
f.push(...
|
|
936
|
+
f.push(...B);
|
|
937
937
|
}
|
|
938
938
|
});
|
|
939
939
|
} else if (o.length) {
|
|
940
|
-
const v =
|
|
940
|
+
const v = Ht.from(n);
|
|
941
941
|
for (let M = 0, A = v.triangles.length; M < A; M += 3) {
|
|
942
|
-
const j = [2, 1, 0].map((S) => v.triangles[M + S]),
|
|
942
|
+
const j = [2, 1, 0].map((S) => v.triangles[M + S]), B = j.map((S) => n[S]);
|
|
943
943
|
if (j.some((S) => S < r.length)) {
|
|
944
944
|
const S = [0, 1].map(
|
|
945
|
-
($) =>
|
|
945
|
+
($) => Kt(B, (k) => k[$])
|
|
946
946
|
);
|
|
947
947
|
if (!Y(
|
|
948
948
|
S,
|
|
@@ -955,7 +955,7 @@ function ce(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
955
955
|
}
|
|
956
956
|
} else {
|
|
957
957
|
const { vertices: v, holes: M = [] } = Pt(s);
|
|
958
|
-
f =
|
|
958
|
+
f = Xt(v, M, 2);
|
|
959
959
|
}
|
|
960
960
|
let p = e ? [e[0], e[2]] : ht(n, (v) => v[0]), g = e ? [e[1], e[3]] : ht(n, (v) => v[1]);
|
|
961
961
|
if (i) {
|
|
@@ -971,7 +971,7 @@ function ce(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
971
971
|
});
|
|
972
972
|
return { contour: s, triangles: { points: n, indices: f, uvs: D } };
|
|
973
973
|
}
|
|
974
|
-
const bt = new
|
|
974
|
+
const bt = new H().setAttribute ? "setAttribute" : "addAttribute";
|
|
975
975
|
function Z(a, t, e, i) {
|
|
976
976
|
const s = a.map(
|
|
977
977
|
(r) => r.map(([o, n]) => {
|
|
@@ -979,12 +979,12 @@ function Z(a, t, e, i) {
|
|
|
979
979
|
const [l, c] = i([o, n]);
|
|
980
980
|
return [l, -c, t];
|
|
981
981
|
}
|
|
982
|
-
return e ?
|
|
982
|
+
return e ? Nt(o, n, t) : [o, n, t];
|
|
983
983
|
})
|
|
984
984
|
);
|
|
985
985
|
return Pt(s);
|
|
986
986
|
}
|
|
987
|
-
function
|
|
987
|
+
function he(a, t, e, i, s) {
|
|
988
988
|
const { vertices: r, holes: o } = Z(
|
|
989
989
|
a,
|
|
990
990
|
t,
|
|
@@ -995,7 +995,7 @@ function ue(a, t, e, i, s) {
|
|
|
995
995
|
e,
|
|
996
996
|
i,
|
|
997
997
|
s
|
|
998
|
-
), l =
|
|
998
|
+
), l = J([n, r]), c = Math.round(n.length / 3), d = new Set(o);
|
|
999
999
|
let u = 0;
|
|
1000
1000
|
const m = [];
|
|
1001
1001
|
for (let f = 0; f < c; f++) {
|
|
@@ -1025,7 +1025,7 @@ function yt(a, t, e, i, s, r) {
|
|
|
1025
1025
|
uvs: e
|
|
1026
1026
|
};
|
|
1027
1027
|
}
|
|
1028
|
-
const
|
|
1028
|
+
const fe = ({
|
|
1029
1029
|
polygonGeoJson: a,
|
|
1030
1030
|
startHeight: t,
|
|
1031
1031
|
endHeight: e,
|
|
@@ -1038,15 +1038,15 @@ const he = ({
|
|
|
1038
1038
|
bbox: c
|
|
1039
1039
|
}) => {
|
|
1040
1040
|
a.forEach((w) => {
|
|
1041
|
-
|
|
1041
|
+
Yt(w) || w.reverse();
|
|
1042
1042
|
});
|
|
1043
|
-
const { contour: d, triangles: u } =
|
|
1043
|
+
const { contour: d, triangles: u } = ue(a, {
|
|
1044
1044
|
resolution: i,
|
|
1045
1045
|
bbox: c,
|
|
1046
1046
|
projection: l
|
|
1047
1047
|
});
|
|
1048
1048
|
let m = {}, h;
|
|
1049
|
-
r && (m =
|
|
1049
|
+
r && (m = he(
|
|
1050
1050
|
d,
|
|
1051
1051
|
t != null ? t : e,
|
|
1052
1052
|
e != null ? e : t,
|
|
@@ -1054,7 +1054,7 @@ const he = ({
|
|
|
1054
1054
|
l
|
|
1055
1055
|
), h = m.topVerts);
|
|
1056
1056
|
let f = [];
|
|
1057
|
-
(o || n) && (f =
|
|
1057
|
+
(o || n) && (f = J(u.uvs));
|
|
1058
1058
|
let p = {};
|
|
1059
1059
|
o && (p = yt(
|
|
1060
1060
|
u,
|
|
@@ -1074,7 +1074,7 @@ const he = ({
|
|
|
1074
1074
|
l
|
|
1075
1075
|
)), { contour: d, triangles: u, sideTorso: m, bottomCap: p, topCap: g, topVerts: h };
|
|
1076
1076
|
};
|
|
1077
|
-
class
|
|
1077
|
+
class Te extends H {
|
|
1078
1078
|
constructor(t, e = {}) {
|
|
1079
1079
|
super(), this.type = "PolygonBufferGeometry", this.parameters = L({
|
|
1080
1080
|
polygonGeoJson: t,
|
|
@@ -1097,7 +1097,7 @@ class Ie extends J {
|
|
|
1097
1097
|
cartesian: l,
|
|
1098
1098
|
userDataRsoOffset: c,
|
|
1099
1099
|
projection: d
|
|
1100
|
-
} = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: p } =
|
|
1100
|
+
} = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: p } = fe(L({}, this.parameters));
|
|
1101
1101
|
let g = [], w = [], z = [], D = 0;
|
|
1102
1102
|
const P = (v) => {
|
|
1103
1103
|
const M = Math.round(g.length / 3), A = z.length;
|
|
@@ -1114,11 +1114,11 @@ class Ie extends J {
|
|
|
1114
1114
|
}
|
|
1115
1115
|
}
|
|
1116
1116
|
export {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1117
|
+
ie as B,
|
|
1118
|
+
ze as G,
|
|
1119
|
+
De as L,
|
|
1120
|
+
Ie as M,
|
|
1121
|
+
Te as P,
|
|
1122
1122
|
O as R,
|
|
1123
|
-
|
|
1123
|
+
fe as g
|
|
1124
1124
|
};
|
package/dist/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var ft=Object.defineProperty,dt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var
|
|
1
|
+
"use strict";var ft=Object.defineProperty,dt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var J=Math.pow,H=(o,t,e)=>t in o?ft(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,O=(o,t)=>{for(var e in t||(t={}))mt.call(t,e)&&H(o,e,t[e]);if(Y)for(var e of Y(t))vt.call(t,e)&&H(o,e,t[e]);return o},F=(o,t)=>dt(o,pt(t));var tt=(o,t,e)=>new Promise((i,s)=>{var a=c=>{try{r(e.next(c))}catch(u){s(u)}},l=c=>{try{r(e.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,l);r((e=e.apply(o,t)).next())});const n=require("three"),gt=require("three/examples/jsm/renderers/CSS2DRenderer"),et=require("three/examples/jsm/renderers/CSS3DRenderer"),k=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),bt=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),yt=require("@turf/boolean-clockwise"),xt=require("delaunator"),Mt=require("@turf/boolean-point-in-polygon"),wt=require("d3-geo-voronoi"),it=require("d3-scale");class _{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 n.Material)return t;if(t instanceof _?(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 n.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof _)this.track(t.children);else if(t instanceof n.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof n.Material){for(const i of Object.values(t))i instanceof n.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 n.Texture||Array.isArray(s))&&this.track(s)}}}else t instanceof n.VideoTexture&&t.source.data&&this.resources.add(t.source.data);return t}dispose(){const t=[];for(const e of this.resources)e instanceof n.Object3D?t.push(e):e instanceof HTMLVideoElement&&(e.pause(),e.src="",e.remove()),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const Pt=(o,t=1)=>{const e=new n.BufferGeometry;e.setAttribute("position",new n.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new n.Float32BufferAttribute(new Array(t).fill(1),1));const i=o.material,s=new n.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
3
|
${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
-
`},new n.Points(e,s)};class ut extends _{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!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 n.Mesh(...t),this}createGroup(){return this.object3d=new n.Group,this}createPoints(...t){return this.object3d=new n.Points(...t),this}createCSS2DObject(t){return this.object3d=new gt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new et.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new et.CSS3DSprite(t),this}createSprite(t){return this.object3d=new n.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new n.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new n.Vector3),center:t.getCenter(new n.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return tt(this,null,function*(){var p;const i=t&&t.length>0,s=(p=e==null?void 0:e.recursive)!=null?p:!0,{objectType:a,objectOptions:l}=this,[,r]=a.split("#");let c=e==null?void 0:e.create;c===void 0&&(c=h=>{if(this.object3d){if(i){const v=t.length;if(this.object3d instanceof n.Sprite)h.object3d=Pt(this.object3d,v);else{const d=this.object3d;h.object3d=new n.InstancedMesh(d.geometry,d.material,v),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate")}const f=new n.Object3D;t.forEach((d,m)=>{const b=Q.parseVector3(d.position),P=Q.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(m,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate");h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(r,F(O({},l||{}),{create:c,prefab:!1,key:(e==null?void 0:e.key)||(l==null?void 0:l.key),target:(e==null?void 0:e.target)||(l==null?void 0:l.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(t,e){if(this.object3d instanceof n.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof n.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,l=s.attributes.scaleAtt.array,r=new n.Vector3,c=new n.Vector3,u=new n.Quaternion,p=t*3,h=t*1;e.decompose(r,u,c),a[p]=r.x,a[p+1]=r.y,a[p+2]=r.z,l[h]=Math.max(c.x,c.y,c.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 l=this.materialList[t],r=new _;r.track(l),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)}enableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var t;this.onPointerIndex.forEach(e=>{this.lead.removePick(e)}),(t=this.pencil.composerController)==null||t.bloomSelection.delete(this),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 At extends ut{create(){this.createGroup()}}const Z=new n.Vector4,st=new n.Vector3,rt=new n.Vector3,y=new n.Vector4,x=new n.Vector4,
|
|
4
|
+
`},new n.Points(e,s)};class ut extends _{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!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 n.Mesh(...t),this}createGroup(){return this.object3d=new n.Group,this}createPoints(...t){return this.object3d=new n.Points(...t),this}createCSS2DObject(t){return this.object3d=new gt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new et.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new et.CSS3DSprite(t),this}createSprite(t){return this.object3d=new n.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new n.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new n.Vector3),center:t.getCenter(new n.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return tt(this,null,function*(){var p;const i=t&&t.length>0,s=(p=e==null?void 0:e.recursive)!=null?p:!0,{objectType:a,objectOptions:l}=this,[,r]=a.split("#");let c=e==null?void 0:e.create;c===void 0&&(c=h=>{if(this.object3d){if(i){const v=t.length;if(this.object3d instanceof n.Sprite)h.object3d=Pt(this.object3d,v);else{const d=this.object3d;h.object3d=new n.InstancedMesh(d.geometry,d.material,v),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate")}const f=new n.Object3D;t.forEach((d,m)=>{const b=Q.parseVector3(d.position),P=Q.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(P),f.updateMatrix(),h.setInstancedMatrix(m,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.setMaterialList("instantiate","clone"),h.useMaterial("instantiate");h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(r,F(O({},l||{}),{create:c,prefab:!1,key:(e==null?void 0:e.key)||(l==null?void 0:l.key),target:(e==null?void 0:e.target)||(l==null?void 0:l.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(t,e){if(this.object3d instanceof n.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof n.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,l=s.attributes.scaleAtt.array,r=new n.Vector3,c=new n.Vector3,u=new n.Quaternion,p=t*3,h=t*1;e.decompose(r,u,c),a[p]=r.x,a[p+1]=r.y,a[p+2]=r.z,l[h]=Math.max(c.x,c.y,c.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 l=this.materialList[t],r=new _;r.track(l),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)}enableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var t;(t=this.pencil.composerController)==null||t.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var t;this.onPointerIndex.forEach(e=>{this.lead.removePick(e)}),(t=this.pencil.composerController)==null||t.bloomSelection.delete(this),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 At extends ut{create(){this.createGroup()}}const Z=new n.Vector4,st=new n.Vector3,rt=new n.Vector3,y=new n.Vector4,x=new n.Vector4,z=new n.Vector4,$=new n.Vector3,N=new n.Matrix4,M=new n.Line3,nt=new n.Vector3,R=new n.Box3,E=new n.Sphere,B=new n.Vector4;let I,L;function at(o,t,e){return B.set(0,0,-t,1).applyMatrix4(o.projectionMatrix),B.multiplyScalar(1/B.w),B.x=L/e.width,B.y=L/e.height,B.applyMatrix4(o.projectionMatrixInverse),B.multiplyScalar(1/B.w),Math.abs(Math.max(B.x,B.y))}function St(o,t){const e=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){M.start.fromBufferAttribute(s,r),M.end.fromBufferAttribute(a,r),M.applyMatrix4(e);const u=new n.Vector3,p=new n.Vector3;I.distanceSqToSegment(M.start,M.end,p,u),p.distanceTo(u)<L*.5&&t.push({point:p,pointOnLine:u,distance:I.origin.distanceTo(p),object:o,face:null,faceIndex:r,uv:null,uv1:null})}}function jt(o,t,e){const i=t.projectionMatrix,a=o.material.resolution,l=o.matrixWorld,r=o.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,p=Math.min(r.instanceCount,c.count),h=-t.near;I.at(1,z),z.w=1,z.applyMatrix4(t.matrixWorldInverse),z.applyMatrix4(i),z.multiplyScalar(1/z.w),z.x*=a.x/2,z.y*=a.y/2,z.z=0,$.copy(z),N.multiplyMatrices(t.matrixWorldInverse,l);for(let v=0,f=p;v<f;v++){if(y.fromBufferAttribute(c,v),x.fromBufferAttribute(u,v),y.w=1,x.w=1,y.applyMatrix4(N),x.applyMatrix4(N),y.z>h&&x.z>h)continue;if(y.z>h){const V=y.z-x.z,A=(y.z-h)/V;y.lerp(x,A)}else if(x.z>h){const V=x.z-y.z,A=(x.z-h)/V;x.lerp(y,A)}y.applyMatrix4(i),x.applyMatrix4(i),y.multiplyScalar(1/y.w),x.multiplyScalar(1/x.w),y.x*=a.x/2,y.y*=a.y/2,x.x*=a.x/2,x.y*=a.y/2,M.start.copy(y),M.start.z=0,M.end.copy(x),M.end.z=0;const m=M.closestPointToPointParameter($,!0);M.at(m,nt);const b=n.MathUtils.lerp(y.z,x.z,m),P=b>=-1&&b<=1,D=$.distanceTo(nt)<L*.5;if(P&&D){M.start.fromBufferAttribute(c,v),M.end.fromBufferAttribute(u,v),M.start.applyMatrix4(l),M.end.applyMatrix4(l);const V=new n.Vector3,A=new n.Vector3;I.distanceSqToSegment(M.start,M.end,A,V),e.push({point:A,pointOnLine:V,distance:I.origin.distanceTo(A),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ct extends n.Mesh{constructor(t=new bt.LineSegmentsGeometry,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,s=new Float32Array(2*e.count);for(let l=0,r=0,c=e.count;l<c;l++,r+=2)st.fromBufferAttribute(e,l),rt.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+st.distanceTo(rt);const a=new n.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(a,1,0)),t.setAttribute("instanceDistanceEnd",new n.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;I=t.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;L=c.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),E.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=L*.5;else{const h=Math.max(s.near,E.distanceToPoint(I.origin));u=at(s,h,c.resolution)}if(E.radius+=u,I.intersectsSphere(E)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),R.copy(r.boundingBox).applyMatrix4(l);let p;if(i)p=L*.5;else{const h=Math.max(s.near,R.distanceToPoint(I.origin));p=at(s,h,c.resolution)}R.expandByScalar(p),I.intersectsBox(R)!==!1&&(i?St(this,e):jt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(Z),this.material.uniforms.resolution.value.set(Z.z,Z.w))}}const ot=["encodings_fragment","colorspace_fragment"],Dt=`
|
|
5
5
|
#include <common>
|
|
6
6
|
#include <logdepthbuf_pars_vertex>
|
|
7
7
|
#include <fog_pars_vertex>
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
vHighPrecisionZW = finalPosition.zw;
|
|
95
95
|
#include <fog_vertex>
|
|
96
96
|
}
|
|
97
|
-
`,
|
|
97
|
+
`,Vt=`
|
|
98
98
|
#include <packing>
|
|
99
99
|
#include <fog_pars_fragment>
|
|
100
100
|
#include <logdepthbuf_pars_fragment>
|
|
@@ -146,4 +146,4 @@
|
|
|
146
146
|
#include <tonemapping_fragment>
|
|
147
147
|
#include <${+n.REVISION<154?ot[0]:ot[1]}>
|
|
148
148
|
}
|
|
149
|
-
`;class
|
|
149
|
+
`;class zt extends n.ShaderMaterial{constructor(t){super({uniforms:F(O({},n.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new n.Color(16777215)},opacity:{value:1},resolution:{value:new n.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 n.Vector2(1,1)},offset:{value:new n.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new n.Vector2(0,0)},lightColor:{value:new n.Color(16777215)}}),vertexShader:Dt,fragmentShader:Vt}),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 Bt(o,t){return o.map(e=>{const i=[];let s;return e.forEach(a=>{if(s){const l=k.geoDistance(a,s)*180/Math.PI;if(l>t){const r=k.geoInterpolate(s,a),c=1/Math.ceil(l/t);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=a)}),i})}function It(o,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const a=Math.round(J(360/o,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=f=>f/l*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,u=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,p=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],h=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=p[0];f<=p[1];f++){const d=r(f);h(d)&&v.push([d,c(f)])}return v}function X(o,t,e=!1){return e?k.geoContains(t,o):Mt(o,t)}function Tt(o,t){const e={type:"Polygon",coordinates:o},[[i,s],[a,l]]=k.geoBounds(e);if(Math.min(Math.abs(a-i),Math.abs(l-s))<t)return[];const r=i>a||l>=89||s<=-89;return It(t,{minLng:i,maxLng:a,minLat:s,maxLat:l}).filter(c=>X(c,e,r))}function Lt(o,{resolution:t=1/0,bbox:e,projection:i}={}){const s=Bt(o,t),a=W.merge(s),l=Tt(o,t),r=[...a,...l],c={type:"Polygon",coordinates:o},[[u,p],[h,v]]=k.geoBounds(c),f=u>h||v>=89||p<=-89;let d=[];if(f){const g=wt.geoVoronoi(r).triangles(),w=new Map(r.map(([S,j],T)=>[`${S}-${j}`,T]));g.features.forEach(S=>{const j=S.geometry.coordinates[0].slice(0,3).reverse(),T=[];if(j.forEach(([C,q])=>{const G=`${C}-${q}`;w.has(G)&&T.push(w.get(G))}),T.length===3){if(T.some(C=>C<a.length)){const C=S.properties.circumcenter;if(!X(C,c,f))return}d.push(...T)}})}else if(l.length){const g=xt.from(r);for(let w=0,S=g.triangles.length;w<S;w+=3){const j=[2,1,0].map(C=>g.triangles[w+C]),T=j.map(C=>r[C]);if(j.some(C=>C<a.length)){const C=[0,1].map(q=>W.mean(T,G=>G[q]));if(!X(C,c,f))continue}d.push(...j)}}else{const{vertices:g,holes:w=[]}=K.flatten(s);d=K(g,w,2)}let m=e?[e[0],e[2]]:W.extent(r,g=>g[0]),b=e?[e[1],e[3]]:W.extent(r,g=>g[1]);if(i){const[g,w]=i([m[0],b[0]]),[S,j]=i([m[1],b[1]]);m=[g,S],b=[-w,-j]}const P=it.scaleLinear(m,[0,1]),D=it.scaleLinear(b,[0,1]),V=r.map(([g,w])=>{if(i){const[S,j]=i([g,w]);return[P(S),D(-j)]}else return[P(g),D(w)]});return{contour:s,triangles:{points:r,indices:d,uvs:V}}}const lt=new n.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function U(o,t,e,i){const s=o.map(a=>a.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,t]}return e?Q.polar2Cartesian(l,r,t):[l,r,t]}));return K.flatten(s)}function Wt(o,t,e,i,s){const{vertices:a,holes:l}=U(o,t,i,s),{vertices:r}=U(o,e,i,s),c=W.merge([r,a]),u=Math.round(r.length/3),p=new Set(l);let h=0;const v=[];for(let d=0;d<u;d++){let m=d+1;if(m===u)m=h;else if(p.has(m)){const b=m;m=h,h=b}v.push(d,d+u,m+u),v.push(m+u,m,d)}const f=[];for(let d=1;d>=0;d--)for(let m=0;m<u;m+=1)f.push(m/(u-1),d);return{indices:v,vertices:c,uvs:f,topVerts:r}}function ct(o,t,e,i,s,a){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:U([o.points],t,s,a).vertices,uvs:e}}const ht=({polygonGeoJson:o,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{o.forEach(P=>{yt(P)||P.reverse()});const{contour:p,triangles:h}=Lt(o,{resolution:i,bbox:u,projection:c});let v={},f;a&&(v=Wt(p,t!=null?t:e,e!=null?e:t,s,c),f=v.topVerts);let d=[];(l||r)&&(d=W.merge(h.uvs));let m={};l&&(m=ct(h,t,d,!1,s,c));let b={};return r&&(b=ct(h,e,d,!0,s,c)),{contour:p,triangles:h,sideTorso:v,bottomCap:m,topCap:b,topVerts:f}};class _t extends n.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=O({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:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:p}=this.parameters,{contour:h,sideTorso:v,topVerts:f,bottomCap:d,topCap:m}=ht(O({},this.parameters));let b=[],P=[],D=[],V=0;const A=g=>{const w=Math.round(b.length/3),S=D.length;b=b.concat(g.vertices),P=P.concat(g.uvs),D=D.concat(w?g.indices.map(j=>j+w):g.indices),this.addGroup(S,D.length-S,V++)};s&&a&&A(m),r&&(A(v),this.userData.topVerts=u?U(h,i+u,c,p).vertices:f),l&&A(d),s&&!a&&A(m),this.setIndex(D),this[lt]("position",new n.Float32BufferAttribute(b,3)),this[lt]("uv",new n.Float32BufferAttribute(P,2)),this.computeVertexNormals()}}exports.BaseObject=ut;exports.Group=At;exports.LineSegments2=Ct;exports.MeshLineMaterial=zt;exports.PolygonGeometry=_t;exports.ResourceTracker=_;exports.getMetas=ht;
|