gl-draw 0.13.2 → 0.13.4

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.
@@ -1,152 +1,400 @@
1
- var ce = Object.defineProperty, fe = Object.defineProperties;
2
- var he = Object.getOwnPropertyDescriptors;
1
+ var ft = Object.defineProperty, pt = Object.defineProperties;
2
+ var dt = Object.getOwnPropertyDescriptors;
3
3
  var K = Object.getOwnPropertySymbols;
4
- var pe = Object.prototype.hasOwnProperty, me = Object.prototype.propertyIsEnumerable;
5
- var X = Math.pow, Q = (n, t, e) => t in n ? ce(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, U = (n, t) => {
4
+ var mt = Object.prototype.hasOwnProperty, vt = Object.prototype.propertyIsEnumerable;
5
+ var Y = Math.pow, X = (o, t, e) => t in o ? ft(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, E = (o, t) => {
6
6
  for (var e in t || (t = {}))
7
- pe.call(t, e) && Q(n, e, t[e]);
7
+ mt.call(t, e) && X(o, e, t[e]);
8
8
  if (K)
9
9
  for (var e of K(t))
10
- me.call(t, e) && Q(n, e, t[e]);
11
- return n;
12
- }, Y = (n, t) => fe(n, he(t));
13
- import * as _ from "three";
14
- import { Vector4 as O, Vector3 as D, Matrix4 as de, Line3 as ve, Box3 as ge, Sphere as ye, Mesh as xe, InstancedInterleavedBuffer as Me, InterleavedBufferAttribute as H, MathUtils as be } from "three";
15
- import { LineSegmentsGeometry as we } from "three/examples/jsm/lines/LineSegmentsGeometry";
16
- import { merge as q, mean as Pe, extent as J } from "d3-array";
17
- import Ae, { flatten as ue } from "earcut";
18
- import Ce from "@turf/boolean-clockwise";
19
- import { p as _e } from "./polar2Cartesian.module.js";
20
- import Se from "delaunator";
21
- import ze from "@turf/boolean-point-in-polygon";
22
- import { geoBounds as le, geoContains as We, geoDistance as Ie, geoInterpolate as Be } from "d3-geo";
23
- import { geoVoronoi as Ve } from "d3-geo-voronoi";
24
- import { scaleLinear as ee } from "d3-scale";
25
- const j = new O(), te = new D(), ie = new D(), y = new O(), x = new O(), I = new O(), $ = new D(), k = new de(), M = new ve(), ne = new D(), E = new ge(), G = new ye(), B = new O();
26
- let V, L;
27
- function re(n, t, e) {
28
- return B.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), B.multiplyScalar(1 / B.w), B.x = L / e.width, B.y = L / e.height, B.applyMatrix4(n.projectionMatrixInverse), B.multiplyScalar(1 / B.w), Math.abs(Math.max(B.x, B.y));
10
+ vt.call(t, e) && X(o, e, t[e]);
11
+ return o;
12
+ }, H = (o, t) => pt(o, dt(t));
13
+ import * as h from "three";
14
+ import { Vector4 as V, Vector3 as W, Matrix4 as gt, Line3 as bt, Box3 as yt, Sphere as xt, Mesh as Mt, InstancedInterleavedBuffer as wt, InterleavedBufferAttribute as J, MathUtils as Pt } from "three";
15
+ import { makePromiseCreator as At } from "esus-lite";
16
+ import { CSS2DObject as Ct } from "three/examples/jsm/renderers/CSS2DRenderer";
17
+ import { CSS3DObject as St, CSS3DSprite as jt } from "three/examples/jsm/renderers/CSS3DRenderer";
18
+ import { p as tt, d as U, a as zt } from "./parseVector.module.js";
19
+ import { geoBounds as ct, geoContains as It, geoDistance as Dt, geoInterpolate as _t } from "d3-geo";
20
+ import "d3-geo-projection";
21
+ import { LineSegmentsGeometry as Bt } from "three/examples/jsm/lines/LineSegmentsGeometry";
22
+ import { merge as Q, mean as Lt, extent as et } from "d3-array";
23
+ import Wt, { flatten as ht } from "earcut";
24
+ import Tt from "@turf/boolean-clockwise";
25
+ import Vt from "delaunator";
26
+ import Ot from "@turf/boolean-point-in-polygon";
27
+ import { geoVoronoi as Et } from "d3-geo-voronoi";
28
+ import { scaleLinear as it } from "d3-scale";
29
+ const Ut = (o, t = 1) => {
30
+ const e = new h.BufferGeometry();
31
+ e.setAttribute(
32
+ "position",
33
+ new h.Float32BufferAttribute(new Array(t * 3).fill(0), 3)
34
+ ), e.setAttribute(
35
+ "scaleAtt",
36
+ new h.Float32BufferAttribute(new Array(t).fill(1), 1)
37
+ );
38
+ const i = o.material, r = new h.PointsMaterial({
39
+ size: 10,
40
+ map: i.map,
41
+ alphaMap: i.alphaMap,
42
+ color: i.color,
43
+ blending: i.blending,
44
+ depthTest: i.depthTest,
45
+ depthWrite: !1,
46
+ opacity: i.opacity,
47
+ transparent: !0,
48
+ alphaTest: i.alphaTest,
49
+ sizeAttenuation: !1
50
+ });
51
+ return r.onBeforeCompile = (n) => {
52
+ n.vertexShader = `
53
+ attribute float scaleAtt;
54
+ ${n.vertexShader.replace(
55
+ "gl_PointSize = size;",
56
+ "gl_PointSize = size * scaleAtt;"
57
+ )}
58
+ `;
59
+ }, new h.Points(e, r);
60
+ };
61
+ class Gt {
62
+ constructor() {
63
+ this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.pm = At(), this.materialList = {}, this.useMaterialType = "origin", this.onPointerIndex = [];
64
+ }
65
+ get parent() {
66
+ const t = this.object3d.parent;
67
+ return t ? this.drawController.objMap.get(t) || this.pencil.scene : null;
68
+ }
69
+ get children() {
70
+ return this.object3d.children.map((t) => this.drawController.objMap.get(t)).filter((t) => !!t);
71
+ }
72
+ get position() {
73
+ return this.object3d.position;
74
+ }
75
+ get rotation() {
76
+ return this.object3d.rotation;
77
+ }
78
+ get scale() {
79
+ return this.object3d.scale;
80
+ }
81
+ get add() {
82
+ return this.object3d.add.bind(this.object3d);
83
+ }
84
+ get remove() {
85
+ return this.object3d.remove.bind(this.object3d);
86
+ }
87
+ get visible() {
88
+ return this.object3d.visible;
89
+ }
90
+ get visibleWithAncestors() {
91
+ if (this.visible) {
92
+ let t = this.parent;
93
+ for (; t; ) {
94
+ if (!t.visible)
95
+ return !1;
96
+ t = t.parent;
97
+ }
98
+ return !0;
99
+ } else
100
+ return !1;
101
+ }
102
+ create() {
103
+ this.createGroup();
104
+ }
105
+ render() {
106
+ }
107
+ update(t, e) {
108
+ }
109
+ resize(t, e) {
110
+ }
111
+ show() {
112
+ return this.object3d.visible = !0, this;
113
+ }
114
+ hide() {
115
+ return this.object3d.visible = !1, this;
116
+ }
117
+ createMesh(...t) {
118
+ return this.object3d = new h.Mesh(...t), this;
119
+ }
120
+ createGroup() {
121
+ return this.object3d = new h.Group(), this;
122
+ }
123
+ createPoints(...t) {
124
+ return this.object3d = new h.Points(...t), this;
125
+ }
126
+ createCSS2DObject(t) {
127
+ return this.object3d = new Ct(t), this;
128
+ }
129
+ createCSS3DObject(t) {
130
+ return this.object3d = new St(t), this;
131
+ }
132
+ createCSS3DSprite(t) {
133
+ return this.object3d = new jt(t), this;
134
+ }
135
+ createSprite(t) {
136
+ return this.object3d = new h.Sprite(t), this;
137
+ }
138
+ attach(...t) {
139
+ return [...t].forEach((e) => {
140
+ this.object3d.attach(e.object3d);
141
+ }), this;
142
+ }
143
+ getSize() {
144
+ const t = new h.Box3().setFromObject(this.object3d);
145
+ return {
146
+ min: t.min,
147
+ max: t.max,
148
+ size: t.getSize(new h.Vector3()),
149
+ center: t.getCenter(new h.Vector3())
150
+ };
151
+ }
152
+ traverse(t) {
153
+ t(this), this.children.forEach((e) => {
154
+ e.traverse(t);
155
+ });
156
+ }
157
+ clone() {
158
+ return this.instantiate();
159
+ }
160
+ instantiate(t) {
161
+ const e = t && t.length > 0;
162
+ return this.drawController.instantiate(this, {
163
+ create: (i) => {
164
+ var r;
165
+ if (this.object3d) {
166
+ if (e) {
167
+ const n = t.length;
168
+ if (this.object3d instanceof h.Sprite)
169
+ i.object3d = Ut(this.object3d, n);
170
+ else {
171
+ const s = this.object3d;
172
+ i.object3d = new h.InstancedMesh(
173
+ s.geometry,
174
+ s.material,
175
+ n
176
+ ), i.setMaterialList("instantiate", "clone"), i.useMaterial("instantiate");
177
+ }
178
+ const a = new h.Object3D();
179
+ t.forEach((s, l) => {
180
+ const u = tt(s.position), f = tt(s.scale || [1, 1, 1]);
181
+ a.position.copy(u), a.scale.copy(f), a.updateMatrix(), i.setInstancedMatrix(l, a.matrix.clone());
182
+ });
183
+ } else
184
+ i.object3d = this.object3d.clone(!0), i.position.set(0, 0, 0), i.rotation.set(0, 0, 0), i.setMaterialList("instantiate", "clone"), i.useMaterial("instantiate");
185
+ i.object3d.userData.bloom && ((r = this.pencil.composerController) == null || r.toggleBloomSelection(
186
+ i.object3d,
187
+ !0
188
+ )), i.object3d.userData.prefab && (i.object3d.userData.prefab = !1);
189
+ }
190
+ }
191
+ });
192
+ }
193
+ setInstancedMatrix(t, e) {
194
+ if (this.object3d instanceof h.InstancedMesh || this.object3d.isInstantiate)
195
+ this.object3d.setMatrixAt(t, e);
196
+ else if (this.object3d instanceof h.Points || this.object3d.type === "Points") {
197
+ const r = this.object3d.geometry, n = r.attributes.position.array, a = r.attributes.scaleAtt.array, s = new h.Vector3(), l = new h.Vector3(), u = new h.Quaternion(), f = t * 3, p = t * 1;
198
+ e.decompose(s, u, l), n[f] = s.x, n[f + 1] = s.y, n[f + 2] = s.z, a[p] = Math.max(l.x, l.y, l.z), r.attributes.position.needsUpdate = !0, r.attributes.scaleAtt.needsUpdate = !0;
199
+ }
200
+ }
201
+ erase() {
202
+ this.drawController.erase(this);
203
+ }
204
+ cloneMaterial() {
205
+ const t = this.object3d;
206
+ if (!t || !t.material)
207
+ return;
208
+ const e = t.material;
209
+ if (Array.isArray(e))
210
+ return e.map((i) => {
211
+ const r = i.userData;
212
+ i.userData = {};
213
+ const n = i.clone();
214
+ return i.userData = r, n;
215
+ });
216
+ {
217
+ const i = e.userData;
218
+ e.userData = {};
219
+ const r = e.clone();
220
+ return e.userData = i, r;
221
+ }
222
+ }
223
+ setMaterialList(t, e, i = !0) {
224
+ const r = this.object3d;
225
+ if (!r || !r.material)
226
+ return;
227
+ if (this.materialList.origin || (this.materialList.origin = r.material), this.materialList[t])
228
+ if (i) {
229
+ const a = this.materialList[t];
230
+ U({
231
+ material: a
232
+ });
233
+ } else
234
+ return this.materialList[t];
235
+ const n = e === "clone" ? this.cloneMaterial() : e;
236
+ return this.materialList[t] = n, n;
237
+ }
238
+ useMaterial(t) {
239
+ const e = this.object3d;
240
+ !e || !e.material || this.useMaterialType === t || !this.materialList[t] || (this.useMaterialType = t, e.material = this.materialList[t]);
241
+ }
242
+ setTop(t) {
243
+ this.object3d && (this.object3d.renderOrder = t);
244
+ }
245
+ onPointerEvent(t, e) {
246
+ const i = this.drawController.handlePick([this], t, e);
247
+ this.onPointerIndex.push(i);
248
+ }
249
+ dispose() {
250
+ this.onPointerIndex.forEach((t) => {
251
+ this.drawController.removePick(t);
252
+ }), this.object3d && U(this.object3d), Object.keys(this.materialList).forEach((t) => {
253
+ if (t !== this.useMaterialType) {
254
+ if (this.isInstantiate && t === "origin")
255
+ return;
256
+ U({
257
+ material: this.materialList[t]
258
+ });
259
+ }
260
+ });
261
+ }
262
+ disposeWithOutMaterial() {
263
+ this.onPointerIndex.forEach((t) => {
264
+ this.drawController.removePick(t);
265
+ }), this.object3d && U(this.object3d, !1);
266
+ }
267
+ }
268
+ class pe extends Gt {
269
+ create() {
270
+ this.createGroup();
271
+ }
272
+ }
273
+ const Z = new V(), rt = new W(), st = new W(), y = new V(), x = new V(), D = new V(), $ = new W(), q = new gt(), M = new bt(), nt = new W(), G = new yt(), R = new xt(), _ = new V();
274
+ let B, T;
275
+ function ot(o, t, e) {
276
+ return _.set(0, 0, -t, 1).applyMatrix4(o.projectionMatrix), _.multiplyScalar(1 / _.w), _.x = T / e.width, _.y = T / e.height, _.applyMatrix4(o.projectionMatrixInverse), _.multiplyScalar(1 / _.w), Math.abs(Math.max(_.x, _.y));
29
277
  }
30
- function Te(n, t) {
31
- const e = n.matrixWorld, s = n.geometry, r = s.attributes.instanceStart, o = s.attributes.instanceEnd, a = Math.min(s.instanceCount, r.count);
32
- for (let i = 0, c = a; i < c; i++) {
33
- M.start.fromBufferAttribute(r, i), M.end.fromBufferAttribute(o, i), M.applyMatrix4(e);
34
- const u = new D(), m = new D();
35
- V.distanceSqToSegment(M.start, M.end, m, u), m.distanceTo(u) < L * 0.5 && t.push({
36
- point: m,
278
+ function Rt(o, t) {
279
+ const e = o.matrixWorld, i = o.geometry, r = i.attributes.instanceStart, n = i.attributes.instanceEnd, a = Math.min(i.instanceCount, r.count);
280
+ for (let s = 0, l = a; s < l; s++) {
281
+ M.start.fromBufferAttribute(r, s), M.end.fromBufferAttribute(n, s), M.applyMatrix4(e);
282
+ const u = new W(), f = new W();
283
+ B.distanceSqToSegment(M.start, M.end, f, u), f.distanceTo(u) < T * 0.5 && t.push({
284
+ point: f,
37
285
  pointOnLine: u,
38
- distance: V.origin.distanceTo(m),
39
- object: n,
286
+ distance: B.origin.distanceTo(f),
287
+ object: o,
40
288
  face: null,
41
- faceIndex: i,
289
+ faceIndex: s,
42
290
  uv: null,
43
291
  uv1: null
44
292
  });
45
293
  }
46
294
  }
47
- function De(n, t, e) {
48
- const s = t.projectionMatrix, o = n.material.resolution, a = n.matrixWorld, i = n.geometry, c = i.attributes.instanceStart, u = i.attributes.instanceEnd, m = Math.min(i.instanceCount, c.count), f = -t.near;
49
- V.at(1, I), I.w = 1, I.applyMatrix4(t.matrixWorldInverse), I.applyMatrix4(s), I.multiplyScalar(1 / I.w), I.x *= o.x / 2, I.y *= o.y / 2, I.z = 0, $.copy(I), k.multiplyMatrices(t.matrixWorldInverse, a);
50
- for (let d = 0, l = m; d < l; d++) {
51
- if (y.fromBufferAttribute(c, d), x.fromBufferAttribute(u, d), y.w = 1, x.w = 1, y.applyMatrix4(k), x.applyMatrix4(k), y.z > f && x.z > f)
295
+ function Ft(o, t, e) {
296
+ const i = t.projectionMatrix, n = o.material.resolution, a = o.matrixWorld, s = o.geometry, l = s.attributes.instanceStart, u = s.attributes.instanceEnd, f = Math.min(s.instanceCount, l.count), p = -t.near;
297
+ B.at(1, D), D.w = 1, D.applyMatrix4(t.matrixWorldInverse), D.applyMatrix4(i), D.multiplyScalar(1 / D.w), D.x *= n.x / 2, D.y *= n.y / 2, D.z = 0, $.copy(D), q.multiplyMatrices(t.matrixWorldInverse, a);
298
+ for (let v = 0, c = f; v < c; v++) {
299
+ if (y.fromBufferAttribute(l, v), x.fromBufferAttribute(u, v), y.w = 1, x.w = 1, y.applyMatrix4(q), x.applyMatrix4(q), y.z > p && x.z > p)
52
300
  continue;
53
- if (y.z > f) {
54
- const W = y.z - x.z, w = (y.z - f) / W;
55
- y.lerp(x, w);
56
- } else if (x.z > f) {
57
- const W = x.z - y.z, w = (x.z - f) / W;
58
- x.lerp(y, w);
301
+ if (y.z > p) {
302
+ const I = y.z - x.z, P = (y.z - p) / I;
303
+ y.lerp(x, P);
304
+ } else if (x.z > p) {
305
+ const I = x.z - y.z, P = (x.z - p) / I;
306
+ x.lerp(y, P);
59
307
  }
60
- y.applyMatrix4(s), x.applyMatrix4(s), y.multiplyScalar(1 / y.w), x.multiplyScalar(1 / x.w), y.x *= o.x / 2, y.y *= o.y / 2, x.x *= o.x / 2, x.y *= o.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(x), M.end.z = 0;
61
- const h = M.closestPointToPointParameter($, !0);
62
- M.at(h, ne);
63
- const g = be.lerp(y.z, x.z, h), S = g >= -1 && g <= 1, z = $.distanceTo(ne) < L * 0.5;
64
- if (S && z) {
65
- M.start.fromBufferAttribute(c, d), M.end.fromBufferAttribute(u, d), M.start.applyMatrix4(a), M.end.applyMatrix4(a);
66
- const W = new D(), w = new D();
67
- V.distanceSqToSegment(M.start, M.end, w, W), e.push({
68
- point: w,
69
- pointOnLine: W,
70
- distance: V.origin.distanceTo(w),
71
- object: n,
308
+ y.applyMatrix4(i), x.applyMatrix4(i), y.multiplyScalar(1 / y.w), x.multiplyScalar(1 / x.w), y.x *= n.x / 2, y.y *= n.y / 2, x.x *= n.x / 2, x.y *= n.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(x), M.end.z = 0;
309
+ const d = M.closestPointToPointParameter($, !0);
310
+ M.at(d, nt);
311
+ const b = Pt.lerp(y.z, x.z, d), j = b >= -1 && b <= 1, z = $.distanceTo(nt) < T * 0.5;
312
+ if (j && z) {
313
+ M.start.fromBufferAttribute(l, v), M.end.fromBufferAttribute(u, v), M.start.applyMatrix4(a), M.end.applyMatrix4(a);
314
+ const I = new W(), P = new W();
315
+ B.distanceSqToSegment(M.start, M.end, P, I), e.push({
316
+ point: P,
317
+ pointOnLine: I,
318
+ distance: B.origin.distanceTo(P),
319
+ object: o,
72
320
  face: null,
73
- faceIndex: d,
321
+ faceIndex: v,
74
322
  uv: null,
75
323
  uv1: null
76
324
  });
77
325
  }
78
326
  }
79
327
  }
80
- class tt extends xe {
81
- constructor(t = new we(), e) {
328
+ class de extends Mt {
329
+ constructor(t = new Bt(), e) {
82
330
  super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
83
331
  }
84
332
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
85
333
  computeLineDistances() {
86
- const t = this.geometry, e = t.attributes.instanceStart, s = t.attributes.instanceEnd, r = new Float32Array(2 * e.count);
87
- for (let a = 0, i = 0, c = e.count; a < c; a++, i += 2)
88
- te.fromBufferAttribute(e, a), ie.fromBufferAttribute(s, a), r[i] = i === 0 ? 0 : r[i - 1], r[i + 1] = r[i] + te.distanceTo(ie);
89
- const o = new Me(
334
+ const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, r = new Float32Array(2 * e.count);
335
+ for (let a = 0, s = 0, l = e.count; a < l; a++, s += 2)
336
+ rt.fromBufferAttribute(e, a), st.fromBufferAttribute(i, a), r[s] = s === 0 ? 0 : r[s - 1], r[s + 1] = r[s] + rt.distanceTo(st);
337
+ const n = new wt(
90
338
  r,
91
339
  2,
92
340
  1
93
341
  );
94
342
  return t.setAttribute(
95
343
  "instanceDistanceStart",
96
- new H(o, 1, 0)
344
+ new J(n, 1, 0)
97
345
  ), t.setAttribute(
98
346
  "instanceDistanceEnd",
99
- new H(o, 1, 1)
347
+ new J(n, 1, 1)
100
348
  ), this;
101
349
  }
102
350
  raycast(t, e) {
103
- const s = this.material.worldUnits, r = t.camera;
104
- r === null && !s && console.error(
351
+ const i = this.material.worldUnits, r = t.camera;
352
+ r === null && !i && console.error(
105
353
  'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
106
354
  );
107
- const o = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
108
- V = t.ray;
109
- const a = this.matrixWorld, i = this.geometry, c = this.material;
110
- L = c.linewidth + o, i.boundingSphere === null && i.computeBoundingSphere(), G.copy(i.boundingSphere).applyMatrix4(a);
355
+ const n = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
356
+ B = t.ray;
357
+ const a = this.matrixWorld, s = this.geometry, l = this.material;
358
+ T = l.linewidth + n, s.boundingSphere === null && s.computeBoundingSphere(), R.copy(s.boundingSphere).applyMatrix4(a);
111
359
  let u;
112
- if (s)
113
- u = L * 0.5;
360
+ if (i)
361
+ u = T * 0.5;
114
362
  else {
115
- const f = Math.max(
363
+ const p = Math.max(
116
364
  r.near,
117
- G.distanceToPoint(V.origin)
365
+ R.distanceToPoint(B.origin)
118
366
  );
119
- u = re(
367
+ u = ot(
120
368
  r,
121
- f,
122
- c.resolution
369
+ p,
370
+ l.resolution
123
371
  );
124
372
  }
125
- if (G.radius += u, V.intersectsSphere(G) === !1)
373
+ if (R.radius += u, B.intersectsSphere(R) === !1)
126
374
  return;
127
- i.boundingBox === null && i.computeBoundingBox(), E.copy(i.boundingBox).applyMatrix4(a);
128
- let m;
129
- if (s)
130
- m = L * 0.5;
375
+ s.boundingBox === null && s.computeBoundingBox(), G.copy(s.boundingBox).applyMatrix4(a);
376
+ let f;
377
+ if (i)
378
+ f = T * 0.5;
131
379
  else {
132
- const f = Math.max(
380
+ const p = Math.max(
133
381
  r.near,
134
- E.distanceToPoint(V.origin)
382
+ G.distanceToPoint(B.origin)
135
383
  );
136
- m = re(
384
+ f = ot(
137
385
  r,
138
- f,
139
- c.resolution
386
+ p,
387
+ l.resolution
140
388
  );
141
389
  }
142
- E.expandByScalar(m), V.intersectsBox(E) !== !1 && (s ? Te(this, e) : De(this, r, e));
390
+ G.expandByScalar(f), B.intersectsBox(G) !== !1 && (i ? Rt(this, e) : Ft(this, r, e));
143
391
  }
144
392
  onBeforeRender(t) {
145
393
  const e = this.material.uniforms;
146
- e && e.resolution && (t.getViewport(j), this.material.uniforms.resolution.value.set(j.z, j.w));
394
+ e && e.resolution && (t.getViewport(Z), this.material.uniforms.resolution.value.set(Z.z, Z.w));
147
395
  }
148
396
  }
149
- const se = ["encodings_fragment", "colorspace_fragment"], Le = (
397
+ const at = ["encodings_fragment", "colorspace_fragment"], kt = (
150
398
  /* glsl */
151
399
  `
152
400
  #include <common>
@@ -242,7 +490,7 @@ const se = ["encodings_fragment", "colorspace_fragment"], Le = (
242
490
  #include <fog_vertex>
243
491
  }
244
492
  `
245
- ), Oe = (
493
+ ), Zt = (
246
494
  /* glsl */
247
495
  `
248
496
  #include <packing>
@@ -294,22 +542,22 @@ const se = ["encodings_fragment", "colorspace_fragment"], Le = (
294
542
 
295
543
  #include <fog_fragment>
296
544
  #include <tonemapping_fragment>
297
- #include <${+_.REVISION < 154 ? se[0] : se[1]}>
545
+ #include <${+h.REVISION < 154 ? at[0] : at[1]}>
298
546
  }
299
547
  `
300
548
  );
301
- class it extends _.ShaderMaterial {
549
+ class me extends h.ShaderMaterial {
302
550
  constructor(t) {
303
551
  super({
304
- uniforms: Y(U({}, _.UniformsLib.fog), {
552
+ uniforms: H(E({}, h.UniformsLib.fog), {
305
553
  lineWidth: { value: 1 },
306
554
  map: { value: null },
307
555
  useMap: { value: 0 },
308
556
  alphaMap: { value: null },
309
557
  useAlphaMap: { value: 0 },
310
- color: { value: new _.Color(16777215) },
558
+ color: { value: new h.Color(16777215) },
311
559
  opacity: { value: 1 },
312
- resolution: { value: new _.Vector2(1, 1) },
560
+ resolution: { value: new h.Vector2(1, 1) },
313
561
  sizeAttenuation: { value: 1 },
314
562
  dashArray: { value: 0 },
315
563
  dashOffset: { value: 0 },
@@ -318,19 +566,19 @@ class it extends _.ShaderMaterial {
318
566
  useDepth: { value: 0 },
319
567
  visibility: { value: 1 },
320
568
  alphaTest: { value: 0 },
321
- repeat: { value: new _.Vector2(1, 1) },
322
- offset: { value: new _.Vector2(0, 0) },
569
+ repeat: { value: new h.Vector2(1, 1) },
570
+ offset: { value: new h.Vector2(0, 0) },
323
571
  offsetLoop: { value: 1 },
324
572
  lineLightAnimation: { value: 0 },
325
573
  time: { value: 0 },
326
574
  size: { value: 300 },
327
575
  speed: { value: 0.3 },
328
576
  lightWidth: { value: 0.1 },
329
- uCenter: { value: new _.Vector2(0, 0) },
330
- lightColor: { value: new _.Color(16777215) }
577
+ uCenter: { value: new h.Vector2(0, 0) },
578
+ lightColor: { value: new h.Color(16777215) }
331
579
  }),
332
- vertexShader: Le,
333
- fragmentShader: Oe
580
+ vertexShader: kt,
581
+ fragmentShader: Zt
334
582
  }), this.type = "MeshLineMaterial", Object.defineProperties(this, {
335
583
  lineWidth: {
336
584
  enumerable: !0,
@@ -554,220 +802,220 @@ class it extends _.ShaderMaterial {
554
802
  return super.copy(t), this.lineWidth = t.lineWidth, this.map = t.map, this.useMap = t.useMap, this.alphaMap = t.alphaMap, this.useAlphaMap = t.useAlphaMap, this.color.copy(t.color), this.opacity = t.opacity, this.resolution.copy(t.resolution), this.sizeAttenuation = t.sizeAttenuation, this.dashArray = t.dashArray, this.dashOffset = t.dashOffset, this.dashRatio = t.dashRatio, this.useDash = t.useDash, this.visibility = t.visibility, this.alphaTest = t.alphaTest, this.repeat.copy(t.repeat), this;
555
803
  }
556
804
  }
557
- function Re(n, t) {
558
- return n.map((e) => {
559
- const s = [];
805
+ function $t(o, t) {
806
+ return o.map((e) => {
807
+ const i = [];
560
808
  let r;
561
- return e.forEach((o) => {
809
+ return e.forEach((n) => {
562
810
  if (r) {
563
- const a = Ie(o, r) * 180 / Math.PI;
811
+ const a = Dt(n, r) * 180 / Math.PI;
564
812
  if (a > t) {
565
- const i = Be(r, o), c = 1 / Math.ceil(a / t);
566
- let u = c;
813
+ const s = _t(r, n), l = 1 / Math.ceil(a / t);
814
+ let u = l;
567
815
  for (; u < 1; )
568
- s.push(i(u)), u += c;
816
+ i.push(s(u)), u += l;
569
817
  }
570
818
  }
571
- s.push(r = o);
572
- }), s;
819
+ i.push(r = n);
820
+ }), i;
573
821
  });
574
822
  }
575
- function Ue(n, { minLng: t, maxLng: e, minLat: s, maxLat: r } = {}) {
576
- const o = Math.round(X(360 / n, 2) / Math.PI), a = (1 + Math.sqrt(5)) / 2, i = (l) => l / a * 360 % 360 - 180, c = (l) => Math.acos(2 * l / o - 1) / Math.PI * 180 - 90, u = (l) => o * (Math.cos((l + 90) * Math.PI / 180) + 1) / 2, m = [
823
+ function qt(o, { minLng: t, maxLng: e, minLat: i, maxLat: r } = {}) {
824
+ const n = Math.round(Y(360 / o, 2) / Math.PI), a = (1 + Math.sqrt(5)) / 2, s = (c) => c / a * 360 % 360 - 180, l = (c) => Math.acos(2 * c / n - 1) / Math.PI * 180 - 90, u = (c) => n * (Math.cos((c + 90) * Math.PI / 180) + 1) / 2, f = [
577
825
  r !== void 0 ? Math.ceil(u(r)) : 0,
578
- s !== void 0 ? Math.floor(u(s)) : o - 1
579
- ], f = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (l) => l <= e : e === void 0 ? (l) => l >= t : e >= t ? (l) => l >= t && l <= e : (l) => l >= t || l <= e, d = [];
580
- for (let l = m[0]; l <= m[1]; l++) {
581
- const p = i(l);
582
- f(p) && d.push([p, c(l)]);
826
+ i !== void 0 ? Math.floor(u(i)) : n - 1
827
+ ], p = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (c) => c <= e : e === void 0 ? (c) => c >= t : e >= t ? (c) => c >= t && c <= e : (c) => c >= t || c <= e, v = [];
828
+ for (let c = f[0]; c <= f[1]; c++) {
829
+ const m = s(c);
830
+ p(m) && v.push([m, l(c)]);
583
831
  }
584
- return d;
832
+ return v;
585
833
  }
586
- function N(n, t, e = !1) {
587
- return e ? We(t, n) : ze(n, t);
834
+ function N(o, t, e = !1) {
835
+ return e ? It(t, o) : Ot(o, t);
588
836
  }
589
- function Ee(n, t) {
590
- const e = { type: "Polygon", coordinates: n }, [[s, r], [o, a]] = le(e);
591
- if (Math.min(Math.abs(o - s), Math.abs(a - r)) < t)
837
+ function Nt(o, t) {
838
+ const e = { type: "Polygon", coordinates: o }, [[i, r], [n, a]] = ct(e);
839
+ if (Math.min(Math.abs(n - i), Math.abs(a - r)) < t)
592
840
  return [];
593
- const i = s > o || a >= 89 || r <= -89;
594
- return Ue(t, {
595
- minLng: s,
596
- maxLng: o,
841
+ const s = i > n || a >= 89 || r <= -89;
842
+ return qt(t, {
843
+ minLng: i,
844
+ maxLng: n,
597
845
  minLat: r,
598
846
  maxLat: a
599
847
  }).filter(
600
- (c) => N(c, e, i)
848
+ (l) => N(l, e, s)
601
849
  );
602
850
  }
603
- function Ge(n, { resolution: t = 1 / 0, bbox: e, projection: s } = {}) {
604
- const r = Re(n, t), o = q(r), a = Ee(n, t), i = [...o, ...a], c = { type: "Polygon", coordinates: n }, [[u, m], [f, d]] = le(c), l = u > f || // crosses antimeridian
605
- d >= 89 || // crosses north pole
606
- m <= -89;
607
- let p = [];
608
- if (l) {
609
- const v = Ve(i).triangles(), b = new Map(
610
- i.map(([P, A], T) => [`${P}-${A}`, T])
851
+ function Qt(o, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
852
+ const r = $t(o, t), n = Q(r), a = Nt(o, t), s = [...n, ...a], l = { type: "Polygon", coordinates: o }, [[u, f], [p, v]] = ct(l), c = u > p || // crosses antimeridian
853
+ v >= 89 || // crosses north pole
854
+ f <= -89;
855
+ let m = [];
856
+ if (c) {
857
+ const g = Et(s).triangles(), w = new Map(
858
+ s.map(([A, C], L) => [`${A}-${C}`, L])
611
859
  );
612
- v.features.forEach((P) => {
613
- const A = P.geometry.coordinates[0].slice(0, 3).reverse(), T = [];
614
- if (A.forEach(([C, Z]) => {
615
- const R = `${C}-${Z}`;
616
- b.has(R) && T.push(b.get(R));
617
- }), T.length === 3) {
618
- if (T.some((C) => C < o.length)) {
619
- const C = P.properties.circumcenter;
860
+ g.features.forEach((A) => {
861
+ const C = A.geometry.coordinates[0].slice(0, 3).reverse(), L = [];
862
+ if (C.forEach(([S, k]) => {
863
+ const O = `${S}-${k}`;
864
+ w.has(O) && L.push(w.get(O));
865
+ }), L.length === 3) {
866
+ if (L.some((S) => S < n.length)) {
867
+ const S = A.properties.circumcenter;
620
868
  if (!N(
621
- C,
622
- c,
623
- l
869
+ S,
870
+ l,
871
+ c
624
872
  ))
625
873
  return;
626
874
  }
627
- p.push(...T);
875
+ m.push(...L);
628
876
  }
629
877
  });
630
878
  } else if (a.length) {
631
- const v = Se.from(i);
632
- for (let b = 0, P = v.triangles.length; b < P; b += 3) {
633
- const A = [2, 1, 0].map((C) => v.triangles[b + C]), T = A.map((C) => i[C]);
634
- if (A.some((C) => C < o.length)) {
635
- const C = [0, 1].map(
636
- (Z) => Pe(T, (R) => R[Z])
879
+ const g = Vt.from(s);
880
+ for (let w = 0, A = g.triangles.length; w < A; w += 3) {
881
+ const C = [2, 1, 0].map((S) => g.triangles[w + S]), L = C.map((S) => s[S]);
882
+ if (C.some((S) => S < n.length)) {
883
+ const S = [0, 1].map(
884
+ (k) => Lt(L, (O) => O[k])
637
885
  );
638
886
  if (!N(
639
- C,
640
- c,
641
- l
887
+ S,
888
+ l,
889
+ c
642
890
  ))
643
891
  continue;
644
892
  }
645
- p.push(...A);
893
+ m.push(...C);
646
894
  }
647
895
  } else {
648
- const { vertices: v, holes: b = [] } = ue(r);
649
- p = Ae(v, b, 2);
650
- }
651
- let h = e ? [e[0], e[2]] : J(i, (v) => v[0]), g = e ? [e[1], e[3]] : J(i, (v) => v[1]);
652
- if (s) {
653
- const [v, b] = s([h[0], g[0]]), [P, A] = s([h[1], g[1]]);
654
- h = [v, P], g = [-b, -A];
655
- }
656
- const S = ee(h, [0, 1]), z = ee(g, [0, 1]), W = i.map(([v, b]) => {
657
- if (s) {
658
- const [P, A] = s([v, b]);
659
- return [S(P), z(-A)];
896
+ const { vertices: g, holes: w = [] } = ht(r);
897
+ m = Wt(g, w, 2);
898
+ }
899
+ let d = e ? [e[0], e[2]] : et(s, (g) => g[0]), b = e ? [e[1], e[3]] : et(s, (g) => g[1]);
900
+ if (i) {
901
+ const [g, w] = i([d[0], b[0]]), [A, C] = i([d[1], b[1]]);
902
+ d = [g, A], b = [-w, -C];
903
+ }
904
+ const j = it(d, [0, 1]), z = it(b, [0, 1]), I = s.map(([g, w]) => {
905
+ if (i) {
906
+ const [A, C] = i([g, w]);
907
+ return [j(A), z(-C)];
660
908
  } else
661
- return [S(v), z(b)];
909
+ return [j(g), z(w)];
662
910
  });
663
- return { contour: r, triangles: { points: i, indices: p, uvs: W } };
911
+ return { contour: r, triangles: { points: s, indices: m, uvs: I } };
664
912
  }
665
- const oe = new _.BufferGeometry().setAttribute ? "setAttribute" : "addAttribute";
666
- function F(n, t, e, s) {
667
- const r = n.map(
668
- (o) => o.map(([a, i]) => {
669
- if (s) {
670
- const [c, u] = s([a, i]);
671
- return [c, -u, t];
913
+ const lt = new h.BufferGeometry().setAttribute ? "setAttribute" : "addAttribute";
914
+ function F(o, t, e, i) {
915
+ const r = o.map(
916
+ (n) => n.map(([a, s]) => {
917
+ if (i) {
918
+ const [l, u] = i([a, s]);
919
+ return [l, -u, t];
672
920
  }
673
- return e ? _e(a, i, t) : [a, i, t];
921
+ return e ? zt(a, s, t) : [a, s, t];
674
922
  })
675
923
  );
676
- return ue(r);
924
+ return ht(r);
677
925
  }
678
- function Fe(n, t, e, s, r) {
679
- const { vertices: o, holes: a } = F(
680
- n,
926
+ function Kt(o, t, e, i, r) {
927
+ const { vertices: n, holes: a } = F(
928
+ o,
681
929
  t,
682
- s,
930
+ i,
683
931
  r
684
- ), { vertices: i } = F(
685
- n,
932
+ ), { vertices: s } = F(
933
+ o,
686
934
  e,
687
- s,
935
+ i,
688
936
  r
689
- ), c = q([i, o]), u = Math.round(i.length / 3), m = new Set(a);
690
- let f = 0;
691
- const d = [];
692
- for (let p = 0; p < u; p++) {
693
- let h = p + 1;
694
- if (h === u)
695
- h = f;
696
- else if (m.has(h)) {
697
- const g = h;
698
- h = f, f = g;
937
+ ), l = Q([s, n]), u = Math.round(s.length / 3), f = new Set(a);
938
+ let p = 0;
939
+ const v = [];
940
+ for (let m = 0; m < u; m++) {
941
+ let d = m + 1;
942
+ if (d === u)
943
+ d = p;
944
+ else if (f.has(d)) {
945
+ const b = d;
946
+ d = p, p = b;
699
947
  }
700
- d.push(p, p + u, h + u), d.push(h + u, h, p);
948
+ v.push(m, m + u, d + u), v.push(d + u, d, m);
701
949
  }
702
- const l = [];
703
- for (let p = 1; p >= 0; p--)
704
- for (let h = 0; h < u; h += 1) l.push(h / (u - 1), p);
705
- return { indices: d, vertices: c, uvs: l, topVerts: i };
950
+ const c = [];
951
+ for (let m = 1; m >= 0; m--)
952
+ for (let d = 0; d < u; d += 1) c.push(d / (u - 1), m);
953
+ return { indices: v, vertices: l, uvs: c, topVerts: s };
706
954
  }
707
- function ae(n, t, e, s, r, o) {
955
+ function ut(o, t, e, i, r, n) {
708
956
  return {
709
- indices: s ? n.indices : n.indices.slice().reverse(),
957
+ indices: i ? o.indices : o.indices.slice().reverse(),
710
958
  vertices: F(
711
- [n.points],
959
+ [o.points],
712
960
  t,
713
961
  r,
714
- o
962
+ n
715
963
  ).vertices,
716
964
  uvs: e
717
965
  };
718
966
  }
719
- const Ze = ({
720
- polygonGeoJson: n,
967
+ const Xt = ({
968
+ polygonGeoJson: o,
721
969
  startHeight: t,
722
970
  endHeight: e,
723
- curvatureResolution: s = 1,
971
+ curvatureResolution: i = 1,
724
972
  cartesian: r = !0,
725
- hasSide: o = !0,
973
+ hasSide: n = !0,
726
974
  hasBottom: a = !1,
727
- hasTop: i = !1,
728
- projection: c,
975
+ hasTop: s = !1,
976
+ projection: l,
729
977
  bbox: u
730
978
  }) => {
731
- n.forEach((S) => {
732
- Ce(S) || S.reverse();
979
+ o.forEach((j) => {
980
+ Tt(j) || j.reverse();
733
981
  });
734
- const { contour: m, triangles: f } = Ge(n, {
735
- resolution: s,
982
+ const { contour: f, triangles: p } = Qt(o, {
983
+ resolution: i,
736
984
  bbox: u,
737
- projection: c
985
+ projection: l
738
986
  });
739
- let d = {}, l;
740
- o && (d = Fe(
741
- m,
987
+ let v = {}, c;
988
+ n && (v = Kt(
989
+ f,
742
990
  t != null ? t : e,
743
991
  e != null ? e : t,
744
992
  r,
745
- c
746
- ), l = d.topVerts);
747
- let p = [];
748
- (a || i) && (p = q(f.uvs));
749
- let h = {};
750
- a && (h = ae(
751
- f,
752
- t,
993
+ l
994
+ ), c = v.topVerts);
995
+ let m = [];
996
+ (a || s) && (m = Q(p.uvs));
997
+ let d = {};
998
+ a && (d = ut(
753
999
  p,
1000
+ t,
1001
+ m,
754
1002
  !1,
755
1003
  r,
756
- c
1004
+ l
757
1005
  ));
758
- let g = {};
759
- return i && (g = ae(
760
- f,
761
- e,
1006
+ let b = {};
1007
+ return s && (b = ut(
762
1008
  p,
1009
+ e,
1010
+ m,
763
1011
  !0,
764
1012
  r,
765
- c
766
- )), { contour: m, triangles: f, sideTorso: d, bottomCap: h, topCap: g, topVerts: l };
1013
+ l
1014
+ )), { contour: f, triangles: p, sideTorso: v, bottomCap: d, topCap: b, topVerts: c };
767
1015
  };
768
- class nt extends _.BufferGeometry {
1016
+ class ve extends h.BufferGeometry {
769
1017
  constructor(t, e = {}) {
770
- super(), this.type = "PolygonBufferGeometry", this.parameters = U({
1018
+ super(), this.type = "PolygonBufferGeometry", this.parameters = E({
771
1019
  polygonGeoJson: t,
772
1020
  startHeight: 0,
773
1021
  endHeight: 1,
@@ -780,36 +1028,38 @@ class nt extends _.BufferGeometry {
780
1028
  userDataRsoOffset: 0
781
1029
  }, e);
782
1030
  const {
783
- endHeight: s,
1031
+ endHeight: i,
784
1032
  hasTop: r,
785
- topFirst: o,
1033
+ topFirst: n,
786
1034
  hasBottom: a,
787
- hasSide: i,
788
- cartesian: c,
1035
+ hasSide: s,
1036
+ cartesian: l,
789
1037
  userDataRsoOffset: u,
790
- projection: m
791
- } = this.parameters, { contour: f, sideTorso: d, topVerts: l, bottomCap: p, topCap: h } = Ze(U({}, this.parameters));
792
- let g = [], S = [], z = [], W = 0;
793
- const w = (v) => {
794
- const b = Math.round(g.length / 3), P = z.length;
795
- g = g.concat(v.vertices), S = S.concat(v.uvs), z = z.concat(
796
- b ? v.indices.map((A) => A + b) : v.indices
797
- ), this.addGroup(P, z.length - P, W++);
1038
+ projection: f
1039
+ } = this.parameters, { contour: p, sideTorso: v, topVerts: c, bottomCap: m, topCap: d } = Xt(E({}, this.parameters));
1040
+ let b = [], j = [], z = [], I = 0;
1041
+ const P = (g) => {
1042
+ const w = Math.round(b.length / 3), A = z.length;
1043
+ b = b.concat(g.vertices), j = j.concat(g.uvs), z = z.concat(
1044
+ w ? g.indices.map((C) => C + w) : g.indices
1045
+ ), this.addGroup(A, z.length - A, I++);
798
1046
  };
799
- r && o && w(h), i && (w(d), this.userData.topVerts = u ? F(
800
- f,
801
- s + u,
802
- c,
803
- m
804
- ).vertices : l), a && w(p), r && !o && w(h), this.setIndex(z), this[oe](
1047
+ r && n && P(d), s && (P(v), this.userData.topVerts = u ? F(
1048
+ p,
1049
+ i + u,
1050
+ l,
1051
+ f
1052
+ ).vertices : c), a && P(m), r && !n && P(d), this.setIndex(z), this[lt](
805
1053
  "position",
806
- new _.Float32BufferAttribute(g, 3)
807
- ), this[oe]("uv", new _.Float32BufferAttribute(S, 2)), this.computeVertexNormals();
1054
+ new h.Float32BufferAttribute(b, 3)
1055
+ ), this[lt]("uv", new h.Float32BufferAttribute(j, 2)), this.computeVertexNormals();
808
1056
  }
809
1057
  }
810
1058
  export {
811
- tt as L,
812
- it as M,
813
- nt as P,
814
- Ze as g
1059
+ Gt as B,
1060
+ pe as G,
1061
+ de as L,
1062
+ me as M,
1063
+ ve as P,
1064
+ Xt as g
815
1065
  };