@rr0/ufoathome 0.91.0 → 0.92.1

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img src="doc/web/ufoathome/UFOAtHome.png" align=right alt="UFO@home logo">
1
+ <img src="site/assets/logo.png" width="128" align="right" alt="UFO@home logo: a flying saucer with a play button">
2
2
 
3
3
  # UFO@home
4
4
 
@@ -0,0 +1,6 @@
1
+ const c=`(function(){"use strict";class tt{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(t){return tt.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(t,1e-12))}static fromMagPerArcsec2(t){return 10**(.4*(tt.S10_MAG_PER_ARCSEC2-t))}static latitudeOfRowCoord(t){const s=2*t-1;return 90*Math.sign(s)*s*s}static rowCoordOfLatitude(t){return(Math.sign(t)*Math.sqrt(Math.min(Math.abs(t),90)/90)+1)/2}static angleOfColumnCoord(t){return 180*t*t}static columnCoordOfAngle(t){return Math.sqrt(Math.min(Math.max(t,0),180)/180)}}class p{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(t,s){return this.radianceTowards(t,s)*p.anchor()}static anchor(){return tt.fromMagPerArcsec2(p.PEAK_MAG_PER_ARCSEC2)/p.PEAK_RADIANCE}radianceTowards(t,s){return this.trace(t,s).light}extinctionTowards(t,s){return this.trace(t,s).extinctionMag}trace(t,s){const i=t*Math.PI/180,e=s*Math.PI/180,n=-Math.cos(e)*Math.cos(i),r=Math.cos(e)*Math.sin(i),o=Math.sin(e);let h=0,a=0,c=0;const l=Math.log(p.NEAR_LIMIT_KPC),M=Math.log(p.FAR_LIMIT_KPC)-l;for(let u=0;u<p.STEPS;u++){const x=Math.exp(l+M*u/(p.STEPS-1)),m=x-c;c=x;const d=x-m/2,y=p.SUN_RADIUS_KPC+d*n,_=d*r,E=p.SUN_HEIGHT_KPC+d*o,A=Math.hypot(y,_),w=Math.exp(-(A-p.SUN_RADIUS_KPC)/p.DISK_SCALE_LENGTH_KPC-Math.abs(E)/p.DISK_SCALE_HEIGHT_KPC),S=Math.hypot(A,E/p.BULGE_FLATTENING),T=p.BULGE_TO_LOCAL_DISK*Math.exp(-S/p.BULGE_SCALE_KPC);if(h+=(w+T)*m*10**(-.4*a),a+=p.EXTINCTION_MAG_PER_KPC*Math.exp(-(A-p.SUN_RADIUS_KPC)/p.DUST_SCALE_LENGTH_KPC-(Math.abs(E)-p.SUN_HEIGHT_KPC)/p.DUST_SCALE_HEIGHT_KPC)*m,a>p.OPAQUE_MAG)break}return{light:h,extinctionMag:a}}values=new Float32Array(p.LONGITUDE_STEPS*p.LATITUDE_STEPS);walked=0;get done(){return this.walked>=p.LATITUDE_STEPS}walk(t){const s=p.LONGITUDE_STEPS,i=Math.min(p.LATITUDE_STEPS,this.walked+t);for(;this.walked<i;this.walked++){const e=tt.latitudeOfRowCoord((this.walked+.5)/p.LATITUDE_STEPS);for(let n=0;n<s;n++)this.values[this.walked*s+n]=this.radianceTowards(360*(n+.5)/s,e)}}harvest(){let t=Number.POSITIVE_INFINITY;for(const e of this.values)e<t&&(t=e);const s=p.anchor(),i=new Float32Array(this.values.length);for(let e=0;e<i.length;e++)i[e]=(this.values[e]-t)*s;return{width:p.LONGITUDE_STEPS,height:p.LATITUDE_STEPS,data:i}}}class L{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(t,s){return this.radianceTowards(t,s)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=L.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(t,s){const i=t*Math.PI/180,e=s*Math.PI/180,n=-Math.cos(e)*Math.cos(i),r=-Math.cos(e)*Math.sin(i),o=Math.sin(e),h=-n;let a=0,c=0;const l=Math.log(L.NEAR_LIMIT_AU),M=Math.log(L.FAR_LIMIT_AU)-l;for(let u=0;u<L.STEPS;u++){const x=Math.exp(l+M*u/(L.STEPS-1)),m=x-c;c=x;const d=x-m/2,y=1+d*n,_=d*r,E=d*o,A=Math.hypot(y,_,E);if(A<L.SUBLIMATION_AU)continue;const w=E/A,S=A**-1.3*Math.exp(-2.6*Math.abs(w)),T=(h-d)/A;a+=S*this.scattering(T)*m/(A*A)}return a}scattering(t){let s=0;for(let i=0;i<L.LOBE_ASYMMETRY.length;i++){const e=L.LOBE_ASYMMETRY[i],n=1+e*e-2*e*t;s+=L.LOBE_WEIGHT[i]*(1-e*e)/(4*Math.PI*n**1.5)}return s}values=new Float32Array(L.LONGITUDE_STEPS*L.LATITUDE_STEPS);walked=0;get done(){return this.walked>=L.LATITUDE_STEPS}walk(t){const s=L.LONGITUDE_STEPS,i=Math.min(L.LATITUDE_STEPS,this.walked+t);for(;this.walked<i;this.walked++){const e=tt.latitudeOfRowCoord((this.walked+.5)/L.LATITUDE_STEPS);for(let n=0;n<s;n++){const r=tt.angleOfColumnCoord((n+.5)/s);this.values[this.walked*s+n]=this.radianceTowards(r,e)}}}harvest(){const t=this.anchor();let s=Number.POSITIVE_INFINITY;for(const e of this.values)e<s&&(s=e);const i=new Float32Array(this.values.length);for(let e=0;e<i.length;e++)i[e]=(this.values[e]-s)*t;return{width:L.LONGITUDE_STEPS,height:L.LATITUDE_STEPS,data:i}}}class Et{static reflectance(t,s,i){const n=s/i*Math.sqrt(Math.max(0,1-t*t));if(n>=1)return 1;const r=Math.sqrt(Math.max(0,1-n*n)),o=(i*t-s*r)/(i*t+s*r),h=(s*t-i*r)/(s*t+i*r);return(o*o+h*h)/2}}class G{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(G.ANCHOR_BLUE-G.ANCHOR_RED)/(1/(G.BLUE_NM*G.BLUE_NM)-1/(G.RED_NM*G.RED_NM));static A=G.ANCHOR_RED-G.B/(G.RED_NM*G.RED_NM);static indexAt(t){return G.A+G.B/(t*t)}}class rt{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,s,i,e,n,r){let o=0,h=0,a=0;Math.abs(i)<.9?(o=-s,h=t,a=0):(o=0,h=-i,a=s);const c=Math.hypot(o,h,a)||1;o/=c,h/=c,a/=c;const l=s*a-i*h,M=i*o-t*a,u=t*h-s*o,x=n/2,m=r/2;for(let d=0;d<6;d++){const y=e+d*Math.PI/3,_=Math.cos(y),E=Math.sin(y);this.normals[d*3]=o*_+l*E,this.normals[d*3+1]=h*_+M*E,this.normals[d*3+2]=a*_+u*E,this.offsets[d]=x}this.normals[18]=t,this.normals[19]=s,this.normals[20]=i,this.offsets[6]=m,this.normals[21]=-t,this.normals[22]=-s,this.normals[23]=-i,this.offsets[7]=m,this.radius=Math.hypot(x,m)}get aimRadius(){return this.radius}trace(t,s,i,e,n,r,o){let h=-s,a=t,c=0,l=Math.hypot(h,a,c);l<1e-6&&(h=1,a=0,c=0,l=1),h/=l,a/=l,c/=l;const M=s*c-i*a,u=i*h-t*c,x=t*a-s*h,m=h*e+M*n-t*this.radius*2,d=a*e+u*n-s*this.radius*2,y=c*e+x*n-i*this.radius*2;let _=-1,E=-1/0,A=1/0;for(let F=0;F<8;F++){const q=this.normals[F*3],W=this.normals[F*3+1],ht=this.normals[F*3+2],v=q*t+W*s+ht*i,it=this.offsets[F]-(q*m+W*d+ht*y);if(v>1e-9){const V=it/v;V<A&&(A=V)}else if(v<-1e-9){const V=it/v;V>E&&(E=V,_=F)}else if(it<0)return 0}if(_<0||E>=A)return 0;let w=0;const S=this.normals[_*3],T=this.normals[_*3+1],b=this.normals[_*3+2],P=-(S*t+T*s+b*i),N=Et.reflectance(P,1,r);o[w].x=t+2*P*S,o[w].y=s+2*P*T,o[w].z=i+2*P*b,o[w].weight=N,w++;const R=1/r,D=Math.sqrt(Math.max(0,1-R*R*(1-P*P)));let U=R*t+(R*P-D)*S,O=R*s+(R*P-D)*T,g=R*i+(R*P-D)*b,$=m+t*E,X=d+s*E,Y=y+i*E,J=1-N;for(let F=0;F<rt.MAX_BOUNCES&&J>rt.MIN_WEIGHT;F++){let q=-1,W=1/0;for(let Z=0;Z<8;Z++){const at=this.normals[Z*3],It=this.normals[Z*3+1],Pt=this.normals[Z*3+2],Ct=at*U+It*O+Pt*g;if(Ct<=1e-9)continue;const wt=(this.offsets[Z]-(at*$+It*X+Pt*Y))/Ct;wt>1e-9&&wt<W&&(W=wt,q=Z)}if(q<0)break;const ht=this.normals[q*3],v=this.normals[q*3+1],it=this.normals[q*3+2],V=ht*U+v*O+it*g,_t=r*Math.sqrt(Math.max(0,1-V*V));if($+=U*W,X+=O*W,Y+=g*W,_t<1){const Z=Math.sqrt(Math.max(0,1-_t*_t)),at=Et.reflectance(V,r,1);if(o[w].x=r*U-(r*V-Z)*ht,o[w].y=r*O-(r*V-Z)*v,o[w].z=r*g-(r*V-Z)*it,o[w].weight=J*(1-at),w++,w>=o.length)return w;J*=at}const zt=2*V;U-=zt*ht,O-=zt*v,g-=zt*it}return w}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class B{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=B.build(24);static build(t){const s=[];let i=0,e=0,n=0;for(let r=0;r<t;r++){const o=B.VIOLET_NM+(r+.5)/t*(B.DEEP_RED_NM-B.VIOLET_NM),[h,a,c]=B.colourMatching(o),l={wavelengthNm:o,r:Math.max(0,3.2406*h-1.5372*a-.4986*c),g:Math.max(0,-.9689*h+1.8758*a+.0415*c),b:Math.max(0,.0557*h-.204*a+1.057*c)};i+=l.r,e+=l.g,n+=l.b,s.push(l)}for(const r of s)r.r/=i,r.g/=e,r.b/=n;return s}static tristimulus(t,s,i){let e=0,n=0,r=0;for(let h=0;h<t.length;h++){const[a,c,l]=B.colourMatching(t[h]);e+=a*s[h],n+=c*s[h],r+=l*s[h]}const o=683*i;return[e*o,n*o,r*o]}static scotopic(t){const s=t/1e3;return .992*Math.exp(-321.9*(s-.5)**2)}static linearSrgbOf([t,s,i]){return[3.2406*t-1.5372*s-.4986*i,-.9689*t+1.8758*s+.0415*i,.0557*t-.204*s+1.057*i]}static colourMatching(t){const s=(i,e,n)=>{const r=(t-i)/(t<i?e:n);return Math.exp(-.5*r*r)};return[1.056*s(599.8,37.9,31)+.362*s(442,16,26.7)-.065*s(501.1,20.4,26.2),.821*s(568.8,46.9,40.5)+.286*s(530.9,16.3,31.1),1.217*s(437,11.8,36)+.681*s(459,26,13.8)]}}class C{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new rt;emergent=Array.from({length:rt.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(C.AZIMUTH_BINS*C.ALTITUDE_BINS*3);radiance=new Float32Array(C.AZIMUTH_BINS*C.ALTITUDE_BINS*3);scratch=new Float32Array(C.AZIMUTH_BINS*C.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,s,i=2654435769){this.seed=i>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,s));const e=C.WORST_TILT_DEG*(C.BEST_TILT_DEG/C.WORST_TILT_DEG)**this.alignment;this.tilt=e*Math.PI/180}trace(t){const s=C.AZIMUTH_BINS,i=C.ALTITUDE_BINS,e=this.tally,n=C.SOURCE_RADIUS_DEG*Math.PI/180,r=Math.cos(C.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let h=0;h<t;h++){const a=this.pickPopulation();this.orient(a,this.tilt);const c=this.random()*2*Math.PI,l=n*Math.sqrt(this.random()),M=o+l*Math.sin(c),u=l*Math.cos(c)/Math.max(.05,Math.cos(o)),x=-Math.cos(M)*Math.cos(u),m=-Math.cos(M)*Math.sin(u),d=-Math.sin(M),y=this.crystal.aimRadius,_=(this.random()*2-1)*y,E=(this.random()*2-1)*y,A=4*y*y,w=B.SAMPLES[this.random()*B.SAMPLES.length|0],S=this.crystal.trace(x,m,d,_,E,G.indexAt(w.wavelengthNm),this.emergent);for(let T=0;T<S;T++){const b=this.emergent[T],P=Math.hypot(b.x,b.y,b.z);if(P<1e-9||b.weight<=0)continue;const N=b.x/P,R=b.y/P,D=b.z/P;if(N*x+R*m+D*d>r)continue;const U=Math.asin(Math.max(-1,Math.min(1,-D))),O=Math.abs(Math.atan2(-R,-N)),g=Math.min(s-1,O/Math.PI*s|0),X=(Math.min(i-1,(U+Math.PI/2)/Math.PI*i|0)*s+g)*3,Y=b.weight*A*B.SAMPLES.length;e[X]+=Y*w.r,e[X+1]+=Y*w.g,e[X+2]+=Y*w.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=C.AZIMUTH_BINS,s=C.ALTITUDE_BINS;return this.toRadiance(t,s),this.smooth(t,s),{width:t,height:s,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,s,i,e){return this.begin(t,s,e),this.trace(i),this.harvest()}toRadiance(t,s){const i=2*Math.PI/t,e=Math.max(1,this.traced),n=4*C.REFERENCE_MICRONS*C.REFERENCE_MICRONS;for(let r=0;r<s;r++){const o=Math.sin(r/s*Math.PI-Math.PI/2),h=Math.sin((r+1)/s*Math.PI-Math.PI/2),a=1/(i*(h-o)*e*n);for(let c=0;c<t;c++){const l=(r*t+c)*3;this.radiance[l]=this.tally[l]*a,this.radiance[l+1]=this.tally[l+1]*a,this.radiance[l+2]=this.tally[l+2]*a}}}static REFERENCE_MICRONS=50;smooth(t,s){const i=this.scratch,e=this.radiance;i.set(e);for(let r=0;r<s;r++){const o=r*t*3;for(let h=0;h<3;h++){let a=i[o+h];for(let c=0;c<t;c++){const l=o+c*3+h,M=c+1<t?i[l+3]:i[l];e[l]=(a+2*i[l]+M)/4,a=i[l]}}}i.set(e);const n=t*3;for(let r=0;r<s;r++){const o=r>0?-n:0,h=r+1<s?n:0,a=r*n;for(let c=a;c<a+n;c++)e[c]=(i[c+o]+2*i[c]+i[c+h])/4}}pickPopulation(){const t=this.random();let s=0;for(const i of C.POPULATIONS)if(s+=i.share,t<=s)return i;return C.POPULATIONS[C.POPULATIONS.length-1]}orient(t,s){const i=this.random()*2*Math.PI;let e=this.random()*2*Math.PI,n=0,r=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const h=Math.sqrt(Math.max(0,1-o*o));n=h*Math.cos(i),r=h*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(s);const h=Math.sqrt(Math.max(0,1-o*o));n=h*Math.cos(i),r=h*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(s);const h=Math.sqrt(Math.max(0,1-o*o));n=h*Math.cos(i),r=h*Math.sin(i),t.orientation==="parry"&&(e=Math.PI/2+this.gaussian()*s);break}}this.crystal.set(n,r,o,e,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const s=1/Math.max(1e-6,t*t),i=Math.max(1e-12,this.random()),e=1+Math.log(i+(1-i)*Math.exp(-2*s))/s;return Math.max(-1,Math.min(1,e))}spreadAboutAPlane(t){for(let s=0;s<8;s++){const i=this.gaussian()*t;if(i>=-1&&i<=1)return i}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),s=2*Math.PI*this.random();return this.spare=t*Math.sin(s),this.hasSpare=!0,t*Math.cos(s)}}/**
2
+ * @license
3
+ * Copyright 2010-2026 Three.js Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */const At="185",ot=2e3,Tt=2001,pt={};function Rt(f){const t=f[0];if(typeof t=="string"&&t.startsWith("TSL:")){const s=f[1];s&&s.isStackTrace?f[0]+=" "+s.getLocation():f[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return f}function ct(...f){f=Rt(f);const t="THREE."+f.shift();{const s=f[0];s&&s.isStackTrace?console.warn(s.getError(t)):console.warn(t,...f)}}function Mt(...f){const t=f.join(" ");t in pt||(pt[t]=!0,ct(...f))}function I(f,t,s){return Math.max(t,Math.min(s,f))}class St{static{St.prototype.isVector2=!0}constructor(t=0,s=0){this.x=t,this.y=s}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,s){return this.x=t,this.y=s,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,s){return this.x=t.x-s.x,this.y=t.y-s.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const s=this.x,i=this.y,e=t.elements;return this.x=e[0]*s+e[3]*i+e[6],this.y=e[1]*s+e[4]*i+e[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,s){return this.x=I(this.x,t.x,s.x),this.y=I(this.y,t.y,s.y),this}clampScalar(t,s){return this.x=I(this.x,t,s),this.y=I(this.y,t,s),this}clampLength(t,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(I(i,t,s))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const s=Math.sqrt(this.lengthSq()*t.lengthSq());if(s===0)return Math.PI/2;const i=this.dot(t)/s;return Math.acos(I(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const s=this.x-t.x,i=this.y-t.y;return s*s+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this}lerpVectors(t,s,i){return this.x=t.x+(s.x-t.x)*i,this.y=t.y+(s.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t}fromBufferAttribute(t,s){return this.x=t.getX(s),this.y=t.getY(s),this}rotateAround(t,s){const i=Math.cos(s),e=Math.sin(s),n=this.x-t.x,r=this.y-t.y;return this.x=n*i-r*e+t.x,this.y=n*e+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Lt{constructor(t=0,s=0,i=0,e=1){this.isQuaternion=!0,this._x=t,this._y=s,this._z=i,this._w=e}static slerpFlat(t,s,i,e,n,r,o){let h=i[e+0],a=i[e+1],c=i[e+2],l=i[e+3],M=n[r+0],u=n[r+1],x=n[r+2],m=n[r+3];if(l!==m||h!==M||a!==u||c!==x){let d=h*M+a*u+c*x+l*m;d<0&&(M=-M,u=-u,x=-x,m=-m,d=-d);let y=1-o;if(d<.9995){const _=Math.acos(d),E=Math.sin(_);y=Math.sin(y*_)/E,o=Math.sin(o*_)/E,h=h*y+M*o,a=a*y+u*o,c=c*y+x*o,l=l*y+m*o}else{h=h*y+M*o,a=a*y+u*o,c=c*y+x*o,l=l*y+m*o;const _=1/Math.sqrt(h*h+a*a+c*c+l*l);h*=_,a*=_,c*=_,l*=_}}t[s]=h,t[s+1]=a,t[s+2]=c,t[s+3]=l}static multiplyQuaternionsFlat(t,s,i,e,n,r){const o=i[e],h=i[e+1],a=i[e+2],c=i[e+3],l=n[r],M=n[r+1],u=n[r+2],x=n[r+3];return t[s]=o*x+c*l+h*u-a*M,t[s+1]=h*x+c*M+a*l-o*u,t[s+2]=a*x+c*u+o*M-h*l,t[s+3]=c*x-o*l-h*M-a*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,s,i,e){return this._x=t,this._y=s,this._z=i,this._w=e,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,s=!0){const i=t._x,e=t._y,n=t._z,r=t._order,o=Math.cos,h=Math.sin,a=o(i/2),c=o(e/2),l=o(n/2),M=h(i/2),u=h(e/2),x=h(n/2);switch(r){case"XYZ":this._x=M*c*l+a*u*x,this._y=a*u*l-M*c*x,this._z=a*c*x+M*u*l,this._w=a*c*l-M*u*x;break;case"YXZ":this._x=M*c*l+a*u*x,this._y=a*u*l-M*c*x,this._z=a*c*x-M*u*l,this._w=a*c*l+M*u*x;break;case"ZXY":this._x=M*c*l-a*u*x,this._y=a*u*l+M*c*x,this._z=a*c*x+M*u*l,this._w=a*c*l-M*u*x;break;case"ZYX":this._x=M*c*l-a*u*x,this._y=a*u*l+M*c*x,this._z=a*c*x-M*u*l,this._w=a*c*l+M*u*x;break;case"YZX":this._x=M*c*l+a*u*x,this._y=a*u*l+M*c*x,this._z=a*c*x-M*u*l,this._w=a*c*l-M*u*x;break;case"XZY":this._x=M*c*l-a*u*x,this._y=a*u*l-M*c*x,this._z=a*c*x+M*u*l,this._w=a*c*l+M*u*x;break;default:ct("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return s===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,s){const i=s/2,e=Math.sin(i);return this._x=t.x*e,this._y=t.y*e,this._z=t.z*e,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const s=t.elements,i=s[0],e=s[4],n=s[8],r=s[1],o=s[5],h=s[9],a=s[2],c=s[6],l=s[10],M=i+o+l;if(M>0){const u=.5/Math.sqrt(M+1);this._w=.25/u,this._x=(c-h)*u,this._y=(n-a)*u,this._z=(r-e)*u}else if(i>o&&i>l){const u=2*Math.sqrt(1+i-o-l);this._w=(c-h)/u,this._x=.25*u,this._y=(e+r)/u,this._z=(n+a)/u}else if(o>l){const u=2*Math.sqrt(1+o-i-l);this._w=(n-a)/u,this._x=(e+r)/u,this._y=.25*u,this._z=(h+c)/u}else{const u=2*Math.sqrt(1+l-i-o);this._w=(r-e)/u,this._x=(n+a)/u,this._y=(h+c)/u,this._z=.25*u}return this._onChangeCallback(),this}setFromUnitVectors(t,s){let i=t.dot(s)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*s.z-t.z*s.y,this._y=t.z*s.x-t.x*s.z,this._z=t.x*s.y-t.y*s.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(I(this.dot(t),-1,1)))}rotateTowards(t,s){const i=this.angleTo(t);if(i===0)return this;const e=Math.min(1,s/i);return this.slerp(t,e),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,s){const i=t._x,e=t._y,n=t._z,r=t._w,o=s._x,h=s._y,a=s._z,c=s._w;return this._x=i*c+r*o+e*a-n*h,this._y=e*c+r*h+n*o-i*a,this._z=n*c+r*a+i*h-e*o,this._w=r*c-i*o-e*h-n*a,this._onChangeCallback(),this}slerp(t,s){let i=t._x,e=t._y,n=t._z,r=t._w,o=this.dot(t);o<0&&(i=-i,e=-e,n=-n,r=-r,o=-o);let h=1-s;if(o<.9995){const a=Math.acos(o),c=Math.sin(a);h=Math.sin(h*a)/c,s=Math.sin(s*a)/c,this._x=this._x*h+i*s,this._y=this._y*h+e*s,this._z=this._z*h+n*s,this._w=this._w*h+r*s,this._onChangeCallback()}else this._x=this._x*h+i*s,this._y=this._y*h+e*s,this._z=this._z*h+n*s,this._w=this._w*h+r*s,this.normalize();return this}slerpQuaternions(t,s,i){return this.copy(t).slerp(s,i)}random(){const t=2*Math.PI*Math.random(),s=2*Math.PI*Math.random(),i=Math.random(),e=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(e*Math.sin(t),e*Math.cos(t),n*Math.sin(s),n*Math.cos(s))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,s=0){return this._x=t[s],this._y=t[s+1],this._z=t[s+2],this._w=t[s+3],this._onChangeCallback(),this}toArray(t=[],s=0){return t[s]=this._x,t[s+1]=this._y,t[s+2]=this._z,t[s+3]=this._w,t}fromBufferAttribute(t,s){return this._x=t.getX(s),this._y=t.getY(s),this._z=t.getZ(s),this._w=t.getW(s),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Q{static{Q.prototype.isVector3=!0}constructor(t=0,s=0,i=0){this.x=t,this.y=s,this.z=i}set(t,s,i){return i===void 0&&(i=this.z),this.x=t,this.y=s,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this.z=t.z+s.z,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,s){return this.x=t.x-s.x,this.y=t.y-s.y,this.z=t.z-s.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,s){return this.x=t.x*s.x,this.y=t.y*s.y,this.z=t.z*s.z,this}applyEuler(t){return this.applyQuaternion(ft.setFromEuler(t))}applyAxisAngle(t,s){return this.applyQuaternion(ft.setFromAxisAngle(t,s))}applyMatrix3(t){const s=this.x,i=this.y,e=this.z,n=t.elements;return this.x=n[0]*s+n[3]*i+n[6]*e,this.y=n[1]*s+n[4]*i+n[7]*e,this.z=n[2]*s+n[5]*i+n[8]*e,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const s=this.x,i=this.y,e=this.z,n=t.elements,r=1/(n[3]*s+n[7]*i+n[11]*e+n[15]);return this.x=(n[0]*s+n[4]*i+n[8]*e+n[12])*r,this.y=(n[1]*s+n[5]*i+n[9]*e+n[13])*r,this.z=(n[2]*s+n[6]*i+n[10]*e+n[14])*r,this}applyQuaternion(t){const s=this.x,i=this.y,e=this.z,n=t.x,r=t.y,o=t.z,h=t.w,a=2*(r*e-o*i),c=2*(o*s-n*e),l=2*(n*i-r*s);return this.x=s+h*a+r*l-o*c,this.y=i+h*c+o*a-n*l,this.z=e+h*l+n*c-r*a,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const s=this.x,i=this.y,e=this.z,n=t.elements;return this.x=n[0]*s+n[4]*i+n[8]*e,this.y=n[1]*s+n[5]*i+n[9]*e,this.z=n[2]*s+n[6]*i+n[10]*e,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,s){return this.x=I(this.x,t.x,s.x),this.y=I(this.y,t.y,s.y),this.z=I(this.z,t.z,s.z),this}clampScalar(t,s){return this.x=I(this.x,t,s),this.y=I(this.y,t,s),this.z=I(this.z,t,s),this}clampLength(t,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(I(i,t,s))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this.z+=(t.z-this.z)*s,this}lerpVectors(t,s,i){return this.x=t.x+(s.x-t.x)*i,this.y=t.y+(s.y-t.y)*i,this.z=t.z+(s.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,s){const i=t.x,e=t.y,n=t.z,r=s.x,o=s.y,h=s.z;return this.x=e*h-n*o,this.y=n*r-i*h,this.z=i*o-e*r,this}projectOnVector(t){const s=t.lengthSq();if(s===0)return this.set(0,0,0);const i=t.dot(this)/s;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return mt.copy(this).projectOnVector(t),this.sub(mt)}reflect(t){return this.sub(mt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const s=Math.sqrt(this.lengthSq()*t.lengthSq());if(s===0)return Math.PI/2;const i=this.dot(t)/s;return Math.acos(I(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const s=this.x-t.x,i=this.y-t.y,e=this.z-t.z;return s*s+i*i+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,s,i){const e=Math.sin(s)*t;return this.x=e*Math.sin(i),this.y=Math.cos(s)*t,this.z=e*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,s,i){return this.x=t*Math.sin(s),this.y=i,this.z=t*Math.cos(s),this}setFromMatrixPosition(t){const s=t.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this}setFromMatrixScale(t){const s=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),e=this.setFromMatrixColumn(t,2).length();return this.x=s,this.y=i,this.z=e,this}setFromMatrixColumn(t,s){return this.fromArray(t.elements,s*4)}setFromMatrix3Column(t,s){return this.fromArray(t.elements,s*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this.z=t[s+2],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t[s+2]=this.z,t}fromBufferAttribute(t,s){return this.x=t.getX(s),this.y=t.getY(s),this.z=t.getZ(s),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,s=Math.random()*2-1,i=Math.sqrt(1-s*s);return this.x=i*Math.cos(t),this.y=s,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const mt=new Q,ft=new Lt;class yt{static{yt.prototype.isMatrix3=!0}constructor(t,s,i,e,n,r,o,h,a){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,s,i,e,n,r,o,h,a)}set(t,s,i,e,n,r,o,h,a){const c=this.elements;return c[0]=t,c[1]=e,c[2]=o,c[3]=s,c[4]=n,c[5]=h,c[6]=i,c[7]=r,c[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const s=this.elements,i=t.elements;return s[0]=i[0],s[1]=i[1],s[2]=i[2],s[3]=i[3],s[4]=i[4],s[5]=i[5],s[6]=i[6],s[7]=i[7],s[8]=i[8],this}extractBasis(t,s,i){return t.setFromMatrix3Column(this,0),s.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const s=t.elements;return this.set(s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const i=t.elements,e=s.elements,n=this.elements,r=i[0],o=i[3],h=i[6],a=i[1],c=i[4],l=i[7],M=i[2],u=i[5],x=i[8],m=e[0],d=e[3],y=e[6],_=e[1],E=e[4],A=e[7],w=e[2],S=e[5],T=e[8];return n[0]=r*m+o*_+h*w,n[3]=r*d+o*E+h*S,n[6]=r*y+o*A+h*T,n[1]=a*m+c*_+l*w,n[4]=a*d+c*E+l*S,n[7]=a*y+c*A+l*T,n[2]=M*m+u*_+x*w,n[5]=M*d+u*E+x*S,n[8]=M*y+u*A+x*T,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[3]*=t,s[6]*=t,s[1]*=t,s[4]*=t,s[7]*=t,s[2]*=t,s[5]*=t,s[8]*=t,this}determinant(){const t=this.elements,s=t[0],i=t[1],e=t[2],n=t[3],r=t[4],o=t[5],h=t[6],a=t[7],c=t[8];return s*r*c-s*o*a-i*n*c+i*o*h+e*n*a-e*r*h}invert(){const t=this.elements,s=t[0],i=t[1],e=t[2],n=t[3],r=t[4],o=t[5],h=t[6],a=t[7],c=t[8],l=c*r-o*a,M=o*h-c*n,u=a*n-r*h,x=s*l+i*M+e*u;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/x;return t[0]=l*m,t[1]=(e*a-c*i)*m,t[2]=(o*i-e*r)*m,t[3]=M*m,t[4]=(c*s-e*h)*m,t[5]=(e*n-o*s)*m,t[6]=u*m,t[7]=(i*h-a*s)*m,t[8]=(r*s-i*n)*m,this}transpose(){let t;const s=this.elements;return t=s[1],s[1]=s[3],s[3]=t,t=s[2],s[2]=s[6],s[6]=t,t=s[5],s[5]=s[7],s[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const s=this.elements;return t[0]=s[0],t[1]=s[3],t[2]=s[6],t[3]=s[1],t[4]=s[4],t[5]=s[7],t[6]=s[2],t[7]=s[5],t[8]=s[8],this}setUvTransform(t,s,i,e,n,r,o){const h=Math.cos(n),a=Math.sin(n);return this.set(i*h,i*a,-i*(h*r+a*o)+r+t,-e*a,e*h,-e*(-a*r+h*o)+o+s,0,0,1),this}scale(t,s){return Mt("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(dt.makeScale(t,s)),this}rotate(t){return Mt("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(dt.makeRotation(-t)),this}translate(t,s){return Mt("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(dt.makeTranslation(t,s)),this}makeTranslation(t,s){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,s,0,0,1),this}makeRotation(t){const s=Math.cos(t),i=Math.sin(t);return this.set(s,-i,0,i,s,0,0,0,1),this}makeScale(t,s){return this.set(t,0,0,0,s,0,0,0,1),this}equals(t){const s=this.elements,i=t.elements;for(let e=0;e<9;e++)if(s[e]!==i[e])return!1;return!0}fromArray(t,s=0){for(let i=0;i<9;i++)this.elements[i]=t[i+s];return this}toArray(t=[],s=0){const i=this.elements;return t[s]=i[0],t[s+1]=i[1],t[s+2]=i[2],t[s+3]=i[3],t[s+4]=i[4],t[s+5]=i[5],t[s+6]=i[6],t[s+7]=i[7],t[s+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const dt=new yt;class gt{static{gt.prototype.isVector4=!0}constructor(t=0,s=0,i=0,e=1){this.x=t,this.y=s,this.z=i,this.w=e}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,s,i,e){return this.x=t,this.y=s,this.z=i,this.w=e,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;case 3:this.w=s;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this.z=t.z+s.z,this.w=t.w+s.w,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,this.w+=t.w*s,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,s){return this.x=t.x-s.x,this.y=t.y-s.y,this.z=t.z-s.z,this.w=t.w-s.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const s=this.x,i=this.y,e=this.z,n=this.w,r=t.elements;return this.x=r[0]*s+r[4]*i+r[8]*e+r[12]*n,this.y=r[1]*s+r[5]*i+r[9]*e+r[13]*n,this.z=r[2]*s+r[6]*i+r[10]*e+r[14]*n,this.w=r[3]*s+r[7]*i+r[11]*e+r[15]*n,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const s=Math.sqrt(1-t.w*t.w);return s<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/s,this.y=t.y/s,this.z=t.z/s),this}setAxisAngleFromRotationMatrix(t){let s,i,e,n;const h=t.elements,a=h[0],c=h[4],l=h[8],M=h[1],u=h[5],x=h[9],m=h[2],d=h[6],y=h[10];if(Math.abs(c-M)<.01&&Math.abs(l-m)<.01&&Math.abs(x-d)<.01){if(Math.abs(c+M)<.1&&Math.abs(l+m)<.1&&Math.abs(x+d)<.1&&Math.abs(a+u+y-3)<.1)return this.set(1,0,0,0),this;s=Math.PI;const E=(a+1)/2,A=(u+1)/2,w=(y+1)/2,S=(c+M)/4,T=(l+m)/4,b=(x+d)/4;return E>A&&E>w?E<.01?(i=0,e=.707106781,n=.707106781):(i=Math.sqrt(E),e=S/i,n=T/i):A>w?A<.01?(i=.707106781,e=0,n=.707106781):(e=Math.sqrt(A),i=S/e,n=b/e):w<.01?(i=.707106781,e=.707106781,n=0):(n=Math.sqrt(w),i=T/n,e=b/n),this.set(i,e,n,s),this}let _=Math.sqrt((d-x)*(d-x)+(l-m)*(l-m)+(M-c)*(M-c));return Math.abs(_)<.001&&(_=1),this.x=(d-x)/_,this.y=(l-m)/_,this.z=(M-c)/_,this.w=Math.acos((a+u+y-1)/2),this}setFromMatrixPosition(t){const s=t.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this.w=s[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,s){return this.x=I(this.x,t.x,s.x),this.y=I(this.y,t.y,s.y),this.z=I(this.z,t.z,s.z),this.w=I(this.w,t.w,s.w),this}clampScalar(t,s){return this.x=I(this.x,t,s),this.y=I(this.y,t,s),this.z=I(this.z,t,s),this.w=I(this.w,t,s),this}clampLength(t,s){const i=this.length();return this.divideScalar(i||1).multiplyScalar(I(i,t,s))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this.z+=(t.z-this.z)*s,this.w+=(t.w-this.w)*s,this}lerpVectors(t,s,i){return this.x=t.x+(s.x-t.x)*i,this.y=t.y+(s.y-t.y)*i,this.z=t.z+(s.z-t.z)*i,this.w=t.w+(s.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this.z=t[s+2],this.w=t[s+3],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t[s+2]=this.z,t[s+3]=this.w,t}fromBufferAttribute(t,s){return this.x=t.getX(s),this.y=t.getY(s),this.z=t.getZ(s),this.w=t.getW(s),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class lt{static{lt.prototype.isMatrix4=!0}constructor(t,s,i,e,n,r,o,h,a,c,l,M,u,x,m,d){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,s,i,e,n,r,o,h,a,c,l,M,u,x,m,d)}set(t,s,i,e,n,r,o,h,a,c,l,M,u,x,m,d){const y=this.elements;return y[0]=t,y[4]=s,y[8]=i,y[12]=e,y[1]=n,y[5]=r,y[9]=o,y[13]=h,y[2]=a,y[6]=c,y[10]=l,y[14]=M,y[3]=u,y[7]=x,y[11]=m,y[15]=d,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new lt().fromArray(this.elements)}copy(t){const s=this.elements,i=t.elements;return s[0]=i[0],s[1]=i[1],s[2]=i[2],s[3]=i[3],s[4]=i[4],s[5]=i[5],s[6]=i[6],s[7]=i[7],s[8]=i[8],s[9]=i[9],s[10]=i[10],s[11]=i[11],s[12]=i[12],s[13]=i[13],s[14]=i[14],s[15]=i[15],this}copyPosition(t){const s=this.elements,i=t.elements;return s[12]=i[12],s[13]=i[13],s[14]=i[14],this}setFromMatrix3(t){const s=t.elements;return this.set(s[0],s[3],s[6],0,s[1],s[4],s[7],0,s[2],s[5],s[8],0,0,0,0,1),this}extractBasis(t,s,i){return this.determinantAffine()===0?(t.set(1,0,0),s.set(0,1,0),i.set(0,0,1),this):(t.setFromMatrixColumn(this,0),s.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(t,s,i){return this.set(t.x,s.x,i.x,0,t.y,s.y,i.y,0,t.z,s.z,i.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const s=this.elements,i=t.elements,e=1/et.setFromMatrixColumn(t,0).length(),n=1/et.setFromMatrixColumn(t,1).length(),r=1/et.setFromMatrixColumn(t,2).length();return s[0]=i[0]*e,s[1]=i[1]*e,s[2]=i[2]*e,s[3]=0,s[4]=i[4]*n,s[5]=i[5]*n,s[6]=i[6]*n,s[7]=0,s[8]=i[8]*r,s[9]=i[9]*r,s[10]=i[10]*r,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromEuler(t){const s=this.elements,i=t.x,e=t.y,n=t.z,r=Math.cos(i),o=Math.sin(i),h=Math.cos(e),a=Math.sin(e),c=Math.cos(n),l=Math.sin(n);if(t.order==="XYZ"){const M=r*c,u=r*l,x=o*c,m=o*l;s[0]=h*c,s[4]=-h*l,s[8]=a,s[1]=u+x*a,s[5]=M-m*a,s[9]=-o*h,s[2]=m-M*a,s[6]=x+u*a,s[10]=r*h}else if(t.order==="YXZ"){const M=h*c,u=h*l,x=a*c,m=a*l;s[0]=M+m*o,s[4]=x*o-u,s[8]=r*a,s[1]=r*l,s[5]=r*c,s[9]=-o,s[2]=u*o-x,s[6]=m+M*o,s[10]=r*h}else if(t.order==="ZXY"){const M=h*c,u=h*l,x=a*c,m=a*l;s[0]=M-m*o,s[4]=-r*l,s[8]=x+u*o,s[1]=u+x*o,s[5]=r*c,s[9]=m-M*o,s[2]=-r*a,s[6]=o,s[10]=r*h}else if(t.order==="ZYX"){const M=r*c,u=r*l,x=o*c,m=o*l;s[0]=h*c,s[4]=x*a-u,s[8]=M*a+m,s[1]=h*l,s[5]=m*a+M,s[9]=u*a-x,s[2]=-a,s[6]=o*h,s[10]=r*h}else if(t.order==="YZX"){const M=r*h,u=r*a,x=o*h,m=o*a;s[0]=h*c,s[4]=m-M*l,s[8]=x*l+u,s[1]=l,s[5]=r*c,s[9]=-o*c,s[2]=-a*c,s[6]=u*l+x,s[10]=M-m*l}else if(t.order==="XZY"){const M=r*h,u=r*a,x=o*h,m=o*a;s[0]=h*c,s[4]=-l,s[8]=a*c,s[1]=M*l+m,s[5]=r*c,s[9]=u*l-x,s[2]=x*l-u,s[6]=o*c,s[10]=m*l+M}return s[3]=0,s[7]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ut,t,Dt)}lookAt(t,s,i){const e=this.elements;return H.subVectors(t,s),H.lengthSq()===0&&(H.z=1),H.normalize(),j.crossVectors(i,H),j.lengthSq()===0&&(Math.abs(i.z)===1?H.x+=1e-4:H.z+=1e-4,H.normalize(),j.crossVectors(i,H)),j.normalize(),ut.crossVectors(H,j),e[0]=j.x,e[4]=ut.x,e[8]=H.x,e[1]=j.y,e[5]=ut.y,e[9]=H.y,e[2]=j.z,e[6]=ut.z,e[10]=H.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const i=t.elements,e=s.elements,n=this.elements,r=i[0],o=i[4],h=i[8],a=i[12],c=i[1],l=i[5],M=i[9],u=i[13],x=i[2],m=i[6],d=i[10],y=i[14],_=i[3],E=i[7],A=i[11],w=i[15],S=e[0],T=e[4],b=e[8],P=e[12],N=e[1],R=e[5],D=e[9],U=e[13],O=e[2],g=e[6],$=e[10],X=e[14],Y=e[3],J=e[7],F=e[11],q=e[15];return n[0]=r*S+o*N+h*O+a*Y,n[4]=r*T+o*R+h*g+a*J,n[8]=r*b+o*D+h*$+a*F,n[12]=r*P+o*U+h*X+a*q,n[1]=c*S+l*N+M*O+u*Y,n[5]=c*T+l*R+M*g+u*J,n[9]=c*b+l*D+M*$+u*F,n[13]=c*P+l*U+M*X+u*q,n[2]=x*S+m*N+d*O+y*Y,n[6]=x*T+m*R+d*g+y*J,n[10]=x*b+m*D+d*$+y*F,n[14]=x*P+m*U+d*X+y*q,n[3]=_*S+E*N+A*O+w*Y,n[7]=_*T+E*R+A*g+w*J,n[11]=_*b+E*D+A*$+w*F,n[15]=_*P+E*U+A*X+w*q,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[4]*=t,s[8]*=t,s[12]*=t,s[1]*=t,s[5]*=t,s[9]*=t,s[13]*=t,s[2]*=t,s[6]*=t,s[10]*=t,s[14]*=t,s[3]*=t,s[7]*=t,s[11]*=t,s[15]*=t,this}determinant(){const t=this.elements,s=t[0],i=t[4],e=t[8],n=t[12],r=t[1],o=t[5],h=t[9],a=t[13],c=t[2],l=t[6],M=t[10],u=t[14],x=t[3],m=t[7],d=t[11],y=t[15],_=h*u-a*M,E=o*u-a*l,A=o*M-h*l,w=r*u-a*c,S=r*M-h*c,T=r*l-o*c;return s*(m*_-d*E+y*A)-i*(x*_-d*w+y*S)+e*(x*E-m*w+y*T)-n*(x*A-m*S+d*T)}determinantAffine(){const t=this.elements,s=t[0],i=t[4],e=t[8],n=t[1],r=t[5],o=t[9],h=t[2],a=t[6],c=t[10];return s*(r*c-o*a)-i*(n*c-o*h)+e*(n*a-r*h)}transpose(){const t=this.elements;let s;return s=t[1],t[1]=t[4],t[4]=s,s=t[2],t[2]=t[8],t[8]=s,s=t[6],t[6]=t[9],t[9]=s,s=t[3],t[3]=t[12],t[12]=s,s=t[7],t[7]=t[13],t[13]=s,s=t[11],t[11]=t[14],t[14]=s,this}setPosition(t,s,i){const e=this.elements;return t.isVector3?(e[12]=t.x,e[13]=t.y,e[14]=t.z):(e[12]=t,e[13]=s,e[14]=i),this}invert(){const t=this.elements,s=t[0],i=t[1],e=t[2],n=t[3],r=t[4],o=t[5],h=t[6],a=t[7],c=t[8],l=t[9],M=t[10],u=t[11],x=t[12],m=t[13],d=t[14],y=t[15],_=s*o-i*r,E=s*h-e*r,A=s*a-n*r,w=i*h-e*o,S=i*a-n*o,T=e*a-n*h,b=c*m-l*x,P=c*d-M*x,N=c*y-u*x,R=l*d-M*m,D=l*y-u*m,U=M*y-u*d,O=_*U-E*D+A*R+w*N-S*P+T*b;if(O===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const g=1/O;return t[0]=(o*U-h*D+a*R)*g,t[1]=(e*D-i*U-n*R)*g,t[2]=(m*T-d*S+y*w)*g,t[3]=(M*S-l*T-u*w)*g,t[4]=(h*N-r*U-a*P)*g,t[5]=(s*U-e*N+n*P)*g,t[6]=(d*A-x*T-y*E)*g,t[7]=(c*T-M*A+u*E)*g,t[8]=(r*D-o*N+a*b)*g,t[9]=(i*N-s*D-n*b)*g,t[10]=(x*S-m*A+y*_)*g,t[11]=(l*A-c*S-u*_)*g,t[12]=(o*P-r*R-h*b)*g,t[13]=(s*R-i*P+e*b)*g,t[14]=(m*E-x*w-d*_)*g,t[15]=(c*w-l*E+M*_)*g,this}scale(t){const s=this.elements,i=t.x,e=t.y,n=t.z;return s[0]*=i,s[4]*=e,s[8]*=n,s[1]*=i,s[5]*=e,s[9]*=n,s[2]*=i,s[6]*=e,s[10]*=n,s[3]*=i,s[7]*=e,s[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,s=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],e=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(s,i,e))}makeTranslation(t,s,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,s,0,0,1,i,0,0,0,1),this}makeRotationX(t){const s=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,s,-i,0,0,i,s,0,0,0,0,1),this}makeRotationY(t){const s=Math.cos(t),i=Math.sin(t);return this.set(s,0,i,0,0,1,0,0,-i,0,s,0,0,0,0,1),this}makeRotationZ(t){const s=Math.cos(t),i=Math.sin(t);return this.set(s,-i,0,0,i,s,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,s){const i=Math.cos(s),e=Math.sin(s),n=1-i,r=t.x,o=t.y,h=t.z,a=n*r,c=n*o;return this.set(a*r+i,a*o-e*h,a*h+e*o,0,a*o+e*h,c*o+i,c*h-e*r,0,a*h-e*o,c*h+e*r,n*h*h+i,0,0,0,0,1),this}makeScale(t,s,i){return this.set(t,0,0,0,0,s,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,s,i,e,n,r){return this.set(1,i,n,0,t,1,r,0,s,e,1,0,0,0,0,1),this}compose(t,s,i){const e=this.elements,n=s._x,r=s._y,o=s._z,h=s._w,a=n+n,c=r+r,l=o+o,M=n*a,u=n*c,x=n*l,m=r*c,d=r*l,y=o*l,_=h*a,E=h*c,A=h*l,w=i.x,S=i.y,T=i.z;return e[0]=(1-(m+y))*w,e[1]=(u+A)*w,e[2]=(x-E)*w,e[3]=0,e[4]=(u-A)*S,e[5]=(1-(M+y))*S,e[6]=(d+_)*S,e[7]=0,e[8]=(x+E)*T,e[9]=(d-_)*T,e[10]=(1-(M+m))*T,e[11]=0,e[12]=t.x,e[13]=t.y,e[14]=t.z,e[15]=1,this}decompose(t,s,i){const e=this.elements;t.x=e[12],t.y=e[13],t.z=e[14];const n=this.determinantAffine();if(n===0)return i.set(1,1,1),s.identity(),this;let r=et.set(e[0],e[1],e[2]).length();const o=et.set(e[4],e[5],e[6]).length(),h=et.set(e[8],e[9],e[10]).length();n<0&&(r=-r),K.copy(this);const a=1/r,c=1/o,l=1/h;return K.elements[0]*=a,K.elements[1]*=a,K.elements[2]*=a,K.elements[4]*=c,K.elements[5]*=c,K.elements[6]*=c,K.elements[8]*=l,K.elements[9]*=l,K.elements[10]*=l,s.setFromRotationMatrix(K),i.x=r,i.y=o,i.z=h,this}makePerspective(t,s,i,e,n,r,o=ot,h=!1){const a=this.elements,c=2*n/(s-t),l=2*n/(i-e),M=(s+t)/(s-t),u=(i+e)/(i-e);let x,m;if(h)x=n/(r-n),m=r*n/(r-n);else if(o===ot)x=-(r+n)/(r-n),m=-2*r*n/(r-n);else if(o===Tt)x=-r/(r-n),m=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return a[0]=c,a[4]=0,a[8]=M,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=x,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,s,i,e,n,r,o=ot,h=!1){const a=this.elements,c=2/(s-t),l=2/(i-e),M=-(s+t)/(s-t),u=-(i+e)/(i-e);let x,m;if(h)x=1/(r-n),m=r/(r-n);else if(o===ot)x=-2/(r-n),m=-(r+n)/(r-n);else if(o===Tt)x=-1/(r-n),m=-n/(r-n);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return a[0]=c,a[4]=0,a[8]=0,a[12]=M,a[1]=0,a[5]=l,a[9]=0,a[13]=u,a[2]=0,a[6]=0,a[10]=x,a[14]=m,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(t){const s=this.elements,i=t.elements;for(let e=0;e<16;e++)if(s[e]!==i[e])return!1;return!0}fromArray(t,s=0){for(let i=0;i<16;i++)this.elements[i]=t[i+s];return this}toArray(t=[],s=0){const i=this.elements;return t[s]=i[0],t[s+1]=i[1],t[s+2]=i[2],t[s+3]=i[3],t[s+4]=i[4],t[s+5]=i[5],t[s+6]=i[6],t[s+7]=i[7],t[s+8]=i[8],t[s+9]=i[9],t[s+10]=i[10],t[s+11]=i[11],t[s+12]=i[12],t[s+13]=i[13],t[s+14]=i[14],t[s+15]=i[15],t}}const et=new Q,K=new lt,Ut=new Q(0,0,0),Dt=new Q(1,1,1),j=new Q,ut=new Q,H=new Q,k=Nt();function Nt(){const f=new ArrayBuffer(4),t=new Float32Array(f),s=new Uint32Array(f),i=new Uint32Array(512),e=new Uint32Array(512);for(let h=0;h<256;++h){const a=h-127;a<-27?(i[h]=0,i[h|256]=32768,e[h]=24,e[h|256]=24):a<-14?(i[h]=1024>>-a-14,i[h|256]=1024>>-a-14|32768,e[h]=-a-1,e[h|256]=-a-1):a<=15?(i[h]=a+15<<10,i[h|256]=a+15<<10|32768,e[h]=13,e[h|256]=13):a<128?(i[h]=31744,i[h|256]=64512,e[h]=24,e[h|256]=24):(i[h]=31744,i[h|256]=64512,e[h]=13,e[h|256]=13)}const n=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let h=1;h<1024;++h){let a=h<<13,c=0;for(;(a&8388608)===0;)a<<=1,c-=8388608;a&=-8388609,c+=947912704,n[h]=a|c}for(let h=1024;h<2048;++h)n[h]=939524096+(h-1024<<13);for(let h=1;h<31;++h)r[h]=h<<23;r[31]=1199570944,r[32]=2147483648;for(let h=33;h<63;++h)r[h]=2147483648+(h-32<<23);r[63]=3347054592;for(let h=1;h<64;++h)h!==32&&(o[h]=1024);return{floatView:t,uint32View:s,baseTable:i,shiftTable:e,mantissaTable:n,exponentTable:r,offsetTable:o}}function Ot(f){Math.abs(f)>65504&&ct("DataUtils.toHalfFloat(): Value out of range."),f=I(f,-65504,65504),k.floatView[0]=f;const t=k.uint32View[0],s=t>>23&511;return k.baseTable[s]+((t&8388607)>>k.shiftTable[s])}function Ft(f){const t=f>>10;return k.uint32View[0]=k.mantissaTable[k.offsetTable[t]+(f&1023)]+k.exponentTable[t],k.floatView[0]}class nt{static toHalfFloat(t){return Ot(t)}static fromHalfFloat(t){return Ft(t)}}class bt{static{bt.prototype.isMatrix2=!0}constructor(t,s,i,e){this.elements=[1,0,0,1],t!==void 0&&this.set(t,s,i,e)}identity(){return this.set(1,0,0,1),this}fromArray(t,s=0){for(let i=0;i<4;i++)this.elements[i]=t[i+s];return this}set(t,s,i,e){const n=this.elements;return n[0]=t,n[2]=s,n[1]=i,n[3]=e,this}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:At}})),typeof window<"u"&&(window.__THREE__?ct("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=At);class z{static get NANOLAMBERTS_PER_S10(){return z.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(t){return t*z.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(t,s)=>{const i=-4-s;return{sunAltitudeDeg:i,magPerArcsec2:z.patatV(i)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(t){const s=90-t-95;return 11.84+1.518*s-.057*s*s}static moonlessMagPerArcsec2(t){const s=z.TWILIGHT;for(let i=0;i<s.length-1;i++){const e=s[i],n=s[i+1];if(t<=e.sunAltitudeDeg&&t>=n.sunAltitudeDeg){const r=(e.sunAltitudeDeg-t)/(e.sunAltitudeDeg-n.sunAltitudeDeg);return e.magPerArcsec2+(n.magPerArcsec2-e.magPerArcsec2)*r}}return t>0?s[0].magPerArcsec2:s[s.length-1].magPerArcsec2}static toNanolamberts(t){return 34.08*Math.exp(z.NANOLAMBERT_OFFSET-z.PER_MAGNITUDE*t)}static fromNanolamberts(t){return(z.NANOLAMBERT_OFFSET-Math.log(Math.max(t,1e-6)/34.08))/z.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(t){const s=Math.cos(Math.max(t,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*s*s,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(t){const s=Math.min(Math.max(t,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(s)**2)+10**(6.15-Math.min(t,180)/40)}static scatteredFraction(t){return 1-10**(-.4*z.EXTINCTION_PER_AIR_MASS*z.airMass(t))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(t){return Math.max(0,z.toNanolamberts(z.moonlessMagPerArcsec2(t))-z.toNanolamberts(z.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(t){const s=z.scatteringAt(90-t)*z.scatteredFraction(90);return z.twilightExcessNanolamberts(t)/s}static moonNanolamberts(t,s,i,e){return z.scatteringAt(i)*z.moonOutput(t,s)*z.scatteredFraction(e)}static moonOutput(t,s){if(s<=0)return 0;const i=Math.min(Math.abs(t),180);return 10**(-.4*(3.84+.026*i+4e-9*i**4))*10**(-.4*z.EXTINCTION_PER_AIR_MASS*z.airMass(s))}static phaseAngleOf(t){return Math.acos(Math.min(Math.max(2*t-1,-1),1))*180/Math.PI}static magPerArcsec2(t,s,i,e){const n=z.scatteredFraction(i),r=z.scatteringAt(t.separationDeg)*z.twilightOutput(t.altitudeDeg)*n,o=z.scatteringAt(s.separationDeg)*z.moonOutput(s.phaseAngleDeg,s.altitudeDeg)*n;return z.fromNanolamberts(z.toNanolamberts(z.AIRGLOW_MAG_PER_ARCSEC2)+r+o+z.artificialNanolamberts(e,i))}static artificialZenithNanolamberts(t){return t===void 0||!Number.isFinite(t)?0:Math.max(0,z.toNanolamberts(t)-z.toNanolamberts(z.AIRGLOW_MAG_PER_ARCSEC2))}static artificialNanolamberts(t,s){const i=z.artificialZenithNanolamberts(t);return i>0?i*z.artificialShape(s):0}static artificialShape(t){return z.scatteredFraction(t)/z.scatteredFraction(90)}static nakedEyeLimit(t){return 7.93-5*Math.log10(10**(4.316-t/5)+1)}static starLossMagnitudes(t,s,i){const e=z.moonlessMagPerArcsec2(t),n=z.fromNanolamberts(z.toNanolamberts(e)+z.scatteringAt(90-s.altitudeDeg)*z.moonOutput(s.phaseAngleDeg,s.altitudeDeg)*z.scatteredFraction(90)+z.artificialZenithNanolamberts(i));return Math.max(0,z.nakedEyeLimit(e)-z.nakedEyeLimit(n))}}class xt{static HALF_FLOAT_MAX=65504;static fromMap(t,s){const i=nt.toHalfFloat(1);for(let e=0;e<t.data.length;e++)s[e*4]=nt.toHalfFloat(Math.min(xt.HALF_FLOAT_MAX,z.nanolambertsOfS10(t.data[e]))),s[e*4+3]=i}}class Gt{static fromRadiance(t,s){const i=nt.toHalfFloat(1);for(let e=0,n=0;n<t.length;e+=4,n+=3)s[e]=nt.toHalfFloat(t[n]),s[e+1]=nt.toHalfFloat(t[n+1]),s[e+2]=nt.toHalfFloat(t[n+2]),s[e+3]=i}}class st{constructor(t){this.scope=t,t.onmessage=s=>this.receive(s.data)}static RAYS_PER_BATCH=6e4;static ROWS_PER_BATCH=4;sky=new C;cancelled=new Set;queue=[];working=!1;receive(t){if(t.type==="cancel"){this.cancelled.add(t.id);return}this.queue.push(t),this.working||this.work()}async work(){this.working=!0;try{for(let t=this.queue.shift();t;t=this.queue.shift())t.type==="halo"?await this.traceHalo(t):await this.walkGlow(t.id)}finally{this.working=!1}}static yield(){return new Promise(t=>setTimeout(t))}async traceHalo(t){for(this.sky.begin(t.altitudeDeg,t.alignment);this.sky.tracedRays<t.rays&&!this.cancelled.has(t.id);)this.sky.trace(Math.min(st.RAYS_PER_BATCH,t.rays-this.sky.tracedRays)),await st.yield();if(this.cancelled.delete(t.id))return;const s=this.sky.harvest(),i=new Uint16Array(C.AZIMUTH_BINS*C.ALTITUDE_BINS*4);Gt.fromRadiance(s.data,i);const e={id:t.id,texels:i};this.scope.postMessage(e,[i.buffer])}async walkGlow(t){const s=new p,i=new L;for(;!(s.done&&i.done)&&!this.cancelled.has(t);)s.walk(st.ROWS_PER_BATCH),i.walk(st.ROWS_PER_BATCH),await st.yield();if(this.cancelled.delete(t))return;const e=new Uint16Array(p.LONGITUDE_STEPS*p.LATITUDE_STEPS*4),n=new Uint16Array(L.LONGITUDE_STEPS*L.LATITUDE_STEPS*4);xt.fromMap(s.harvest(),e),xt.fromMap(i.harvest(),n);const r={id:t,milkyWay:e,zodiacal:n};this.scope.postMessage(r,[e.buffer,n.buffer])}}"WorkerGlobalScope"in globalThis&&new st(globalThis)})();
6
+ `,o=typeof self<"u"&&self.Blob&&new Blob([c],{type:"text/javascript;charset=utf-8"});function l(n){let t;try{if(t=o&&(self.URL||self.webkitURL).createObjectURL(o),!t)throw"";const s=new Worker(t,{name:n?.name});return s.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),s}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(c),{name:n?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}class h{static MAX_WORKERS=3;static shared;static get(){if(h.shared!==void 0)return h.shared;try{h.shared=typeof Worker>"u"?null:new h}catch{h.shared=null}return h.shared}workers=[];waiting=[];jobs=new Map;nextId=1;constructor(){const t=typeof navigator>"u"?2:navigator.hardwareConcurrency||2,s=Math.max(1,Math.min(h.MAX_WORKERS,t-1));for(let i=0;i<s;i++){const e=new l,r={worker:e};e.onmessage=a=>this.finish(r,a.data),e.onerror=()=>this.fail(r),this.workers.push(r)}}trace(t,s,i,e,r){return this.submit({type:"halo",altitudeDeg:t,alignment:s,rays:i},a=>e(a.texels),r)}glow(t,s){return this.submit({type:"glow"},i=>{const e=i;t(e.milkyWay,e.zodiacal)},s)}submit(t,s,i){const e={id:this.nextId++,request:t,done:s,failed:i};return this.jobs.set(e.id,e),this.workers.length===0?(queueMicrotask(()=>{this.jobs.delete(e.id)&&i()}),{cancel:()=>this.jobs.delete(e.id)&&void 0}):(this.waiting.push(e),this.dispatch(),{cancel:()=>this.cancel(e)})}dispatch(){for(const t of this.workers){if(t.running)continue;const s=this.waiting.shift();if(!s)return;t.running=s,s.worker=t;const i={...s.request,id:s.id};t.worker.postMessage(i)}}cancel(t){if(!this.jobs.delete(t.id))return;const s=this.waiting.indexOf(t);if(s>=0){this.waiting.splice(s,1);return}const i={type:"cancel",id:t.id};t.worker?.worker.postMessage(i),t.worker&&(t.worker.running=void 0),this.dispatch()}finish(t,s){const i=this.jobs.get(s.id);t.running?.id===s.id&&(t.running=void 0),i&&(this.jobs.delete(i.id),i.done(s)),this.dispatch()}fail(t){t.worker.terminate(),this.workers.splice(this.workers.indexOf(t),1);const s=t.running;if(t.running=void 0,s&&this.jobs.delete(s.id)&&s.failed(),this.workers.length===0){h.shared=null;for(const i of this.waiting.splice(0))this.jobs.delete(i.id)&&i.failed()}else this.dispatch()}}export{h as OffThreadTracer};