You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
458 lines
71 KiB
458 lines
71 KiB
var fn=Object.defineProperty,dn=Object.defineProperties;var pn=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var pt=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var Fe=(t,e)=>{if(e=Symbol[t])return e;throw Error("Symbol."+t+" is not defined")};var We=(t,e,n)=>e in t?fn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Q=(t,e)=>{for(var n in e||(e={}))pt.call(e,n)&&We(t,n,e[n]);if(Me)for(var n of Me(e))mt.call(e,n)&&We(t,n,e[n]);return t},Z=(t,e)=>dn(t,pn(e));var vt=(t,e)=>{var n={};for(var i in t)pt.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(t!=null&&Me)for(var i of Me(t))e.indexOf(i)<0&&mt.call(t,i)&&(n[i]=t[i]);return n};var M=(t,e,n)=>(We(t,typeof e!="symbol"?e+"":e,n),n);var mn=function(t,e){this[0]=t,this[1]=e};var gt=t=>{var e=t[Fe("asyncIterator")],n=!1,i,s={};return e==null?(e=t[Fe("iterator")](),i=o=>s[o]=r=>e[o](r)):(e=e.call(t),i=o=>s[o]=r=>{if(n){if(n=!1,o==="throw")throw r;return r}return n=!0,{done:!1,value:new mn(new Promise(a=>{var h=e[o](r);if(!(h instanceof Object))throw TypeError("Object expected");a(h)}),1)}}),s[Fe("iterator")]=()=>s,i("next"),"throw"in e?i("throw"):s.throw=o=>{throw o},"return"in e&&i("return"),s};import{X as vn,Y as gn,S as wn,Z as yn,_ as Sn,$ as En,a0 as ke,a1 as xn,a2 as Mn,b as re,C as Ke,V as F,a3 as An,G as ve,a as ge,D as Cn,a4 as bn,z as it,w as De,m as kt,a5 as Ht,a6 as N,J as st,y as Yt,O as ot,a7 as rt,a8 as Pn,P as Ln,A as On,t as zn,a9 as Dn,aa as at,ab as Tn,I as wt,ac as qe,ad as ue,ae as Rn,af as Vt,ag as Te,ah as Re,ai as Jt,aj as Bn,ak as Ge,al as _n,am as Un,L as In,x as jn,T as Gn,E as Nn,an as Fn}from"./screen2Standard-f85af2d3-1784378651390.js";import{E as lt,q as Xt}from"./TopicSwitcher-c2a18053-1784378651390.js";import{t as Wn,Y as kn,a as Hn,b as Kt,c as Yn}from"./livestockData-36ec0ae2-1784378651390.js";function Vn(t){let e=null,n=!1,i=!1;function s(){!n||i||(t(),e=requestAnimationFrame(s))}function o(){n||(n=!0,s())}function r(){n&&(n=!1,i=!0,cancelAnimationFrame(e))}function a(){!n&&i&&(n=!0,i=!1,s())}return{start:o,pause:r,resume:a,isActive:()=>n}}class Jn extends lt{constructor({canvas:e,config:n={}}){super(),this.canvas=e,this.config=n||{},this.maxPixelRatio=Number(this.config.maxPixelRatio)||2,this.handleResize=()=>{this.init(),this.emit("resize")},this.init(),window.addEventListener("resize",this.handleResize)}init(){var i;const e=((i=this.canvas)==null?void 0:i.parentNode)||this.canvas||document.documentElement;this.width=e.offsetWidth||window.innerWidth||1,this.height=e.offsetHeight||window.innerHeight||1;const n=Number(this.config.maxPixelRatio)||this.maxPixelRatio||2;this.maxPixelRatio=n,this.pixelRatio=Math.min(window.devicePixelRatio||1,n)}destroy(){window.removeEventListener("resize",this.handleResize),this.off("resize")}}class Xn extends lt{constructor(){super(),this.start=Date.now(),this.current=this.start,this.elapsed=0,this.delta=16,this.clock=new vn,this.raf=Vn(()=>this.tick()),this.raf.start()}tick(){const e=Date.now();this.delta=e-this.current,this.current=e,this.elapsed=this.current-this.start;const n=this.clock.getDelta(),i=this.clock.getElapsedTime();this.emit("tick",n,i)}destroy(){this.pause(),this.off("tick")}pause(){this.raf.pause()}resume(){this.raf.resume()}isActive(){this.raf.isActive()}}function Kn(t=10,e=62){var n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),i=[],s;if(e=e||n.length,t)for(s=0;s<t;s++)i[s]=n[0|Math.random()*e];else{var o;for(i[8]=i[13]=i[18]=i[23]="-",i[14]="4",s=0;s<36;s++)i[s]||(o=0|Math.random()*16,i[s]=n[s==19?o&3|8:o])}return i.join("")}const ct=t=>qn(typeof t=="string"?JSON.parse(t):t);function qn(t){var n,i,s,o;let e=(t==null?void 0:t.features)||[];for(let r=0;r<e.length;r++){const a=e[r],h=(n=a.geometry)==null?void 0:n.coordinates,d=Array.isArray(h)&&typeof((s=(i=h==null?void 0:h[0])==null?void 0:i[0])==null?void 0:s[0])=="number";((o=a.geometry)==null?void 0:o.type)==="Polygon"&&d&&(a.geometry.coordinates=[a.geometry.coordinates])}return t}class Qn{constructor({canvas:e,sizes:n,scene:i,camera:s,config:o={},postprocessing:r=!1,composer:a=null}){this.canvas=e,this.sizes=n,this.scene=i,this.camera=s,this.config=o||{},this.postprocessing=r,this.composer=a,this.setInstance()}setInstance(){this.instance=new gn({alpha:!1,antialias:this.config.antialias!==!1,powerPreference:this.config.powerPreference||"high-performance",canvas:this.canvas}),this.instance.outputColorSpace=wn,this.instance.setSize(this.sizes.width,this.sizes.height),this.instance.setPixelRatio(this.sizes.pixelRatio)}resize(){this.instance.setSize(this.sizes.width,this.sizes.height),this.instance.setPixelRatio(this.sizes.pixelRatio)}update(){this.postprocessing&&this.composer?this.composer.render():this.instance.render(this.scene,this.camera.instance)}destroy(){this.instance.dispose(),this.instance.forceContextLoss()}}class Zn{constructor({sizes:e,scene:n,canvas:i},s={isOrthographic:!1}){this.sizes=e,this.scene=n,this.canvas=i,this.options=Object.assign({isOrthographic:!1},s),this.setInstance()}setInstance(){this.instance=null,this.setCamera(this.options.isOrthographic),this.instance.position.set(10,10,10),this.scene.add(this.instance)}setCamera(e=!0){let n=this.sizes.width/this.sizes.height;if(e){let i=120;this.instance=new yn(-i*n,i*n,i,-i,1,1e4)}else this.instance=new Sn(45,n,1,1e4);this.setControls()}setControls(){this.controls=new En(this.instance,this.canvas),this.controls.enableDamping=!0,this.controls.dampingFactor=.08,this.controls.enablePan=!0,this.controls.enableRotate=!0,this.controls.enableZoom=!0,this.controls.screenSpacePanning=!0,this.controls.minDistance=7,this.controls.maxDistance=72,this.controls.minPolarAngle=Math.PI*.08,this.controls.maxPolarAngle=Math.PI*.49,this.controls.mouseButtons.LEFT=ke.PAN,this.controls.mouseButtons.MIDDLE=ke.DOLLY,this.controls.mouseButtons.RIGHT=ke.ROTATE,this.setCanvasInteractionStyle(),this.controls.update()}setCanvasInteractionStyle(){var e;(e=this.canvas)!=null&&e.style&&(this.handlePointerDown=()=>{this.canvas.style.cursor="grabbing"},this.handlePointerUp=()=>{this.canvas.style.cursor="grab"},this.canvas.style.cursor="grab",this.canvas.style.touchAction="none",this.canvas.addEventListener("pointerdown",this.handlePointerDown),window.addEventListener("pointerup",this.handlePointerUp),this.canvas.addEventListener("pointerleave",this.handlePointerUp))}resize(){let e=this.sizes.width/this.sizes.height;if(this.options.isOrthographic){let n=120;this.instance.left=-n*e,this.instance.right=n*e,this.instance.top=n,this.instance.bottom=-n}else this.instance.aspect=e;this.instance.updateProjectionMatrix()}update(){this.controls.update()}destroy(){var e,n,i,s;(n=(e=this.canvas)==null?void 0:e.removeEventListener)==null||n.call(e,"pointerdown",this.handlePointerDown),(s=(i=this.canvas)==null?void 0:i.removeEventListener)==null||s.call(i,"pointerleave",this.handlePointerUp),window.removeEventListener("pointerup",this.handlePointerUp),this.controls.dispose()}}class $n{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const n=this._partials;let i=0;for(let s=0;s<this._n&&s<32;s++){const o=n[s],r=e+o,a=Math.abs(e)<Math.abs(o)?e-(r-o):o-(r-e);a&&(n[i++]=a),e=r}return n[i]=e,this._n=i+1,this}valueOf(){const e=this._partials;let n=this._n,i,s,o,r=0;if(n>0){for(r=e[--n];n>0&&(i=r,s=e[--n],r=i+s,o=s-(r-i),!o););n>0&&(o<0&&e[n-1]<0||o>0&&e[n-1]>0)&&(s=o*2,i=r+s,s==i-r&&(r=i))}return r}}function*ei(t){for(const e of t)yield*gt(e)}function qt(t){return Array.from(ei(t))}var T=1e-6,ti=1e-12,P=Math.PI,X=P/2,yt=P/4,$=P*2,K=180/P,j=P/180,B=Math.abs,Qt=Math.atan,we=Math.atan2,U=Math.cos,ni=Math.exp,ii=Math.log,I=Math.sin,si=Math.sign||function(t){return t>0?1:t<0?-1:0},Ne=Math.sqrt,oi=Math.tan;function ri(t){return t>1?0:t<-1?P:Math.acos(t)}function ye(t){return t>1?X:t<-1?-X:Math.asin(t)}function pe(){}function _e(t,e){t&&Et.hasOwnProperty(t.type)&&Et[t.type](t,e)}var St={Feature:function(t,e){_e(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,s=n.length;++i<s;)_e(n[i].geometry,e)}},Et={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,i=-1,s=n.length;++i<s;)t=n[i],e.point(t[0],t[1],t[2])},LineString:function(t,e){Qe(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,i=-1,s=n.length;++i<s;)Qe(n[i],e,0)},Polygon:function(t,e){xt(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,i=-1,s=n.length;++i<s;)xt(n[i],e)},GeometryCollection:function(t,e){for(var n=t.geometries,i=-1,s=n.length;++i<s;)_e(n[i],e)}};function Qe(t,e,n){var i=-1,s=t.length-n,o;for(e.lineStart();++i<s;)o=t[i],e.point(o[0],o[1],o[2]);e.lineEnd()}function xt(t,e){var n=-1,i=t.length;for(e.polygonStart();++n<i;)Qe(t[n],e,1);e.polygonEnd()}function ai(t,e){t&&St.hasOwnProperty(t.type)?St[t.type](t,e):_e(t,e)}function Ze(t){return[we(t[1],t[0]),ye(t[2])]}function he(t){var e=t[0],n=t[1],i=U(n);return[i*U(e),i*I(e),I(n)]}function Ae(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Ue(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function He(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Ce(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function $e(t){var e=Ne(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function et(t,e){function n(i,s){return i=t(i,s),e(i[0],i[1])}return t.invert&&e.invert&&(n.invert=function(i,s){return i=e.invert(i,s),i&&t.invert(i[0],i[1])}),n}function tt(t,e){return B(t)>P&&(t-=Math.round(t/$)*$),[t,e]}tt.invert=tt;function Zt(t,e,n){return(t%=$)?e||n?et(At(t),Ct(e,n)):At(t):e||n?Ct(e,n):tt}function Mt(t){return function(e,n){return e+=t,B(e)>P&&(e-=Math.round(e/$)*$),[e,n]}}function At(t){var e=Mt(t);return e.invert=Mt(-t),e}function Ct(t,e){var n=U(t),i=I(t),s=U(e),o=I(e);function r(a,h){var d=U(h),l=U(a)*d,c=I(a)*d,u=I(h),p=u*n+l*i;return[we(c*s-p*o,l*n-u*i),ye(p*s+c*o)]}return r.invert=function(a,h){var d=U(h),l=U(a)*d,c=I(a)*d,u=I(h),p=u*s-c*o;return[we(c*s+u*o,l*n+p*i),ye(p*n-l*i)]},r}function li(t){t=Zt(t[0]*j,t[1]*j,t.length>2?t[2]*j:0);function e(n){return n=t(n[0]*j,n[1]*j),n[0]*=K,n[1]*=K,n}return e.invert=function(n){return n=t.invert(n[0]*j,n[1]*j),n[0]*=K,n[1]*=K,n},e}function ci(t,e,n,i,s,o){if(n){var r=U(e),a=I(e),h=i*n;s==null?(s=e+i*$,o=e-h/2):(s=bt(r,s),o=bt(r,o),(i>0?s<o:s>o)&&(s+=i*$));for(var d,l=s;i>0?l>o:l<o;l-=h)d=Ze([r,-a*U(l),-a*I(l)]),t.point(d[0],d[1])}}function bt(t,e){e=he(e),e[0]-=t,$e(e);var n=ri(-e[1]);return((-e[2]<0?-n:n)+$-T)%$}function $t(){var t=[],e;return{point:function(n,i,s){e.push([n,i,s])},lineStart:function(){t.push(e=[])},lineEnd:pe,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var n=t;return t=[],e=null,n}}}function Be(t,e){return B(t[0]-e[0])<T&&B(t[1]-e[1])<T}function be(t,e,n,i){this.x=t,this.z=e,this.o=n,this.e=i,this.v=!1,this.n=this.p=null}function en(t,e,n,i,s){var o=[],r=[],a,h;if(t.forEach(function(m){if(!((g=m.length-1)<=0)){var g,f=m[0],E=m[g],S;if(Be(f,E)){if(!f[2]&&!E[2]){for(s.lineStart(),a=0;a<g;++a)s.point((f=m[a])[0],f[1]);s.lineEnd();return}E[0]+=2*T}o.push(S=new be(f,m,null,!0)),r.push(S.o=new be(f,null,S,!1)),o.push(S=new be(E,m,null,!1)),r.push(S.o=new be(E,null,S,!0))}}),!!o.length){for(r.sort(e),Pt(o),Pt(r),a=0,h=r.length;a<h;++a)r[a].e=n=!n;for(var d=o[0],l,c;;){for(var u=d,p=!0;u.v;)if((u=u.n)===d)return;l=u.z,s.lineStart();do{if(u.v=u.o.v=!0,u.e){if(p)for(a=0,h=l.length;a<h;++a)s.point((c=l[a])[0],c[1]);else i(u.x,u.n.x,1,s);u=u.n}else{if(p)for(l=u.p.z,a=l.length-1;a>=0;--a)s.point((c=l[a])[0],c[1]);else i(u.x,u.p.x,-1,s);u=u.p}u=u.o,l=u.z,p=!p}while(!u.v);s.lineEnd()}}}function Pt(t){if(e=t.length){for(var e,n=0,i=t[0],s;++n<e;)i.n=s=t[n],s.p=i,i=s;i.n=s=t[0],s.p=i}}function Ye(t){return B(t[0])<=P?t[0]:si(t[0])*((B(t[0])+P)%$-P)}function ui(t,e){var n=Ye(e),i=e[1],s=I(i),o=[I(n),-U(n),0],r=0,a=0,h=new $n;s===1?i=X+T:s===-1&&(i=-X-T);for(var d=0,l=t.length;d<l;++d)if(u=(c=t[d]).length)for(var c,u,p=c[u-1],m=Ye(p),g=p[1]/2+yt,f=I(g),E=U(g),S=0;S<u;++S,m=w,f=C,E=L,p=y){var y=c[S],w=Ye(y),x=y[1]/2+yt,C=I(x),L=U(x),O=w-m,z=O>=0?1:-1,R=z*O,A=R>P,Y=f*C;if(h.add(we(Y*z*I(R),E*L+Y*U(R))),r+=A?O+z*$:O,A^m>=n^w>=n){var _=Ue(he(p),he(y));$e(_);var D=Ue(o,_);$e(D);var v=(A^O>=0?-1:1)*ye(D[2]);(i>v||i===v&&(_[0]||_[1]))&&(a+=A^O>=0?1:-1)}}return(r<-T||r<T&&h<-ti)^a&1}function tn(t,e,n,i){return function(s){var o=e(s),r=$t(),a=e(r),h=!1,d,l,c,u={point:p,lineStart:g,lineEnd:f,polygonStart:function(){u.point=E,u.lineStart=S,u.lineEnd=y,l=[],d=[]},polygonEnd:function(){u.point=p,u.lineStart=g,u.lineEnd=f,l=qt(l);var w=ui(d,i);l.length?(h||(s.polygonStart(),h=!0),en(l,fi,w,n,s)):w&&(h||(s.polygonStart(),h=!0),s.lineStart(),n(null,null,1,s),s.lineEnd()),h&&(s.polygonEnd(),h=!1),l=d=null},sphere:function(){s.polygonStart(),s.lineStart(),n(null,null,1,s),s.lineEnd(),s.polygonEnd()}};function p(w,x){t(w,x)&&s.point(w,x)}function m(w,x){o.point(w,x)}function g(){u.point=m,o.lineStart()}function f(){u.point=p,o.lineEnd()}function E(w,x){c.push([w,x]),a.point(w,x)}function S(){a.lineStart(),c=[]}function y(){E(c[0][0],c[0][1]),a.lineEnd();var w=a.clean(),x=r.result(),C,L=x.length,O,z,R;if(c.pop(),d.push(c),c=null,!!L){if(w&1){if(z=x[0],(O=z.length-1)>0){for(h||(s.polygonStart(),h=!0),s.lineStart(),C=0;C<O;++C)s.point((R=z[C])[0],R[1]);s.lineEnd()}return}L>1&&w&2&&x.push(x.pop().concat(x.shift())),l.push(x.filter(hi))}}return u}}function hi(t){return t.length>1}function fi(t,e){return((t=t.x)[0]<0?t[1]-X-T:X-t[1])-((e=e.x)[0]<0?e[1]-X-T:X-e[1])}const Lt=tn(function(){return!0},di,mi,[-P,-X]);function di(t){var e=NaN,n=NaN,i=NaN,s;return{lineStart:function(){t.lineStart(),s=1},point:function(o,r){var a=o>0?P:-P,h=B(o-e);B(h-P)<T?(t.point(e,n=(n+r)/2>0?X:-X),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(a,n),t.point(o,n),s=0):i!==a&&h>=P&&(B(e-i)<T&&(e-=i*T),B(o-a)<T&&(o-=a*T),n=pi(e,n,o,r),t.point(i,n),t.lineEnd(),t.lineStart(),t.point(a,n),s=0),t.point(e=o,n=r),i=a},lineEnd:function(){t.lineEnd(),e=n=NaN},clean:function(){return 2-s}}}function pi(t,e,n,i){var s,o,r=I(t-n);return B(r)>T?Qt((I(e)*(o=U(i))*I(n)-I(i)*(s=U(e))*I(t))/(s*o*r)):(e+i)/2}function mi(t,e,n,i){var s;if(t==null)s=n*X,i.point(-P,s),i.point(0,s),i.point(P,s),i.point(P,0),i.point(P,-s),i.point(0,-s),i.point(-P,-s),i.point(-P,0),i.point(-P,s);else if(B(t[0]-e[0])>T){var o=t[0]<e[0]?P:-P;s=n*o/2,i.point(-o,s),i.point(0,s),i.point(o,s)}else i.point(e[0],e[1])}function vi(t){var e=U(t),n=2*j,i=e>0,s=B(e)>T;function o(l,c,u,p){ci(p,t,n,u,l,c)}function r(l,c){return U(l)*U(c)>e}function a(l){var c,u,p,m,g;return{lineStart:function(){m=p=!1,g=1},point:function(f,E){var S=[f,E],y,w=r(f,E),x=i?w?0:d(f,E):w?d(f+(f<0?P:-P),E):0;if(!c&&(m=p=w)&&l.lineStart(),w!==p&&(y=h(c,S),(!y||Be(c,y)||Be(S,y))&&(S[2]=1)),w!==p)g=0,w?(l.lineStart(),y=h(S,c),l.point(y[0],y[1])):(y=h(c,S),l.point(y[0],y[1],2),l.lineEnd()),c=y;else if(s&&c&&i^w){var C;!(x&u)&&(C=h(S,c,!0))&&(g=0,i?(l.lineStart(),l.point(C[0][0],C[0][1]),l.point(C[1][0],C[1][1]),l.lineEnd()):(l.point(C[1][0],C[1][1]),l.lineEnd(),l.lineStart(),l.point(C[0][0],C[0][1],3)))}w&&(!c||!Be(c,S))&&l.point(S[0],S[1]),c=S,p=w,u=x},lineEnd:function(){p&&l.lineEnd(),c=null},clean:function(){return g|(m&&p)<<1}}}function h(l,c,u){var p=he(l),m=he(c),g=[1,0,0],f=Ue(p,m),E=Ae(f,f),S=f[0],y=E-S*S;if(!y)return!u&&l;var w=e*E/y,x=-e*S/y,C=Ue(g,f),L=Ce(g,w),O=Ce(f,x);He(L,O);var z=C,R=Ae(L,z),A=Ae(z,z),Y=R*R-A*(Ae(L,L)-1);if(!(Y<0)){var _=Ne(Y),D=Ce(z,(-R-_)/A);if(He(D,L),D=Ze(D),!u)return D;var v=l[0],b=c[0],G=l[1],V=c[1],q;b<v&&(q=v,v=b,b=q);var de=b-v,se=B(de-P)<T,ae=se||de<T;if(!se&&V<G&&(q=G,G=V,V=q),ae?se?G+V>0^D[1]<(B(D[0]-v)<T?G:V):G<=D[1]&&D[1]<=V:de>P^(v<=D[0]&&D[0]<=b)){var oe=Ce(z,(-R+_)/A);return He(oe,L),[D,Ze(oe)]}}}function d(l,c){var u=i?t:P-t,p=0;return l<-u?p|=1:l>u&&(p|=2),c<-u?p|=4:c>u&&(p|=8),p}return tn(r,a,o,i?[0,-t]:[-P,t-P])}function gi(t,e,n,i,s,o){var r=t[0],a=t[1],h=e[0],d=e[1],l=0,c=1,u=h-r,p=d-a,m;if(m=n-r,!(!u&&m>0)){if(m/=u,u<0){if(m<l)return;m<c&&(c=m)}else if(u>0){if(m>c)return;m>l&&(l=m)}if(m=s-r,!(!u&&m<0)){if(m/=u,u<0){if(m>c)return;m>l&&(l=m)}else if(u>0){if(m<l)return;m<c&&(c=m)}if(m=i-a,!(!p&&m>0)){if(m/=p,p<0){if(m<l)return;m<c&&(c=m)}else if(p>0){if(m>c)return;m>l&&(l=m)}if(m=o-a,!(!p&&m<0)){if(m/=p,p<0){if(m>c)return;m>l&&(l=m)}else if(p>0){if(m<l)return;m<c&&(c=m)}return l>0&&(t[0]=r+l*u,t[1]=a+l*p),c<1&&(e[0]=r+c*u,e[1]=a+c*p),!0}}}}}var me=1e9,Pe=-me;function wi(t,e,n,i){function s(d,l){return t<=d&&d<=n&&e<=l&&l<=i}function o(d,l,c,u){var p=0,m=0;if(d==null||(p=r(d,c))!==(m=r(l,c))||h(d,l)<0^c>0)do u.point(p===0||p===3?t:n,p>1?i:e);while((p=(p+c+4)%4)!==m);else u.point(l[0],l[1])}function r(d,l){return B(d[0]-t)<T?l>0?0:3:B(d[0]-n)<T?l>0?2:1:B(d[1]-e)<T?l>0?1:0:l>0?3:2}function a(d,l){return h(d.x,l.x)}function h(d,l){var c=r(d,1),u=r(l,1);return c!==u?c-u:c===0?l[1]-d[1]:c===1?d[0]-l[0]:c===2?d[1]-l[1]:l[0]-d[0]}return function(d){var l=d,c=$t(),u,p,m,g,f,E,S,y,w,x,C,L={point:O,lineStart:Y,lineEnd:_,polygonStart:R,polygonEnd:A};function O(v,b){s(v,b)&&l.point(v,b)}function z(){for(var v=0,b=0,G=p.length;b<G;++b)for(var V=p[b],q=1,de=V.length,se=V[0],ae,oe,xe=se[0],ce=se[1];q<de;++q)ae=xe,oe=ce,se=V[q],xe=se[0],ce=se[1],oe<=i?ce>i&&(xe-ae)*(i-oe)>(ce-oe)*(t-ae)&&++v:ce<=i&&(xe-ae)*(i-oe)<(ce-oe)*(t-ae)&&--v;return v}function R(){l=c,u=[],p=[],C=!0}function A(){var v=z(),b=C&&v,G=(u=qt(u)).length;(b||G)&&(d.polygonStart(),b&&(d.lineStart(),o(null,null,1,d),d.lineEnd()),G&&en(u,a,v,o,d),d.polygonEnd()),l=d,u=p=m=null}function Y(){L.point=D,p&&p.push(m=[]),x=!0,w=!1,S=y=NaN}function _(){u&&(D(g,f),E&&w&&c.rejoin(),u.push(c.result())),L.point=O,w&&l.lineEnd()}function D(v,b){var G=s(v,b);if(p&&m.push([v,b]),x)g=v,f=b,E=G,x=!1,G&&(l.lineStart(),l.point(v,b));else if(G&&w)l.point(v,b);else{var V=[S=Math.max(Pe,Math.min(me,S)),y=Math.max(Pe,Math.min(me,y))],q=[v=Math.max(Pe,Math.min(me,v)),b=Math.max(Pe,Math.min(me,b))];gi(V,q,t,e,n,i)?(w||(l.lineStart(),l.point(V[0],V[1])),l.point(q[0],q[1]),G||l.lineEnd(),C=!1):G&&(l.lineStart(),l.point(v,b),C=!1)}S=v,y=b,w=G}return L}}const Ot=t=>t;var fe=1/0,Ie=fe,Se=-fe,je=Se,yi={point:Si,lineStart:pe,lineEnd:pe,polygonStart:pe,polygonEnd:pe,result:function(){var t=[[fe,Ie],[Se,je]];return Se=je=-(Ie=fe=1/0),t}};function Si(t,e){t<fe&&(fe=t),t>Se&&(Se=t),e<Ie&&(Ie=e),e>je&&(je=e)}const zt=yi;function ut(t){return function(e){var n=new nt;for(var i in t)n[i]=t[i];return n.stream=e,n}}function nt(){}nt.prototype={constructor:nt,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function ht(t,e,n){var i=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),i!=null&&t.clipExtent(null),ai(n,t.stream(zt)),e(zt.result()),i!=null&&t.clipExtent(i),t}function nn(t,e,n){return ht(t,function(i){var s=e[1][0]-e[0][0],o=e[1][1]-e[0][1],r=Math.min(s/(i[1][0]-i[0][0]),o/(i[1][1]-i[0][1])),a=+e[0][0]+(s-r*(i[1][0]+i[0][0]))/2,h=+e[0][1]+(o-r*(i[1][1]+i[0][1]))/2;t.scale(150*r).translate([a,h])},n)}function Ei(t,e,n){return nn(t,[[0,0],e],n)}function xi(t,e,n){return ht(t,function(i){var s=+e,o=s/(i[1][0]-i[0][0]),r=(s-o*(i[1][0]+i[0][0]))/2,a=-o*i[0][1];t.scale(150*o).translate([r,a])},n)}function Mi(t,e,n){return ht(t,function(i){var s=+e,o=s/(i[1][1]-i[0][1]),r=-o*i[0][0],a=(s-o*(i[1][1]+i[0][1]))/2;t.scale(150*o).translate([r,a])},n)}var Dt=16,Ai=U(30*j);function Tt(t,e){return+e?bi(t,e):Ci(t)}function Ci(t){return ut({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}function bi(t,e){function n(i,s,o,r,a,h,d,l,c,u,p,m,g,f){var E=d-i,S=l-s,y=E*E+S*S;if(y>4*e&&g--){var w=r+u,x=a+p,C=h+m,L=Ne(w*w+x*x+C*C),O=ye(C/=L),z=B(B(C)-1)<T||B(o-c)<T?(o+c)/2:we(x,w),R=t(z,O),A=R[0],Y=R[1],_=A-i,D=Y-s,v=S*_-E*D;(v*v/y>e||B((E*_+S*D)/y-.5)>.3||r*u+a*p+h*m<Ai)&&(n(i,s,o,r,a,h,A,Y,z,w/=L,x/=L,C,g,f),f.point(A,Y),n(A,Y,z,w,x,C,d,l,c,u,p,m,g,f))}}return function(i){var s,o,r,a,h,d,l,c,u,p,m,g,f={point:E,lineStart:S,lineEnd:w,polygonStart:function(){i.polygonStart(),f.lineStart=x},polygonEnd:function(){i.polygonEnd(),f.lineStart=S}};function E(O,z){O=t(O,z),i.point(O[0],O[1])}function S(){c=NaN,f.point=y,i.lineStart()}function y(O,z){var R=he([O,z]),A=t(O,z);n(c,u,l,p,m,g,c=A[0],u=A[1],l=O,p=R[0],m=R[1],g=R[2],Dt,i),i.point(c,u)}function w(){f.point=E,i.lineEnd()}function x(){S(),f.point=C,f.lineEnd=L}function C(O,z){y(s=O,z),o=c,r=u,a=p,h=m,d=g,f.point=y}function L(){n(c,u,l,p,m,g,o,r,s,a,h,d,Dt,i),f.lineEnd=w,w()}return f}}var Pi=ut({point:function(t,e){this.stream.point(t*j,e*j)}});function Li(t){return ut({point:function(e,n){var i=t(e,n);return this.stream.point(i[0],i[1])}})}function Oi(t,e,n,i,s){function o(r,a){return r*=i,a*=s,[e+t*r,n-t*a]}return o.invert=function(r,a){return[(r-e)/t*i,(n-a)/t*s]},o}function Rt(t,e,n,i,s,o){if(!o)return Oi(t,e,n,i,s);var r=U(o),a=I(o),h=r*t,d=a*t,l=r/t,c=a/t,u=(a*n-r*e)/t,p=(a*e+r*n)/t;function m(g,f){return g*=i,f*=s,[h*g-d*f+e,n-d*g-h*f]}return m.invert=function(g,f){return[i*(l*g-c*f+u),s*(p-c*g-l*f)]},m}function zi(t){return Di(function(){return t})()}function Di(t){var e,n=150,i=480,s=250,o=0,r=0,a=0,h=0,d=0,l,c=0,u=1,p=1,m=null,g=Lt,f=null,E,S,y,w=Ot,x=.5,C,L,O,z,R;function A(v){return O(v[0]*j,v[1]*j)}function Y(v){return v=O.invert(v[0],v[1]),v&&[v[0]*K,v[1]*K]}A.stream=function(v){return z&&R===v?z:z=Pi(Li(l)(g(C(w(R=v)))))},A.preclip=function(v){return arguments.length?(g=v,m=void 0,D()):g},A.postclip=function(v){return arguments.length?(w=v,f=E=S=y=null,D()):w},A.clipAngle=function(v){return arguments.length?(g=+v?vi(m=v*j):(m=null,Lt),D()):m*K},A.clipExtent=function(v){return arguments.length?(w=v==null?(f=E=S=y=null,Ot):wi(f=+v[0][0],E=+v[0][1],S=+v[1][0],y=+v[1][1]),D()):f==null?null:[[f,E],[S,y]]},A.scale=function(v){return arguments.length?(n=+v,_()):n},A.translate=function(v){return arguments.length?(i=+v[0],s=+v[1],_()):[i,s]},A.center=function(v){return arguments.length?(o=v[0]%360*j,r=v[1]%360*j,_()):[o*K,r*K]},A.rotate=function(v){return arguments.length?(a=v[0]%360*j,h=v[1]%360*j,d=v.length>2?v[2]%360*j:0,_()):[a*K,h*K,d*K]},A.angle=function(v){return arguments.length?(c=v%360*j,_()):c*K},A.reflectX=function(v){return arguments.length?(u=v?-1:1,_()):u<0},A.reflectY=function(v){return arguments.length?(p=v?-1:1,_()):p<0},A.precision=function(v){return arguments.length?(C=Tt(L,x=v*v),D()):Ne(x)},A.fitExtent=function(v,b){return nn(A,v,b)},A.fitSize=function(v,b){return Ei(A,v,b)},A.fitWidth=function(v,b){return xi(A,v,b)},A.fitHeight=function(v,b){return Mi(A,v,b)};function _(){var v=Rt(n,0,0,u,p,c).apply(null,e(o,r)),b=Rt(n,i-v[0],s-v[1],u,p,c);return l=Zt(a,h,d),L=et(e,b),O=et(l,L),C=Tt(L,x),D()}function D(){return z=R=null,A}return function(){return e=t.apply(this,arguments),A.invert=e.invert&&Y,_()}}function ft(t,e){return[t,ii(oi((X+e)/2))]}ft.invert=function(t,e){return[t,2*Qt(ni(e))-X]};function dt(){return Ti(ft).scale(961/$)}function Ti(t){var e=zi(t),n=e.center,i=e.scale,s=e.translate,o=e.clipExtent,r=null,a,h,d;e.scale=function(c){return arguments.length?(i(c),l()):i()},e.translate=function(c){return arguments.length?(s(c),l()):s()},e.center=function(c){return arguments.length?(n(c),l()):n()},e.clipExtent=function(c){return arguments.length?(c==null?r=a=h=d=null:(r=+c[0][0],a=+c[0][1],h=+c[1][0],d=+c[1][1]),l()):r==null?null:[[r,a],[h,d]]};function l(){var c=P*i(),u=e(li(e.rotate()).invert([0,0]));return o(r==null?[[u[0]-c,u[1]-c],[u[0]+c,u[1]+c]]:t===ft?[[Math.max(u[0]-c,r),a],[Math.min(u[0]+c,h),d]]:[[r,Math.max(u[1]-c,a)],[h,Math.min(u[1]+c,d)]])}return l()}class Qi extends lt{constructor(e,n={}){var s,o;super();let i={isOrthographic:!1};this.config=Object.assign({},i,n),this.canvas=e,this.scene=new xn,this.sizes=new Jn(this),this.time=new Xn(this),this.camera=new Zn(this,{isOrthographic:this.config.isOrthographic}),this.renderer=new Qn(this),this.handleControlsChange=()=>{var r,a,h;this.renderer.update(),(a=(r=this.label3d)==null?void 0:r.update)==null||a.call(r),(h=this.updateTownLabelScale)==null||h.call(this)},(o=(s=this.camera.controls)==null?void 0:s.addEventListener)==null||o.call(s,"change",this.handleControlsChange),this.sizes.on("resize",()=>{this.resize()}),this.time.on("tick",r=>{this.update(r)})}setAxesHelper(e=250){if(!e)return!1;let n=new Mn(e);this.scene.add(n)}resize(){this.camera.resize(),this.renderer.resize()}update(e){this.camera.update(e),this.renderer.update(e)}destroy(){var e,n,i,s;(n=(e=this.camera.controls)==null?void 0:e.removeEventListener)==null||n.call(e,"change",this.handleControlsChange),this.sizes.destroy(),this.time.destroy(),this.camera.destroy(),this.renderer.destroy(),this.scene.traverse(o=>{if(o instanceof re){o.geometry.dispose();for(const r in o.material){const a=o.material[r];a&&typeof a.dispose=="function"&&a.dispose()}}}),(s=(i=this.canvas)==null?void 0:i.parentNode)==null||s.removeChild(this.canvas)}}class Zi{constructor({material:e,time:n,size:i,diffuseColor:s,diffuseSpeed:o,diffuseWidth:r,callback:a=()=>{}}){this.time=n,this.pointShader=null,this.callback=a;let h={size:100,diffuseSpeed:15,diffuseColor:9345950,diffuseWidth:10};this.options=Object.assign({},h,{material:e,size:i,diffuseColor:s,diffuseSpeed:o,diffuseWidth:r}),this.init()}init(){let{material:e,size:n,diffuseColor:i,diffuseSpeed:s,diffuseWidth:o}=this.options,r=n/s;e.onBeforeCompile=a=>{this.pointShader=a,this.callback(a,r),a.uniforms=Z(Q({},a.uniforms),{uTime:{value:0},uSpeed:{value:s},uWidth:{value:o},uColor:{value:new Ke(i)}}),a.vertexShader=a.vertexShader.replace("void main() {",`
|
|
varying vec3 vPosition;
|
|
void main(){
|
|
vPosition = position;
|
|
`),a.fragmentShader=a.fragmentShader.replace("void main() {",`
|
|
uniform float uTime;
|
|
uniform float uSpeed;
|
|
uniform float uWidth;
|
|
uniform vec3 uColor;
|
|
varying vec3 vPosition;
|
|
void main(){
|
|
`),a.fragmentShader=a.fragmentShader.replace("#include <opaque_fragment>",`
|
|
#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
#endif
|
|
|
|
float r = uTime * uSpeed;
|
|
|
|
float w = uWidth;
|
|
// if(w>uWidth){
|
|
// w = uWidth;
|
|
// }else{
|
|
// w = uTime * 1.5;
|
|
// }
|
|
|
|
vec2 center = vec2(0.0, 0.0);
|
|
|
|
float rDistance = distance(vPosition.xy, center);
|
|
|
|
if(rDistance > r && rDistance < r + 2.0 * w) {
|
|
float per = 0.0;
|
|
if(rDistance < r + w) {
|
|
float p = smoothstep(0.0,1.0,(rDistance - r) / w);
|
|
p*=p;
|
|
outgoingLight = mix(outgoingLight, uColor, p);
|
|
} else {
|
|
|
|
float p = smoothstep(0.0,1.0,(rDistance - r - w) / w);
|
|
|
|
outgoingLight = mix(uColor, outgoingLight, p);
|
|
}
|
|
gl_FragColor = vec4(outgoingLight, diffuseColor.a);
|
|
} else {
|
|
gl_FragColor = vec4(outgoingLight, 0.0);
|
|
}
|
|
`)}}}class $i{constructor({scene:e,time:n},i){this.scene=e,this.time=n,this.instance=null;let s={position:new F(0,0,0),gridSize:100,gridDivision:20,gridColor:2635578,shapeSize:1,shapeColor:9345950,pointSize:.2,pointColor:2635578,pointLayout:{row:200,col:200},pointBlending:An};this.options=Object.assign({},s,i),this.init()}init(){let e=new ve;e.name="Grid";let n=this.createGridHelp(),i=this.createShapes(),s=this.createPoint();e.add(n,i,s),e.position.copy(this.options.position),this.instance=e,this.scene.add(e)}createShapes(){let{gridSize:e,gridDivision:n,shapeSize:i,shapeColor:s}=this.options,o=e/n,r=e/2,a=new ge({color:s,side:Cn}),h=[];for(let c=0;c<n+1;c++)for(let u=0;u<n+1;u++){let p=this.createPlus(i);p.translate(-r+c*o,-r+u*o,0),h.push(p)}let d=Xt(h),l=new re(d,a);return l.renderOrder=-1,l.rotateX(-Math.PI/2),l.position.y+=.01,l}createGridHelp(){let{gridSize:e,gridDivision:n,gridColor:i}=this.options;return new bn(e,n,i,i)}createPoint(){let{gridSize:e,pointSize:n,pointColor:i,pointBlending:s,pointLayout:o}=this.options;const r=o.row,a=o.col,h=new Float32Array(r*a*3);for(let u=0;u<r;u++)for(let p=0;p<a;p++){let m=u/(r-1)*e-e/2,g=0,f=p/(a-1)*e-e/2,E=(u*a+p)*3;h[E]=m,h[E+1]=g,h[E+2]=f}var d=new it;d.setAttribute("position",new De(h,3));let l=new kt({size:n,sizeAttenuation:!0,color:i,blending:s});return new Ht(d,l)}setPointMode(){}createPlus(e=50){let n=e/6/3,i=e/3,s=[new N(-i,-n),new N(-n,-n),new N(-n,-i),new N(n,-i),new N(n,-i),new N(n,-n),new N(i,-n),new N(i,n),new N(n,n),new N(n,i),new N(-n,i),new N(-n,n),new N(-i,n)],o=new st(s);return new Yt(o,24)}}const Bt=new F,Ri=new Pn,_t=new F;class sn extends ot{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(n){n.element instanceof Element&&n.element.parentNode!==null&&n.element.parentNode.removeChild(n.element)})})}copy(e,n){return super.copy(e,n),this.element=e.element.cloneNode(!0),this}}class Bi extends sn{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,n){return super.copy(e,n),this.rotation2D=e.rotation2D,this}}const ee=new rt,_i=new rt;class Ui{constructor(e={}){const n=this;let i,s,o,r;const a={camera:{style:""},objects:new WeakMap},h=e.element!==void 0?e.element:document.createElement("div");h.style.overflow="hidden",this.domElement=h;const d=document.createElement("div");d.style.transformOrigin="0 0",d.style.pointerEvents="none",h.appendChild(d);const l=document.createElement("div");l.style.transformStyle="preserve-3d",d.appendChild(l),this.getSize=function(){return{width:i,height:s}},this.render=function(g,f){const E=f.projectionMatrix.elements[5]*r;f.view&&f.view.enabled?(d.style.transform=`translate( ${-f.view.offsetX*(i/f.view.width)}px, ${-f.view.offsetY*(s/f.view.height)}px )`,d.style.transform+=`scale( ${f.view.fullWidth/f.view.width}, ${f.view.fullHeight/f.view.height} )`):d.style.transform="",g.matrixWorldAutoUpdate===!0&&g.updateMatrixWorld(),f.parent===null&&f.matrixWorldAutoUpdate===!0&&f.updateMatrixWorld();let S,y;f.isOrthographicCamera&&(S=-(f.right+f.left)/2,y=(f.top+f.bottom)/2);const w=f.view&&f.view.enabled?f.view.height/f.view.fullHeight:1,x=f.isOrthographicCamera?`scale( ${w} )scale(`+E+")translate("+c(S)+"px,"+c(y)+"px)"+u(f.matrixWorldInverse):`scale( ${w} )translateZ(`+E+"px)"+u(f.matrixWorldInverse),L=(f.isPerspectiveCamera?"perspective("+E+"px) ":"")+x+"translate("+o+"px,"+r+"px)";a.camera.style!==L&&(l.style.transform=L,a.camera.style=L),m(g,g,f)},this.setSize=function(g,f){i=g,s=f,o=i/2,r=s/2,h.style.width=g+"px",h.style.height=f+"px",d.style.width=g+"px",d.style.height=f+"px",l.style.width=g+"px",l.style.height=f+"px"};function c(g){return Math.abs(g)<1e-10?0:g}function u(g){const f=g.elements;return"matrix3d("+c(f[0])+","+c(-f[1])+","+c(f[2])+","+c(f[3])+","+c(f[4])+","+c(-f[5])+","+c(f[6])+","+c(f[7])+","+c(f[8])+","+c(-f[9])+","+c(f[10])+","+c(f[11])+","+c(f[12])+","+c(-f[13])+","+c(f[14])+","+c(f[15])+")"}function p(g){const f=g.elements;return"translate(-50%,-50%)"+("matrix3d("+c(f[0])+","+c(f[1])+","+c(f[2])+","+c(f[3])+","+c(-f[4])+","+c(-f[5])+","+c(-f[6])+","+c(-f[7])+","+c(f[8])+","+c(f[9])+","+c(f[10])+","+c(f[11])+","+c(f[12])+","+c(f[13])+","+c(f[14])+","+c(f[15])+")")}function m(g,f,E,S){if(g.isCSS3DObject){const y=g.visible===!0&&g.layers.test(E.layers)===!0;if(g.element.style.display=y===!0?"":"none",y===!0){g.onBeforeRender(n,f,E);let w;g.isCSS3DSprite?(ee.copy(E.matrixWorldInverse),ee.transpose(),g.rotation2D!==0&&ee.multiply(_i.makeRotationZ(g.rotation2D)),g.matrixWorld.decompose(Bt,Ri,_t),ee.setPosition(Bt),ee.scale(_t),ee.elements[3]=0,ee.elements[7]=0,ee.elements[11]=0,ee.elements[15]=1,w=p(ee)):w=p(g.matrixWorld);const x=g.element,C=a.objects.get(g);if(C===void 0||C.style!==w){x.style.transform=w;const L={style:w};a.objects.set(g,L)}x.parentNode!==l&&l.appendChild(x),g.onAfterRender(n,f,E)}}for(let y=0,w=g.children.length;y<w;y++)m(g.children[y],f,E)}}}class es{constructor({scene:e,camera:n,time:i,sizes:s,canvas:o}){this.scene=e,this.camera=n,this.time=i,this.sizes=s,this.canvas=o,this.parent=null;let{width:r,height:a}=this.sizes,h=new Ui;this.css3dRender=h,h.setSize(r,a),h.domElement.style.position="absolute",h.domElement.style.left="0px",h.domElement.style.top="0px",h.domElement.style.pointerEvents="none",h.domElement.className="label3d-"+Kn(),this.canvas.parentNode.appendChild(h.domElement),this.time.on("tick",()=>{this.update()}),this.sizes.on("resize",()=>{this.resize()})}create(e="",n="",i=!1){let s=document.createElement("div");s.innerHTML=e,s.className=n,s.style.visibility="hidden",s.style.position="absolute",n||(s.style.padding="10px",s.style.color="#fff",s.style.fontSize="12px",s.style.textAlign="center",s.style.background="rgba(0,0,0,0.6)",s.style.borderRadius="4px");let o=null;return i?o=new Bi(s):o=new sn(s),o.init=(r,a)=>{o.element.innerHTML=r,o.element.style.visibility="visible",o.position.copy(a)},o.hide=()=>{o.element.style.visibility="hidden"},o.scaleHide=()=>{o.element.classList.add("scale-hidden")},o.show=()=>{o.element.style.visibility="visible",o.element.classList.remove("scale-hidden")},o.setParent=r=>{this.parent=r,r.add(o)},o.remove=()=>{this.parent.remove(o)},o}setLabelStyle(e,n=.1,i="x",s=Math.PI/2,o="none"){e.element.style.pointerEvents=o,e.scale.set(n,n,n),e.rotation[i]=s}setRenderLevel(e){this.css3dRender.domElement.style.zIndex=e}update(){this.css3dRender.render(this.scene,this.camera.instance)}destroy(){if(this.css3dRender){let e=this.css3dRender.domElement;e.parentNode.removeChild(e)}}resize(){let{width:e,height:n}=this.sizes;this.css3dRender.setSize(e,n)}}class ts{constructor({time:e},n){this.time=e,this.options=Object.assign({},{width:10,scale:1,position:new F(0,0,0),needRotate:!1,rotateSpeed:.001,material:new ge({transparent:!0,opacity:1,depthTest:!0})},n);let i=new Ln(this.options.width,this.options.width),s=new re(i,this.options.material);s.position.copy(this.options.position),s.scale.set(this.options.scale,this.options.scale,this.options.scale),this.instance=s}setParent(e){e.add(this.instance),this.time.on("tick",()=>{this.update()})}update(){this.options.needRotate&&(this.instance.rotation.z+=this.options.rotateSpeed)}}class on{constructor({time:e},n={}){this.instance=null,this.time=e,this.enable=!0,this.config=Object.assign({num:100,range:500,speed:.01,renderOrder:99,dir:"up",material:new kt({map:on.createTexture(),size:20,color:16777215,transparent:!0,opacity:1,depthTest:!1,vertexColors:!0,blending:On,sizeAttenuation:!0})},n),this.create()}create(){const{range:e,speed:n,dir:i,material:s,num:o,renderOrder:r}=this.config,a=[],h=[],d=[];for(let c=0;c<o;c++){a.push(Math.random()*e-e/2,Math.random()*e-e/2,Math.random()*e-e/2);let u=i==="up"?1:-1;d.push(Math.random()*u,(.1+Math.random())*u,.1+Math.random()*u);const p=s.color.clone();let m={};p.getHSL(m),p.setHSL(m.h,m.s,m.l*Math.random()),h.push(p.r,p.g,p.b)}const l=new it;l.setAttribute("position",new De(new Float32Array(a),3)),l.setAttribute("velocities",new De(new Float32Array(d),3)),l.setAttribute("color",new De(new Float32Array(h),3)),this.instance=new Ht(l,s),this.instance.renderOrder=r}static createTexture(){let e=document.createElement("canvas");e.width=1024,e.height=1024;let n=e.getContext("2d"),i=n.createRadialGradient(512,512,0,512,512,512);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(1,"rgba(255,255,255,0)"),n.fillStyle=i,n.fillRect(0,0,1024,1024),new zn(e)}update(e,n){if(!this.instance)return!1;const{range:i,speed:s,dir:o}=this.config;let r=o==="up"?1:-1,a=this.instance.geometry.getAttribute("position"),h=this.instance.geometry.getAttribute("velocities");const d=a.count;for(let l=0;l<d;l++){let c=a.getX(l);a.getY(l);let u=a.getZ(l),p=h.getX(l),m=h.getY(l);h.getZ(l),c+=Math.sin(p*n)*e,u+=s*r,u>i/2&&r===1&&(u=-i/2),u<-i/2&&r==-1&&(u=i/2),a.setX(l,c),a.setZ(l,u),h.setX(l,p),h.setY(l,m)}a.needsUpdate=!0,h.needsUpdate=!0}setParent(e){e.add(this.instance),this.time.on("tick",(n,i)=>{this.enable&&this.update(n,i)})}}class ns{constructor({},e={}){this.mapGroup=new ve,this.coordinates=[],this.config=Object.assign({position:new F(0,0,0),geoProjectionCenter:new N(0,0),geoProjectionScale:120,data:"",renderOrder:1,merge:!1,material:new ge({color:1582651,transparent:!0,opacity:1})},e),this.mapGroup.position.copy(this.config.position);let n=ct(this.config.data);this.create(n)}geoProjection(e){return dt().center(this.config.geoProjectionCenter).scale(this.config.geoProjectionScale).translate([0,0])(e)}create(e){let{merge:n}=this.config,i=[];if(e.features.forEach(s=>{const o=new ot;let{name:r,center:a=[],centroid:h=[]}=s.properties;this.coordinates.push({name:r,center:a,centroid:h}),o.userData.name=r,s.geometry.coordinates.forEach(d=>{d.forEach(l=>{const c=new st;for(let p=0;p<l.length;p++){if(!l[p][0]||!l[p][1])return!1;const[m,g]=this.geoProjection(l[p]);p===0&&c.moveTo(m,-g),c.lineTo(m,-g)}const u=new Yt(c);if(n)i.push(u);else{const p=new re(u,this.config.material);p.renderOrder=this.config.renderOrder,p.userData.name=r,o.add(p)}})}),n||this.mapGroup.add(o)}),n){let s=Xt(i);const o=new re(s,this.config.material);o.renderOrder=this.config.renderOrder,this.mapGroup.add(o)}}getCoordinates(){return this.coordinates}setParent(e){e.add(this.mapGroup)}}class is{constructor({assets:e,time:n},i={}){this.mapGroup=new ve,this.assets=e,this.time=n,this.coordinates=[],this.config=Object.assign({position:new F(0,0,0),geoProjectionCenter:new N(0,0),geoProjectionScale:120,data:"",renderOrder:1,topFaceMaterial:new ge({color:1582651,transparent:!0,opacity:1}),sideMaterial:new ge({color:464171,transparent:!0,opacity:1}),depth:.1},i),this.mapGroup.position.copy(this.config.position);let s=ct(this.config.data);this.create(s)}geoProjection(e){return dt().center(this.config.geoProjectionCenter).scale(this.config.geoProjectionScale).translate([0,0])(e)}create(e){e.features.forEach(n=>{var d,l,c;const i=new ot;let{name:s,center:o=[],centroid:r=[]}=n.properties;this.coordinates.push({name:s,center:o,centroid:r});const a={depth:this.config.depth,bevelEnabled:(d=this.config.bevelEnabled)!=null?d:!0,bevelSegments:(l=this.config.bevelSegments)!=null?l:1,bevelThickness:(c=this.config.bevelThickness)!=null?c:.1};let h=[this.config.topFaceMaterial,this.config.sideMaterial];n.geometry.coordinates.forEach(u=>{u.forEach((p,m)=>{const g=new st;for(let S=0;S<p.length;S++){if(!p[S][0]||!p[S][1])return!1;const[y,w]=this.geoProjection(p[S]);S===0&&g.moveTo(y,-w),g.lineTo(y,-w)}const f=new Dn(g,a),E=new re(f,h);i.add(E)})}),this.mapGroup.add(i)})}getCoordinates(){return this.coordinates}setParent(e){e.add(this.mapGroup)}}const Ut=new at,Le=new F;class rn extends Tn{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],n=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],i=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(i),this.setAttribute("position",new wt(e,3)),this.setAttribute("uv",new wt(n,2))}applyMatrix4(e){const n=this.attributes.instanceStart,i=this.attributes.instanceEnd;return n!==void 0&&(n.applyMatrix4(e),i.applyMatrix4(e),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new qe(n,6,1);return this.setAttribute("instanceStart",new ue(i,3,0)),this.setAttribute("instanceEnd",new ue(i,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const i=new qe(n,6,1);return this.setAttribute("instanceColorStart",new ue(i,3,0)),this.setAttribute("instanceColorEnd",new ue(i,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Rn(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new at);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Ut.setFromBufferAttribute(n),this.boundingBox.union(Ut))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Vt),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let s=0;for(let o=0,r=e.count;o<r;o++)Le.fromBufferAttribute(e,o),s=Math.max(s,i.distanceToSquared(Le)),Le.fromBufferAttribute(n,o),s=Math.max(s,i.distanceToSquared(Le));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}Te.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new N(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};Re.line={uniforms:Jt.merge([Te.common,Te.fog,Te.line]),vertexShader:`
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
|
|
uniform float linewidth;
|
|
uniform vec2 resolution;
|
|
|
|
attribute vec3 instanceStart;
|
|
attribute vec3 instanceEnd;
|
|
|
|
attribute vec3 instanceColorStart;
|
|
attribute vec3 instanceColorEnd;
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
varying vec4 worldPos;
|
|
varying vec3 worldStart;
|
|
varying vec3 worldEnd;
|
|
|
|
#ifdef USE_DASH
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_DASH
|
|
|
|
uniform float dashScale;
|
|
attribute float instanceDistanceStart;
|
|
attribute float instanceDistanceEnd;
|
|
varying float vLineDistance;
|
|
|
|
#endif
|
|
|
|
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|
|
|
// trim end segment so it terminates between the camera plane and the near plane
|
|
|
|
// conservative estimate of the near plane
|
|
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
float nearEstimate = - 0.5 * b / a;
|
|
|
|
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
|
|
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
#ifdef USE_COLOR
|
|
|
|
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_DASH
|
|
|
|
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
vUv = uv;
|
|
|
|
#endif
|
|
|
|
float aspect = resolution.x / resolution.y;
|
|
|
|
// camera space
|
|
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
worldStart = start.xyz;
|
|
worldEnd = end.xyz;
|
|
|
|
#else
|
|
|
|
vUv = uv;
|
|
|
|
#endif
|
|
|
|
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
// perhaps there is a more elegant solution -- WestLangley
|
|
|
|
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
|
|
if ( perspective ) {
|
|
|
|
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
|
|
trimSegment( start, end );
|
|
|
|
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
|
|
trimSegment( end, start );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// clip space
|
|
vec4 clipStart = projectionMatrix * start;
|
|
vec4 clipEnd = projectionMatrix * end;
|
|
|
|
// ndc space
|
|
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
|
|
// direction
|
|
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
|
|
// account for clip-space aspect ratio
|
|
dir.x *= aspect;
|
|
dir = normalize( dir );
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
vec3 worldFwd = cross( worldDir, worldUp );
|
|
worldPos = position.y < 0.5 ? start: end;
|
|
|
|
// height offset
|
|
float hw = linewidth * 0.5;
|
|
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
|
|
// don't extend the line if we're rendering dashes because we
|
|
// won't be rendering the endcaps
|
|
#ifndef USE_DASH
|
|
|
|
// cap extension
|
|
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
|
|
// add width to the box
|
|
worldPos.xyz += worldFwd * hw;
|
|
|
|
// endcaps
|
|
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
|
|
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// project the worldpos
|
|
vec4 clip = projectionMatrix * worldPos;
|
|
|
|
// shift the depth of the projected points so the line
|
|
// segments overlap neatly
|
|
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
clip.z = clipPose.z * clip.w;
|
|
|
|
#else
|
|
|
|
vec2 offset = vec2( dir.y, - dir.x );
|
|
// undo aspect ratio adjustment
|
|
dir.x /= aspect;
|
|
offset.x /= aspect;
|
|
|
|
// sign flip
|
|
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
|
|
// endcaps
|
|
if ( position.y < 0.0 ) {
|
|
|
|
offset += - dir;
|
|
|
|
} else if ( position.y > 1.0 ) {
|
|
|
|
offset += dir;
|
|
|
|
}
|
|
|
|
// adjust for linewidth
|
|
offset *= linewidth;
|
|
|
|
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
offset /= resolution.y;
|
|
|
|
// select end
|
|
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
|
|
// back to clip space
|
|
offset *= clip.w;
|
|
|
|
clip.xy += offset;
|
|
|
|
#endif
|
|
|
|
gl_Position = clip;
|
|
|
|
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float linewidth;
|
|
|
|
#ifdef USE_DASH
|
|
|
|
uniform float dashOffset;
|
|
uniform float dashSize;
|
|
uniform float gapSize;
|
|
|
|
#endif
|
|
|
|
varying float vLineDistance;
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
varying vec4 worldPos;
|
|
varying vec3 worldStart;
|
|
varying vec3 worldEnd;
|
|
|
|
#ifdef USE_DASH
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
|
|
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
|
|
float mua;
|
|
float mub;
|
|
|
|
vec3 p13 = p1 - p3;
|
|
vec3 p43 = p4 - p3;
|
|
|
|
vec3 p21 = p2 - p1;
|
|
|
|
float d1343 = dot( p13, p43 );
|
|
float d4321 = dot( p43, p21 );
|
|
float d1321 = dot( p13, p21 );
|
|
float d4343 = dot( p43, p43 );
|
|
float d2121 = dot( p21, p21 );
|
|
|
|
float denom = d2121 * d4343 - d4321 * d4321;
|
|
|
|
float numer = d1343 * d4321 - d1321 * d4343;
|
|
|
|
mua = numer / denom;
|
|
mua = clamp( mua, 0.0, 1.0 );
|
|
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
mub = clamp( mub, 0.0, 1.0 );
|
|
|
|
return vec2( mua, mub );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
#include <clipping_planes_fragment>
|
|
|
|
#ifdef USE_DASH
|
|
|
|
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
|
|
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
|
|
#endif
|
|
|
|
float alpha = opacity;
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
// Find the closest points on the view ray and the line segment
|
|
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
vec3 lineDir = worldEnd - worldStart;
|
|
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
|
|
vec3 p1 = worldStart + lineDir * params.x;
|
|
vec3 p2 = rayEnd * params.y;
|
|
vec3 delta = p1 - p2;
|
|
float len = length( delta );
|
|
float norm = len / linewidth;
|
|
|
|
#ifndef USE_DASH
|
|
|
|
#ifdef USE_ALPHA_TO_COVERAGE
|
|
|
|
float dnorm = fwidth( norm );
|
|
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
|
|
#else
|
|
|
|
if ( norm > 0.5 ) {
|
|
|
|
discard;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#ifdef USE_ALPHA_TO_COVERAGE
|
|
|
|
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
float a = vUv.x;
|
|
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
float len2 = a * a + b * b;
|
|
float dlen = fwidth( len2 );
|
|
|
|
if ( abs( vUv.y ) > 1.0 ) {
|
|
|
|
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if ( abs( vUv.y ) > 1.0 ) {
|
|
|
|
float a = vUv.x;
|
|
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
float len2 = a * a + b * b;
|
|
|
|
if ( len2 > 1.0 ) discard;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
|
|
#include <logdepthbuf_fragment>
|
|
#include <color_fragment>
|
|
|
|
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
|
|
}
|
|
`};class an extends Bn{constructor(e){super({type:"LineMaterial",uniforms:Jt.clone(Re.line.uniforms),vertexShader:Re.line.vertexShader,fragmentShader:Re.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const It=new F,jt=new F,W=new Ge,k=new Ge,te=new Ge,Ve=new F,Je=new rt,H=new _n,Gt=new F,Oe=new at,ze=new Vt,ne=new Ge;let ie,le;function Nt(t,e,n){return ne.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),ne.multiplyScalar(1/ne.w),ne.x=le/n.width,ne.y=le/n.height,ne.applyMatrix4(t.projectionMatrixInverse),ne.multiplyScalar(1/ne.w),Math.abs(Math.max(ne.x,ne.y))}function Ii(t,e){const n=t.matrixWorld,i=t.geometry,s=i.attributes.instanceStart,o=i.attributes.instanceEnd,r=Math.min(i.instanceCount,s.count);for(let a=0,h=r;a<h;a++){H.start.fromBufferAttribute(s,a),H.end.fromBufferAttribute(o,a),H.applyMatrix4(n);const d=new F,l=new F;ie.distanceSqToSegment(H.start,H.end,l,d),l.distanceTo(d)<le*.5&&e.push({point:l,pointOnLine:d,distance:ie.origin.distanceTo(l),object:t,face:null,faceIndex:a,uv:null,uv1:null})}}function ji(t,e,n){const i=e.projectionMatrix,o=t.material.resolution,r=t.matrixWorld,a=t.geometry,h=a.attributes.instanceStart,d=a.attributes.instanceEnd,l=Math.min(a.instanceCount,h.count),c=-e.near;ie.at(1,te),te.w=1,te.applyMatrix4(e.matrixWorldInverse),te.applyMatrix4(i),te.multiplyScalar(1/te.w),te.x*=o.x/2,te.y*=o.y/2,te.z=0,Ve.copy(te),Je.multiplyMatrices(e.matrixWorldInverse,r);for(let u=0,p=l;u<p;u++){if(W.fromBufferAttribute(h,u),k.fromBufferAttribute(d,u),W.w=1,k.w=1,W.applyMatrix4(Je),k.applyMatrix4(Je),W.z>c&&k.z>c)continue;if(W.z>c){const y=W.z-k.z,w=(W.z-c)/y;W.lerp(k,w)}else if(k.z>c){const y=k.z-W.z,w=(k.z-c)/y;k.lerp(W,w)}W.applyMatrix4(i),k.applyMatrix4(i),W.multiplyScalar(1/W.w),k.multiplyScalar(1/k.w),W.x*=o.x/2,W.y*=o.y/2,k.x*=o.x/2,k.y*=o.y/2,H.start.copy(W),H.start.z=0,H.end.copy(k),H.end.z=0;const g=H.closestPointToPointParameter(Ve,!0);H.at(g,Gt);const f=Un.lerp(W.z,k.z,g),E=f>=-1&&f<=1,S=Ve.distanceTo(Gt)<le*.5;if(E&&S){H.start.fromBufferAttribute(h,u),H.end.fromBufferAttribute(d,u),H.start.applyMatrix4(r),H.end.applyMatrix4(r);const y=new F,w=new F;ie.distanceSqToSegment(H.start,H.end,w,y),n.push({point:w,pointOnLine:y,distance:ie.origin.distanceTo(w),object:t,face:null,faceIndex:u,uv:null,uv1:null})}}}class Gi extends re{constructor(e=new rn,n=new an({color:Math.random()*16777215})){super(e,n),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,n=e.attributes.instanceStart,i=e.attributes.instanceEnd,s=new Float32Array(2*n.count);for(let r=0,a=0,h=n.count;r<h;r++,a+=2)It.fromBufferAttribute(n,r),jt.fromBufferAttribute(i,r),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+It.distanceTo(jt);const o=new qe(s,2,1);return e.setAttribute("instanceDistanceStart",new ue(o,1,0)),e.setAttribute("instanceDistanceEnd",new ue(o,1,1)),this}raycast(e,n){const i=this.material.worldUnits,s=e.camera;s===null&&!i&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;ie=e.ray;const r=this.matrixWorld,a=this.geometry,h=this.material;le=h.linewidth+o,a.boundingSphere===null&&a.computeBoundingSphere(),ze.copy(a.boundingSphere).applyMatrix4(r);let d;if(i)d=le*.5;else{const c=Math.max(s.near,ze.distanceToPoint(ie.origin));d=Nt(s,c,h.resolution)}if(ze.radius+=d,ie.intersectsSphere(ze)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),Oe.copy(a.boundingBox).applyMatrix4(r);let l;if(i)l=le*.5;else{const c=Math.max(s.near,Oe.distanceToPoint(ie.origin));l=Nt(s,c,h.resolution)}Oe.expandByScalar(l),ie.intersectsBox(Oe)!==!1&&(i?Ii(this,n):ji(this,s,n))}}class ln extends rn{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const n=e.length-3,i=new Float32Array(2*n);for(let s=0;s<n;s+=3)i[2*s]=e[s],i[2*s+1]=e[s+1],i[2*s+2]=e[s+2],i[2*s+3]=e[s+3],i[2*s+4]=e[s+4],i[2*s+5]=e[s+5];return super.setPositions(i),this}setColors(e){const n=e.length-3,i=new Float32Array(2*n);for(let s=0;s<n;s+=3)i[2*s]=e[s],i[2*s+1]=e[s+1],i[2*s+2]=e[s+2],i[2*s+3]=e[s+3],i[2*s+4]=e[s+4],i[2*s+5]=e[s+5];return super.setColors(i),this}fromLine(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}}class Ni extends Gi{constructor(e=new ln,n=new an({color:Math.random()*16777215})){super(e,n),this.isLine2=!0,this.type="Line2"}}class ss{constructor({},e={}){this.config=Object.assign({visibelProvince:"",geoProjectionCenter:[0,0],geoProjectionScale:120,position:new F(0,0,0),data:"",material:new In({color:16777215}),type:"LineLoop",renderOrder:1,tubeRadius:.2},e);let n=ct(this.config.data),i=this.create(n);this.lineGroup=i,this.lineGroup.position.copy(this.config.position)}geoProjection(e){return dt().center(this.config.geoProjectionCenter).scale(this.config.geoProjectionScale).translate([0,0])(e)}create(e){const{type:n,visibelProvince:i}=this.config;let s=e.features,o=new ve;for(let r=0;r<s.length;r++){const a=s[r];let h=new ve;h.name="meshLineGroup"+r,a.properties.name!==i&&(a.geometry.coordinates.forEach(d=>{const l=[];let c=null;n==="Line2"?(d[0].forEach(u=>{const[p,m]=this.geoProjection(u);l.push(p,-m,0)}),c=this.createLine2(l)):n==="Line3"?(d[0].forEach(u=>{const[p,m]=this.geoProjection(u);l.push(new F(p,-m,0))}),c=this.createLine3(l)):d[0].forEach(u=>{const[p,m]=this.geoProjection(u);l.push(new F(p,-m,0)),c=this.createLine(l)}),h.add(c)}),o.add(h))}return o}createLine3(e){const n=this.config.tubeRadius,i=256*10,s=4,o=!1,{material:r,renderOrder:a}=this.config,h=new jn(e),d=new Gn(h,i,n,s,o),l=new re(d,r);return l.name="mapLine3",l.renderOrder=a,l}createLine2(e){const{material:n,renderOrder:i}=this.config,s=new ln;s.setPositions(e);let o=new Ni(s,n);return o.name="mapLine2",o.renderOrder=i,o.computeLineDistances(),o}createLine(e){const{material:n,renderOrder:i,type:s}=this.config,o=new it;o.setFromPoints(e);let r=new Nn(o,n);return r.renderOrder=i,r.name="mapLine",r}setParent(e){e.add(this.lineGroup)}}class os{constructor(e,n){this.shader=null,this.config=Object.assign({uColor1:2781042,uColor2:860197,size:15,dir:"x"},n),this.init(e)}init(e){let{uColor1:n,uColor2:i,dir:s,size:o}=this.config,r={x:1,y:2,z:3};e.onBeforeCompile=a=>{this.shader=a,a.uniforms=Z(Q({},a.uniforms),{uColor1:{value:new Ke(n)},uColor2:{value:new Ke(i)},uDir:{value:r[s]},uSize:{value:o}}),a.vertexShader=a.vertexShader.replace("void main() {",`
|
|
attribute float alpha;
|
|
varying vec3 vPosition;
|
|
varying float vAlpha;
|
|
void main() {
|
|
vAlpha = alpha;
|
|
vPosition = position;
|
|
`),a.fragmentShader=a.fragmentShader.replace("void main() {",`
|
|
varying vec3 vPosition;
|
|
varying float vAlpha;
|
|
uniform vec3 uColor1;
|
|
uniform vec3 uColor2;
|
|
uniform float uDir;
|
|
uniform float uSize;
|
|
|
|
void main() {
|
|
`),a.fragmentShader=a.fragmentShader.replace("#include <opaque_fragment>",`
|
|
#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
|
|
// https://github.com/mrdoob/three.js/pull/22425
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= transmissionAlpha + 0.1;
|
|
#endif
|
|
// vec3 gradient = mix(uColor1, uColor2, vPosition.x / 15.0);
|
|
vec3 gradient = vec3(0.0,0.0,0.0);
|
|
if(uDir==1.0){
|
|
gradient = mix(uColor1, uColor2, vPosition.x/ uSize);
|
|
}else if(uDir==2.0){
|
|
gradient = mix(uColor1, uColor2, vPosition.z/ uSize);
|
|
}else if(uDir==3.0){
|
|
gradient = mix(uColor1, uColor2, vPosition.y/ uSize);
|
|
}
|
|
outgoingLight = outgoingLight * gradient;
|
|
|
|
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );
|
|
`)}}}const rs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAK+SURBVHgB7dzNbdswGIdxSugCRtGBuklWSO17nXs/J0hHywA11AEMu3wDsLFT5WCJ5PtI/D8nQ5cA/FmxJJLqtofhHBSmPihUAoElEFgCgfVu7ODX95suqOKNXVDpDIElEFgCgSUQWAKBJRBYAoE1G2Q3DJ/j9fRjUGE7DI+f4niEGc0CMYzzKezjx7vWUQwjnMJdF8djDsq8M+QYLu/om0VJGP8OXI/LTc0C+fJhs4/fiIeLQ82hvMaI/zEevsVxCROb/RvSMkpuDCvLVVaLKCUwrGyXvS2hlMKwst6HtIBSEsPKfmO4ZpTSGFaRO/U1otTAsIo9OlkTSi0Mq+izrDWg1MSwij9cXDJKbQyrytPeJaJ4YFjVHr8vCcULw6o6H7IEFE8Mq/oEFRnFG8NymTEkohAwLLcpXBIKBcNynVMnoJAwLPdFDp4oNAwLserEA4WIYXVjK7C9Vr+fY8Gh7e8/Lhha/f5GhDMjJRBYAoElEFgCgSUQWAKBJRBYAoElEFgCgSUQWAKBJRBYAoElEFgCgSUQWAKBJRBYAoElEFgCgSUQWAKBJZDwvIIQs2kIA/K81tYvzKYhBMh/75vyCYHiDgLBSLmjuIK8xrBV6J1HoO11biCk/Rmk7XUuIMTNMhSU6iDUnUsWAaUqCBkj5Y1SDWQJGClPlCogS8JIeaEUB1kiRsoDpSjIkjFStVGKgawBI1UTpQjImjBStVCyg6wRI1UDJSvImjFSpVGygbSAkSqJkgWkJYxUKZTZIC1ipEqgzAJpGSOVG2UyiDBeyokyCWR3OOyFcd0Yyu4wfA83Ngnk2Pe/ziE82WdhvHSJYuNz7MPPcGOTQH5sNk+nPnyMf/xeGNcZSvyS3tv42DiFG0O94q+19Iq/BSQQWAKBJRBYAoElEFgCgSUQWKM3hsovnSGwBAJLILAEAusvLK6Na4P/Au0AAAAASUVORK5CYII=";var Ft=class{constructor(t,e){M(this,"target");M(this,"name");M(this,"intersected");M(this,"wasIntersected",!1);M(this,"wasIntersectedOnMouseDown",!1);M(this,"distance");this.target=t,this.name=e,this.intersected=!1,this.distance=0}},J=class{constructor(t,e=null){M(this,"type");M(this,"cancelBubble");M(this,"originalEvent");M(this,"coords",new N(0,0));M(this,"distance",0);M(this,"intersected",!1);M(this,"wasIntersected",!1);M(this,"wasIntersectedOnMouseDown",!1);this.cancelBubble=!1,this.type=t,this.originalEvent=e}stopPropagation(){this.cancelBubble=!0}},as=class{constructor(t,e,n,i){M(this,"renderer");M(this,"camera");M(this,"domElement");M(this,"bindEventsOnBodyElement");M(this,"autoAdd");M(this,"scene");M(this,"mouse");M(this,"supportsPointerEvents");M(this,"interactiveObjects");M(this,"closestObject");M(this,"raycaster");M(this,"treatTouchEventsAsMouseEvents");M(this,"dispose",()=>{this.domElement.removeEventListener("click",this.onMouseClick),this.supportsPointerEvents&&(this.bindEventsOnBodyElement?this.domElement.ownerDocument.removeEventListener("pointermove",this.onDocumentPointerMove):this.domElement.removeEventListener("pointermove",this.onDocumentPointerMove),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointerup",this.onPointerUp)),this.bindEventsOnBodyElement?this.domElement.ownerDocument.removeEventListener("mousemove",this.onDocumentMouseMove):this.domElement.removeEventListener("mousemove",this.onDocumentMouseMove),this.domElement.removeEventListener("mousedown",this.onMouseDown),this.domElement.removeEventListener("mouseup",this.onMouseUp),this.domElement.removeEventListener("touchstart",this.onTouchStart),this.domElement.removeEventListener("touchmove",this.onTouchMove),this.domElement.removeEventListener("touchend",this.onTouchEnd)});M(this,"add",(t,e=[])=>{if(t&&!this.interactiveObjects.find(n=>n.target===t))if(e.length>0)e.forEach(n=>{let i=t.getObjectByName(n);if(i){let s=new Ft(i,n);this.interactiveObjects.push(s)}});else{let n=new Ft(t,t.name);this.interactiveObjects.push(n)}});M(this,"remove",(t,e=[])=>{!t||(e.length>0?e.forEach(n=>{let i=t.getObjectByName(n);i&&(this.interactiveObjects=this.interactiveObjects.filter(s=>s.target!==i))}):this.interactiveObjects=this.interactiveObjects.filter(n=>n.target!==t))});M(this,"update",()=>{var i;this.raycaster.setFromCamera(this.mouse,this.camera),this.interactiveObjects.forEach(s=>{s.target&&this.checkIntersection(s)}),this.interactiveObjects.sort(function(s,o){return s.distance-o.distance});let t=(i=this.interactiveObjects.find(s=>s.intersected))!=null?i:null;if(t!=this.closestObject){if(this.closestObject){let s=new J("mouseout");this.dispatch(this.closestObject,s)}if(t){let s=new J("mouseover");this.dispatch(t,s)}this.closestObject=t}let e;this.interactiveObjects.forEach(s=>{!s.intersected&&s.wasIntersected&&(e||(e=new J("mouseleave")),this.dispatch(s,e))});let n;this.interactiveObjects.forEach(s=>{s.intersected&&!s.wasIntersected&&(n||(n=new J("mouseenter")),this.dispatch(s,n))})});M(this,"checkIntersection",t=>{let e=this.raycaster.intersectObjects([t.target],!0);if(t.wasIntersected=t.intersected,e.length>0){let n=e[0].distance;e.forEach(i=>{i.distance<n&&(n=i.distance)}),t.intersected=!0,t.distance=n}else t.intersected=!1});M(this,"onDocumentMouseMove",t=>{this.mapPositionToPoint(this.mouse,t.clientX,t.clientY);let e=new J("mousemove",t);this.interactiveObjects.forEach(n=>{this.dispatch(n,e)})});M(this,"onDocumentPointerMove",t=>{this.mapPositionToPoint(this.mouse,t.clientX,t.clientY);let e=new J("pointermove",t);this.interactiveObjects.forEach(n=>{this.dispatch(n,e)})});M(this,"onTouchMove",t=>{t.touches.length>0&&this.mapPositionToPoint(this.mouse,t.touches[0].clientX,t.touches[0].clientY);let e=new J(this.treatTouchEventsAsMouseEvents?"mousemove":"touchmove",t);this.interactiveObjects.forEach(n=>{this.dispatch(n,e)})});M(this,"onMouseClick",t=>{this.update();let e=new J("click",t);this.interactiveObjects.forEach(n=>{n.intersected&&this.dispatch(n,e)})});M(this,"onMouseDown",t=>{this.mapPositionToPoint(this.mouse,t.clientX,t.clientY),this.update();let e=new J("mousedown",t);this.interactiveObjects.forEach(n=>{n.intersected?(n.wasIntersectedOnMouseDown=!0,this.dispatch(n,e)):n.wasIntersectedOnMouseDown=!1})});M(this,"onPointerDown",t=>{this.mapPositionToPoint(this.mouse,t.clientX,t.clientY),this.update();let e=new J("pointerdown",t);this.interactiveObjects.forEach(n=>{n.intersected&&this.dispatch(n,e)})});M(this,"onTouchStart",t=>{t.touches.length>0&&this.mapPositionToPoint(this.mouse,t.touches[0].clientX,t.touches[0].clientY),this.update();let e=new J(this.treatTouchEventsAsMouseEvents?"mousedown":"touchstart",t);this.interactiveObjects.forEach(n=>{n.intersected&&this.dispatch(n,e)})});M(this,"onMouseUp",t=>{let e=new J("mouseup",t);this.interactiveObjects.forEach(n=>{this.dispatch(n,e)})});M(this,"onPointerUp",t=>{let e=new J("pointerup",t);this.interactiveObjects.forEach(n=>{this.dispatch(n,e)})});M(this,"onTouchEnd",t=>{t.touches.length>0&&this.mapPositionToPoint(this.mouse,t.touches[0].clientX,t.touches[0].clientY),this.update();let e=new J(this.treatTouchEventsAsMouseEvents?"mouseup":"touchend",t);this.interactiveObjects.forEach(n=>{this.dispatch(n,e)})});M(this,"dispatch",(t,e)=>{t.target&&!e.cancelBubble&&(e.coords=this.mouse,e.distance=t.distance,e.intersected=t.intersected,e.wasIntersected=t.wasIntersected,e.wasIntersectedOnMouseDown=t.wasIntersectedOnMouseDown,t.target.dispatchEvent(e))});M(this,"mapPositionToPoint",(t,e,n)=>{let i=this.renderer.domElement.getBoundingClientRect();t.x=(e-i.left)/i.width*2-1,t.y=-((n-i.top)/i.height)*2+1});this.renderer=t,this.camera=e,this.domElement=n,this.bindEventsOnBodyElement=i&&typeof i.bindEventsOnBodyElement<"u"?i.bindEventsOnBodyElement:!0,this.scene=i&&typeof i.scene<"u"?i.scene:null,this.scene&&(this.scene.onBeforeRender=()=>{this.autoAdd&&this.scene!==null&&this.scene.traverse(s=>{this.add(s),s.addEventListener("removed",o=>{this.remove(o.target)})}),this.update()}),this.autoAdd=i&&typeof i.autoAdd<"u"?i.autoAdd:!1,this.autoAdd&&this.scene===null&&console.error("Attention: Options.scene needs to be set when using options.autoAdd"),this.mouse=new N(-1,1),this.supportsPointerEvents=!!window.PointerEvent,this.interactiveObjects=[],this.closestObject=null,this.raycaster=new Fn,n.addEventListener("click",this.onMouseClick),this.supportsPointerEvents&&(this.bindEventsOnBodyElement?n.ownerDocument.addEventListener("pointermove",this.onDocumentPointerMove):n.addEventListener("pointermove",this.onDocumentPointerMove),n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointerup",this.onPointerUp)),this.bindEventsOnBodyElement?n.ownerDocument.addEventListener("mousemove",this.onDocumentMouseMove):n.addEventListener("mousemove",this.onDocumentMouseMove),n.addEventListener("mousedown",this.onMouseDown),n.addEventListener("mouseup",this.onMouseUp),n.addEventListener("touchstart",this.onTouchStart,{passive:!0}),n.addEventListener("touchmove",this.onTouchMove,{passive:!0}),n.addEventListener("touchend",this.onTouchEnd,{passive:!0}),this.treatTouchEventsAsMouseEvents=!0}};const ls=kn,cs=Hn,us=0,Ee=Kt;function hs(t){return t}function Fi(t=[],e=Kt){const n=t.map(r=>{var a,h,d;return Z(Q({},r),{name:r.name||r.label||r.town||"",count:Number((d=(h=(a=r.count)!=null?a:r.value)!=null?h:r.total)!=null?d:0)})}).filter(r=>r.name&&Number.isFinite(r.count)&&r.count>=0),i=n.reduce((r,a)=>r+a.count,0);if(!i||!e)return n.map(r=>Z(Q({},r),{count:0}));const s=n.map(r=>Z(Q({},r),{count:Math.round(r.count/i*e)})),o=e-s.reduce((r,a)=>r+a.count,0);return o&&s[0]&&(s[0].count+=o),s}const Wi=Fi(Yn,Ee).sort((t,e)=>e.count-t.count),ki=[{key:"fertileCow",name:"适龄能繁母牛",ratio:45,source:"畜群结构比例表"},{key:"meatBull",name:"麦洼公牦牛",ratio:15,source:"畜群结构比例表"},{key:"breedingBull",name:"种公牛",ratio:3,source:"畜群结构比例表"},{key:"femaleCalf",name:"母犊牛",ratio:15,source:"畜群结构比例表"},{key:"maleCalf",name:"公犊牛",ratio:15,source:"畜群结构比例表"},{key:"overageCow",name:"过龄能繁母牛",ratio:7,source:"畜群结构比例表"}],Hi=[{key:"fertileCow",name:"适龄能繁母牛",ratio:44.8,source:"畜群结构比例表"},{key:"meatBull",name:"麦洼公牦牛",ratio:15.2,source:"畜群结构比例表"},{key:"breedingBull",name:"种公牛",ratio:3.1,source:"畜群结构比例表"},{key:"femaleCalf",name:"母犊牛",ratio:14.9,source:"畜群结构比例表"},{key:"maleCalf",name:"公犊牛",ratio:15.1,source:"畜群结构比例表"},{key:"overageCow",name:"过龄能繁母牛",ratio:6.9,source:"畜群结构比例表"}],fs=hn(Hi,Ee),ds=Wn.map((t,e)=>Z(Q({},t),{color:["#48cfff","#30dcff","#8bf7ff","#48cfff"][e%4]})),ps=[{age:"≤1岁",cow:38586,bull:40861},{age:"1-2岁",cow:27124,bull:27549},{age:"2-4岁",cow:93355,bull:49265},{age:"4-8岁",cow:106679,bull:32655},{age:"8岁以上",cow:28671,bull:13485}],Wt=[{key:"2026",label:"2026年底",shortLabel:"2026",months:7,stock:462850,births:24680,outflow:19020,correction:-1040,structure:{fertileCow:45.1,meatBull:15,breedingBull:3,femaleCalf:15.2,maleCalf:14.9,overageCow:6.8}},{key:"2027",label:"2027年底",shortLabel:"2027",months:19,stock:468920,births:67420,outflow:55180,correction:-1550,structure:{fertileCow:45.5,meatBull:14.8,breedingBull:3.1,femaleCalf:15.1,maleCalf:14.8,overageCow:6.7}},{key:"2028",label:"2028年底",shortLabel:"2028",months:31,stock:475360,births:109680,outflow:90140,correction:-2410,structure:{fertileCow:45.9,meatBull:14.5,breedingBull:3.1,femaleCalf:15.3,maleCalf:14.7,overageCow:6.5}}],ms=[{name:"新生牛犊",value:86},{name:"出栏周转",value:62},{name:"死亡淘汰",value:48},{name:"母牛基础",value:91},{name:"幼畜存活",value:73}],cn=2026,un=6;function vs(t){return Wt.find(e=>e.key===t)||Wt[1]}function gs(t){const e=(t==null?void 0:t.structure)||{};return hn(ki.map(n=>{var i;return Z(Q({},n),{ratio:(i=e[n.key])!=null?i:n.ratio,source:"预测模型"})}),t.stock)}function ws(t){const e=t.stock/Ee,n=Wi.map((s,o)=>Z(Q({},s),{forecast:Math.round(s.count*e+(o%3-1)*t.months*18)})),i=t.stock-n.reduce((s,o)=>s+o.forecast,0);if(i){const s=n.reduce((o,r)=>r.count>o.count?r:o,n[0]);s.forecast+=i}return n.map(s=>Z(Q({},s),{change:s.forecast-s.count})).sort((s,o)=>o.forecast-s.forecast)}function ys(t){const e=Yi(t),n=Array.from({length:e},(r,a)=>Vi(a)),i=n.map((r,a)=>{const h=Xe(a,e),d=Math.sin(a/2.6)*Math.sin(Math.PI*h)*Math.min(360,t.months*18);return Math.round(Ee+(t.stock-Ee)*h+d)}),s=n.map((r,a)=>Math.round(t.births*Xe(a,e))),o=n.map((r,a)=>Math.round(t.outflow*Xe(a,e)));return{labels:n,stock:i,births:s,outflow:o}}function Yi(t={}){return Math.max(1,Math.round(Number(t.months||1)))}function Xe(t,e){return e<=1?1:Math.min(1,Math.max(0,t/(e-1)))}function Vi(t=0){const e=new Date(Date.UTC(cn,un-1+t,1));return`${String(e.getUTCFullYear()).slice(-2)}-${String(e.getUTCMonth()+1).padStart(2,"0")}`}function Ss(t=0){const e=new Date(Date.UTC(cn,un-1,1+t));return[String(e.getUTCFullYear()).slice(-2),String(e.getUTCMonth()+1).padStart(2,"0"),String(e.getUTCDate()).padStart(2,"0")].join("-")}function hn(t,e){const n=t.map((s,o)=>{const r=e*s.ratio/100;return Z(Q({},s),{index:o,exact:r,count:Math.floor(r),remainder:r-Math.floor(r)})});let i=e-n.reduce((s,o)=>s+o.count,0);return n.slice().sort((s,o)=>o.remainder-s.remainder||s.index-o.index).forEach(s=>{i<=0||(s.count+=1,i-=1)}),n.map(h=>{var d=h,{index:s,exact:o,remainder:r}=d,a=vt(d,["index","exact","remainder"]);return Z(Q({},a),{count:Math.round(a.count)})})}function Es(t){const e=new Map;return t.forEach(n=>{const i=n.name,s=e.get(i)||{name:i,count:0};s.count+=Number(n.count||0),e.set(i,s)}),[...e.values()].sort((n,i)=>i.count-n.count)}export{ns as B,Zi as D,is as E,os as G,es as L,Qi as M,ts as P,ss as a,$i as b,on as c,vs as d,ys as e,Wt as f,dt as g,as as h,Yi as i,Ss as j,Ee as k,rs as l,cs as m,Fi as n,Wi as o,ws as p,gs as q,ps as r,fs as s,us as t,ds as u,ms as v,hs as w,ls as x,Es as y};
|
|
|