gl-draw 0.16.0-beta.2 → 0.16.0-beta.3
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/WebGPULineSegments2.js +3 -3
- package/dist/WebGPULineSegments2.module.js +233 -233
- package/dist/core/BaseObject/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/index.module.js +263 -263
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +32 -32
- package/dist/objects/node/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2,38 +2,38 @@ var Ct = Object.defineProperty, Pt = Object.defineProperties;
|
|
|
2
2
|
var It = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var k = Object.getOwnPropertySymbols;
|
|
4
4
|
var et = Object.prototype.hasOwnProperty, it = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var st = Math.pow, tt = (n, t, e) => t in n ? Ct(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
|
-
et.call(t, e) && tt(
|
|
7
|
+
et.call(t, e) && tt(n, e, t[e]);
|
|
8
8
|
if (k)
|
|
9
9
|
for (var e of k(t))
|
|
10
|
-
it.call(t, e) && tt(
|
|
11
|
-
return
|
|
12
|
-
}, $ = (
|
|
13
|
-
var
|
|
10
|
+
it.call(t, e) && tt(n, e, t[e]);
|
|
11
|
+
return n;
|
|
12
|
+
}, $ = (n, t) => Pt(n, It(t));
|
|
13
|
+
var nt = (n, t) => {
|
|
14
14
|
var e = {};
|
|
15
|
-
for (var i in
|
|
16
|
-
et.call(
|
|
17
|
-
if (
|
|
18
|
-
for (var i of k(
|
|
19
|
-
t.indexOf(i) < 0 && it.call(
|
|
15
|
+
for (var i in n)
|
|
16
|
+
et.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 && it.call(n, i) && (e[i] = n[i]);
|
|
20
20
|
return e;
|
|
21
21
|
};
|
|
22
|
-
var rt = (
|
|
22
|
+
var rt = (n, t, e) => new Promise((i, s) => {
|
|
23
23
|
var a = (o) => {
|
|
24
24
|
try {
|
|
25
25
|
r(e.next(o));
|
|
26
26
|
} catch (c) {
|
|
27
|
-
|
|
27
|
+
s(c);
|
|
28
28
|
}
|
|
29
|
-
},
|
|
29
|
+
}, l = (o) => {
|
|
30
30
|
try {
|
|
31
31
|
r(e.throw(o));
|
|
32
32
|
} catch (c) {
|
|
33
|
-
|
|
33
|
+
s(c);
|
|
34
34
|
}
|
|
35
|
-
}, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a,
|
|
36
|
-
r((e = e.apply(
|
|
35
|
+
}, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, l);
|
|
36
|
+
r((e = e.apply(n, t)).next());
|
|
37
37
|
});
|
|
38
38
|
import { Material as at, Object3D as N, Texture as ot, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Dt, Points as J, InstancedMesh as xt, Vector3 as I, Quaternion as Bt, Group as Tt, Mesh as wt, Sprite as ct, Box3 as St, ShaderMaterial as zt, Vector2 as q, Color as lt, Vector4 as O, Matrix4 as _t, Line3 as Et, Sphere as Lt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as ut, MathUtils as Vt } from "three";
|
|
39
39
|
import { CSS2DObject as kt } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
@@ -75,8 +75,8 @@ class te {
|
|
|
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 ot || Array.isArray(s)) && this.track(s);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
} else this.disposeVideo && t.isVideoTexture && t.source.data && this.resources.add(t.source.data);
|
|
@@ -91,7 +91,7 @@ class te {
|
|
|
91
91
|
}), t.length = 0, this.resources.clear();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
const ee = (
|
|
94
|
+
const ee = (n, t = 1) => {
|
|
95
95
|
const e = new Z();
|
|
96
96
|
e.setAttribute(
|
|
97
97
|
"position",
|
|
@@ -100,7 +100,7 @@ const ee = (s, t = 1) => {
|
|
|
100
100
|
"scaleAtt",
|
|
101
101
|
new R(new Array(t).fill(1), 1)
|
|
102
102
|
);
|
|
103
|
-
const i =
|
|
103
|
+
const i = n.material, s = new Dt({
|
|
104
104
|
size: 10,
|
|
105
105
|
map: i.map,
|
|
106
106
|
alphaMap: i.alphaMap,
|
|
@@ -113,7 +113,7 @@ const ee = (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,22 +121,22 @@ const ee = (s, t = 1) => {
|
|
|
121
121
|
"gl_PointSize = size * scaleAtt;"
|
|
122
122
|
)}
|
|
123
123
|
`;
|
|
124
|
-
}, new J(e,
|
|
125
|
-
}, ie = (
|
|
124
|
+
}, new J(e, s);
|
|
125
|
+
}, ie = (n, t) => {
|
|
126
126
|
const e = new N();
|
|
127
|
-
t.forEach((i,
|
|
128
|
-
const a = ft(i.position),
|
|
129
|
-
e.position.copy(a), e.scale.copy(
|
|
127
|
+
t.forEach((i, s) => {
|
|
128
|
+
const a = ft(i.position), l = ft(i.scale || [1, 1, 1]);
|
|
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 c =
|
|
135
|
-
r.decompose(h,
|
|
131
|
+
if (n instanceof xt || n.isInstantiate)
|
|
132
|
+
n.setMatrixAt(s, r);
|
|
133
|
+
else if (n instanceof J || n.type === "Points") {
|
|
134
|
+
const c = n.geometry, f = c.attributes.position.array, d = c.attributes.scaleAtt.array, h = new I(), u = new I(), m = new Bt(), p = s * 3, v = s * 1;
|
|
135
|
+
r.decompose(h, m, u), f[p] = h.x, f[p + 1] = h.y, f[p + 2] = h.z, d[v] = Math.max(u.x, u.y, u.z), c.attributes.position.needsUpdate = !0, c.attributes.scaleAtt.needsUpdate = !0;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
};
|
|
139
|
-
class
|
|
139
|
+
class se {
|
|
140
140
|
constructor() {
|
|
141
141
|
this.onPointerIndex = [];
|
|
142
142
|
}
|
|
@@ -165,7 +165,7 @@ class ne {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
class
|
|
168
|
+
class ne extends se {
|
|
169
169
|
constructor() {
|
|
170
170
|
super(...arguments), this.userData = {}, this.materialList = {}, this.useMaterialType = "origin", this.disposeMaterialIfNotUsed = !0;
|
|
171
171
|
}
|
|
@@ -176,16 +176,16 @@ class se extends ne {
|
|
|
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 se extends ne {
|
|
|
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 se extends ne {
|
|
|
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)
|
|
@@ -223,9 +223,9 @@ class se extends ne {
|
|
|
223
223
|
);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
-
class pt extends
|
|
226
|
+
class pt extends ne {
|
|
227
227
|
constructor() {
|
|
228
|
-
super(...arguments), this.objectType = "BaseObject", this.userData = {}, this.
|
|
228
|
+
super(...arguments), this.objectType = "BaseObject", this.userData = {}, this.isPrefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.isBaseObject = !0, this.disposeTrack = !0;
|
|
229
229
|
}
|
|
230
230
|
get parent() {
|
|
231
231
|
const t = this.object3d.parent;
|
|
@@ -334,19 +334,19 @@ class pt extends se {
|
|
|
334
334
|
}
|
|
335
335
|
instantiate(t) {
|
|
336
336
|
return rt(this, null, function* () {
|
|
337
|
-
var
|
|
338
|
-
const e = (
|
|
339
|
-
let
|
|
340
|
-
|
|
341
|
-
var
|
|
337
|
+
var o, c;
|
|
338
|
+
const e = (o = t == null ? void 0 : t.recursive) != null ? o : !0, i = (c = t == null ? void 0 : t.cloneMaterial) != null ? c : !1, { objectType: s, objectOptions: a } = this;
|
|
339
|
+
let l = t == null ? void 0 : t.create;
|
|
340
|
+
l === void 0 && (l = (f) => {
|
|
341
|
+
var d;
|
|
342
342
|
if (this.object3d) {
|
|
343
|
-
if ((
|
|
344
|
-
const
|
|
343
|
+
if ((d = t == null ? void 0 : t.instancedAttr) != null && d.length) {
|
|
344
|
+
const h = t.instancedAttr.length;
|
|
345
345
|
if (this.object3d instanceof ct)
|
|
346
|
-
f.object3d = ee(this.object3d,
|
|
346
|
+
f.object3d = ee(this.object3d, h);
|
|
347
347
|
else {
|
|
348
|
-
const
|
|
349
|
-
f.object3d = new xt(
|
|
348
|
+
const u = this.object3d, m = i ? this.cloneMaterial() : u.material;
|
|
349
|
+
f.object3d = new xt(u.geometry, m, h);
|
|
350
350
|
}
|
|
351
351
|
ie(f.object3d, t == null ? void 0 : t.instancedAttr);
|
|
352
352
|
} else
|
|
@@ -354,20 +354,20 @@ class pt extends se {
|
|
|
354
354
|
f.object3d.userData.prefab && delete f.object3d.userData.prefab;
|
|
355
355
|
}
|
|
356
356
|
});
|
|
357
|
-
const
|
|
358
|
-
create:
|
|
357
|
+
const r = yield this.lead.draw(s, $(L({}, a || {}), {
|
|
358
|
+
create: l,
|
|
359
359
|
prefab: !1,
|
|
360
360
|
key: (t == null ? void 0 : t.key) || (a == null ? void 0 : a.key),
|
|
361
361
|
target: (t == null ? void 0 : t.target) || (a == null ? void 0 : a.target)
|
|
362
362
|
}));
|
|
363
|
-
return this.isBloom &&
|
|
363
|
+
return this.isBloom && r.enableBloom(), e && (yield Promise.all(
|
|
364
364
|
this.children.map(
|
|
365
365
|
(f) => f.instantiate({
|
|
366
366
|
cloneMaterial: i,
|
|
367
|
-
target:
|
|
367
|
+
target: r
|
|
368
368
|
})
|
|
369
369
|
)
|
|
370
|
-
)),
|
|
370
|
+
)), r.isInstantiate = !0, r;
|
|
371
371
|
});
|
|
372
372
|
}
|
|
373
373
|
erase() {
|
|
@@ -391,62 +391,62 @@ class pt extends se {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
function re(
|
|
395
|
-
return
|
|
394
|
+
function re(n, t) {
|
|
395
|
+
return n.map((e) => {
|
|
396
396
|
const i = [];
|
|
397
|
-
let
|
|
397
|
+
let s;
|
|
398
398
|
return e.forEach((a) => {
|
|
399
|
-
if (
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
const r = Gt(
|
|
399
|
+
if (s) {
|
|
400
|
+
const l = Rt(a, s) * 180 / Math.PI;
|
|
401
|
+
if (l > t) {
|
|
402
|
+
const r = Gt(s, a), o = 1 / Math.ceil(l / t);
|
|
403
403
|
let c = o;
|
|
404
404
|
for (; c < 1; )
|
|
405
405
|
i.push(r(c)), c += o;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
i.push(
|
|
408
|
+
i.push(s = a);
|
|
409
409
|
}), i;
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
|
-
function ae(
|
|
413
|
-
const a = Math.round(
|
|
414
|
-
|
|
412
|
+
function ae(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
413
|
+
const a = Math.round(st(360 / n, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, r = (u) => u / l * 360 % 360 - 180, o = (u) => Math.acos(2 * u / a - 1) / Math.PI * 180 - 90, c = (u) => a * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, f = [
|
|
414
|
+
s !== void 0 ? Math.ceil(c(s)) : 0,
|
|
415
415
|
i !== void 0 ? Math.floor(c(i)) : a - 1
|
|
416
|
-
],
|
|
417
|
-
for (let
|
|
418
|
-
const
|
|
419
|
-
|
|
416
|
+
], 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, h = [];
|
|
417
|
+
for (let u = f[0]; u <= f[1]; u++) {
|
|
418
|
+
const m = r(u);
|
|
419
|
+
d(m) && h.push([m, o(u)]);
|
|
420
420
|
}
|
|
421
421
|
return h;
|
|
422
422
|
}
|
|
423
|
-
function Y(
|
|
424
|
-
return e ? Nt(t,
|
|
423
|
+
function Y(n, t, e = !1) {
|
|
424
|
+
return e ? Nt(t, n) : Xt(n, t);
|
|
425
425
|
}
|
|
426
|
-
function oe(
|
|
427
|
-
const e = { type: "Polygon", coordinates:
|
|
428
|
-
if (Math.min(Math.abs(a - i), Math.abs(
|
|
426
|
+
function oe(n, t) {
|
|
427
|
+
const e = { type: "Polygon", coordinates: n }, [[i, s], [a, l]] = jt(e);
|
|
428
|
+
if (Math.min(Math.abs(a - i), Math.abs(l - s)) < t)
|
|
429
429
|
return [];
|
|
430
|
-
const r = i > a ||
|
|
430
|
+
const r = i > a || l >= 89 || s <= -89;
|
|
431
431
|
return ae(t, {
|
|
432
432
|
minLng: i,
|
|
433
433
|
maxLng: a,
|
|
434
|
-
minLat:
|
|
435
|
-
maxLat:
|
|
434
|
+
minLat: s,
|
|
435
|
+
maxLat: l
|
|
436
436
|
}).filter(
|
|
437
437
|
(o) => Y(o, e, r)
|
|
438
438
|
);
|
|
439
439
|
}
|
|
440
|
-
function ce(
|
|
441
|
-
const
|
|
440
|
+
function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
441
|
+
const s = re(n, t), a = H(s), l = oe(n, t), r = [...a, ...l], o = { type: "Polygon", coordinates: n }, [[c, f], [d, h]] = jt(o), u = c > d || // crosses antimeridian
|
|
442
442
|
h >= 89 || // crosses north pole
|
|
443
|
-
|
|
444
|
-
let
|
|
445
|
-
if (
|
|
446
|
-
const
|
|
443
|
+
f <= -89;
|
|
444
|
+
let m = [];
|
|
445
|
+
if (u) {
|
|
446
|
+
const g = Yt(r).triangles(), x = new Map(
|
|
447
447
|
r.map(([A, C], _) => [`${A}-${C}`, _])
|
|
448
448
|
);
|
|
449
|
-
|
|
449
|
+
g.features.forEach((A) => {
|
|
450
450
|
const C = A.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
|
|
451
451
|
if (C.forEach(([P, F]) => {
|
|
452
452
|
const V = `${P}-${F}`;
|
|
@@ -457,17 +457,17 @@ function ce(s, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
457
457
|
if (!Y(
|
|
458
458
|
P,
|
|
459
459
|
o,
|
|
460
|
-
|
|
460
|
+
u
|
|
461
461
|
))
|
|
462
462
|
return;
|
|
463
463
|
}
|
|
464
|
-
|
|
464
|
+
m.push(..._);
|
|
465
465
|
}
|
|
466
466
|
});
|
|
467
|
-
} else if (
|
|
468
|
-
const
|
|
469
|
-
for (let x = 0, A =
|
|
470
|
-
const C = [2, 1, 0].map((P) =>
|
|
467
|
+
} else if (l.length) {
|
|
468
|
+
const g = Qt.from(r);
|
|
469
|
+
for (let x = 0, A = g.triangles.length; x < A; x += 3) {
|
|
470
|
+
const C = [2, 1, 0].map((P) => g.triangles[x + P]), _ = C.map((P) => r[P]);
|
|
471
471
|
if (C.some((P) => P < a.length)) {
|
|
472
472
|
const P = [0, 1].map(
|
|
473
473
|
(F) => $t(_, (V) => V[F])
|
|
@@ -475,132 +475,132 @@ function ce(s, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
|
475
475
|
if (!Y(
|
|
476
476
|
P,
|
|
477
477
|
o,
|
|
478
|
-
|
|
478
|
+
u
|
|
479
479
|
))
|
|
480
480
|
continue;
|
|
481
481
|
}
|
|
482
|
-
|
|
482
|
+
m.push(...C);
|
|
483
483
|
}
|
|
484
484
|
} else {
|
|
485
|
-
const { vertices:
|
|
486
|
-
|
|
485
|
+
const { vertices: g, holes: x = [] } = At(s);
|
|
486
|
+
m = qt(g, x, 2);
|
|
487
487
|
}
|
|
488
|
-
let
|
|
488
|
+
let p = e ? [e[0], e[2]] : dt(r, (g) => g[0]), v = e ? [e[1], e[3]] : dt(r, (g) => g[1]);
|
|
489
489
|
if (i) {
|
|
490
|
-
const [
|
|
491
|
-
|
|
490
|
+
const [g, x] = i([p[0], v[0]]), [A, C] = i([p[1], v[1]]);
|
|
491
|
+
p = [g, A], v = [-x, -C];
|
|
492
492
|
}
|
|
493
|
-
const w = ht(
|
|
493
|
+
const w = ht(p, [0, 1]), S = ht(v, [0, 1]), D = r.map(([g, x]) => {
|
|
494
494
|
if (i) {
|
|
495
|
-
const [A, C] = i([
|
|
495
|
+
const [A, C] = i([g, x]);
|
|
496
496
|
return [w(A), S(-C)];
|
|
497
497
|
} else
|
|
498
|
-
return [w(
|
|
498
|
+
return [w(g), S(x)];
|
|
499
499
|
});
|
|
500
|
-
return { contour:
|
|
500
|
+
return { contour: s, triangles: { points: r, indices: m, uvs: D } };
|
|
501
501
|
}
|
|
502
502
|
const mt = new Z().setAttribute ? "setAttribute" : "addAttribute";
|
|
503
|
-
function G(
|
|
504
|
-
const
|
|
505
|
-
(a) => a.map(([
|
|
503
|
+
function G(n, t, e, i) {
|
|
504
|
+
const s = n.map(
|
|
505
|
+
(a) => a.map(([l, r]) => {
|
|
506
506
|
if (i) {
|
|
507
|
-
const [o, c] = i([
|
|
507
|
+
const [o, c] = i([l, r]);
|
|
508
508
|
return [o, -c, t];
|
|
509
509
|
}
|
|
510
|
-
return e ? Ft(
|
|
510
|
+
return e ? Ft(l, r, t) : [l, r, t];
|
|
511
511
|
})
|
|
512
512
|
);
|
|
513
|
-
return At(
|
|
513
|
+
return At(s);
|
|
514
514
|
}
|
|
515
|
-
function le(
|
|
516
|
-
const { vertices: a, holes:
|
|
517
|
-
|
|
515
|
+
function le(n, t, e, i, s) {
|
|
516
|
+
const { vertices: a, holes: l } = G(
|
|
517
|
+
n,
|
|
518
518
|
t,
|
|
519
519
|
i,
|
|
520
|
-
|
|
520
|
+
s
|
|
521
521
|
), { vertices: r } = G(
|
|
522
|
-
|
|
522
|
+
n,
|
|
523
523
|
e,
|
|
524
524
|
i,
|
|
525
|
-
|
|
526
|
-
), o = H([r, a]), c = Math.round(r.length / 3),
|
|
527
|
-
let
|
|
525
|
+
s
|
|
526
|
+
), o = H([r, a]), c = Math.round(r.length / 3), f = new Set(l);
|
|
527
|
+
let d = 0;
|
|
528
528
|
const h = [];
|
|
529
|
-
for (let
|
|
530
|
-
let
|
|
531
|
-
if (
|
|
532
|
-
|
|
533
|
-
else if (
|
|
534
|
-
const v =
|
|
535
|
-
|
|
529
|
+
for (let m = 0; m < c; m++) {
|
|
530
|
+
let p = m + 1;
|
|
531
|
+
if (p === c)
|
|
532
|
+
p = d;
|
|
533
|
+
else if (f.has(p)) {
|
|
534
|
+
const v = p;
|
|
535
|
+
p = d, d = v;
|
|
536
536
|
}
|
|
537
|
-
h.push(
|
|
537
|
+
h.push(m, m + c, p + c), h.push(p + c, p, m);
|
|
538
538
|
}
|
|
539
|
-
const
|
|
540
|
-
for (let
|
|
541
|
-
for (let
|
|
542
|
-
return { indices: h, vertices: o, uvs:
|
|
539
|
+
const u = [];
|
|
540
|
+
for (let m = 1; m >= 0; m--)
|
|
541
|
+
for (let p = 0; p < c; p += 1) u.push(p / (c - 1), m);
|
|
542
|
+
return { indices: h, vertices: o, uvs: u, topVerts: r };
|
|
543
543
|
}
|
|
544
|
-
function vt(
|
|
544
|
+
function vt(n, t, e, i, s, a) {
|
|
545
545
|
return {
|
|
546
|
-
indices: i ?
|
|
546
|
+
indices: i ? n.indices : n.indices.slice().reverse(),
|
|
547
547
|
vertices: G(
|
|
548
|
-
[
|
|
548
|
+
[n.points],
|
|
549
549
|
t,
|
|
550
|
-
|
|
550
|
+
s,
|
|
551
551
|
a
|
|
552
552
|
).vertices,
|
|
553
553
|
uvs: e
|
|
554
554
|
};
|
|
555
555
|
}
|
|
556
556
|
const ue = ({
|
|
557
|
-
polygonGeoJson:
|
|
557
|
+
polygonGeoJson: n,
|
|
558
558
|
startHeight: t,
|
|
559
559
|
endHeight: e,
|
|
560
560
|
curvatureResolution: i = 1,
|
|
561
|
-
cartesian:
|
|
561
|
+
cartesian: s = !0,
|
|
562
562
|
hasSide: a = !0,
|
|
563
|
-
hasBottom:
|
|
563
|
+
hasBottom: l = !1,
|
|
564
564
|
hasTop: r = !1,
|
|
565
565
|
projection: o,
|
|
566
566
|
bbox: c
|
|
567
567
|
}) => {
|
|
568
|
-
|
|
568
|
+
n.forEach((w) => {
|
|
569
569
|
Kt(w) || w.reverse();
|
|
570
570
|
});
|
|
571
|
-
const { contour:
|
|
571
|
+
const { contour: f, triangles: d } = ce(n, {
|
|
572
572
|
resolution: i,
|
|
573
573
|
bbox: c,
|
|
574
574
|
projection: o
|
|
575
575
|
});
|
|
576
|
-
let h = {},
|
|
576
|
+
let h = {}, u;
|
|
577
577
|
a && (h = le(
|
|
578
|
-
|
|
578
|
+
f,
|
|
579
579
|
t != null ? t : e,
|
|
580
580
|
e != null ? e : t,
|
|
581
|
-
|
|
581
|
+
s,
|
|
582
582
|
o
|
|
583
|
-
),
|
|
584
|
-
let
|
|
585
|
-
(
|
|
586
|
-
let
|
|
587
|
-
|
|
588
|
-
|
|
583
|
+
), u = h.topVerts);
|
|
584
|
+
let m = [];
|
|
585
|
+
(l || r) && (m = H(d.uvs));
|
|
586
|
+
let p = {};
|
|
587
|
+
l && (p = vt(
|
|
588
|
+
d,
|
|
589
589
|
t,
|
|
590
|
-
|
|
590
|
+
m,
|
|
591
591
|
!1,
|
|
592
|
-
|
|
592
|
+
s,
|
|
593
593
|
o
|
|
594
594
|
));
|
|
595
595
|
let v = {};
|
|
596
596
|
return r && (v = vt(
|
|
597
|
-
|
|
597
|
+
d,
|
|
598
598
|
e,
|
|
599
|
-
|
|
599
|
+
m,
|
|
600
600
|
!0,
|
|
601
|
-
|
|
601
|
+
s,
|
|
602
602
|
o
|
|
603
|
-
)), { contour:
|
|
603
|
+
)), { contour: f, triangles: d, sideTorso: h, bottomCap: p, topCap: v, topVerts: u };
|
|
604
604
|
};
|
|
605
605
|
class ze extends Z {
|
|
606
606
|
constructor(t, e = {}) {
|
|
@@ -618,27 +618,27 @@ class ze extends Z {
|
|
|
618
618
|
}, e);
|
|
619
619
|
const {
|
|
620
620
|
endHeight: i,
|
|
621
|
-
hasTop:
|
|
621
|
+
hasTop: s,
|
|
622
622
|
topFirst: a,
|
|
623
|
-
hasBottom:
|
|
623
|
+
hasBottom: l,
|
|
624
624
|
hasSide: r,
|
|
625
625
|
cartesian: o,
|
|
626
626
|
userDataRsoOffset: c,
|
|
627
|
-
projection:
|
|
628
|
-
} = this.parameters, { contour:
|
|
627
|
+
projection: f
|
|
628
|
+
} = this.parameters, { contour: d, sideTorso: h, topVerts: u, bottomCap: m, topCap: p } = ue(L({}, this.parameters));
|
|
629
629
|
let v = [], w = [], S = [], D = 0;
|
|
630
|
-
const j = (
|
|
630
|
+
const j = (g) => {
|
|
631
631
|
const x = Math.round(v.length / 3), A = S.length;
|
|
632
|
-
v = v.concat(
|
|
633
|
-
x ?
|
|
632
|
+
v = v.concat(g.vertices), w = w.concat(g.uvs), S = S.concat(
|
|
633
|
+
x ? g.indices.map((C) => C + x) : g.indices
|
|
634
634
|
), this.addGroup(A, S.length - A, D++);
|
|
635
635
|
};
|
|
636
|
-
|
|
637
|
-
|
|
636
|
+
s && a && j(p), r && (j(h), this.userData.topVerts = c ? G(
|
|
637
|
+
d,
|
|
638
638
|
i + c,
|
|
639
639
|
o,
|
|
640
|
-
|
|
641
|
-
).vertices :
|
|
640
|
+
f
|
|
641
|
+
).vertices : u), l && j(m), s && !a && j(p), this.setIndex(S), this[mt]("position", new R(v, 3)), this[mt]("uv", new R(w, 2)), this.computeVertexNormals();
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
644
|
const fe = `
|
|
@@ -783,20 +783,20 @@ class _e extends zt {
|
|
|
783
783
|
const S = t, {
|
|
784
784
|
lineWidth: e = 1,
|
|
785
785
|
color: i = "#ffffff",
|
|
786
|
-
opacity:
|
|
786
|
+
opacity: s = 1,
|
|
787
787
|
map: a = null,
|
|
788
|
-
dashOffset:
|
|
788
|
+
dashOffset: l = 0,
|
|
789
789
|
dashArray: r = 0,
|
|
790
790
|
dashRatio: o = 0,
|
|
791
791
|
sizeAttenuation: c = !0,
|
|
792
|
-
offsetLoop:
|
|
793
|
-
offset:
|
|
792
|
+
offsetLoop: f = !0,
|
|
793
|
+
offset: d = new q(0, 0),
|
|
794
794
|
scaleDown: h = 0,
|
|
795
|
-
alphaMap:
|
|
796
|
-
alphaTest:
|
|
797
|
-
repeat:
|
|
795
|
+
alphaMap: u = void 0,
|
|
796
|
+
alphaTest: m = 0,
|
|
797
|
+
repeat: p = new q(1, 1),
|
|
798
798
|
resolution: v = new q(1, 1)
|
|
799
|
-
} = S, w =
|
|
799
|
+
} = S, w = nt(S, [
|
|
800
800
|
"lineWidth",
|
|
801
801
|
"color",
|
|
802
802
|
"opacity",
|
|
@@ -817,22 +817,22 @@ class _e extends zt {
|
|
|
817
817
|
uniforms: {
|
|
818
818
|
lineWidth: { value: e },
|
|
819
819
|
color: { value: new lt(i) },
|
|
820
|
-
opacity: { value:
|
|
820
|
+
opacity: { value: s },
|
|
821
821
|
map: { value: a },
|
|
822
822
|
useMap: { value: a ? 1 : 0 },
|
|
823
823
|
resolution: { value: v },
|
|
824
824
|
sizeAttenuation: { value: c ? 1 : 0 },
|
|
825
|
-
offset: { value:
|
|
826
|
-
offsetLoop: { value:
|
|
825
|
+
offset: { value: d },
|
|
826
|
+
offsetLoop: { value: f ? 1 : 0 },
|
|
827
827
|
dashArray: { value: r },
|
|
828
|
-
dashOffset: { value:
|
|
828
|
+
dashOffset: { value: l },
|
|
829
829
|
dashRatio: { value: o },
|
|
830
830
|
useDash: { value: r > 0 ? 1 : 0 },
|
|
831
831
|
scaleDown: { value: h / 10 },
|
|
832
|
-
alphaTest: { value:
|
|
833
|
-
alphaMap: { value:
|
|
834
|
-
useAlphaMap: { value:
|
|
835
|
-
repeat: { value:
|
|
832
|
+
alphaTest: { value: m },
|
|
833
|
+
alphaMap: { value: u },
|
|
834
|
+
useAlphaMap: { value: u ? 1 : 0 },
|
|
835
|
+
repeat: { value: p }
|
|
836
836
|
},
|
|
837
837
|
vertexShader: de,
|
|
838
838
|
fragmentShader: fe
|
|
@@ -886,21 +886,21 @@ class _e extends zt {
|
|
|
886
886
|
this.uniforms.sizeAttenuation.value = t ? 1 : 0;
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
|
-
const K = new O(),
|
|
889
|
+
const K = new O(), gt = new I(), yt = new I(), y = new O(), b = new O(), B = new O(), Q = new I(), X = new _t(), M = new Et(), bt = new I(), W = new St(), U = new Lt(), T = new O();
|
|
890
890
|
let z, E;
|
|
891
|
-
function Mt(
|
|
892
|
-
return T.set(0, 0, -t, 1).applyMatrix4(
|
|
891
|
+
function Mt(n, t, e) {
|
|
892
|
+
return T.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = E / e.width, T.y = E / e.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
|
|
893
893
|
}
|
|
894
|
-
function he(
|
|
895
|
-
const e =
|
|
896
|
-
for (let r = 0, o =
|
|
897
|
-
M.start.fromBufferAttribute(
|
|
898
|
-
const c = new I(),
|
|
899
|
-
z.distanceSqToSegment(M.start, M.end,
|
|
900
|
-
point:
|
|
894
|
+
function he(n, t) {
|
|
895
|
+
const e = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
|
|
896
|
+
for (let r = 0, o = l; r < o; r++) {
|
|
897
|
+
M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(e);
|
|
898
|
+
const c = new I(), f = new I();
|
|
899
|
+
z.distanceSqToSegment(M.start, M.end, f, c), f.distanceTo(c) < E * 0.5 && t.push({
|
|
900
|
+
point: f,
|
|
901
901
|
pointOnLine: c,
|
|
902
|
-
distance: z.origin.distanceTo(
|
|
903
|
-
object:
|
|
902
|
+
distance: z.origin.distanceTo(f),
|
|
903
|
+
object: n,
|
|
904
904
|
face: null,
|
|
905
905
|
faceIndex: r,
|
|
906
906
|
uv: null,
|
|
@@ -908,31 +908,31 @@ function he(s, t) {
|
|
|
908
908
|
});
|
|
909
909
|
}
|
|
910
910
|
}
|
|
911
|
-
function pe(
|
|
912
|
-
const i = t.projectionMatrix, a =
|
|
913
|
-
z.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, Q.copy(B), X.multiplyMatrices(t.matrixWorldInverse,
|
|
914
|
-
for (let h = 0,
|
|
915
|
-
if (
|
|
911
|
+
function pe(n, t, e) {
|
|
912
|
+
const i = t.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, o = r.attributes.instanceStart, c = r.attributes.instanceEnd, f = Math.min(r.instanceCount, o.count), d = -t.near;
|
|
913
|
+
z.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, Q.copy(B), X.multiplyMatrices(t.matrixWorldInverse, l);
|
|
914
|
+
for (let h = 0, u = f; h < u; h++) {
|
|
915
|
+
if (y.fromBufferAttribute(o, h), b.fromBufferAttribute(c, h), y.w = 1, b.w = 1, y.applyMatrix4(X), b.applyMatrix4(X), y.z > d && b.z > d)
|
|
916
916
|
continue;
|
|
917
|
-
if (
|
|
918
|
-
const D =
|
|
919
|
-
|
|
920
|
-
} else if (b.z >
|
|
921
|
-
const D = b.z -
|
|
922
|
-
b.lerp(
|
|
917
|
+
if (y.z > d) {
|
|
918
|
+
const D = y.z - b.z, j = (y.z - d) / D;
|
|
919
|
+
y.lerp(b, j);
|
|
920
|
+
} else if (b.z > d) {
|
|
921
|
+
const D = b.z - y.z, j = (b.z - d) / D;
|
|
922
|
+
b.lerp(y, j);
|
|
923
923
|
}
|
|
924
|
-
|
|
925
|
-
const
|
|
926
|
-
M.at(
|
|
927
|
-
const v = Vt.lerp(
|
|
924
|
+
y.applyMatrix4(i), b.applyMatrix4(i), y.multiplyScalar(1 / y.w), b.multiplyScalar(1 / b.w), y.x *= a.x / 2, y.y *= a.y / 2, b.x *= a.x / 2, b.y *= a.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(b), M.end.z = 0;
|
|
925
|
+
const p = M.closestPointToPointParameter(Q, !0);
|
|
926
|
+
M.at(p, bt);
|
|
927
|
+
const v = Vt.lerp(y.z, b.z, p), w = v >= -1 && v <= 1, S = Q.distanceTo(bt) < E * 0.5;
|
|
928
928
|
if (w && S) {
|
|
929
|
-
M.start.fromBufferAttribute(o, h), M.end.fromBufferAttribute(c, h), M.start.applyMatrix4(
|
|
929
|
+
M.start.fromBufferAttribute(o, h), M.end.fromBufferAttribute(c, h), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
|
|
930
930
|
const D = new I(), j = new I();
|
|
931
931
|
z.distanceSqToSegment(M.start, M.end, j, D), e.push({
|
|
932
932
|
point: j,
|
|
933
933
|
pointOnLine: D,
|
|
934
934
|
distance: z.origin.distanceTo(j),
|
|
935
|
-
object:
|
|
935
|
+
object: n,
|
|
936
936
|
face: null,
|
|
937
937
|
faceIndex: h,
|
|
938
938
|
uv: null,
|
|
@@ -947,11 +947,11 @@ class Ee extends wt {
|
|
|
947
947
|
}
|
|
948
948
|
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
949
949
|
computeLineDistances() {
|
|
950
|
-
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd,
|
|
951
|
-
for (let
|
|
952
|
-
|
|
950
|
+
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
|
|
951
|
+
for (let l = 0, r = 0, o = e.count; l < o; l++, r += 2)
|
|
952
|
+
gt.fromBufferAttribute(e, l), yt.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + gt.distanceTo(yt);
|
|
953
953
|
const a = new Ot(
|
|
954
|
-
|
|
954
|
+
s,
|
|
955
955
|
2,
|
|
956
956
|
1
|
|
957
957
|
);
|
|
@@ -964,46 +964,46 @@ class Ee extends wt {
|
|
|
964
964
|
), this;
|
|
965
965
|
}
|
|
966
966
|
raycast(t, e) {
|
|
967
|
-
const i = this.material.worldUnits,
|
|
968
|
-
|
|
967
|
+
const i = this.material.worldUnits, s = t.camera;
|
|
968
|
+
s === null && !i && console.error(
|
|
969
969
|
'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
|
|
970
970
|
);
|
|
971
971
|
const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
|
|
972
972
|
z = t.ray;
|
|
973
|
-
const
|
|
974
|
-
E = o.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(
|
|
973
|
+
const l = this.matrixWorld, r = this.geometry, o = this.material;
|
|
974
|
+
E = o.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(l);
|
|
975
975
|
let c;
|
|
976
976
|
if (i)
|
|
977
977
|
c = E * 0.5;
|
|
978
978
|
else {
|
|
979
|
-
const
|
|
980
|
-
|
|
979
|
+
const d = Math.max(
|
|
980
|
+
s.near,
|
|
981
981
|
U.distanceToPoint(z.origin)
|
|
982
982
|
);
|
|
983
983
|
c = Mt(
|
|
984
|
-
|
|
985
|
-
|
|
984
|
+
s,
|
|
985
|
+
d,
|
|
986
986
|
o.resolution
|
|
987
987
|
);
|
|
988
988
|
}
|
|
989
989
|
if (U.radius += c, z.intersectsSphere(U) === !1)
|
|
990
990
|
return;
|
|
991
|
-
r.boundingBox === null && r.computeBoundingBox(), W.copy(r.boundingBox).applyMatrix4(
|
|
992
|
-
let
|
|
991
|
+
r.boundingBox === null && r.computeBoundingBox(), W.copy(r.boundingBox).applyMatrix4(l);
|
|
992
|
+
let f;
|
|
993
993
|
if (i)
|
|
994
|
-
|
|
994
|
+
f = E * 0.5;
|
|
995
995
|
else {
|
|
996
|
-
const
|
|
997
|
-
|
|
996
|
+
const d = Math.max(
|
|
997
|
+
s.near,
|
|
998
998
|
W.distanceToPoint(z.origin)
|
|
999
999
|
);
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1000
|
+
f = Mt(
|
|
1001
|
+
s,
|
|
1002
|
+
d,
|
|
1003
1003
|
o.resolution
|
|
1004
1004
|
);
|
|
1005
1005
|
}
|
|
1006
|
-
W.expandByScalar(
|
|
1006
|
+
W.expandByScalar(f), z.intersectsBox(W) !== !1 && (i ? he(this, e) : pe(this, s, e));
|
|
1007
1007
|
}
|
|
1008
1008
|
onBeforeRender(t) {
|
|
1009
1009
|
const e = this.material.uniforms;
|