gl-draw 0.17.0-beta.4 → 0.17.0-beta.41

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