gl-draw 0.14.15 → 0.14.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/BaseObject.d.ts +4 -1
- package/dist/index.module2.js +292 -290
- package/dist/index2.js +5 -5
- package/package.json +1 -1
|
@@ -49,7 +49,10 @@ export default class BaseObject extends ResourceTracker {
|
|
|
49
49
|
instantiate(meta?: {
|
|
50
50
|
position: THREE.Vector3 | number[] | [number, number, number];
|
|
51
51
|
scale?: THREE.Vector3 | number[] | [number, number, number];
|
|
52
|
-
}[]
|
|
52
|
+
}[], ops?: {
|
|
53
|
+
target?: IBaseObject;
|
|
54
|
+
create?: ((...args: any[]) => any) | boolean;
|
|
55
|
+
}): Promise<this>;
|
|
53
56
|
private setInstancedMatrix;
|
|
54
57
|
erase(): void;
|
|
55
58
|
cloneMaterial(): THREE.Material | THREE.Material[] | undefined;
|
package/dist/index.module2.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
1
|
+
var dt = Object.defineProperty, pt = Object.defineProperties;
|
|
2
2
|
var mt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var X = Object.getOwnPropertySymbols;
|
|
4
4
|
var vt = Object.prototype.hasOwnProperty, gt = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var H = Math.pow, Y = (a, t, e) => t in a ?
|
|
5
|
+
var H = Math.pow, Y = (a, t, e) => t in a ? dt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e, O = (a, t) => {
|
|
6
6
|
for (var e in t || (t = {}))
|
|
7
7
|
vt.call(t, e) && Y(a, e, t[e]);
|
|
8
8
|
if (X)
|
|
9
9
|
for (var e of X(t))
|
|
10
10
|
gt.call(t, e) && Y(a, e, t[e]);
|
|
11
11
|
return a;
|
|
12
|
-
}, Z = (a, t) =>
|
|
13
|
-
var J = (a, t, e) => new Promise((
|
|
14
|
-
var r = (
|
|
12
|
+
}, Z = (a, t) => pt(a, mt(t));
|
|
13
|
+
var J = (a, t, e) => new Promise((i, s) => {
|
|
14
|
+
var r = (l) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
} catch (
|
|
18
|
-
|
|
16
|
+
n(e.next(l));
|
|
17
|
+
} catch (o) {
|
|
18
|
+
s(o);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, c = (l) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
23
|
-
} catch (
|
|
24
|
-
|
|
22
|
+
n(e.throw(l));
|
|
23
|
+
} catch (o) {
|
|
24
|
+
s(o);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(r, c);
|
|
27
|
+
n((e = e.apply(a, t)).next());
|
|
28
28
|
});
|
|
29
|
-
import * as
|
|
29
|
+
import * as h from "three";
|
|
30
30
|
import { Vector4 as k, Vector3 as B, Matrix4 as bt, Line3 as yt, Box3 as xt, Sphere as Mt, Mesh as wt, InstancedInterleavedBuffer as Pt, InterleavedBufferAttribute as tt, MathUtils as jt } from "three";
|
|
31
31
|
import { CSS2DObject as At } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
32
32
|
import { CSS3DObject as St, CSS3DSprite as Ct } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
@@ -50,22 +50,22 @@ class V {
|
|
|
50
50
|
return t;
|
|
51
51
|
if (Array.isArray(t))
|
|
52
52
|
return t.forEach((e) => this.track(e)), t;
|
|
53
|
-
if (!this.disposeWithMaterial && t instanceof
|
|
53
|
+
if (!this.disposeWithMaterial && t instanceof h.Material)
|
|
54
54
|
return t;
|
|
55
|
-
if (t instanceof V ? (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
|
|
55
|
+
if (t instanceof V ? (t === this && t.object3d ? this.track(t.object3d) : (t.disposeTrack = !1, this.resources.add(t)), Object.values(t.materialList).map((e) => this.track(e))) : (t instanceof h.Object3D || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof V)
|
|
56
56
|
this.track(t.children);
|
|
57
|
-
else if (t instanceof
|
|
57
|
+
else if (t instanceof h.Object3D) {
|
|
58
58
|
const e = t;
|
|
59
59
|
this.track(e.geometry), this.track(e.material), this.track(e.children);
|
|
60
|
-
} else if (t instanceof
|
|
61
|
-
for (const
|
|
62
|
-
|
|
60
|
+
} else if (t instanceof h.Material) {
|
|
61
|
+
for (const i of Object.values(t))
|
|
62
|
+
i instanceof h.Texture && this.track(i);
|
|
63
63
|
const e = t;
|
|
64
64
|
if (e.uniforms) {
|
|
65
|
-
for (const
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
(
|
|
65
|
+
for (const i of Object.values(e.uniforms))
|
|
66
|
+
if (i) {
|
|
67
|
+
const s = i.value;
|
|
68
|
+
(s instanceof h.Texture || Array.isArray(s)) && this.track(s);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -74,35 +74,35 @@ class V {
|
|
|
74
74
|
dispose() {
|
|
75
75
|
const t = [];
|
|
76
76
|
for (const e of this.resources)
|
|
77
|
-
e instanceof
|
|
77
|
+
e instanceof h.Object3D && t.push(e), Reflect.has(e, "dispose") && e.dispose();
|
|
78
78
|
t.forEach((e) => {
|
|
79
79
|
e.removeFromParent();
|
|
80
80
|
}), t.length = 0, this.resources.clear();
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
const Et = (a, t = 1) => {
|
|
84
|
-
const e = new
|
|
84
|
+
const e = new h.BufferGeometry();
|
|
85
85
|
e.setAttribute(
|
|
86
86
|
"position",
|
|
87
|
-
new
|
|
87
|
+
new h.Float32BufferAttribute(new Array(t * 3).fill(0), 3)
|
|
88
88
|
), e.setAttribute(
|
|
89
89
|
"scaleAtt",
|
|
90
|
-
new
|
|
90
|
+
new h.Float32BufferAttribute(new Array(t).fill(1), 1)
|
|
91
91
|
);
|
|
92
|
-
const
|
|
92
|
+
const i = a.material, s = new h.PointsMaterial({
|
|
93
93
|
size: 10,
|
|
94
|
-
map:
|
|
95
|
-
alphaMap:
|
|
96
|
-
color:
|
|
97
|
-
blending:
|
|
98
|
-
depthTest:
|
|
94
|
+
map: i.map,
|
|
95
|
+
alphaMap: i.alphaMap,
|
|
96
|
+
color: i.color,
|
|
97
|
+
blending: i.blending,
|
|
98
|
+
depthTest: i.depthTest,
|
|
99
99
|
depthWrite: !1,
|
|
100
|
-
opacity:
|
|
100
|
+
opacity: i.opacity,
|
|
101
101
|
transparent: !0,
|
|
102
|
-
alphaTest:
|
|
102
|
+
alphaTest: i.alphaTest,
|
|
103
103
|
sizeAttenuation: !1
|
|
104
104
|
});
|
|
105
|
-
return
|
|
105
|
+
return s.onBeforeCompile = (r) => {
|
|
106
106
|
r.vertexShader = `
|
|
107
107
|
attribute float scaleAtt;
|
|
108
108
|
${r.vertexShader.replace(
|
|
@@ -110,7 +110,7 @@ const Et = (a, t = 1) => {
|
|
|
110
110
|
"gl_PointSize = size * scaleAtt;"
|
|
111
111
|
)}
|
|
112
112
|
`;
|
|
113
|
-
}, new
|
|
113
|
+
}, new h.Points(e, s);
|
|
114
114
|
};
|
|
115
115
|
class Rt extends V {
|
|
116
116
|
constructor() {
|
|
@@ -169,13 +169,13 @@ class Rt extends V {
|
|
|
169
169
|
return this.object3d.visible = !1, this;
|
|
170
170
|
}
|
|
171
171
|
createMesh(...t) {
|
|
172
|
-
return this.object3d = new
|
|
172
|
+
return this.object3d = new h.Mesh(...t), this;
|
|
173
173
|
}
|
|
174
174
|
createGroup() {
|
|
175
|
-
return this.object3d = new
|
|
175
|
+
return this.object3d = new h.Group(), this;
|
|
176
176
|
}
|
|
177
177
|
createPoints(...t) {
|
|
178
|
-
return this.object3d = new
|
|
178
|
+
return this.object3d = new h.Points(...t), this;
|
|
179
179
|
}
|
|
180
180
|
createCSS2DObject(t) {
|
|
181
181
|
return this.object3d = new At(t), this;
|
|
@@ -187,7 +187,7 @@ class Rt extends V {
|
|
|
187
187
|
return this.object3d = new Ct(t), this;
|
|
188
188
|
}
|
|
189
189
|
createSprite(t) {
|
|
190
|
-
return this.object3d = new
|
|
190
|
+
return this.object3d = new h.Sprite(t), this;
|
|
191
191
|
}
|
|
192
192
|
attach(...t) {
|
|
193
193
|
return [...t].forEach((e) => {
|
|
@@ -195,12 +195,12 @@ class Rt extends V {
|
|
|
195
195
|
}), this;
|
|
196
196
|
}
|
|
197
197
|
getSize() {
|
|
198
|
-
const t = new
|
|
198
|
+
const t = new h.Box3().setFromObject(this.object3d);
|
|
199
199
|
return {
|
|
200
200
|
min: t.min,
|
|
201
201
|
max: t.max,
|
|
202
|
-
size: t.getSize(new
|
|
203
|
-
center: t.getCenter(new
|
|
202
|
+
size: t.getSize(new h.Vector3()),
|
|
203
|
+
center: t.getCenter(new h.Vector3())
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
traverse(t) {
|
|
@@ -211,52 +211,54 @@ class Rt extends V {
|
|
|
211
211
|
clone() {
|
|
212
212
|
return this.instantiate();
|
|
213
213
|
}
|
|
214
|
-
instantiate(t) {
|
|
214
|
+
instantiate(t, e) {
|
|
215
215
|
return J(this, null, function* () {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
216
|
+
const i = t && t.length > 0, { objectType: s, objectOptions: r } = this, [, c] = s.split("#");
|
|
217
|
+
let n = e == null ? void 0 : e.create;
|
|
218
|
+
n === void 0 && (n = (o) => {
|
|
219
|
+
var d;
|
|
220
|
+
if (this.object3d) {
|
|
221
|
+
if (i) {
|
|
222
|
+
const f = t.length;
|
|
223
|
+
if (this.object3d instanceof h.Sprite)
|
|
224
|
+
o.object3d = Et(this.object3d, f);
|
|
225
|
+
else {
|
|
226
|
+
const u = this.object3d;
|
|
227
|
+
o.object3d = new h.InstancedMesh(
|
|
228
|
+
u.geometry,
|
|
229
|
+
u.material,
|
|
230
|
+
f
|
|
231
|
+
), o.setMaterialList("instantiate", "clone"), o.useMaterial("instantiate");
|
|
232
|
+
}
|
|
233
|
+
const m = new h.Object3D();
|
|
234
|
+
t.forEach((u, v) => {
|
|
235
|
+
const p = et(u.position), b = et(u.scale || [1, 1, 1]);
|
|
236
|
+
m.position.copy(p), m.scale.copy(b), m.updateMatrix(), o.setInstancedMatrix(v, m.matrix.clone());
|
|
237
|
+
});
|
|
238
|
+
} else
|
|
239
|
+
o.object3d = this.object3d.clone(!1), o.setMaterialList("instantiate", "clone"), o.useMaterial("instantiate");
|
|
240
|
+
o.object3d.userData.bloom && ((d = this.pencil.composerController) == null || d.toggleBloomSelection(
|
|
241
|
+
o.object3d,
|
|
242
|
+
!0
|
|
243
|
+
)), o.object3d.userData.prefab && (o.object3d.userData.prefab = !1);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
const l = yield this.lead.draw(c, Z(O({}, r || {}), {
|
|
247
|
+
create: n,
|
|
248
|
+
prefab: !1,
|
|
249
|
+
target: (e == null ? void 0 : e.target) || (r == null ? void 0 : r.target)
|
|
246
250
|
}));
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
return l.isInstantiate = !0, l;
|
|
251
|
+
return yield Promise.all(
|
|
252
|
+
this.children.map((o) => o.instantiate(void 0, l))
|
|
253
|
+
), l.isInstantiate = !0, l;
|
|
252
254
|
});
|
|
253
255
|
}
|
|
254
256
|
setInstancedMatrix(t, e) {
|
|
255
|
-
if (this.object3d instanceof
|
|
257
|
+
if (this.object3d instanceof h.InstancedMesh || this.object3d.isInstantiate)
|
|
256
258
|
this.object3d.setMatrixAt(t, e);
|
|
257
|
-
else if (this.object3d instanceof
|
|
258
|
-
const
|
|
259
|
-
e.decompose(
|
|
259
|
+
else if (this.object3d instanceof h.Points || this.object3d.type === "Points") {
|
|
260
|
+
const s = this.object3d.geometry, r = s.attributes.position.array, c = s.attributes.scaleAtt.array, n = new h.Vector3(), l = new h.Vector3(), o = new h.Quaternion(), d = t * 3, f = t * 1;
|
|
261
|
+
e.decompose(n, o, l), r[d] = n.x, r[d + 1] = n.y, r[d + 2] = n.z, c[f] = Math.max(l.x, l.y, l.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
|
|
260
262
|
}
|
|
261
263
|
}
|
|
262
264
|
erase() {
|
|
@@ -268,27 +270,27 @@ class Rt extends V {
|
|
|
268
270
|
return;
|
|
269
271
|
const e = t.material;
|
|
270
272
|
if (Array.isArray(e))
|
|
271
|
-
return e.map((
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
const r =
|
|
275
|
-
return
|
|
273
|
+
return e.map((i) => {
|
|
274
|
+
const s = i.userData;
|
|
275
|
+
i.userData = {};
|
|
276
|
+
const r = i.clone();
|
|
277
|
+
return i.userData = s, r;
|
|
276
278
|
});
|
|
277
279
|
{
|
|
278
|
-
const
|
|
280
|
+
const i = e.userData;
|
|
279
281
|
e.userData = {};
|
|
280
|
-
const
|
|
281
|
-
return e.userData =
|
|
282
|
+
const s = e.clone();
|
|
283
|
+
return e.userData = i, s;
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
|
-
setMaterialList(t, e,
|
|
285
|
-
const
|
|
286
|
-
if (!
|
|
286
|
+
setMaterialList(t, e, i = !0) {
|
|
287
|
+
const s = this.object3d;
|
|
288
|
+
if (!s || !s.material)
|
|
287
289
|
return;
|
|
288
|
-
if (this.materialList.origin || (this.materialList.origin =
|
|
289
|
-
if (
|
|
290
|
-
const
|
|
291
|
-
|
|
290
|
+
if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t])
|
|
291
|
+
if (i) {
|
|
292
|
+
const c = this.materialList[t], n = new V();
|
|
293
|
+
n.track(c), n.dispose();
|
|
292
294
|
} else
|
|
293
295
|
return this.materialList[t];
|
|
294
296
|
const r = e === "clone" ? this.cloneMaterial() : e;
|
|
@@ -302,8 +304,8 @@ class Rt extends V {
|
|
|
302
304
|
this.object3d && (this.object3d.renderOrder = t);
|
|
303
305
|
}
|
|
304
306
|
onPointerEvent(t, e) {
|
|
305
|
-
const
|
|
306
|
-
this.onPointerIndex.push(
|
|
307
|
+
const i = this.lead.handlePick([this], t, e);
|
|
308
|
+
this.onPointerIndex.push(i);
|
|
307
309
|
}
|
|
308
310
|
dispose() {
|
|
309
311
|
this.onPointerIndex.forEach((t) => {
|
|
@@ -325,27 +327,27 @@ function ot(a, t, e) {
|
|
|
325
327
|
return T.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = L / e.width, T.y = L / e.height, T.applyMatrix4(a.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
|
|
326
328
|
}
|
|
327
329
|
function Ut(a, t) {
|
|
328
|
-
const e = a.matrixWorld,
|
|
329
|
-
for (let
|
|
330
|
-
M.start.fromBufferAttribute(
|
|
331
|
-
const
|
|
332
|
-
W.distanceSqToSegment(M.start, M.end,
|
|
333
|
-
point:
|
|
334
|
-
pointOnLine:
|
|
335
|
-
distance: W.origin.distanceTo(
|
|
330
|
+
const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, r = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
|
|
331
|
+
for (let n = 0, l = c; n < l; n++) {
|
|
332
|
+
M.start.fromBufferAttribute(s, n), M.end.fromBufferAttribute(r, n), M.applyMatrix4(e);
|
|
333
|
+
const o = new B(), d = new B();
|
|
334
|
+
W.distanceSqToSegment(M.start, M.end, d, o), d.distanceTo(o) < L * 0.5 && t.push({
|
|
335
|
+
point: d,
|
|
336
|
+
pointOnLine: o,
|
|
337
|
+
distance: W.origin.distanceTo(d),
|
|
336
338
|
object: a,
|
|
337
339
|
face: null,
|
|
338
|
-
faceIndex:
|
|
340
|
+
faceIndex: n,
|
|
339
341
|
uv: null,
|
|
340
342
|
uv1: null
|
|
341
343
|
});
|
|
342
344
|
}
|
|
343
345
|
}
|
|
344
346
|
function Gt(a, t, e) {
|
|
345
|
-
const
|
|
346
|
-
W.at(1, I), I.w = 1, I.applyMatrix4(t.matrixWorldInverse), I.applyMatrix4(
|
|
347
|
-
for (let
|
|
348
|
-
if (y.fromBufferAttribute(
|
|
347
|
+
const i = t.projectionMatrix, r = a.material.resolution, c = a.matrixWorld, n = a.geometry, l = n.attributes.instanceStart, o = n.attributes.instanceEnd, d = Math.min(n.instanceCount, l.count), f = -t.near;
|
|
348
|
+
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), N.multiplyMatrices(t.matrixWorldInverse, c);
|
|
349
|
+
for (let m = 0, u = d; m < u; m++) {
|
|
350
|
+
if (y.fromBufferAttribute(l, m), x.fromBufferAttribute(o, m), y.w = 1, x.w = 1, y.applyMatrix4(N), x.applyMatrix4(N), y.z > f && x.z > f)
|
|
349
351
|
continue;
|
|
350
352
|
if (y.z > f) {
|
|
351
353
|
const D = y.z - x.z, P = (y.z - f) / D;
|
|
@@ -354,12 +356,12 @@ function Gt(a, t, e) {
|
|
|
354
356
|
const D = x.z - y.z, P = (x.z - f) / D;
|
|
355
357
|
x.lerp(y, P);
|
|
356
358
|
}
|
|
357
|
-
y.applyMatrix4(
|
|
358
|
-
const
|
|
359
|
-
M.at(
|
|
360
|
-
const b = jt.lerp(y.z, x.z,
|
|
359
|
+
y.applyMatrix4(i), x.applyMatrix4(i), y.multiplyScalar(1 / y.w), x.multiplyScalar(1 / x.w), y.x *= r.x / 2, y.y *= r.y / 2, x.x *= r.x / 2, x.y *= r.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(x), M.end.z = 0;
|
|
360
|
+
const p = M.closestPointToPointParameter(q, !0);
|
|
361
|
+
M.at(p, at);
|
|
362
|
+
const b = jt.lerp(y.z, x.z, p), C = b >= -1 && b <= 1, z = q.distanceTo(at) < L * 0.5;
|
|
361
363
|
if (C && z) {
|
|
362
|
-
M.start.fromBufferAttribute(
|
|
364
|
+
M.start.fromBufferAttribute(l, m), M.end.fromBufferAttribute(o, m), M.start.applyMatrix4(c), M.end.applyMatrix4(c);
|
|
363
365
|
const D = new B(), P = new B();
|
|
364
366
|
W.distanceSqToSegment(M.start, M.end, P, D), e.push({
|
|
365
367
|
point: P,
|
|
@@ -367,24 +369,24 @@ function Gt(a, t, e) {
|
|
|
367
369
|
distance: W.origin.distanceTo(P),
|
|
368
370
|
object: a,
|
|
369
371
|
face: null,
|
|
370
|
-
faceIndex:
|
|
372
|
+
faceIndex: m,
|
|
371
373
|
uv: null,
|
|
372
374
|
uv1: null
|
|
373
375
|
});
|
|
374
376
|
}
|
|
375
377
|
}
|
|
376
378
|
}
|
|
377
|
-
class
|
|
379
|
+
class de extends wt {
|
|
378
380
|
constructor(t = new Wt(), e) {
|
|
379
381
|
super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
|
|
380
382
|
}
|
|
381
383
|
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
382
384
|
computeLineDistances() {
|
|
383
|
-
const t = this.geometry, e = t.attributes.instanceStart,
|
|
384
|
-
for (let
|
|
385
|
-
nt.fromBufferAttribute(e,
|
|
385
|
+
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
|
|
386
|
+
for (let c = 0, n = 0, l = e.count; c < l; c++, n += 2)
|
|
387
|
+
nt.fromBufferAttribute(e, c), rt.fromBufferAttribute(i, c), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + nt.distanceTo(rt);
|
|
386
388
|
const r = new Pt(
|
|
387
|
-
|
|
389
|
+
s,
|
|
388
390
|
2,
|
|
389
391
|
1
|
|
390
392
|
);
|
|
@@ -397,46 +399,46 @@ class pe extends wt {
|
|
|
397
399
|
), this;
|
|
398
400
|
}
|
|
399
401
|
raycast(t, e) {
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
+
const i = this.material.worldUnits, s = t.camera;
|
|
403
|
+
s === null && !i && console.error(
|
|
402
404
|
'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
|
|
403
405
|
);
|
|
404
406
|
const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
|
|
405
407
|
W = t.ray;
|
|
406
|
-
const
|
|
407
|
-
L =
|
|
408
|
-
let
|
|
409
|
-
if (
|
|
410
|
-
|
|
408
|
+
const c = this.matrixWorld, n = this.geometry, l = this.material;
|
|
409
|
+
L = l.linewidth + r, n.boundingSphere === null && n.computeBoundingSphere(), U.copy(n.boundingSphere).applyMatrix4(c);
|
|
410
|
+
let o;
|
|
411
|
+
if (i)
|
|
412
|
+
o = L * 0.5;
|
|
411
413
|
else {
|
|
412
414
|
const f = Math.max(
|
|
413
|
-
|
|
415
|
+
s.near,
|
|
414
416
|
U.distanceToPoint(W.origin)
|
|
415
417
|
);
|
|
416
|
-
|
|
417
|
-
|
|
418
|
+
o = ot(
|
|
419
|
+
s,
|
|
418
420
|
f,
|
|
419
|
-
|
|
421
|
+
l.resolution
|
|
420
422
|
);
|
|
421
423
|
}
|
|
422
|
-
if (U.radius +=
|
|
424
|
+
if (U.radius += o, W.intersectsSphere(U) === !1)
|
|
423
425
|
return;
|
|
424
|
-
|
|
425
|
-
let
|
|
426
|
-
if (
|
|
427
|
-
|
|
426
|
+
n.boundingBox === null && n.computeBoundingBox(), R.copy(n.boundingBox).applyMatrix4(c);
|
|
427
|
+
let d;
|
|
428
|
+
if (i)
|
|
429
|
+
d = L * 0.5;
|
|
428
430
|
else {
|
|
429
431
|
const f = Math.max(
|
|
430
|
-
|
|
432
|
+
s.near,
|
|
431
433
|
R.distanceToPoint(W.origin)
|
|
432
434
|
);
|
|
433
|
-
|
|
434
|
-
|
|
435
|
+
d = ot(
|
|
436
|
+
s,
|
|
435
437
|
f,
|
|
436
|
-
|
|
438
|
+
l.resolution
|
|
437
439
|
);
|
|
438
440
|
}
|
|
439
|
-
R.expandByScalar(
|
|
441
|
+
R.expandByScalar(d), W.intersectsBox(R) !== !1 && (i ? Ut(this, e) : Gt(this, s, e));
|
|
440
442
|
}
|
|
441
443
|
onBeforeRender(t) {
|
|
442
444
|
const e = this.material.uniforms;
|
|
@@ -591,22 +593,22 @@ const lt = ["encodings_fragment", "colorspace_fragment"], Ft = (
|
|
|
591
593
|
|
|
592
594
|
#include <fog_fragment>
|
|
593
595
|
#include <tonemapping_fragment>
|
|
594
|
-
#include <${+
|
|
596
|
+
#include <${+h.REVISION < 154 ? lt[0] : lt[1]}>
|
|
595
597
|
}
|
|
596
598
|
`
|
|
597
599
|
);
|
|
598
|
-
class
|
|
600
|
+
class pe extends h.ShaderMaterial {
|
|
599
601
|
constructor(t) {
|
|
600
602
|
super({
|
|
601
|
-
uniforms: Z(O({},
|
|
603
|
+
uniforms: Z(O({}, h.UniformsLib.fog), {
|
|
602
604
|
lineWidth: { value: 1 },
|
|
603
605
|
map: { value: null },
|
|
604
606
|
useMap: { value: 0 },
|
|
605
607
|
alphaMap: { value: null },
|
|
606
608
|
useAlphaMap: { value: 0 },
|
|
607
|
-
color: { value: new
|
|
609
|
+
color: { value: new h.Color(16777215) },
|
|
608
610
|
opacity: { value: 1 },
|
|
609
|
-
resolution: { value: new
|
|
611
|
+
resolution: { value: new h.Vector2(1, 1) },
|
|
610
612
|
sizeAttenuation: { value: 1 },
|
|
611
613
|
dashArray: { value: 0 },
|
|
612
614
|
dashOffset: { value: 0 },
|
|
@@ -615,16 +617,16 @@ class de extends u.ShaderMaterial {
|
|
|
615
617
|
useDepth: { value: 0 },
|
|
616
618
|
visibility: { value: 1 },
|
|
617
619
|
alphaTest: { value: 0 },
|
|
618
|
-
repeat: { value: new
|
|
619
|
-
offset: { value: new
|
|
620
|
+
repeat: { value: new h.Vector2(1, 1) },
|
|
621
|
+
offset: { value: new h.Vector2(0, 0) },
|
|
620
622
|
offsetLoop: { value: 1 },
|
|
621
623
|
lineLightAnimation: { value: 0 },
|
|
622
624
|
time: { value: 0 },
|
|
623
625
|
size: { value: 300 },
|
|
624
626
|
speed: { value: 0.3 },
|
|
625
627
|
lightWidth: { value: 0.1 },
|
|
626
|
-
uCenter: { value: new
|
|
627
|
-
lightColor: { value: new
|
|
628
|
+
uCenter: { value: new h.Vector2(0, 0) },
|
|
629
|
+
lightColor: { value: new h.Color(16777215) }
|
|
628
630
|
}),
|
|
629
631
|
vertexShader: Ft,
|
|
630
632
|
fragmentShader: Zt
|
|
@@ -853,58 +855,58 @@ class de extends u.ShaderMaterial {
|
|
|
853
855
|
}
|
|
854
856
|
function $t(a, t) {
|
|
855
857
|
return a.map((e) => {
|
|
856
|
-
const
|
|
857
|
-
let
|
|
858
|
+
const i = [];
|
|
859
|
+
let s;
|
|
858
860
|
return e.forEach((r) => {
|
|
859
|
-
if (
|
|
860
|
-
const
|
|
861
|
-
if (
|
|
862
|
-
const
|
|
863
|
-
let
|
|
864
|
-
for (;
|
|
865
|
-
|
|
861
|
+
if (s) {
|
|
862
|
+
const c = Dt(r, s) * 180 / Math.PI;
|
|
863
|
+
if (c > t) {
|
|
864
|
+
const n = It(s, r), l = 1 / Math.ceil(c / t);
|
|
865
|
+
let o = l;
|
|
866
|
+
for (; o < 1; )
|
|
867
|
+
i.push(n(o)), o += l;
|
|
866
868
|
}
|
|
867
869
|
}
|
|
868
|
-
|
|
869
|
-
}),
|
|
870
|
+
i.push(s = r);
|
|
871
|
+
}), i;
|
|
870
872
|
});
|
|
871
873
|
}
|
|
872
|
-
function qt(a, { minLng: t, maxLng: e, minLat:
|
|
873
|
-
const r = Math.round(H(360 / a, 2) / Math.PI),
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
], f = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (
|
|
877
|
-
for (let
|
|
878
|
-
const
|
|
879
|
-
f(
|
|
874
|
+
function qt(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
875
|
+
const r = Math.round(H(360 / a, 2) / Math.PI), c = (1 + Math.sqrt(5)) / 2, n = (u) => u / c * 360 % 360 - 180, l = (u) => Math.acos(2 * u / r - 1) / Math.PI * 180 - 90, o = (u) => r * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, d = [
|
|
876
|
+
s !== void 0 ? Math.ceil(o(s)) : 0,
|
|
877
|
+
i !== void 0 ? Math.floor(o(i)) : r - 1
|
|
878
|
+
], f = 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, m = [];
|
|
879
|
+
for (let u = d[0]; u <= d[1]; u++) {
|
|
880
|
+
const v = n(u);
|
|
881
|
+
f(v) && m.push([v, l(u)]);
|
|
880
882
|
}
|
|
881
|
-
return
|
|
883
|
+
return m;
|
|
882
884
|
}
|
|
883
885
|
function Q(a, t, e = !1) {
|
|
884
886
|
return e ? zt(t, a) : Vt(a, t);
|
|
885
887
|
}
|
|
886
888
|
function Nt(a, t) {
|
|
887
|
-
const e = { type: "Polygon", coordinates: a }, [[
|
|
888
|
-
if (Math.min(Math.abs(r -
|
|
889
|
+
const e = { type: "Polygon", coordinates: a }, [[i, s], [r, c]] = ht(e);
|
|
890
|
+
if (Math.min(Math.abs(r - i), Math.abs(c - s)) < t)
|
|
889
891
|
return [];
|
|
890
|
-
const
|
|
892
|
+
const n = i > r || c >= 89 || s <= -89;
|
|
891
893
|
return qt(t, {
|
|
892
|
-
minLng:
|
|
894
|
+
minLng: i,
|
|
893
895
|
maxLng: r,
|
|
894
|
-
minLat:
|
|
895
|
-
maxLat:
|
|
896
|
+
minLat: s,
|
|
897
|
+
maxLat: c
|
|
896
898
|
}).filter(
|
|
897
|
-
(
|
|
899
|
+
(l) => Q(l, e, n)
|
|
898
900
|
);
|
|
899
901
|
}
|
|
900
|
-
function Qt(a, { resolution: t = 1 / 0, bbox: e, projection:
|
|
901
|
-
const
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
let
|
|
905
|
-
if (
|
|
906
|
-
const g = kt(
|
|
907
|
-
|
|
902
|
+
function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
903
|
+
const s = $t(a, t), r = K(s), c = Nt(a, t), n = [...r, ...c], l = { type: "Polygon", coordinates: a }, [[o, d], [f, m]] = ht(l), u = o > f || // crosses antimeridian
|
|
904
|
+
m >= 89 || // crosses north pole
|
|
905
|
+
d <= -89;
|
|
906
|
+
let v = [];
|
|
907
|
+
if (u) {
|
|
908
|
+
const g = kt(n).triangles(), w = new Map(
|
|
909
|
+
n.map(([j, A], _) => [`${j}-${A}`, _])
|
|
908
910
|
);
|
|
909
911
|
g.features.forEach((j) => {
|
|
910
912
|
const A = j.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
|
|
@@ -916,98 +918,98 @@ function Qt(a, { resolution: t = 1 / 0, bbox: e, projection: s } = {}) {
|
|
|
916
918
|
const S = j.properties.circumcenter;
|
|
917
919
|
if (!Q(
|
|
918
920
|
S,
|
|
919
|
-
|
|
920
|
-
|
|
921
|
+
l,
|
|
922
|
+
u
|
|
921
923
|
))
|
|
922
924
|
return;
|
|
923
925
|
}
|
|
924
|
-
|
|
926
|
+
v.push(..._);
|
|
925
927
|
}
|
|
926
928
|
});
|
|
927
|
-
} else if (
|
|
928
|
-
const g = Ot.from(
|
|
929
|
+
} else if (c.length) {
|
|
930
|
+
const g = Ot.from(n);
|
|
929
931
|
for (let w = 0, j = g.triangles.length; w < j; w += 3) {
|
|
930
|
-
const A = [2, 1, 0].map((S) => g.triangles[w + S]), _ = A.map((S) =>
|
|
932
|
+
const A = [2, 1, 0].map((S) => g.triangles[w + S]), _ = A.map((S) => n[S]);
|
|
931
933
|
if (A.some((S) => S < r.length)) {
|
|
932
934
|
const S = [0, 1].map(
|
|
933
935
|
(F) => _t(_, (E) => E[F])
|
|
934
936
|
);
|
|
935
937
|
if (!Q(
|
|
936
938
|
S,
|
|
937
|
-
|
|
938
|
-
|
|
939
|
+
l,
|
|
940
|
+
u
|
|
939
941
|
))
|
|
940
942
|
continue;
|
|
941
943
|
}
|
|
942
|
-
|
|
944
|
+
v.push(...A);
|
|
943
945
|
}
|
|
944
946
|
} else {
|
|
945
|
-
const { vertices: g, holes: w = [] } = ft(
|
|
946
|
-
|
|
947
|
+
const { vertices: g, holes: w = [] } = ft(s);
|
|
948
|
+
v = Bt(g, w, 2);
|
|
947
949
|
}
|
|
948
|
-
let
|
|
949
|
-
if (
|
|
950
|
-
const [g, w] =
|
|
951
|
-
|
|
950
|
+
let p = e ? [e[0], e[2]] : it(n, (g) => g[0]), b = e ? [e[1], e[3]] : it(n, (g) => g[1]);
|
|
951
|
+
if (i) {
|
|
952
|
+
const [g, w] = i([p[0], b[0]]), [j, A] = i([p[1], b[1]]);
|
|
953
|
+
p = [g, j], b = [-w, -A];
|
|
952
954
|
}
|
|
953
|
-
const C = st(
|
|
954
|
-
if (
|
|
955
|
-
const [j, A] =
|
|
955
|
+
const C = st(p, [0, 1]), z = st(b, [0, 1]), D = n.map(([g, w]) => {
|
|
956
|
+
if (i) {
|
|
957
|
+
const [j, A] = i([g, w]);
|
|
956
958
|
return [C(j), z(-A)];
|
|
957
959
|
} else
|
|
958
960
|
return [C(g), z(w)];
|
|
959
961
|
});
|
|
960
|
-
return { contour:
|
|
962
|
+
return { contour: s, triangles: { points: n, indices: v, uvs: D } };
|
|
961
963
|
}
|
|
962
|
-
const ct = new
|
|
963
|
-
function G(a, t, e,
|
|
964
|
-
const
|
|
965
|
-
(r) => r.map(([
|
|
966
|
-
if (
|
|
967
|
-
const [
|
|
968
|
-
return [
|
|
964
|
+
const ct = new h.BufferGeometry().setAttribute ? "setAttribute" : "addAttribute";
|
|
965
|
+
function G(a, t, e, i) {
|
|
966
|
+
const s = a.map(
|
|
967
|
+
(r) => r.map(([c, n]) => {
|
|
968
|
+
if (i) {
|
|
969
|
+
const [l, o] = i([c, n]);
|
|
970
|
+
return [l, -o, t];
|
|
969
971
|
}
|
|
970
|
-
return e ? Tt(
|
|
972
|
+
return e ? Tt(c, n, t) : [c, n, t];
|
|
971
973
|
})
|
|
972
974
|
);
|
|
973
|
-
return ft(
|
|
975
|
+
return ft(s);
|
|
974
976
|
}
|
|
975
|
-
function Kt(a, t, e,
|
|
976
|
-
const { vertices: r, holes:
|
|
977
|
+
function Kt(a, t, e, i, s) {
|
|
978
|
+
const { vertices: r, holes: c } = G(
|
|
977
979
|
a,
|
|
978
980
|
t,
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
), { vertices:
|
|
981
|
+
i,
|
|
982
|
+
s
|
|
983
|
+
), { vertices: n } = G(
|
|
982
984
|
a,
|
|
983
985
|
e,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
),
|
|
986
|
+
i,
|
|
987
|
+
s
|
|
988
|
+
), l = K([n, r]), o = Math.round(n.length / 3), d = new Set(c);
|
|
987
989
|
let f = 0;
|
|
988
|
-
const
|
|
989
|
-
for (let
|
|
990
|
-
let
|
|
991
|
-
if (
|
|
992
|
-
|
|
993
|
-
else if (
|
|
994
|
-
const b =
|
|
995
|
-
|
|
990
|
+
const m = [];
|
|
991
|
+
for (let v = 0; v < o; v++) {
|
|
992
|
+
let p = v + 1;
|
|
993
|
+
if (p === o)
|
|
994
|
+
p = f;
|
|
995
|
+
else if (d.has(p)) {
|
|
996
|
+
const b = p;
|
|
997
|
+
p = f, f = b;
|
|
996
998
|
}
|
|
997
|
-
|
|
999
|
+
m.push(v, v + o, p + o), m.push(p + o, p, v);
|
|
998
1000
|
}
|
|
999
|
-
const
|
|
1000
|
-
for (let
|
|
1001
|
-
for (let
|
|
1002
|
-
return { indices:
|
|
1001
|
+
const u = [];
|
|
1002
|
+
for (let v = 1; v >= 0; v--)
|
|
1003
|
+
for (let p = 0; p < o; p += 1) u.push(p / (o - 1), v);
|
|
1004
|
+
return { indices: m, vertices: l, uvs: u, topVerts: n };
|
|
1003
1005
|
}
|
|
1004
|
-
function ut(a, t, e,
|
|
1006
|
+
function ut(a, t, e, i, s, r) {
|
|
1005
1007
|
return {
|
|
1006
|
-
indices:
|
|
1008
|
+
indices: i ? a.indices : a.indices.slice().reverse(),
|
|
1007
1009
|
vertices: G(
|
|
1008
1010
|
[a.points],
|
|
1009
1011
|
t,
|
|
1010
|
-
|
|
1012
|
+
s,
|
|
1011
1013
|
r
|
|
1012
1014
|
).vertices,
|
|
1013
1015
|
uvs: e
|
|
@@ -1017,52 +1019,52 @@ const Xt = ({
|
|
|
1017
1019
|
polygonGeoJson: a,
|
|
1018
1020
|
startHeight: t,
|
|
1019
1021
|
endHeight: e,
|
|
1020
|
-
curvatureResolution:
|
|
1021
|
-
cartesian:
|
|
1022
|
+
curvatureResolution: i = 1,
|
|
1023
|
+
cartesian: s = !0,
|
|
1022
1024
|
hasSide: r = !0,
|
|
1023
|
-
hasBottom:
|
|
1024
|
-
hasTop:
|
|
1025
|
-
projection:
|
|
1026
|
-
bbox:
|
|
1025
|
+
hasBottom: c = !1,
|
|
1026
|
+
hasTop: n = !1,
|
|
1027
|
+
projection: l,
|
|
1028
|
+
bbox: o
|
|
1027
1029
|
}) => {
|
|
1028
1030
|
a.forEach((C) => {
|
|
1029
1031
|
Lt(C) || C.reverse();
|
|
1030
1032
|
});
|
|
1031
|
-
const { contour:
|
|
1032
|
-
resolution:
|
|
1033
|
-
bbox:
|
|
1034
|
-
projection:
|
|
1033
|
+
const { contour: d, triangles: f } = Qt(a, {
|
|
1034
|
+
resolution: i,
|
|
1035
|
+
bbox: o,
|
|
1036
|
+
projection: l
|
|
1035
1037
|
});
|
|
1036
|
-
let
|
|
1037
|
-
r && (
|
|
1038
|
-
|
|
1038
|
+
let m = {}, u;
|
|
1039
|
+
r && (m = Kt(
|
|
1040
|
+
d,
|
|
1039
1041
|
t != null ? t : e,
|
|
1040
1042
|
e != null ? e : t,
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
),
|
|
1044
|
-
let
|
|
1045
|
-
(
|
|
1046
|
-
let
|
|
1047
|
-
|
|
1043
|
+
s,
|
|
1044
|
+
l
|
|
1045
|
+
), u = m.topVerts);
|
|
1046
|
+
let v = [];
|
|
1047
|
+
(c || n) && (v = K(f.uvs));
|
|
1048
|
+
let p = {};
|
|
1049
|
+
c && (p = ut(
|
|
1048
1050
|
f,
|
|
1049
1051
|
t,
|
|
1050
|
-
|
|
1052
|
+
v,
|
|
1051
1053
|
!1,
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
+
s,
|
|
1055
|
+
l
|
|
1054
1056
|
));
|
|
1055
1057
|
let b = {};
|
|
1056
|
-
return
|
|
1058
|
+
return n && (b = ut(
|
|
1057
1059
|
f,
|
|
1058
1060
|
e,
|
|
1059
|
-
|
|
1061
|
+
v,
|
|
1060
1062
|
!0,
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
)), { contour:
|
|
1063
|
+
s,
|
|
1064
|
+
l
|
|
1065
|
+
)), { contour: d, triangles: f, sideTorso: m, bottomCap: p, topCap: b, topVerts: u };
|
|
1064
1066
|
};
|
|
1065
|
-
class me extends
|
|
1067
|
+
class me extends h.BufferGeometry {
|
|
1066
1068
|
constructor(t, e = {}) {
|
|
1067
1069
|
super(), this.type = "PolygonBufferGeometry", this.parameters = O({
|
|
1068
1070
|
polygonGeoJson: t,
|
|
@@ -1077,15 +1079,15 @@ class me extends u.BufferGeometry {
|
|
|
1077
1079
|
userDataRsoOffset: 0
|
|
1078
1080
|
}, e);
|
|
1079
1081
|
const {
|
|
1080
|
-
endHeight:
|
|
1081
|
-
hasTop:
|
|
1082
|
+
endHeight: i,
|
|
1083
|
+
hasTop: s,
|
|
1082
1084
|
topFirst: r,
|
|
1083
|
-
hasBottom:
|
|
1084
|
-
hasSide:
|
|
1085
|
-
cartesian:
|
|
1086
|
-
userDataRsoOffset:
|
|
1087
|
-
projection:
|
|
1088
|
-
} = this.parameters, { contour: f, sideTorso:
|
|
1085
|
+
hasBottom: c,
|
|
1086
|
+
hasSide: n,
|
|
1087
|
+
cartesian: l,
|
|
1088
|
+
userDataRsoOffset: o,
|
|
1089
|
+
projection: d
|
|
1090
|
+
} = this.parameters, { contour: f, sideTorso: m, topVerts: u, bottomCap: v, topCap: p } = Xt(O({}, this.parameters));
|
|
1089
1091
|
let b = [], C = [], z = [], D = 0;
|
|
1090
1092
|
const P = (g) => {
|
|
1091
1093
|
const w = Math.round(b.length / 3), j = z.length;
|
|
@@ -1093,22 +1095,22 @@ class me extends u.BufferGeometry {
|
|
|
1093
1095
|
w ? g.indices.map((A) => A + w) : g.indices
|
|
1094
1096
|
), this.addGroup(j, z.length - j, D++);
|
|
1095
1097
|
};
|
|
1096
|
-
|
|
1098
|
+
s && r && P(p), n && (P(m), this.userData.topVerts = o ? G(
|
|
1097
1099
|
f,
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
).vertices :
|
|
1100
|
+
i + o,
|
|
1101
|
+
l,
|
|
1102
|
+
d
|
|
1103
|
+
).vertices : u), c && P(v), s && !r && P(p), this.setIndex(z), this[ct](
|
|
1102
1104
|
"position",
|
|
1103
|
-
new
|
|
1104
|
-
), this[ct]("uv", new
|
|
1105
|
+
new h.Float32BufferAttribute(b, 3)
|
|
1106
|
+
), this[ct]("uv", new h.Float32BufferAttribute(C, 2)), this.computeVertexNormals();
|
|
1105
1107
|
}
|
|
1106
1108
|
}
|
|
1107
1109
|
export {
|
|
1108
1110
|
Rt as B,
|
|
1109
1111
|
fe as G,
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
+
de as L,
|
|
1113
|
+
pe as M,
|
|
1112
1114
|
me as P,
|
|
1113
1115
|
V as R,
|
|
1114
1116
|
Xt as g
|
package/dist/index2.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var dt=Object.defineProperty,pt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var tt=Math.pow,J=(r,t,e)=>t in r?dt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k=(r,t)=>{for(var e in t||(t={}))vt.call(t,e)&&J(r,e,t[e]);if(Y)for(var e of Y(t))gt.call(t,e)&&J(r,e,t[e]);return r},Z=(r,t)=>pt(r,mt(t));var et=(r,t,e)=>new Promise((s
|
|
1
|
+
"use strict";var dt=Object.defineProperty,pt=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var vt=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var tt=Math.pow,J=(r,t,e)=>t in r?dt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k=(r,t)=>{for(var e in t||(t={}))vt.call(t,e)&&J(r,e,t[e]);if(Y)for(var e of Y(t))gt.call(t,e)&&J(r,e,t[e]);return r},Z=(r,t)=>pt(r,mt(t));var et=(r,t,e)=>new Promise((i,s)=>{var a=l=>{try{n(e.next(l))}catch(o){s(o)}},c=l=>{try{n(e.throw(l))}catch(o){s(o)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,c);n((e=e.apply(r,t)).next())});const g=require("three"),bt=require("three/examples/jsm/renderers/CSS2DRenderer"),it=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const H=require("./parseVector.js"),yt=require("three/examples/jsm/lines/LineSegmentsGeometry"),W=require("d3-array"),K=require("earcut"),xt=require("@turf/boolean-clockwise"),Mt=require("delaunator"),wt=require("@turf/boolean-point-in-polygon"),Pt=require("d3-geo-voronoi"),st=require("d3-scale");function jt(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>r[e]})}}return t.default=r,Object.freeze(t)}const h=jt(g);class B{constructor(){this.resources=new Set,this.disposeWithMaterial=!0,this.materialList={},this.disposeTrack=!0}track(t){if(!t||this.disposeTrack===!1)return t;if(Array.isArray(t))return t.forEach(e=>this.track(e)),t;if(!this.disposeWithMaterial&&t instanceof h.Material)return t;if(t instanceof B?(t===this&&t.object3d?this.track(t.object3d):(t.disposeTrack=!1,this.resources.add(t)),Object.values(t.materialList).map(e=>this.track(e))):(t instanceof h.Object3D||Reflect.has(t,"dispose"))&&this.resources.add(t),t instanceof B)this.track(t.children);else if(t instanceof h.Object3D){const e=t;this.track(e.geometry),this.track(e.material),this.track(e.children)}else if(t instanceof h.Material){for(const i of Object.values(t))i instanceof h.Texture&&this.track(i);const e=t;if(e.uniforms){for(const i of Object.values(e.uniforms))if(i){const s=i.value;(s instanceof h.Texture||Array.isArray(s))&&this.track(s)}}}return t}dispose(){const t=[];for(const e of this.resources)e instanceof h.Object3D&&t.push(e),Reflect.has(e,"dispose")&&e.dispose();t.forEach(e=>{e.removeFromParent()}),t.length=0,this.resources.clear()}}const At=(r,t=1)=>{const e=new h.BufferGeometry;e.setAttribute("position",new h.Float32BufferAttribute(new Array(t*3).fill(0),3)),e.setAttribute("scaleAtt",new h.Float32BufferAttribute(new Array(t).fill(1),1));const i=r.material,s=new h.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return s.onBeforeCompile=a=>{a.vertexShader=`
|
|
2
2
|
attribute float scaleAtt;
|
|
3
|
-
${
|
|
4
|
-
`},new
|
|
3
|
+
${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
|
|
4
|
+
`},new h.Points(e,s)};class ht extends B{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.materialList={},this.useMaterialType="origin",this.onPointerIndex=[]}get parent(){const t=this.object3d.parent;return t&&this.lead.objMap.get(t)||null}get children(){return this.object3d.children.map(t=>this.lead.objMap.get(t)).filter(t=>!!t)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}get add(){return this.object3d.add.bind(this.object3d)}get remove(){return this.object3d.remove.bind(this.object3d)}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let t=this.parent;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(t,e){}resize(t,e){}show(){return this.object3d.visible=!0,this}hide(){return this.object3d.visible=!1,this}createMesh(...t){return this.object3d=new h.Mesh(...t),this}createGroup(){return this.object3d=new h.Group,this}createPoints(...t){return this.object3d=new h.Points(...t),this}createCSS2DObject(t){return this.object3d=new bt.CSS2DObject(t),this}createCSS3DObject(t){return this.object3d=new it.CSS3DObject(t),this}createCSS3DSprite(t){return this.object3d=new it.CSS3DSprite(t),this}createSprite(t){return this.object3d=new h.Sprite(t),this}attach(...t){return[...t].forEach(e=>{this.object3d.attach(e.object3d)}),this}getSize(){const t=new h.Box3().setFromObject(this.object3d);return{min:t.min,max:t.max,size:t.getSize(new h.Vector3),center:t.getCenter(new h.Vector3)}}traverse(t){t(this),this.children.forEach(e=>{e.traverse(t)})}clone(){return this.instantiate()}instantiate(t,e){return et(this,null,function*(){const i=t&&t.length>0,{objectType:s,objectOptions:a}=this,[,c]=s.split("#");let n=e==null?void 0:e.create;n===void 0&&(n=o=>{var d;if(this.object3d){if(i){const f=t.length;if(this.object3d instanceof h.Sprite)o.object3d=At(this.object3d,f);else{const u=this.object3d;o.object3d=new h.InstancedMesh(u.geometry,u.material,f),o.setMaterialList("instantiate","clone"),o.useMaterial("instantiate")}const m=new h.Object3D;t.forEach((u,v)=>{const p=H.parseVector3(u.position),y=H.parseVector3(u.scale||[1,1,1]);m.position.copy(p),m.scale.copy(y),m.updateMatrix(),o.setInstancedMatrix(v,m.matrix.clone())})}else o.object3d=this.object3d.clone(!1),o.setMaterialList("instantiate","clone"),o.useMaterial("instantiate");o.object3d.userData.bloom&&((d=this.pencil.composerController)==null||d.toggleBloomSelection(o.object3d,!0)),o.object3d.userData.prefab&&(o.object3d.userData.prefab=!1)}});const l=yield this.lead.draw(c,Z(k({},a||{}),{create:n,prefab:!1,target:(e==null?void 0:e.target)||(a==null?void 0:a.target)}));return yield Promise.all(this.children.map(o=>o.instantiate(void 0,l))),l.isInstantiate=!0,l})}setInstancedMatrix(t,e){if(this.object3d instanceof h.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(t,e);else if(this.object3d instanceof h.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,c=s.attributes.scaleAtt.array,n=new h.Vector3,l=new h.Vector3,o=new h.Quaternion,d=t*3,f=t*1;e.decompose(n,o,l),a[d]=n.x,a[d+1]=n.y,a[d+2]=n.z,c[f]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.dispose()}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 c=this.materialList[t],n=new B;n.track(c),n.dispose()}else return this.materialList[t];const a=e==="clone"?this.cloneMaterial():e;return this.materialList[t]=a,a}useMaterial(t){const e=this.object3d;!e||!e.material||this.useMaterialType===t||!this.materialList[t]||(this.useMaterialType=t,e.material=this.materialList[t])}setTop(t){this.object3d&&(this.object3d.renderOrder=t)}onPointerEvent(t,e){const i=this.lead.handlePick([this],t,e);this.onPointerIndex.push(i)}dispose(){this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.lead&&(this.lead.objects.delete(this.key),this.object3d&&this.lead.objMap.delete(this.object3d)),this.track(this),super.dispose()}disposeWithOutMaterial(){this.disposeWithMaterial=!1,this.dispose()}}class St extends ht{create(){this.createGroup()}}const $=new g.Vector4,nt=new g.Vector3,rt=new g.Vector3,x=new g.Vector4,M=new g.Vector4,I=new g.Vector4,N=new g.Vector3,Q=new g.Matrix4,w=new g.Line3,at=new g.Vector3,R=new g.Box3,U=new g.Sphere,T=new g.Vector4;let _,L;function ot(r,t,e){return T.set(0,0,-t,1).applyMatrix4(r.projectionMatrix),T.multiplyScalar(1/T.w),T.x=L/e.width,T.y=L/e.height,T.applyMatrix4(r.projectionMatrixInverse),T.multiplyScalar(1/T.w),Math.abs(Math.max(T.x,T.y))}function Ct(r,t){const e=r.matrixWorld,i=r.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let n=0,l=c;n<l;n++){w.start.fromBufferAttribute(s,n),w.end.fromBufferAttribute(a,n),w.applyMatrix4(e);const o=new g.Vector3,d=new g.Vector3;_.distanceSqToSegment(w.start,w.end,d,o),d.distanceTo(o)<L*.5&&t.push({point:d,pointOnLine:o,distance:_.origin.distanceTo(d),object:r,face:null,faceIndex:n,uv:null,uv1:null})}}function Dt(r,t,e){const i=t.projectionMatrix,a=r.material.resolution,c=r.matrixWorld,n=r.geometry,l=n.attributes.instanceStart,o=n.attributes.instanceEnd,d=Math.min(n.instanceCount,l.count),f=-t.near;_.at(1,I),I.w=1,I.applyMatrix4(t.matrixWorldInverse),I.applyMatrix4(i),I.multiplyScalar(1/I.w),I.x*=a.x/2,I.y*=a.y/2,I.z=0,N.copy(I),Q.multiplyMatrices(t.matrixWorldInverse,c);for(let m=0,u=d;m<u;m++){if(x.fromBufferAttribute(l,m),M.fromBufferAttribute(o,m),x.w=1,M.w=1,x.applyMatrix4(Q),M.applyMatrix4(Q),x.z>f&&M.z>f)continue;if(x.z>f){const V=x.z-M.z,j=(x.z-f)/V;x.lerp(M,j)}else if(M.z>f){const V=M.z-x.z,j=(M.z-f)/V;M.lerp(x,j)}x.applyMatrix4(i),M.applyMatrix4(i),x.multiplyScalar(1/x.w),M.multiplyScalar(1/M.w),x.x*=a.x/2,x.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,w.start.copy(x),w.start.z=0,w.end.copy(M),w.end.z=0;const p=w.closestPointToPointParameter(N,!0);w.at(p,at);const y=g.MathUtils.lerp(x.z,M.z,p),D=y>=-1&&y<=1,z=N.distanceTo(at)<L*.5;if(D&&z){w.start.fromBufferAttribute(l,m),w.end.fromBufferAttribute(o,m),w.start.applyMatrix4(c),w.end.applyMatrix4(c);const V=new g.Vector3,j=new g.Vector3;_.distanceSqToSegment(w.start,w.end,j,V),e.push({point:j,pointOnLine:V,distance:_.origin.distanceTo(j),object:r,face:null,faceIndex:m,uv:null,uv1:null})}}}class zt extends g.Mesh{constructor(t=new yt.LineSegmentsGeometry,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,i=t.attributes.instanceEnd,s=new Float32Array(2*e.count);for(let c=0,n=0,l=e.count;c<l;c++,n+=2)nt.fromBufferAttribute(e,c),rt.fromBufferAttribute(i,c),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+nt.distanceTo(rt);const a=new g.InstancedInterleavedBuffer(s,2,1);return t.setAttribute("instanceDistanceStart",new g.InterleavedBufferAttribute(a,1,0)),t.setAttribute("instanceDistanceEnd",new g.InterleavedBufferAttribute(a,1,1)),this}raycast(t,e){const i=this.material.worldUnits,s=t.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=t.params.Line2!==void 0&&t.params.Line2.threshold||0;_=t.ray;const c=this.matrixWorld,n=this.geometry,l=this.material;L=l.linewidth+a,n.boundingSphere===null&&n.computeBoundingSphere(),U.copy(n.boundingSphere).applyMatrix4(c);let o;if(i)o=L*.5;else{const f=Math.max(s.near,U.distanceToPoint(_.origin));o=ot(s,f,l.resolution)}if(U.radius+=o,_.intersectsSphere(U)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),R.copy(n.boundingBox).applyMatrix4(c);let d;if(i)d=L*.5;else{const f=Math.max(s.near,R.distanceToPoint(_.origin));d=ot(s,f,l.resolution)}R.expandByScalar(d),_.intersectsBox(R)!==!1&&(i?Ct(this,e):Dt(this,s,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport($),this.material.uniforms.resolution.value.set($.z,$.w))}}const lt=["encodings_fragment","colorspace_fragment"],Vt=`
|
|
5
5
|
#include <common>
|
|
6
6
|
#include <logdepthbuf_pars_vertex>
|
|
7
7
|
#include <fog_pars_vertex>
|
|
@@ -144,6 +144,6 @@
|
|
|
144
144
|
|
|
145
145
|
#include <fog_fragment>
|
|
146
146
|
#include <tonemapping_fragment>
|
|
147
|
-
#include <${+
|
|
147
|
+
#include <${+h.REVISION<154?lt[0]:lt[1]}>
|
|
148
148
|
}
|
|
149
|
-
`;class
|
|
149
|
+
`;class Tt extends h.ShaderMaterial{constructor(t){super({uniforms:Z(k({},h.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new h.Color(16777215)},opacity:{value:1},resolution:{value:new h.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new h.Vector2(1,1)},offset:{value:new h.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new h.Vector2(0,0)},lightColor:{value:new h.Color(16777215)}}),vertexShader:Vt,fragmentShader:It}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(e){this.uniforms.lineWidth.value=e}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(e){this.uniforms.map.value=e}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(e){this.uniforms.useMap.value=e}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(e){this.uniforms.alphaMap.value=e}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(e){this.uniforms.useAlphaMap.value=e}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(e){this.uniforms.color.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(e){this.uniforms.sizeAttenuation.value=e}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(e){this.uniforms.dashArray.value=e,this.useDash=e!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(e){this.uniforms.dashOffset.value=e}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(e){this.uniforms.dashRatio.value=e}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(e){this.uniforms.useDash.value=e}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(e){this.uniforms.useDepth.value=e}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(e){this.uniforms.visibility.value=e}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(e){this.uniforms.alphaTest.value=e}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(e){this.uniforms.repeat.value.copy(e)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(e){this.uniforms.lineLightAnimation.value=e}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(e){this.uniforms.time.value=e}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(e){this.uniforms.speed.value=e}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(e){this.uniforms.lightWidth.value=e}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(e){this.uniforms.uCenter.value=e}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(e){e&&(this.uniforms.lightColor.value=e)}}}),this.setValues(t)}copy(t){return super.copy(t),this.lineWidth=t.lineWidth,this.map=t.map,this.useMap=t.useMap,this.alphaMap=t.alphaMap,this.useAlphaMap=t.useAlphaMap,this.color.copy(t.color),this.opacity=t.opacity,this.resolution.copy(t.resolution),this.sizeAttenuation=t.sizeAttenuation,this.dashArray=t.dashArray,this.dashOffset=t.dashOffset,this.dashRatio=t.dashRatio,this.useDash=t.useDash,this.visibility=t.visibility,this.alphaTest=t.alphaTest,this.repeat.copy(t.repeat),this}}function _t(r,t){return r.map(e=>{const i=[];let s;return e.forEach(a=>{if(s){const c=E.geoDistance(a,s)*180/Math.PI;if(c>t){const n=E.geoInterpolate(s,a),l=1/Math.ceil(c/t);let o=l;for(;o<1;)i.push(n(o)),o+=l}}i.push(s=a)}),i})}function Ot(r,{minLng:t,maxLng:e,minLat:i,maxLat:s}={}){const a=Math.round(tt(360/r,2)/Math.PI),c=(1+Math.sqrt(5))/2,n=u=>u/c*360%360-180,l=u=>Math.acos(2*u/a-1)/Math.PI*180-90,o=u=>a*(Math.cos((u+90)*Math.PI/180)+1)/2,d=[s!==void 0?Math.ceil(o(s)):0,i!==void 0?Math.floor(o(i)):a-1],f=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,m=[];for(let u=d[0];u<=d[1];u++){const v=n(u);f(v)&&m.push([v,l(u)])}return m}function X(r,t,e=!1){return e?E.geoContains(t,r):wt(r,t)}function Lt(r,t){const e={type:"Polygon",coordinates:r},[[i,s],[a,c]]=E.geoBounds(e);if(Math.min(Math.abs(a-i),Math.abs(c-s))<t)return[];const n=i>a||c>=89||s<=-89;return Ot(t,{minLng:i,maxLng:a,minLat:s,maxLat:c}).filter(l=>X(l,e,n))}function Wt(r,{resolution:t=1/0,bbox:e,projection:i}={}){const s=_t(r,t),a=W.merge(s),c=Lt(r,t),n=[...a,...c],l={type:"Polygon",coordinates:r},[[o,d],[f,m]]=E.geoBounds(l),u=o>f||m>=89||d<=-89;let v=[];if(u){const b=Pt.geoVoronoi(n).triangles(),P=new Map(n.map(([A,S],O)=>[`${A}-${S}`,O]));b.features.forEach(A=>{const S=A.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(S.forEach(([C,F])=>{const G=`${C}-${F}`;P.has(G)&&O.push(P.get(G))}),O.length===3){if(O.some(C=>C<a.length)){const C=A.properties.circumcenter;if(!X(C,l,u))return}v.push(...O)}})}else if(c.length){const b=Mt.from(n);for(let P=0,A=b.triangles.length;P<A;P+=3){const S=[2,1,0].map(C=>b.triangles[P+C]),O=S.map(C=>n[C]);if(S.some(C=>C<a.length)){const C=[0,1].map(F=>W.mean(O,G=>G[F]));if(!X(C,l,u))continue}v.push(...S)}}else{const{vertices:b,holes:P=[]}=K.flatten(s);v=K(b,P,2)}let p=e?[e[0],e[2]]:W.extent(n,b=>b[0]),y=e?[e[1],e[3]]:W.extent(n,b=>b[1]);if(i){const[b,P]=i([p[0],y[0]]),[A,S]=i([p[1],y[1]]);p=[b,A],y=[-P,-S]}const D=st.scaleLinear(p,[0,1]),z=st.scaleLinear(y,[0,1]),V=n.map(([b,P])=>{if(i){const[A,S]=i([b,P]);return[D(A),z(-S)]}else return[D(b),z(P)]});return{contour:s,triangles:{points:n,indices:v,uvs:V}}}const ct=new h.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(r,t,e,i){const s=r.map(a=>a.map(([c,n])=>{if(i){const[l,o]=i([c,n]);return[l,-o,t]}return e?H.polar2Cartesian(c,n,t):[c,n,t]}));return K.flatten(s)}function Bt(r,t,e,i,s){const{vertices:a,holes:c}=q(r,t,i,s),{vertices:n}=q(r,e,i,s),l=W.merge([n,a]),o=Math.round(n.length/3),d=new Set(c);let f=0;const m=[];for(let v=0;v<o;v++){let p=v+1;if(p===o)p=f;else if(d.has(p)){const y=p;p=f,f=y}m.push(v,v+o,p+o),m.push(p+o,p,v)}const u=[];for(let v=1;v>=0;v--)for(let p=0;p<o;p+=1)u.push(p/(o-1),v);return{indices:m,vertices:l,uvs:u,topVerts:n}}function ut(r,t,e,i,s,a){return{indices:i?r.indices:r.indices.slice().reverse(),vertices:q([r.points],t,s,a).vertices,uvs:e}}const ft=({polygonGeoJson:r,startHeight:t,endHeight:e,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:c=!1,hasTop:n=!1,projection:l,bbox:o})=>{r.forEach(D=>{xt(D)||D.reverse()});const{contour:d,triangles:f}=Wt(r,{resolution:i,bbox:o,projection:l});let m={},u;a&&(m=Bt(d,t!=null?t:e,e!=null?e:t,s,l),u=m.topVerts);let v=[];(c||n)&&(v=W.merge(f.uvs));let p={};c&&(p=ut(f,t,v,!1,s,l));let y={};return n&&(y=ut(f,e,v,!0,s,l)),{contour:d,triangles:f,sideTorso:m,bottomCap:p,topCap:y,topVerts:u}};class kt extends h.BufferGeometry{constructor(t,e={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({polygonGeoJson:t,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},e);const{endHeight:i,hasTop:s,topFirst:a,hasBottom:c,hasSide:n,cartesian:l,userDataRsoOffset:o,projection:d}=this.parameters,{contour:f,sideTorso:m,topVerts:u,bottomCap:v,topCap:p}=ft(k({},this.parameters));let y=[],D=[],z=[],V=0;const j=b=>{const P=Math.round(y.length/3),A=z.length;y=y.concat(b.vertices),D=D.concat(b.uvs),z=z.concat(P?b.indices.map(S=>S+P):b.indices),this.addGroup(A,z.length-A,V++)};s&&a&&j(p),n&&(j(m),this.userData.topVerts=o?q(f,i+o,l,d).vertices:u),c&&j(v),s&&!a&&j(p),this.setIndex(z),this[ct]("position",new h.Float32BufferAttribute(y,3)),this[ct]("uv",new h.Float32BufferAttribute(D,2)),this.computeVertexNormals()}}exports.BaseObject=ht;exports.Group=St;exports.LineSegments2=zt;exports.MeshLineMaterial=Tt;exports.PolygonGeometry=kt;exports.ResourceTracker=B;exports.getMetas=ft;
|