gl-draw 0.16.6 → 0.16.7
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
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
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=`
|
|
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,v=l.attributes.position.array,d=l.attributes.scaleAtt.array,p=new o.Vector3,f=new o.Vector3,m=new o.Quaternion,h=r*3,y=r*1;s.decompose(p,m,f),v[h]=p.x,v[h+1]=p.y,v[h+2]=p.z,d[y]=Math.max(f.x,f.y,f.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 l,v;const t=(l=e==null?void 0:e.recursive)!=null?l:!0,i=(v=e==null?void 0:e.cloneMaterial)!=null?v:!1,{objectType:r,objectOptions:a}=this;let u=e==null?void 0:e.create,s,c=(e==null?void 0:e.target)||this.parent;return c===this.lead.prefabGroup&&(c=this.lead.group),this.objectType==="BaseObject"?s=this.lead.createBaseObject(this.object3d.clone(!1),{target:c}):(u===void 0&&(u=d=>{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)d.object3d=Be(this.object3d,f);else{const m=this.object3d,h=i?this.cloneMaterial():m.material;d.object3d=new o.InstancedMesh(m.geometry,h,f)}Ie(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}}),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:c}))),this.isBloom&&s.enableBloom(),t&&(yield Promise.all(this.children.map(d=>d.instantiate({key:d.keyUId?`${d.keyName}-${d.keyUId}`:d.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=f=>f/u*360%360-180,c=f=>Math.acos(2*f/a-1)/Math.PI*180-90,l=f=>a*(Math.cos((f+90)*Math.PI/180)+1)/2,v=[r!==void 0?Math.ceil(l(r)):0,i!==void 0?Math.floor(l(i)):a-1],d=e===void 0&&t===void 0?()=>!0:e===void 0?f=>f<=t:t===void 0?f=>f>=e:t>=e?f=>f>=e&&f<=t:f=>f>=e||f<=t,p=[];for(let f=v[0];f<=v[1];f++){const m=s(f);d(m)&&p.push([m,c(f)])}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,v],[d,p]]=E.geoBounds(c),f=l>d||p>=89||v<=-89;let m=[];if(f){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,f))return}m.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,f))continue}m.push(...B)}}else{const{vertices:b,holes:S=[]}=X.flatten(r);m=X(b,S,2)}let h=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([h[0],y[0]]),[C,B]=i([h[1],y[1]]);h=[b,C],y=[-S,-B]}const w=se.scaleLinear(h,[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:m,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),v=new Set(u);let d=0;const p=[];for(let m=0;m<l;m++){let h=m+1;if(h===l)h=d;else if(v.has(h)){const y=h;h=d,d=y}p.push(m,m+l,h+l),p.push(h+l,h,m)}const f=[];for(let m=1;m>=0;m--)for(let h=0;h<l;h+=1)f.push(h/(l-1),m);return{indices:p,vertices:c,uvs:f,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:v,triangles:d}=ze(n,{resolution:i,bbox:l,projection:c});let p={},f;a&&(p=Le(v,e!=null?e:t,t!=null?t:e,r,c),f=p.topVerts);let m=[];(u||s)&&(m=L.merge(d.uvs));let h={};u&&(h=ae(d,e,m,!1,r,c));let y={};return s&&(y=ae(d,t,m,!0,r,c)),{contour:v,triangles:d,sideTorso:p,bottomCap:h,topCap:y,topVerts:f}};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:v}=this.parameters,{contour:d,sideTorso:p,topVerts:f,bottomCap:m,topCap:h}=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(h),s&&(A(p),this.userData.topVerts=l?G(d,i+l,c,v).vertices:f),u&&A(m),r&&!a&&A(h),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 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:
|
|
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:v=!0,offset:d=new o.Vector2(0,0),scaleDown:p=0,alphaMap:f=void 0,alphaTest:m=0,repeat:h=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:d},offsetLoop:{value:v?1:0},dashArray:{value:s},dashOffset:{value:u},dashRatio:{value:c},useDash:{value:s>0?1:0},scaleDown:{value:p/10},alphaTest:{value:m},alphaMap:{value:f},useAlphaMap:{value:f?1:0},repeat:{value:h}},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,v=new o.Vector3;T.distanceSqToSegment(x.start,x.end,v,l),v.distanceTo(l)<z*.5&&e.push({point:v,pointOnLine:l,distance:T.origin.distanceTo(v),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,v=Math.min(s.instanceCount,c.count),d=-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,f=v;p<f;p++){if(g.fromBufferAttribute(c,p),M.fromBufferAttribute(l,p),g.w=1,M.w=1,g.applyMatrix4(K),M.applyMatrix4(K),g.z>d&&M.z>d)continue;if(g.z>d){const P=g.z-M.z,A=(g.z-d)/P;g.lerp(M,A)}else if(M.z>d){const P=M.z-g.z,A=(M.z-d)/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 h=x.closestPointToPointParameter($,!0);x.at(h,ue);const y=o.MathUtils.lerp(g.z,M.z,h),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 d=Math.max(r.near,W.distanceToPoint(T.origin));l=de(r,d,c.resolution)}if(W.radius+=l,T.intersectsSphere(W)===!1)return;s.boundingBox===null&&s.computeBoundingBox(),U.copy(s.boundingBox).applyMatrix4(u);let v;if(i)v=z*.5;else{const d=Math.max(r.near,U.distanceToPoint(T.origin));v=de(r,d,c.resolution)}U.expandByScalar(v),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;
|
|
@@ -2,38 +2,38 @@ var Ce = Object.defineProperty, Ie = Object.defineProperties;
|
|
|
2
2
|
var Pe = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var V = Object.getOwnPropertySymbols;
|
|
4
4
|
var te = Object.prototype.hasOwnProperty, ie = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var se = Math.pow, ee = (n, e, t) => e in n ? Ce(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, k = (n, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
te.call(e, t) && ee(
|
|
7
|
+
te.call(e, t) && ee(n, t, e[t]);
|
|
8
8
|
if (V)
|
|
9
9
|
for (var t of V(e))
|
|
10
|
-
ie.call(e, t) && ee(
|
|
11
|
-
return
|
|
12
|
-
}, $ = (
|
|
13
|
-
var
|
|
10
|
+
ie.call(e, t) && ee(n, t, e[t]);
|
|
11
|
+
return n;
|
|
12
|
+
}, $ = (n, e) => Ie(n, Pe(e));
|
|
13
|
+
var ne = (n, e) => {
|
|
14
14
|
var t = {};
|
|
15
|
-
for (var i in
|
|
16
|
-
te.call(
|
|
17
|
-
if (
|
|
18
|
-
for (var i of V(
|
|
19
|
-
e.indexOf(i) < 0 && ie.call(
|
|
15
|
+
for (var i in n)
|
|
16
|
+
te.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
|
|
17
|
+
if (n != null && V)
|
|
18
|
+
for (var i of V(n))
|
|
19
|
+
e.indexOf(i) < 0 && ie.call(n, i) && (t[i] = n[i]);
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var re = (
|
|
22
|
+
var re = (n, e, t) => new Promise((i, s) => {
|
|
23
23
|
var a = (o) => {
|
|
24
24
|
try {
|
|
25
25
|
r(t.next(o));
|
|
26
26
|
} catch (c) {
|
|
27
|
-
|
|
27
|
+
s(c);
|
|
28
28
|
}
|
|
29
29
|
}, l = (o) => {
|
|
30
30
|
try {
|
|
31
31
|
r(t.throw(o));
|
|
32
32
|
} catch (c) {
|
|
33
|
-
|
|
33
|
+
s(c);
|
|
34
34
|
}
|
|
35
35
|
}, r = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, l);
|
|
36
|
-
r((t = t.apply(
|
|
36
|
+
r((t = t.apply(n, e)).next());
|
|
37
37
|
});
|
|
38
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";
|
|
@@ -75,8 +75,8 @@ class et {
|
|
|
75
75
|
if (t.uniforms) {
|
|
76
76
|
for (const i of Object.values(t.uniforms))
|
|
77
77
|
if (i) {
|
|
78
|
-
const
|
|
79
|
-
(
|
|
78
|
+
const s = i.value;
|
|
79
|
+
(s instanceof oe || Array.isArray(s)) && this.track(s);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
} else this.disposeVideo && e.isVideoTexture && e.source.data && this.resources.add(e.source.data);
|
|
@@ -91,7 +91,7 @@ class et {
|
|
|
91
91
|
}), e.length = 0, this.resources.clear();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
const tt = (
|
|
94
|
+
const tt = (n, e = 1) => {
|
|
95
95
|
const t = new Z();
|
|
96
96
|
t.setAttribute(
|
|
97
97
|
"position",
|
|
@@ -100,7 +100,7 @@ const tt = (s, e = 1) => {
|
|
|
100
100
|
"scaleAtt",
|
|
101
101
|
new R(new Array(e).fill(1), 1)
|
|
102
102
|
);
|
|
103
|
-
const i =
|
|
103
|
+
const i = n.material, s = new Be({
|
|
104
104
|
size: 10,
|
|
105
105
|
map: i.map,
|
|
106
106
|
alphaMap: i.alphaMap,
|
|
@@ -113,7 +113,7 @@ const tt = (s, e = 1) => {
|
|
|
113
113
|
alphaTest: i.alphaTest,
|
|
114
114
|
sizeAttenuation: !1
|
|
115
115
|
});
|
|
116
|
-
return
|
|
116
|
+
return s.onBeforeCompile = (a) => {
|
|
117
117
|
a.vertexShader = `
|
|
118
118
|
attribute float scaleAtt;
|
|
119
119
|
${a.vertexShader.replace(
|
|
@@ -121,22 +121,22 @@ const tt = (s, e = 1) => {
|
|
|
121
121
|
"gl_PointSize = size * scaleAtt;"
|
|
122
122
|
)}
|
|
123
123
|
`;
|
|
124
|
-
}, new J(t,
|
|
125
|
-
}, it = (
|
|
124
|
+
}, new J(t, s);
|
|
125
|
+
}, it = (n, e) => {
|
|
126
126
|
const t = new N();
|
|
127
|
-
e.forEach((i,
|
|
127
|
+
e.forEach((i, s) => {
|
|
128
128
|
const a = fe(i.position), l = fe(i.scale || [1, 1, 1]);
|
|
129
129
|
t.position.copy(a), t.scale.copy(l), t.updateMatrix();
|
|
130
130
|
const r = t.matrix.clone();
|
|
131
|
-
if (
|
|
132
|
-
|
|
133
|
-
else if (
|
|
134
|
-
const c =
|
|
135
|
-
r.decompose(h,
|
|
131
|
+
if (n instanceof xe || n.isInstantiate)
|
|
132
|
+
n.setMatrixAt(s, r);
|
|
133
|
+
else if (n instanceof J || n.type === "Points") {
|
|
134
|
+
const c = n.geometry, m = c.attributes.position.array, u = c.attributes.scaleAtt.array, h = new w(), f = new w(), p = new De(), d = s * 3, v = s * 1;
|
|
135
|
+
r.decompose(h, p, f), m[d] = h.x, m[d + 1] = h.y, m[d + 2] = h.z, u[v] = Math.max(f.x, f.y, f.z), c.attributes.position.needsUpdate = !0, c.attributes.scaleAtt.needsUpdate = !0;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
};
|
|
139
|
-
class
|
|
139
|
+
class st {
|
|
140
140
|
constructor() {
|
|
141
141
|
this.onPointerIndex = [];
|
|
142
142
|
}
|
|
@@ -165,7 +165,7 @@ class nt {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
class
|
|
168
|
+
class nt extends st {
|
|
169
169
|
constructor() {
|
|
170
170
|
super(...arguments), this.userData = {}, this.materialList = {}, this.useMaterialType = "origin", this.disposeMaterialIfNotUsed = !0;
|
|
171
171
|
}
|
|
@@ -176,16 +176,16 @@ class st extends nt {
|
|
|
176
176
|
const t = e.material;
|
|
177
177
|
if (Array.isArray(t))
|
|
178
178
|
return t.map((i) => {
|
|
179
|
-
const
|
|
179
|
+
const s = i.userData;
|
|
180
180
|
i.userData = {};
|
|
181
181
|
const a = i.clone();
|
|
182
|
-
return i.userData =
|
|
182
|
+
return i.userData = s, a;
|
|
183
183
|
});
|
|
184
184
|
{
|
|
185
185
|
const i = t.userData;
|
|
186
186
|
t.userData = {};
|
|
187
|
-
const
|
|
188
|
-
return t.userData = i,
|
|
187
|
+
const s = t.clone();
|
|
188
|
+
return t.userData = i, s;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
setMaterialList(e, t) {
|
|
@@ -193,8 +193,8 @@ class st extends nt {
|
|
|
193
193
|
if (!i || !i.material)
|
|
194
194
|
return;
|
|
195
195
|
this.materialList.origin || (this.materialList.origin = i.material);
|
|
196
|
-
const
|
|
197
|
-
return this.materialList[e] =
|
|
196
|
+
const s = t === "clone" ? this.cloneMaterial() : Array.isArray(t) ? t.slice() : t;
|
|
197
|
+
return this.materialList[e] = s, s;
|
|
198
198
|
}
|
|
199
199
|
useMaterial(e) {
|
|
200
200
|
const t = this.object3d;
|
|
@@ -206,8 +206,8 @@ class st extends nt {
|
|
|
206
206
|
const i = this.mList.get(e);
|
|
207
207
|
if (!i)
|
|
208
208
|
return;
|
|
209
|
-
const
|
|
210
|
-
Array.isArray(
|
|
209
|
+
const s = this.object3d;
|
|
210
|
+
Array.isArray(s.material) && t !== void 0 ? s.material[t] = i : s.material = i;
|
|
211
211
|
}
|
|
212
212
|
useMListByName(e, t) {
|
|
213
213
|
if (!this.mList)
|
|
@@ -223,7 +223,7 @@ class st extends nt {
|
|
|
223
223
|
);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
|
-
class pe extends
|
|
226
|
+
class pe extends nt {
|
|
227
227
|
constructor() {
|
|
228
228
|
super(...arguments), this.key = "", this.objectType = "BaseObject", this.userData = {}, this.isPrefab = !1, this.isInstantiate = !1, this.isBloom = !1, this.isBaseObject = !0, this.disposeTrack = !0;
|
|
229
229
|
}
|
|
@@ -335,42 +335,42 @@ class pe extends st {
|
|
|
335
335
|
}
|
|
336
336
|
instantiate(e) {
|
|
337
337
|
return re(this, null, function* () {
|
|
338
|
-
var
|
|
339
|
-
const t = (
|
|
340
|
-
let l = e == null ? void 0 : e.create, r;
|
|
341
|
-
return this.objectType === "BaseObject" ? r = this.lead.createBaseObject(this.object3d.clone(!1), {
|
|
342
|
-
target:
|
|
343
|
-
}) : (l === void 0 && (l = (
|
|
344
|
-
var
|
|
338
|
+
var c, m;
|
|
339
|
+
const t = (c = e == null ? void 0 : e.recursive) != null ? c : !0, i = (m = e == null ? void 0 : e.cloneMaterial) != null ? m : !1, { objectType: s, objectOptions: a } = this;
|
|
340
|
+
let l = e == null ? void 0 : e.create, r, o = (e == null ? void 0 : e.target) || this.parent;
|
|
341
|
+
return o === this.lead.prefabGroup && (o = this.lead.group), this.objectType === "BaseObject" ? r = this.lead.createBaseObject(this.object3d.clone(!1), {
|
|
342
|
+
target: o
|
|
343
|
+
}) : (l === void 0 && (l = (u) => {
|
|
344
|
+
var h;
|
|
345
345
|
if (this.object3d) {
|
|
346
|
-
if ((
|
|
347
|
-
const
|
|
346
|
+
if ((h = e == null ? void 0 : e.instancedAttr) != null && h.length) {
|
|
347
|
+
const f = e.instancedAttr.length;
|
|
348
348
|
if (this.object3d instanceof ce)
|
|
349
|
-
|
|
349
|
+
u.object3d = tt(this.object3d, f);
|
|
350
350
|
else {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
351
|
+
const p = this.object3d, d = i ? this.cloneMaterial() : p.material;
|
|
352
|
+
u.object3d = new xe(
|
|
353
|
+
p.geometry,
|
|
354
|
+
d,
|
|
355
|
+
f
|
|
356
356
|
);
|
|
357
357
|
}
|
|
358
|
-
it(
|
|
358
|
+
it(u.object3d, e == null ? void 0 : e.instancedAttr);
|
|
359
359
|
} else
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
u.object3d = this.object3d.clone(!1), i && u.object3d.material && (u.object3d.material = this.cloneMaterial());
|
|
361
|
+
u.object3d.userData.prefab && delete u.object3d.userData.prefab;
|
|
362
362
|
}
|
|
363
|
-
}), r = yield this.lead.draw(
|
|
363
|
+
}), r = yield this.lead.draw(s, $(k({}, a || {}), {
|
|
364
364
|
create: l,
|
|
365
365
|
prefab: !1,
|
|
366
366
|
keyType: this.keyType,
|
|
367
367
|
key: (e == null ? void 0 : e.key) || this.keyName,
|
|
368
368
|
uId: (e == null ? void 0 : e.uId) || this.keyUId,
|
|
369
|
-
target:
|
|
369
|
+
target: o
|
|
370
370
|
}))), this.isBloom && r.enableBloom(), t && (yield Promise.all(
|
|
371
371
|
this.children.map(
|
|
372
|
-
(
|
|
373
|
-
key:
|
|
372
|
+
(u) => u.instantiate({
|
|
373
|
+
key: u.keyUId ? `${u.keyName}-${u.keyUId}` : u.keyName,
|
|
374
374
|
uId: e == null ? void 0 : e.uId,
|
|
375
375
|
cloneMaterial: i,
|
|
376
376
|
target: r
|
|
@@ -400,58 +400,58 @@ class pe extends st {
|
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function rt(
|
|
404
|
-
return
|
|
403
|
+
function rt(n, e) {
|
|
404
|
+
return n.map((t) => {
|
|
405
405
|
const i = [];
|
|
406
|
-
let
|
|
406
|
+
let s;
|
|
407
407
|
return t.forEach((a) => {
|
|
408
|
-
if (
|
|
409
|
-
const l = Re(a,
|
|
408
|
+
if (s) {
|
|
409
|
+
const l = Re(a, s) * 180 / Math.PI;
|
|
410
410
|
if (l > e) {
|
|
411
|
-
const r = Ge(
|
|
411
|
+
const r = Ge(s, a), o = 1 / Math.ceil(l / e);
|
|
412
412
|
let c = o;
|
|
413
413
|
for (; c < 1; )
|
|
414
414
|
i.push(r(c)), c += o;
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
i.push(
|
|
417
|
+
i.push(s = a);
|
|
418
418
|
}), i;
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
|
-
function at(
|
|
422
|
-
const a = Math.round(
|
|
423
|
-
|
|
421
|
+
function at(n, { minLng: e, maxLng: t, minLat: i, maxLat: s } = {}) {
|
|
422
|
+
const a = Math.round(se(360 / n, 2) / Math.PI), l = (1 + Math.sqrt(5)) / 2, r = (f) => f / l * 360 % 360 - 180, o = (f) => Math.acos(2 * f / a - 1) / Math.PI * 180 - 90, c = (f) => a * (Math.cos((f + 90) * Math.PI / 180) + 1) / 2, m = [
|
|
423
|
+
s !== void 0 ? Math.ceil(c(s)) : 0,
|
|
424
424
|
i !== void 0 ? Math.floor(c(i)) : a - 1
|
|
425
|
-
],
|
|
426
|
-
for (let
|
|
427
|
-
const
|
|
428
|
-
|
|
425
|
+
], u = e === void 0 && t === void 0 ? () => !0 : e === void 0 ? (f) => f <= t : t === void 0 ? (f) => f >= e : t >= e ? (f) => f >= e && f <= t : (f) => f >= e || f <= t, h = [];
|
|
426
|
+
for (let f = m[0]; f <= m[1]; f++) {
|
|
427
|
+
const p = r(f);
|
|
428
|
+
u(p) && h.push([p, o(f)]);
|
|
429
429
|
}
|
|
430
430
|
return h;
|
|
431
431
|
}
|
|
432
|
-
function Y(
|
|
433
|
-
return t ? Ne(e,
|
|
432
|
+
function Y(n, e, t = !1) {
|
|
433
|
+
return t ? Ne(e, n) : Xe(n, e);
|
|
434
434
|
}
|
|
435
|
-
function ot(
|
|
436
|
-
const t = { type: "Polygon", coordinates:
|
|
437
|
-
if (Math.min(Math.abs(a - i), Math.abs(l -
|
|
435
|
+
function ot(n, e) {
|
|
436
|
+
const t = { type: "Polygon", coordinates: n }, [[i, s], [a, l]] = je(t);
|
|
437
|
+
if (Math.min(Math.abs(a - i), Math.abs(l - s)) < e)
|
|
438
438
|
return [];
|
|
439
|
-
const r = i > a || l >= 89 ||
|
|
439
|
+
const r = i > a || l >= 89 || s <= -89;
|
|
440
440
|
return at(e, {
|
|
441
441
|
minLng: i,
|
|
442
442
|
maxLng: a,
|
|
443
|
-
minLat:
|
|
443
|
+
minLat: s,
|
|
444
444
|
maxLat: l
|
|
445
445
|
}).filter(
|
|
446
446
|
(o) => Y(o, t, r)
|
|
447
447
|
);
|
|
448
448
|
}
|
|
449
|
-
function ct(
|
|
450
|
-
const
|
|
449
|
+
function ct(n, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
|
|
450
|
+
const s = rt(n, e), a = H(s), l = ot(n, e), r = [...a, ...l], o = { type: "Polygon", coordinates: n }, [[c, m], [u, h]] = je(o), f = c > u || // crosses antimeridian
|
|
451
451
|
h >= 89 || // crosses north pole
|
|
452
|
-
|
|
453
|
-
let
|
|
454
|
-
if (
|
|
452
|
+
m <= -89;
|
|
453
|
+
let p = [];
|
|
454
|
+
if (f) {
|
|
455
455
|
const y = Ye(r).triangles(), x = new Map(
|
|
456
456
|
r.map(([C, I], O) => [`${C}-${I}`, O])
|
|
457
457
|
);
|
|
@@ -466,11 +466,11 @@ function ct(s, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
|
|
|
466
466
|
if (!Y(
|
|
467
467
|
P,
|
|
468
468
|
o,
|
|
469
|
-
|
|
469
|
+
f
|
|
470
470
|
))
|
|
471
471
|
return;
|
|
472
472
|
}
|
|
473
|
-
|
|
473
|
+
p.push(...O);
|
|
474
474
|
}
|
|
475
475
|
});
|
|
476
476
|
} else if (l.length) {
|
|
@@ -484,33 +484,33 @@ function ct(s, { resolution: e = 1 / 0, bbox: t, projection: i } = {}) {
|
|
|
484
484
|
if (!Y(
|
|
485
485
|
P,
|
|
486
486
|
o,
|
|
487
|
-
|
|
487
|
+
f
|
|
488
488
|
))
|
|
489
489
|
continue;
|
|
490
490
|
}
|
|
491
|
-
|
|
491
|
+
p.push(...I);
|
|
492
492
|
}
|
|
493
493
|
} else {
|
|
494
|
-
const { vertices: y, holes: x = [] } = Ae(
|
|
495
|
-
|
|
494
|
+
const { vertices: y, holes: x = [] } = Ae(s);
|
|
495
|
+
p = qe(y, x, 2);
|
|
496
496
|
}
|
|
497
|
-
let
|
|
497
|
+
let d = t ? [t[0], t[2]] : de(r, (y) => y[0]), v = t ? [t[1], t[3]] : de(r, (y) => y[1]);
|
|
498
498
|
if (i) {
|
|
499
|
-
const [y, x] = i([
|
|
500
|
-
|
|
499
|
+
const [y, x] = i([d[0], v[0]]), [C, I] = i([d[1], v[1]]);
|
|
500
|
+
d = [y, C], v = [-x, -I];
|
|
501
501
|
}
|
|
502
|
-
const S = he(
|
|
502
|
+
const S = he(d, [0, 1]), j = he(v, [0, 1]), B = r.map(([y, x]) => {
|
|
503
503
|
if (i) {
|
|
504
504
|
const [C, I] = i([y, x]);
|
|
505
505
|
return [S(C), j(-I)];
|
|
506
506
|
} else
|
|
507
507
|
return [S(y), j(x)];
|
|
508
508
|
});
|
|
509
|
-
return { contour:
|
|
509
|
+
return { contour: s, triangles: { points: r, indices: p, uvs: B } };
|
|
510
510
|
}
|
|
511
511
|
const me = new Z().setAttribute ? "setAttribute" : "addAttribute";
|
|
512
|
-
function G(
|
|
513
|
-
const
|
|
512
|
+
function G(n, e, t, i) {
|
|
513
|
+
const s = n.map(
|
|
514
514
|
(a) => a.map(([l, r]) => {
|
|
515
515
|
if (i) {
|
|
516
516
|
const [o, c] = i([l, r]);
|
|
@@ -519,97 +519,97 @@ function G(s, e, t, i) {
|
|
|
519
519
|
return t ? Fe(l, r, e) : [l, r, e];
|
|
520
520
|
})
|
|
521
521
|
);
|
|
522
|
-
return Ae(
|
|
522
|
+
return Ae(s);
|
|
523
523
|
}
|
|
524
|
-
function lt(
|
|
524
|
+
function lt(n, e, t, i, s) {
|
|
525
525
|
const { vertices: a, holes: l } = G(
|
|
526
|
-
|
|
526
|
+
n,
|
|
527
527
|
e,
|
|
528
528
|
i,
|
|
529
|
-
|
|
529
|
+
s
|
|
530
530
|
), { vertices: r } = G(
|
|
531
|
-
|
|
531
|
+
n,
|
|
532
532
|
t,
|
|
533
533
|
i,
|
|
534
|
-
|
|
535
|
-
), o = H([r, a]), c = Math.round(r.length / 3),
|
|
536
|
-
let
|
|
534
|
+
s
|
|
535
|
+
), o = H([r, a]), c = Math.round(r.length / 3), m = new Set(l);
|
|
536
|
+
let u = 0;
|
|
537
537
|
const h = [];
|
|
538
|
-
for (let
|
|
539
|
-
let
|
|
540
|
-
if (
|
|
541
|
-
|
|
542
|
-
else if (
|
|
543
|
-
const v =
|
|
544
|
-
|
|
538
|
+
for (let p = 0; p < c; p++) {
|
|
539
|
+
let d = p + 1;
|
|
540
|
+
if (d === c)
|
|
541
|
+
d = u;
|
|
542
|
+
else if (m.has(d)) {
|
|
543
|
+
const v = d;
|
|
544
|
+
d = u, u = v;
|
|
545
545
|
}
|
|
546
|
-
h.push(
|
|
546
|
+
h.push(p, p + c, d + c), h.push(d + c, d, p);
|
|
547
547
|
}
|
|
548
|
-
const
|
|
549
|
-
for (let
|
|
550
|
-
for (let
|
|
551
|
-
return { indices: h, vertices: o, uvs:
|
|
548
|
+
const f = [];
|
|
549
|
+
for (let p = 1; p >= 0; p--)
|
|
550
|
+
for (let d = 0; d < c; d += 1) f.push(d / (c - 1), p);
|
|
551
|
+
return { indices: h, vertices: o, uvs: f, topVerts: r };
|
|
552
552
|
}
|
|
553
|
-
function ve(
|
|
553
|
+
function ve(n, e, t, i, s, a) {
|
|
554
554
|
return {
|
|
555
|
-
indices: i ?
|
|
555
|
+
indices: i ? n.indices : n.indices.slice().reverse(),
|
|
556
556
|
vertices: G(
|
|
557
|
-
[
|
|
557
|
+
[n.points],
|
|
558
558
|
e,
|
|
559
|
-
|
|
559
|
+
s,
|
|
560
560
|
a
|
|
561
561
|
).vertices,
|
|
562
562
|
uvs: t
|
|
563
563
|
};
|
|
564
564
|
}
|
|
565
565
|
const ut = ({
|
|
566
|
-
polygonGeoJson:
|
|
566
|
+
polygonGeoJson: n,
|
|
567
567
|
startHeight: e,
|
|
568
568
|
endHeight: t,
|
|
569
569
|
curvatureResolution: i = 1,
|
|
570
|
-
cartesian:
|
|
570
|
+
cartesian: s = !0,
|
|
571
571
|
hasSide: a = !0,
|
|
572
572
|
hasBottom: l = !1,
|
|
573
573
|
hasTop: r = !1,
|
|
574
574
|
projection: o,
|
|
575
575
|
bbox: c
|
|
576
576
|
}) => {
|
|
577
|
-
|
|
577
|
+
n.forEach((S) => {
|
|
578
578
|
Ke(S) || S.reverse();
|
|
579
579
|
});
|
|
580
|
-
const { contour:
|
|
580
|
+
const { contour: m, triangles: u } = ct(n, {
|
|
581
581
|
resolution: i,
|
|
582
582
|
bbox: c,
|
|
583
583
|
projection: o
|
|
584
584
|
});
|
|
585
|
-
let h = {},
|
|
585
|
+
let h = {}, f;
|
|
586
586
|
a && (h = lt(
|
|
587
|
-
|
|
587
|
+
m,
|
|
588
588
|
e != null ? e : t,
|
|
589
589
|
t != null ? t : e,
|
|
590
|
-
|
|
590
|
+
s,
|
|
591
591
|
o
|
|
592
|
-
),
|
|
593
|
-
let
|
|
594
|
-
(l || r) && (
|
|
595
|
-
let
|
|
596
|
-
l && (
|
|
597
|
-
|
|
592
|
+
), f = h.topVerts);
|
|
593
|
+
let p = [];
|
|
594
|
+
(l || r) && (p = H(u.uvs));
|
|
595
|
+
let d = {};
|
|
596
|
+
l && (d = ve(
|
|
597
|
+
u,
|
|
598
598
|
e,
|
|
599
|
-
|
|
599
|
+
p,
|
|
600
600
|
!1,
|
|
601
|
-
|
|
601
|
+
s,
|
|
602
602
|
o
|
|
603
603
|
));
|
|
604
604
|
let v = {};
|
|
605
605
|
return r && (v = ve(
|
|
606
|
-
|
|
606
|
+
u,
|
|
607
607
|
t,
|
|
608
|
-
|
|
608
|
+
p,
|
|
609
609
|
!0,
|
|
610
|
-
|
|
610
|
+
s,
|
|
611
611
|
o
|
|
612
|
-
)), { contour:
|
|
612
|
+
)), { contour: m, triangles: u, sideTorso: h, bottomCap: d, topCap: v, topVerts: f };
|
|
613
613
|
};
|
|
614
614
|
class zt extends Z {
|
|
615
615
|
constructor(e, t = {}) {
|
|
@@ -627,14 +627,14 @@ class zt extends Z {
|
|
|
627
627
|
}, t);
|
|
628
628
|
const {
|
|
629
629
|
endHeight: i,
|
|
630
|
-
hasTop:
|
|
630
|
+
hasTop: s,
|
|
631
631
|
topFirst: a,
|
|
632
632
|
hasBottom: l,
|
|
633
633
|
hasSide: r,
|
|
634
634
|
cartesian: o,
|
|
635
635
|
userDataRsoOffset: c,
|
|
636
|
-
projection:
|
|
637
|
-
} = this.parameters, { contour:
|
|
636
|
+
projection: m
|
|
637
|
+
} = this.parameters, { contour: u, sideTorso: h, topVerts: f, bottomCap: p, topCap: d } = ut(k({}, this.parameters));
|
|
638
638
|
let v = [], S = [], j = [], B = 0;
|
|
639
639
|
const A = (y) => {
|
|
640
640
|
const x = Math.round(v.length / 3), C = j.length;
|
|
@@ -642,12 +642,12 @@ class zt extends Z {
|
|
|
642
642
|
x ? y.indices.map((I) => I + x) : y.indices
|
|
643
643
|
), this.addGroup(C, j.length - C, B++);
|
|
644
644
|
};
|
|
645
|
-
|
|
646
|
-
|
|
645
|
+
s && a && A(d), r && (A(h), this.userData.topVerts = c ? G(
|
|
646
|
+
u,
|
|
647
647
|
i + c,
|
|
648
648
|
o,
|
|
649
|
-
|
|
650
|
-
).vertices :
|
|
649
|
+
m
|
|
650
|
+
).vertices : f), l && A(p), s && !a && A(d), this.setIndex(j), this[me]("position", new R(v, 3)), this[me]("uv", new R(S, 2)), this.computeVertexNormals();
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
const ft = `
|
|
@@ -792,20 +792,20 @@ class Ot extends ze {
|
|
|
792
792
|
const j = e, {
|
|
793
793
|
lineWidth: t = 1,
|
|
794
794
|
color: i = "#ffffff",
|
|
795
|
-
opacity:
|
|
795
|
+
opacity: s = 1,
|
|
796
796
|
map: a = null,
|
|
797
797
|
dashOffset: l = 0,
|
|
798
798
|
dashArray: r = 0,
|
|
799
799
|
dashRatio: o = 0,
|
|
800
800
|
sizeAttenuation: c = !0,
|
|
801
|
-
offsetLoop:
|
|
802
|
-
offset:
|
|
801
|
+
offsetLoop: m = !0,
|
|
802
|
+
offset: u = new q(0, 0),
|
|
803
803
|
scaleDown: h = 0,
|
|
804
|
-
alphaMap:
|
|
805
|
-
alphaTest:
|
|
806
|
-
repeat:
|
|
804
|
+
alphaMap: f = void 0,
|
|
805
|
+
alphaTest: p = 0,
|
|
806
|
+
repeat: d = new q(1, 1),
|
|
807
807
|
resolution: v = new q(1, 1)
|
|
808
|
-
} = j, S =
|
|
808
|
+
} = j, S = ne(j, [
|
|
809
809
|
"lineWidth",
|
|
810
810
|
"color",
|
|
811
811
|
"opacity",
|
|
@@ -826,22 +826,22 @@ class Ot extends ze {
|
|
|
826
826
|
uniforms: {
|
|
827
827
|
lineWidth: { value: t },
|
|
828
828
|
color: { value: new le(i) },
|
|
829
|
-
opacity: { value:
|
|
829
|
+
opacity: { value: s },
|
|
830
830
|
map: { value: a },
|
|
831
831
|
useMap: { value: a ? 1 : 0 },
|
|
832
832
|
resolution: { value: v },
|
|
833
833
|
sizeAttenuation: { value: c ? 1 : 0 },
|
|
834
|
-
offset: { value:
|
|
835
|
-
offsetLoop: { value:
|
|
834
|
+
offset: { value: u },
|
|
835
|
+
offsetLoop: { value: m ? 1 : 0 },
|
|
836
836
|
dashArray: { value: r },
|
|
837
837
|
dashOffset: { value: l },
|
|
838
838
|
dashRatio: { value: o },
|
|
839
839
|
useDash: { value: r > 0 ? 1 : 0 },
|
|
840
840
|
scaleDown: { value: h / 10 },
|
|
841
|
-
alphaTest: { value:
|
|
842
|
-
alphaMap: { value:
|
|
843
|
-
useAlphaMap: { value:
|
|
844
|
-
repeat: { value:
|
|
841
|
+
alphaTest: { value: p },
|
|
842
|
+
alphaMap: { value: f },
|
|
843
|
+
useAlphaMap: { value: f ? 1 : 0 },
|
|
844
|
+
repeat: { value: d }
|
|
845
845
|
},
|
|
846
846
|
vertexShader: dt,
|
|
847
847
|
fragmentShader: ft
|
|
@@ -897,19 +897,19 @@ class Ot extends ze {
|
|
|
897
897
|
}
|
|
898
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();
|
|
899
899
|
let z, _;
|
|
900
|
-
function Me(
|
|
901
|
-
return T.set(0, 0, -e, 1).applyMatrix4(
|
|
900
|
+
function Me(n, e, t) {
|
|
901
|
+
return T.set(0, 0, -e, 1).applyMatrix4(n.projectionMatrix), T.multiplyScalar(1 / T.w), T.x = _ / t.width, T.y = _ / t.height, T.applyMatrix4(n.projectionMatrixInverse), T.multiplyScalar(1 / T.w), Math.abs(Math.max(T.x, T.y));
|
|
902
902
|
}
|
|
903
|
-
function ht(
|
|
904
|
-
const t =
|
|
903
|
+
function ht(n, e) {
|
|
904
|
+
const t = n.matrixWorld, i = n.geometry, s = i.attributes.instanceStart, a = i.attributes.instanceEnd, l = Math.min(i.instanceCount, s.count);
|
|
905
905
|
for (let r = 0, o = l; r < o; r++) {
|
|
906
|
-
M.start.fromBufferAttribute(
|
|
907
|
-
const c = new w(),
|
|
908
|
-
z.distanceSqToSegment(M.start, M.end,
|
|
909
|
-
point:
|
|
906
|
+
M.start.fromBufferAttribute(s, r), M.end.fromBufferAttribute(a, r), M.applyMatrix4(t);
|
|
907
|
+
const c = new w(), m = new w();
|
|
908
|
+
z.distanceSqToSegment(M.start, M.end, m, c), m.distanceTo(c) < _ * 0.5 && e.push({
|
|
909
|
+
point: m,
|
|
910
910
|
pointOnLine: c,
|
|
911
|
-
distance: z.origin.distanceTo(
|
|
912
|
-
object:
|
|
911
|
+
distance: z.origin.distanceTo(m),
|
|
912
|
+
object: n,
|
|
913
913
|
face: null,
|
|
914
914
|
faceIndex: r,
|
|
915
915
|
uv: null,
|
|
@@ -917,23 +917,23 @@ function ht(s, e) {
|
|
|
917
917
|
});
|
|
918
918
|
}
|
|
919
919
|
}
|
|
920
|
-
function pt(
|
|
921
|
-
const i = e.projectionMatrix, a =
|
|
920
|
+
function pt(n, e, t) {
|
|
921
|
+
const i = e.projectionMatrix, a = n.material.resolution, l = n.matrixWorld, r = n.geometry, o = r.attributes.instanceStart, c = r.attributes.instanceEnd, m = Math.min(r.instanceCount, o.count), u = -e.near;
|
|
922
922
|
z.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, Q.copy(D), X.multiplyMatrices(e.matrixWorldInverse, l);
|
|
923
|
-
for (let h = 0,
|
|
924
|
-
if (b.fromBufferAttribute(o, h), g.fromBufferAttribute(c, h), b.w = 1, g.w = 1, b.applyMatrix4(X), g.applyMatrix4(X), b.z >
|
|
923
|
+
for (let h = 0, f = m; h < f; h++) {
|
|
924
|
+
if (b.fromBufferAttribute(o, h), g.fromBufferAttribute(c, h), b.w = 1, g.w = 1, b.applyMatrix4(X), g.applyMatrix4(X), b.z > u && g.z > u)
|
|
925
925
|
continue;
|
|
926
|
-
if (b.z >
|
|
927
|
-
const B = b.z - g.z, A = (b.z -
|
|
926
|
+
if (b.z > u) {
|
|
927
|
+
const B = b.z - g.z, A = (b.z - u) / B;
|
|
928
928
|
b.lerp(g, A);
|
|
929
|
-
} else if (g.z >
|
|
930
|
-
const B = g.z - b.z, A = (g.z -
|
|
929
|
+
} else if (g.z > u) {
|
|
930
|
+
const B = g.z - b.z, A = (g.z - u) / B;
|
|
931
931
|
g.lerp(b, A);
|
|
932
932
|
}
|
|
933
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;
|
|
934
|
-
const
|
|
935
|
-
M.at(
|
|
936
|
-
const v = Le.lerp(b.z, g.z,
|
|
934
|
+
const d = M.closestPointToPointParameter(Q, !0);
|
|
935
|
+
M.at(d, ge);
|
|
936
|
+
const v = Le.lerp(b.z, g.z, d), S = v >= -1 && v <= 1, j = Q.distanceTo(ge) < _ * 0.5;
|
|
937
937
|
if (S && j) {
|
|
938
938
|
M.start.fromBufferAttribute(o, h), M.end.fromBufferAttribute(c, h), M.start.applyMatrix4(l), M.end.applyMatrix4(l);
|
|
939
939
|
const B = new w(), A = new w();
|
|
@@ -941,7 +941,7 @@ function pt(s, e, t) {
|
|
|
941
941
|
point: A,
|
|
942
942
|
pointOnLine: B,
|
|
943
943
|
distance: z.origin.distanceTo(A),
|
|
944
|
-
object:
|
|
944
|
+
object: n,
|
|
945
945
|
face: null,
|
|
946
946
|
faceIndex: h,
|
|
947
947
|
uv: null,
|
|
@@ -956,11 +956,11 @@ class _t extends we {
|
|
|
956
956
|
}
|
|
957
957
|
// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
|
|
958
958
|
computeLineDistances() {
|
|
959
|
-
const e = this.geometry, t = e.attributes.instanceStart, i = e.attributes.instanceEnd,
|
|
959
|
+
const e = this.geometry, t = e.attributes.instanceStart, i = e.attributes.instanceEnd, s = new Float32Array(2 * t.count);
|
|
960
960
|
for (let l = 0, r = 0, o = t.count; l < o; l++, r += 2)
|
|
961
|
-
ye.fromBufferAttribute(t, l), be.fromBufferAttribute(i, l),
|
|
961
|
+
ye.fromBufferAttribute(t, l), be.fromBufferAttribute(i, l), s[r] = r === 0 ? 0 : s[r - 1], s[r + 1] = s[r] + ye.distanceTo(be);
|
|
962
962
|
const a = new Ee(
|
|
963
|
-
|
|
963
|
+
s,
|
|
964
964
|
2,
|
|
965
965
|
1
|
|
966
966
|
);
|
|
@@ -973,8 +973,8 @@ class _t extends we {
|
|
|
973
973
|
), this;
|
|
974
974
|
}
|
|
975
975
|
raycast(e, t) {
|
|
976
|
-
const i = this.material.worldUnits,
|
|
977
|
-
|
|
976
|
+
const i = this.material.worldUnits, s = e.camera;
|
|
977
|
+
s === null && !i && console.error(
|
|
978
978
|
'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.'
|
|
979
979
|
);
|
|
980
980
|
const a = e.params.Line2 !== void 0 && e.params.Line2.threshold || 0;
|
|
@@ -985,34 +985,34 @@ class _t extends we {
|
|
|
985
985
|
if (i)
|
|
986
986
|
c = _ * 0.5;
|
|
987
987
|
else {
|
|
988
|
-
const
|
|
989
|
-
|
|
988
|
+
const u = Math.max(
|
|
989
|
+
s.near,
|
|
990
990
|
W.distanceToPoint(z.origin)
|
|
991
991
|
);
|
|
992
992
|
c = Me(
|
|
993
|
-
|
|
994
|
-
|
|
993
|
+
s,
|
|
994
|
+
u,
|
|
995
995
|
o.resolution
|
|
996
996
|
);
|
|
997
997
|
}
|
|
998
998
|
if (W.radius += c, z.intersectsSphere(W) === !1)
|
|
999
999
|
return;
|
|
1000
1000
|
r.boundingBox === null && r.computeBoundingBox(), U.copy(r.boundingBox).applyMatrix4(l);
|
|
1001
|
-
let
|
|
1001
|
+
let m;
|
|
1002
1002
|
if (i)
|
|
1003
|
-
|
|
1003
|
+
m = _ * 0.5;
|
|
1004
1004
|
else {
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1005
|
+
const u = Math.max(
|
|
1006
|
+
s.near,
|
|
1007
1007
|
U.distanceToPoint(z.origin)
|
|
1008
1008
|
);
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1009
|
+
m = Me(
|
|
1010
|
+
s,
|
|
1011
|
+
u,
|
|
1012
1012
|
o.resolution
|
|
1013
1013
|
);
|
|
1014
1014
|
}
|
|
1015
|
-
U.expandByScalar(
|
|
1015
|
+
U.expandByScalar(m), z.intersectsBox(U) !== !1 && (i ? ht(this, t) : pt(this, s, t));
|
|
1016
1016
|
}
|
|
1017
1017
|
onBeforeRender(e) {
|
|
1018
1018
|
const t = this.material.uniforms;
|