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