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