gralobe 1.0.35 → 1.0.36
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.
- package/dist/gralobe.js +1 -1
- package/dist/gralobe.js.map +1 -1
- package/dist/gralobe.umd.cjs +1 -1
- package/dist/gralobe.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/gralobe.umd.cjs
CHANGED
|
@@ -480,7 +480,7 @@
|
|
|
480
480
|
});
|
|
481
481
|
}
|
|
482
482
|
};
|
|
483
|
-
`;class ht{canvas;ctx;countries=[];loaded=!1;statsMap;topologyConfig;currentRenderId=0;onProgress;onTextureUpdate;static cache=new Map;constructor(e,t,i){this.canvas=document.createElement("canvas"),this.canvas.width=jt,this.canvas.height=Yt,this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),this.onProgress=t,this.onTextureUpdate=i,this.topologyConfig={url:e?.url||"https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json",objectName:e?.objectName||"countries",disableNormalization:e?.disableNormalization||!1,idProperty:e?.idProperty},this.statsMap=new Map,$i.forEach(n=>{this.statsMap.set(n.id,n)}),this.loadCountries()}async loadCountries(){const e=`${this.topologyConfig.url}|${this.topologyConfig.objectName}|${this.topologyConfig.idProperty||""}`;if(this.onProgress?.(.1),!ht.cache.has(e)){const t=(async()=>{try{let i;i=await this.loadInWorker(this.topologyConfig.url,this.topologyConfig.objectName,this.topologyConfig.idProperty),this.onProgress?.(.4);const n=200,r=i.length;for(let s=0;s<r;s+=n){i.slice(s,s+n).forEach(h=>{h.path=this.createPath(h)});const l=.4+.6*(s+n)/r;this.onProgress?.(Math.min(.99,l)),await new Promise(h=>setTimeout(h,0))}return console.log(`Loaded and processed ${i.length} boundaries from ${this.topologyConfig.objectName}`),i}catch(i){throw console.error("Failed to load map boundaries:",i),i}})();ht.cache.set(e,t)}try{this.countries=await ht.cache.get(e),this.loaded=!0,this.onProgress?.(1)}catch(t){ht.cache.delete(e),console.error("Error loading cached topology:",t),this.loaded=!0}}loadInWorker(e,t,i){return new Promise((n,r)=>{const s=new Blob([Eo],{type:"application/javascript"}),a=URL.createObjectURL(s),l=new Worker(a);l.onmessage=h=>{URL.revokeObjectURL(a),l.terminate(),h.data.success?n(h.data.features):r(new Error(h.data.error))},l.onerror=h=>{URL.revokeObjectURL(a),l.terminate(),r(new Error("Worker error: "+h.message))},l.postMessage({url:e,objectName:t})})}async waitForLoad(){for(;!this.loaded;)await new Promise(e=>setTimeout(e,100))}setFeatures(e){e.forEach(t=>{t.path||(t.path=this.createPath(t))}),this.countries=e,this.loaded=!0}renderTexture(e){this.currentRenderId++;const t=this.currentRenderId;if(this.ctx.fillStyle="rgba(10, 20, 30, 0.9)",this.ctx.fillRect(0,0,jt,Yt),this.onTextureUpdate?.(),!this.loaded)return this.canvas;const i=this.countries.length<1500;this.ctx.lineWidth=.5,this.ctx.strokeStyle="rgba(0, 0, 0, 0.3)";const n=500,r=this.countries.length;let s=0;const a=()=>{if(this.currentRenderId!==t)return;const l=Math.min(s+n,r);for(let h=s;h<l;h++){const c=this.countries[h],u=this.statsMap.get(c.id);let f="#2a2a2a";if(u){const g=e.accessor(u),p=bo(e,g);f=this.interpolateColor(e.colorScale,p)}this.drawFeature(c,f,i)}s=l,this.onTextureUpdate?.(),s<r&&requestAnimationFrame(a)};return requestAnimationFrame(a),this.canvas}drawFeature(e,t,i){const n=e.path;n&&(this.ctx.fillStyle=t,this.ctx.fill(n),i&&this.ctx.stroke(n))}createPath(e){const t=new Path2D,{geometry:i}=e;if(i.type==="Polygon")this.addPolygonToPath(t,i.coordinates);else if(i.type==="MultiPolygon")i.coordinates.forEach(n=>{this.addPolygonToPath(t,n)});else if(i.type==="Point"){const[n,r]=i.coordinates,[s,a]=this.projectPoint(n,r);t.arc(s,a,4,0,Math.PI*2)}return t}addPolygonToPath(e,t){t.forEach(i=>{let n=null;i.forEach((r,s)=>{const a=r[0],l=r[1],[h,c]=this.projectPoint(a,l),u=n!==null&&Math.abs(a-n)>180;s===0||u?e.moveTo(h,c):e.lineTo(h,c),n=a}),e.closePath()})}projectPoint(e,t){const i=(e+180)/360*jt,n=(90-t)/180*Yt;return[i,n]}interpolateColor(e,t){const i=c=>({r:parseInt(c.slice(1,3),16),g:parseInt(c.slice(3,5),16),b:parseInt(c.slice(5,7),16)}),[n,r,s]=e.map(i);let a,l,h;if(t<.5){const c=t*2;a=Math.round(n.r+(r.r-n.r)*c),l=Math.round(n.g+(r.g-n.g)*c),h=Math.round(n.b+(r.b-n.b)*c)}else{const c=(t-.5)*2;a=Math.round(r.r+(s.r-r.r)*c),l=Math.round(r.g+(s.g-r.g)*c),h=Math.round(r.b+(s.b-r.b)*c)}return`rgb(${a}, ${l}, ${h})`}renderCustomTexture(e,t,i){this.currentRenderId++;const n=this.currentRenderId;if(this.ctx.fillStyle="rgba(10, 20, 30, 0.9)",this.ctx.fillRect(0,0,jt,Yt),this.onTextureUpdate?.(),!this.loaded)return this.canvas;const r=this.topologyConfig?.disableNormalization?e instanceof Map?Object.fromEntries(e):e:fr(e),s=this.countries.length<1500;this.ctx.lineWidth=.5,this.ctx.strokeStyle="rgba(0, 0, 0, 0.3)";const a=500,l=this.countries.length;let h=0;const c=()=>{if(this.currentRenderId!==n)return;const u=Math.min(h+a,l);for(let f=h;f<u;f++){const g=this.countries[f],p=r[g.id];let d="#2a2a2a";if(p!==void 0){const m=Math.max(0,Math.min(1,(p-i[0])/(i[1]-i[0])));d=this.interpolateColor(t,m)}this.drawFeature(g,d,s)}h=u,this.onTextureUpdate?.(),h<l&&requestAnimationFrame(c)};return requestAnimationFrame(c),this.canvas}getCanvas(){return this.canvas}getDataURL(){return this.canvas.toDataURL("image/png")}getBounds(){if(this.countries.length===0)return null;let e=1/0,t=-1/0,i=1/0,n=-1/0,r=0,s=1/0,a=-1/0,l=1/0,h=-1/0,c=0;const u=_=>{if(typeof _[0]=="number"){const y=_[0],x=_[1];y<0?(y<e&&(e=y),y>t&&(t=y),x<i&&(i=x),x>n&&(n=x),r++):(y<s&&(s=y),y>a&&(a=y),x<l&&(l=x),x>h&&(h=x),c++)}else _.forEach(u)};if(this.countries.forEach(_=>{_.geometry&&u(_.geometry.coordinates)}),r===0&&c===0)return null;if(r===0)return[s,l,a,h];if(c===0)return[e,i,t,n];const f=Math.min(e,s),g=Math.max(t,a);if(g-f>180){if(r>c*2)return[e,i,t,n];if(c>r*2)return[s,l,a,h]}const d=Math.min(i,l),m=Math.max(n,h);return[f,d,g,m]}}class wo extends S.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new S.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element&&t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const ct=new S.Vector3,mr=new S.Matrix4,gr=new S.Matrix4,_r=new S.Vector3,yr=new S.Vector3;class Po{constructor(e={}){const t=this;let i,n,r,s;const a={objects:new WeakMap},l=e.element!==void 0?e.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.sortObjects=!0,this.getSize=function(){return{width:i,height:n}},this.render=function(p,d){p.matrixWorldAutoUpdate===!0&&p.updateMatrixWorld(),d.parent===null&&d.matrixWorldAutoUpdate===!0&&d.updateMatrixWorld(),mr.copy(d.matrixWorldInverse),gr.multiplyMatrices(d.projectionMatrix,mr),c(p,p,d),this.sortObjects&&g(p)},this.setSize=function(p,d){i=p,n=d,r=i/2,s=n/2,l.style.width=p+"px",l.style.height=d+"px"};function h(p){p.isCSS2DObject&&(p.element.style.display="none");for(let d=0,m=p.children.length;d<m;d++)h(p.children[d])}function c(p,d,m){if(p.visible===!1){h(p);return}if(p.isCSS2DObject){ct.setFromMatrixPosition(p.matrixWorld),ct.applyMatrix4(gr);const _=ct.z>=-1&&ct.z<=1&&p.layers.test(m.layers)===!0,y=p.element;y.style.display=_===!0?"":"none",_===!0&&(p.onBeforeRender(t,d,m),y.style.transform="translate("+-100*p.center.x+"%,"+-100*p.center.y+"%)translate("+(ct.x*r+r)+"px,"+(-ct.y*s+s)+"px)",y.parentNode!==l&&l.appendChild(y),p.onAfterRender(t,d,m));const x={distanceToCameraSquared:u(m,p)};a.objects.set(p,x)}for(let _=0,y=p.children.length;_<y;_++)c(p.children[_],d,m)}function u(p,d){return _r.setFromMatrixPosition(p.matrixWorld),yr.setFromMatrixPosition(d.matrixWorld),_r.distanceToSquared(yr)}function f(p){const d=[];return p.traverseVisible(function(m){m.isCSS2DObject&&d.push(m)}),d}function g(p){const d=f(p).sort(function(_,y){if(_.renderOrder!==y.renderOrder)return y.renderOrder-_.renderOrder;const x=a.objects.get(_).distanceToCameraSquared,b=a.objects.get(y).distanceToCameraSquared;return x-b}),m=d.length;for(let _=0,y=d.length;_<y;_++)d[_].element.style.zIndex=m-_}}}const Co={CN:[35,105],IN:[22,78],US:[39,-98],ID:[-2,118],PK:[30,70],BR:[-10,-55],NG:[9,8],BD:[24,90],RU:[60,100],MX:[23,-102],JP:[36,138],ET:[9,38.5],PH:[12,122],EG:[27,30],VN:[16,108],DE:[51,10],TR:[39,35],IR:[32,53],TH:[15,101],GB:[54,-2],FR:[46,2],IT:[42.5,12.5],ZA:[-29,24],TZ:[-6,35],KE:[0,38],KR:[36,128],CO:[4,-72],ES:[40,-4],AR:[-34,-64],UG:[1,32],DZ:[28,3],UA:[49,32],IQ:[33,44],PL:[52,20],CA:[56,-106],MA:[32,-5],SA:[24,45],PE:[-10,-76],AU:[-25,134],MY:[4,109.5],GH:[8,-1],NP:[28,84],VE:[7,-66],MG:[-19,47],CM:[6,12],NL:[52.5,5.5],CL:[-34,-71],SE:[62,15],NO:[64,10],SG:[1.3,103.8],NZ:[-42,174],IE:[53,-8],IL:[31,35],AE:[24,54],CH:[47,8],AT:[47.5,14.5],PT:[39.5,-8],GR:[39,22],CZ:[49.8,15.5],BE:[50.8,4],HU:[47,20],FI:[64,26],DK:[56,10],IS:[65,-18],CD:[-3,22],SD:[16,30],AO:[-12.5,18.5],MZ:[-18,35],CI:[7.5,-5.5],NE:[17,10],BF:[12,-1.5],ML:[17,-4],SN:[14.5,-14.5],ZM:[-15,28],ZW:[-19,29.5],RW:[-2,30],AF:[33,65],MM:[21,96],KP:[40,127],MN:[46,105],LK:[7.8,80.8],KZ:[48,67],UZ:[41,64],CU:[22,-79.5],EC:[-1.5,-78.5],GT:[15.5,-90.3],BO:[-17,-65],HN:[15,-86.5],PY:[-23,-58],UY:[-33,-56],CR:[10,-84],PA:[9,-80]},Ao=new Set(["CN","IN","US","BR","RU","JP","DE","GB","FR","AU","CA","MX","ID","SA","ZA","EG","NG","AR","IT","ES","KR","TR","PL","NL","CH","SE","NO","PK","BD","VN"]),So=new Set(["CN","IN","US","BR","RU","AU","CA"]),Mo=new Set(["RU","CA","US","CN","BR","AU"]),To=new Set(["IN","AR","KZ","DZ","CD","SA","MX","ID","SD","LY","IR","MN","PE","TD","NE","AO","ML","ZA","CO","ET","BO","MR","EG","TZ","NG","VE","PK","TR","CL","MM"]),Do=new Set(["AF","UA","MG","MZ","FR","ES","TH","CM","PG","JP","DE","VN","MY","CI","PL","IT","PH","EC","BF","NZ","GB","GH","RO","LA","GY","OM","BY","KH","SN","UG","NO","SE","FI","MR","ZM","ZW","NP","MA","IQ","BD"]);class Oo{labelRenderer;labels=[];labelGroup;currentStyle="none";sphereRadius;currentMorph=0;globe=null;camera=null;constructor(e,t){this.sphereRadius=t,this.labelRenderer=new Po;const i=e.clientWidth||800,n=e.clientHeight||600;this.labelRenderer.setSize(i,n),this.labelRenderer.domElement.style.position="absolute",this.labelRenderer.domElement.style.top="0",this.labelRenderer.domElement.style.left="0",this.labelRenderer.domElement.style.pointerEvents="none",this.labelRenderer.domElement.style.zIndex="5",e.appendChild(this.labelRenderer.domElement),this.labelGroup=new A.Group,this.injectStyles(),this.createLabels()}injectStyles(){const e=document.createElement("style");e.textContent=`
|
|
483
|
+
`;class ht{canvas;ctx;countries=[];loaded=!1;statsMap;topologyConfig;currentRenderId=0;onProgress;onTextureUpdate;static cache=new Map;constructor(e,t,i){this.canvas=document.createElement("canvas"),this.canvas.width=jt,this.canvas.height=Yt,this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),this.onProgress=t,this.onTextureUpdate=i,this.topologyConfig={url:e?.url||"https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json",objectName:e?.objectName||"countries",disableNormalization:e?.disableNormalization||!1,idProperty:e?.idProperty},this.statsMap=new Map,$i.forEach(n=>{this.statsMap.set(n.id,n)}),this.loadCountries()}async loadCountries(){const e=`${this.topologyConfig.url}|${this.topologyConfig.objectName}|${this.topologyConfig.idProperty||""}`;if(this.onProgress?.(.1),!ht.cache.has(e)){const t=(async()=>{try{let i;i=await this.loadInWorker(this.topologyConfig.url,this.topologyConfig.objectName,this.topologyConfig.idProperty),this.onProgress?.(.4);const n=200,r=i.length;for(let s=0;s<r;s+=n){i.slice(s,s+n).forEach(h=>{h.path=this.createPath(h)});const l=.4+.6*(s+n)/r;this.onProgress?.(Math.min(.99,l)),await new Promise(h=>setTimeout(h,0))}return console.log(`Loaded and processed ${i.length} boundaries from ${this.topologyConfig.objectName}`),i}catch(i){throw console.error("Failed to load map boundaries:",i),i}})();ht.cache.set(e,t)}try{this.countries=await ht.cache.get(e),this.loaded=!0,this.onProgress?.(1)}catch(t){ht.cache.delete(e),console.error("Error loading cached topology:",t),this.loaded=!0}}loadInWorker(e,t,i){return new Promise((n,r)=>{const s=new Blob([Eo],{type:"application/javascript"}),a=URL.createObjectURL(s),l=new Worker(a);l.onmessage=h=>{URL.revokeObjectURL(a),l.terminate(),h.data.success?n(h.data.features):r(new Error(h.data.error))},l.onerror=h=>{URL.revokeObjectURL(a),l.terminate(),r(new Error("Worker error: "+h.message))},l.postMessage({url:e,objectName:t})})}async waitForLoad(){for(;!this.loaded;)await new Promise(e=>setTimeout(e,100))}setFeatures(e){e.forEach(t=>{t.path||(t.path=this.createPath(t))}),this.countries=e,this.loaded=!0,this.topologyConfig&&(this.topologyConfig.disableNormalization=!0)}renderTexture(e){this.currentRenderId++;const t=this.currentRenderId;if(this.ctx.fillStyle="rgba(10, 20, 30, 0.9)",this.ctx.fillRect(0,0,jt,Yt),this.onTextureUpdate?.(),!this.loaded)return this.canvas;const i=this.countries.length<1500;this.ctx.lineWidth=.5,this.ctx.strokeStyle="rgba(0, 0, 0, 0.3)";const n=500,r=this.countries.length;let s=0;const a=()=>{if(this.currentRenderId!==t)return;const l=Math.min(s+n,r);for(let h=s;h<l;h++){const c=this.countries[h],u=this.statsMap.get(c.id);let f="#2a2a2a";if(u){const g=e.accessor(u),p=bo(e,g);f=this.interpolateColor(e.colorScale,p)}this.drawFeature(c,f,i)}s=l,this.onTextureUpdate?.(),s<r&&requestAnimationFrame(a)};return requestAnimationFrame(a),this.canvas}drawFeature(e,t,i){const n=e.path;n&&(this.ctx.fillStyle=t,this.ctx.fill(n),i&&this.ctx.stroke(n))}createPath(e){const t=new Path2D,{geometry:i}=e;if(i.type==="Polygon")this.addPolygonToPath(t,i.coordinates);else if(i.type==="MultiPolygon")i.coordinates.forEach(n=>{this.addPolygonToPath(t,n)});else if(i.type==="Point"){const[n,r]=i.coordinates,[s,a]=this.projectPoint(n,r);t.arc(s,a,4,0,Math.PI*2)}return t}addPolygonToPath(e,t){t.forEach(i=>{let n=null;i.forEach((r,s)=>{const a=r[0],l=r[1],[h,c]=this.projectPoint(a,l),u=n!==null&&Math.abs(a-n)>180;s===0||u?e.moveTo(h,c):e.lineTo(h,c),n=a}),e.closePath()})}projectPoint(e,t){const i=(e+180)/360*jt,n=(90-t)/180*Yt;return[i,n]}interpolateColor(e,t){const i=c=>({r:parseInt(c.slice(1,3),16),g:parseInt(c.slice(3,5),16),b:parseInt(c.slice(5,7),16)}),[n,r,s]=e.map(i);let a,l,h;if(t<.5){const c=t*2;a=Math.round(n.r+(r.r-n.r)*c),l=Math.round(n.g+(r.g-n.g)*c),h=Math.round(n.b+(r.b-n.b)*c)}else{const c=(t-.5)*2;a=Math.round(r.r+(s.r-r.r)*c),l=Math.round(r.g+(s.g-r.g)*c),h=Math.round(r.b+(s.b-r.b)*c)}return`rgb(${a}, ${l}, ${h})`}renderCustomTexture(e,t,i){this.currentRenderId++;const n=this.currentRenderId;if(this.ctx.fillStyle="rgba(10, 20, 30, 0.9)",this.ctx.fillRect(0,0,jt,Yt),this.onTextureUpdate?.(),!this.loaded)return this.canvas;const r=this.topologyConfig?.disableNormalization?e instanceof Map?Object.fromEntries(e):e:fr(e),s=this.countries.length<1500;this.ctx.lineWidth=.5,this.ctx.strokeStyle="rgba(0, 0, 0, 0.3)";const a=500,l=this.countries.length;let h=0;const c=()=>{if(this.currentRenderId!==n)return;const u=Math.min(h+a,l);for(let f=h;f<u;f++){const g=this.countries[f],p=r[g.id];let d="#2a2a2a";if(p!==void 0){const m=Math.max(0,Math.min(1,(p-i[0])/(i[1]-i[0])));d=this.interpolateColor(t,m)}this.drawFeature(g,d,s)}h=u,this.onTextureUpdate?.(),h<l&&requestAnimationFrame(c)};return requestAnimationFrame(c),this.canvas}getCanvas(){return this.canvas}getDataURL(){return this.canvas.toDataURL("image/png")}getBounds(){if(this.countries.length===0)return null;let e=1/0,t=-1/0,i=1/0,n=-1/0,r=0,s=1/0,a=-1/0,l=1/0,h=-1/0,c=0;const u=_=>{if(typeof _[0]=="number"){const y=_[0],x=_[1];y<0?(y<e&&(e=y),y>t&&(t=y),x<i&&(i=x),x>n&&(n=x),r++):(y<s&&(s=y),y>a&&(a=y),x<l&&(l=x),x>h&&(h=x),c++)}else _.forEach(u)};if(this.countries.forEach(_=>{_.geometry&&u(_.geometry.coordinates)}),r===0&&c===0)return null;if(r===0)return[s,l,a,h];if(c===0)return[e,i,t,n];const f=Math.min(e,s),g=Math.max(t,a);if(g-f>180){if(r>c*2)return[e,i,t,n];if(c>r*2)return[s,l,a,h]}const d=Math.min(i,l),m=Math.max(n,h);return[f,d,g,m]}}class wo extends S.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new S.Vector2(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element&&t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const ct=new S.Vector3,mr=new S.Matrix4,gr=new S.Matrix4,_r=new S.Vector3,yr=new S.Vector3;class Po{constructor(e={}){const t=this;let i,n,r,s;const a={objects:new WeakMap},l=e.element!==void 0?e.element:document.createElement("div");l.style.overflow="hidden",this.domElement=l,this.sortObjects=!0,this.getSize=function(){return{width:i,height:n}},this.render=function(p,d){p.matrixWorldAutoUpdate===!0&&p.updateMatrixWorld(),d.parent===null&&d.matrixWorldAutoUpdate===!0&&d.updateMatrixWorld(),mr.copy(d.matrixWorldInverse),gr.multiplyMatrices(d.projectionMatrix,mr),c(p,p,d),this.sortObjects&&g(p)},this.setSize=function(p,d){i=p,n=d,r=i/2,s=n/2,l.style.width=p+"px",l.style.height=d+"px"};function h(p){p.isCSS2DObject&&(p.element.style.display="none");for(let d=0,m=p.children.length;d<m;d++)h(p.children[d])}function c(p,d,m){if(p.visible===!1){h(p);return}if(p.isCSS2DObject){ct.setFromMatrixPosition(p.matrixWorld),ct.applyMatrix4(gr);const _=ct.z>=-1&&ct.z<=1&&p.layers.test(m.layers)===!0,y=p.element;y.style.display=_===!0?"":"none",_===!0&&(p.onBeforeRender(t,d,m),y.style.transform="translate("+-100*p.center.x+"%,"+-100*p.center.y+"%)translate("+(ct.x*r+r)+"px,"+(-ct.y*s+s)+"px)",y.parentNode!==l&&l.appendChild(y),p.onAfterRender(t,d,m));const x={distanceToCameraSquared:u(m,p)};a.objects.set(p,x)}for(let _=0,y=p.children.length;_<y;_++)c(p.children[_],d,m)}function u(p,d){return _r.setFromMatrixPosition(p.matrixWorld),yr.setFromMatrixPosition(d.matrixWorld),_r.distanceToSquared(yr)}function f(p){const d=[];return p.traverseVisible(function(m){m.isCSS2DObject&&d.push(m)}),d}function g(p){const d=f(p).sort(function(_,y){if(_.renderOrder!==y.renderOrder)return y.renderOrder-_.renderOrder;const x=a.objects.get(_).distanceToCameraSquared,b=a.objects.get(y).distanceToCameraSquared;return x-b}),m=d.length;for(let _=0,y=d.length;_<y;_++)d[_].element.style.zIndex=m-_}}}const Co={CN:[35,105],IN:[22,78],US:[39,-98],ID:[-2,118],PK:[30,70],BR:[-10,-55],NG:[9,8],BD:[24,90],RU:[60,100],MX:[23,-102],JP:[36,138],ET:[9,38.5],PH:[12,122],EG:[27,30],VN:[16,108],DE:[51,10],TR:[39,35],IR:[32,53],TH:[15,101],GB:[54,-2],FR:[46,2],IT:[42.5,12.5],ZA:[-29,24],TZ:[-6,35],KE:[0,38],KR:[36,128],CO:[4,-72],ES:[40,-4],AR:[-34,-64],UG:[1,32],DZ:[28,3],UA:[49,32],IQ:[33,44],PL:[52,20],CA:[56,-106],MA:[32,-5],SA:[24,45],PE:[-10,-76],AU:[-25,134],MY:[4,109.5],GH:[8,-1],NP:[28,84],VE:[7,-66],MG:[-19,47],CM:[6,12],NL:[52.5,5.5],CL:[-34,-71],SE:[62,15],NO:[64,10],SG:[1.3,103.8],NZ:[-42,174],IE:[53,-8],IL:[31,35],AE:[24,54],CH:[47,8],AT:[47.5,14.5],PT:[39.5,-8],GR:[39,22],CZ:[49.8,15.5],BE:[50.8,4],HU:[47,20],FI:[64,26],DK:[56,10],IS:[65,-18],CD:[-3,22],SD:[16,30],AO:[-12.5,18.5],MZ:[-18,35],CI:[7.5,-5.5],NE:[17,10],BF:[12,-1.5],ML:[17,-4],SN:[14.5,-14.5],ZM:[-15,28],ZW:[-19,29.5],RW:[-2,30],AF:[33,65],MM:[21,96],KP:[40,127],MN:[46,105],LK:[7.8,80.8],KZ:[48,67],UZ:[41,64],CU:[22,-79.5],EC:[-1.5,-78.5],GT:[15.5,-90.3],BO:[-17,-65],HN:[15,-86.5],PY:[-23,-58],UY:[-33,-56],CR:[10,-84],PA:[9,-80]},Ao=new Set(["CN","IN","US","BR","RU","JP","DE","GB","FR","AU","CA","MX","ID","SA","ZA","EG","NG","AR","IT","ES","KR","TR","PL","NL","CH","SE","NO","PK","BD","VN"]),So=new Set(["CN","IN","US","BR","RU","AU","CA"]),Mo=new Set(["RU","CA","US","CN","BR","AU"]),To=new Set(["IN","AR","KZ","DZ","CD","SA","MX","ID","SD","LY","IR","MN","PE","TD","NE","AO","ML","ZA","CO","ET","BO","MR","EG","TZ","NG","VE","PK","TR","CL","MM"]),Do=new Set(["AF","UA","MG","MZ","FR","ES","TH","CM","PG","JP","DE","VN","MY","CI","PL","IT","PH","EC","BF","NZ","GB","GH","RO","LA","GY","OM","BY","KH","SN","UG","NO","SE","FI","MR","ZM","ZW","NP","MA","IQ","BD"]);class Oo{labelRenderer;labels=[];labelGroup;currentStyle="none";sphereRadius;currentMorph=0;globe=null;camera=null;constructor(e,t){this.sphereRadius=t,this.labelRenderer=new Po;const i=e.clientWidth||800,n=e.clientHeight||600;this.labelRenderer.setSize(i,n),this.labelRenderer.domElement.style.position="absolute",this.labelRenderer.domElement.style.top="0",this.labelRenderer.domElement.style.left="0",this.labelRenderer.domElement.style.pointerEvents="none",this.labelRenderer.domElement.style.zIndex="5",e.appendChild(this.labelRenderer.domElement),this.labelGroup=new A.Group,this.injectStyles(),this.createLabels()}injectStyles(){const e=document.createElement("style");e.textContent=`
|
|
484
484
|
.country-label {
|
|
485
485
|
font-family: system-ui, -apple-system, sans-serif;
|
|
486
486
|
font-weight: 500;
|