gl-draw 0.15.16 → 0.15.17

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.
@@ -6,9 +6,9 @@ import type { PickFunctionsItem } from "./Lead/Pick";
6
6
  export { CSS3DObject, CSS3DSprite, } from 'three/examples/jsm/renderers/CSS3DRenderer';
7
7
  export { CSS2DObject } from 'three/examples/jsm/renderers/CSS2DRenderer';
8
8
  export default class BaseObject {
9
+ key: string;
9
10
  objectType: string;
10
11
  objectOptions?: Record<string, any>;
11
- key: string;
12
12
  pencil: Pencil;
13
13
  lead: Lead;
14
14
  mList: MList;
@@ -46,18 +46,18 @@ export default class BaseObject {
46
46
  size: Vector3;
47
47
  center: Vector3;
48
48
  };
49
+ setTop(onTop: number): void;
49
50
  traverse(fn: (o: IBaseObject) => void): void;
50
- clone(): Promise<this>;
51
- instantiate(meta?: {
52
- position: Vector3 | number[] | [number, number, number];
53
- scale?: Vector3 | number[] | [number, number, number];
54
- }[], ops?: {
51
+ instantiate(ops?: {
55
52
  key?: string;
56
53
  target?: IBaseObject;
57
54
  create?: ((...args: any[]) => any) | boolean;
58
55
  recursive?: boolean;
56
+ instancedAttr?: {
57
+ position: Vector3 | number[] | [number, number, number];
58
+ scale?: Vector3 | number[] | [number, number, number];
59
+ }[];
59
60
  }): Promise<this>;
60
- private setInstancedMatrix;
61
61
  erase(): void;
62
62
  cloneMaterial(): Material | Material[] | undefined;
63
63
  materialList: Record<string, Material | Material[]>;
@@ -66,7 +66,6 @@ export default class BaseObject {
66
66
  useMaterial(name: string): void;
67
67
  useMListById(id: string, slot?: number): void;
68
68
  useMListByName(name: string, slot?: number): void;
69
- setTop(onTop: number): void;
70
69
  private onPointerIndex;
71
70
  onPointerEvent(type: PickFunctionsItem['type'], cb: PickFunctionsItem['cb']): void;
72
71
  enableBloom(): void;
@@ -1,47 +1,47 @@
1
- var Pt = Object.defineProperty, At = Object.defineProperties;
1
+ var At = Object.defineProperty, jt = Object.defineProperties;
2
2
  var St = Object.getOwnPropertyDescriptors;
3
3
  var J = Object.getOwnPropertySymbols;
4
4
  var Ct = Object.prototype.hasOwnProperty, It = Object.prototype.propertyIsEnumerable;
5
- var et = Math.pow, tt = (a, t, e) => t in a ? Pt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e, W = (a, t) => {
5
+ var et = Math.pow, tt = (r, t, e) => t in r ? At(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, W = (r, t) => {
6
6
  for (var e in t || (t = {}))
7
- Ct.call(t, e) && tt(a, e, t[e]);
7
+ Ct.call(t, e) && tt(r, e, t[e]);
8
8
  if (J)
9
9
  for (var e of J(t))
10
- It.call(t, e) && tt(a, e, t[e]);
11
- return a;
12
- }, Z = (a, t) => At(a, St(t));
13
- var it = (a, t, e) => new Promise((i, s) => {
14
- var r = (o) => {
10
+ It.call(t, e) && tt(r, e, t[e]);
11
+ return r;
12
+ }, Z = (r, t) => jt(r, St(t));
13
+ var it = (r, t, e) => new Promise((i, s) => {
14
+ var a = (l) => {
15
15
  try {
16
- n(e.next(o));
17
- } catch (c) {
18
- s(c);
16
+ n(e.next(l));
17
+ } catch (o) {
18
+ s(o);
19
19
  }
20
- }, l = (o) => {
20
+ }, c = (l) => {
21
21
  try {
22
- n(e.throw(o));
23
- } catch (c) {
24
- s(c);
22
+ n(e.throw(l));
23
+ } catch (o) {
24
+ s(o);
25
25
  }
26
- }, n = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(r, l);
27
- n((e = e.apply(a, t)).next());
26
+ }, n = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(a, c);
27
+ n((e = e.apply(r, t)).next());
28
28
  });
29
- import { BufferGeometry as X, Float32BufferAttribute as G, PointsMaterial as zt, Points as Q, Mesh as Mt, Group as Bt, Sprite as st, Box3 as xt, Vector3 as C, InstancedMesh as nt, Quaternion as Dt, Object3D as U, Material as rt, Texture as at, VideoTexture as Lt, Vector4 as O, Matrix4 as _t, Line3 as Tt, Sphere as Wt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as ot, MathUtils as Et, ShaderMaterial as Vt, UniformsLib as kt, Color as lt, Vector2 as V, REVISION as Rt } from "three";
29
+ import { BufferGeometry as H, Float32BufferAttribute as G, PointsMaterial as zt, Points as X, Object3D as U, InstancedMesh as bt, Vector3 as S, Quaternion as Bt, Mesh as Mt, Group as Dt, Sprite as st, Box3 as xt, Material as nt, Texture as rt, VideoTexture as Lt, Vector4 as O, Matrix4 as _t, Line3 as Tt, Sphere as Wt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as at, MathUtils as Et, ShaderMaterial as Vt, UniformsLib as kt, Color as ot, Vector2 as V, REVISION as Rt } from "three";
30
30
  import { CSS2DObject as Ut } from "three/examples/jsm/renderers/CSS2DRenderer";
31
31
  import { CSS3DObject as Gt, CSS3DSprite as Nt } from "three/examples/jsm/renderers/CSS3DRenderer";
32
32
  import { geoBounds as wt, geoContains as Ft, geoDistance as Zt, geoInterpolate as $t } from "d3-geo";
33
33
  import "d3-geo-projection";
34
- import { p as ct, a as qt } from "./parseVector.module.js";
34
+ import { p as lt, a as qt } from "./parseVector.module.js";
35
35
  import { LineSegmentsGeometry as Kt } from "three/examples/jsm/lines/LineSegmentsGeometry";
36
- import { merge as Y, mean as Qt, extent as ut } from "d3-array";
37
- import Ht, { flatten as jt } from "earcut";
36
+ import { merge as Y, mean as Qt, extent as ct } from "d3-array";
37
+ import Ht, { flatten as Pt } from "earcut";
38
38
  import Xt from "@turf/boolean-clockwise";
39
39
  import Yt from "delaunator";
40
40
  import Jt from "@turf/boolean-point-in-polygon";
41
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 X();
42
+ import { scaleLinear as ut } from "d3-scale";
43
+ const ee = (r, t = 1) => {
44
+ const e = new H();
45
45
  e.setAttribute(
46
46
  "position",
47
47
  new G(new Array(t * 3).fill(0), 3)
@@ -49,7 +49,7 @@ const ee = (a, t = 1) => {
49
49
  "scaleAtt",
50
50
  new G(new Array(t).fill(1), 1)
51
51
  );
52
- const i = a.material, s = new zt({
52
+ const i = r.material, s = new zt({
53
53
  size: 10,
54
54
  map: i.map,
55
55
  alphaMap: i.alphaMap,
@@ -62,17 +62,30 @@ const ee = (a, t = 1) => {
62
62
  alphaTest: i.alphaTest,
63
63
  sizeAttenuation: !1
64
64
  });
65
- return s.onBeforeCompile = (r) => {
66
- r.vertexShader = `
65
+ return s.onBeforeCompile = (a) => {
66
+ a.vertexShader = `
67
67
  attribute float scaleAtt;
68
- ${r.vertexShader.replace(
68
+ ${a.vertexShader.replace(
69
69
  "gl_PointSize = size;",
70
70
  "gl_PointSize = size * scaleAtt;"
71
71
  )}
72
72
  `;
73
- }, new Q(e, s);
74
- }, ie = 0, Be = 1, se = 2, De = !1;
75
- class ft {
73
+ }, new X(e, s);
74
+ }, ie = (r, t) => {
75
+ const e = new U();
76
+ t.forEach((i, s) => {
77
+ const a = lt(i.position), c = lt(i.scale || [1, 1, 1]);
78
+ e.position.copy(a), e.scale.copy(c), e.updateMatrix();
79
+ const n = e.matrix.clone();
80
+ if (r instanceof bt || r.isInstantiate)
81
+ r.setMatrixAt(s, n);
82
+ else if (r instanceof X || r.type === "Points") {
83
+ const o = r.geometry, d = o.attributes.position.array, h = o.attributes.scaleAtt.array, p = new S(), u = new S(), m = new Bt(), f = s * 3, g = s * 1;
84
+ n.decompose(p, m, u), d[f] = p.x, d[f + 1] = p.y, d[f + 2] = p.z, h[g] = Math.max(u.x, u.y, u.z), o.attributes.position.needsUpdate = !0, o.attributes.scaleAtt.needsUpdate = !0;
85
+ }
86
+ });
87
+ }, se = 0, De = 1, ne = 2, Le = !1;
88
+ class ht {
76
89
  constructor() {
77
90
  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
91
  }
@@ -129,19 +142,19 @@ class ft {
129
142
  resize(t, e) {
130
143
  }
131
144
  show() {
132
- return this.object3d.visible = !0, this.object3d.layers.set(ie), this;
145
+ return this.object3d.visible = !0, this.object3d.layers.set(se), this;
133
146
  }
134
147
  hide() {
135
- return this.object3d.visible = !1, this.object3d.layers.set(se), this;
148
+ return this.object3d.visible = !1, this.object3d.layers.set(ne), this;
136
149
  }
137
150
  createMesh(...t) {
138
151
  return this.object3d = new Mt(...t), this;
139
152
  }
140
153
  createGroup() {
141
- return this.object3d = new Bt(), this;
154
+ return this.object3d = new Dt(), this;
142
155
  }
143
156
  createPoints(...t) {
144
- return this.object3d = new Q(...t), this;
157
+ return this.object3d = new X(...t), this;
145
158
  }
146
159
  createCSS2DObject(t) {
147
160
  return this.object3d = new Ut(t), this;
@@ -165,66 +178,55 @@ class ft {
165
178
  return {
166
179
  min: t.min,
167
180
  max: t.max,
168
- size: t.getSize(new C()),
169
- center: t.getCenter(new C())
181
+ size: t.getSize(new S()),
182
+ center: t.getCenter(new S())
170
183
  };
171
184
  }
185
+ setTop(t) {
186
+ this.object3d && (this.object3d.renderOrder = t);
187
+ }
172
188
  traverse(t) {
173
189
  t(this), this.children.forEach((e) => {
174
190
  e.traverse(t);
175
191
  });
176
192
  }
177
- clone() {
178
- return this.instantiate();
179
- }
180
- instantiate(t, e) {
193
+ instantiate(t) {
181
194
  return it(this, null, function* () {
182
- var p;
183
- 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("#");
184
- let o = e == null ? void 0 : e.create;
185
- o === void 0 && (o = (u) => {
195
+ var l;
196
+ const e = (l = t == null ? void 0 : t.recursive) != null ? l : !0, { objectType: i, objectOptions: s } = this, [, a] = i.split("#");
197
+ let c = t == null ? void 0 : t.create;
198
+ c === void 0 && (c = (o) => {
199
+ var d;
186
200
  if (this.object3d) {
187
- if (i) {
188
- const m = t.length;
201
+ if ((d = t == null ? void 0 : t.instancedAttr) != null && d.length) {
202
+ const h = t.instancedAttr.length;
189
203
  if (this.object3d instanceof st)
190
- u.object3d = ee(this.object3d, m);
204
+ o.object3d = ee(this.object3d, h);
191
205
  else {
192
- const f = this.object3d, d = this.cloneMaterial();
193
- u.object3d = new nt(f.geometry, d, m);
206
+ const p = this.object3d, u = this.cloneMaterial();
207
+ o.object3d = new bt(p.geometry, u, h);
194
208
  }
195
- const h = new U();
196
- t.forEach((f, d) => {
197
- const g = ct(f.position), w = ct(f.scale || [1, 1, 1]);
198
- h.position.copy(g), h.scale.copy(w), h.updateMatrix(), u.setInstancedMatrix(d, h.matrix.clone());
199
- });
209
+ ie(o.object3d, t == null ? void 0 : t.instancedAttr);
200
210
  } else
201
- u.object3d = this.object3d.clone(!1), u.object3d.material && (u.object3d.material = this.cloneMaterial());
202
- u.object3d.userData.prefab && delete u.object3d.userData.prefab;
211
+ o.object3d = this.object3d.clone(!1), o.object3d.material && (o.object3d.material = this.cloneMaterial());
212
+ o.object3d.userData.prefab && delete o.object3d.userData.prefab;
203
213
  }
204
214
  });
205
- const c = yield this.lead.draw(n, Z(W({}, l || {}), {
206
- create: o,
215
+ const n = yield this.lead.draw(a, Z(W({}, s || {}), {
216
+ create: c,
207
217
  prefab: !1,
208
- key: (e == null ? void 0 : e.key) || (l == null ? void 0 : l.key),
209
- target: (e == null ? void 0 : e.target) || (l == null ? void 0 : l.target)
218
+ key: (t == null ? void 0 : t.key) || (s == null ? void 0 : s.key),
219
+ target: (t == null ? void 0 : t.target) || (s == null ? void 0 : s.target)
210
220
  }));
211
- return this.isBloom && c.enableBloom(), s && (yield Promise.all(
221
+ return this.isBloom && n.enableBloom(), e && (yield Promise.all(
212
222
  this.children.map(
213
- (u) => u.instantiate(void 0, {
214
- target: c
223
+ (o) => o.instantiate({
224
+ target: n
215
225
  })
216
226
  )
217
- )), c.isInstantiate = !0, c;
227
+ )), n.isInstantiate = !0, n;
218
228
  });
219
229
  }
220
- setInstancedMatrix(t, e) {
221
- if (this.object3d instanceof nt || this.object3d.isInstantiate)
222
- this.object3d.setMatrixAt(t, e);
223
- else if (this.object3d instanceof Q || this.object3d.type === "Points") {
224
- const s = this.object3d.geometry, r = s.attributes.position.array, l = s.attributes.scaleAtt.array, n = new C(), o = new C(), c = new Dt(), p = t * 3, u = t * 1;
225
- 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;
226
- }
227
- }
228
230
  erase() {
229
231
  this.lead.erase(this);
230
232
  }
@@ -237,8 +239,8 @@ class ft {
237
239
  return e.map((i) => {
238
240
  const s = i.userData;
239
241
  i.userData = {};
240
- const r = i.clone();
241
- return i.userData = s, r;
242
+ const a = i.clone();
243
+ return i.userData = s, a;
242
244
  });
243
245
  {
244
246
  const i = e.userData;
@@ -253,8 +255,8 @@ class ft {
253
255
  return;
254
256
  if (this.materialList.origin || (this.materialList.origin = s.material), this.materialList[t] && !i)
255
257
  return this.materialList[t];
256
- const r = e === "clone" ? this.cloneMaterial() : Array.isArray(e) ? e.slice() : e;
257
- return this.materialList[t] = r, r;
258
+ const a = e === "clone" ? this.cloneMaterial() : Array.isArray(e) ? e.slice() : e;
259
+ return this.materialList[t] = a, a;
258
260
  }
259
261
  useMaterial(t) {
260
262
  const e = this.object3d;
@@ -275,9 +277,6 @@ class ft {
275
277
  const i = this.mList.getKeyByName(t);
276
278
  i && this.useMListById(i, e);
277
279
  }
278
- setTop(t) {
279
- this.object3d && (this.object3d.renderOrder = t);
280
- }
281
280
  onPointerEvent(t, e) {
282
281
  const i = this.lead.handlePick([this], t, e);
283
282
  this.onPointerIndex.push(i);
@@ -299,12 +298,12 @@ class ft {
299
298
  void 0,
300
299
  this.disposeMaterialIfNotUsed
301
300
  ), (t = this.pencil.composerController) == null || t.bloomSelection.delete(this), this.lead && (this.lead.objects.delete(this.key), this.lead.objectWrapChindIdMap.delete(this), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack) {
302
- const e = new ne();
301
+ const e = new re();
303
302
  e.disposeMaterial = !this.pencil.options.mList, e.track(this), e.dispose();
304
303
  }
305
304
  }
306
305
  }
307
- class ne {
306
+ class re {
308
307
  constructor() {
309
308
  this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
310
309
  }
@@ -313,24 +312,24 @@ class ne {
313
312
  return t;
314
313
  if (Array.isArray(t))
315
314
  return t.forEach((e) => this.track(e)), t;
316
- if (!this.disposeMaterial && t instanceof rt)
315
+ if (!this.disposeMaterial && t instanceof nt)
317
316
  return t;
318
- 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 U || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof ft)
317
+ if (t instanceof ht ? (t.disposeTrack && t.object3d ? this.track(t.object3d) : this.resources.add(t), Object.values(t.materialList).map((e) => this.track(e))) : (t instanceof U || Reflect.has(t, "dispose")) && this.resources.add(t), t instanceof ht)
319
318
  t.children.forEach((e) => {
320
319
  e.disposeTrack = !1;
321
320
  }), this.track(t.children);
322
321
  else if (t instanceof U) {
323
322
  const e = t;
324
323
  this.track(e.geometry), this.track(e.material), this.track(e.children);
325
- } else if (t instanceof rt) {
324
+ } else if (t instanceof nt) {
326
325
  for (const i of Object.values(t))
327
- i instanceof at && this.track(i);
326
+ i instanceof rt && this.track(i);
328
327
  const e = t;
329
328
  if (e.uniforms) {
330
329
  for (const i of Object.values(e.uniforms))
331
330
  if (i) {
332
331
  const s = i.value;
333
- (s instanceof at || Array.isArray(s)) && this.track(s);
332
+ (s instanceof rt || Array.isArray(s)) && this.track(s);
334
333
  }
335
334
  }
336
335
  } else this.disposeVideo && t instanceof Lt && t.source.data && this.resources.add(t.source.data);
@@ -345,21 +344,21 @@ class ne {
345
344
  }), t.length = 0, this.resources.clear();
346
345
  }
347
346
  }
348
- const $ = new O(), dt = new C(), pt = new C(), b = new O(), y = new O(), B = new O(), q = new C(), K = new _t(), M = new Tt(), mt = new C(), k = new xt(), R = new Wt(), D = new O();
347
+ const $ = new O(), ft = new S(), dt = new S(), y = new O(), b = new O(), B = new O(), q = new S(), K = new _t(), M = new Tt(), pt = new S(), k = new xt(), R = new Wt(), D = new O();
349
348
  let L, T;
350
- function vt(a, t, e) {
351
- return D.set(0, 0, -t, 1).applyMatrix4(a.projectionMatrix), D.multiplyScalar(1 / D.w), D.x = T / e.width, D.y = T / e.height, D.applyMatrix4(a.projectionMatrixInverse), D.multiplyScalar(1 / D.w), Math.abs(Math.max(D.x, D.y));
349
+ function mt(r, t, e) {
350
+ return D.set(0, 0, -t, 1).applyMatrix4(r.projectionMatrix), D.multiplyScalar(1 / D.w), D.x = T / e.width, D.y = T / e.height, D.applyMatrix4(r.projectionMatrixInverse), D.multiplyScalar(1 / D.w), Math.abs(Math.max(D.x, D.y));
352
351
  }
353
- function re(a, t) {
354
- const e = a.matrixWorld, i = a.geometry, s = i.attributes.instanceStart, r = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
355
- for (let n = 0, o = l; n < o; n++) {
356
- M.start.fromBufferAttribute(s, n), M.end.fromBufferAttribute(r, n), M.applyMatrix4(e);
357
- const c = new C(), p = new C();
358
- L.distanceSqToSegment(M.start, M.end, p, c), p.distanceTo(c) < T * 0.5 && t.push({
359
- point: p,
360
- pointOnLine: c,
361
- distance: L.origin.distanceTo(p),
362
- object: a,
352
+ function ae(r, t) {
353
+ const e = r.matrixWorld, i = r.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
354
+ for (let n = 0, l = c; n < l; n++) {
355
+ M.start.fromBufferAttribute(s, n), M.end.fromBufferAttribute(a, n), M.applyMatrix4(e);
356
+ const o = new S(), d = new S();
357
+ L.distanceSqToSegment(M.start, M.end, d, o), d.distanceTo(o) < T * 0.5 && t.push({
358
+ point: d,
359
+ pointOnLine: o,
360
+ distance: L.origin.distanceTo(d),
361
+ object: r,
363
362
  face: null,
364
363
  faceIndex: n,
365
364
  uv: null,
@@ -367,59 +366,59 @@ function re(a, t) {
367
366
  });
368
367
  }
369
368
  }
370
- function ae(a, t, e) {
371
- 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;
372
- L.at(1, B), B.w = 1, B.applyMatrix4(t.matrixWorldInverse), B.applyMatrix4(i), B.multiplyScalar(1 / B.w), B.x *= r.x / 2, B.y *= r.y / 2, B.z = 0, q.copy(B), K.multiplyMatrices(t.matrixWorldInverse, l);
373
- for (let m = 0, h = p; m < h; m++) {
374
- if (b.fromBufferAttribute(o, m), y.fromBufferAttribute(c, m), b.w = 1, y.w = 1, b.applyMatrix4(K), y.applyMatrix4(K), b.z > u && y.z > u)
369
+ function oe(r, t, e) {
370
+ const i = t.projectionMatrix, a = r.material.resolution, c = r.matrixWorld, n = r.geometry, l = n.attributes.instanceStart, o = n.attributes.instanceEnd, d = Math.min(n.instanceCount, l.count), h = -t.near;
371
+ L.at(1, B), B.w = 1, B.applyMatrix4(t.matrixWorldInverse), B.applyMatrix4(i), B.multiplyScalar(1 / B.w), B.x *= a.x / 2, B.y *= a.y / 2, B.z = 0, q.copy(B), K.multiplyMatrices(t.matrixWorldInverse, c);
372
+ for (let p = 0, u = d; p < u; p++) {
373
+ if (y.fromBufferAttribute(l, p), b.fromBufferAttribute(o, p), y.w = 1, b.w = 1, y.applyMatrix4(K), b.applyMatrix4(K), y.z > h && b.z > h)
375
374
  continue;
376
- if (b.z > u) {
377
- const z = b.z - y.z, j = (b.z - u) / z;
378
- b.lerp(y, j);
379
- } else if (y.z > u) {
380
- const z = y.z - b.z, j = (y.z - u) / z;
381
- y.lerp(b, j);
375
+ if (y.z > h) {
376
+ const z = y.z - b.z, w = (y.z - h) / z;
377
+ y.lerp(b, w);
378
+ } else if (b.z > h) {
379
+ const z = b.z - y.z, w = (b.z - h) / z;
380
+ b.lerp(y, w);
382
381
  }
383
- 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, M.start.copy(b), M.start.z = 0, M.end.copy(y), M.end.z = 0;
384
- const d = M.closestPointToPointParameter(q, !0);
385
- M.at(d, mt);
386
- const g = Et.lerp(b.z, y.z, d), w = g >= -1 && g <= 1, I = q.distanceTo(mt) < T * 0.5;
387
- if (w && I) {
388
- M.start.fromBufferAttribute(o, m), M.end.fromBufferAttribute(c, m), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
389
- const z = new C(), j = new C();
390
- L.distanceSqToSegment(M.start, M.end, j, z), e.push({
391
- point: j,
382
+ y.applyMatrix4(i), b.applyMatrix4(i), y.multiplyScalar(1 / y.w), b.multiplyScalar(1 / b.w), y.x *= a.x / 2, y.y *= a.y / 2, b.x *= a.x / 2, b.y *= a.y / 2, M.start.copy(y), M.start.z = 0, M.end.copy(b), M.end.z = 0;
383
+ const f = M.closestPointToPointParameter(q, !0);
384
+ M.at(f, pt);
385
+ const g = Et.lerp(y.z, b.z, f), C = g >= -1 && g <= 1, I = q.distanceTo(pt) < T * 0.5;
386
+ if (C && I) {
387
+ M.start.fromBufferAttribute(l, p), M.end.fromBufferAttribute(o, p), M.start.applyMatrix4(c), M.end.applyMatrix4(c);
388
+ const z = new S(), w = new S();
389
+ L.distanceSqToSegment(M.start, M.end, w, z), e.push({
390
+ point: w,
392
391
  pointOnLine: z,
393
- distance: L.origin.distanceTo(j),
394
- object: a,
392
+ distance: L.origin.distanceTo(w),
393
+ object: r,
395
394
  face: null,
396
- faceIndex: m,
395
+ faceIndex: p,
397
396
  uv: null,
398
397
  uv1: null
399
398
  });
400
399
  }
401
400
  }
402
401
  }
403
- class Le extends Mt {
402
+ class _e extends Mt {
404
403
  constructor(t = new Kt(), e) {
405
404
  super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
406
405
  }
407
406
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
408
407
  computeLineDistances() {
409
408
  const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
410
- for (let l = 0, n = 0, o = e.count; l < o; l++, n += 2)
411
- dt.fromBufferAttribute(e, l), pt.fromBufferAttribute(i, l), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + dt.distanceTo(pt);
412
- const r = new Ot(
409
+ for (let c = 0, n = 0, l = e.count; c < l; c++, n += 2)
410
+ ft.fromBufferAttribute(e, c), dt.fromBufferAttribute(i, c), s[n] = n === 0 ? 0 : s[n - 1], s[n + 1] = s[n] + ft.distanceTo(dt);
411
+ const a = new Ot(
413
412
  s,
414
413
  2,
415
414
  1
416
415
  );
417
416
  return t.setAttribute(
418
417
  "instanceDistanceStart",
419
- new ot(r, 1, 0)
418
+ new at(a, 1, 0)
420
419
  ), t.setAttribute(
421
420
  "instanceDistanceEnd",
422
- new ot(r, 1, 1)
421
+ new at(a, 1, 1)
423
422
  ), this;
424
423
  }
425
424
  raycast(t, e) {
@@ -427,49 +426,49 @@ class Le extends Mt {
427
426
  s === null && !i && console.error(
428
427
  'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
429
428
  );
430
- const r = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
429
+ const a = t.params.Line2 !== void 0 && t.params.Line2.threshold || 0;
431
430
  L = t.ray;
432
- const l = this.matrixWorld, n = this.geometry, o = this.material;
433
- T = o.linewidth + r, n.boundingSphere === null && n.computeBoundingSphere(), R.copy(n.boundingSphere).applyMatrix4(l);
434
- let c;
431
+ const c = this.matrixWorld, n = this.geometry, l = this.material;
432
+ T = l.linewidth + a, n.boundingSphere === null && n.computeBoundingSphere(), R.copy(n.boundingSphere).applyMatrix4(c);
433
+ let o;
435
434
  if (i)
436
- c = T * 0.5;
435
+ o = T * 0.5;
437
436
  else {
438
- const u = Math.max(
437
+ const h = Math.max(
439
438
  s.near,
440
439
  R.distanceToPoint(L.origin)
441
440
  );
442
- c = vt(
441
+ o = mt(
443
442
  s,
444
- u,
445
- o.resolution
443
+ h,
444
+ l.resolution
446
445
  );
447
446
  }
448
- if (R.radius += c, L.intersectsSphere(R) === !1)
447
+ if (R.radius += o, L.intersectsSphere(R) === !1)
449
448
  return;
450
- n.boundingBox === null && n.computeBoundingBox(), k.copy(n.boundingBox).applyMatrix4(l);
451
- let p;
449
+ n.boundingBox === null && n.computeBoundingBox(), k.copy(n.boundingBox).applyMatrix4(c);
450
+ let d;
452
451
  if (i)
453
- p = T * 0.5;
452
+ d = T * 0.5;
454
453
  else {
455
- const u = Math.max(
454
+ const h = Math.max(
456
455
  s.near,
457
456
  k.distanceToPoint(L.origin)
458
457
  );
459
- p = vt(
458
+ d = mt(
460
459
  s,
461
- u,
462
- o.resolution
460
+ h,
461
+ l.resolution
463
462
  );
464
463
  }
465
- k.expandByScalar(p), L.intersectsBox(k) !== !1 && (i ? re(this, e) : ae(this, s, e));
464
+ k.expandByScalar(d), L.intersectsBox(k) !== !1 && (i ? ae(this, e) : oe(this, s, e));
466
465
  }
467
466
  onBeforeRender(t) {
468
467
  const e = this.material.uniforms;
469
468
  e && e.resolution && (t.getViewport($), this.material.uniforms.resolution.value.set($.z, $.w));
470
469
  }
471
470
  }
472
- const gt = ["encodings_fragment", "colorspace_fragment"], oe = (
471
+ const vt = ["encodings_fragment", "colorspace_fragment"], le = (
473
472
  /* glsl */
474
473
  `
475
474
  #include <common>
@@ -565,7 +564,7 @@ const gt = ["encodings_fragment", "colorspace_fragment"], oe = (
565
564
  #include <fog_vertex>
566
565
  }
567
566
  `
568
- ), le = (
567
+ ), ce = (
569
568
  /* glsl */
570
569
  `
571
570
  #include <packing>
@@ -617,11 +616,11 @@ const gt = ["encodings_fragment", "colorspace_fragment"], oe = (
617
616
 
618
617
  #include <fog_fragment>
619
618
  #include <tonemapping_fragment>
620
- #include <${+Rt < 154 ? gt[0] : gt[1]}>
619
+ #include <${+Rt < 154 ? vt[0] : vt[1]}>
621
620
  }
622
621
  `
623
622
  );
624
- class _e extends Vt {
623
+ class Te extends Vt {
625
624
  constructor(t) {
626
625
  super({
627
626
  uniforms: Z(W({}, kt.fog), {
@@ -630,7 +629,7 @@ class _e extends Vt {
630
629
  useMap: { value: 0 },
631
630
  alphaMap: { value: null },
632
631
  useAlphaMap: { value: 0 },
633
- color: { value: new lt(16777215) },
632
+ color: { value: new ot(16777215) },
634
633
  opacity: { value: 1 },
635
634
  resolution: { value: new V(1, 1) },
636
635
  sizeAttenuation: { value: 1 },
@@ -650,10 +649,10 @@ class _e extends Vt {
650
649
  speed: { value: 0.3 },
651
650
  lightWidth: { value: 0.1 },
652
651
  uCenter: { value: new V(0, 0) },
653
- lightColor: { value: new lt(16777215) }
652
+ lightColor: { value: new ot(16777215) }
654
653
  }),
655
- vertexShader: oe,
656
- fragmentShader: le
654
+ vertexShader: le,
655
+ fragmentShader: ce
657
656
  }), this.type = "MeshLineMaterial", Object.defineProperties(this, {
658
657
  lineWidth: {
659
658
  enumerable: !0,
@@ -877,218 +876,218 @@ class _e extends Vt {
877
876
  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;
878
877
  }
879
878
  }
880
- function ce(a, t) {
881
- return a.map((e) => {
879
+ function ue(r, t) {
880
+ return r.map((e) => {
882
881
  const i = [];
883
882
  let s;
884
- return e.forEach((r) => {
883
+ return e.forEach((a) => {
885
884
  if (s) {
886
- const l = Zt(r, s) * 180 / Math.PI;
887
- if (l > t) {
888
- const n = $t(s, r), o = 1 / Math.ceil(l / t);
889
- let c = o;
890
- for (; c < 1; )
891
- i.push(n(c)), c += o;
885
+ const c = Zt(a, s) * 180 / Math.PI;
886
+ if (c > t) {
887
+ const n = $t(s, a), l = 1 / Math.ceil(c / t);
888
+ let o = l;
889
+ for (; o < 1; )
890
+ i.push(n(o)), o += l;
892
891
  }
893
892
  }
894
- i.push(s = r);
893
+ i.push(s = a);
895
894
  }), i;
896
895
  });
897
896
  }
898
- function ue(a, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
899
- 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 = [
900
- s !== void 0 ? Math.ceil(c(s)) : 0,
901
- i !== void 0 ? Math.floor(c(i)) : r - 1
902
- ], 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 = [];
903
- for (let h = p[0]; h <= p[1]; h++) {
904
- const f = n(h);
905
- u(f) && m.push([f, o(h)]);
897
+ function he(r, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
898
+ const a = Math.round(et(360 / r, 2) / Math.PI), c = (1 + Math.sqrt(5)) / 2, n = (u) => u / c * 360 % 360 - 180, l = (u) => Math.acos(2 * u / a - 1) / Math.PI * 180 - 90, o = (u) => a * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, d = [
899
+ s !== void 0 ? Math.ceil(o(s)) : 0,
900
+ i !== void 0 ? Math.floor(o(i)) : a - 1
901
+ ], h = t === void 0 && e === void 0 ? () => !0 : t === void 0 ? (u) => u <= e : e === void 0 ? (u) => u >= t : e >= t ? (u) => u >= t && u <= e : (u) => u >= t || u <= e, p = [];
902
+ for (let u = d[0]; u <= d[1]; u++) {
903
+ const m = n(u);
904
+ h(m) && p.push([m, l(u)]);
906
905
  }
907
- return m;
906
+ return p;
908
907
  }
909
- function H(a, t, e = !1) {
910
- return e ? Ft(t, a) : Jt(a, t);
908
+ function Q(r, t, e = !1) {
909
+ return e ? Ft(t, r) : Jt(r, t);
911
910
  }
912
- function he(a, t) {
913
- const e = { type: "Polygon", coordinates: a }, [[i, s], [r, l]] = wt(e);
914
- if (Math.min(Math.abs(r - i), Math.abs(l - s)) < t)
911
+ function fe(r, t) {
912
+ const e = { type: "Polygon", coordinates: r }, [[i, s], [a, c]] = wt(e);
913
+ if (Math.min(Math.abs(a - i), Math.abs(c - s)) < t)
915
914
  return [];
916
- const n = i > r || l >= 89 || s <= -89;
917
- return ue(t, {
915
+ const n = i > a || c >= 89 || s <= -89;
916
+ return he(t, {
918
917
  minLng: i,
919
- maxLng: r,
918
+ maxLng: a,
920
919
  minLat: s,
921
- maxLat: l
920
+ maxLat: c
922
921
  }).filter(
923
- (o) => H(o, e, n)
922
+ (l) => Q(l, e, n)
924
923
  );
925
924
  }
926
- function fe(a, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
927
- const s = ce(a, t), r = Y(s), l = he(a, t), n = [...r, ...l], o = { type: "Polygon", coordinates: a }, [[c, p], [u, m]] = wt(o), h = c > u || // crosses antimeridian
928
- m >= 89 || // crosses north pole
929
- p <= -89;
930
- let f = [];
931
- if (h) {
925
+ function de(r, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
926
+ const s = ue(r, t), a = Y(s), c = fe(r, t), n = [...a, ...c], l = { type: "Polygon", coordinates: r }, [[o, d], [h, p]] = wt(l), u = o > h || // crosses antimeridian
927
+ p >= 89 || // crosses north pole
928
+ d <= -89;
929
+ let m = [];
930
+ if (u) {
932
931
  const v = te(n).triangles(), x = new Map(
933
932
  n.map(([P, A], _) => [`${P}-${A}`, _])
934
933
  );
935
934
  v.features.forEach((P) => {
936
935
  const A = P.geometry.coordinates[0].slice(0, 3).reverse(), _ = [];
937
- if (A.forEach(([S, F]) => {
938
- const E = `${S}-${F}`;
936
+ if (A.forEach(([j, F]) => {
937
+ const E = `${j}-${F}`;
939
938
  x.has(E) && _.push(x.get(E));
940
939
  }), _.length === 3) {
941
- if (_.some((S) => S < r.length)) {
942
- const S = P.properties.circumcenter;
943
- if (!H(
944
- S,
945
- o,
946
- h
940
+ if (_.some((j) => j < a.length)) {
941
+ const j = P.properties.circumcenter;
942
+ if (!Q(
943
+ j,
944
+ l,
945
+ u
947
946
  ))
948
947
  return;
949
948
  }
950
- f.push(..._);
949
+ m.push(..._);
951
950
  }
952
951
  });
953
- } else if (l.length) {
952
+ } else if (c.length) {
954
953
  const v = Yt.from(n);
955
954
  for (let x = 0, P = v.triangles.length; x < P; x += 3) {
956
- const A = [2, 1, 0].map((S) => v.triangles[x + S]), _ = A.map((S) => n[S]);
957
- if (A.some((S) => S < r.length)) {
958
- const S = [0, 1].map(
955
+ const A = [2, 1, 0].map((j) => v.triangles[x + j]), _ = A.map((j) => n[j]);
956
+ if (A.some((j) => j < a.length)) {
957
+ const j = [0, 1].map(
959
958
  (F) => Qt(_, (E) => E[F])
960
959
  );
961
- if (!H(
962
- S,
963
- o,
964
- h
960
+ if (!Q(
961
+ j,
962
+ l,
963
+ u
965
964
  ))
966
965
  continue;
967
966
  }
968
- f.push(...A);
967
+ m.push(...A);
969
968
  }
970
969
  } else {
971
- const { vertices: v, holes: x = [] } = jt(s);
972
- f = Ht(v, x, 2);
970
+ const { vertices: v, holes: x = [] } = Pt(s);
971
+ m = Ht(v, x, 2);
973
972
  }
974
- let d = e ? [e[0], e[2]] : ut(n, (v) => v[0]), g = e ? [e[1], e[3]] : ut(n, (v) => v[1]);
973
+ let f = e ? [e[0], e[2]] : ct(n, (v) => v[0]), g = e ? [e[1], e[3]] : ct(n, (v) => v[1]);
975
974
  if (i) {
976
- const [v, x] = i([d[0], g[0]]), [P, A] = i([d[1], g[1]]);
977
- d = [v, P], g = [-x, -A];
975
+ const [v, x] = i([f[0], g[0]]), [P, A] = i([f[1], g[1]]);
976
+ f = [v, P], g = [-x, -A];
978
977
  }
979
- const w = ht(d, [0, 1]), I = ht(g, [0, 1]), z = n.map(([v, x]) => {
978
+ const C = ut(f, [0, 1]), I = ut(g, [0, 1]), z = n.map(([v, x]) => {
980
979
  if (i) {
981
980
  const [P, A] = i([v, x]);
982
- return [w(P), I(-A)];
981
+ return [C(P), I(-A)];
983
982
  } else
984
- return [w(v), I(x)];
983
+ return [C(v), I(x)];
985
984
  });
986
- return { contour: s, triangles: { points: n, indices: f, uvs: z } };
985
+ return { contour: s, triangles: { points: n, indices: m, uvs: z } };
987
986
  }
988
- const bt = new X().setAttribute ? "setAttribute" : "addAttribute";
989
- function N(a, t, e, i) {
990
- const s = a.map(
991
- (r) => r.map(([l, n]) => {
987
+ const gt = new H().setAttribute ? "setAttribute" : "addAttribute";
988
+ function N(r, t, e, i) {
989
+ const s = r.map(
990
+ (a) => a.map(([c, n]) => {
992
991
  if (i) {
993
- const [o, c] = i([l, n]);
994
- return [o, -c, t];
992
+ const [l, o] = i([c, n]);
993
+ return [l, -o, t];
995
994
  }
996
- return e ? qt(l, n, t) : [l, n, t];
995
+ return e ? qt(c, n, t) : [c, n, t];
997
996
  })
998
997
  );
999
- return jt(s);
998
+ return Pt(s);
1000
999
  }
1001
- function de(a, t, e, i, s) {
1002
- const { vertices: r, holes: l } = N(
1003
- a,
1000
+ function pe(r, t, e, i, s) {
1001
+ const { vertices: a, holes: c } = N(
1002
+ r,
1004
1003
  t,
1005
1004
  i,
1006
1005
  s
1007
1006
  ), { vertices: n } = N(
1008
- a,
1007
+ r,
1009
1008
  e,
1010
1009
  i,
1011
1010
  s
1012
- ), o = Y([n, r]), c = Math.round(n.length / 3), p = new Set(l);
1013
- let u = 0;
1014
- const m = [];
1015
- for (let f = 0; f < c; f++) {
1016
- let d = f + 1;
1017
- if (d === c)
1018
- d = u;
1019
- else if (p.has(d)) {
1020
- const g = d;
1021
- d = u, u = g;
1011
+ ), l = Y([n, a]), o = Math.round(n.length / 3), d = new Set(c);
1012
+ let h = 0;
1013
+ const p = [];
1014
+ for (let m = 0; m < o; m++) {
1015
+ let f = m + 1;
1016
+ if (f === o)
1017
+ f = h;
1018
+ else if (d.has(f)) {
1019
+ const g = f;
1020
+ f = h, h = g;
1022
1021
  }
1023
- m.push(f, f + c, d + c), m.push(d + c, d, f);
1022
+ p.push(m, m + o, f + o), p.push(f + o, f, m);
1024
1023
  }
1025
- const h = [];
1026
- for (let f = 1; f >= 0; f--)
1027
- for (let d = 0; d < c; d += 1) h.push(d / (c - 1), f);
1028
- return { indices: m, vertices: o, uvs: h, topVerts: n };
1024
+ const u = [];
1025
+ for (let m = 1; m >= 0; m--)
1026
+ for (let f = 0; f < o; f += 1) u.push(f / (o - 1), m);
1027
+ return { indices: p, vertices: l, uvs: u, topVerts: n };
1029
1028
  }
1030
- function yt(a, t, e, i, s, r) {
1029
+ function yt(r, t, e, i, s, a) {
1031
1030
  return {
1032
- indices: i ? a.indices : a.indices.slice().reverse(),
1031
+ indices: i ? r.indices : r.indices.slice().reverse(),
1033
1032
  vertices: N(
1034
- [a.points],
1033
+ [r.points],
1035
1034
  t,
1036
1035
  s,
1037
- r
1036
+ a
1038
1037
  ).vertices,
1039
1038
  uvs: e
1040
1039
  };
1041
1040
  }
1042
- const pe = ({
1043
- polygonGeoJson: a,
1041
+ const me = ({
1042
+ polygonGeoJson: r,
1044
1043
  startHeight: t,
1045
1044
  endHeight: e,
1046
1045
  curvatureResolution: i = 1,
1047
1046
  cartesian: s = !0,
1048
- hasSide: r = !0,
1049
- hasBottom: l = !1,
1047
+ hasSide: a = !0,
1048
+ hasBottom: c = !1,
1050
1049
  hasTop: n = !1,
1051
- projection: o,
1052
- bbox: c
1050
+ projection: l,
1051
+ bbox: o
1053
1052
  }) => {
1054
- a.forEach((w) => {
1055
- Xt(w) || w.reverse();
1053
+ r.forEach((C) => {
1054
+ Xt(C) || C.reverse();
1056
1055
  });
1057
- const { contour: p, triangles: u } = fe(a, {
1056
+ const { contour: d, triangles: h } = de(r, {
1058
1057
  resolution: i,
1059
- bbox: c,
1060
- projection: o
1058
+ bbox: o,
1059
+ projection: l
1061
1060
  });
1062
- let m = {}, h;
1063
- r && (m = de(
1064
- p,
1061
+ let p = {}, u;
1062
+ a && (p = pe(
1063
+ d,
1065
1064
  t != null ? t : e,
1066
1065
  e != null ? e : t,
1067
1066
  s,
1068
- o
1069
- ), h = m.topVerts);
1070
- let f = [];
1071
- (l || n) && (f = Y(u.uvs));
1072
- let d = {};
1073
- l && (d = yt(
1074
- u,
1067
+ l
1068
+ ), u = p.topVerts);
1069
+ let m = [];
1070
+ (c || n) && (m = Y(h.uvs));
1071
+ let f = {};
1072
+ c && (f = yt(
1073
+ h,
1075
1074
  t,
1076
- f,
1075
+ m,
1077
1076
  !1,
1078
1077
  s,
1079
- o
1078
+ l
1080
1079
  ));
1081
1080
  let g = {};
1082
1081
  return n && (g = yt(
1083
- u,
1082
+ h,
1084
1083
  e,
1085
- f,
1084
+ m,
1086
1085
  !0,
1087
1086
  s,
1088
- o
1089
- )), { contour: p, triangles: u, sideTorso: m, bottomCap: d, topCap: g, topVerts: h };
1087
+ l
1088
+ )), { contour: d, triangles: h, sideTorso: p, bottomCap: f, topCap: g, topVerts: u };
1090
1089
  };
1091
- class Te extends X {
1090
+ class We extends H {
1092
1091
  constructor(t, e = {}) {
1093
1092
  super(), this.type = "PolygonBufferGeometry", this.parameters = W({
1094
1093
  polygonGeoJson: t,
@@ -1105,35 +1104,35 @@ class Te extends X {
1105
1104
  const {
1106
1105
  endHeight: i,
1107
1106
  hasTop: s,
1108
- topFirst: r,
1109
- hasBottom: l,
1107
+ topFirst: a,
1108
+ hasBottom: c,
1110
1109
  hasSide: n,
1111
- cartesian: o,
1112
- userDataRsoOffset: c,
1113
- projection: p
1114
- } = this.parameters, { contour: u, sideTorso: m, topVerts: h, bottomCap: f, topCap: d } = pe(W({}, this.parameters));
1115
- let g = [], w = [], I = [], z = 0;
1116
- const j = (v) => {
1110
+ cartesian: l,
1111
+ userDataRsoOffset: o,
1112
+ projection: d
1113
+ } = this.parameters, { contour: h, sideTorso: p, topVerts: u, bottomCap: m, topCap: f } = me(W({}, this.parameters));
1114
+ let g = [], C = [], I = [], z = 0;
1115
+ const w = (v) => {
1117
1116
  const x = Math.round(g.length / 3), P = I.length;
1118
- g = g.concat(v.vertices), w = w.concat(v.uvs), I = I.concat(
1117
+ g = g.concat(v.vertices), C = C.concat(v.uvs), I = I.concat(
1119
1118
  x ? v.indices.map((A) => A + x) : v.indices
1120
1119
  ), this.addGroup(P, I.length - P, z++);
1121
1120
  };
1122
- s && r && j(d), n && (j(m), this.userData.topVerts = c ? N(
1123
- u,
1124
- i + c,
1125
- o,
1126
- p
1127
- ).vertices : h), l && j(f), s && !r && j(d), this.setIndex(I), this[bt]("position", new G(g, 3)), this[bt]("uv", new G(w, 2)), this.computeVertexNormals();
1121
+ s && a && w(f), n && (w(p), this.userData.topVerts = o ? N(
1122
+ h,
1123
+ i + o,
1124
+ l,
1125
+ d
1126
+ ).vertices : u), c && w(m), s && !a && w(f), this.setIndex(I), this[gt]("position", new G(g, 3)), this[gt]("uv", new G(C, 2)), this.computeVertexNormals();
1128
1127
  }
1129
1128
  }
1130
1129
  export {
1131
- Be as B,
1132
- De as I,
1133
- Le as L,
1134
- _e as M,
1135
- Te as P,
1136
- ne as R,
1137
- ft as a,
1138
- pe as g
1130
+ De as B,
1131
+ Le as I,
1132
+ _e as L,
1133
+ Te as M,
1134
+ We as P,
1135
+ re as R,
1136
+ ht as a,
1137
+ me as g
1139
1138
  };
package/dist/index2.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var fe=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var J=Math.pow,Y=(o,e,t)=>e in o?fe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,O=(o,e)=>{for(var t in e||(e={}))me.call(e,t)&&Y(o,t,e[t]);if(X)for(var t of X(e))ve.call(e,t)&&Y(o,t,e[t]);return o},q=(o,e)=>de(o,pe(e));var ee=(o,e,t)=>new Promise((i,s)=>{var a=l=>{try{n(t.next(l))}catch(u){s(u)}},c=l=>{try{n(t.throw(l))}catch(u){s(u)}},n=l=>l.done?i(l.value):Promise.resolve(l.value).then(a,c);n((t=t.apply(o,e)).next())});const r=require("three"),ge=require("three/examples/jsm/renderers/CSS2DRenderer"),te=require("three/examples/jsm/renderers/CSS3DRenderer"),W=require("d3-geo");require("d3-geo-projection");const $=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),T=require("d3-array"),K=require("earcut"),ye=require("@turf/boolean-clockwise"),Me=require("delaunator"),xe=require("@turf/boolean-point-in-polygon"),we=require("d3-geo-voronoi"),ie=require("d3-scale"),je=(o,e=1)=>{const t=new r.BufferGeometry;t.setAttribute("position",new r.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new r.Float32BufferAttribute(new Array(e).fill(1),1));const i=o.material,s=new r.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return s.onBeforeCompile=a=>{a.vertexShader=`
1
+ "use strict";var fe=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var X=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var J=Math.pow,Y=(a,e,t)=>e in a?fe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,O=(a,e)=>{for(var t in e||(e={}))me.call(e,t)&&Y(a,t,e[t]);if(X)for(var t of X(e))ve.call(e,t)&&Y(a,t,e[t]);return a},q=(a,e)=>de(a,pe(e));var ee=(a,e,t)=>new Promise((i,s)=>{var o=c=>{try{r(t.next(c))}catch(l){s(l)}},u=c=>{try{r(t.throw(c))}catch(l){s(l)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,u);r((t=t.apply(a,e)).next())});const n=require("three"),ge=require("three/examples/jsm/renderers/CSS2DRenderer"),te=require("three/examples/jsm/renderers/CSS3DRenderer"),W=require("d3-geo");require("d3-geo-projection");const $=require("./parseVector.js"),be=require("three/examples/jsm/lines/LineSegmentsGeometry"),T=require("d3-array"),K=require("earcut"),ye=require("@turf/boolean-clockwise"),Me=require("delaunator"),xe=require("@turf/boolean-point-in-polygon"),we=require("d3-geo-voronoi"),ie=require("d3-scale"),Ae=(a,e=1)=>{const t=new n.BufferGeometry;t.setAttribute("position",new n.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new n.Float32BufferAttribute(new Array(e).fill(1),1));const i=a.material,s=new n.PointsMaterial({size:10,map:i.map,alphaMap:i.alphaMap,color:i.color,blending:i.blending,depthTest:i.depthTest,depthWrite:!1,opacity:i.opacity,transparent:!0,alphaTest:i.alphaTest,sizeAttenuation:!1});return s.onBeforeCompile=o=>{o.vertexShader=`
2
2
  attribute float scaleAtt;
3
- ${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new r.Points(t,s)},Pe=0,Se=1,Ae=2,Ce=!1;class Q{constructor(){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}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.lead.objMap.get(t).erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(Pe),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),this}createMesh(...e){return this.object3d=new r.Mesh(...e),this}createGroup(){return this.object3d=new r.Group,this}createPoints(...e){return this.object3d=new r.Points(...e),this}createCSS2DObject(e){return this.object3d=new ge.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new te.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new te.CSS3DSprite(e),this}createSprite(e){return this.object3d=new r.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new r.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new r.Vector3),center:e.getCenter(new r.Vector3)}}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}clone(){return this.instantiate()}instantiate(e,t){return ee(this,null,function*(){var m;const i=e&&e.length>0,s=(m=t==null?void 0:t.recursive)!=null?m:!0,{objectType:a,objectOptions:c}=this,[,n]=a.split("#");let l=t==null?void 0:t.create;l===void 0&&(l=h=>{if(this.object3d){if(i){const v=e.length;if(this.object3d instanceof r.Sprite)h.object3d=je(this.object3d,v);else{const d=this.object3d,p=this.cloneMaterial();h.object3d=new r.InstancedMesh(d.geometry,p,v)}const f=new r.Object3D;e.forEach((d,p)=>{const b=$.parseVector3(d.position),j=$.parseVector3(d.scale||[1,1,1]);f.position.copy(b),f.scale.copy(j),f.updateMatrix(),h.setInstancedMatrix(p,f.matrix.clone())})}else h.object3d=this.object3d.clone(!1),h.object3d.material&&(h.object3d.material=this.cloneMaterial());h.object3d.userData.prefab&&delete h.object3d.userData.prefab}});const u=yield this.lead.draw(n,q(O({},c||{}),{create:l,prefab:!1,key:(t==null?void 0:t.key)||(c==null?void 0:c.key),target:(t==null?void 0:t.target)||(c==null?void 0:c.target)}));return this.isBloom&&u.enableBloom(),s&&(yield Promise.all(this.children.map(h=>h.instantiate(void 0,{target:u})))),u.isInstantiate=!0,u})}setInstancedMatrix(e,t){if(this.object3d instanceof r.InstancedMesh||this.object3d.isInstantiate)this.object3d.setMatrixAt(e,t);else if(this.object3d instanceof r.Points||this.object3d.type==="Points"){const s=this.object3d.geometry,a=s.attributes.position.array,c=s.attributes.scaleAtt.array,n=new r.Vector3,l=new r.Vector3,u=new r.Quaternion,m=e*3,h=e*1;t.decompose(n,u,l),a[m]=n.x,a[m+1]=n.y,a[m+2]=n.z,c[h]=Math.max(l.x,l.y,l.z),s.attributes.position.needsUpdate=!0,s.attributes.scaleAtt.needsUpdate=!0}}erase(){this.lead.erase(this)}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const a=i.clone();return i.userData=s,a});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e]&&!i)return this.materialList[e];const a=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=a,a}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.pencil.options.mList&&this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new ue;t.disposeMaterial=!this.pencil.options.mList,t.track(this),t.dispose()}}}class ue{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof r.Material)return e;if(e instanceof Q?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof r.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Q)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof r.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof r.Material){for(const i of Object.values(e))i instanceof r.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof r.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e instanceof r.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof r.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const F=new r.Vector4,se=new r.Vector3,re=new r.Vector3,y=new r.Vector4,M=new r.Vector4,V=new r.Vector4,N=new r.Vector3,Z=new r.Matrix4,x=new r.Line3,ne=new r.Vector3,k=new r.Box3,R=new r.Sphere,D=new r.Vector4;let L,_;function ae(o,e,t){return D.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),D.multiplyScalar(1/D.w),D.x=_/t.width,D.y=_/t.height,D.applyMatrix4(o.projectionMatrixInverse),D.multiplyScalar(1/D.w),Math.abs(Math.max(D.x,D.y))}function Be(o,e){const t=o.matrixWorld,i=o.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,c=Math.min(i.instanceCount,s.count);for(let n=0,l=c;n<l;n++){x.start.fromBufferAttribute(s,n),x.end.fromBufferAttribute(a,n),x.applyMatrix4(t);const u=new r.Vector3,m=new r.Vector3;L.distanceSqToSegment(x.start,x.end,m,u),m.distanceTo(u)<_*.5&&e.push({point:m,pointOnLine:u,distance:L.origin.distanceTo(m),object:o,face:null,faceIndex:n,uv:null,uv1:null})}}function Ie(o,e,t){const i=e.projectionMatrix,a=o.material.resolution,c=o.matrixWorld,n=o.geometry,l=n.attributes.instanceStart,u=n.attributes.instanceEnd,m=Math.min(n.instanceCount,l.count),h=-e.near;L.at(1,V),V.w=1,V.applyMatrix4(e.matrixWorldInverse),V.applyMatrix4(i),V.multiplyScalar(1/V.w),V.x*=a.x/2,V.y*=a.y/2,V.z=0,N.copy(V),Z.multiplyMatrices(e.matrixWorldInverse,c);for(let v=0,f=m;v<f;v++){if(y.fromBufferAttribute(l,v),M.fromBufferAttribute(u,v),y.w=1,M.w=1,y.applyMatrix4(Z),M.applyMatrix4(Z),y.z>h&&M.z>h)continue;if(y.z>h){const I=y.z-M.z,P=(y.z-h)/I;y.lerp(M,P)}else if(M.z>h){const I=M.z-y.z,P=(M.z-h)/I;M.lerp(y,P)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=a.x/2,y.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const p=x.closestPointToPointParameter(N,!0);x.at(p,ne);const b=r.MathUtils.lerp(y.z,M.z,p),j=b>=-1&&b<=1,B=N.distanceTo(ne)<_*.5;if(j&&B){x.start.fromBufferAttribute(l,v),x.end.fromBufferAttribute(u,v),x.start.applyMatrix4(c),x.end.applyMatrix4(c);const I=new r.Vector3,P=new r.Vector3;L.distanceSqToSegment(x.start,x.end,P,I),t.push({point:P,pointOnLine:I,distance:L.origin.distanceTo(P),object:o,face:null,faceIndex:v,uv:null,uv1:null})}}}class Ve extends r.Mesh{constructor(e=new be.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let c=0,n=0,l=t.count;c<l;c++,n+=2)se.fromBufferAttribute(t,c),re.fromBufferAttribute(i,c),s[n]=n===0?0:s[n-1],s[n+1]=s[n]+se.distanceTo(re);const a=new r.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new r.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new r.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;L=e.ray;const c=this.matrixWorld,n=this.geometry,l=this.material;_=l.linewidth+a,n.boundingSphere===null&&n.computeBoundingSphere(),R.copy(n.boundingSphere).applyMatrix4(c);let u;if(i)u=_*.5;else{const h=Math.max(s.near,R.distanceToPoint(L.origin));u=ae(s,h,l.resolution)}if(R.radius+=u,L.intersectsSphere(R)===!1)return;n.boundingBox===null&&n.computeBoundingBox(),k.copy(n.boundingBox).applyMatrix4(c);let m;if(i)m=_*.5;else{const h=Math.max(s.near,k.distanceToPoint(L.origin));m=ae(s,h,l.resolution)}k.expandByScalar(m),L.intersectsBox(k)!==!1&&(i?Be(this,t):Ie(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}const oe=["encodings_fragment","colorspace_fragment"],De=`
3
+ ${o.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
+ `},new n.Points(t,s)},Pe=(a,e)=>{const t=new n.Object3D;e.forEach((i,s)=>{const o=$.parseVector3(i.position),u=$.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(u),t.updateMatrix();const r=t.matrix.clone();if(a instanceof n.InstancedMesh||a.isInstantiate)a.setMatrixAt(s,r);else if(a instanceof n.Points||a.type==="Points"){const l=a.geometry,p=l.attributes.position.array,f=l.attributes.scaleAtt.array,m=new n.Vector3,h=new n.Vector3,v=new n.Quaternion,d=s*3,b=s*1;r.decompose(m,v,h),p[d]=m.x,p[d+1]=m.y,p[d+2]=m.z,f[b]=Math.max(h.x,h.y,h.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})},Se=0,je=1,Ce=2,Be=!1;class Q{constructor(){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}get parent(){const e=this.object3d.parent;return e&&this.lead.objMap.get(e)||null}get children(){return this.object3d.children.map(e=>this.lead.objMap.get(e)).filter(e=>!!e)}get position(){return this.object3d.position}get rotation(){return this.object3d.rotation}get scale(){return this.object3d.scale}add(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.object3d.add(t):this.lead.createBaseObject(t,{target:this})})}remove(...e){[...e].forEach(t=>{this.lead.objMap.get(t)?this.lead.objMap.get(t).erase():this.object3d.remove(t)})}get visible(){return this.object3d.visible}get visibleWithAncestors(){if(this.visible){let e=this.parent;for(;e;){if(!e.visible)return!1;e=e.parent}return!0}else return!1}create(){this.createGroup()}render(){}update(e,t){}resize(e,t){}show(){return this.object3d.visible=!0,this.object3d.layers.set(Se),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ce),this}createMesh(...e){return this.object3d=new n.Mesh(...e),this}createGroup(){return this.object3d=new n.Group,this}createPoints(...e){return this.object3d=new n.Points(...e),this}createCSS2DObject(e){return this.object3d=new ge.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new te.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new te.CSS3DSprite(e),this}createSprite(e){return this.object3d=new n.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new n.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new n.Vector3),center:e.getCenter(new n.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return ee(this,null,function*(){var c;const t=(c=e==null?void 0:e.recursive)!=null?c:!0,{objectType:i,objectOptions:s}=this,[,o]=i.split("#");let u=e==null?void 0:e.create;u===void 0&&(u=l=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const f=e.instancedAttr.length;if(this.object3d instanceof n.Sprite)l.object3d=Ae(this.object3d,f);else{const m=this.object3d,h=this.cloneMaterial();l.object3d=new n.InstancedMesh(m.geometry,h,f)}Pe(l.object3d,e==null?void 0:e.instancedAttr)}else l.object3d=this.object3d.clone(!1),l.object3d.material&&(l.object3d.material=this.cloneMaterial());l.object3d.userData.prefab&&delete l.object3d.userData.prefab}});const r=yield this.lead.draw(o,q(O({},s||{}),{create:u,prefab:!1,key:(e==null?void 0:e.key)||(s==null?void 0:s.key),target:(e==null?void 0:e.target)||(s==null?void 0:s.target)}));return this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(l=>l.instantiate({target:r})))),r.isInstantiate=!0,r})}erase(){this.lead.erase(this)}cloneMaterial(){const e=this.object3d;if(!e||!e.material)return;const t=e.material;if(Array.isArray(t))return t.map(i=>{const s=i.userData;i.userData={};const o=i.clone();return i.userData=s,o});{const i=t.userData;t.userData={};const s=t.clone();return t.userData=i,s}}setMaterialList(e,t,i=!0){const s=this.object3d;if(!s||!s.material)return;if(this.materialList.origin||(this.materialList.origin=s.material),this.materialList[e]&&!i)return this.materialList[e];const o=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=o,o}useMaterial(e){const t=this.object3d;!t||!t.material||this.useMaterialType===e||!this.materialList[e]||(this.useMaterialType=e,t.material=this.materialList[e])}useMListById(e,t){if(!this.mList)return;const i=this.mList.get(e);if(!i)return;const s=this.object3d;Array.isArray(s.material)&&t!==void 0?s.material[t]=i:s.material=i}useMListByName(e,t){if(!this.mList)return;const i=this.mList.getKeyByName(e);i&&this.useMListById(i,t)}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}enableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!0),this.isBloom=!0}disableBloom(){var e;(e=this.pencil.composerController)==null||e.setBloomSelection(this,!1),this.isBloom=!1}dispose(){var e;if(this.onPointerIndex.forEach(t=>{this.lead.removePick(t)}),this.pencil.options.mList&&this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed),(e=this.pencil.composerController)==null||e.bloomSelection.delete(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack){const t=new ue;t.disposeMaterial=!this.pencil.options.mList,t.track(this),t.dispose()}}}class ue{constructor(){this.resources=new Set,this.disposeMaterial=!0,this.disposeVideo=!0}track(e){if(!e)return e;if(Array.isArray(e))return e.forEach(t=>this.track(t)),e;if(!this.disposeMaterial&&e instanceof n.Material)return e;if(e instanceof Q?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof n.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof Q)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof n.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof n.Material){for(const i of Object.values(e))i instanceof n.Texture&&this.track(i);const t=e;if(t.uniforms){for(const i of Object.values(t.uniforms))if(i){const s=i.value;(s instanceof n.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e instanceof n.VideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof n.Object3D?e.push(t):t instanceof HTMLVideoElement&&t.pause(),Reflect.has(t,"dispose")&&t.dispose();e.forEach(t=>{t.removeFromParent()}),e.length=0,this.resources.clear()}}const F=new n.Vector4,se=new n.Vector3,re=new n.Vector3,y=new n.Vector4,M=new n.Vector4,D=new n.Vector4,N=new n.Vector3,Z=new n.Matrix4,x=new n.Line3,ne=new n.Vector3,k=new n.Box3,R=new n.Sphere,I=new n.Vector4;let L,_;function ae(a,e,t){return I.set(0,0,-e,1).applyMatrix4(a.projectionMatrix),I.multiplyScalar(1/I.w),I.x=_/t.width,I.y=_/t.height,I.applyMatrix4(a.projectionMatrixInverse),I.multiplyScalar(1/I.w),Math.abs(Math.max(I.x,I.y))}function Ve(a,e){const t=a.matrixWorld,i=a.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,u=Math.min(i.instanceCount,s.count);for(let r=0,c=u;r<c;r++){x.start.fromBufferAttribute(s,r),x.end.fromBufferAttribute(o,r),x.applyMatrix4(t);const l=new n.Vector3,p=new n.Vector3;L.distanceSqToSegment(x.start,x.end,p,l),p.distanceTo(l)<_*.5&&e.push({point:p,pointOnLine:l,distance:L.origin.distanceTo(p),object:a,face:null,faceIndex:r,uv:null,uv1:null})}}function De(a,e,t){const i=e.projectionMatrix,o=a.material.resolution,u=a.matrixWorld,r=a.geometry,c=r.attributes.instanceStart,l=r.attributes.instanceEnd,p=Math.min(r.instanceCount,c.count),f=-e.near;L.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=o.x/2,D.y*=o.y/2,D.z=0,N.copy(D),Z.multiplyMatrices(e.matrixWorldInverse,u);for(let m=0,h=p;m<h;m++){if(y.fromBufferAttribute(c,m),M.fromBufferAttribute(l,m),y.w=1,M.w=1,y.applyMatrix4(Z),M.applyMatrix4(Z),y.z>f&&M.z>f)continue;if(y.z>f){const V=y.z-M.z,A=(y.z-f)/V;y.lerp(M,A)}else if(M.z>f){const V=M.z-y.z,A=(M.z-f)/V;M.lerp(y,A)}y.applyMatrix4(i),M.applyMatrix4(i),y.multiplyScalar(1/y.w),M.multiplyScalar(1/M.w),y.x*=o.x/2,y.y*=o.y/2,M.x*=o.x/2,M.y*=o.y/2,x.start.copy(y),x.start.z=0,x.end.copy(M),x.end.z=0;const d=x.closestPointToPointParameter(N,!0);x.at(d,ne);const b=n.MathUtils.lerp(y.z,M.z,d),C=b>=-1&&b<=1,B=N.distanceTo(ne)<_*.5;if(C&&B){x.start.fromBufferAttribute(c,m),x.end.fromBufferAttribute(l,m),x.start.applyMatrix4(u),x.end.applyMatrix4(u);const V=new n.Vector3,A=new n.Vector3;L.distanceSqToSegment(x.start,x.end,A,V),t.push({point:A,pointOnLine:V,distance:L.origin.distanceTo(A),object:a,face:null,faceIndex:m,uv:null,uv1:null})}}}class Ie extends n.Mesh{constructor(e=new be.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let u=0,r=0,c=t.count;u<c;u++,r+=2)se.fromBufferAttribute(t,u),re.fromBufferAttribute(i,u),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+se.distanceTo(re);const o=new n.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new n.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new n.InterleavedBufferAttribute(o,1,1)),this}raycast(e,t){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;L=e.ray;const u=this.matrixWorld,r=this.geometry,c=this.material;_=c.linewidth+o,r.boundingSphere===null&&r.computeBoundingSphere(),R.copy(r.boundingSphere).applyMatrix4(u);let l;if(i)l=_*.5;else{const f=Math.max(s.near,R.distanceToPoint(L.origin));l=ae(s,f,c.resolution)}if(R.radius+=l,L.intersectsSphere(R)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),k.copy(r.boundingBox).applyMatrix4(u);let p;if(i)p=_*.5;else{const f=Math.max(s.near,k.distanceToPoint(L.origin));p=ae(s,f,c.resolution)}k.expandByScalar(p),L.intersectsBox(k)!==!1&&(i?Ve(this,t):De(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}const oe=["encodings_fragment","colorspace_fragment"],Le=`
5
5
  #include <common>
6
6
  #include <logdepthbuf_pars_vertex>
7
7
  #include <fog_pars_vertex>
@@ -94,7 +94,7 @@
94
94
  vHighPrecisionZW = finalPosition.zw;
95
95
  #include <fog_vertex>
96
96
  }
97
- `,Le=`
97
+ `,ze=`
98
98
  #include <packing>
99
99
  #include <fog_pars_fragment>
100
100
  #include <logdepthbuf_pars_fragment>
@@ -144,6 +144,6 @@
144
144
 
145
145
  #include <fog_fragment>
146
146
  #include <tonemapping_fragment>
147
- #include <${+r.REVISION<154?oe[0]:oe[1]}>
147
+ #include <${+n.REVISION<154?oe[0]:oe[1]}>
148
148
  }
149
- `;class ze extends r.ShaderMaterial{constructor(e){super({uniforms:q(O({},r.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new r.Color(16777215)},opacity:{value:1},resolution:{value:new r.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new r.Vector2(1,1)},offset:{value:new r.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new r.Vector2(0,0)},lightColor:{value:new r.Color(16777215)}}),vertexShader:De,fragmentShader:Le}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(t){this.uniforms.useDash.value=t}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(t){this.uniforms.useDepth.value=t}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(t){this.uniforms.repeat.value.copy(t)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(t){this.uniforms.lineLightAnimation.value=t}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(t){this.uniforms.size.value=t}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(t){this.uniforms.speed.value=t}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(t){this.uniforms.lightWidth.value=t}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(t){this.uniforms.uCenter.value=t}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(t){t&&(this.uniforms.lightColor.value=t)}}}),this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray=e.dashArray,this.dashOffset=e.dashOffset,this.dashRatio=e.dashRatio,this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}function _e(o,e){return o.map(t=>{const i=[];let s;return t.forEach(a=>{if(s){const c=W.geoDistance(a,s)*180/Math.PI;if(c>e){const n=W.geoInterpolate(s,a),l=1/Math.ceil(c/e);let u=l;for(;u<1;)i.push(n(u)),u+=l}}i.push(s=a)}),i})}function Te(o,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const a=Math.round(J(360/o,2)/Math.PI),c=(1+Math.sqrt(5))/2,n=f=>f/c*360%360-180,l=f=>Math.acos(2*f/a-1)/Math.PI*180-90,u=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,m=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],h=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,v=[];for(let f=m[0];f<=m[1];f++){const d=n(f);h(d)&&v.push([d,l(f)])}return v}function H(o,e,t=!1){return t?W.geoContains(e,o):xe(o,e)}function Oe(o,e){const t={type:"Polygon",coordinates:o},[[i,s],[a,c]]=W.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(c-s))<e)return[];const n=i>a||c>=89||s<=-89;return Te(e,{minLng:i,maxLng:a,minLat:s,maxLat:c}).filter(l=>H(l,t,n))}function We(o,{resolution:e=1/0,bbox:t,projection:i}={}){const s=_e(o,e),a=T.merge(s),c=Oe(o,e),n=[...a,...c],l={type:"Polygon",coordinates:o},[[u,m],[h,v]]=W.geoBounds(l),f=u>h||v>=89||m<=-89;let d=[];if(f){const g=we.geoVoronoi(n).triangles(),w=new Map(n.map(([S,A],z)=>[`${S}-${A}`,z]));g.features.forEach(S=>{const A=S.geometry.coordinates[0].slice(0,3).reverse(),z=[];if(A.forEach(([C,G])=>{const E=`${C}-${G}`;w.has(E)&&z.push(w.get(E))}),z.length===3){if(z.some(C=>C<a.length)){const C=S.properties.circumcenter;if(!H(C,l,f))return}d.push(...z)}})}else if(c.length){const g=Me.from(n);for(let w=0,S=g.triangles.length;w<S;w+=3){const A=[2,1,0].map(C=>g.triangles[w+C]),z=A.map(C=>n[C]);if(A.some(C=>C<a.length)){const C=[0,1].map(G=>T.mean(z,E=>E[G]));if(!H(C,l,f))continue}d.push(...A)}}else{const{vertices:g,holes:w=[]}=K.flatten(s);d=K(g,w,2)}let p=t?[t[0],t[2]]:T.extent(n,g=>g[0]),b=t?[t[1],t[3]]:T.extent(n,g=>g[1]);if(i){const[g,w]=i([p[0],b[0]]),[S,A]=i([p[1],b[1]]);p=[g,S],b=[-w,-A]}const j=ie.scaleLinear(p,[0,1]),B=ie.scaleLinear(b,[0,1]),I=n.map(([g,w])=>{if(i){const[S,A]=i([g,w]);return[j(S),B(-A)]}else return[j(g),B(w)]});return{contour:s,triangles:{points:n,indices:d,uvs:I}}}const le=new r.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function U(o,e,t,i){const s=o.map(a=>a.map(([c,n])=>{if(i){const[l,u]=i([c,n]);return[l,-u,e]}return t?$.polar2Cartesian(c,n,e):[c,n,e]}));return K.flatten(s)}function Ee(o,e,t,i,s){const{vertices:a,holes:c}=U(o,e,i,s),{vertices:n}=U(o,t,i,s),l=T.merge([n,a]),u=Math.round(n.length/3),m=new Set(c);let h=0;const v=[];for(let d=0;d<u;d++){let p=d+1;if(p===u)p=h;else if(m.has(p)){const b=p;p=h,h=b}v.push(d,d+u,p+u),v.push(p+u,p,d)}const f=[];for(let d=1;d>=0;d--)for(let p=0;p<u;p+=1)f.push(p/(u-1),d);return{indices:v,vertices:l,uvs:f,topVerts:n}}function ce(o,e,t,i,s,a){return{indices:i?o.indices:o.indices.slice().reverse(),vertices:U([o.points],e,s,a).vertices,uvs:t}}const he=({polygonGeoJson:o,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:c=!1,hasTop:n=!1,projection:l,bbox:u})=>{o.forEach(j=>{ye(j)||j.reverse()});const{contour:m,triangles:h}=We(o,{resolution:i,bbox:u,projection:l});let v={},f;a&&(v=Ee(m,e!=null?e:t,t!=null?t:e,s,l),f=v.topVerts);let d=[];(c||n)&&(d=T.merge(h.uvs));let p={};c&&(p=ce(h,e,d,!1,s,l));let b={};return n&&(b=ce(h,t,d,!0,s,l)),{contour:m,triangles:h,sideTorso:v,bottomCap:p,topCap:b,topVerts:f}};class ke extends r.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=O({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:a,hasBottom:c,hasSide:n,cartesian:l,userDataRsoOffset:u,projection:m}=this.parameters,{contour:h,sideTorso:v,topVerts:f,bottomCap:d,topCap:p}=he(O({},this.parameters));let b=[],j=[],B=[],I=0;const P=g=>{const w=Math.round(b.length/3),S=B.length;b=b.concat(g.vertices),j=j.concat(g.uvs),B=B.concat(w?g.indices.map(A=>A+w):g.indices),this.addGroup(S,B.length-S,I++)};s&&a&&P(p),n&&(P(v),this.userData.topVerts=u?U(h,i+u,l,m).vertices:f),c&&P(d),s&&!a&&P(p),this.setIndex(B),this[le]("position",new r.Float32BufferAttribute(b,3)),this[le]("uv",new r.Float32BufferAttribute(j,2)),this.computeVertexNormals()}}exports.BLOOM_SCENE=Se;exports.BaseObject=Q;exports.IS_DEV=Ce;exports.LineSegments2=Ve;exports.MeshLineMaterial=ze;exports.PolygonGeometry=ke;exports.ResourceTracker=ue;exports.getMetas=he;
149
+ `;class _e extends n.ShaderMaterial{constructor(e){super({uniforms:q(O({},n.UniformsLib.fog),{lineWidth:{value:1},map:{value:null},useMap:{value:0},alphaMap:{value:null},useAlphaMap:{value:0},color:{value:new n.Color(16777215)},opacity:{value:1},resolution:{value:new n.Vector2(1,1)},sizeAttenuation:{value:1},dashArray:{value:0},dashOffset:{value:0},dashRatio:{value:.5},useDash:{value:0},useDepth:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new n.Vector2(1,1)},offset:{value:new n.Vector2(0,0)},offsetLoop:{value:1},lineLightAnimation:{value:0},time:{value:0},size:{value:300},speed:{value:.3},lightWidth:{value:.1},uCenter:{value:new n.Vector2(0,0)},lightColor:{value:new n.Color(16777215)}}),vertexShader:Le,fragmentShader:ze}),this.type="MeshLineMaterial",Object.defineProperties(this,{lineWidth:{enumerable:!0,get(){return this.uniforms.lineWidth.value},set(t){this.uniforms.lineWidth.value=t}},map:{enumerable:!0,get(){return this.uniforms.map.value},set(t){this.uniforms.map.value=t}},useMap:{enumerable:!0,get(){return this.uniforms.useMap.value},set(t){this.uniforms.useMap.value=t}},alphaMap:{enumerable:!0,get(){return this.uniforms.alphaMap.value},set(t){this.uniforms.alphaMap.value=t}},useAlphaMap:{enumerable:!0,get(){return this.uniforms.useAlphaMap.value},set(t){this.uniforms.useAlphaMap.value=t}},color:{enumerable:!0,get(){return this.uniforms.color.value},set(t){this.uniforms.color.value=t}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(t){this.uniforms.resolution.value.copy(t)}},sizeAttenuation:{enumerable:!0,get(){return this.uniforms.sizeAttenuation.value},set(t){this.uniforms.sizeAttenuation.value=t}},dashArray:{enumerable:!0,get(){return this.uniforms.dashArray.value},set(t){this.uniforms.dashArray.value=t,this.useDash=t!==0?1:0}},dashOffset:{enumerable:!0,get(){return this.uniforms.dashOffset.value},set(t){this.uniforms.dashOffset.value=t}},dashRatio:{enumerable:!0,get(){return this.uniforms.dashRatio.value},set(t){this.uniforms.dashRatio.value=t}},useDash:{enumerable:!0,get(){return this.uniforms.useDash.value},set(t){this.uniforms.useDash.value=t}},useDepth:{enumerable:!0,get(){return this.uniforms.useDepth.value},set(t){this.uniforms.useDepth.value=t}},visibility:{enumerable:!0,get(){return this.uniforms.visibility.value},set(t){this.uniforms.visibility.value=t}},alphaTest:{enumerable:!0,get(){return this.uniforms.alphaTest.value},set(t){this.uniforms.alphaTest.value=t}},repeat:{enumerable:!0,get(){return this.uniforms.repeat.value},set(t){this.uniforms.repeat.value.copy(t)}},lineLightAnimation:{enumerable:!0,get:function(){return this.uniforms.lineLightAnimation.value},set:function(t){this.uniforms.lineLightAnimation.value=t}},time:{enumerable:!0,get:function(){return this.uniforms.time.value},set:function(t){this.uniforms.time.value=t}},size:{enumerable:!0,get:function(){return this.uniforms.size.value},set:function(t){this.uniforms.size.value=t}},speed:{enumerable:!0,get:function(){return this.uniforms.speed.value},set:function(t){this.uniforms.speed.value=t}},lightWidth:{enumerable:!0,get:function(){return this.uniforms.lightWidth.value},set:function(t){this.uniforms.lightWidth.value=t}},uCenter:{enumerable:!0,get:function(){return this.uniforms.uCenter.value},set:function(t){this.uniforms.uCenter.value=t}},lightColor:{enumerable:!0,get:function(){return this.uniforms.lightColor.value},set:function(t){t&&(this.uniforms.lightColor.value=t)}}}),this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.map=e.map,this.useMap=e.useMap,this.alphaMap=e.alphaMap,this.useAlphaMap=e.useAlphaMap,this.color.copy(e.color),this.opacity=e.opacity,this.resolution.copy(e.resolution),this.sizeAttenuation=e.sizeAttenuation,this.dashArray=e.dashArray,this.dashOffset=e.dashOffset,this.dashRatio=e.dashRatio,this.useDash=e.useDash,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}function Te(a,e){return a.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const u=W.geoDistance(o,s)*180/Math.PI;if(u>e){const r=W.geoInterpolate(s,o),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(r(l)),l+=c}}i.push(s=o)}),i})}function Oe(a,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const o=Math.round(J(360/a,2)/Math.PI),u=(1+Math.sqrt(5))/2,r=h=>h/u*360%360-180,c=h=>Math.acos(2*h/o-1)/Math.PI*180-90,l=h=>o*(Math.cos((h+90)*Math.PI/180)+1)/2,p=[s!==void 0?Math.ceil(l(s)):0,i!==void 0?Math.floor(l(i)):o-1],f=e===void 0&&t===void 0?()=>!0:e===void 0?h=>h<=t:t===void 0?h=>h>=e:t>=e?h=>h>=e&&h<=t:h=>h>=e||h<=t,m=[];for(let h=p[0];h<=p[1];h++){const v=r(h);f(v)&&m.push([v,c(h)])}return m}function H(a,e,t=!1){return t?W.geoContains(e,a):xe(a,e)}function We(a,e){const t={type:"Polygon",coordinates:a},[[i,s],[o,u]]=W.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(u-s))<e)return[];const r=i>o||u>=89||s<=-89;return Oe(e,{minLng:i,maxLng:o,minLat:s,maxLat:u}).filter(c=>H(c,t,r))}function Ee(a,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Te(a,e),o=T.merge(s),u=We(a,e),r=[...o,...u],c={type:"Polygon",coordinates:a},[[l,p],[f,m]]=W.geoBounds(c),h=l>f||m>=89||p<=-89;let v=[];if(h){const g=we.geoVoronoi(r).triangles(),w=new Map(r.map(([P,S],z)=>[`${P}-${S}`,z]));g.features.forEach(P=>{const S=P.geometry.coordinates[0].slice(0,3).reverse(),z=[];if(S.forEach(([j,G])=>{const E=`${j}-${G}`;w.has(E)&&z.push(w.get(E))}),z.length===3){if(z.some(j=>j<o.length)){const j=P.properties.circumcenter;if(!H(j,c,h))return}v.push(...z)}})}else if(u.length){const g=Me.from(r);for(let w=0,P=g.triangles.length;w<P;w+=3){const S=[2,1,0].map(j=>g.triangles[w+j]),z=S.map(j=>r[j]);if(S.some(j=>j<o.length)){const j=[0,1].map(G=>T.mean(z,E=>E[G]));if(!H(j,c,h))continue}v.push(...S)}}else{const{vertices:g,holes:w=[]}=K.flatten(s);v=K(g,w,2)}let d=t?[t[0],t[2]]:T.extent(r,g=>g[0]),b=t?[t[1],t[3]]:T.extent(r,g=>g[1]);if(i){const[g,w]=i([d[0],b[0]]),[P,S]=i([d[1],b[1]]);d=[g,P],b=[-w,-S]}const C=ie.scaleLinear(d,[0,1]),B=ie.scaleLinear(b,[0,1]),V=r.map(([g,w])=>{if(i){const[P,S]=i([g,w]);return[C(P),B(-S)]}else return[C(g),B(w)]});return{contour:s,triangles:{points:r,indices:v,uvs:V}}}const le=new n.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function U(a,e,t,i){const s=a.map(o=>o.map(([u,r])=>{if(i){const[c,l]=i([u,r]);return[c,-l,e]}return t?$.polar2Cartesian(u,r,e):[u,r,e]}));return K.flatten(s)}function ke(a,e,t,i,s){const{vertices:o,holes:u}=U(a,e,i,s),{vertices:r}=U(a,t,i,s),c=T.merge([r,o]),l=Math.round(r.length/3),p=new Set(u);let f=0;const m=[];for(let v=0;v<l;v++){let d=v+1;if(d===l)d=f;else if(p.has(d)){const b=d;d=f,f=b}m.push(v,v+l,d+l),m.push(d+l,d,v)}const h=[];for(let v=1;v>=0;v--)for(let d=0;d<l;d+=1)h.push(d/(l-1),v);return{indices:m,vertices:c,uvs:h,topVerts:r}}function ce(a,e,t,i,s,o){return{indices:i?a.indices:a.indices.slice().reverse(),vertices:U([a.points],e,s,o).vertices,uvs:t}}const he=({polygonGeoJson:a,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:u=!1,hasTop:r=!1,projection:c,bbox:l})=>{a.forEach(C=>{ye(C)||C.reverse()});const{contour:p,triangles:f}=Ee(a,{resolution:i,bbox:l,projection:c});let m={},h;o&&(m=ke(p,e!=null?e:t,t!=null?t:e,s,c),h=m.topVerts);let v=[];(u||r)&&(v=T.merge(f.uvs));let d={};u&&(d=ce(f,e,v,!1,s,c));let b={};return r&&(b=ce(f,t,v,!0,s,c)),{contour:p,triangles:f,sideTorso:m,bottomCap:d,topCap:b,topVerts:h}};class Re extends n.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=O({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:i,hasTop:s,topFirst:o,hasBottom:u,hasSide:r,cartesian:c,userDataRsoOffset:l,projection:p}=this.parameters,{contour:f,sideTorso:m,topVerts:h,bottomCap:v,topCap:d}=he(O({},this.parameters));let b=[],C=[],B=[],V=0;const A=g=>{const w=Math.round(b.length/3),P=B.length;b=b.concat(g.vertices),C=C.concat(g.uvs),B=B.concat(w?g.indices.map(S=>S+w):g.indices),this.addGroup(P,B.length-P,V++)};s&&o&&A(d),r&&(A(m),this.userData.topVerts=l?U(f,i+l,c,p).vertices:h),u&&A(v),s&&!o&&A(d),this.setIndex(B),this[le]("position",new n.Float32BufferAttribute(b,3)),this[le]("uv",new n.Float32BufferAttribute(C,2)),this.computeVertexNormals()}}exports.BLOOM_SCENE=je;exports.BaseObject=Q;exports.IS_DEV=Be;exports.LineSegments2=Ie;exports.MeshLineMaterial=_e;exports.PolygonGeometry=Re;exports.ResourceTracker=ue;exports.getMetas=he;
@@ -0,0 +1,6 @@
1
+ import { Vector3 } from 'three';
2
+ declare const _default: (object: any, instancedAttr: {
3
+ position: Vector3 | number[] | [number, number, number];
4
+ scale?: Vector3 | number[] | [number, number, number];
5
+ }[]) => void;
6
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.15.16",
3
+ "version": "0.15.17",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",