gl-draw 0.16.2 → 0.16.3

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,7 +1,7 @@
1
- "use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var N=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,_=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(N)for(var t of N(e))ee.call(e,t)&&J(n,t,e[t]);return n},R=(n,e)=>me(n,ve(e));var ie=(n,e)=>{var t={};for(var i in n)H.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&N)for(var i of N(n))e.indexOf(i)<0&&ee.call(n,i)&&(t[i]=n[i]);return t};var re=(n,e,t)=>new Promise((i,r)=>{var o=c=>{try{s(t.next(c))}catch(l){r(l)}},u=c=>{try{s(t.throw(c))}catch(l){r(l)}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,u);s((t=t.apply(n,e)).next())});const a=require("three"),ye=require("three/examples/jsm/renderers/CSS2DRenderer"),ne=require("three/examples/jsm/renderers/CSS3DRenderer"),E=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),L=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 a.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 a.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 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 r=i.value;(r instanceof a.Texture||Array.isArray(r))&&this.track(r)}}}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 Be=(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,r=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 r.onBeforeCompile=o=>{o.vertexShader=`
1
+ "use strict";var pe=Object.defineProperty,me=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var N=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,_=(n,e)=>{for(var t in e||(e={}))H.call(e,t)&&J(n,t,e[t]);if(N)for(var t of N(e))ee.call(e,t)&&J(n,t,e[t]);return n},R=(n,e)=>me(n,ve(e));var ie=(n,e)=>{var t={};for(var i in n)H.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&N)for(var i of N(n))e.indexOf(i)<0&&ee.call(n,i)&&(t[i]=n[i]);return t};var re=(n,e,t)=>new Promise((i,r)=>{var a=c=>{try{s(t.next(c))}catch(l){r(l)}},u=c=>{try{s(t.throw(c))}catch(l){r(l)}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,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"),E=require("d3-geo");require("d3-geo-projection");const Q=require("./polar2Cartesian.js"),L=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 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 r=i.value;(r instanceof o.Texture||Array.isArray(r))&&this.track(r)}}}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 Be=(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,r=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 r.onBeforeCompile=a=>{a.vertexShader=`
2
2
  attribute float scaleAtt;
3
- ${o.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
- `},new a.Points(t,r)},Ie=(n,e)=>{const t=new a.Object3D;e.forEach((i,r)=>{const o=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(o),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof a.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof a.Points||n.type==="Points"){const l=n.geometry,f=l.attributes.position.array,h=l.attributes.scaleAtt.array,p=new a.Vector3,d=new a.Vector3,v=new a.Quaternion,m=r*3,y=r*1;s.decompose(p,v,d),f[m]=p.x,f[m+1]=p.y,f[m+2]=p.z,h[y]=Math.max(d.x,d.y,d.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})};class Pe{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 De extends Pe{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 r=i.userData;i.userData={};const o=i.clone();return i.userData=r,o});{const i=t.userData;t.userData={};const r=t.clone();return t.userData=i,r}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const r=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=r,r}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 r=this.object3d;Array.isArray(r.material)&&t!==void 0?r.material[t]=i:r.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 Y extends De{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}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 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(we),this.isBloom&&this.enableBloom(),this}hide(){return this.object3d.visible=!1,this.object3d.layers.set(Ae),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 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 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 re(this,null,function*(){var c,l;const t=(c=e==null?void 0:e.recursive)!=null?c:!0,i=(l=e==null?void 0:e.cloneMaterial)!=null?l:!1,{objectType:r,objectOptions:o}=this;let u=e==null?void 0:e.create,s;return this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:(e==null?void 0:e.target)||this.parent}):(u===void 0&&(u=f=>{var h;if(this.object3d){if((h=e==null?void 0:e.instancedAttr)!=null&&h.length){const p=e.instancedAttr.length;if(this.object3d instanceof a.Sprite)f.object3d=Be(this.object3d,p);else{const d=this.object3d,v=i?this.cloneMaterial():d.material;f.object3d=new a.InstancedMesh(d.geometry,v,p)}Ie(f.object3d,e==null?void 0:e.instancedAttr)}else f.object3d=this.object3d.clone(!1),i&&f.object3d.material&&(f.object3d.material=this.cloneMaterial());f.object3d.userData.prefab&&delete f.object3d.userData.prefab}}),s=yield this.lead.draw(r,R(_({},o||{}),{create:u,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:(e==null?void 0:e.target)||this.parent}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(f=>f.instantiate({key:f.keyUId?`${f.keyName}-${f.keyUId}`:f.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,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 Te(n,e){return n.map(t=>{const i=[];let r;return t.forEach(o=>{if(r){const u=E.geoDistance(o,r)*180/Math.PI;if(u>e){const s=E.geoInterpolate(r,o),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=o)}),i})}function Ve(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const o=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=d=>d/u*360%360-180,c=d=>Math.acos(2*d/o-1)/Math.PI*180-90,l=d=>o*(Math.cos((d+90)*Math.PI/180)+1)/2,f=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):o-1],h=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,p=[];for(let d=f[0];d<=f[1];d++){const v=s(d);h(v)&&p.push([v,c(d)])}return p}function Z(n,e,t=!1){return t?E.geoContains(e,n):Me(n,e)}function Oe(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[o,u]]=E.geoBounds(t);if(Math.min(Math.abs(o-i),Math.abs(u-r))<e)return[];const s=i>o||u>=89||r<=-89;return Ve(e,{minLng:i,maxLng:o,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Te(n,e),o=L.merge(r),u=Oe(n,e),s=[...o,...u],c={type:"Polygon",coordinates:n},[[l,f],[h,p]]=E.geoBounds(c),d=l>h||p>=89||f<=-89;let v=[];if(d){const b=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,B],O)=>[`${C}-${B}`,O]));b.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(B.forEach(([I,q])=>{const k=`${I}-${q}`;S.has(k)&&O.push(S.get(k))}),O.length===3){if(O.some(I=>I<o.length)){const I=C.properties.circumcenter;if(!Z(I,c,d))return}v.push(...O)}})}else if(u.length){const b=ge.from(s);for(let S=0,C=b.triangles.length;S<C;S+=3){const B=[2,1,0].map(I=>b.triangles[S+I]),O=B.map(I=>s[I]);if(B.some(I=>I<o.length)){const I=[0,1].map(q=>L.mean(O,k=>k[q]));if(!Z(I,c,d))continue}v.push(...B)}}else{const{vertices:b,holes:S=[]}=X.flatten(r);v=X(b,S,2)}let m=t?[t[0],t[2]]:L.extent(s,b=>b[0]),y=t?[t[1],t[3]]:L.extent(s,b=>b[1]);if(i){const[b,S]=i([m[0],y[0]]),[C,B]=i([m[1],y[1]]);m=[b,C],y=[-S,-B]}const w=se.scaleLinear(m,[0,1]),j=se.scaleLinear(y,[0,1]),P=s.map(([b,S])=>{if(i){const[C,B]=i([b,S]);return[w(C),j(-B)]}else return[w(b),j(S)]});return{contour:r,triangles:{points:s,indices:v,uvs:P}}}const ae=new a.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(o=>o.map(([u,s])=>{if(i){const[c,l]=i([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(r)}function Le(n,e,t,i,r){const{vertices:o,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,o]),l=Math.round(s.length/3),f=new Set(u);let h=0;const p=[];for(let v=0;v<l;v++){let m=v+1;if(m===l)m=h;else if(f.has(m)){const y=m;m=h,h=y}p.push(v,v+l,m+l),p.push(m+l,m,v)}const d=[];for(let v=1;v>=0;v--)for(let m=0;m<l;m+=1)d.push(m/(l-1),v);return{indices:p,vertices:c,uvs:d,topVerts:s}}function oe(n,e,t,i,r,o){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,o).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:o=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{be(w)||w.reverse()});const{contour:f,triangles:h}=ze(n,{resolution:i,bbox:l,projection:c});let p={},d;o&&(p=Le(f,e!=null?e:t,t!=null?t:e,r,c),d=p.topVerts);let v=[];(u||s)&&(v=L.merge(h.uvs));let m={};u&&(m=oe(h,e,v,!1,r,c));let y={};return s&&(y=oe(h,t,v,!0,r,c)),{contour:f,triangles:h,sideTorso:p,bottomCap:m,topCap:y,topVerts:d}};class _e extends a.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({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:r,topFirst:o,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:f}=this.parameters,{contour:h,sideTorso:p,topVerts:d,bottomCap:v,topCap:m}=he(_({},this.parameters));let y=[],w=[],j=[],P=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(B=>B+S):b.indices),this.addGroup(C,j.length-C,P++)};r&&o&&A(m),s&&(A(p),this.userData.topVerts=l?G(h,i+l,c,f).vertices:d),u&&A(v),r&&!o&&A(m),this.setIndex(j),this[ae]("position",new a.Float32BufferAttribute(y,3)),this[ae]("uv",new a.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Ee=`
3
+ ${a.vertexShader.replace("gl_PointSize = size;","gl_PointSize = size * scaleAtt;")}
4
+ `},new o.Points(t,r)},Ie=(n,e)=>{const t=new o.Object3D;e.forEach((i,r)=>{const a=Q.parseVector3(i.position),u=Q.parseVector3(i.scale||[1,1,1]);t.position.copy(a),t.scale.copy(u),t.updateMatrix();const s=t.matrix.clone();if(n instanceof o.InstancedMesh||n.isInstantiate)n.setMatrixAt(r,s);else if(n instanceof o.Points||n.type==="Points"){const l=n.geometry,f=l.attributes.position.array,h=l.attributes.scaleAtt.array,p=new o.Vector3,d=new o.Vector3,v=new o.Quaternion,m=r*3,y=r*1;s.decompose(p,v,d),f[m]=p.x,f[m+1]=p.y,f[m+2]=p.z,h[y]=Math.max(d.x,d.y,d.z),l.attributes.position.needsUpdate=!0,l.attributes.scaleAtt.needsUpdate=!0}})};class Pe{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 De extends Pe{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 r=i.userData;i.userData={};const a=i.clone();return i.userData=r,a});{const i=t.userData;t.userData={};const r=t.clone();return t.userData=i,r}}setMaterialList(e,t){const i=this.object3d;if(!i||!i.material)return;this.materialList.origin||(this.materialList.origin=i.material);const r=t==="clone"?this.cloneMaterial():Array.isArray(t)?t.slice():t;return this.materialList[e]=r,r}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 r=this.object3d;Array.isArray(r.material)&&t!==void 0?r.material[t]=i:r.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 Y extends De{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}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(we),this.isBloom&&this.enableBloom(),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 re(this,null,function*(){var c,l;const t=(c=e==null?void 0:e.recursive)!=null?c:!0,i=(l=e==null?void 0:e.cloneMaterial)!=null?l:!1,{objectType:r,objectOptions:a}=this;let u=e==null?void 0:e.create,s;return this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:(e==null?void 0:e.target)||this.parent}):(u===void 0&&(u=f=>{var h;if(this.object3d){if((h=e==null?void 0:e.instancedAttr)!=null&&h.length){const p=e.instancedAttr.length;if(this.object3d instanceof o.Sprite)f.object3d=Be(this.object3d,p);else{const d=this.object3d,v=i?this.cloneMaterial():d.material;f.object3d=new o.InstancedMesh(d.geometry,v,p)}Ie(f.object3d,e==null?void 0:e.instancedAttr)}else f.object3d=this.object3d.clone(!1),i&&f.object3d.material&&(f.object3d.material=this.cloneMaterial());f.object3d.userData.prefab&&delete f.object3d.userData.prefab}}),s=yield this.lead.draw(r,R(_({},a||{}),{create:u,prefab:!1,keyType:this.keyType,key:(e==null?void 0:e.key)||this.keyName,uId:(e==null?void 0:e.uId)||this.keyUId,target:(e==null?void 0:e.target)||this.parent}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(f=>f.instantiate({key:f.keyUId?`${f.keyName}-${f.keyUId}`:f.keyName,uId:e==null?void 0:e.uId,cloneMaterial:i,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 i=[];let r;return t.forEach(a=>{if(r){const u=E.geoDistance(a,r)*180/Math.PI;if(u>e){const s=E.geoInterpolate(r,a),c=1/Math.ceil(u/e);let l=c;for(;l<1;)i.push(s(l)),l+=c}}i.push(r=a)}),i})}function Te(n,{minLng:e,maxLng:t,minLat:i,maxLat:r}={}){const a=Math.round(te(360/n,2)/Math.PI),u=(1+Math.sqrt(5))/2,s=d=>d/u*360%360-180,c=d=>Math.acos(2*d/a-1)/Math.PI*180-90,l=d=>a*(Math.cos((d+90)*Math.PI/180)+1)/2,f=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):a-1],h=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,p=[];for(let d=f[0];d<=f[1];d++){const v=s(d);h(v)&&p.push([v,c(d)])}return p}function Z(n,e,t=!1){return t?E.geoContains(e,n):Me(n,e)}function Oe(n,e){const t={type:"Polygon",coordinates:n},[[i,r],[a,u]]=E.geoBounds(t);if(Math.min(Math.abs(a-i),Math.abs(u-r))<e)return[];const s=i>a||u>=89||r<=-89;return Te(e,{minLng:i,maxLng:a,minLat:r,maxLat:u}).filter(c=>Z(c,t,s))}function ze(n,{resolution:e=1/0,bbox:t,projection:i}={}){const r=Ve(n,e),a=L.merge(r),u=Oe(n,e),s=[...a,...u],c={type:"Polygon",coordinates:n},[[l,f],[h,p]]=E.geoBounds(c),d=l>h||p>=89||f<=-89;let v=[];if(d){const b=xe.geoVoronoi(s).triangles(),S=new Map(s.map(([C,B],O)=>[`${C}-${B}`,O]));b.features.forEach(C=>{const B=C.geometry.coordinates[0].slice(0,3).reverse(),O=[];if(B.forEach(([I,q])=>{const k=`${I}-${q}`;S.has(k)&&O.push(S.get(k))}),O.length===3){if(O.some(I=>I<a.length)){const I=C.properties.circumcenter;if(!Z(I,c,d))return}v.push(...O)}})}else if(u.length){const b=ge.from(s);for(let S=0,C=b.triangles.length;S<C;S+=3){const B=[2,1,0].map(I=>b.triangles[S+I]),O=B.map(I=>s[I]);if(B.some(I=>I<a.length)){const I=[0,1].map(q=>L.mean(O,k=>k[q]));if(!Z(I,c,d))continue}v.push(...B)}}else{const{vertices:b,holes:S=[]}=X.flatten(r);v=X(b,S,2)}let m=t?[t[0],t[2]]:L.extent(s,b=>b[0]),y=t?[t[1],t[3]]:L.extent(s,b=>b[1]);if(i){const[b,S]=i([m[0],y[0]]),[C,B]=i([m[1],y[1]]);m=[b,C],y=[-S,-B]}const w=se.scaleLinear(m,[0,1]),j=se.scaleLinear(y,[0,1]),P=s.map(([b,S])=>{if(i){const[C,B]=i([b,S]);return[w(C),j(-B)]}else return[w(b),j(S)]});return{contour:r,triangles:{points:s,indices:v,uvs:P}}}const oe=new o.BufferGeometry().setAttribute?"setAttribute":"addAttribute";function G(n,e,t,i){const r=n.map(a=>a.map(([u,s])=>{if(i){const[c,l]=i([u,s]);return[c,-l,e]}return t?Q.polar2Cartesian(u,s,e):[u,s,e]}));return X.flatten(r)}function Le(n,e,t,i,r){const{vertices:a,holes:u}=G(n,e,i,r),{vertices:s}=G(n,t,i,r),c=L.merge([s,a]),l=Math.round(s.length/3),f=new Set(u);let h=0;const p=[];for(let v=0;v<l;v++){let m=v+1;if(m===l)m=h;else if(f.has(m)){const y=m;m=h,h=y}p.push(v,v+l,m+l),p.push(m+l,m,v)}const d=[];for(let v=1;v>=0;v--)for(let m=0;m<l;m+=1)d.push(m/(l-1),v);return{indices:p,vertices:c,uvs:d,topVerts:s}}function ae(n,e,t,i,r,a){return{indices:i?n.indices:n.indices.slice().reverse(),vertices:G([n.points],e,r,a).vertices,uvs:t}}const he=({polygonGeoJson:n,startHeight:e,endHeight:t,curvatureResolution:i=1,cartesian:r=!0,hasSide:a=!0,hasBottom:u=!1,hasTop:s=!1,projection:c,bbox:l})=>{n.forEach(w=>{be(w)||w.reverse()});const{contour:f,triangles:h}=ze(n,{resolution:i,bbox:l,projection:c});let p={},d;a&&(p=Le(f,e!=null?e:t,t!=null?t:e,r,c),d=p.topVerts);let v=[];(u||s)&&(v=L.merge(h.uvs));let m={};u&&(m=ae(h,e,v,!1,r,c));let y={};return s&&(y=ae(h,t,v,!0,r,c)),{contour:f,triangles:h,sideTorso:p,bottomCap:m,topCap:y,topVerts:d}};class _e extends o.BufferGeometry{constructor(e,t={}){super(),this.type="PolygonBufferGeometry",this.parameters=_({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:r,topFirst:a,hasBottom:u,hasSide:s,cartesian:c,userDataRsoOffset:l,projection:f}=this.parameters,{contour:h,sideTorso:p,topVerts:d,bottomCap:v,topCap:m}=he(_({},this.parameters));let y=[],w=[],j=[],P=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(B=>B+S):b.indices),this.addGroup(C,j.length-C,P++)};r&&a&&A(m),s&&(A(p),this.userData.topVerts=l?G(h,i+l,c,f).vertices:d),u&&A(v),r&&!a&&A(m),this.setIndex(j),this[oe]("position",new o.Float32BufferAttribute(y,3)),this[oe]("uv",new o.Float32BufferAttribute(w,2)),this.computeVertexNormals()}}const Ee=`
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 Ne extends a.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:i="#ffffff",opacity:r=1,map:o=null,dashOffset:u=0,dashArray:s=0,dashRatio:c=0,sizeAttenuation:l=!0,offsetLoop:f=!0,offset:h=new a.Vector2(0,0),scaleDown:p=0,alphaMap:d=void 0,alphaTest:v=0,repeat:m=new a.Vector2(1,1),resolution:y=new a.Vector2(1,1)}=j,w=ie(j,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(R(_({},w),{uniforms:{lineWidth:{value:t},color:{value:new a.Color(i)},opacity:{value:r},map:{value:o},useMap:{value:o?1:0},resolution:{value:y},sizeAttenuation:{value:l?1:0},offset:{value:h},offsetLoop:{value:f?1:0},dashArray:{value:s},dashOffset:{value:u},dashRatio:{value:c},useDash:{value:s>0?1:0},scaleDown:{value:p/10},alphaTest:{value:v},alphaMap:{value:d},useAlphaMap:{value:d?1:0},repeat:{value:m}},vertexShader:ke,fragmentShader:Ee})),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 F=new a.Vector4,ce=new a.Vector3,le=new a.Vector3,g=new a.Vector4,M=new a.Vector4,D=new a.Vector4,$=new a.Vector3,K=new a.Matrix4,x=new a.Line3,ue=new a.Vector3,U=new a.Box3,W=new a.Sphere,T=new a.Vector4;let V,z;function de(n,e,t){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))}function Ue(n,e){const t=n.matrixWorld,i=n.geometry,r=i.attributes.instanceStart,o=i.attributes.instanceEnd,u=Math.min(i.instanceCount,r.count);for(let s=0,c=u;s<c;s++){x.start.fromBufferAttribute(r,s),x.end.fromBufferAttribute(o,s),x.applyMatrix4(t);const l=new a.Vector3,f=new a.Vector3;V.distanceSqToSegment(x.start,x.end,f,l),f.distanceTo(l)<z*.5&&e.push({point:f,pointOnLine:l,distance:V.origin.distanceTo(f),object:n,face:null,faceIndex:s,uv:null,uv1:null})}}function We(n,e,t){const i=e.projectionMatrix,o=n.material.resolution,u=n.matrixWorld,s=n.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,f=Math.min(s.instanceCount,c.count),h=-e.near;V.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=o.x/2,D.y*=o.y/2,D.z=0,$.copy(D),K.multiplyMatrices(e.matrixWorldInverse,u);for(let p=0,d=f;p<d;p++){if(g.fromBufferAttribute(c,p),M.fromBufferAttribute(l,p),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>h&&M.z>h)continue;if(g.z>h){const P=g.z-M.z,A=(g.z-h)/P;g.lerp(M,A)}else if(M.z>h){const P=M.z-g.z,A=(M.z-h)/P;M.lerp(g,A)}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,x.start.copy(g),x.start.z=0,x.end.copy(M),x.end.z=0;const m=x.closestPointToPointParameter($,!0);x.at(m,ue);const y=a.MathUtils.lerp(g.z,M.z,m),w=y>=-1&&y<=1,j=$.distanceTo(ue)<z*.5;if(w&&j){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(l,p),x.start.applyMatrix4(u),x.end.applyMatrix4(u);const P=new a.Vector3,A=new a.Vector3;V.distanceSqToSegment(x.start,x.end,A,P),t.push({point:A,pointOnLine:P,distance:V.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ge extends a.Mesh{constructor(e=new Se.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let u=0,s=0,c=t.count;u<c;u++,s+=2)ce.fromBufferAttribute(t,u),le.fromBufferAttribute(i,u),r[s]=s===0?0:r[s-1],r[s+1]=r[s]+ce.distanceTo(le);const o=new a.InstancedInterleavedBuffer(r,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,r=e.camera;r===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;V=e.ray;const u=this.matrixWorld,s=this.geometry,c=this.material;z=c.linewidth+o,s.boundingSphere===null&&s.computeBoundingSphere(),W.copy(s.boundingSphere).applyMatrix4(u);let l;if(i)l=z*.5;else{const h=Math.max(r.near,W.distanceToPoint(V.origin));l=de(r,h,c.resolution)}if(W.radius+=l,V.intersectsSphere(W)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),U.copy(s.boundingBox).applyMatrix4(u);let f;if(i)f=z*.5;else{const h=Math.max(r.near,U.distanceToPoint(V.origin));f=de(r,h,c.resolution)}U.expandByScalar(f),V.intersectsBox(U)!==!1&&(i?Ue(this,t):We(this,r,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}exports.BLOOM_SCENE=je;exports.BaseObject=Y;exports.IS_DEV=Ce;exports.LineSegments2=Ge;exports.MeshLineMaterial=Ne;exports.PolygonGeometry=_e;exports.ResourceTracker=fe;exports.getMetas=he;
140
+ `;class Ne extends o.ShaderMaterial{constructor(e={}){const j=e,{lineWidth:t=1,color:i="#ffffff",opacity:r=1,map:a=null,dashOffset:u=0,dashArray:s=0,dashRatio:c=0,sizeAttenuation:l=!0,offsetLoop:f=!0,offset:h=new o.Vector2(0,0),scaleDown:p=0,alphaMap:d=void 0,alphaTest:v=0,repeat:m=new o.Vector2(1,1),resolution:y=new o.Vector2(1,1)}=j,w=ie(j,["lineWidth","color","opacity","map","dashOffset","dashArray","dashRatio","sizeAttenuation","offsetLoop","offset","scaleDown","alphaMap","alphaTest","repeat","resolution"]);super(R(_({},w),{uniforms:{lineWidth:{value:t},color:{value:new o.Color(i)},opacity:{value:r},map:{value:a},useMap:{value:a?1:0},resolution:{value:y},sizeAttenuation:{value:l?1:0},offset:{value:h},offsetLoop:{value:f?1:0},dashArray:{value:s},dashOffset:{value:u},dashRatio:{value:c},useDash:{value:s>0?1:0},scaleDown:{value:p/10},alphaTest:{value:v},alphaMap:{value:d},useAlphaMap:{value:d?1:0},repeat:{value:m}},vertexShader:ke,fragmentShader:Ee})),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 F=new o.Vector4,ce=new o.Vector3,le=new o.Vector3,g=new o.Vector4,M=new o.Vector4,D=new o.Vector4,$=new o.Vector3,K=new o.Matrix4,x=new o.Line3,ue=new o.Vector3,U=new o.Box3,W=new o.Sphere,V=new o.Vector4;let T,z;function de(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 Ue(n,e){const t=n.matrixWorld,i=n.geometry,r=i.attributes.instanceStart,a=i.attributes.instanceEnd,u=Math.min(i.instanceCount,r.count);for(let s=0,c=u;s<c;s++){x.start.fromBufferAttribute(r,s),x.end.fromBufferAttribute(a,s),x.applyMatrix4(t);const l=new o.Vector3,f=new o.Vector3;T.distanceSqToSegment(x.start,x.end,f,l),f.distanceTo(l)<z*.5&&e.push({point:f,pointOnLine:l,distance:T.origin.distanceTo(f),object:n,face:null,faceIndex:s,uv:null,uv1:null})}}function We(n,e,t){const i=e.projectionMatrix,a=n.material.resolution,u=n.matrixWorld,s=n.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,f=Math.min(s.instanceCount,c.count),h=-e.near;T.at(1,D),D.w=1,D.applyMatrix4(e.matrixWorldInverse),D.applyMatrix4(i),D.multiplyScalar(1/D.w),D.x*=a.x/2,D.y*=a.y/2,D.z=0,$.copy(D),K.multiplyMatrices(e.matrixWorldInverse,u);for(let p=0,d=f;p<d;p++){if(g.fromBufferAttribute(c,p),M.fromBufferAttribute(l,p),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>h&&M.z>h)continue;if(g.z>h){const P=g.z-M.z,A=(g.z-h)/P;g.lerp(M,A)}else if(M.z>h){const P=M.z-g.z,A=(M.z-h)/P;M.lerp(g,A)}g.applyMatrix4(i),M.applyMatrix4(i),g.multiplyScalar(1/g.w),M.multiplyScalar(1/M.w),g.x*=a.x/2,g.y*=a.y/2,M.x*=a.x/2,M.y*=a.y/2,x.start.copy(g),x.start.z=0,x.end.copy(M),x.end.z=0;const m=x.closestPointToPointParameter($,!0);x.at(m,ue);const y=o.MathUtils.lerp(g.z,M.z,m),w=y>=-1&&y<=1,j=$.distanceTo(ue)<z*.5;if(w&&j){x.start.fromBufferAttribute(c,p),x.end.fromBufferAttribute(l,p),x.start.applyMatrix4(u),x.end.applyMatrix4(u);const P=new o.Vector3,A=new o.Vector3;T.distanceSqToSegment(x.start,x.end,A,P),t.push({point:A,pointOnLine:P,distance:T.origin.distanceTo(A),object:n,face:null,faceIndex:p,uv:null,uv1:null})}}}class Ge extends o.Mesh{constructor(e=new Se.LineSegmentsGeometry,t){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,i=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let u=0,s=0,c=t.count;u<c;u++,s+=2)ce.fromBufferAttribute(t,u),le.fromBufferAttribute(i,u),r[s]=s===0?0:r[s-1],r[s+1]=r[s]+ce.distanceTo(le);const a=new o.InstancedInterleavedBuffer(r,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,r=e.camera;r===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 u=this.matrixWorld,s=this.geometry,c=this.material;z=c.linewidth+a,s.boundingSphere===null&&s.computeBoundingSphere(),W.copy(s.boundingSphere).applyMatrix4(u);let l;if(i)l=z*.5;else{const h=Math.max(r.near,W.distanceToPoint(T.origin));l=de(r,h,c.resolution)}if(W.radius+=l,T.intersectsSphere(W)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),U.copy(s.boundingBox).applyMatrix4(u);let f;if(i)f=z*.5;else{const h=Math.max(r.near,U.distanceToPoint(T.origin));f=de(r,h,c.resolution)}U.expandByScalar(f),T.intersectsBox(U)!==!1&&(i?Ue(this,t):We(this,r,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(F),this.material.uniforms.resolution.value.set(F.z,F.w))}}exports.BLOOM_SCENE=je;exports.BaseObject=Y;exports.IS_DEV=Ce;exports.LineSegments2=Ge;exports.MeshLineMaterial=Ne;exports.PolygonGeometry=_e;exports.ResourceTracker=fe;exports.getMetas=he;
@@ -35,7 +35,7 @@ var re = (s, e, t) => new Promise((i, n) => {
35
35
  }, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, l);
36
36
  r((t = t.apply(s, e)).next());
37
37
  });
38
- import { Material as ae, Object3D as N, Texture as oe, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Be, Points as J, InstancedMesh as xe, Vector3 as P, Quaternion as De, Group as Te, Mesh as we, Sprite as ce, Box3 as Se, ShaderMaterial as ze, Vector2 as q, Color as le, Vector4 as E, Matrix4 as Oe, Line3 as _e, Sphere as ke, InstancedInterleavedBuffer as Ee, InterleavedBufferAttribute as ue, MathUtils as Le } from "three";
38
+ import { Material as ae, Object3D as N, Texture as oe, BufferGeometry as Z, Float32BufferAttribute as R, PointsMaterial as Be, Points as J, InstancedMesh as xe, Vector3 as w, Quaternion as De, Group as Te, Mesh as we, Sprite as ce, Box3 as Se, ShaderMaterial as ze, Vector2 as q, Color as le, Vector4 as E, Matrix4 as Oe, Line3 as _e, Sphere as ke, InstancedInterleavedBuffer as Ee, InterleavedBufferAttribute as ue, MathUtils as Le } from "three";
39
39
  import { CSS2DObject as Ve } from "three/examples/jsm/renderers/CSS2DRenderer";
40
40
  import { CSS3DObject as Ue, CSS3DSprite as We } from "three/examples/jsm/renderers/CSS3DRenderer";
41
41
  import { geoBounds as je, geoContains as Ne, geoDistance as Re, geoInterpolate as Ge } from "d3-geo";
@@ -131,7 +131,7 @@ const tt = (s, e = 1) => {
131
131
  if (s instanceof xe || s.isInstantiate)
132
132
  s.setMatrixAt(n, r);
133
133
  else if (s instanceof J || s.type === "Points") {
134
- const c = s.geometry, f = c.attributes.position.array, d = c.attributes.scaleAtt.array, h = new P(), u = new P(), m = new De(), p = n * 3, v = n * 1;
134
+ const c = s.geometry, f = c.attributes.position.array, d = c.attributes.scaleAtt.array, h = new w(), u = new w(), m = new De(), p = n * 3, v = n * 1;
135
135
  r.decompose(h, m, u), f[p] = h.x, f[p + 1] = h.y, f[p + 2] = h.z, d[v] = Math.max(u.x, u.y, u.z), c.attributes.position.needsUpdate = !0, c.attributes.scaleAtt.needsUpdate = !0;
136
136
  }
137
137
  });
@@ -243,8 +243,9 @@ class pe extends st {
243
243
  get scale() {
244
244
  return this.object3d.scale;
245
245
  }
246
- get lookAt() {
247
- return this.object3d.lookAt;
246
+ lookAt(e) {
247
+ const t = e instanceof w ? e : new w(...e);
248
+ this.object3d.lookAt(t);
248
249
  }
249
250
  add(...e) {
250
251
  [...e].forEach((t) => {
@@ -320,8 +321,8 @@ class pe extends st {
320
321
  return {
321
322
  min: e.min,
322
323
  max: e.max,
323
- size: e.getSize(new P()),
324
- center: e.getCenter(new P())
324
+ size: e.getSize(new w()),
325
+ center: e.getCenter(new w())
325
326
  };
326
327
  }
327
328
  setTop(e) {
@@ -452,18 +453,18 @@ function ct(s, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
452
453
  let m = [];
453
454
  if (u) {
454
455
  const y = Ye(r).triangles(), x = new Map(
455
- r.map(([A, C], O) => [`${A}-${C}`, O])
456
+ r.map(([C, I], O) => [`${C}-${I}`, O])
456
457
  );
457
- y.features.forEach((A) => {
458
- const C = A.geometry.coordinates[0].slice(0, 3).reverse(), O = [];
459
- if (C.forEach(([I, F]) => {
460
- const L = `${I}-${F}`;
458
+ y.features.forEach((C) => {
459
+ const I = C.geometry.coordinates[0].slice(0, 3).reverse(), O = [];
460
+ if (I.forEach(([P, F]) => {
461
+ const L = `${P}-${F}`;
461
462
  x.has(L) && O.push(x.get(L));
462
463
  }), O.length === 3) {
463
- if (O.some((I) => I < a.length)) {
464
- const I = A.properties.circumcenter;
464
+ if (O.some((P) => P < a.length)) {
465
+ const P = C.properties.circumcenter;
465
466
  if (!Y(
466
- I,
467
+ P,
467
468
  o,
468
469
  u
469
470
  ))
@@ -474,20 +475,20 @@ function ct(s, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
474
475
  });
475
476
  } else if (l.length) {
476
477
  const y = Qe.from(r);
477
- for (let x = 0, A = y.triangles.length; x < A; x += 3) {
478
- const C = [2, 1, 0].map((I) => y.triangles[x + I]), O = C.map((I) => r[I]);
479
- if (C.some((I) => I < a.length)) {
480
- const I = [0, 1].map(
478
+ for (let x = 0, C = y.triangles.length; x < C; x += 3) {
479
+ const I = [2, 1, 0].map((P) => y.triangles[x + P]), O = I.map((P) => r[P]);
480
+ if (I.some((P) => P < a.length)) {
481
+ const P = [0, 1].map(
481
482
  (F) => $e(O, (L) => L[F])
482
483
  );
483
484
  if (!Y(
484
- I,
485
+ P,
485
486
  o,
486
487
  u
487
488
  ))
488
489
  continue;
489
490
  }
490
- m.push(...C);
491
+ m.push(...I);
491
492
  }
492
493
  } else {
493
494
  const { vertices: y, holes: x = [] } = Ae(n);
@@ -495,15 +496,15 @@ function ct(s, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
495
496
  }
496
497
  let p = t ? [t[0], t[2]] : de(r, (y) => y[0]), v = t ? [t[1], t[3]] : de(r, (y) => y[1]);
497
498
  if (i) {
498
- const [y, x] = i([p[0], v[0]]), [A, C] = i([p[1], v[1]]);
499
- p = [y, A], v = [-x, -C];
499
+ const [y, x] = i([p[0], v[0]]), [C, I] = i([p[1], v[1]]);
500
+ p = [y, C], v = [-x, -I];
500
501
  }
501
- const w = he(p, [0, 1]), S = he(v, [0, 1]), B = r.map(([y, x]) => {
502
+ const S = he(p, [0, 1]), j = he(v, [0, 1]), B = r.map(([y, x]) => {
502
503
  if (i) {
503
- const [A, C] = i([y, x]);
504
- return [w(A), S(-C)];
504
+ const [C, I] = i([y, x]);
505
+ return [S(C), j(-I)];
505
506
  } else
506
- return [w(y), S(x)];
507
+ return [S(y), j(x)];
507
508
  });
508
509
  return { contour: n, triangles: { points: r, indices: m, uvs: B } };
509
510
  }
@@ -573,8 +574,8 @@ const ut = ({
573
574
  projection: o,
574
575
  bbox: c
575
576
  }) => {
576
- s.forEach((w) => {
577
- Ke(w) || w.reverse();
577
+ s.forEach((S) => {
578
+ Ke(S) || S.reverse();
578
579
  });
579
580
  const { contour: f, triangles: d } = ct(s, {
580
581
  resolution: i,
@@ -634,19 +635,19 @@ class zt extends Z {
634
635
  userDataRsoOffset: c,
635
636
  projection: f
636
637
  } = this.parameters, { contour: d, sideTorso: h, topVerts: u, bottomCap: m, topCap: p } = ut(k({}, this.parameters));
637
- let v = [], w = [], S = [], B = 0;
638
- const j = (y) => {
639
- const x = Math.round(v.length / 3), A = S.length;
640
- v = v.concat(y.vertices), w = w.concat(y.uvs), S = S.concat(
641
- x ? y.indices.map((C) => C + x) : y.indices
642
- ), this.addGroup(A, S.length - A, B++);
638
+ let v = [], S = [], j = [], B = 0;
639
+ const A = (y) => {
640
+ const x = Math.round(v.length / 3), C = j.length;
641
+ v = v.concat(y.vertices), S = S.concat(y.uvs), j = j.concat(
642
+ x ? y.indices.map((I) => I + x) : y.indices
643
+ ), this.addGroup(C, j.length - C, B++);
643
644
  };
644
- n && a && j(p), r && (j(h), this.userData.topVerts = c ? G(
645
+ n && a && A(p), r && (A(h), this.userData.topVerts = c ? G(
645
646
  d,
646
647
  i + c,
647
648
  o,
648
649
  f
649
- ).vertices : u), l && j(m), n && !a && j(p), this.setIndex(S), this[me]("position", new R(v, 3)), this[me]("uv", new R(w, 2)), this.computeVertexNormals();
650
+ ).vertices : u), l && A(m), n && !a && A(p), this.setIndex(j), this[me]("position", new R(v, 3)), this[me]("uv", new R(S, 2)), this.computeVertexNormals();
650
651
  }
651
652
  }
652
653
  const ft = `
@@ -788,7 +789,7 @@ void main() {
788
789
  `;
789
790
  class Ot extends ze {
790
791
  constructor(e = {}) {
791
- const S = e, {
792
+ const j = e, {
792
793
  lineWidth: t = 1,
793
794
  color: i = "#ffffff",
794
795
  opacity: n = 1,
@@ -804,7 +805,7 @@ class Ot extends ze {
804
805
  alphaTest: m = 0,
805
806
  repeat: p = new q(1, 1),
806
807
  resolution: v = new q(1, 1)
807
- } = S, w = se(S, [
808
+ } = j, S = se(j, [
808
809
  "lineWidth",
809
810
  "color",
810
811
  "opacity",
@@ -821,7 +822,7 @@ class Ot extends ze {
821
822
  "repeat",
822
823
  "resolution"
823
824
  ]);
824
- super($(k({}, w), {
825
+ super($(k({}, S), {
825
826
  uniforms: {
826
827
  lineWidth: { value: t },
827
828
  color: { value: new le(i) },
@@ -894,7 +895,7 @@ class Ot extends ze {
894
895
  this.uniforms.sizeAttenuation.value = e ? 1 : 0;
895
896
  }
896
897
  }
897
- const K = new E(), ye = new P(), be = new P(), b = new E(), g = new E(), D = new E(), Q = new P(), X = new Oe(), M = new _e(), ge = new P(), U = new Se(), W = new ke(), T = new E();
898
+ const K = new E(), ye = new w(), be = new w(), b = new E(), g = new E(), D = new E(), Q = new w(), X = new Oe(), M = new _e(), ge = new w(), U = new Se(), W = new ke(), T = new E();
898
899
  let z, _;
899
900
  function Me(s, e, t) {
900
901
  return T.set(0, 0, -e, 1).applyMatrix4(s.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = _ / t.width, T.y = _ / t.height, T.applyMatrix4(s.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
@@ -903,7 +904,7 @@ function ht(s, e) {
903
904
  const t = s.matrixWorld, i = s.geometry, n = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, n.count);
904
905
  for (let r = 0, o = l; r < o; r++) {
905
906
  M.start.fromBufferAttribute(n, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(t);
906
- const c = new P(), f = new P();
907
+ const c = new w(), f = new w();
907
908
  z.distanceSqToSegment(M.start, M.end, f, c), f.distanceTo(c) < _ * 0.5 && e.push({
908
909
  point: f,
909
910
  pointOnLine: c,
@@ -923,23 +924,23 @@ function pt(s, e, t) {
923
924
  if (b.fromBufferAttribute(o, h), g.fromBufferAttribute(c, h), b.w = 1, g.w = 1, b.applyMatrix4(X), g.applyMatrix4(X), b.z > d && g.z > d)
924
925
  continue;
925
926
  if (b.z > d) {
926
- const B = b.z - g.z, j = (b.z - d) / B;
927
- b.lerp(g, j);
927
+ const B = b.z - g.z, A = (b.z - d) / B;
928
+ b.lerp(g, A);
928
929
  } else if (g.z > d) {
929
- const B = g.z - b.z, j = (g.z - d) / B;
930
- g.lerp(b, j);
930
+ const B = g.z - b.z, A = (g.z - d) / B;
931
+ g.lerp(b, A);
931
932
  }
932
933
  b.applyMatrix4(i), g.applyMatrix4(i), b.multiplyScalar(1 / b.w), g.multiplyScalar(1 / g.w), b.x *= a.x / 2, b.y *= a.y / 2, g.x *= a.x / 2, g.y *= a.y / 2, M.start.copy(b), M.start.z = 0, M.end.copy(g), M.end.z = 0;
933
934
  const p = M.closestPointToPointParameter(Q, !0);
934
935
  M.at(p, ge);
935
- const v = Le.lerp(b.z, g.z, p), w = v >= -1 && v <= 1, S = Q.distanceTo(ge) < _ * 0.5;
936
- if (w && S) {
936
+ const v = Le.lerp(b.z, g.z, p), S = v >= -1 && v <= 1, j = Q.distanceTo(ge) < _ * 0.5;
937
+ if (S && j) {
937
938
  M.start.fromBufferAttribute(o, h), M.end.fromBufferAttribute(c, h), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
938
- const B = new P(), j = new P();
939
- z.distanceSqToSegment(M.start, M.end, j, B), t.push({
940
- point: j,
939
+ const B = new w(), A = new w();
940
+ z.distanceSqToSegment(M.start, M.end, A, B), t.push({
941
+ point: A,
941
942
  pointOnLine: B,
942
- distance: z.origin.distanceTo(j),
943
+ distance: z.origin.distanceTo(A),
943
944
  object: s,
944
945
  face: null,
945
946
  faceIndex: h,
@@ -26,10 +26,7 @@ export default class BaseObject extends UseMaterial {
26
26
  get position(): Vector3;
27
27
  get rotation(): import("three").Euler;
28
28
  get scale(): Vector3;
29
- get lookAt(): {
30
- (vector: Vector3): void;
31
- (x: number, y: number, z: number): void;
32
- };
29
+ lookAt(vector: Vector3 | [number, number, number]): void;
33
30
  add(...object: Object3D[]): void;
34
31
  remove(...object: Object3D[]): void;
35
32
  get visible(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gl-draw",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "author": "gitplus <hstits@gmail.com>",
5
5
  "scripts": {
6
6
  "start": "bundler-dev",