gl-draw 0.17.0-beta.21 → 0.17.0-beta.23

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.
@@ -37,7 +37,7 @@ var ae = (n, e, t) => new Promise((i, s) => {
37
37
  });
38
38
  import { merge as J, mean as Te, extent as ce } from "d3-array";
39
39
  import Ee, { flatten as je } from "earcut";
40
- import { Material as le, Object3D as R, Texture as ue, BufferGeometry as ee, Float32BufferAttribute as G, PointsMaterial as ze, Points as te, InstancedMesh as Ce, Vector3 as S, Quaternion as ke, Group as Le, Mesh as Ae, Sprite as de, Box3 as Pe, ShaderMaterial as Ve, Vector2 as K, Color as he, Vector4 as V, Matrix4 as Ne, Line3 as We, Sphere as Ue, InstancedInterleavedBuffer as _e, InterleavedBufferAttribute as fe, MathUtils as Re } from "three";
40
+ import { Material as le, Object3D as R, Texture as ue, BufferGeometry as ee, Float32BufferAttribute as G, PointsMaterial as ke, Points as te, InstancedMesh as Ce, Vector3 as S, Quaternion as ze, Group as Le, Mesh as Ae, Sprite as de, Box3 as Pe, ShaderMaterial as Ve, Vector2 as K, Color as he, Vector4 as V, Matrix4 as Ne, Line3 as We, Sphere as Ue, InstancedInterleavedBuffer as _e, InterleavedBufferAttribute as fe, MathUtils as Re } from "three";
41
41
  import Ge from "@turf/boolean-clockwise";
42
42
  import { p as pe, a as $e } from "./polar2Cartesian.module.js";
43
43
  import Fe from "delaunator";
@@ -100,7 +100,7 @@ const rt = (n, e = 1) => {
100
100
  "scaleAtt",
101
101
  new G(new Array(e).fill(1), 1)
102
102
  );
103
- const i = n.material, s = new ze({
103
+ const i = n.material, s = new ke({
104
104
  size: 10,
105
105
  map: i.map,
106
106
  alphaMap: i.alphaMap,
@@ -131,7 +131,7 @@ const rt = (n, e = 1) => {
131
131
  if (n instanceof Ce || n.isInstantiate)
132
132
  n.setMatrixAt(s, r);
133
133
  else if (n instanceof te || n.type === "Points") {
134
- const l = n.geometry, m = l.attributes.position.array, u = l.attributes.scaleAtt.array, f = new S(), d = new S(), p = new ke(), h = s * 3, v = s * 1;
134
+ const l = n.geometry, m = l.attributes.position.array, u = l.attributes.scaleAtt.array, f = new S(), d = new S(), p = new ze(), h = s * 3, v = s * 1;
135
135
  r.decompose(f, p, d), m[h] = f.x, m[h + 1] = f.y, m[h + 2] = f.z, u[v] = Math.max(d.x, d.y, d.z), l.attributes.position.needsUpdate = !0, l.attributes.scaleAtt.needsUpdate = !0;
136
136
  }
137
137
  });
@@ -385,38 +385,38 @@ class Z extends at {
385
385
  handleMaterialChange(e) {
386
386
  }
387
387
  enableBloom(e = !0) {
388
- var t, i;
388
+ var t, i, s;
389
389
  if (!((t = this.pencil.composerController) != null && t.bloomComposer)) {
390
390
  console.warn("err:pencil.options.bloom");
391
391
  return;
392
392
  }
393
393
  if (e) {
394
- this.traverse((s) => {
395
- s.enableBloom(!1);
394
+ this.traverse((o) => {
395
+ o.enableBloom(!1);
396
396
  });
397
397
  return;
398
398
  }
399
- this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.add(this), this.object3d.layers.enable(ve)), this.isBloom = !0;
399
+ this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.add(this), this.object3d.layers.enable(ve)), (s = this.pencil.composerController) == null || s.checkBloomComposerActive(), this.isBloom = !0;
400
400
  }
401
401
  disableBloom(e = !0) {
402
- var t, i;
402
+ var t, i, s;
403
403
  if (!((t = this.pencil.composerController) != null && t.bloomComposer)) {
404
404
  console.warn("err:pencil.options.bloom");
405
405
  return;
406
406
  }
407
407
  if (e) {
408
- this.traverse((s) => {
409
- s.disableBloom(!1);
408
+ this.traverse((o) => {
409
+ o.disableBloom(!1);
410
410
  });
411
411
  return;
412
412
  }
413
- this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.delete(this), this.object3d.layers.disable(ve)), this.isBloom = !1;
413
+ this.object3d && ((i = this.pencil.composerController) == null || i.bloomSelection.delete(this), this.object3d.layers.disable(ve)), (s = this.pencil.composerController) == null || s.checkBloomComposerActive(), this.isBloom = !1;
414
414
  }
415
415
  dispose() {
416
- var e;
417
- if (!this.isDispose && (this.isDispose = !0, super.dispose(), this.isBloom && (this.disableBloom(!1), (e = this.pencil.composerController) == null || e.checkBloomComposerActive()), this.lead && (this.lead.objects.delete(this.key), this.lead.objectWrapChindIdMap.delete(this), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack)) {
418
- const t = new st();
419
- t.disposeMaterial = !1, t.track(this), t.dispose();
416
+ var e, t;
417
+ if (!this.isDispose && (this.isDispose = !0, super.dispose(), this.isBloom && (this.disableBloom(!1), (e = this.pencil.composerController) == null || e.checkBloomComposerActive()), (t = this.lead) == null || t.disableCursor(this), this.lead && (this.lead.objects.delete(this.key), this.lead.objectWrapChindIdMap.delete(this), this.object3d && this.lead.objMap.delete(this.object3d)), this.disposeTrack)) {
418
+ const i = new st();
419
+ i.disposeMaterial = !1, i.track(this), i.dispose();
420
420
  }
421
421
  }
422
422
  }
@@ -473,15 +473,15 @@ function dt(n, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
473
473
  let p = [];
474
474
  if (d) {
475
475
  const y = Ye(r).triangles(), x = new Map(
476
- r.map(([P, I], z) => [`${P}-${I}`, z])
476
+ r.map(([P, I], k) => [`${P}-${I}`, k])
477
477
  );
478
478
  y.features.forEach((P) => {
479
- const I = P.geometry.coordinates[0].slice(0, 3).reverse(), z = [];
479
+ const I = P.geometry.coordinates[0].slice(0, 3).reverse(), k = [];
480
480
  if (I.forEach(([B, F]) => {
481
481
  const N = `${B}-${F}`;
482
- x.has(N) && z.push(x.get(N));
483
- }), z.length === 3) {
484
- if (z.some((B) => B < o.length)) {
482
+ x.has(N) && k.push(x.get(N));
483
+ }), k.length === 3) {
484
+ if (k.some((B) => B < o.length)) {
485
485
  const B = P.properties.circumcenter;
486
486
  if (!H(
487
487
  B,
@@ -490,16 +490,16 @@ function dt(n, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
490
490
  ))
491
491
  return;
492
492
  }
493
- p.push(...z);
493
+ p.push(...k);
494
494
  }
495
495
  });
496
496
  } else if (c.length) {
497
497
  const y = Fe.from(r);
498
498
  for (let x = 0, P = y.triangles.length; x < P; x += 3) {
499
- const I = [2, 1, 0].map((B) => y.triangles[x + B]), z = I.map((B) => r[B]);
499
+ const I = [2, 1, 0].map((B) => y.triangles[x + B]), k = I.map((B) => r[B]);
500
500
  if (I.some((B) => B < o.length)) {
501
501
  const B = [0, 1].map(
502
- (F) => Te(z, (N) => N[F])
502
+ (F) => Te(k, (N) => N[F])
503
503
  );
504
504
  if (!H(
505
505
  B,
@@ -631,7 +631,7 @@ const ft = ({
631
631
  a
632
632
  )), { contour: m, triangles: u, sideTorso: f, bottomCap: h, topCap: v, topVerts: d };
633
633
  };
634
- class zt extends ee {
634
+ class kt extends ee {
635
635
  constructor(e, t = {}) {
636
636
  super(), this.type = "PolygonBufferGeometry", this.parameters = L({
637
637
  polygonGeoJson: e,
@@ -807,7 +807,7 @@ void main() {
807
807
  #include <fog_vertex>
808
808
  }
809
809
  `;
810
- class kt extends Ve {
810
+ class zt extends Ve {
811
811
  constructor(e = {}) {
812
812
  const C = e, {
813
813
  lineWidth: t = 1,
@@ -916,16 +916,16 @@ class kt extends Ve {
916
916
  }
917
917
  }
918
918
  const Q = new V(), ge = new S(), Me = new S(), g = new V(), M = new V(), O = new V(), X = new S(), Y = new Ne(), w = new We(), we = new S(), U = new Pe(), _ = new Ue(), T = new V();
919
- let E, k;
919
+ let E, z;
920
920
  function xe(n, e, t) {
921
- return T.set(0, 0, -e, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = k / t.width, T.y = k / t.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
921
+ return T.set(0, 0, -e, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = z / t.width, T.y = z / t.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
922
922
  }
923
923
  function vt(n, e) {
924
924
  const t = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, o = i.attributes.instanceEnd, c = Math.min(i.instanceCount, s.count);
925
925
  for (let r = 0, a = c; r < a; r++) {
926
926
  w.start.fromBufferAttribute(s, r), w.end.fromBufferAttribute(o, r), w.applyMatrix4(t);
927
927
  const l = new S(), m = new S();
928
- E.distanceSqToSegment(w.start, w.end, m, l), m.distanceTo(l) < k * 0.5 && e.push({
928
+ E.distanceSqToSegment(w.start, w.end, m, l), m.distanceTo(l) < z * 0.5 && e.push({
929
929
  point: m,
930
930
  pointOnLine: l,
931
931
  distance: E.origin.distanceTo(m),
@@ -953,7 +953,7 @@ function bt(n, e, t) {
953
953
  g.applyMatrix4(i), M.applyMatrix4(i), g.multiplyScalar(1 / g.w), M.multiplyScalar(1 / M.w), g.x *= o.x / 2, g.y *= o.y / 2, M.x *= o.x / 2, M.y *= o.y / 2, w.start.copy(g), w.start.z = 0, w.end.copy(M), w.end.z = 0;
954
954
  const h = w.closestPointToPointParameter(X, !0);
955
955
  w.at(h, we);
956
- const v = Re.lerp(g.z, M.z, h), j = v >= -1 && v <= 1, C = X.distanceTo(we) < k * 0.5;
956
+ const v = Re.lerp(g.z, M.z, h), j = v >= -1 && v <= 1, C = X.distanceTo(we) < z * 0.5;
957
957
  if (j && C) {
958
958
  w.start.fromBufferAttribute(a, f), w.end.fromBufferAttribute(l, f), w.start.applyMatrix4(c), w.end.applyMatrix4(c);
959
959
  const D = new S(), A = new S();
@@ -1000,10 +1000,10 @@ class Lt extends Ae {
1000
1000
  const o = e.params.Line2 !== void 0 && e.params.Line2.threshold || 0;
1001
1001
  E = e.ray;
1002
1002
  const c = this.matrixWorld, r = this.geometry, a = this.material;
1003
- k = a.linewidth + o, r.boundingSphere === null && r.computeBoundingSphere(), _.copy(r.boundingSphere).applyMatrix4(c);
1003
+ z = a.linewidth + o, r.boundingSphere === null && r.computeBoundingSphere(), _.copy(r.boundingSphere).applyMatrix4(c);
1004
1004
  let l;
1005
1005
  if (i)
1006
- l = k * 0.5;
1006
+ l = z * 0.5;
1007
1007
  else {
1008
1008
  const u = Math.max(
1009
1009
  s.near,
@@ -1020,7 +1020,7 @@ class Lt extends Ae {
1020
1020
  r.boundingBox === null && r.computeBoundingBox(), U.copy(r.boundingBox).applyMatrix4(c);
1021
1021
  let m;
1022
1022
  if (i)
1023
- m = k * 0.5;
1023
+ m = z * 0.5;
1024
1024
  else {
1025
1025
  const u = Math.max(
1026
1026
  s.near,
@@ -1091,9 +1091,9 @@ export {
1091
1091
  ve as B,
1092
1092
  Et as I,
1093
1093
  Lt as L,
1094
- kt as M,
1094
+ zt as M,
1095
1095
  Se as N,
1096
- zt as P,
1096
+ kt as P,
1097
1097
  st as R,
1098
1098
  Z as a,
1099
1099
  ft as g
package/dist/index2.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var be=Object.defineProperty,ye=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var re=Math.pow,te=(n,e,t)=>e in n?be(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,k=(n,e)=>{for(var t in e||(e={}))ie.call(e,t)&&te(n,t,e[t]);if(U)for(var t of U(e))se.call(e,t)&&te(n,t,e[t]);return n},$=(n,e)=>ye(n,ge(e));var ne=(n,e)=>{var t={};for(var i in n)ie.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&U)for(var i of U(n))e.indexOf(i)<0&&se.call(n,i)&&(t[i]=n[i]);return t};var oe=(n,e,t)=>new Promise((i,s)=>{var a=c=>{try{r(t.next(c))}catch(u){s(u)}},l=c=>{try{r(t.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,l);r((t=t.apply(n,e)).next())});const L=require("d3-array"),Y=require("earcut"),o=require("three"),Me=require("@turf/boolean-clockwise"),Z=require("./polar2Cartesian.js"),we=require("delaunator"),xe=require("@turf/boolean-point-in-polygon"),N=require("d3-geo"),Se=require("d3-geo-voronoi"),ae=require("d3-scale"),je=require("three/examples/jsm/lines/LineSegmentsGeometry"),Ce=require("three/examples/jsm/renderers/CSS2DRenderer"),ce=require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo-projection");const Ae=0,H=1,Pe=2,Be=!1;class me{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 o.Material)return e;if(e instanceof R?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof o.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof R)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof o.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof o.Material){for(const i of Object.values(e))i instanceof o.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 o.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof o.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 Ie=(n,e=1)=>{const t=new o.BufferGeometry;t.setAttribute("position",new o.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new o.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,s=new o.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 be=Object.defineProperty,ye=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var re=Math.pow,te=(n,e,t)=>e in n?be(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,z=(n,e)=>{for(var t in e||(e={}))ie.call(e,t)&&te(n,t,e[t]);if(U)for(var t of U(e))se.call(e,t)&&te(n,t,e[t]);return n},$=(n,e)=>ye(n,ge(e));var ne=(n,e)=>{var t={};for(var i in n)ie.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&U)for(var i of U(n))e.indexOf(i)<0&&se.call(n,i)&&(t[i]=n[i]);return t};var oe=(n,e,t)=>new Promise((i,s)=>{var o=c=>{try{r(t.next(c))}catch(u){s(u)}},l=c=>{try{r(t.throw(c))}catch(u){s(u)}},r=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,l);r((t=t.apply(n,e)).next())});const L=require("d3-array"),Y=require("earcut"),a=require("three"),Me=require("@turf/boolean-clockwise"),Z=require("./polar2Cartesian.js"),we=require("delaunator"),xe=require("@turf/boolean-point-in-polygon"),N=require("d3-geo"),Se=require("d3-geo-voronoi"),ae=require("d3-scale"),je=require("three/examples/jsm/lines/LineSegmentsGeometry"),Ce=require("three/examples/jsm/renderers/CSS2DRenderer"),ce=require("three/examples/jsm/renderers/CSS3DRenderer");require("d3-geo-projection");const Ae=0,H=1,Be=2,Pe=!1;class me{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 a.Material)return e;if(e instanceof R?(e.disposeTrack&&e.object3d?this.track(e.object3d):this.resources.add(e),Object.values(e.materialList).map(t=>this.track(t))):(e instanceof a.Object3D||Reflect.has(e,"dispose"))&&this.resources.add(e),e instanceof R)e.children.forEach(t=>{t.disposeTrack=!1}),this.track(e.children);else if(e instanceof a.Object3D){const t=e;this.track(t.geometry),this.track(t.material),this.track(t.children)}else if(e instanceof a.Material){for(const i of Object.values(e))i instanceof a.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 a.Texture||Array.isArray(s))&&this.track(s)}}}else this.disposeVideo&&e.isVideoTexture&&e.source.data&&this.resources.add(e.source.data);return e}dispose(){const e=[];for(const t of this.resources)t instanceof a.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 Ie=(n,e=1)=>{const t=new a.BufferGeometry;t.setAttribute("position",new a.Float32BufferAttribute(new Array(e*3).fill(0),3)),t.setAttribute("scaleAtt",new a.Float32BufferAttribute(new Array(e).fill(1),1));const i=n.material,s=new a.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 o.Points(t,s)},De=(n,e)=>{const t=new o.Object3D;e.forEach((i,s)=>{const a=Z.parseVector3(i.position),l=Z.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(l),t.updateMatrix();const r=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(s,r);else if(n instanceof o.Points||n.type==="Points"){const u=n.geometry,v=u.attributes.position.array,d=u.attributes.scaleAtt.array,p=new o.Vector3,h=new o.Vector3,m=new o.Quaternion,f=s*3,b=s*1;r.decompose(p,m,h),v[f]=p.x,v[f+1]=p.y,v[f+2]=p.z,d[b]=Math.max(h.x,h.y,h.z),u.attributes.position.needsUpdate=!0,u.attributes.scaleAtt.needsUpdate=!0}})};class Oe{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class Ve extends Oe{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}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){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const s=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=s,s}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)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class R extends Ve{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0,this.isDispose=!1}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}lookAt(e){const t=e instanceof o.Vector3?e:new o.Vector3(...e);this.object3d.lookAt(t)}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=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.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(Ae),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Pe),this}createGroup(){return this.object3d=new o.Group,this}createMesh(...e){return this.object3d=new o.Mesh(...e),this}createPoints(...e){return this.object3d=new o.Points(...e),this}createCSS2DObject(e){return this.object3d=new Ce.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ce.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ce.CSS3DSprite(e),this}createSprite(e){return this.object3d=new o.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new o.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new o.Vector3),center:e.getCenter(new o.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return oe(this,null,function*(){var u,v;const t=(u=e==null?void 0:e.recursive)!=null?u:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:s,objectOptions:a}=this;let l=e==null?void 0:e.create,r,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?r=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(l===void 0&&(l=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const h=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)d.object3d=Ie(this.object3d,h);else{const m=this.object3d,f=i?this.cloneMaterial():m.material;d.object3d=new o.InstancedMesh(m.geometry,f,h)}De(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),r=yield this.lead.draw(s,$(k({},a||{}),{create:l,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId&&d.keyName?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:r})))),r.isInstantiate=!0,r})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(e=!0){var t,i;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(s=>{s.enableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.add(this),this.object3d.layers.enable(H)),this.isBloom=!0}disableBloom(e=!0){var t,i;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(s=>{s.disableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.delete(this),this.object3d.layers.disable(H)),this.isBloom=!1}dispose(){var e;if(!this.isDispose&&(this.isDispose=!0,super.dispose(),this.isBloom&&(this.disableBloom(!1),(e=this.pencil.composerController)==null||e.checkBloomComposerActive()),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack)){const t=new me;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Te(n,e){return n.map(t=>{const i=[];let s;return t.forEach(a=>{if(s){const l=N.geoDistance(a,s)*180/Math.PI;if(l>e){const r=N.geoInterpolate(s,a),c=1/Math.ceil(l/e);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=a)}),i})}function Ee(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const a=Math.round(re(360/n,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=h=>h/l*360%360-180,c=h=>Math.acos(2*h/a-1)/Math.PI*180-90,u=h=>a*(Math.cos((h+90)*Math.PI/180)+1)/2,v=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],d=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,p=[];for(let h=v[0];h<=v[1];h++){const m=r(h);d(m)&&p.push([m,c(h)])}return p}function J(n,e,t=!1){return t?N.geoContains(e,n):xe(n,e)}function ze(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[a,l]]=N.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(l-s))<e)return[];const r=i>a||l>=89||s<=-89;return Ee(e,{minLng:i,maxLng:a,minLat:s,maxLat:l}).filter(c=>J(c,t,r))}function ke(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Te(n,e),a=L.merge(s),l=ze(n,e),r=[...a,...l],c={type:"Polygon",coordinates:n},[[u,v],[d,p]]=N.geoBounds(c),h=u>d||p>=89||v<=-89;let m=[];if(h){const g=Se.geoVoronoi(r).triangles(),S=new Map(r.map(([P,B],E)=>[`${P}-${B}`,E]));g.features.forEach(P=>{const B=P.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(B.forEach(([I,F])=>{const W=`${I}-${F}`;S.has(W)&&E.push(S.get(W))}),E.length===3){if(E.some(I=>I<a.length)){const I=P.properties.circumcenter;if(!J(I,c,h))return}m.push(...E)}})}else if(l.length){const g=we.from(r);for(let S=0,P=g.triangles.length;S<P;S+=3){const B=[2,1,0].map(I=>g.triangles[S+I]),E=B.map(I=>r[I]);if(B.some(I=>I<a.length)){const I=[0,1].map(F=>L.mean(E,W=>W[F]));if(!J(I,c,h))continue}m.push(...B)}}else{const{vertices:g,holes:S=[]}=Y.flatten(s);m=Y(g,S,2)}let f=t?[t[0],t[2]]:L.extent(r,g=>g[0]),b=t?[t[1],t[3]]:L.extent(r,g=>g[1]);if(i){const[g,S]=i([f[0],b[0]]),[P,B]=i([f[1],b[1]]);f=[g,P],b=[-S,-B]}const j=ae.scaleLinear(f,[0,1]),C=ae.scaleLinear(b,[0,1]),D=r.map(([g,S])=>{if(i){const[P,B]=i([g,S]);return[j(P),C(-B)]}else return[j(g),C(S)]});return{contour:s,triangles:{points:r,indices:m,uvs:D}}}const le=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(n,e,t,i){const s=n.map(a=>a.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,e]}return t?Z.polar2Cartesian(l,r,e):[l,r,e]}));return Y.flatten(s)}function Le(n,e,t,i,s){const{vertices:a,holes:l}=q(n,e,i,s),{vertices:r}=q(n,t,i,s),c=L.merge([r,a]),u=Math.round(r.length/3),v=new Set(l);let d=0;const p=[];for(let m=0;m<u;m++){let f=m+1;if(f===u)f=d;else if(v.has(f)){const b=f;f=d,d=b}p.push(m,m+u,f+u),p.push(f+u,f,m)}const h=[];for(let m=1;m>=0;m--)for(let f=0;f<u;f+=1)h.push(f/(u-1),m);return{indices:p,vertices:c,uvs:h,topVerts:r}}function ue(n,e,t,i,s,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:q([n.points],e,s,a).vertices,uvs:t}}const ve=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:a=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{n.forEach(j=>{Me(j)||j.reverse()});const{contour:v,triangles:d}=ke(n,{resolution:i,bbox:u,projection:c});let p={},h;a&&(p=Le(v,e!=null?e:t,t!=null?t:e,s,c),h=p.topVerts);let m=[];(l||r)&&(m=L.merge(d.uvs));let f={};l&&(f=ue(d,e,m,!1,s,c));let b={};return r&&(b=ue(d,t,m,!0,s,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:f,topCap:b,topVerts:h}};class Ne extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=k({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:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:h,bottomCap:m,topCap:f}=ve(k({},this.parameters));let b=[],j=[],C=[],D=0;const A=g=>{const S=Math.round(b.length/3),P=C.length;b=b.concat(g.vertices),j=j.concat(g.uvs),C=C.concat(S?g.indices.map(B=>B+S):g.indices),this.addGroup(P,C.length-P,D++)};s&&a&&A(f),r&&(A(p),this.userData.topVerts=u?q(d,i+u,c,v).vertices:h),l&&A(m),s&&!a&&A(f),this.setIndex(C),this[le]("position",new o.Float32BufferAttribute(b,3)),this[le]("uv",new o.Float32BufferAttribute(j,2)),this.computeVertexNormals()}}const We=`
3
+ ${o.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
+ `},new a.Points(t,s)},De=(n,e)=>{const t=new a.Object3D;e.forEach((i,s)=>{const o=Z.parseVector3(i.position),l=Z.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(l),t.updateMatrix();const r=t.matrix.clone();if(n instanceof a.InstancedMesh||n.isInstantiate)n.setMatrixAt(s,r);else if(n instanceof a.Points||n.type==="Points"){const u=n.geometry,v=u.attributes.position.array,d=u.attributes.scaleAtt.array,p=new a.Vector3,h=new a.Vector3,m=new a.Quaternion,f=s*3,b=s*1;r.decompose(p,m,h),v[f]=p.x,v[f+1]=p.y,v[f+2]=p.z,d[b]=Math.max(h.x,h.y,h.z),u.attributes.position.needsUpdate=!0,u.attributes.scaleAtt.needsUpdate=!0}})};class Oe{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const i=this.lead.handlePick([this],e,t);this.onPointerIndex.push(i)}onClick(e){this.onPointerEvent("click",e)}onPointerEnter(e){this.onPointerEvent("enter",e)}onPointerLeave(e){this.onPointerEvent("leave",e)}onPointerMove(e){this.onPointerEvent("move",e)}onPointerDown(e){this.onPointerEvent("down",e)}dispose(){this.onPointerIndex.forEach(e=>{this.lead.removePick(e)})}}class Ve extends Oe{constructor(){super(...arguments),this.userData={},this.materialList={},this.useMaterialType="origin",this.disposeMaterialIfNotUsed=!0}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){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const s=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=s,s}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)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class R extends Ve{constructor(){super(...arguments),this.key="",this.objectType="BaseObject",this.userData={},this.isPrefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.isBaseObject=!0,this.disposeTrack=!0,this.isDispose=!1}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}lookAt(e){const t=e instanceof a.Vector3?e:new a.Vector3(...e);this.object3d.lookAt(t)}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=>{var i;this.lead.objMap.get(t)?(i=this.lead.objMap.get(t))==null||i.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(Ae),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Be),this}createGroup(){return this.object3d=new a.Group,this}createMesh(...e){return this.object3d=new a.Mesh(...e),this}createPoints(...e){return this.object3d=new a.Points(...e),this}createCSS2DObject(e){return this.object3d=new Ce.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ce.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ce.CSS3DSprite(e),this}createSprite(e){return this.object3d=new a.Sprite(e),this}attach(...e){return[...e].forEach(t=>{this.object3d.attach(t.object3d)}),this}getSize(){const e=new a.Box3().setFromObject(this.object3d);return{min:e.min,max:e.max,size:e.getSize(new a.Vector3),center:e.getCenter(new a.Vector3)}}setTop(e){this.object3d&&(this.object3d.renderOrder=e)}traverse(e){e(this),this.children.forEach(t=>{t.traverse(e)})}instantiate(e){return oe(this,null,function*(){var u,v;const t=(u=e==null?void 0:e.recursive)!=null?u:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:s,objectOptions:o}=this;let l=e==null?void 0:e.create,r,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?r=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(l===void 0&&(l=d=>{var p;if(this.object3d){if((p=e==null?void 0:e.instancedAttr)!=null&&p.length){const h=e.instancedAttr.length;if(this.object3d instanceof a.Sprite)d.object3d=Ie(this.object3d,h);else{const m=this.object3d,f=i?this.cloneMaterial():m.material;d.object3d=new a.InstancedMesh(m.geometry,f,h)}De(d.object3d,e==null?void 0:e.instancedAttr)}else d.object3d=this.object3d.clone(!1),i&&d.object3d.material&&(d.object3d.material=this.cloneMaterial());d.object3d.userData.prefab&&delete d.object3d.userData.prefab}}),r=yield this.lead.draw(s,$(z({},o||{}),{create:l,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:c}))),this.isBloom&&r.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId&&d.keyName?`${d.keyName}-${d.keyUId}`:d.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,target:r})))),r.isInstantiate=!0,r})}erase(){this.lead.erase(this)}handleMaterialChange(e){}enableBloom(e=!0){var t,i,s;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(o=>{o.enableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.add(this),this.object3d.layers.enable(H)),(s=this.pencil.composerController)==null||s.checkBloomComposerActive(),this.isBloom=!0}disableBloom(e=!0){var t,i,s;if(!((t=this.pencil.composerController)!=null&&t.bloomComposer)){console.warn("err:pencil.options.bloom");return}if(e){this.traverse(o=>{o.disableBloom(!1)});return}this.object3d&&((i=this.pencil.composerController)==null||i.bloomSelection.delete(this),this.object3d.layers.disable(H)),(s=this.pencil.composerController)==null||s.checkBloomComposerActive(),this.isBloom=!1}dispose(){var e,t;if(!this.isDispose&&(this.isDispose=!0,super.dispose(),this.isBloom&&(this.disableBloom(!1),(e=this.pencil.composerController)==null||e.checkBloomComposerActive()),(t=this.lead)==null||t.disableCursor(this),this.lead&&(this.lead.objects.delete(this.key),this.lead.objectWrapChindIdMap.delete(this),this.object3d&&this.lead.objMap.delete(this.object3d)),this.disposeTrack)){const i=new me;i.disposeMaterial=!1,i.track(this),i.dispose()}}}function Te(n,e){return n.map(t=>{const i=[];let s;return t.forEach(o=>{if(s){const l=N.geoDistance(o,s)*180/Math.PI;if(l>e){const r=N.geoInterpolate(s,o),c=1/Math.ceil(l/e);let u=c;for(;u<1;)i.push(r(u)),u+=c}}i.push(s=o)}),i})}function Ee(n,{minLng:e,maxLng:t,minLat:i,maxLat:s}={}){const o=Math.round(re(360/n,2)/Math.PI),l=(1+Math.sqrt(5))/2,r=h=>h/l*360%360-180,c=h=>Math.acos(2*h/o-1)/Math.PI*180-90,u=h=>o*(Math.cos((h+90)*Math.PI/180)+1)/2,v=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):o-1],d=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,p=[];for(let h=v[0];h<=v[1];h++){const m=r(h);d(m)&&p.push([m,c(h)])}return p}function J(n,e,t=!1){return t?N.geoContains(e,n):xe(n,e)}function ke(n,e){const t={type:"Polygon",coordinates:n},[[i,s],[o,l]]=N.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(l-s))<e)return[];const r=i>o||l>=89||s<=-89;return Ee(e,{minLng:i,maxLng:o,minLat:s,maxLat:l}).filter(c=>J(c,t,r))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const s=Te(n,e),o=L.merge(s),l=ke(n,e),r=[...o,...l],c={type:"Polygon",coordinates:n},[[u,v],[d,p]]=N.geoBounds(c),h=u>d||p>=89||v<=-89;let m=[];if(h){const g=Se.geoVoronoi(r).triangles(),S=new Map(r.map(([B,P],E)=>[`${B}-${P}`,E]));g.features.forEach(B=>{const P=B.geometry.coordinates[0].slice(0,3).reverse(),E=[];if(P.forEach(([I,F])=>{const W=`${I}-${F}`;S.has(W)&&E.push(S.get(W))}),E.length===3){if(E.some(I=>I<o.length)){const I=B.properties.circumcenter;if(!J(I,c,h))return}m.push(...E)}})}else if(l.length){const g=we.from(r);for(let S=0,B=g.triangles.length;S<B;S+=3){const P=[2,1,0].map(I=>g.triangles[S+I]),E=P.map(I=>r[I]);if(P.some(I=>I<o.length)){const I=[0,1].map(F=>L.mean(E,W=>W[F]));if(!J(I,c,h))continue}m.push(...P)}}else{const{vertices:g,holes:S=[]}=Y.flatten(s);m=Y(g,S,2)}let f=t?[t[0],t[2]]:L.extent(r,g=>g[0]),b=t?[t[1],t[3]]:L.extent(r,g=>g[1]);if(i){const[g,S]=i([f[0],b[0]]),[B,P]=i([f[1],b[1]]);f=[g,B],b=[-S,-P]}const j=ae.scaleLinear(f,[0,1]),C=ae.scaleLinear(b,[0,1]),D=r.map(([g,S])=>{if(i){const[B,P]=i([g,S]);return[j(B),C(-P)]}else return[j(g),C(S)]});return{contour:s,triangles:{points:r,indices:m,uvs:D}}}const le=new a.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function q(n,e,t,i){const s=n.map(o=>o.map(([l,r])=>{if(i){const[c,u]=i([l,r]);return[c,-u,e]}return t?Z.polar2Cartesian(l,r,e):[l,r,e]}));return Y.flatten(s)}function Le(n,e,t,i,s){const{vertices:o,holes:l}=q(n,e,i,s),{vertices:r}=q(n,t,i,s),c=L.merge([r,o]),u=Math.round(r.length/3),v=new Set(l);let d=0;const p=[];for(let m=0;m<u;m++){let f=m+1;if(f===u)f=d;else if(v.has(f)){const b=f;f=d,d=b}p.push(m,m+u,f+u),p.push(f+u,f,m)}const h=[];for(let m=1;m>=0;m--)for(let f=0;f<u;f+=1)h.push(f/(u-1),m);return{indices:p,vertices:c,uvs:h,topVerts:r}}function ue(n,e,t,i,s,o){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:q([n.points],e,s,o).vertices,uvs:t}}const ve=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:s=!0,hasSide:o=!0,hasBottom:l=!1,hasTop:r=!1,projection:c,bbox:u})=>{n.forEach(j=>{Me(j)||j.reverse()});const{contour:v,triangles:d}=ze(n,{resolution:i,bbox:u,projection:c});let p={},h;o&&(p=Le(v,e!=null?e:t,t!=null?t:e,s,c),h=p.topVerts);let m=[];(l||r)&&(m=L.merge(d.uvs));let f={};l&&(f=ue(d,e,m,!1,s,c));let b={};return r&&(b=ue(d,t,m,!0,s,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:f,topCap:b,topVerts:h}};class Ne extends a.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=z({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:l,hasSide:r,cartesian:c,userDataRsoOffset:u,projection:v}=this.parameters,{contour:d,sideTorso:p,topVerts:h,bottomCap:m,topCap:f}=ve(z({},this.parameters));let b=[],j=[],C=[],D=0;const A=g=>{const S=Math.round(b.length/3),B=C.length;b=b.concat(g.vertices),j=j.concat(g.uvs),C=C.concat(S?g.indices.map(P=>P+S):g.indices),this.addGroup(B,C.length-B,D++)};s&&o&&A(f),r&&(A(p),this.userData.topVerts=u?q(d,i+u,c,v).vertices:h),l&&A(m),s&&!o&&A(f),this.setIndex(C),this[le]("position",new a.Float32BufferAttribute(b,3)),this[le]("uv",new a.Float32BufferAttribute(j,2)),this.computeVertexNormals()}}const We=`
5
5
  #include <fog_pars_fragment>
6
6
  #include <logdepthbuf_pars_fragment>
7
7
 
@@ -137,4 +137,4 @@ void main() {
137
137
  #include <logdepthbuf_vertex>
138
138
  #include <fog_vertex>
139
139
  }
140
- `;class _e extends o.ShaderMaterial{constructor(e={}){const C=e,{lineWidth:t=1,color:i="#ffffff",opacity:s=1,map:a=null,dashOffset:l=0,dashArray:r=0,dashRatio:c=0,sizeAttenuation:u=!0,offsetLoop:v=!0,offset:d=new o.Vector2(0,0),scaleDown:p=0,alphaMap:h=void 0,alphaTest:m=0,repeat:f=new o.Vector2(1,1),resolution:b=new o.Vector2(1,1)}=C,j=ne(C,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super($(k({},j),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(i)},opacity:{value:s},map:{value:a},useMap:{value:a?1:0},resolution:{value:b},sizeAttenuation:{value:u?1:0},offset:{value:d},offsetLoop:{value:v?1:0},dashArray:{value:r},dashOffset:{value:l},dashRatio:{value:c},useDash:{value:r>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:h},useAlphaMap:{value:h?1:0},repeat:{value:f}},vertexShader:Ue,fragmentShader:We})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new o.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const K=new o.Vector4,de=new o.Vector3,he=new o.Vector3,M=new o.Vector4,w=new o.Vector4,O=new o.Vector4,Q=new o.Vector3,X=new o.Matrix4,x=new o.Line3,fe=new o.Vector3,_=new o.Box3,G=new o.Sphere,V=new o.Vector4;let T,z;function pe(n,e,t){return V.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),V.multiplyScalar(1/V.w),V.x=z/t.width,V.y=z/t.height,V.applyMatrix4(n.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ge(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,a=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){x.start.fromBufferAttribute(s,r),x.end.fromBufferAttribute(a,r),x.applyMatrix4(t);const u=new o.Vector3,v=new o.Vector3;T.distanceSqToSegment(x.start,x.end,v,u),v.distanceTo(u)<z*.5&&e.push({point:v,pointOnLine:u,distance:T.origin.distanceTo(v),object:n,face:null,faceIndex:r,uv:null,uv1:null})}}function Re(n,e,t){const i=e.projectionMatrix,a=n.material.resolution,l=n.matrixWorld,r=n.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,v=Math.min(r.instanceCount,c.count),d=-e.near;T.at(1,O),O.w=1,O.applyMatrix4(e.matrixWorldInverse),O.applyMatrix4(i),O.multiplyScalar(1/O.w),O.x*=a.x/2,O.y*=a.y/2,O.z=0,Q.copy(O),X.multiplyMatrices(e.matrixWorldInverse,l);for(let p=0,h=v;p<h;p++){if(M.fromBufferAttribute(c,p),w.fromBufferAttribute(u,p),M.w=1,w.w=1,M.applyMatrix4(X),w.applyMatrix4(X),M.z>d&&w.z>d)continue;if(M.z>d){const D=M.z-w.z,A=(M.z-d)/D;M.lerp(w,A)}else if(w.z>d){const D=w.z-M.z,A=(w.z-d)/D;w.lerp(M,A)}M.applyMatrix4(i),w.applyMatrix4(i),M.multiplyScalar(1/M.w),w.multiplyScalar(1/w.w),M.x*=a.x/2,M.y*=a.y/2,w.x*=a.x/2,w.y*=a.y/2,x.start.copy(M),x.start.z=0,x.end.copy(w),x.end.z=0;const f=x.closestPointToPointParameter(Q,!0);x.at(f,fe);const b=o.MathUtils.lerp(M.z,w.z,f),j=b>=-1&&b<=1,C=Q.distanceTo(fe)<z*.5;if(j&&C){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(u,p),x.start.applyMatrix4(l),x.end.applyMatrix4(l);const D=new o.Vector3,A=new o.Vector3;T.distanceSqToSegment(x.start,x.end,A,D),t.push({point:A,pointOnLine:D,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class qe extends o.Mesh{constructor(e=new je.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 l=0,r=0,c=t.count;l<c;l++,r+=2)de.fromBufferAttribute(t,l),he.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+de.distanceTo(he);const a=new o.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new o.InterleavedBufferAttribute(a,1,0)),e.setAttribute("instanceDistanceEnd",new o.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;T=e.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;z=c.linewidth+a,r.boundingSphere===null&&r.computeBoundingSphere(),G.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=z*.5;else{const d=Math.max(s.near,G.distanceToPoint(T.origin));u=pe(s,d,c.resolution)}if(G.radius+=u,T.intersectsSphere(G)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),_.copy(r.boundingBox).applyMatrix4(l);let v;if(i)v=z*.5;else{const d=Math.max(s.near,_.distanceToPoint(T.origin));v=pe(s,d,c.resolution)}_.expandByScalar(v),T.intersectsBox(_)!==!1&&(i?Ge(this,t):Re(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(K),this.material.uniforms.resolution.value.set(K.z,K.w))}}const y=class y extends R{constructor(e){super(),this.objectType="Node",this.onNodePointerIndex=[],this.options=k({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,a=t.width,l=t.height;let r=0,c=0;a>i?t.left>0&&(r=-t.left):t.left<0?r=-t.left:t.right>i&&(r=i-t.right,t.left+r<0&&(r=-t.left)),l>s?t.top>0&&(c=-t.top):t.top<0?c=-t.top:t.bottom>s&&(c=s-t.bottom,t.top+c<0&&(c=-t.top)),(r!==0||c!==0)&&(e.style.transform=`translate(${r}px, ${c}px)`)}ensureVisible(){const e=this.options.children;e&&(e.style.transform&&(e.style.transform=""),!y.observerMap.has(e)&&(y.sharedObserver||(y.sharedObserver=new IntersectionObserver(t=>{t.forEach(i=>{const s=i.target,a=y.observerMap.get(s);a&&i.isIntersecting&&(a.moveElementToViewport(),y.observerMap.delete(s),y.sharedObserver&&(y.sharedObserver.unobserve(s),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)))})})),y.observerMap.set(e,this),y.sharedObserver.observe(e)))}onPointerEvent(e,t){const i=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){const e=this.options.children;e&&y.sharedObserver&&(y.observerMap.delete(e),y.sharedObserver.unobserve(e),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)),this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}};y.observerMap=new Map;let ee=y;exports.BLOOM_SCENE=H;exports.BaseObject=R;exports.IS_DEV=Be;exports.LineSegments2=qe;exports.MeshLineMaterial=_e;exports.Node=ee;exports.PolygonGeometry=Ne;exports.ResourceTracker=me;exports.getMetas=ve;
140
+ `;class _e extends a.ShaderMaterial{constructor(e={}){const C=e,{lineWidth:t=1,color:i="#ffffff",opacity:s=1,map:o=null,dashOffset:l=0,dashArray:r=0,dashRatio:c=0,sizeAttenuation:u=!0,offsetLoop:v=!0,offset:d=new a.Vector2(0,0),scaleDown:p=0,alphaMap:h=void 0,alphaTest:m=0,repeat:f=new a.Vector2(1,1),resolution:b=new a.Vector2(1,1)}=C,j=ne(C,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super($(z({},j),{uniforms:{lineWidth:{value:t},color:{value:new a.Color(i)},opacity:{value:s},map:{value:o},useMap:{value:o?1:0},resolution:{value:b},sizeAttenuation:{value:u?1:0},offset:{value:d},offsetLoop:{value:v?1:0},dashArray:{value:r},dashOffset:{value:l},dashRatio:{value:c},useDash:{value:r>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:h},useAlphaMap:{value:h?1:0},repeat:{value:f}},vertexShader:Ue,fragmentShader:We})),this.type="MeshLineMaterial"}get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new a.Color(e)}get opacity(){var e;return((e=this.uniforms)==null?void 0:e.opacity.value)||1}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms&&(this.uniforms.alphaTest.value=e)}get map(){return this.uniforms.map.value}set map(e){this.uniforms.map.value=e,this.uniforms.useMap.value=e?1:0}get repeat(){return this.uniforms.repeat.value}set repeat(e){this.uniforms.repeat.value.copy(e)}get lineWidth(){return this.uniforms.lineWidth.value}set lineWidth(e){this.uniforms.lineWidth.value=e}get sizeAttenuation(){return this.uniforms.sizeAttenuation.value===1}set sizeAttenuation(e){this.uniforms.sizeAttenuation.value=e?1:0}}const K=new a.Vector4,de=new a.Vector3,he=new a.Vector3,M=new a.Vector4,w=new a.Vector4,O=new a.Vector4,Q=new a.Vector3,X=new a.Matrix4,x=new a.Line3,fe=new a.Vector3,_=new a.Box3,G=new a.Sphere,V=new a.Vector4;let T,k;function pe(n,e,t){return V.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),V.multiplyScalar(1/V.w),V.x=k/t.width,V.y=k/t.height,V.applyMatrix4(n.projectionMatrixInverse),V.multiplyScalar(1/V.w),Math.abs(Math.max(V.x,V.y))}function Ge(n,e){const t=n.matrixWorld,i=n.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,l=Math.min(i.instanceCount,s.count);for(let r=0,c=l;r<c;r++){x.start.fromBufferAttribute(s,r),x.end.fromBufferAttribute(o,r),x.applyMatrix4(t);const u=new a.Vector3,v=new a.Vector3;T.distanceSqToSegment(x.start,x.end,v,u),v.distanceTo(u)<k*.5&&e.push({point:v,pointOnLine:u,distance:T.origin.distanceTo(v),object:n,face:null,faceIndex:r,uv:null,uv1:null})}}function Re(n,e,t){const i=e.projectionMatrix,o=n.material.resolution,l=n.matrixWorld,r=n.geometry,c=r.attributes.instanceStart,u=r.attributes.instanceEnd,v=Math.min(r.instanceCount,c.count),d=-e.near;T.at(1,O),O.w=1,O.applyMatrix4(e.matrixWorldInverse),O.applyMatrix4(i),O.multiplyScalar(1/O.w),O.x*=o.x/2,O.y*=o.y/2,O.z=0,Q.copy(O),X.multiplyMatrices(e.matrixWorldInverse,l);for(let p=0,h=v;p<h;p++){if(M.fromBufferAttribute(c,p),w.fromBufferAttribute(u,p),M.w=1,w.w=1,M.applyMatrix4(X),w.applyMatrix4(X),M.z>d&&w.z>d)continue;if(M.z>d){const D=M.z-w.z,A=(M.z-d)/D;M.lerp(w,A)}else if(w.z>d){const D=w.z-M.z,A=(w.z-d)/D;w.lerp(M,A)}M.applyMatrix4(i),w.applyMatrix4(i),M.multiplyScalar(1/M.w),w.multiplyScalar(1/w.w),M.x*=o.x/2,M.y*=o.y/2,w.x*=o.x/2,w.y*=o.y/2,x.start.copy(M),x.start.z=0,x.end.copy(w),x.end.z=0;const f=x.closestPointToPointParameter(Q,!0);x.at(f,fe);const b=a.MathUtils.lerp(M.z,w.z,f),j=b>=-1&&b<=1,C=Q.distanceTo(fe)<k*.5;if(j&&C){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(u,p),x.start.applyMatrix4(l),x.end.applyMatrix4(l);const D=new a.Vector3,A=new a.Vector3;T.distanceSqToSegment(x.start,x.end,A,D),t.push({point:A,pointOnLine:D,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class qe extends a.Mesh{constructor(e=new je.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 l=0,r=0,c=t.count;l<c;l++,r+=2)de.fromBufferAttribute(t,l),he.fromBufferAttribute(i,l),s[r]=r===0?0:s[r-1],s[r+1]=s[r]+de.distanceTo(he);const o=new a.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new a.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new a.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;T=e.ray;const l=this.matrixWorld,r=this.geometry,c=this.material;k=c.linewidth+o,r.boundingSphere===null&&r.computeBoundingSphere(),G.copy(r.boundingSphere).applyMatrix4(l);let u;if(i)u=k*.5;else{const d=Math.max(s.near,G.distanceToPoint(T.origin));u=pe(s,d,c.resolution)}if(G.radius+=u,T.intersectsSphere(G)===!1)return;r.boundingBox===null&&r.computeBoundingBox(),_.copy(r.boundingBox).applyMatrix4(l);let v;if(i)v=k*.5;else{const d=Math.max(s.near,_.distanceToPoint(T.origin));v=pe(s,d,c.resolution)}_.expandByScalar(v),T.intersectsBox(_)!==!1&&(i?Ge(this,t):Re(this,s,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(K),this.material.uniforms.resolution.value.set(K.z,K.w))}}const y=class y extends R{constructor(e){super(),this.objectType="Node",this.onNodePointerIndex=[],this.options=z({type:"2d"},e)}create(){const{position:e,children:t}=this.options,i=document.createElement("div");this.element=i,t&&i.appendChild(t),this.options.type==="3d"?this.createCSS3DObject(i):this.options.type==="3dSprite"?this.createCSS3DSprite(i):this.createCSS2DObject(i),e&&this.object3d.position.copy(e)}setChildren(e){this.options.children=e,this.element.innerHTML="",this.element.appendChild(e)}showAndEnsureVisible(){const e=this.options.children;e&&(e.style.visibility="hidden",this.show(),setTimeout(()=>{e.style.visibility="",this.ensureVisible()}))}moveElementToViewport(){const e=this.options.children;if(!e)return;const t=e.getBoundingClientRect(),i=window.innerWidth,s=window.innerHeight,o=t.width,l=t.height;let r=0,c=0;o>i?t.left>0&&(r=-t.left):t.left<0?r=-t.left:t.right>i&&(r=i-t.right,t.left+r<0&&(r=-t.left)),l>s?t.top>0&&(c=-t.top):t.top<0?c=-t.top:t.bottom>s&&(c=s-t.bottom,t.top+c<0&&(c=-t.top)),(r!==0||c!==0)&&(e.style.transform=`translate(${r}px, ${c}px)`)}ensureVisible(){const e=this.options.children;e&&(e.style.transform&&(e.style.transform=""),!y.observerMap.has(e)&&(y.sharedObserver||(y.sharedObserver=new IntersectionObserver(t=>{t.forEach(i=>{const s=i.target,o=y.observerMap.get(s);o&&i.isIntersecting&&(o.moveElementToViewport(),y.observerMap.delete(s),y.sharedObserver&&(y.sharedObserver.unobserve(s),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)))})})),y.observerMap.set(e,this),y.sharedObserver.observe(e)))}onPointerEvent(e,t){const i=this.lead.handlePickNode([this],e,t);this.onNodePointerIndex.push(i)}dispose(){const e=this.options.children;e&&y.sharedObserver&&(y.observerMap.delete(e),y.sharedObserver.unobserve(e),y.observerMap.size===0&&(y.sharedObserver.disconnect(),y.sharedObserver=void 0)),this.onNodePointerIndex.forEach(t=>{this.lead.removePickNode(t)}),super.dispose()}};y.observerMap=new Map;let ee=y;exports.BLOOM_SCENE=H;exports.BaseObject=R;exports.IS_DEV=Pe;exports.LineSegments2=qe;exports.MeshLineMaterial=_e;exports.Node=ee;exports.PolygonGeometry=Ne;exports.ResourceTracker=me;exports.getMetas=ve;