gl-draw 0.15.20 → 0.15.21
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 +139 -0
- package/dist/WebGPULineSegments2.module.js +1014 -0
- package/dist/core/BaseObject/index.d.ts +2 -1
- package/dist/core/Composer.d.ts +5 -5
- package/dist/core/ResourceTracker.d.ts +1 -1
- package/dist/index.js +23 -23
- package/dist/index.module.js +64 -60
- package/dist/objects/conicPolygon/geometry/index.d.ts +4 -4
- package/dist/objects/index.d.ts +8 -8
- package/dist/objects/index.js +1 -1
- package/dist/objects/index.module.js +954 -927
- package/dist/objects/line/createGeometry.d.ts +2 -2
- package/dist/objects/line/index.d.ts +5 -5
- package/dist/objects/line/meshLine/MeshLineGeometry.d.ts +16 -35
- package/dist/objects/line/meshLine/MeshLineMaterial.d.ts +67 -41
- package/dist/objects/line/meshLine/fragment.d.ts +1 -0
- package/dist/objects/line/meshLine/index.d.ts +1 -0
- package/dist/objects/line/meshLine/raycast.d.ts +3 -0
- package/dist/objects/line/meshLine/vertex.d.ts +1 -0
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.module.js +24 -24
- package/package.json +1 -1
- package/dist/index.module2.js +0 -1173
- package/dist/index2.js +0 -149
|
@@ -0,0 +1,1014 @@
|
|
|
1
|
+
var Pt = Object.defineProperty, It = Object.defineProperties;
|
|
2
|
+
var Dt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var k = Object.getOwnPropertySymbols;
|
|
4
|
+
var it = Object.prototype.hasOwnProperty, st = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var nt = Math.pow, et = (n, t, e) => t in n ? Pt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, L = (n, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
it.call(t, e) && et(n, e, t[e]);
|
|
8
|
+
if (k)
|
|
9
|
+
for (var e of k(t))
|
|
10
|
+
st.call(t, e) && et(n, e, t[e]);
|
|
11
|
+
return n;
|
|
12
|
+
}, q = (n, t) => It(n, Dt(t));
|
|
13
|
+
var rt = (n, t) => {
|
|
14
|
+
var e = {};
|
|
15
|
+
for (var i in n)
|
|
16
|
+
it.call(n, i) && t.indexOf(i) < 0 && (e[i] = n[i]);
|
|
17
|
+
if (n != null && k)
|
|
18
|
+
for (var i of k(n))
|
|
19
|
+
t.indexOf(i) < 0 && st.call(n, i) && (e[i] = n[i]);
|
|
20
|
+
return e;
|
|
21
|
+
};
|
|
22
|
+
var ot = (n, t, e) => new Promise((i, s) => {
|
|
23
|
+
var a = (c) => {
|
|
24
|
+
try {
|
|
25
|
+
r(e.next(c));
|
|
26
|
+
} catch (o) {
|
|
27
|
+
s(o);
|
|
28
|
+
}
|
|
29
|
+
}, l = (c) => {
|
|
30
|
+
try {
|
|
31
|
+
r(e.throw(c));
|
|
32
|
+
} catch (o) {
|
|
33
|
+
s(o);
|
|
34
|
+
}
|
|
35
|
+
}, r = (c) => c.done ? i(c.value) : Promise.resolve(c.value).then(a, l);
|
|
36
|
+
r((e = e.apply(n, t)).next());
|
|
37
|
+
});
|
|
38
|
+
import { Material as at, Object3D as R, Texture as ct, VideoTexture as Bt, BufferGeometry as J, Float32BufferAttribute as G, PointsMaterial as zt, Points as H, InstancedMesh as wt, Vector3 as I, Quaternion as Tt, Group as _t, Mesh as St, Sprite as lt, Box3 as jt, REVISION as Et, ShaderChunk as W, ShaderMaterial as Lt, Vector2 as K, Color as ut, Vector4 as O, Matrix4 as Ot, Line3 as Vt, Sphere as kt, InstancedInterleavedBuffer as Wt, InterleavedBufferAttribute as ft, MathUtils as Nt } from "three";
|
|
39
|
+
import { CSS2DObject as Ut } from "three/examples/jsm/renderers/CSS2DRenderer";
|
|
40
|
+
import { CSS3DObject as Rt, CSS3DSprite as Gt } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
41
|
+
import { geoBounds as At, geoContains as $t, geoDistance as Ft, geoInterpolate as qt } from "d3-geo";
|
|
42
|
+
import "d3-geo-projection";
|
|
43
|
+
import { p as dt, a as Kt } from "./parseVector.module.js";
|
|
44
|
+
import { merge as tt, mean as Qt, extent as ht } from "d3-array";
|
|
45
|
+
import Xt, { flatten as Ct } from "earcut";
|
|
46
|
+
import Yt from "@turf/boolean-clockwise";
|
|
47
|
+
import Zt from "delaunator";
|
|
48
|
+
import Jt from "@turf/boolean-point-in-polygon";
|
|
49
|
+
import { geoVoronoi as Ht } from "d3-geo-voronoi";
|
|
50
|
+
import { scaleLinear as pt } from "d3-scale";
|
|
51
|
+
import { LineSegmentsGeometry as te } from "three/examples/jsm/lines/LineSegmentsGeometry";
|
|
52
|
+
const ee = 0, _e = 1, ie = 2, Ee = !1;
|
|
53
|
+
class se {
|
|
54
|
+
constructor() {
|
|
55
|
+
this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
|
|
56
|
+
}
|
|
57
|
+
track(t) {
|
|
58
|
+
if (!t)
|
|
59
|
+
return t;
|
|
60
|
+
if (Array.isArray(t))
|
|
61
|
+
return t.forEach((e) => this.track(e)), t;
|
|
62
|
+
if (!this.disposeMaterial && t instanceof at)
|
|
63
|
+
return t;
|
|
64
|
+
if (t instanceof mt ? (t.disposeTrack && t.object3d ? this.track(t.object3d) : this.resources.add(t), Object.values(t.materialList).map((e) => this.track(e))) : (t instanceof R || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof mt)
|
|
65
|
+
t.children.forEach((e) => {
|
|
66
|
+
e.disposeTrack = !1;
|
|
67
|
+
}), this.track(t.children);
|
|
68
|
+
else if (t instanceof R) {
|
|
69
|
+
const e = t;
|
|
70
|
+
this.track(e.geometry), this.track(e.material), this.track(e.children);
|
|
71
|
+
} else if (t instanceof at) {
|
|
72
|
+
for (const i of Object.values(t))
|
|
73
|
+
i instanceof ct && this.track(i);
|
|
74
|
+
const e = t;
|
|
75
|
+
if (e.uniforms) {
|
|
76
|
+
for (const i of Object.values(e.uniforms))
|
|
77
|
+
if (i) {
|
|
78
|
+
const s = i.value;
|
|
79
|
+
(s instanceof ct || Array.isArray(s)) && this.track(s);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} else this.disposeVideo && t instanceof Bt && t.source.data && this.resources.add(t.source.data);
|
|
83
|
+
return t;
|
|
84
|
+
}
|
|
85
|
+
dispose() {
|
|
86
|
+
const t = [];
|
|
87
|
+
for (const e of this.resources)
|
|
88
|
+
e instanceof R ? t.push(e) : e instanceof HTMLVideoElement && e.pause(), Reflect.has(e, "dispose") && e.dispose();
|
|
89
|
+
t.forEach((e) => {
|
|
90
|
+
e.removeFromParent();
|
|
91
|
+
}), t.length = 0, this.resources.clear();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const ne = (n, t = 1) => {
|
|
95
|
+
const e = new J();
|
|
96
|
+
e.setAttribute(
|
|
97
|
+
"position",
|
|
98
|
+
new G(new Array(t * 3).fill(0), 3)
|
|
99
|
+
), e.setAttribute(
|
|
100
|
+
"scaleAtt",
|
|
101
|
+
new G(new Array(t).fill(1), 1)
|
|
102
|
+
);
|
|
103
|
+
const i = n.material, s = new zt({
|
|
104
|
+
size: 10,
|
|
105
|
+
map: i.map,
|
|
106
|
+
alphaMap: i.alphaMap,
|
|
107
|
+
color: i.color,
|
|
108
|
+
blending: i.blending,
|
|
109
|
+
depthTest: i.depthTest,
|
|
110
|
+
depthWrite: !1,
|
|
111
|
+
opacity: i.opacity,
|
|
112
|
+
transparent: !0,
|
|
113
|
+
alphaTest: i.alphaTest,
|
|
114
|
+
sizeAttenuation: !1
|
|
115
|
+
});
|
|
116
|
+
return s.onBeforeCompile = (a) => {
|
|
117
|
+
a.vertexShader = `
|
|
118
|
+
attribute float scaleAtt;
|
|
119
|
+
${a.vertexShader.replace(
|
|
120
|
+
"gl_PointSize = size;",
|
|
121
|
+
"gl_PointSize = size * scaleAtt;"
|
|
122
|
+
)}
|
|
123
|
+
`;
|
|
124
|
+
}, new H(e, s);
|
|
125
|
+
}, re = (n, t) => {
|
|
126
|
+
const e = new R();
|
|
127
|
+
t.forEach((i, s) => {
|
|
128
|
+
const a = dt(i.position), l = dt(i.scale || [1, 1, 1]);
|
|
129
|
+
e.position.copy(a), e.scale.copy(l), e.updateMatrix();
|
|
130
|
+
const r = e.matrix.clone();
|
|
131
|
+
if (n instanceof wt || n.isInstantiate)
|
|
132
|
+
n.setMatrixAt(s, r);
|
|
133
|
+
else if (n instanceof H || n.type === "Points") {
|
|
134
|
+
const o = n.geometry, h = o.attributes.position.array, f = o.attributes.scaleAtt.array, p = new I(), u = new I(), m = new Tt(), d = s * 3, v = s * 1;
|
|
135
|
+
r.decompose(p, m, u), h[d] = p.x, h[d + 1] = p.y, h[d + 2] = p.z, f[v] = Math.max(u.x, u.y, u.z), o.attributes.position.needsUpdate = !0, o.attributes.scaleAtt.needsUpdate = !0;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
class oe {
|
|
140
|
+
constructor() {
|
|
141
|
+
this.onPointerIndex = [];
|
|
142
|
+
}
|
|
143
|
+
onPointerEvent(t, e) {
|
|
144
|
+
const i = this.lead.handlePick([this], t, e);
|
|
145
|
+
this.onPointerIndex.push(i);
|
|
146
|
+
}
|
|
147
|
+
onClick(t) {
|
|
148
|
+
this.onPointerEvent("click", t);
|
|
149
|
+
}
|
|
150
|
+
onPointerEnter(t) {
|
|
151
|
+
this.onPointerEvent("enter", t);
|
|
152
|
+
}
|
|
153
|
+
onPointerLeave(t) {
|
|
154
|
+
this.onPointerEvent("leave", t);
|
|
155
|
+
}
|
|
156
|
+
onPointerMove(t) {
|
|
157
|
+
this.onPointerEvent("move", t);
|
|
158
|
+
}
|
|
159
|
+
onPointerDown(t) {
|
|
160
|
+
this.onPointerEvent("down", t);
|
|
161
|
+
}
|
|
162
|
+
dispose() {
|
|
163
|
+
this.onPointerIndex.forEach((t) => {
|
|
164
|
+
this.lead.removePick(t);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
class ae extends oe {
|
|
169
|
+
constructor() {
|
|
170
|
+
super(...arguments), this.userData = {}, this.materialList = {}, this.useMaterialType = "origin", this.disposeMaterialIfNotUsed = !0;
|
|
171
|
+
}
|
|
172
|
+
cloneMaterial() {
|
|
173
|
+
const t = this.object3d;
|
|
174
|
+
if (!t || !t.material)
|
|
175
|
+
return;
|
|
176
|
+
const e = t.material;
|
|
177
|
+
if (Array.isArray(e))
|
|
178
|
+
return e.map((i) => {
|
|
179
|
+
const s = i.userData;
|
|
180
|
+
i.userData = {};
|
|
181
|
+
const a = i.clone();
|
|
182
|
+
return i.userData = s, a;
|
|
183
|
+
});
|
|
184
|
+
{
|
|
185
|
+
const i = e.userData;
|
|
186
|
+
e.userData = {};
|
|
187
|
+
const s = e.clone();
|
|
188
|
+
return e.userData = i, s;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
setMaterialList(t, e) {
|
|
192
|
+
const i = this.object3d;
|
|
193
|
+
if (!i || !i.material)
|
|
194
|
+
return;
|
|
195
|
+
this.materialList.origin || (this.materialList.origin = i.material);
|
|
196
|
+
const s = e === "clone" ? this.cloneMaterial() : Array.isArray(e) ? e.slice() : e;
|
|
197
|
+
return this.materialList[t] = s, s;
|
|
198
|
+
}
|
|
199
|
+
useMaterial(t) {
|
|
200
|
+
const e = this.object3d;
|
|
201
|
+
!e || !e.material || this.useMaterialType === t || !this.materialList[t] || (this.useMaterialType = t, e.material = this.materialList[t]);
|
|
202
|
+
}
|
|
203
|
+
useMListById(t, e) {
|
|
204
|
+
if (!this.mList)
|
|
205
|
+
return;
|
|
206
|
+
const i = this.mList.get(t);
|
|
207
|
+
if (!i)
|
|
208
|
+
return;
|
|
209
|
+
const s = this.object3d;
|
|
210
|
+
Array.isArray(s.material) && e !== void 0 ? s.material[e] = i : s.material = i;
|
|
211
|
+
}
|
|
212
|
+
useMListByName(t, e) {
|
|
213
|
+
if (!this.mList)
|
|
214
|
+
return;
|
|
215
|
+
const i = this.mList.getKeyByName(t);
|
|
216
|
+
i && this.useMListById(i, e);
|
|
217
|
+
}
|
|
218
|
+
dispose() {
|
|
219
|
+
super.dispose(), this.mList.rmBaseObjectMap(
|
|
220
|
+
this,
|
|
221
|
+
void 0,
|
|
222
|
+
this.disposeMaterialIfNotUsed
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
class mt extends ae {
|
|
227
|
+
constructor() {
|
|
228
|
+
super(...arguments), this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.disposeTrack = !0;
|
|
229
|
+
}
|
|
230
|
+
get parent() {
|
|
231
|
+
const t = this.object3d.parent;
|
|
232
|
+
return t && this.lead.objMap.get(t) || null;
|
|
233
|
+
}
|
|
234
|
+
get children() {
|
|
235
|
+
return this.object3d.children.map((t) => this.lead.objMap.get(t)).filter((t) => !!t);
|
|
236
|
+
}
|
|
237
|
+
get position() {
|
|
238
|
+
return this.object3d.position;
|
|
239
|
+
}
|
|
240
|
+
get rotation() {
|
|
241
|
+
return this.object3d.rotation;
|
|
242
|
+
}
|
|
243
|
+
get scale() {
|
|
244
|
+
return this.object3d.scale;
|
|
245
|
+
}
|
|
246
|
+
get lookAt() {
|
|
247
|
+
return this.object3d.lookAt;
|
|
248
|
+
}
|
|
249
|
+
add(...t) {
|
|
250
|
+
[...t].forEach((e) => {
|
|
251
|
+
this.lead.objMap.get(e) ? this.object3d.add(e) : this.lead.createBaseObject(e, {
|
|
252
|
+
target: this
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
remove(...t) {
|
|
257
|
+
[...t].forEach((e) => {
|
|
258
|
+
var i;
|
|
259
|
+
this.lead.objMap.get(e) ? (i = this.lead.objMap.get(e)) == null || i.erase() : this.object3d.remove(e);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
get visible() {
|
|
263
|
+
return this.object3d.visible;
|
|
264
|
+
}
|
|
265
|
+
get visibleWithAncestors() {
|
|
266
|
+
if (this.visible) {
|
|
267
|
+
let t = this.parent;
|
|
268
|
+
for (; t; ) {
|
|
269
|
+
if (!t.visible)
|
|
270
|
+
return !1;
|
|
271
|
+
t = t.parent;
|
|
272
|
+
}
|
|
273
|
+
return !0;
|
|
274
|
+
} else
|
|
275
|
+
return !1;
|
|
276
|
+
}
|
|
277
|
+
create() {
|
|
278
|
+
this.createGroup();
|
|
279
|
+
}
|
|
280
|
+
render() {
|
|
281
|
+
}
|
|
282
|
+
update(t, e) {
|
|
283
|
+
}
|
|
284
|
+
resize(t, e) {
|
|
285
|
+
}
|
|
286
|
+
show() {
|
|
287
|
+
return this.object3d.visible = !0, this.object3d.layers.set(ee), this;
|
|
288
|
+
}
|
|
289
|
+
hide() {
|
|
290
|
+
return this.object3d.visible = !1, this.object3d.layers.set(ie), this;
|
|
291
|
+
}
|
|
292
|
+
createGroup() {
|
|
293
|
+
return this.object3d = new _t(), this;
|
|
294
|
+
}
|
|
295
|
+
createMesh(...t) {
|
|
296
|
+
return this.object3d = new St(...t), this;
|
|
297
|
+
}
|
|
298
|
+
createPoints(...t) {
|
|
299
|
+
return this.object3d = new H(...t), this;
|
|
300
|
+
}
|
|
301
|
+
createCSS2DObject(t) {
|
|
302
|
+
return this.object3d = new Ut(t), this;
|
|
303
|
+
}
|
|
304
|
+
createCSS3DObject(t) {
|
|
305
|
+
return this.object3d = new Rt(t), this;
|
|
306
|
+
}
|
|
307
|
+
createCSS3DSprite(t) {
|
|
308
|
+
return this.object3d = new Gt(t), this;
|
|
309
|
+
}
|
|
310
|
+
createSprite(t) {
|
|
311
|
+
return this.object3d = new lt(t), this;
|
|
312
|
+
}
|
|
313
|
+
attach(...t) {
|
|
314
|
+
return [...t].forEach((e) => {
|
|
315
|
+
this.object3d.attach(e.object3d);
|
|
316
|
+
}), this;
|
|
317
|
+
}
|
|
318
|
+
getSize() {
|
|
319
|
+
const t = new jt().setFromObject(this.object3d);
|
|
320
|
+
return {
|
|
321
|
+
min: t.min,
|
|
322
|
+
max: t.max,
|
|
323
|
+
size: t.getSize(new I()),
|
|
324
|
+
center: t.getCenter(new I())
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
setTop(t) {
|
|
328
|
+
this.object3d && (this.object3d.renderOrder = t);
|
|
329
|
+
}
|
|
330
|
+
traverse(t) {
|
|
331
|
+
t(this), this.children.forEach((e) => {
|
|
332
|
+
e.traverse(t);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
instantiate(t) {
|
|
336
|
+
return ot(this, null, function* () {
|
|
337
|
+
var c;
|
|
338
|
+
const e = (c = t == null ? void 0 : t.recursive) != null ? c : !0, { objectType: i, objectOptions: s } = this, [, a] = i.split("#");
|
|
339
|
+
let l = t == null ? void 0 : t.create;
|
|
340
|
+
l === void 0 && (l = (o) => {
|
|
341
|
+
var h;
|
|
342
|
+
if (this.object3d) {
|
|
343
|
+
if ((h = t == null ? void 0 : t.instancedAttr) != null && h.length) {
|
|
344
|
+
const f = t.instancedAttr.length;
|
|
345
|
+
if (this.object3d instanceof lt)
|
|
346
|
+
o.object3d = ne(this.object3d, f);
|
|
347
|
+
else {
|
|
348
|
+
const p = this.object3d, u = this.cloneMaterial();
|
|
349
|
+
o.object3d = new wt(p.geometry, u, f);
|
|
350
|
+
}
|
|
351
|
+
re(o.object3d, t == null ? void 0 : t.instancedAttr);
|
|
352
|
+
} else
|
|
353
|
+
o.object3d = this.object3d.clone(!1), o.object3d.material && (o.object3d.material = this.cloneMaterial());
|
|
354
|
+
o.object3d.userData.prefab && delete o.object3d.userData.prefab;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
const r = yield this.lead.draw(a, q(L({}, s || {}), {
|
|
358
|
+
create: l,
|
|
359
|
+
prefab: !1,
|
|
360
|
+
key: (t == null ? void 0 : t.key) || (s == null ? void 0 : s.key),
|
|
361
|
+
target: (t == null ? void 0 : t.target) || (s == null ? void 0 : s.target)
|
|
362
|
+
}));
|
|
363
|
+
return this.isBloom && r.enableBloom(), e && (yield Promise.all(
|
|
364
|
+
this.children.map(
|
|
365
|
+
(o) => o.instantiate({
|
|
366
|
+
target: r
|
|
367
|
+
})
|
|
368
|
+
)
|
|
369
|
+
)), r.isInstantiate = !0, r;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
erase() {
|
|
373
|
+
this.lead.erase(this);
|
|
374
|
+
}
|
|
375
|
+
handleMaterialChange(t) {
|
|
376
|
+
}
|
|
377
|
+
enableBloom() {
|
|
378
|
+
var t;
|
|
379
|
+
(t = this.pencil.composerController) == null || t.setBloomSelection(this, !0), this.isBloom = !0;
|
|
380
|
+
}
|
|
381
|
+
disableBloom() {
|
|
382
|
+
var t;
|
|
383
|
+
(t = this.pencil.composerController) == null || t.setBloomSelection(this, !1), this.isBloom = !1;
|
|
384
|
+
}
|
|
385
|
+
dispose() {
|
|
386
|
+
var t;
|
|
387
|
+
if (super.dispose(), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.lead.objectWrapChindIdMap.delete(this), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
|
|
388
|
+
const e = new se();
|
|
389
|
+
e.disposeMaterial = !1, e.track(this), e.dispose();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function ce(n, t) {
|
|
394
|
+
return n.map((e) => {
|
|
395
|
+
const i = [];
|
|
396
|
+
let s;
|
|
397
|
+
return e.forEach((a) => {
|
|
398
|
+
if (s) {
|
|
399
|
+
const l = Ft(a, s) * 180 / Math.PI;
|
|
400
|
+
if (l > t) {
|
|
401
|
+
const r = qt(s, a), c = 1 / Math.ceil(l / t);
|
|
402
|
+
let o = c;
|
|
403
|
+
for (; o < 1; )
|
|
404
|
+
i.push(r(o)), o += c;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
i.push(s = a);
|
|
408
|
+
}), i;
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function le(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
|
|
412
|
+
const a = Math.round(nt(360 / n, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, r = (u) => u / l * 360 % 360 - 180, c = (u) => Math.acos(2 * u / a - 1) / Math.PI * 180 - 90, o = (u) => a * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, h = [
|
|
413
|
+
s !== void 0 ? Math.ceil(o(s)) : 0,
|
|
414
|
+
i !== void 0 ? Math.floor(o(i)) : a - 1
|
|
415
|
+
], 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, p = [];
|
|
416
|
+
for (let u = h[0]; u <= h[1]; u++) {
|
|
417
|
+
const m = r(u);
|
|
418
|
+
f(m) && p.push([m, c(u)]);
|
|
419
|
+
}
|
|
420
|
+
return p;
|
|
421
|
+
}
|
|
422
|
+
function Z(n, t, e = !1) {
|
|
423
|
+
return e ? $t(t, n) : Jt(n, t);
|
|
424
|
+
}
|
|
425
|
+
function ue(n, t) {
|
|
426
|
+
const e = { type: "Polygon", coordinates: n }, [[i, s], [a, l]] = At(e);
|
|
427
|
+
if (Math.min(Math.abs(a - i), Math.abs(l - s)) < t)
|
|
428
|
+
return [];
|
|
429
|
+
const r = i > a || l >= 89 || s <= -89;
|
|
430
|
+
return le(t, {
|
|
431
|
+
minLng: i,
|
|
432
|
+
maxLng: a,
|
|
433
|
+
minLat: s,
|
|
434
|
+
maxLat: l
|
|
435
|
+
}).filter(
|
|
436
|
+
(c) => Z(c, e, r)
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
function fe(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
|
|
440
|
+
const s = ce(n, t), a = tt(s), l = ue(n, t), r = [...a, ...l], c = { type: "Polygon", coordinates: n }, [[o, h], [f, p]] = At(c), u = o > f || // crosses antimeridian
|
|
441
|
+
p >= 89 || // crosses north pole
|
|
442
|
+
h <= -89;
|
|
443
|
+
let m = [];
|
|
444
|
+
if (u) {
|
|
445
|
+
const y = Ht(r).triangles(), x = new Map(
|
|
446
|
+
r.map(([A, C], _) => [`${A}-${C}`, _])
|
|
447
|
+
);
|
|
448
|
+
y.features.forEach((A) => {
|
|
449
|
+
const C = A.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
|
|
450
|
+
if (C.forEach(([P, F]) => {
|
|
451
|
+
const V = `${P}-${F}`;
|
|
452
|
+
x.has(V) && _.push(x.get(V));
|
|
453
|
+
}), _.length === 3) {
|
|
454
|
+
if (_.some((P) => P < a.length)) {
|
|
455
|
+
const P = A.properties.circumcenter;
|
|
456
|
+
if (!Z(
|
|
457
|
+
P,
|
|
458
|
+
c,
|
|
459
|
+
u
|
|
460
|
+
))
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
m.push(..._);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
} else if (l.length) {
|
|
467
|
+
const y = Zt.from(r);
|
|
468
|
+
for (let x = 0, A = y.triangles.length; x < A; x += 3) {
|
|
469
|
+
const C = [2, 1, 0].map((P) => y.triangles[x + P]), _ = C.map((P) => r[P]);
|
|
470
|
+
if (C.some((P) => P < a.length)) {
|
|
471
|
+
const P = [0, 1].map(
|
|
472
|
+
(F) => Qt(_, (V) => V[F])
|
|
473
|
+
);
|
|
474
|
+
if (!Z(
|
|
475
|
+
P,
|
|
476
|
+
c,
|
|
477
|
+
u
|
|
478
|
+
))
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
m.push(...C);
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
const { vertices: y, holes: x = [] } = Ct(s);
|
|
485
|
+
m = Xt(y, x, 2);
|
|
486
|
+
}
|
|
487
|
+
let d = e ? [e[0], e[2]] : ht(r, (y) => y[0]), v = e ? [e[1], e[3]] : ht(r, (y) => y[1]);
|
|
488
|
+
if (i) {
|
|
489
|
+
const [y, x] = i([d[0], v[0]]), [A, C] = i([d[1], v[1]]);
|
|
490
|
+
d = [y, A], v = [-x, -C];
|
|
491
|
+
}
|
|
492
|
+
const w = pt(d, [0, 1]), S = pt(v, [0, 1]), D = r.map(([y, x]) => {
|
|
493
|
+
if (i) {
|
|
494
|
+
const [A, C] = i([y, x]);
|
|
495
|
+
return [w(A), S(-C)];
|
|
496
|
+
} else
|
|
497
|
+
return [w(y), S(x)];
|
|
498
|
+
});
|
|
499
|
+
return { contour: s, triangles: { points: r, indices: m, uvs: D } };
|
|
500
|
+
}
|
|
501
|
+
const vt = new J().setAttribute ? "setAttribute" : "addAttribute";
|
|
502
|
+
function $(n, t, e, i) {
|
|
503
|
+
const s = n.map(
|
|
504
|
+
(a) => a.map(([l, r]) => {
|
|
505
|
+
if (i) {
|
|
506
|
+
const [c, o] = i([l, r]);
|
|
507
|
+
return [c, -o, t];
|
|
508
|
+
}
|
|
509
|
+
return e ? Kt(l, r, t) : [l, r, t];
|
|
510
|
+
})
|
|
511
|
+
);
|
|
512
|
+
return Ct(s);
|
|
513
|
+
}
|
|
514
|
+
function de(n, t, e, i, s) {
|
|
515
|
+
const { vertices: a, holes: l } = $(
|
|
516
|
+
n,
|
|
517
|
+
t,
|
|
518
|
+
i,
|
|
519
|
+
s
|
|
520
|
+
), { vertices: r } = $(
|
|
521
|
+
n,
|
|
522
|
+
e,
|
|
523
|
+
i,
|
|
524
|
+
s
|
|
525
|
+
), c = tt([r, a]), o = Math.round(r.length / 3), h = new Set(l);
|
|
526
|
+
let f = 0;
|
|
527
|
+
const p = [];
|
|
528
|
+
for (let m = 0; m < o; m++) {
|
|
529
|
+
let d = m + 1;
|
|
530
|
+
if (d === o)
|
|
531
|
+
d = f;
|
|
532
|
+
else if (h.has(d)) {
|
|
533
|
+
const v = d;
|
|
534
|
+
d = f, f = v;
|
|
535
|
+
}
|
|
536
|
+
p.push(m, m + o, d + o), p.push(d + o, d, m);
|
|
537
|
+
}
|
|
538
|
+
const u = [];
|
|
539
|
+
for (let m = 1; m >= 0; m--)
|
|
540
|
+
for (let d = 0; d < o; d += 1) u.push(d / (o - 1), m);
|
|
541
|
+
return { indices: p, vertices: c, uvs: u, topVerts: r };
|
|
542
|
+
}
|
|
543
|
+
function yt(n, t, e, i, s, a) {
|
|
544
|
+
return {
|
|
545
|
+
indices: i ? n.indices : n.indices.slice().reverse(),
|
|
546
|
+
vertices: $(
|
|
547
|
+
[n.points],
|
|
548
|
+
t,
|
|
549
|
+
s,
|
|
550
|
+
a
|
|
551
|
+
).vertices,
|
|
552
|
+
uvs: e
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
const he = ({
|
|
556
|
+
polygonGeoJson: n,
|
|
557
|
+
startHeight: t,
|
|
558
|
+
endHeight: e,
|
|
559
|
+
curvatureResolution: i = 1,
|
|
560
|
+
cartesian: s = !0,
|
|
561
|
+
hasSide: a = !0,
|
|
562
|
+
hasBottom: l = !1,
|
|
563
|
+
hasTop: r = !1,
|
|
564
|
+
projection: c,
|
|
565
|
+
bbox: o
|
|
566
|
+
}) => {
|
|
567
|
+
n.forEach((w) => {
|
|
568
|
+
Yt(w) || w.reverse();
|
|
569
|
+
});
|
|
570
|
+
const { contour: h, triangles: f } = fe(n, {
|
|
571
|
+
resolution: i,
|
|
572
|
+
bbox: o,
|
|
573
|
+
projection: c
|
|
574
|
+
});
|
|
575
|
+
let p = {}, u;
|
|
576
|
+
a && (p = de(
|
|
577
|
+
h,
|
|
578
|
+
t != null ? t : e,
|
|
579
|
+
e != null ? e : t,
|
|
580
|
+
s,
|
|
581
|
+
c
|
|
582
|
+
), u = p.topVerts);
|
|
583
|
+
let m = [];
|
|
584
|
+
(l || r) && (m = tt(f.uvs));
|
|
585
|
+
let d = {};
|
|
586
|
+
l && (d = yt(
|
|
587
|
+
f,
|
|
588
|
+
t,
|
|
589
|
+
m,
|
|
590
|
+
!1,
|
|
591
|
+
s,
|
|
592
|
+
c
|
|
593
|
+
));
|
|
594
|
+
let v = {};
|
|
595
|
+
return r && (v = yt(
|
|
596
|
+
f,
|
|
597
|
+
e,
|
|
598
|
+
m,
|
|
599
|
+
!0,
|
|
600
|
+
s,
|
|
601
|
+
c
|
|
602
|
+
)), { contour: h, triangles: f, sideTorso: p, bottomCap: d, topCap: v, topVerts: u };
|
|
603
|
+
};
|
|
604
|
+
class Le extends J {
|
|
605
|
+
constructor(t, e = {}) {
|
|
606
|
+
super(), this.type = "PolygonBufferGeometry", this.parameters = L({
|
|
607
|
+
polygonGeoJson: t,
|
|
608
|
+
startHeight: 0,
|
|
609
|
+
endHeight: 1,
|
|
610
|
+
hasTop: !0,
|
|
611
|
+
topFirst: !1,
|
|
612
|
+
hasBottom: !0,
|
|
613
|
+
hasSide: !0,
|
|
614
|
+
curvatureResolution: 1,
|
|
615
|
+
cartesian: !0,
|
|
616
|
+
userDataRsoOffset: 0
|
|
617
|
+
}, e);
|
|
618
|
+
const {
|
|
619
|
+
endHeight: i,
|
|
620
|
+
hasTop: s,
|
|
621
|
+
topFirst: a,
|
|
622
|
+
hasBottom: l,
|
|
623
|
+
hasSide: r,
|
|
624
|
+
cartesian: c,
|
|
625
|
+
userDataRsoOffset: o,
|
|
626
|
+
projection: h
|
|
627
|
+
} = this.parameters, { contour: f, sideTorso: p, topVerts: u, bottomCap: m, topCap: d } = he(L({}, this.parameters));
|
|
628
|
+
let v = [], w = [], S = [], D = 0;
|
|
629
|
+
const j = (y) => {
|
|
630
|
+
const x = Math.round(v.length / 3), A = S.length;
|
|
631
|
+
v = v.concat(y.vertices), w = w.concat(y.uvs), S = S.concat(
|
|
632
|
+
x ? y.indices.map((C) => C + x) : y.indices
|
|
633
|
+
), this.addGroup(A, S.length - A, D++);
|
|
634
|
+
};
|
|
635
|
+
s && a && j(d), r && (j(p), this.userData.topVerts = o ? $(
|
|
636
|
+
f,
|
|
637
|
+
i + o,
|
|
638
|
+
c,
|
|
639
|
+
h
|
|
640
|
+
).vertices : u), l && j(m), s && !a && j(d), this.setIndex(S), this[vt]("position", new G(v, 3)), this[vt]("uv", new G(w, 2)), this.computeVertexNormals();
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const pe = `
|
|
644
|
+
#include <fog_pars_fragment>
|
|
645
|
+
#include <logdepthbuf_pars_fragment>
|
|
646
|
+
|
|
647
|
+
uniform float useDash;
|
|
648
|
+
uniform float dashArray;
|
|
649
|
+
uniform float dashOffset;
|
|
650
|
+
uniform float dashRatio;
|
|
651
|
+
uniform sampler2D alphaMap;
|
|
652
|
+
uniform float useAlphaMap;
|
|
653
|
+
|
|
654
|
+
varying vec2 vUV;
|
|
655
|
+
varying vec4 vColor;
|
|
656
|
+
varying float vCounters;
|
|
657
|
+
|
|
658
|
+
uniform sampler2D map;
|
|
659
|
+
uniform float useMap;
|
|
660
|
+
uniform vec2 repeat;
|
|
661
|
+
uniform float offsetLoop;
|
|
662
|
+
uniform float alphaTest;
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
void main() {
|
|
667
|
+
#include <logdepthbuf_fragment>
|
|
668
|
+
|
|
669
|
+
vec4 c = vColor;
|
|
670
|
+
|
|
671
|
+
if( useMap == 1. ) c *= texture2D( map, vUV * repeat );
|
|
672
|
+
if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).r;
|
|
673
|
+
if(offsetLoop!=1.0){
|
|
674
|
+
if(vUV.x>1.0 || vUV.x<0.0){
|
|
675
|
+
c.a = 0.0;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (c.a < alphaTest) discard;
|
|
679
|
+
if( useDash == 1. ){
|
|
680
|
+
c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));
|
|
681
|
+
}
|
|
682
|
+
gl_FragColor = c;
|
|
683
|
+
#include <fog_fragment>
|
|
684
|
+
#include <${parseInt(Et) < 154 ? "encodings_fragment" : "colorspace_fragment"}>
|
|
685
|
+
}
|
|
686
|
+
`, me = `
|
|
687
|
+
#include <common>
|
|
688
|
+
${W.logdepthbuf_pars_vertex}
|
|
689
|
+
${W.fog_pars_vertex}
|
|
690
|
+
|
|
691
|
+
attribute vec3 previous;
|
|
692
|
+
attribute vec3 next;
|
|
693
|
+
attribute float side;
|
|
694
|
+
attribute float width;
|
|
695
|
+
attribute float counters;
|
|
696
|
+
|
|
697
|
+
uniform vec2 resolution;
|
|
698
|
+
uniform float lineWidth;
|
|
699
|
+
uniform vec3 color;
|
|
700
|
+
uniform float opacity;
|
|
701
|
+
uniform float sizeAttenuation;
|
|
702
|
+
uniform float scaleDown;
|
|
703
|
+
uniform vec2 offset;
|
|
704
|
+
|
|
705
|
+
varying vec2 vUV;
|
|
706
|
+
varying vec4 vColor;
|
|
707
|
+
varying float vCounters;
|
|
708
|
+
|
|
709
|
+
vec2 intoScreen(vec4 i) {
|
|
710
|
+
return resolution * (0.5 * i.xy / i.w + 0.5);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
void main() {
|
|
714
|
+
float aspect = resolution.y / resolution.x;
|
|
715
|
+
|
|
716
|
+
mat4 m = projectionMatrix * modelViewMatrix;
|
|
717
|
+
|
|
718
|
+
vec4 currentClip = m * vec4( position, 1.0 );
|
|
719
|
+
vec4 prevClip = m * vec4( previous, 1.0 );
|
|
720
|
+
vec4 nextClip = m * vec4( next, 1.0 );
|
|
721
|
+
|
|
722
|
+
vec4 currentNormed = currentClip / currentClip.w;
|
|
723
|
+
vec4 prevNormed = prevClip / prevClip.w;
|
|
724
|
+
vec4 nextNormed = nextClip / nextClip.w;
|
|
725
|
+
|
|
726
|
+
vec2 currentScreen = intoScreen(currentNormed);
|
|
727
|
+
vec2 prevScreen = intoScreen(prevNormed);
|
|
728
|
+
vec2 nextScreen = intoScreen(nextNormed);
|
|
729
|
+
|
|
730
|
+
float actualWidth = lineWidth * width;
|
|
731
|
+
|
|
732
|
+
vec2 dir;
|
|
733
|
+
if(nextScreen == currentScreen) {
|
|
734
|
+
dir = normalize( currentScreen - prevScreen );
|
|
735
|
+
} else if(prevScreen == currentScreen) {
|
|
736
|
+
dir = normalize( nextScreen - currentScreen );
|
|
737
|
+
} else {
|
|
738
|
+
vec2 inDir = currentScreen - prevScreen;
|
|
739
|
+
vec2 outDir = nextScreen - currentScreen;
|
|
740
|
+
vec2 fullDir = nextScreen - prevScreen;
|
|
741
|
+
|
|
742
|
+
if(length(fullDir) > 0.0) {
|
|
743
|
+
dir = normalize(fullDir);
|
|
744
|
+
} else if(length(inDir) > 0.0){
|
|
745
|
+
dir = normalize(inDir);
|
|
746
|
+
} else {
|
|
747
|
+
dir = normalize(outDir);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
vec2 normal = vec2(-dir.y, dir.x);
|
|
752
|
+
|
|
753
|
+
if(sizeAttenuation != 0.0) {
|
|
754
|
+
normal /= currentClip.w;
|
|
755
|
+
normal *= min(resolution.x, resolution.y);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
if (scaleDown > 0.0) {
|
|
759
|
+
float dist = length(nextNormed - prevNormed);
|
|
760
|
+
normal *= smoothstep(0.0, scaleDown, dist);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
vec2 offsetInScreen = actualWidth * normal * side * 0.5;
|
|
764
|
+
|
|
765
|
+
vec2 withOffsetScreen = currentScreen + offsetInScreen;
|
|
766
|
+
vec3 withOffsetNormed = vec3((2.0 * withOffsetScreen/resolution - 1.0), currentNormed.z);
|
|
767
|
+
|
|
768
|
+
vCounters = counters;
|
|
769
|
+
vColor = vec4( color, opacity );
|
|
770
|
+
vUV = uv;
|
|
771
|
+
vUV=uv+offset;
|
|
772
|
+
|
|
773
|
+
gl_Position = currentClip.w * vec4(withOffsetNormed, 1.0);
|
|
774
|
+
|
|
775
|
+
${W.logdepthbuf_vertex}
|
|
776
|
+
${W.fog_vertex}
|
|
777
|
+
}
|
|
778
|
+
`;
|
|
779
|
+
class Oe extends Lt {
|
|
780
|
+
constructor(t = {}) {
|
|
781
|
+
const S = t, {
|
|
782
|
+
lineWidth: e = 1,
|
|
783
|
+
color: i = "#ffffff",
|
|
784
|
+
opacity: s = 1,
|
|
785
|
+
map: a = null,
|
|
786
|
+
dashOffset: l = 0,
|
|
787
|
+
dashArray: r = 0,
|
|
788
|
+
dashRatio: c = 0,
|
|
789
|
+
sizeAttenuation: o = !0,
|
|
790
|
+
offsetLoop: h = !0,
|
|
791
|
+
offset: f = new K(0, 0),
|
|
792
|
+
scaleDown: p = 0,
|
|
793
|
+
alphaMap: u = void 0,
|
|
794
|
+
alphaTest: m = 0,
|
|
795
|
+
repeat: d = new K(1, 1),
|
|
796
|
+
resolution: v = new K(1, 1)
|
|
797
|
+
} = S, w = rt(S, [
|
|
798
|
+
"lineWidth",
|
|
799
|
+
"color",
|
|
800
|
+
"opacity",
|
|
801
|
+
"map",
|
|
802
|
+
"dashOffset",
|
|
803
|
+
"dashArray",
|
|
804
|
+
"dashRatio",
|
|
805
|
+
"sizeAttenuation",
|
|
806
|
+
"offsetLoop",
|
|
807
|
+
"offset",
|
|
808
|
+
"scaleDown",
|
|
809
|
+
"alphaMap",
|
|
810
|
+
"alphaTest",
|
|
811
|
+
"repeat",
|
|
812
|
+
"resolution"
|
|
813
|
+
]);
|
|
814
|
+
super(q(L({}, w), {
|
|
815
|
+
uniforms: {
|
|
816
|
+
lineWidth: { value: e },
|
|
817
|
+
color: { value: new ut(i) },
|
|
818
|
+
opacity: { value: s },
|
|
819
|
+
map: { value: a },
|
|
820
|
+
useMap: { value: a ? 1 : 0 },
|
|
821
|
+
resolution: { value: v },
|
|
822
|
+
sizeAttenuation: { value: o ? 1 : 0 },
|
|
823
|
+
offset: { value: f },
|
|
824
|
+
offsetLoop: { value: h ? 1 : 0 },
|
|
825
|
+
dashArray: { value: r },
|
|
826
|
+
dashOffset: { value: l },
|
|
827
|
+
dashRatio: { value: c },
|
|
828
|
+
useDash: { value: r > 0 ? 1 : 0 },
|
|
829
|
+
scaleDown: { value: p / 10 },
|
|
830
|
+
alphaTest: { value: m },
|
|
831
|
+
alphaMap: { value: u },
|
|
832
|
+
useAlphaMap: { value: u ? 1 : 0 },
|
|
833
|
+
repeat: { value: d }
|
|
834
|
+
},
|
|
835
|
+
vertexShader: me,
|
|
836
|
+
fragmentShader: pe
|
|
837
|
+
})), this.type = "MeshLineMaterial";
|
|
838
|
+
}
|
|
839
|
+
// Getter and setter for color
|
|
840
|
+
get color() {
|
|
841
|
+
return this.uniforms.color.value;
|
|
842
|
+
}
|
|
843
|
+
set color(t) {
|
|
844
|
+
this.uniforms.color.value = new ut(t);
|
|
845
|
+
}
|
|
846
|
+
get opacity() {
|
|
847
|
+
var t;
|
|
848
|
+
return ((t = this.uniforms) == null ? void 0 : t.opacity.value) || 1;
|
|
849
|
+
}
|
|
850
|
+
set opacity(t) {
|
|
851
|
+
this.uniforms && (this.uniforms.opacity.value = t);
|
|
852
|
+
}
|
|
853
|
+
// Getter and setter for map
|
|
854
|
+
get map() {
|
|
855
|
+
return this.uniforms.map.value;
|
|
856
|
+
}
|
|
857
|
+
set map(t) {
|
|
858
|
+
this.uniforms.map.value = t, this.uniforms.useMap.value = t ? 1 : 0;
|
|
859
|
+
}
|
|
860
|
+
get repeat() {
|
|
861
|
+
return this.uniforms.repeat.value;
|
|
862
|
+
}
|
|
863
|
+
set repeat(t) {
|
|
864
|
+
this.uniforms.repeat.value.copy(t);
|
|
865
|
+
}
|
|
866
|
+
// Getter and setter for lineWidth
|
|
867
|
+
get lineWidth() {
|
|
868
|
+
return this.uniforms.lineWidth.value;
|
|
869
|
+
}
|
|
870
|
+
set lineWidth(t) {
|
|
871
|
+
this.uniforms.lineWidth.value = t;
|
|
872
|
+
}
|
|
873
|
+
// Getter and setter for sizeAttenuation
|
|
874
|
+
get sizeAttenuation() {
|
|
875
|
+
return this.uniforms.sizeAttenuation.value === 1;
|
|
876
|
+
}
|
|
877
|
+
set sizeAttenuation(t) {
|
|
878
|
+
this.uniforms.sizeAttenuation.value = t ? 1 : 0;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
const Q = new O(), gt = new I(), bt = new I(), g = new O(), b = new O(), B = new O(), X = new I(), Y = new Ot(), M = new Vt(), Mt = new I(), N = new jt(), U = new kt(), z = new O();
|
|
882
|
+
let T, E;
|
|
883
|
+
function xt(n, t, e) {
|
|
884
|
+
return z.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), z.multiplyScalar(1 / z.w), z.x = E / e.width, z.y = E / e.height, z.applyMatrix4(n.projectionMatrixInverse), z.multiplyScalar(1 / z.w), Math.abs(Math.max(z.x, z.y));
|
|
885
|
+
}
|
|
886
|
+
function ve(n, t) {
|
|
887
|
+
const e = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
|
|
888
|
+
for (let r = 0, c = l; r < c; r++) {
|
|
889
|
+
M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(e);
|
|
890
|
+
const o = new I(), h = new I();
|
|
891
|
+
T.distanceSqToSegment(M.start, M.end, h, o), h.distanceTo(o) < E * 0.5 && t.push({
|
|
892
|
+
point: h,
|
|
893
|
+
pointOnLine: o,
|
|
894
|
+
distance: T.origin.distanceTo(h),
|
|
895
|
+
object: n,
|
|
896
|
+
face: null,
|
|
897
|
+
faceIndex: r,
|
|
898
|
+
uv: null,
|
|
899
|
+
uv1: null
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
function ye(n, t, e) {
|
|
904
|
+
const i = t.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, c = r.attributes.instanceStart, o = r.attributes.instanceEnd, h = Math.min(r.instanceCount, c.count), f = -t.near;
|
|
905
|
+
T.at(1, B), B.w = 1, B.applyMatrix4(t.matrixWorldInverse), B.applyMatrix4(i), B.multiplyScalar(1 / B.w), B.x *= a.x / 2, B.y *= a.y / 2, B.z = 0, X.copy(B), Y.multiplyMatrices(t.matrixWorldInverse, l);
|
|
906
|
+
for (let p = 0, u = h; p < u; p++) {
|
|
907
|
+
if (g.fromBufferAttribute(c, p), b.fromBufferAttribute(o, p), g.w = 1, b.w = 1, g.applyMatrix4(Y), b.applyMatrix4(Y), g.z > f && b.z > f)
|
|
908
|
+
continue;
|
|
909
|
+
if (g.z > f) {
|
|
910
|
+
const D = g.z - b.z, j = (g.z - f) / D;
|
|
911
|
+
g.lerp(b, j);
|
|
912
|
+
} else if (b.z > f) {
|
|
913
|
+
const D = b.z - g.z, j = (b.z - f) / D;
|
|
914
|
+
b.lerp(g, j);
|
|
915
|
+
}
|
|
916
|
+
g.applyMatrix4(i), b.applyMatrix4(i), g.multiplyScalar(1 / g.w), b.multiplyScalar(1 / b.w), g.x *= a.x / 2, g.y *= a.y / 2, b.x *= a.x / 2, b.y *= a.y / 2, M.start.copy(g), M.start.z = 0, M.end.copy(b), M.end.z = 0;
|
|
917
|
+
const d = M.closestPointToPointParameter(X, !0);
|
|
918
|
+
M.at(d, Mt);
|
|
919
|
+
const v = Nt.lerp(g.z, b.z, d), w = v >= -1 && v <= 1, S = X.distanceTo(Mt) < E * 0.5;
|
|
920
|
+
if (w && S) {
|
|
921
|
+
M.start.fromBufferAttribute(c, p), M.end.fromBufferAttribute(o, p), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
|
|
922
|
+
const D = new I(), j = new I();
|
|
923
|
+
T.distanceSqToSegment(M.start, M.end, j, D), e.push({
|
|
924
|
+
point: j,
|
|
925
|
+
pointOnLine: D,
|
|
926
|
+
distance: T.origin.distanceTo(j),
|
|
927
|
+
object: n,
|
|
928
|
+
face: null,
|
|
929
|
+
faceIndex: p,
|
|
930
|
+
uv: null,
|
|
931
|
+
uv1: null
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
class Ve extends St {
|
|
937
|
+
constructor(t = new te(), e) {
|
|
938
|
+
super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
|
|
939
|
+
}
|
|
940
|
+
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
941
|
+
computeLineDistances() {
|
|
942
|
+
const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
|
|
943
|
+
for (let l = 0, r = 0, c = e.count; l < c; l++, r += 2)
|
|
944
|
+
gt.fromBufferAttribute(e, l), bt.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + gt.distanceTo(bt);
|
|
945
|
+
const a = new Wt(
|
|
946
|
+
s,
|
|
947
|
+
2,
|
|
948
|
+
1
|
|
949
|
+
);
|
|
950
|
+
return t.setAttribute(
|
|
951
|
+
"instanceDistanceStart",
|
|
952
|
+
new ft(a, 1, 0)
|
|
953
|
+
), t.setAttribute(
|
|
954
|
+
"instanceDistanceEnd",
|
|
955
|
+
new ft(a, 1, 1)
|
|
956
|
+
), this;
|
|
957
|
+
}
|
|
958
|
+
raycast(t, e) {
|
|
959
|
+
const i = this.material.worldUnits, s = t.camera;
|
|
960
|
+
s === null && !i && console.error(
|
|
961
|
+
'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
|
|
962
|
+
);
|
|
963
|
+
const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
|
|
964
|
+
T = t.ray;
|
|
965
|
+
const l = this.matrixWorld, r = this.geometry, c = this.material;
|
|
966
|
+
E = c.linewidth + a, r.boundingSphere === null && r.computeBoundingSphere(), U.copy(r.boundingSphere).applyMatrix4(l);
|
|
967
|
+
let o;
|
|
968
|
+
if (i)
|
|
969
|
+
o = E * 0.5;
|
|
970
|
+
else {
|
|
971
|
+
const f = Math.max(
|
|
972
|
+
s.near,
|
|
973
|
+
U.distanceToPoint(T.origin)
|
|
974
|
+
);
|
|
975
|
+
o = xt(
|
|
976
|
+
s,
|
|
977
|
+
f,
|
|
978
|
+
c.resolution
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
if (U.radius += o, T.intersectsSphere(U) === !1)
|
|
982
|
+
return;
|
|
983
|
+
r.boundingBox === null && r.computeBoundingBox(), N.copy(r.boundingBox).applyMatrix4(l);
|
|
984
|
+
let h;
|
|
985
|
+
if (i)
|
|
986
|
+
h = E * 0.5;
|
|
987
|
+
else {
|
|
988
|
+
const f = Math.max(
|
|
989
|
+
s.near,
|
|
990
|
+
N.distanceToPoint(T.origin)
|
|
991
|
+
);
|
|
992
|
+
h = xt(
|
|
993
|
+
s,
|
|
994
|
+
f,
|
|
995
|
+
c.resolution
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
N.expandByScalar(h), T.intersectsBox(N) !== !1 && (i ? ve(this, e) : ye(this, s, e));
|
|
999
|
+
}
|
|
1000
|
+
onBeforeRender(t) {
|
|
1001
|
+
const e = this.material.uniforms;
|
|
1002
|
+
e && e.resolution && (t.getViewport(Q), this.material.uniforms.resolution.value.set(Q.z, Q.w));
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
export {
|
|
1006
|
+
_e as B,
|
|
1007
|
+
Ee as I,
|
|
1008
|
+
Ve as L,
|
|
1009
|
+
Oe as M,
|
|
1010
|
+
Le as P,
|
|
1011
|
+
se as R,
|
|
1012
|
+
mt as a,
|
|
1013
|
+
he as g
|
|
1014
|
+
};
|