gl-draw 0.15.0-beta.9 → 0.15.0

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,47 +1,47 @@
1
- var At = Object.defineProperty, St = Object.defineProperties;
2
- var Ct = Object.getOwnPropertyDescriptors;
3
- var tt = Object.getOwnPropertySymbols;
4
- var zt = Object.prototype.hasOwnProperty, It = Object.prototype.propertyIsEnumerable;
5
- var it = Math.pow, et = (r, t, e) => t in r ? At(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, W = (r, t) => {
1
+ var jt = Object.defineProperty, At = Object.defineProperties;
2
+ var St = Object.getOwnPropertyDescriptors;
3
+ var J = Object.getOwnPropertySymbols;
4
+ var Ct = Object.prototype.hasOwnProperty, zt = Object.prototype.propertyIsEnumerable;
5
+ var et = Math.pow, tt = (a, t, e) => t in a ? jt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e, W = (a, t) => {
6
6
  for (var e in t || (t = {}))
7
- zt.call(t, e) && et(r, e, t[e]);
8
- if (tt)
9
- for (var e of tt(t))
10
- It.call(t, e) && et(r, e, t[e]);
11
- return r;
12
- }, $ = (r, t) => St(r, Ct(t));
13
- var st = (r, t, e) => new Promise((i, s) => {
14
- var a = (l) => {
7
+ Ct.call(t, e) && tt(a, e, t[e]);
8
+ if (J)
9
+ for (var e of J(t))
10
+ zt.call(t, e) && tt(a, e, t[e]);
11
+ return a;
12
+ }, N = (a, t) => At(a, St(t));
13
+ var it = (a, t, e) => new Promise((i, s) => {
14
+ var r = (o) => {
15
15
  try {
16
- n(e.next(l));
16
+ n(e.next(o));
17
17
  } catch (c) {
18
18
  s(c);
19
19
  }
20
- }, o = (l) => {
20
+ }, l = (o) => {
21
21
  try {
22
- n(e.throw(l));
22
+ n(e.throw(o));
23
23
  } catch (c) {
24
24
  s(c);
25
25
  }
26
- }, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(a, o);
27
- n((e = e.apply(r, t)).next());
26
+ }, n = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(r, l);
27
+ n((e = e.apply(a, t)).next());
28
28
  });
29
- import { BufferGeometry as H, Float32BufferAttribute as G, PointsMaterial as Tt, Points as K, Mesh as Mt, Group as Dt, Sprite as nt, Box3 as wt, Vector3 as C, InstancedMesh as rt, Quaternion as _t, Object3D as R, Material as at, Texture as ot, VideoTexture as Bt, Vector4 as O, Matrix4 as Lt, Line3 as Wt, Sphere as Ot, InstancedInterleavedBuffer as Vt, InterleavedBufferAttribute as lt, MathUtils as kt, ShaderMaterial as Ut, UniformsLib as Et, Color as ct, Vector2 as k, REVISION as Rt } from "three";
30
- import { CSS2DObject as Gt } from "three/examples/jsm/renderers/CSS2DRenderer";
31
- import { CSS3DObject as Ft, CSS3DSprite as Zt } from "three/examples/jsm/renderers/CSS3DRenderer";
32
- import { geoBounds as Pt, geoContains as $t, geoDistance as Nt, geoInterpolate as qt } from "d3-geo";
29
+ import { BufferGeometry as Y, Float32BufferAttribute as G, PointsMaterial as It, Points as K, Mesh as xt, Group as Dt, Sprite as st, Box3 as Mt, Vector3 as C, InstancedMesh as nt, Quaternion as Tt, Object3D as R, Material as rt, Texture as at, VideoTexture as _t, Vector4 as O, Matrix4 as Bt, Line3 as Lt, Sphere as Wt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as ot, MathUtils as Vt, ShaderMaterial as kt, UniformsLib as Ut, Color as lt, Vector2 as k, REVISION as Et } from "three";
30
+ import { CSS2DObject as Rt } from "three/examples/jsm/renderers/CSS2DRenderer";
31
+ import { CSS3DObject as Gt, CSS3DSprite as Ft } from "three/examples/jsm/renderers/CSS3DRenderer";
32
+ import { geoBounds as wt, geoContains as Zt, geoDistance as Nt, geoInterpolate as $t } from "d3-geo";
33
33
  import "d3-geo-projection";
34
- import { p as ut, a as Qt } from "./parseVector.module.js";
35
- import { LineSegmentsGeometry as Kt } from "three/examples/jsm/lines/LineSegmentsGeometry";
36
- import { merge as J, mean as Xt, extent as ht } from "d3-array";
37
- import Yt, { flatten as jt } from "earcut";
38
- import Ht from "@turf/boolean-clockwise";
39
- import Jt from "delaunator";
40
- import te from "@turf/boolean-point-in-polygon";
41
- import { geoVoronoi as ee } from "d3-geo-voronoi";
42
- import { scaleLinear as ft } from "d3-scale";
43
- const ie = (r, t = 1) => {
44
- const e = new H();
34
+ import { p as ct, a as qt } from "./parseVector.module.js";
35
+ import { LineSegmentsGeometry as Qt } from "three/examples/jsm/lines/LineSegmentsGeometry";
36
+ import { merge as H, mean as Kt, extent as ut } from "d3-array";
37
+ import Xt, { flatten as Pt } from "earcut";
38
+ import Yt from "@turf/boolean-clockwise";
39
+ import Ht from "delaunator";
40
+ import Jt from "@turf/boolean-point-in-polygon";
41
+ import { geoVoronoi as te } from "d3-geo-voronoi";
42
+ import { scaleLinear as ht } from "d3-scale";
43
+ const ee = (a, t = 1) => {
44
+ const e = new Y();
45
45
  e.setAttribute(
46
46
  "position",
47
47
  new G(new Array(t * 3).fill(0), 3)
@@ -49,7 +49,7 @@ const ie = (r, t = 1) => {
49
49
  "scaleAtt",
50
50
  new G(new Array(t).fill(1), 1)
51
51
  );
52
- const i = r.material, s = new Tt({
52
+ const i = a.material, s = new It({
53
53
  size: 10,
54
54
  map: i.map,
55
55
  alphaMap: i.alphaMap,
@@ -62,17 +62,17 @@ const ie = (r, t = 1) => {
62
62
  alphaTest: i.alphaTest,
63
63
  sizeAttenuation: !1
64
64
  });
65
- return s.onBeforeCompile = (a) => {
66
- a.vertexShader = `
65
+ return s.onBeforeCompile = (r) => {
66
+ r.vertexShader = `
67
67
  attribute float scaleAtt;
68
- ${a.vertexShader.replace(
68
+ ${r.vertexShader.replace(
69
69
  "gl_PointSize = size;",
70
70
  "gl_PointSize = size * scaleAtt;"
71
71
  )}
72
72
  `;
73
73
  }, new K(e, s);
74
74
  };
75
- class X {
75
+ class ft {
76
76
  constructor() {
77
77
  this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.materialList = {}, this.useMaterialType = "origin", this.onPointerIndex = [], this.disposeTrack = !0, this.disposeMaterialIfNotUsed = !0;
78
78
  }
@@ -129,7 +129,7 @@ class X {
129
129
  return this.object3d.visible = !1, this;
130
130
  }
131
131
  createMesh(...t) {
132
- return this.object3d = new Mt(...t), this;
132
+ return this.object3d = new xt(...t), this;
133
133
  }
134
134
  createGroup() {
135
135
  return this.object3d = new Dt(), this;
@@ -138,16 +138,16 @@ class X {
138
138
  return this.object3d = new K(...t), this;
139
139
  }
140
140
  createCSS2DObject(t) {
141
- return this.object3d = new Gt(t), this;
141
+ return this.object3d = new Rt(t), this;
142
142
  }
143
143
  createCSS3DObject(t) {
144
- return this.object3d = new Ft(t), this;
144
+ return this.object3d = new Gt(t), this;
145
145
  }
146
146
  createCSS3DSprite(t) {
147
- return this.object3d = new Zt(t), this;
147
+ return this.object3d = new Ft(t), this;
148
148
  }
149
149
  createSprite(t) {
150
- return this.object3d = new nt(t), this;
150
+ return this.object3d = new st(t), this;
151
151
  }
152
152
  attach(...t) {
153
153
  return [...t].forEach((e) => {
@@ -155,7 +155,7 @@ class X {
155
155
  }), this;
156
156
  }
157
157
  getSize() {
158
- const t = new wt().setFromObject(this.object3d);
158
+ const t = new Mt().setFromObject(this.object3d);
159
159
  return {
160
160
  min: t.min,
161
161
  max: t.max,
@@ -172,39 +172,35 @@ class X {
172
172
  return this.instantiate();
173
173
  }
174
174
  instantiate(t, e) {
175
- return st(this, null, function* () {
176
- var d;
177
- const i = t && t.length > 0, s = (d = e == null ? void 0 : e.recursive) != null ? d : !0, { objectType: a, objectOptions: o } = this, [, n] = a.split("#");
178
- let l = e == null ? void 0 : e.create;
179
- l === void 0 && (l = (u) => {
175
+ return it(this, null, function* () {
176
+ var p;
177
+ const i = t && t.length > 0, s = (p = e == null ? void 0 : e.recursive) != null ? p : !0, { objectType: r, objectOptions: l } = this, [, n] = r.split("#");
178
+ let o = e == null ? void 0 : e.create;
179
+ o === void 0 && (o = (u) => {
180
180
  if (this.object3d) {
181
181
  if (i) {
182
182
  const m = t.length;
183
- if (this.object3d instanceof nt)
184
- u.object3d = ie(this.object3d, m);
183
+ if (this.object3d instanceof st)
184
+ u.object3d = ee(this.object3d, m);
185
185
  else {
186
- const f = this.object3d;
187
- u.object3d = new rt(
188
- f.geometry,
189
- f.material,
190
- m
191
- ), u.setMaterialList("instantiate", "clone"), u.useMaterial("instantiate");
186
+ const f = this.object3d, d = this.cloneMaterial();
187
+ u.object3d = new nt(f.geometry, d, m);
192
188
  }
193
189
  const h = new R();
194
- t.forEach((f, p) => {
195
- const g = ut(f.position), w = ut(f.scale || [1, 1, 1]);
196
- h.position.copy(g), h.scale.copy(w), h.updateMatrix(), u.setInstancedMatrix(p, h.matrix.clone());
190
+ t.forEach((f, d) => {
191
+ const g = ct(f.position), w = ct(f.scale || [1, 1, 1]);
192
+ h.position.copy(g), h.scale.copy(w), h.updateMatrix(), u.setInstancedMatrix(d, h.matrix.clone());
197
193
  });
198
194
  } else
199
- u.object3d = this.object3d.clone(!1), u.setMaterialList("instantiate", "clone"), u.useMaterial("instantiate");
195
+ u.object3d = this.object3d.clone(!1), u.object3d.material && (u.object3d.material = this.cloneMaterial());
200
196
  u.object3d.userData.prefab && delete u.object3d.userData.prefab;
201
197
  }
202
198
  });
203
- const c = yield this.lead.draw(n, $(W({}, o || {}), {
204
- create: l,
199
+ const c = yield this.lead.draw(n, N(W({}, l || {}), {
200
+ create: o,
205
201
  prefab: !1,
206
- key: (e == null ? void 0 : e.key) || (o == null ? void 0 : o.key),
207
- target: (e == null ? void 0 : e.target) || (o == null ? void 0 : o.target)
202
+ key: (e == null ? void 0 : e.key) || (l == null ? void 0 : l.key),
203
+ target: (e == null ? void 0 : e.target) || (l == null ? void 0 : l.target)
208
204
  }));
209
205
  return this.isBloom && c.enableBloom(), s && (yield Promise.all(
210
206
  this.children.map(
@@ -216,11 +212,11 @@ class X {
216
212
  });
217
213
  }
218
214
  setInstancedMatrix(t, e) {
219
- if (this.object3d instanceof rt || this.object3d.isInstantiate)
215
+ if (this.object3d instanceof nt || this.object3d.isInstantiate)
220
216
  this.object3d.setMatrixAt(t, e);
221
217
  else if (this.object3d instanceof K || this.object3d.type === "Points") {
222
- const s = this.object3d.geometry, a = s.attributes.position.array, o = s.attributes.scaleAtt.array, n = new C(), l = new C(), c = new _t(), d = t * 3, u = t * 1;
223
- e.decompose(n, c, l), a[d] = n.x, a[d + 1] = n.y, a[d + 2] = n.z, o[u] = Math.max(l.x, l.y, l.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
218
+ const s = this.object3d.geometry, r = s.attributes.position.array, l = s.attributes.scaleAtt.array, n = new C(), o = new C(), c = new Tt(), p = t * 3, u = t * 1;
219
+ e.decompose(n, c, o), r[p] = n.x, r[p + 1] = n.y, r[p + 2] = n.z, l[u] = Math.max(o.x, o.y, o.z), s.attributes.position.needsUpdate = !0, s.attributes.scaleAtt.needsUpdate = !0;
224
220
  }
225
221
  }
226
222
  erase() {
@@ -235,8 +231,8 @@ class X {
235
231
  return e.map((i) => {
236
232
  const s = i.userData;
237
233
  i.userData = {};
238
- const a = i.clone();
239
- return i.userData = s, a;
234
+ const r = i.clone();
235
+ return i.userData = s, r;
240
236
  });
241
237
  {
242
238
  const i = e.userData;
@@ -249,19 +245,24 @@ class X {
249
245
  const s = this.object3d;
250
246
  if (!s || !s.material)
251
247
  return;
252
- if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t])
253
- if (i) {
254
- const o = this.materialList[t], n = new dt();
255
- n.track(o), n.dispose();
256
- } else
257
- return this.materialList[t];
258
- const a = e === "clone" ? this.cloneMaterial() : e;
259
- return this.materialList[t] = a, a;
248
+ if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t] && !i)
249
+ return this.materialList[t];
250
+ const r = e === "clone" ? this.cloneMaterial() : Array.isArray(e) ? e.slice() : e;
251
+ return this.materialList[t] = r, r;
260
252
  }
261
253
  useMaterial(t) {
262
254
  const e = this.object3d;
263
255
  !e || !e.material || this.useMaterialType === t || !this.materialList[t] || (this.useMaterialType = t, e.material = this.materialList[t]);
264
256
  }
257
+ useMList(t, e) {
258
+ if (!this.mList)
259
+ return;
260
+ const i = this.mList.get(t);
261
+ if (!i)
262
+ return;
263
+ const s = this.object3d;
264
+ Array.isArray(s.material) && e !== void 0 ? s.material[e] = i : s.material = i;
265
+ }
265
266
  setTop(t) {
266
267
  this.object3d && (this.object3d.renderOrder = t);
267
268
  }
@@ -281,13 +282,17 @@ class X {
281
282
  var t;
282
283
  if (this.onPointerIndex.forEach((e) => {
283
284
  this.lead.removePick(e);
284
- }), this.mList.rmBaseObjectMap(this, void 0, this.disposeMaterialIfNotUsed), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
285
- const e = new dt();
286
- e.disposeMaterial = !1, e.track(this), e.dispose();
285
+ }), this.pencil.options.mList && this.mList.rmBaseObjectMap(
286
+ this,
287
+ void 0,
288
+ this.disposeMaterialIfNotUsed
289
+ ), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
290
+ const e = new ie();
291
+ e.disposeMaterial = !this.pencil.options.mList, e.track(this), e.dispose();
287
292
  }
288
293
  }
289
294
  }
290
- class dt {
295
+ class ie {
291
296
  constructor() {
292
297
  this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
293
298
  }
@@ -296,32 +301,31 @@ class dt {
296
301
  return t;
297
302
  if (Array.isArray(t))
298
303
  return t.forEach((e) => this.track(e)), t;
299
- if (!this.disposeMaterial && t instanceof at)
304
+ if (!this.disposeMaterial && t instanceof rt)
300
305
  return t;
301
- if (t instanceof X ? (t.disposeTrack && t.object3d ? this.track(t.object3d) : this.resources.add(t), Object.values(t.materialList).map((e) => this.track(e))) : (t instanceof R || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof X)
306
+ if (t instanceof ft ? (t.disposeTrack && t.object3d ? this.track(t.object3d) : this.resources.add(t), Object.values(t.materialList).map((e) => this.track(e))) : (t instanceof R || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof ft)
302
307
  t.children.forEach((e) => {
303
308
  e.disposeTrack = !1;
304
309
  }), this.track(t.children);
305
310
  else if (t instanceof R) {
306
311
  const e = t;
307
312
  this.track(e.geometry), this.track(e.material), this.track(e.children);
308
- } else if (t instanceof at) {
313
+ } else if (t instanceof rt) {
309
314
  for (const i of Object.values(t))
310
- i instanceof ot && this.track(i);
315
+ i instanceof at && this.track(i);
311
316
  const e = t;
312
317
  if (e.uniforms) {
313
318
  for (const i of Object.values(e.uniforms))
314
319
  if (i) {
315
320
  const s = i.value;
316
- (s instanceof ot || Array.isArray(s)) && this.track(s);
321
+ (s instanceof at || Array.isArray(s)) && this.track(s);
317
322
  }
318
323
  }
319
- } else this.disposeVideo && t instanceof Bt && t.source.data && this.resources.add(t.source.data);
324
+ } else this.disposeVideo && t instanceof _t && t.source.data && this.resources.add(t.source.data);
320
325
  return t;
321
326
  }
322
327
  dispose() {
323
328
  const t = [];
324
- console.log("this.resources", this.resources);
325
329
  for (const e of this.resources)
326
330
  e instanceof R ? t.push(e) : e instanceof HTMLVideoElement && e.pause(), Reflect.has(e, "dispose") && e.dispose();
327
331
  t.forEach((e) => {
@@ -329,26 +333,21 @@ class dt {
329
333
  }), t.length = 0, this.resources.clear();
330
334
  }
331
335
  }
332
- class ze extends X {
333
- create() {
334
- this.createGroup();
335
- }
336
- }
337
- const N = new O(), pt = new C(), mt = new C(), b = new O(), y = new O(), T = new O(), q = new C(), Q = new Lt(), x = new Wt(), vt = new C(), U = new wt(), E = new Ot(), D = new O();
336
+ const $ = new O(), dt = new C(), pt = new C(), b = new O(), y = new O(), D = new O(), q = new C(), Q = new Bt(), x = new Lt(), mt = new C(), U = new Mt(), E = new Wt(), T = new O();
338
337
  let _, L;
339
- function gt(r, t, e) {
340
- return D.set(0, 0, -t, 1).applyMatrix4(r.projectionMatrix), D.multiplyScalar(1 / D.w), D.x = L / e.width, D.y = L / e.height, D.applyMatrix4(r.projectionMatrixInverse), D.multiplyScalar(1 / D.w), Math.abs(Math.max(D.x, D.y));
338
+ function vt(a, t, e) {
339
+ return T.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = L / e.width, T.y = L / e.height, T.applyMatrix4(a.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
341
340
  }
342
- function se(r, t) {
343
- const e = r.matrixWorld, i = r.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, o = Math.min(i.instanceCount, s.count);
344
- for (let n = 0, l = o; n < l; n++) {
345
- x.start.fromBufferAttribute(s, n), x.end.fromBufferAttribute(a, n), x.applyMatrix4(e);
346
- const c = new C(), d = new C();
347
- _.distanceSqToSegment(x.start, x.end, d, c), d.distanceTo(c) < L * 0.5 && t.push({
348
- point: d,
341
+ function se(a, t) {
342
+ const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, r = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
343
+ for (let n = 0, o = l; n < o; n++) {
344
+ x.start.fromBufferAttribute(s, n), x.end.fromBufferAttribute(r, n), x.applyMatrix4(e);
345
+ const c = new C(), p = new C();
346
+ _.distanceSqToSegment(x.start, x.end, p, c), p.distanceTo(c) < L * 0.5 && t.push({
347
+ point: p,
349
348
  pointOnLine: c,
350
- distance: _.origin.distanceTo(d),
351
- object: r,
349
+ distance: _.origin.distanceTo(p),
350
+ object: a,
352
351
  face: null,
353
352
  faceIndex: n,
354
353
  uv: null,
@@ -356,11 +355,11 @@ function se(r, t) {
356
355
  });
357
356
  }
358
357
  }
359
- function ne(r, t, e) {
360
- const i = t.projectionMatrix, a = r.material.resolution, o = r.matrixWorld, n = r.geometry, l = n.attributes.instanceStart, c = n.attributes.instanceEnd, d = Math.min(n.instanceCount, l.count), u = -t.near;
361
- _.at(1, T), T.w = 1, T.applyMatrix4(t.matrixWorldInverse), T.applyMatrix4(i), T.multiplyScalar(1 / T.w), T.x *= a.x / 2, T.y *= a.y / 2, T.z = 0, q.copy(T), Q.multiplyMatrices(t.matrixWorldInverse, o);
362
- for (let m = 0, h = d; m < h; m++) {
363
- if (b.fromBufferAttribute(l, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(Q), y.applyMatrix4(Q), b.z > u && y.z > u)
358
+ function ne(a, t, e) {
359
+ const i = t.projectionMatrix, r = a.material.resolution, l = a.matrixWorld, n = a.geometry, o = n.attributes.instanceStart, c = n.attributes.instanceEnd, p = Math.min(n.instanceCount, o.count), u = -t.near;
360
+ _.at(1, D), D.w = 1, D.applyMatrix4(t.matrixWorldInverse), D.applyMatrix4(i), D.multiplyScalar(1 / D.w), D.x *= r.x / 2, D.y *= r.y / 2, D.z = 0, q.copy(D), Q.multiplyMatrices(t.matrixWorldInverse, l);
361
+ for (let m = 0, h = p; m < h; m++) {
362
+ if (b.fromBufferAttribute(o, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(Q), y.applyMatrix4(Q), b.z > u && y.z > u)
364
363
  continue;
365
364
  if (b.z > u) {
366
365
  const I = b.z - y.z, P = (b.z - u) / I;
@@ -369,18 +368,18 @@ function ne(r, t, e) {
369
368
  const I = y.z - b.z, P = (y.z - u) / I;
370
369
  y.lerp(b, P);
371
370
  }
372
- b.applyMatrix4(i), y.applyMatrix4(i), b.multiplyScalar(1 / b.w), y.multiplyScalar(1 / y.w), b.x *= a.x / 2, b.y *= a.y / 2, y.x *= a.x / 2, y.y *= a.y / 2, x.start.copy(b), x.start.z = 0, x.end.copy(y), x.end.z = 0;
373
- const p = x.closestPointToPointParameter(q, !0);
374
- x.at(p, vt);
375
- const g = kt.lerp(b.z, y.z, p), w = g >= -1 && g <= 1, z = q.distanceTo(vt) < L * 0.5;
371
+ b.applyMatrix4(i), y.applyMatrix4(i), b.multiplyScalar(1 / b.w), y.multiplyScalar(1 / y.w), b.x *= r.x / 2, b.y *= r.y / 2, y.x *= r.x / 2, y.y *= r.y / 2, x.start.copy(b), x.start.z = 0, x.end.copy(y), x.end.z = 0;
372
+ const d = x.closestPointToPointParameter(q, !0);
373
+ x.at(d, mt);
374
+ const g = Vt.lerp(b.z, y.z, d), w = g >= -1 && g <= 1, z = q.distanceTo(mt) < L * 0.5;
376
375
  if (w && z) {
377
- x.start.fromBufferAttribute(l, m), x.end.fromBufferAttribute(c, m), x.start.applyMatrix4(o), x.end.applyMatrix4(o);
376
+ x.start.fromBufferAttribute(o, m), x.end.fromBufferAttribute(c, m), x.start.applyMatrix4(l), x.end.applyMatrix4(l);
378
377
  const I = new C(), P = new C();
379
378
  _.distanceSqToSegment(x.start, x.end, P, I), e.push({
380
379
  point: P,
381
380
  pointOnLine: I,
382
381
  distance: _.origin.distanceTo(P),
383
- object: r,
382
+ object: a,
384
383
  face: null,
385
384
  faceIndex: m,
386
385
  uv: null,
@@ -389,26 +388,26 @@ function ne(r, t, e) {
389
388
  }
390
389
  }
391
390
  }
392
- class Ie extends Mt {
393
- constructor(t = new Kt(), e) {
391
+ class ze extends xt {
392
+ constructor(t = new Qt(), e) {
394
393
  super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
395
394
  }
396
395
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
397
396
  computeLineDistances() {
398
397
  const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
399
- for (let o = 0, n = 0, l = e.count; o < l; o++, n += 2)
400
- pt.fromBufferAttribute(e, o), mt.fromBufferAttribute(i, o), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + pt.distanceTo(mt);
401
- const a = new Vt(
398
+ for (let l = 0, n = 0, o = e.count; l < o; l++, n += 2)
399
+ dt.fromBufferAttribute(e, l), pt.fromBufferAttribute(i, l), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + dt.distanceTo(pt);
400
+ const r = new Ot(
402
401
  s,
403
402
  2,
404
403
  1
405
404
  );
406
405
  return t.setAttribute(
407
406
  "instanceDistanceStart",
408
- new lt(a, 1, 0)
407
+ new ot(r, 1, 0)
409
408
  ), t.setAttribute(
410
409
  "instanceDistanceEnd",
411
- new lt(a, 1, 1)
410
+ new ot(r, 1, 1)
412
411
  ), this;
413
412
  }
414
413
  raycast(t, e) {
@@ -416,10 +415,10 @@ class Ie extends Mt {
416
415
  s === null && !i && console.error(
417
416
  'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
418
417
  );
419
- const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
418
+ const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
420
419
  _ = t.ray;
421
- const o = this.matrixWorld, n = this.geometry, l = this.material;
422
- L = l.linewidth + a, n.boundingSphere === null && n.computeBoundingSphere(), E.copy(n.boundingSphere).applyMatrix4(o);
420
+ const l = this.matrixWorld, n = this.geometry, o = this.material;
421
+ L = o.linewidth + r, n.boundingSphere === null && n.computeBoundingSphere(), E.copy(n.boundingSphere).applyMatrix4(l);
423
422
  let c;
424
423
  if (i)
425
424
  c = L * 0.5;
@@ -428,37 +427,37 @@ class Ie extends Mt {
428
427
  s.near,
429
428
  E.distanceToPoint(_.origin)
430
429
  );
431
- c = gt(
430
+ c = vt(
432
431
  s,
433
432
  u,
434
- l.resolution
433
+ o.resolution
435
434
  );
436
435
  }
437
436
  if (E.radius += c, _.intersectsSphere(E) === !1)
438
437
  return;
439
- n.boundingBox === null && n.computeBoundingBox(), U.copy(n.boundingBox).applyMatrix4(o);
440
- let d;
438
+ n.boundingBox === null && n.computeBoundingBox(), U.copy(n.boundingBox).applyMatrix4(l);
439
+ let p;
441
440
  if (i)
442
- d = L * 0.5;
441
+ p = L * 0.5;
443
442
  else {
444
443
  const u = Math.max(
445
444
  s.near,
446
445
  U.distanceToPoint(_.origin)
447
446
  );
448
- d = gt(
447
+ p = vt(
449
448
  s,
450
449
  u,
451
- l.resolution
450
+ o.resolution
452
451
  );
453
452
  }
454
- U.expandByScalar(d), _.intersectsBox(U) !== !1 && (i ? se(this, e) : ne(this, s, e));
453
+ U.expandByScalar(p), _.intersectsBox(U) !== !1 && (i ? se(this, e) : ne(this, s, e));
455
454
  }
456
455
  onBeforeRender(t) {
457
456
  const e = this.material.uniforms;
458
- e && e.resolution && (t.getViewport(N), this.material.uniforms.resolution.value.set(N.z, N.w));
457
+ e && e.resolution && (t.getViewport($), this.material.uniforms.resolution.value.set($.z, $.w));
459
458
  }
460
459
  }
461
- const bt = ["encodings_fragment", "colorspace_fragment"], re = (
460
+ const gt = ["encodings_fragment", "colorspace_fragment"], re = (
462
461
  /* glsl */
463
462
  `
464
463
  #include <common>
@@ -606,20 +605,20 @@ const bt = ["encodings_fragment", "colorspace_fragment"], re = (
606
605
 
607
606
  #include <fog_fragment>
608
607
  #include <tonemapping_fragment>
609
- #include <${+Rt < 154 ? bt[0] : bt[1]}>
608
+ #include <${+Et < 154 ? gt[0] : gt[1]}>
610
609
  }
611
610
  `
612
611
  );
613
- class Te extends Ut {
612
+ class Ie extends kt {
614
613
  constructor(t) {
615
614
  super({
616
- uniforms: $(W({}, Et.fog), {
615
+ uniforms: N(W({}, Ut.fog), {
617
616
  lineWidth: { value: 1 },
618
617
  map: { value: null },
619
618
  useMap: { value: 0 },
620
619
  alphaMap: { value: null },
621
620
  useAlphaMap: { value: 0 },
622
- color: { value: new ct(16777215) },
621
+ color: { value: new lt(16777215) },
623
622
  opacity: { value: 1 },
624
623
  resolution: { value: new k(1, 1) },
625
624
  sizeAttenuation: { value: 1 },
@@ -639,7 +638,7 @@ class Te extends Ut {
639
638
  speed: { value: 0.3 },
640
639
  lightWidth: { value: 0.1 },
641
640
  uCenter: { value: new k(0, 0) },
642
- lightColor: { value: new ct(16777215) }
641
+ lightColor: { value: new lt(16777215) }
643
642
  }),
644
643
  vertexShader: re,
645
644
  fragmentShader: ae
@@ -866,59 +865,59 @@ class Te extends Ut {
866
865
  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;
867
866
  }
868
867
  }
869
- function oe(r, t) {
870
- return r.map((e) => {
868
+ function oe(a, t) {
869
+ return a.map((e) => {
871
870
  const i = [];
872
871
  let s;
873
- return e.forEach((a) => {
872
+ return e.forEach((r) => {
874
873
  if (s) {
875
- const o = Nt(a, s) * 180 / Math.PI;
876
- if (o > t) {
877
- const n = qt(s, a), l = 1 / Math.ceil(o / t);
878
- let c = l;
874
+ const l = Nt(r, s) * 180 / Math.PI;
875
+ if (l > t) {
876
+ const n = $t(s, r), o = 1 / Math.ceil(l / t);
877
+ let c = o;
879
878
  for (; c < 1; )
880
- i.push(n(c)), c += l;
879
+ i.push(n(c)), c += o;
881
880
  }
882
881
  }
883
- i.push(s = a);
882
+ i.push(s = r);
884
883
  }), i;
885
884
  });
886
885
  }
887
- function le(r, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
888
- const a = Math.round(it(360 / r, 2) / Math.PI), o = (1 + Math.sqrt(5)) / 2, n = (h) => h / o * 360 % 360 - 180, l = (h) => Math.acos(2 * h / a - 1) / Math.PI * 180 - 90, c = (h) => a * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, d = [
886
+ function le(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
887
+ const r = Math.round(et(360 / a, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, n = (h) => h / l * 360 % 360 - 180, o = (h) => Math.acos(2 * h / r - 1) / Math.PI * 180 - 90, c = (h) => r * (Math.cos((h + 90) * Math.PI / 180) + 1) / 2, p = [
889
888
  s !== void 0 ? Math.ceil(c(s)) : 0,
890
- i !== void 0 ? Math.floor(c(i)) : a - 1
889
+ i !== void 0 ? Math.floor(c(i)) : r - 1
891
890
  ], u = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (h) => h <= e : e === void 0 ? (h) => h >= t : e >= t ? (h) => h >= t && h <= e : (h) => h >= t || h <= e, m = [];
892
- for (let h = d[0]; h <= d[1]; h++) {
891
+ for (let h = p[0]; h <= p[1]; h++) {
893
892
  const f = n(h);
894
- u(f) && m.push([f, l(h)]);
893
+ u(f) && m.push([f, o(h)]);
895
894
  }
896
895
  return m;
897
896
  }
898
- function Y(r, t, e = !1) {
899
- return e ? $t(t, r) : te(r, t);
897
+ function X(a, t, e = !1) {
898
+ return e ? Zt(t, a) : Jt(a, t);
900
899
  }
901
- function ce(r, t) {
902
- const e = { type: "Polygon", coordinates: r }, [[i, s], [a, o]] = Pt(e);
903
- if (Math.min(Math.abs(a - i), Math.abs(o - s)) < t)
900
+ function ce(a, t) {
901
+ const e = { type: "Polygon", coordinates: a }, [[i, s], [r, l]] = wt(e);
902
+ if (Math.min(Math.abs(r - i), Math.abs(l - s)) < t)
904
903
  return [];
905
- const n = i > a || o >= 89 || s <= -89;
904
+ const n = i > r || l >= 89 || s <= -89;
906
905
  return le(t, {
907
906
  minLng: i,
908
- maxLng: a,
907
+ maxLng: r,
909
908
  minLat: s,
910
- maxLat: o
909
+ maxLat: l
911
910
  }).filter(
912
- (l) => Y(l, e, n)
911
+ (o) => X(o, e, n)
913
912
  );
914
913
  }
915
- function ue(r, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
916
- const s = oe(r, t), a = J(s), o = ce(r, t), n = [...a, ...o], l = { type: "Polygon", coordinates: r }, [[c, d], [u, m]] = Pt(l), h = c > u || // crosses antimeridian
914
+ function ue(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
915
+ const s = oe(a, t), r = H(s), l = ce(a, t), n = [...r, ...l], o = { type: "Polygon", coordinates: a }, [[c, p], [u, m]] = wt(o), h = c > u || // crosses antimeridian
917
916
  m >= 89 || // crosses north pole
918
- d <= -89;
917
+ p <= -89;
919
918
  let f = [];
920
919
  if (h) {
921
- const v = ee(n).triangles(), M = new Map(
920
+ const v = te(n).triangles(), M = new Map(
922
921
  n.map(([j, A], B) => [`${j}-${A}`, B])
923
922
  );
924
923
  v.features.forEach((j) => {
@@ -927,11 +926,11 @@ function ue(r, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
927
926
  const V = `${S}-${Z}`;
928
927
  M.has(V) && B.push(M.get(V));
929
928
  }), B.length === 3) {
930
- if (B.some((S) => S < a.length)) {
929
+ if (B.some((S) => S < r.length)) {
931
930
  const S = j.properties.circumcenter;
932
- if (!Y(
931
+ if (!X(
933
932
  S,
934
- l,
933
+ o,
935
934
  h
936
935
  ))
937
936
  return;
@@ -939,17 +938,17 @@ function ue(r, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
939
938
  f.push(...B);
940
939
  }
941
940
  });
942
- } else if (o.length) {
943
- const v = Jt.from(n);
941
+ } else if (l.length) {
942
+ const v = Ht.from(n);
944
943
  for (let M = 0, j = v.triangles.length; M < j; M += 3) {
945
944
  const A = [2, 1, 0].map((S) => v.triangles[M + S]), B = A.map((S) => n[S]);
946
- if (A.some((S) => S < a.length)) {
945
+ if (A.some((S) => S < r.length)) {
947
946
  const S = [0, 1].map(
948
- (Z) => Xt(B, (V) => V[Z])
947
+ (Z) => Kt(B, (V) => V[Z])
949
948
  );
950
- if (!Y(
949
+ if (!X(
951
950
  S,
952
- l,
951
+ o,
953
952
  h
954
953
  ))
955
954
  continue;
@@ -957,15 +956,15 @@ function ue(r, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
957
956
  f.push(...A);
958
957
  }
959
958
  } else {
960
- const { vertices: v, holes: M = [] } = jt(s);
961
- f = Yt(v, M, 2);
959
+ const { vertices: v, holes: M = [] } = Pt(s);
960
+ f = Xt(v, M, 2);
962
961
  }
963
- let p = e ? [e[0], e[2]] : ht(n, (v) => v[0]), g = e ? [e[1], e[3]] : ht(n, (v) => v[1]);
962
+ let d = e ? [e[0], e[2]] : ut(n, (v) => v[0]), g = e ? [e[1], e[3]] : ut(n, (v) => v[1]);
964
963
  if (i) {
965
- const [v, M] = i([p[0], g[0]]), [j, A] = i([p[1], g[1]]);
966
- p = [v, j], g = [-M, -A];
964
+ const [v, M] = i([d[0], g[0]]), [j, A] = i([d[1], g[1]]);
965
+ d = [v, j], g = [-M, -A];
967
966
  }
968
- const w = ft(p, [0, 1]), z = ft(g, [0, 1]), I = n.map(([v, M]) => {
967
+ const w = ht(d, [0, 1]), z = ht(g, [0, 1]), I = n.map(([v, M]) => {
969
968
  if (i) {
970
969
  const [j, A] = i([v, M]);
971
970
  return [w(j), z(-A)];
@@ -974,110 +973,110 @@ function ue(r, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
974
973
  });
975
974
  return { contour: s, triangles: { points: n, indices: f, uvs: I } };
976
975
  }
977
- const yt = new H().setAttribute ? "setAttribute" : "addAttribute";
978
- function F(r, t, e, i) {
979
- const s = r.map(
980
- (a) => a.map(([o, n]) => {
976
+ const bt = new Y().setAttribute ? "setAttribute" : "addAttribute";
977
+ function F(a, t, e, i) {
978
+ const s = a.map(
979
+ (r) => r.map(([l, n]) => {
981
980
  if (i) {
982
- const [l, c] = i([o, n]);
983
- return [l, -c, t];
981
+ const [o, c] = i([l, n]);
982
+ return [o, -c, t];
984
983
  }
985
- return e ? Qt(o, n, t) : [o, n, t];
984
+ return e ? qt(l, n, t) : [l, n, t];
986
985
  })
987
986
  );
988
- return jt(s);
987
+ return Pt(s);
989
988
  }
990
- function he(r, t, e, i, s) {
991
- const { vertices: a, holes: o } = F(
992
- r,
989
+ function he(a, t, e, i, s) {
990
+ const { vertices: r, holes: l } = F(
991
+ a,
993
992
  t,
994
993
  i,
995
994
  s
996
995
  ), { vertices: n } = F(
997
- r,
996
+ a,
998
997
  e,
999
998
  i,
1000
999
  s
1001
- ), l = J([n, a]), c = Math.round(n.length / 3), d = new Set(o);
1000
+ ), o = H([n, r]), c = Math.round(n.length / 3), p = new Set(l);
1002
1001
  let u = 0;
1003
1002
  const m = [];
1004
1003
  for (let f = 0; f < c; f++) {
1005
- let p = f + 1;
1006
- if (p === c)
1007
- p = u;
1008
- else if (d.has(p)) {
1009
- const g = p;
1010
- p = u, u = g;
1004
+ let d = f + 1;
1005
+ if (d === c)
1006
+ d = u;
1007
+ else if (p.has(d)) {
1008
+ const g = d;
1009
+ d = u, u = g;
1011
1010
  }
1012
- m.push(f, f + c, p + c), m.push(p + c, p, f);
1011
+ m.push(f, f + c, d + c), m.push(d + c, d, f);
1013
1012
  }
1014
1013
  const h = [];
1015
1014
  for (let f = 1; f >= 0; f--)
1016
- for (let p = 0; p < c; p += 1) h.push(p / (c - 1), f);
1017
- return { indices: m, vertices: l, uvs: h, topVerts: n };
1015
+ for (let d = 0; d < c; d += 1) h.push(d / (c - 1), f);
1016
+ return { indices: m, vertices: o, uvs: h, topVerts: n };
1018
1017
  }
1019
- function xt(r, t, e, i, s, a) {
1018
+ function yt(a, t, e, i, s, r) {
1020
1019
  return {
1021
- indices: i ? r.indices : r.indices.slice().reverse(),
1020
+ indices: i ? a.indices : a.indices.slice().reverse(),
1022
1021
  vertices: F(
1023
- [r.points],
1022
+ [a.points],
1024
1023
  t,
1025
1024
  s,
1026
- a
1025
+ r
1027
1026
  ).vertices,
1028
1027
  uvs: e
1029
1028
  };
1030
1029
  }
1031
1030
  const fe = ({
1032
- polygonGeoJson: r,
1031
+ polygonGeoJson: a,
1033
1032
  startHeight: t,
1034
1033
  endHeight: e,
1035
1034
  curvatureResolution: i = 1,
1036
1035
  cartesian: s = !0,
1037
- hasSide: a = !0,
1038
- hasBottom: o = !1,
1036
+ hasSide: r = !0,
1037
+ hasBottom: l = !1,
1039
1038
  hasTop: n = !1,
1040
- projection: l,
1039
+ projection: o,
1041
1040
  bbox: c
1042
1041
  }) => {
1043
- r.forEach((w) => {
1044
- Ht(w) || w.reverse();
1042
+ a.forEach((w) => {
1043
+ Yt(w) || w.reverse();
1045
1044
  });
1046
- const { contour: d, triangles: u } = ue(r, {
1045
+ const { contour: p, triangles: u } = ue(a, {
1047
1046
  resolution: i,
1048
1047
  bbox: c,
1049
- projection: l
1048
+ projection: o
1050
1049
  });
1051
1050
  let m = {}, h;
1052
- a && (m = he(
1053
- d,
1051
+ r && (m = he(
1052
+ p,
1054
1053
  t != null ? t : e,
1055
1054
  e != null ? e : t,
1056
1055
  s,
1057
- l
1056
+ o
1058
1057
  ), h = m.topVerts);
1059
1058
  let f = [];
1060
- (o || n) && (f = J(u.uvs));
1061
- let p = {};
1062
- o && (p = xt(
1059
+ (l || n) && (f = H(u.uvs));
1060
+ let d = {};
1061
+ l && (d = yt(
1063
1062
  u,
1064
1063
  t,
1065
1064
  f,
1066
1065
  !1,
1067
1066
  s,
1068
- l
1067
+ o
1069
1068
  ));
1070
1069
  let g = {};
1071
- return n && (g = xt(
1070
+ return n && (g = yt(
1072
1071
  u,
1073
1072
  e,
1074
1073
  f,
1075
1074
  !0,
1076
1075
  s,
1077
- l
1078
- )), { contour: d, triangles: u, sideTorso: m, bottomCap: p, topCap: g, topVerts: h };
1076
+ o
1077
+ )), { contour: p, triangles: u, sideTorso: m, bottomCap: d, topCap: g, topVerts: h };
1079
1078
  };
1080
- class De extends H {
1079
+ class De extends Y {
1081
1080
  constructor(t, e = {}) {
1082
1081
  super(), this.type = "PolygonBufferGeometry", this.parameters = W({
1083
1082
  polygonGeoJson: t,
@@ -1094,13 +1093,13 @@ class De extends H {
1094
1093
  const {
1095
1094
  endHeight: i,
1096
1095
  hasTop: s,
1097
- topFirst: a,
1098
- hasBottom: o,
1096
+ topFirst: r,
1097
+ hasBottom: l,
1099
1098
  hasSide: n,
1100
- cartesian: l,
1099
+ cartesian: o,
1101
1100
  userDataRsoOffset: c,
1102
- projection: d
1103
- } = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: p } = fe(W({}, this.parameters));
1101
+ projection: p
1102
+ } = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: d } = fe(W({}, this.parameters));
1104
1103
  let g = [], w = [], z = [], I = 0;
1105
1104
  const P = (v) => {
1106
1105
  const M = Math.round(g.length / 3), j = z.length;
@@ -1108,20 +1107,19 @@ class De extends H {
1108
1107
  M ? v.indices.map((A) => A + M) : v.indices
1109
1108
  ), this.addGroup(j, z.length - j, I++);
1110
1109
  };
1111
- s && a && P(p), n && (P(m), this.userData.topVerts = c ? F(
1110
+ s && r && P(d), n && (P(m), this.userData.topVerts = c ? F(
1112
1111
  u,
1113
1112
  i + c,
1114
- l,
1115
- d
1116
- ).vertices : h), o && P(f), s && !a && P(p), this.setIndex(z), this[yt]("position", new G(g, 3)), this[yt]("uv", new G(w, 2)), this.computeVertexNormals();
1113
+ o,
1114
+ p
1115
+ ).vertices : h), l && P(f), s && !r && P(d), this.setIndex(z), this[bt]("position", new G(g, 3)), this[bt]("uv", new G(w, 2)), this.computeVertexNormals();
1117
1116
  }
1118
1117
  }
1119
1118
  export {
1120
- X as B,
1121
- ze as G,
1122
- Ie as L,
1123
- Te as M,
1119
+ ft as B,
1120
+ ze as L,
1121
+ Ie as M,
1124
1122
  De as P,
1125
- dt as R,
1123
+ ie as R,
1126
1124
  fe as g
1127
1125
  };