gl-draw 0.15.23 → 0.15.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,E=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(W)for(var t of W(e))ee.call(e,t)&&J(n,t,e[t]);return n},R=(n,e)=>me(n,ve(e));var re=(n,e)=>{var t={};for(var r in n)H.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&W)for(var r of W(n))e.indexOf(r)<0&&ee.call(n,r)&&(t[r]=n[r]);return t};var ie=(n,e,t)=>new Promise((r,i)=>{var c=l=>{try{s(t.next(l))}catch(a){i(a)}},u=l=>{try{s(t.throw(l))}catch(a){i(a)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(c,u);s((t=t.apply(n,e)).next())});const o=require("three"),ye=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),O=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),_=require("d3-array"),X=require("earcut"),be=require("@turf/boolean-clockwise"),ge=require("delaunator"),Me=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),se=require("d3-scale"),Se=require("three/examples/jsm/lines/LineSegmentsGeometry"),we=0,je=1,Ae=2,Ce=!1;class fe{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 Y?(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 Y)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 r of Object.values(e))r instanceof o.Texture&&this.track(r);const t=e;if(t.uniforms){for(const r of Object.values(t.uniforms))if(r){const i=r.value;(i instanceof o.Texture||Array.isArray(i))&&this.track(i)}}}else this.disposeVideo&&e instanceof o.VideoTexture&&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 Pe=(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 r=n.material,i=new o.PointsMaterial({size:10,map:r.map,alphaMap:r.alphaMap,color:r.color,blending:r.blending,depthTest:r.depthTest,depthWrite:!1,opacity:r.opacity,transparent:!0,alphaTest:r.alphaTest,sizeAttenuation:!1});return i.onBeforeCompile=c=>{c.vertexShader=`
1
+ "use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var te=Math.pow,J=(n,e,t)=>e in n?pe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,E=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(W)for(var t of W(e))ee.call(e,t)&&J(n,t,e[t]);return n},R=(n,e)=>me(n,ve(e));var re=(n,e)=>{var t={};for(var r in n)H.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&W)for(var r of W(n))e.indexOf(r)<0&&ee.call(n,r)&&(t[r]=n[r]);return t};var ie=(n,e,t)=>new Promise((r,i)=>{var c=l=>{try{s(t.next(l))}catch(a){i(a)}},u=l=>{try{s(t.throw(l))}catch(a){i(a)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(c,u);s((t=t.apply(n,e)).next())});const o=require("three"),ye=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),O=require("d3-geo");require("d3-geo-projection");const Q=require("./parseVector.js"),_=require("d3-array"),X=require("earcut"),be=require("@turf/boolean-clockwise"),ge=require("delaunator"),Me=require("@turf/boolean-point-in-polygon"),xe=require("d3-geo-voronoi"),se=require("d3-scale"),Se=require("three/examples/jsm/lines/LineSegmentsGeometry"),we=0,je=1,Ae=2,Ce=!1;class fe{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 Y?(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 Y)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 r of Object.values(e))r instanceof o.Texture&&this.track(r);const t=e;if(t.uniforms){for(const r of Object.values(t.uniforms))if(r){const i=r.value;(i instanceof o.Texture||Array.isArray(i))&&this.track(i)}}}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 Pe=(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 r=n.material,i=new o.PointsMaterial({size:10,map:r.map,alphaMap:r.alphaMap,color:r.color,blending:r.blending,depthTest:r.depthTest,depthWrite:!1,opacity:r.opacity,transparent:!0,alphaTest:r.alphaTest,sizeAttenuation:!1});return i.onBeforeCompile=c=>{c.vertexShader=`
2
2
  attribute float scaleAtt;
3
3
  ${c.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
4
  `},new o.Points(t,i)},Be=(n,e)=>{const t=new o.Object3D;e.forEach((r,i)=>{const c=Q.parseVector3(r.position),u=Q.parseVector3(r.scale||[1,1,1]);t.position.copy(c),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(i,s);else if(n instanceof o.Points||n.type==="Points"){const a=n.geometry,p=a.attributes.position.array,f=a.attributes.scaleAtt.array,m=new o.Vector3,d=new o.Vector3,v=new o.Quaternion,h=i*3,y=i*1;s.decompose(m,v,d),p[h]=m.x,p[h+1]=m.y,p[h+2]=m.z,f[y]=Math.max(d.x,d.y,d.z),a.attributes.position.needsUpdate=!0,a.attributes.scaleAtt.needsUpdate=!0}})};class De{constructor(){this.onPointerIndex=[]}onPointerEvent(e,t){const r=this.lead.handlePick([this],e,t);this.onPointerIndex.push(r)}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 Ie extends De{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(r=>{const i=r.userData;r.userData={};const c=r.clone();return r.userData=i,c});{const r=t.userData;t.userData={};const i=t.clone();return t.userData=r,i}}setMaterialList(e,t){const r=this.object3d;if(!r||!r.material)return;this.materialList.origin||(this.materialList.origin=r.material);const i=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=i,i}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 r=this.mList.get(e);if(!r)return;const i=this.object3d;Array.isArray(i.material)&&t!==void 0?i.material[t]=r:i.material=r}useMListByName(e,t){if(!this.mList)return;const r=this.mList.getKeyByName(e);r&&this.useMListById(r,t)}dispose(){super.dispose(),this.mList.rmBaseObjectMap(this,void 0,this.disposeMaterialIfNotUsed)}}class Y extends Ie{constructor(){super(...arguments),this.objectType="BaseObject",this.userData={},this.prefab=!1,this.isInstantiate=!1,this.isBloom=!1,this.disposeTrack=!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}get lookAt(){return this.object3d.lookAt}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 r;this.lead.objMap.get(t)?(r=this.lead.objMap.get(t))==null||r.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(we),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),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 ye.CSS2DObject(e),this}createCSS3DObject(e){return this.object3d=new ne.CSS3DObject(e),this}createCSS3DSprite(e){return this.object3d=new ne.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 ie(this,null,function*(){var l;const t=(l=e==null?void 0:e.recursive)!=null?l:!0,{objectType:r,objectOptions:i}=this,[,c]=r.split("#");let u=e==null?void 0:e.create;u===void 0&&(u=a=>{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 o.Sprite)a.object3d=Pe(this.object3d,f);else{const m=this.object3d,d=this.cloneMaterial();a.object3d=new o.InstancedMesh(m.geometry,d,f)}Be(a.object3d,e==null?void 0:e.instancedAttr)}else a.object3d=this.object3d.clone(!1),a.object3d.material&&(a.object3d.material=this.cloneMaterial());a.object3d.userData.prefab&&delete a.object3d.userData.prefab}});const s=yield this.lead.draw(c,R(E({},i||{}),{create:u,prefab:!1,key:(e==null?void 0:e.key)||(i==null?void 0:i.key),target:(e==null?void 0:e.target)||(i==null?void 0:i.target)}));return this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(a=>a.instantiate({target:s})))),s.isInstantiate=!0,s})}erase(){this.lead.erase(this)}handleMaterialChange(e){}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(super.dispose(),(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 fe;t.disposeMaterial=!1,t.track(this),t.dispose()}}}function Ve(n,e){return n.map(t=>{const r=[];let i;return t.forEach(c=>{if(i){const u=O.geoDistance(c,i)*180/Math.PI;if(u>e){const s=O.geoInterpolate(i,c),l=1/Math.ceil(u/e);let a=l;for(;a<1;)r.push(s(a)),a+=l}}r.push(i=c)}),r})}function Te(n,{minLng:e,maxLng:t,minLat:r,maxLat:i}={}){const c=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=d=>d/u*360%360-180,l=d=>Math.acos(2*d/c-1)/Math.PI*180-90,a=d=>c*(Math.cos((d+90)*Math.PI/180)+1)/2,p=[i!==void 0?Math.ceil(a(i)):0,r!==void 0?Math.floor(a(r)):c-1],f=e===void 0&&t===void 0?()=>!0:e===void 0?d=>d<=t:t===void 0?d=>d>=e:t>=e?d=>d>=e&&d<=t:d=>d>=e||d<=t,m=[];for(let d=p[0];d<=p[1];d++){const v=s(d);f(v)&&m.push([v,l(d)])}return m}function Z(n,e,t=!1){return t?O.geoContains(e,n):Me(n,e)}function ze(n,e){const t={type:"Polygon",coordinates:n},[[r,i],[c,u]]=O.geoBounds(t);if(Math.min(Math.abs(c-r),Math.abs(u-i))<e)return[];const s=r>c||u>=89||i<=-89;return Te(e,{minLng:r,maxLng:c,minLat:i,maxLat:u}).filter(l=>Z(l,t,s))}function Le(n,{resolution:e=1/0,bbox:t,projection:r}={}){const i=Ve(n,e),c=_.merge(i),u=ze(n,e),s=[...c,...u],l={type:"Polygon",coordinates:n},[[a,p],[f,m]]=O.geoBounds(l),d=a>f||m>=89||p<=-89;let v=[];if(d){const b=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,P],z)=>[`${C}-${P}`,z]));b.features.forEach(C=>{const P=C.geometry.coordinates[0].slice(0,3).reverse(),z=[];if(P.forEach(([B,q])=>{const k=`${B}-${q}`;S.has(k)&&z.push(S.get(k))}),z.length===3){if(z.some(B=>B<c.length)){const B=C.properties.circumcenter;if(!Z(B,l,d))return}v.push(...z)}})}else if(u.length){const b=ge.from(s);for(let S=0,C=b.triangles.length;S<C;S+=3){const P=[2,1,0].map(B=>b.triangles[S+B]),z=P.map(B=>s[B]);if(P.some(B=>B<c.length)){const B=[0,1].map(q=>_.mean(z,k=>k[q]));if(!Z(B,l,d))continue}v.push(...P)}}else{const{vertices:b,holes:S=[]}=X.flatten(i);v=X(b,S,2)}let h=t?[t[0],t[2]]:_.extent(s,b=>b[0]),y=t?[t[1],t[3]]:_.extent(s,b=>b[1]);if(r){const[b,S]=r([h[0],y[0]]),[C,P]=r([h[1],y[1]]);h=[b,C],y=[-S,-P]}const w=se.scaleLinear(h,[0,1]),j=se.scaleLinear(y,[0,1]),D=s.map(([b,S])=>{if(r){const[C,P]=r([b,S]);return[w(C),j(-P)]}else return[w(b),j(S)]});return{contour:i,triangles:{points:s,indices:v,uvs:D}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,r){const i=n.map(c=>c.map(([u,s])=>{if(r){const[l,a]=r([u,s]);return[l,-a,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(i)}function _e(n,e,t,r,i){const{vertices:c,holes:u}=G(n,e,r,i),{vertices:s}=G(n,t,r,i),l=_.merge([s,c]),a=Math.round(s.length/3),p=new Set(u);let f=0;const m=[];for(let v=0;v<a;v++){let h=v+1;if(h===a)h=f;else if(p.has(h)){const y=h;h=f,f=y}m.push(v,v+a,h+a),m.push(h+a,h,v)}const d=[];for(let v=1;v>=0;v--)for(let h=0;h<a;h+=1)d.push(h/(a-1),v);return{indices:m,vertices:l,uvs:d,topVerts:s}}function ae(n,e,t,r,i,c){return{indices:r?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,i,c).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:r=1,cartesian:i=!0,hasSide:c=!0,hasBottom:u=!1,hasTop:s=!1,projection:l,bbox:a})=>{n.forEach(w=>{be(w)||w.reverse()});const{contour:p,triangles:f}=Le(n,{resolution:r,bbox:a,projection:l});let m={},d;c&&(m=_e(p,e!=null?e:t,t!=null?t:e,i,l),d=m.topVerts);let v=[];(u||s)&&(v=_.merge(f.uvs));let h={};u&&(h=ae(f,e,v,!1,i,l));let y={};return s&&(y=ae(f,t,v,!0,i,l)),{contour:p,triangles:f,sideTorso:m,bottomCap:h,topCap:y,topVerts:d}};class Ee extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=E({polygonGeoJson:e,startHeight:0,endHeight:1,hasTop:!0,topFirst:!1,hasBottom:!0,hasSide:!0,curvatureResolution:1,cartesian:!0,userDataRsoOffset:0},t);const{endHeight:r,hasTop:i,topFirst:c,hasBottom:u,hasSide:s,cartesian:l,userDataRsoOffset:a,projection:p}=this.parameters,{contour:f,sideTorso:m,topVerts:d,bottomCap:v,topCap:h}=he(E({},this.parameters));let y=[],w=[],j=[],D=0;const A=b=>{const S=Math.round(y.length/3),C=j.length;y=y.concat(b.vertices),w=w.concat(b.uvs),j=j.concat(S?b.indices.map(P=>P+S):b.indices),this.addGroup(C,j.length-C,D++)};i&&c&&A(h),s&&(A(m),this.userData.topVerts=a?G(f,r+a,l,p).vertices:d),u&&A(v),i&&!c&&A(h),this.setIndex(j),this[oe]("position",new o.Float32BufferAttribute(y,3)),this[oe]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Oe=`
@@ -35,22 +35,22 @@ var rt = (n, t, e) => new Promise((i, s) => {
35
35
  }, r = (c) => c.done ? i(c.value) : Promise.resolve(c.value).then(a, l);
36
36
  r((e = e.apply(n, t)).next());
37
37
  });
38
- import { Material as ot, Object3D as N, Texture as at, VideoTexture as Dt, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Bt, Points as J, InstancedMesh as xt, Vector3 as I, Quaternion as Tt, Group as zt, Mesh as wt, Sprite as ct, Box3 as St, ShaderMaterial as _t, Vector2 as q, Color as lt, Vector4 as O, Matrix4 as Et, Line3 as Lt, Sphere as Ot, InstancedInterleavedBuffer as Vt, InterleavedBufferAttribute as ut, MathUtils as kt } from "three";
39
- import { CSS2DObject as Wt } from "three/examples/jsm/renderers/CSS2DRenderer";
40
- import { CSS3DObject as Ut, CSS3DSprite as Nt } from "three/examples/jsm/renderers/CSS3DRenderer";
41
- import { geoBounds as jt, geoContains as Rt, geoDistance as Gt, geoInterpolate as Ft } from "d3-geo";
38
+ import { Material as ot, Object3D as N, Texture as at, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Dt, Points as J, InstancedMesh as xt, Vector3 as I, Quaternion as Bt, Group as Tt, Mesh as wt, Sprite as ct, Box3 as St, ShaderMaterial as zt, Vector2 as q, Color as lt, Vector4 as O, Matrix4 as _t, Line3 as Et, Sphere as Lt, InstancedInterleavedBuffer as Ot, InterleavedBufferAttribute as ut, MathUtils as Vt } from "three";
39
+ import { CSS2DObject as kt } from "three/examples/jsm/renderers/CSS2DRenderer";
40
+ import { CSS3DObject as Wt, CSS3DSprite as Ut } from "three/examples/jsm/renderers/CSS3DRenderer";
41
+ import { geoBounds as jt, geoContains as Nt, geoDistance as Rt, geoInterpolate as Gt } from "d3-geo";
42
42
  import "d3-geo-projection";
43
- import { p as ft, a as $t } from "./parseVector.module.js";
44
- import { merge as H, mean as qt, extent as dt } from "d3-array";
45
- import Kt, { flatten as At } from "earcut";
46
- import Qt from "@turf/boolean-clockwise";
47
- import Xt from "delaunator";
48
- import Yt from "@turf/boolean-point-in-polygon";
49
- import { geoVoronoi as Zt } from "d3-geo-voronoi";
43
+ import { p as ft, a as Ft } from "./parseVector.module.js";
44
+ import { merge as H, mean as $t, extent as dt } from "d3-array";
45
+ import qt, { flatten as At } from "earcut";
46
+ import Kt from "@turf/boolean-clockwise";
47
+ import Qt from "delaunator";
48
+ import Xt from "@turf/boolean-point-in-polygon";
49
+ import { geoVoronoi as Yt } from "d3-geo-voronoi";
50
50
  import { scaleLinear as ht } from "d3-scale";
51
- import { LineSegmentsGeometry as Jt } from "three/examples/jsm/lines/LineSegmentsGeometry";
52
- const Ht = 0, Te = 1, te = 2, ze = !1;
53
- class ee {
51
+ import { LineSegmentsGeometry as Zt } from "three/examples/jsm/lines/LineSegmentsGeometry";
52
+ const Jt = 0, Be = 1, Ht = 2, Te = !1;
53
+ class te {
54
54
  constructor() {
55
55
  this.resources = /* @__PURE__ */ new Set(), this.disposeMaterial = !0, this.disposeVideo = !0;
56
56
  }
@@ -79,7 +79,7 @@ class ee {
79
79
  (s instanceof at || Array.isArray(s)) && this.track(s);
80
80
  }
81
81
  }
82
- } else this.disposeVideo && t instanceof Dt && t.source.data && this.resources.add(t.source.data);
82
+ } else this.disposeVideo && t.isVideoTexture && t.source.data && this.resources.add(t.source.data);
83
83
  return t;
84
84
  }
85
85
  dispose() {
@@ -91,7 +91,7 @@ class ee {
91
91
  }), t.length = 0, this.resources.clear();
92
92
  }
93
93
  }
94
- const ie = (n, t = 1) => {
94
+ const ee = (n, t = 1) => {
95
95
  const e = new Z();
96
96
  e.setAttribute(
97
97
  "position",
@@ -100,7 +100,7 @@ const ie = (n, t = 1) => {
100
100
  "scaleAtt",
101
101
  new R(new Array(t).fill(1), 1)
102
102
  );
103
- const i = n.material, s = new Bt({
103
+ const i = n.material, s = new Dt({
104
104
  size: 10,
105
105
  map: i.map,
106
106
  alphaMap: i.alphaMap,
@@ -122,7 +122,7 @@ const ie = (n, t = 1) => {
122
122
  )}
123
123
  `;
124
124
  }, new J(e, s);
125
- }, se = (n, t) => {
125
+ }, ie = (n, t) => {
126
126
  const e = new N();
127
127
  t.forEach((i, s) => {
128
128
  const a = ft(i.position), l = ft(i.scale || [1, 1, 1]);
@@ -131,12 +131,12 @@ const ie = (n, t = 1) => {
131
131
  if (n instanceof xt || n.isInstantiate)
132
132
  n.setMatrixAt(s, r);
133
133
  else if (n instanceof J || n.type === "Points") {
134
- const o = n.geometry, h = o.attributes.position.array, f = o.attributes.scaleAtt.array, p = new I(), u = new I(), m = new Tt(), d = s * 3, v = s * 1;
134
+ const o = n.geometry, h = o.attributes.position.array, f = o.attributes.scaleAtt.array, p = new I(), u = new I(), m = new Bt(), d = s * 3, v = s * 1;
135
135
  r.decompose(p, m, u), h[d] = p.x, h[d + 1] = p.y, h[d + 2] = p.z, f[v] = Math.max(u.x, u.y, u.z), o.attributes.position.needsUpdate = !0, o.attributes.scaleAtt.needsUpdate = !0;
136
136
  }
137
137
  });
138
138
  };
139
- class ne {
139
+ class se {
140
140
  constructor() {
141
141
  this.onPointerIndex = [];
142
142
  }
@@ -165,7 +165,7 @@ class ne {
165
165
  });
166
166
  }
167
167
  }
168
- class re extends ne {
168
+ class ne extends se {
169
169
  constructor() {
170
170
  super(...arguments), this.userData = {}, this.materialList = {}, this.useMaterialType = "origin", this.disposeMaterialIfNotUsed = !0;
171
171
  }
@@ -223,7 +223,7 @@ class re extends ne {
223
223
  );
224
224
  }
225
225
  }
226
- class pt extends re {
226
+ class pt extends ne {
227
227
  constructor() {
228
228
  super(...arguments), this.objectType = "BaseObject", this.userData = {}, this.prefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.disposeTrack = !0;
229
229
  }
@@ -284,13 +284,13 @@ class pt extends re {
284
284
  resize(t, e) {
285
285
  }
286
286
  show() {
287
- return this.object3d.visible = !0, this.object3d.layers.set(Ht), this;
287
+ return this.object3d.visible = !0, this.object3d.layers.set(Jt), this;
288
288
  }
289
289
  hide() {
290
- return this.object3d.visible = !1, this.object3d.layers.set(te), this;
290
+ return this.object3d.visible = !1, this.object3d.layers.set(Ht), this;
291
291
  }
292
292
  createGroup() {
293
- return this.object3d = new zt(), this;
293
+ return this.object3d = new Tt(), this;
294
294
  }
295
295
  createMesh(...t) {
296
296
  return this.object3d = new wt(...t), this;
@@ -299,13 +299,13 @@ class pt extends re {
299
299
  return this.object3d = new J(...t), this;
300
300
  }
301
301
  createCSS2DObject(t) {
302
- return this.object3d = new Wt(t), this;
302
+ return this.object3d = new kt(t), this;
303
303
  }
304
304
  createCSS3DObject(t) {
305
- return this.object3d = new Ut(t), this;
305
+ return this.object3d = new Wt(t), this;
306
306
  }
307
307
  createCSS3DSprite(t) {
308
- return this.object3d = new Nt(t), this;
308
+ return this.object3d = new Ut(t), this;
309
309
  }
310
310
  createSprite(t) {
311
311
  return this.object3d = new ct(t), this;
@@ -343,12 +343,12 @@ class pt extends re {
343
343
  if ((h = t == null ? void 0 : t.instancedAttr) != null && h.length) {
344
344
  const f = t.instancedAttr.length;
345
345
  if (this.object3d instanceof ct)
346
- o.object3d = ie(this.object3d, f);
346
+ o.object3d = ee(this.object3d, f);
347
347
  else {
348
348
  const p = this.object3d, u = this.cloneMaterial();
349
349
  o.object3d = new xt(p.geometry, u, f);
350
350
  }
351
- se(o.object3d, t == null ? void 0 : t.instancedAttr);
351
+ ie(o.object3d, t == null ? void 0 : t.instancedAttr);
352
352
  } else
353
353
  o.object3d = this.object3d.clone(!1), o.object3d.material && (o.object3d.material = this.cloneMaterial());
354
354
  o.object3d.userData.prefab && delete o.object3d.userData.prefab;
@@ -385,20 +385,20 @@ class pt extends re {
385
385
  dispose() {
386
386
  var t;
387
387
  if (super.dispose(), (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) {
388
- const e = new ee();
388
+ const e = new te();
389
389
  e.disposeMaterial = !1, e.track(this), e.dispose();
390
390
  }
391
391
  }
392
392
  }
393
- function oe(n, t) {
393
+ function re(n, t) {
394
394
  return n.map((e) => {
395
395
  const i = [];
396
396
  let s;
397
397
  return e.forEach((a) => {
398
398
  if (s) {
399
- const l = Gt(a, s) * 180 / Math.PI;
399
+ const l = Rt(a, s) * 180 / Math.PI;
400
400
  if (l > t) {
401
- const r = Ft(s, a), c = 1 / Math.ceil(l / t);
401
+ const r = Gt(s, a), c = 1 / Math.ceil(l / t);
402
402
  let o = c;
403
403
  for (; o < 1; )
404
404
  i.push(r(o)), o += c;
@@ -408,7 +408,7 @@ function oe(n, t) {
408
408
  }), i;
409
409
  });
410
410
  }
411
- function ae(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
411
+ function oe(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
412
412
  const a = Math.round(st(360 / n, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, r = (u) => u / l * 360 % 360 - 180, c = (u) => Math.acos(2 * u / a - 1) / Math.PI * 180 - 90, o = (u) => a * (Math.cos((u + 90) * Math.PI / 180) + 1) / 2, h = [
413
413
  s !== void 0 ? Math.ceil(o(s)) : 0,
414
414
  i !== void 0 ? Math.floor(o(i)) : a - 1
@@ -420,14 +420,14 @@ function ae(n, { minLng: t, maxLng: e, minLat: i, maxLat: s } = {}) {
420
420
  return p;
421
421
  }
422
422
  function Y(n, t, e = !1) {
423
- return e ? Rt(t, n) : Yt(n, t);
423
+ return e ? Nt(t, n) : Xt(n, t);
424
424
  }
425
- function ce(n, t) {
425
+ function ae(n, t) {
426
426
  const e = { type: "Polygon", coordinates: n }, [[i, s], [a, l]] = jt(e);
427
427
  if (Math.min(Math.abs(a - i), Math.abs(l - s)) < t)
428
428
  return [];
429
429
  const r = i > a || l >= 89 || s <= -89;
430
- return ae(t, {
430
+ return oe(t, {
431
431
  minLng: i,
432
432
  maxLng: a,
433
433
  minLat: s,
@@ -436,13 +436,13 @@ function ce(n, t) {
436
436
  (c) => Y(c, e, r)
437
437
  );
438
438
  }
439
- function le(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
440
- const s = oe(n, t), a = H(s), l = ce(n, t), r = [...a, ...l], c = { type: "Polygon", coordinates: n }, [[o, h], [f, p]] = jt(c), u = o > f || // crosses antimeridian
439
+ function ce(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
440
+ const s = re(n, t), a = H(s), l = ae(n, t), r = [...a, ...l], c = { type: "Polygon", coordinates: n }, [[o, h], [f, p]] = jt(c), u = o > f || // crosses antimeridian
441
441
  p >= 89 || // crosses north pole
442
442
  h <= -89;
443
443
  let m = [];
444
444
  if (u) {
445
- const y = Zt(r).triangles(), x = new Map(
445
+ const y = Yt(r).triangles(), x = new Map(
446
446
  r.map(([A, C], _) => [`${A}-${C}`, _])
447
447
  );
448
448
  y.features.forEach((A) => {
@@ -464,12 +464,12 @@ function le(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
464
464
  }
465
465
  });
466
466
  } else if (l.length) {
467
- const y = Xt.from(r);
467
+ const y = Qt.from(r);
468
468
  for (let x = 0, A = y.triangles.length; x < A; x += 3) {
469
469
  const C = [2, 1, 0].map((P) => y.triangles[x + P]), _ = C.map((P) => r[P]);
470
470
  if (C.some((P) => P < a.length)) {
471
471
  const P = [0, 1].map(
472
- (F) => qt(_, (V) => V[F])
472
+ (F) => $t(_, (V) => V[F])
473
473
  );
474
474
  if (!Y(
475
475
  P,
@@ -482,7 +482,7 @@ function le(n, { resolution: t = 1 / 0, bbox: e, projection: i } = {}) {
482
482
  }
483
483
  } else {
484
484
  const { vertices: y, holes: x = [] } = At(s);
485
- m = Kt(y, x, 2);
485
+ m = qt(y, x, 2);
486
486
  }
487
487
  let d = e ? [e[0], e[2]] : dt(r, (y) => y[0]), v = e ? [e[1], e[3]] : dt(r, (y) => y[1]);
488
488
  if (i) {
@@ -506,12 +506,12 @@ function G(n, t, e, i) {
506
506
  const [c, o] = i([l, r]);
507
507
  return [c, -o, t];
508
508
  }
509
- return e ? $t(l, r, t) : [l, r, t];
509
+ return e ? Ft(l, r, t) : [l, r, t];
510
510
  })
511
511
  );
512
512
  return At(s);
513
513
  }
514
- function ue(n, t, e, i, s) {
514
+ function le(n, t, e, i, s) {
515
515
  const { vertices: a, holes: l } = G(
516
516
  n,
517
517
  t,
@@ -552,7 +552,7 @@ function vt(n, t, e, i, s, a) {
552
552
  uvs: e
553
553
  };
554
554
  }
555
- const fe = ({
555
+ const ue = ({
556
556
  polygonGeoJson: n,
557
557
  startHeight: t,
558
558
  endHeight: e,
@@ -565,15 +565,15 @@ const fe = ({
565
565
  bbox: o
566
566
  }) => {
567
567
  n.forEach((w) => {
568
- Qt(w) || w.reverse();
568
+ Kt(w) || w.reverse();
569
569
  });
570
- const { contour: h, triangles: f } = le(n, {
570
+ const { contour: h, triangles: f } = ce(n, {
571
571
  resolution: i,
572
572
  bbox: o,
573
573
  projection: c
574
574
  });
575
575
  let p = {}, u;
576
- a && (p = ue(
576
+ a && (p = le(
577
577
  h,
578
578
  t != null ? t : e,
579
579
  e != null ? e : t,
@@ -601,7 +601,7 @@ const fe = ({
601
601
  c
602
602
  )), { contour: h, triangles: f, sideTorso: p, bottomCap: d, topCap: v, topVerts: u };
603
603
  };
604
- class _e extends Z {
604
+ class ze extends Z {
605
605
  constructor(t, e = {}) {
606
606
  super(), this.type = "PolygonBufferGeometry", this.parameters = L({
607
607
  polygonGeoJson: t,
@@ -624,7 +624,7 @@ class _e extends Z {
624
624
  cartesian: c,
625
625
  userDataRsoOffset: o,
626
626
  projection: h
627
- } = this.parameters, { contour: f, sideTorso: p, topVerts: u, bottomCap: m, topCap: d } = fe(L({}, this.parameters));
627
+ } = this.parameters, { contour: f, sideTorso: p, topVerts: u, bottomCap: m, topCap: d } = ue(L({}, this.parameters));
628
628
  let v = [], w = [], S = [], D = 0;
629
629
  const j = (y) => {
630
630
  const x = Math.round(v.length / 3), A = S.length;
@@ -640,7 +640,7 @@ class _e extends Z {
640
640
  ).vertices : u), l && j(m), s && !a && j(d), this.setIndex(S), this[mt]("position", new R(v, 3)), this[mt]("uv", new R(w, 2)), this.computeVertexNormals();
641
641
  }
642
642
  }
643
- const de = `
643
+ const fe = `
644
644
  #include <fog_pars_fragment>
645
645
  #include <logdepthbuf_pars_fragment>
646
646
 
@@ -684,7 +684,7 @@ void main() {
684
684
  #include <tonemapping_fragment>
685
685
  #include <colorspace_fragment>
686
686
  }
687
- `, he = `
687
+ `, de = `
688
688
  #include <common>
689
689
  #include <logdepthbuf_pars_vertex>
690
690
  #include <fog_pars_vertex>
@@ -777,7 +777,7 @@ void main() {
777
777
  #include <fog_vertex>
778
778
  }
779
779
  `;
780
- class Ee extends _t {
780
+ class _e extends zt {
781
781
  constructor(t = {}) {
782
782
  const S = t, {
783
783
  lineWidth: e = 1,
@@ -833,8 +833,8 @@ class Ee extends _t {
833
833
  useAlphaMap: { value: u ? 1 : 0 },
834
834
  repeat: { value: d }
835
835
  },
836
- vertexShader: he,
837
- fragmentShader: de
836
+ vertexShader: de,
837
+ fragmentShader: fe
838
838
  })), this.type = "MeshLineMaterial";
839
839
  }
840
840
  // Getter and setter for color
@@ -885,12 +885,12 @@ class Ee extends _t {
885
885
  this.uniforms.sizeAttenuation.value = t ? 1 : 0;
886
886
  }
887
887
  }
888
- const K = new O(), yt = new I(), gt = new I(), g = new O(), b = new O(), B = new O(), Q = new I(), X = new Et(), M = new Lt(), bt = new I(), W = new St(), U = new Ot(), T = new O();
888
+ const K = new O(), yt = new I(), gt = new I(), g = new O(), b = new O(), B = new O(), Q = new I(), X = new _t(), M = new Et(), bt = new I(), W = new St(), U = new Lt(), T = new O();
889
889
  let z, E;
890
890
  function Mt(n, t, e) {
891
891
  return T.set(0, 0, -t, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = E / e.width, T.y = E / e.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
892
892
  }
893
- function pe(n, t) {
893
+ function he(n, t) {
894
894
  const e = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
895
895
  for (let r = 0, c = l; r < c; r++) {
896
896
  M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(e);
@@ -907,7 +907,7 @@ function pe(n, t) {
907
907
  });
908
908
  }
909
909
  }
910
- function me(n, t, e) {
910
+ function pe(n, t, e) {
911
911
  const i = t.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, c = r.attributes.instanceStart, o = r.attributes.instanceEnd, h = Math.min(r.instanceCount, c.count), f = -t.near;
912
912
  z.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), X.multiplyMatrices(t.matrixWorldInverse, l);
913
913
  for (let p = 0, u = h; p < u; p++) {
@@ -923,7 +923,7 @@ function me(n, t, e) {
923
923
  g.applyMatrix4(i), b.applyMatrix4(i), g.multiplyScalar(1 / g.w), b.multiplyScalar(1 / b.w), g.x *= a.x / 2, g.y *= a.y / 2, b.x *= a.x / 2, b.y *= a.y / 2, M.start.copy(g), M.start.z = 0, M.end.copy(b), M.end.z = 0;
924
924
  const d = M.closestPointToPointParameter(Q, !0);
925
925
  M.at(d, bt);
926
- const v = kt.lerp(g.z, b.z, d), w = v >= -1 && v <= 1, S = Q.distanceTo(bt) < E * 0.5;
926
+ const v = Vt.lerp(g.z, b.z, d), w = v >= -1 && v <= 1, S = Q.distanceTo(bt) < E * 0.5;
927
927
  if (w && S) {
928
928
  M.start.fromBufferAttribute(c, p), M.end.fromBufferAttribute(o, p), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
929
929
  const D = new I(), j = new I();
@@ -940,8 +940,8 @@ function me(n, t, e) {
940
940
  }
941
941
  }
942
942
  }
943
- class Le extends wt {
944
- constructor(t = new Jt(), e) {
943
+ class Ee extends wt {
944
+ constructor(t = new Zt(), e) {
945
945
  super(t, e), this.isLineSegments2 = !0, this.type = "LineSegments2";
946
946
  }
947
947
  // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
@@ -949,7 +949,7 @@ class Le extends wt {
949
949
  const t = this.geometry, e = t.attributes.instanceStart, i = t.attributes.instanceEnd, s = new Float32Array(2 * e.count);
950
950
  for (let l = 0, r = 0, c = e.count; l < c; l++, r += 2)
951
951
  yt.fromBufferAttribute(e, l), gt.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + yt.distanceTo(gt);
952
- const a = new Vt(
952
+ const a = new Ot(
953
953
  s,
954
954
  2,
955
955
  1
@@ -1002,7 +1002,7 @@ class Le extends wt {
1002
1002
  c.resolution
1003
1003
  );
1004
1004
  }
1005
- W.expandByScalar(h), z.intersectsBox(W) !== !1 && (i ? pe(this, e) : me(this, s, e));
1005
+ W.expandByScalar(h), z.intersectsBox(W) !== !1 && (i ? he(this, e) : pe(this, s, e));
1006
1006
  }
1007
1007
  onBeforeRender(t) {
1008
1008
  const e = this.material.uniforms;
@@ -1010,12 +1010,12 @@ class Le extends wt {
1010
1010
  }
1011
1011
  }
1012
1012
  export {
1013
- Te as B,
1014
- ze as I,
1015
- Le as L,
1016
- Ee as M,
1017
- _e as P,
1018
- ee as R,
1013
+ Be as B,
1014
+ Te as I,
1015
+ Ee as L,
1016
+ _e as M,
1017
+ ze as P,
1018
+ te as R,
1019
1019
  pt as a,
1020
- fe as g
1020
+ ue as g
1021
1021
  };
@@ -1,11 +1,11 @@
1
- import { LoadingManager, Scene, FileLoader, DataTexture, Texture, VideoTexture, Object3D } from 'three';
2
1
  import { EventEmitter } from 'events';
3
- import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
2
+ import { DataTexture, FileLoader, LoadingManager, Object3D, Scene, Texture, VideoTexture } from 'three';
4
3
  import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader';
5
4
  import { EXRLoader } from 'three/examples/jsm/loaders/EXRLoader';
5
+ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
6
6
  import { LottieLoader } from 'three/examples/jsm/loaders/LottieLoader';
7
- import TextureLoader from './TextureLoader';
8
7
  import GzipJSONLoader from './GzipJSONLoader';
8
+ import TextureLoader from './TextureLoader';
9
9
  type ValuesOf<T extends readonly any[]> = T[number];
10
10
  export declare const KNOWN_ASSET_TYPES: {
11
11
  readonly images: readonly ["png", "jpg", "jpeg", "ico", "webp", "avif"];
@@ -73,7 +73,7 @@ export default class Loader {
73
73
  getAssetType(src: string): "gltf" | "json" | "exr" | "images" | "media" | "gzipJson" | "lottie" | undefined;
74
74
  getLoader(type: string, options?: {
75
75
  dracoPath?: string;
76
- }): TextureLoader | FileLoader | GzipJSONLoader | GLTFLoader | EXRLoader | LottieLoader | undefined;
76
+ }): GzipJSONLoader | FileLoader | TextureLoader | GLTFLoader | EXRLoader | LottieLoader | undefined;
77
77
  add(src: string | string[], options?: AssetOptions): void;
78
78
  getSrcByAsset(asset: Texture | Object3D | any, assets?: Map<string, any>): string | undefined;
79
79
  get textureAssets(): Map<string, Texture>;
@@ -1,4 +1,4 @@
1
- import { Material, Object3D, Texture, BufferGeometry } from 'three';
1
+ import { BufferGeometry, Material, Object3D, Texture } from 'three';
2
2
  import BaseObject from './BaseObject';
3
3
  type Resource = Object3D | Material | Texture | BufferGeometry | BaseObject | HTMLVideoElement;
4
4
  export default class ResourceTracker {