@rr0/ufoathome 0.63.0 → 0.63.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.
@@ -604,11 +604,11 @@ input[type=range] {
604
604
  * @license
605
605
  * Copyright 2010-2026 Three.js Authors
606
606
  * SPDX-License-Identifier: MIT
607
- */const Xu="185",C1=0,s0=1,I1=2,Ia=1,P1=2,ba=3,Ss=0,Ct=1,ai=2,Ci=0,zr=1,Gn=2,r0=3,a0=4,L1=5,Os=100,N1=101,O1=102,U1=103,F1=104,k1=200,z1=201,B1=202,H1=203,_h=204,yh=205,G1=206,V1=207,W1=208,X1=209,q1=210,Y1=211,K1=212,$1=213,Z1=214,Sh=0,bh=1,Eh=2,Yr=3,wh=4,Ah=5,Th=6,Rh=7,qu=0,J1=1,j1=2,Ii=0,Qp=1,em=2,tm=3,nm=4,im=5,sm=6,rm=7,o0="attached",Q1="detached",am=300,qs=301,Kr=302,il=303,sl=304,Gc=306,Wa=1e3,An=1001,Dh=1002,Tt=1003,e2=1004,uo=1005,dt=1006,rl=1007,Bs=1008,Hn=1009,om=1010,cm=1011,Xa=1012,Yu=1013,li=1014,Tn=1015,cn=1016,Ku=1017,$u=1018,qa=1020,lm=35902,hm=35899,um=1021,dm=1022,_n=1023,Zi=1026,Hs=1027,Vc=1028,Zu=1029,Ys=1030,Ju=1031,ju=1033,cc=33776,lc=33777,hc=33778,uc=33779,Ch=35840,Ih=35841,Ph=35842,Lh=35843,Nh=36196,Oh=37492,Uh=37496,Fh=37488,kh=37489,xc=37490,zh=37491,Bh=37808,Hh=37809,Gh=37810,Vh=37811,Wh=37812,Xh=37813,qh=37814,Yh=37815,Kh=37816,$h=37817,Zh=37818,Jh=37819,jh=37820,Qh=37821,eu=36492,tu=36494,nu=36495,iu=36283,su=36284,_c=36285,ru=36286,yc=2300,au=2301,al=2302,c0=2303,l0=2400,h0=2401,u0=2402,t2=2500,PE=0,LE=1,NE=2,n2=3200,Sc=0,i2=1,vs="",Ln="srgb",bc="srgb-linear",Ec="linear",lt="srgb",sr=7680,d0=519,s2=512,r2=513,a2=514,Qu=515,o2=516,c2=517,ed=518,l2=519,ou=35044,wc="300 es",Ri=2e3,Ya=2001;function h2(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function u2(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ka(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function d2(){const s=Ka("canvas");return s.style.display="block",s}const f0={};function Ac(...s){const e="THREE."+s.shift();console.log(e,...s)}function fm(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function we(...s){s=fm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ke(...s){s=fm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Br(...s){const e=s.join(" ");e in f0||(f0[e]=!0,we(...s))}function f2(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const p2={[Sh]:bh,[Eh]:Th,[wh]:Rh,[Yr]:Ah,[bh]:Sh,[Th]:Eh,[Rh]:wh,[Ah]:Yr};class Js{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const gn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let p0=1234567;const Pa=Math.PI/180,$r=180/Math.PI;function ci(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(gn[s&255]+gn[s>>8&255]+gn[s>>16&255]+gn[s>>24&255]+"-"+gn[e&255]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[t&63|128]+gn[t>>8&255]+"-"+gn[t>>16&255]+gn[t>>24&255]+gn[n&255]+gn[n>>8&255]+gn[n>>16&255]+gn[n>>24&255]).toLowerCase()}function Je(s,e,t){return Math.max(e,Math.min(t,s))}function td(s,e){return(s%e+e)%e}function m2(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function g2(s,e,t){return s!==e?(t-s)/(e-s):0}function La(s,e,t){return(1-t)*s+t*e}function v2(s,e,t,n){return La(s,e,1-Math.exp(-t*n))}function M2(s,e=1){return e-Math.abs(td(s,e*2)-e)}function x2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function _2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function y2(s,e){return s+Math.floor(Math.random()*(e-s+1))}function S2(s,e){return s+Math.random()*(e-s)}function b2(s){return s*(.5-Math.random())}function E2(s){s!==void 0&&(p0=s);let e=p0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function w2(s){return s*Pa}function A2(s){return s*$r}function T2(s){return(s&s-1)===0&&s!==0}function R2(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function D2(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function C2(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),p=a((n-e)/2);switch(i){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*p,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*p,o*l);break;case"ZYZ":s.set(c*p,c*f,o*h,o*l);break;default:we("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function oi(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ht(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const OE={DEG2RAD:Pa,RAD2DEG:$r,generateUUID:ci,clamp:Je,euclideanModulo:td,mapLinear:m2,inverseLerp:g2,lerp:La,damp:v2,pingpong:M2,smoothstep:x2,smootherstep:_2,randInt:y2,randFloat:S2,randFloatSpread:b2,seededRandom:E2,degToRad:w2,radToDeg:A2,isPowerOfTwo:T2,ceilPowerOfTwo:R2,floorPowerOfTwo:D2,setQuaternionFromProperEuler:C2,normalize:ht,denormalize:oi};class Ae{static{Ae.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Es{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3],d=r[a+0],f=r[a+1],p=r[a+2],v=r[a+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const S=Math.acos(m),b=Math.sin(S);g=Math.sin(g*S)/b,o=Math.sin(o*S)/b,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const S=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=S,l*=S,h*=S,u*=S}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+h*u+c*f-l*d,e[t+1]=c*p+h*d+l*u-o*f,e[t+2]=l*p+h*f+o*d-c*u,e[t+3]=h*p-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/2),p=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:we("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{static{C.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(m0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(m0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),h=2*(o*t-r*i),u=2*(r*n-a*t);return this.x=t+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=i+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ol.copy(this).projectOnVector(e),this.sub(ol)}reflect(e){return this.sub(ol.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ol=new C,m0=new Es;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,i,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,c,l)}set(e,t,n,i,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],v=i[0],m=i[3],g=i[6],S=i[1],b=i[4],_=i[7],E=i[2],w=i[5],R=i[8];return r[0]=a*v+o*S+c*E,r[3]=a*m+o*b+c*w,r[6]=a*g+o*_+c*R,r[1]=l*v+h*S+u*E,r[4]=l*m+h*b+u*w,r[7]=l*g+h*_+u*R,r[2]=d*v+f*S+p*E,r[5]=d*m+f*b+p*w,r[8]=d*g+f*_+p*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+i*r*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,p=t*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return e[0]=u*v,e[1]=(i*l-h*n)*v,e[2]=(o*n-i*a)*v,e[3]=d*v,e[4]=(h*t-i*c)*v,e[5]=(i*r-o*t)*v,e[6]=f*v,e[7]=(n*c-l*t)*v,e[8]=(a*t-n*r)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Br("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(cl.makeScale(e,t)),this}rotate(e){return Br("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(cl.makeRotation(-e)),this}translate(e,t){return Br("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(cl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const cl=new ze,g0=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),v0=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function I2(){const s={enabled:!0,workingColorSpace:bc,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===lt&&(i.r=Ki(i.r),i.g=Ki(i.g),i.b=Ki(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===lt&&(i.r=Hr(i.r),i.g=Hr(i.g),i.b=Hr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===vs?Ec:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return Br("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return Br("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[bc]:{primaries:e,whitePoint:n,transfer:Ec,toXYZ:g0,fromXYZ:v0,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ln},outputColorSpaceConfig:{drawingBufferColorSpace:Ln}},[Ln]:{primaries:e,whitePoint:n,transfer:lt,toXYZ:g0,fromXYZ:v0,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ln}}}),s}const et=I2();function Ki(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Hr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let rr;class P2{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{rr===void 0&&(rr=Ka("canvas")),rr.width=e.width,rr.height=e.height;const i=rr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=rr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ka("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Ki(r[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Ki(t[n]/255)*255):t[n]=Ki(t[n]);return{data:t,width:e.width,height:e.height}}else return we("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let L2=0;class nd{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:L2++}),this.uuid=ci(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(ll(i[a].image)):r.push(ll(i[a]))}else r=ll(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function ll(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?P2.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(we("Texture: Unable to serialize Texture."),{})}let N2=0;const hl=new C;class on extends Js{constructor(e=on.DEFAULT_IMAGE,t=on.DEFAULT_MAPPING,n=An,i=An,r=dt,a=Bs,o=_n,c=Hn,l=on.DEFAULT_ANISOTROPY,h=vs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:N2++}),this.uuid=ci(),this.name="",this.source=new nd(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ae(0,0),this.repeat=new Ae(1,1),this.center=new Ae(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(hl).x}get height(){return this.source.getSize(hl).y}get depth(){return this.source.getSize(hl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){we(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){we(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==am)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Wa:e.x=e.x-Math.floor(e.x);break;case An:e.x=e.x<0?0:1;break;case Dh:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Wa:e.y=e.y-Math.floor(e.y);break;case An:e.y=e.y<0?0:1;break;case Dh:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}on.DEFAULT_IMAGE=null;on.DEFAULT_MAPPING=am;on.DEFAULT_ANISOTROPY=1;class nt{static{nt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,_=(f+1)/2,E=(g+1)/2,w=(h+d)/4,R=(u+v)/4,M=(p+m)/4;return b>_&&b>E?b<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(b),i=w/n,r=R/n):_>E?_<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(_),n=w/i,r=M/i):E<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(E),n=R/r,i=M/r),this.set(n,i,r,t),this}let S=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(S)<.001&&(S=1),this.x=(m-p)/S,this.y=(u-v)/S,this.z=(d-h)/S,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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 O2 extends Js{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:dt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new nt(0,0,e,t),this.scissorTest=!1,this.viewport=new nt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},r=new on(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:dt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new nd(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class dn extends O2{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class pm extends on{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Tt,this.minFilter=Tt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mm extends on{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Tt,this.minFilter=Tt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ye{static{Ye.prototype.isMatrix4=!0}constructor(e,t,n,i,r,a,o,c,l,h,u,d,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,c,l,h,u,d,f,p,v,m)}set(e,t,n,i,r,a,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,g[15]=m,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 Ye().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,i=1/ar.setFromMatrixColumn(e,0).length(),r=1/ar.setFromMatrixColumn(e,1).length(),a=1/ar.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,f=a*u,p=o*h,v=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+p*l,t[5]=d-v*l,t[9]=-o*c,t[2]=v-d*l,t[6]=p+f*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d+v*o,t[4]=p*o-f,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-p,t[6]=v+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d-v*o,t[4]=-a*u,t[8]=p+f*o,t[1]=f+p*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,p=o*h,v=o*u;t[0]=c*h,t[4]=p*l-f,t[8]=d*l+v,t[1]=c*u,t[5]=v*l+d,t[9]=f*l-p,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*l,p=o*c,v=o*l;t[0]=c*h,t[4]=v-d*u,t[8]=p*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+p,t[10]=d-v*u}else if(e.order==="XZY"){const d=a*c,f=a*l,p=o*c,v=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+v,t[5]=a*h,t[9]=f*u-p,t[2]=p*u-f,t[6]=o*h,t[10]=v*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(U2,e,F2)}lookAt(e,t,n){const i=this.elements;return Un.subVectors(e,t),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),ss.crossVectors(n,Un),ss.lengthSq()===0&&(Math.abs(n.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),ss.crossVectors(n,Un)),ss.normalize(),fo.crossVectors(Un,ss),i[0]=ss.x,i[4]=fo.x,i[8]=Un.x,i[1]=ss.y,i[5]=fo.y,i[9]=Un.y,i[2]=ss.z,i[6]=fo.z,i[10]=Un.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],v=n[6],m=n[10],g=n[14],S=n[3],b=n[7],_=n[11],E=n[15],w=i[0],R=i[4],M=i[8],A=i[12],I=i[1],D=i[5],P=i[9],F=i[13],H=i[2],O=i[6],V=i[10],z=i[14],Y=i[3],ee=i[7],J=i[11],ne=i[15];return r[0]=a*w+o*I+c*H+l*Y,r[4]=a*R+o*D+c*O+l*ee,r[8]=a*M+o*P+c*V+l*J,r[12]=a*A+o*F+c*z+l*ne,r[1]=h*w+u*I+d*H+f*Y,r[5]=h*R+u*D+d*O+f*ee,r[9]=h*M+u*P+d*V+f*J,r[13]=h*A+u*F+d*z+f*ne,r[2]=p*w+v*I+m*H+g*Y,r[6]=p*R+v*D+m*O+g*ee,r[10]=p*M+v*P+m*V+g*J,r[14]=p*A+v*F+m*z+g*ne,r[3]=S*w+b*I+_*H+E*Y,r[7]=S*R+b*D+_*O+E*ee,r[11]=S*M+b*P+_*V+E*J,r[15]=S*A+b*F+_*z+E*ne,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],S=c*f-l*d,b=o*f-l*u,_=o*d-c*u,E=a*f-l*h,w=a*d-c*h,R=a*u-o*h;return t*(v*S-m*b+g*_)-n*(p*S-m*E+g*w)+i*(p*b-v*E+g*R)-r*(p*_-v*w+m*R)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+i*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],S=t*o-n*a,b=t*c-i*a,_=t*l-r*a,E=n*c-i*o,w=n*l-r*o,R=i*l-r*c,M=h*v-u*p,A=h*m-d*p,I=h*g-f*p,D=u*m-d*v,P=u*g-f*v,F=d*g-f*m,H=S*F-b*P+_*D+E*I-w*A+R*M;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/H;return e[0]=(o*F-c*P+l*D)*O,e[1]=(i*P-n*F-r*D)*O,e[2]=(v*R-m*w+g*E)*O,e[3]=(d*w-u*R-f*E)*O,e[4]=(c*I-a*F-l*A)*O,e[5]=(t*F-i*I+r*A)*O,e[6]=(m*_-p*R-g*b)*O,e[7]=(h*R-d*_+f*b)*O,e[8]=(a*P-o*I+l*M)*O,e[9]=(n*I-t*P-r*M)*O,e[10]=(p*w-v*_+g*S)*O,e[11]=(u*_-h*w-f*S)*O,e[12]=(o*A-a*D-c*M)*O,e[13]=(t*D-n*A+i*M)*O,e[14]=(v*b-p*E-m*S)*O,e[15]=(h*E-u*b+d*S)*O,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,p=r*u,v=a*h,m=a*u,g=o*u,S=c*l,b=c*h,_=c*u,E=n.x,w=n.y,R=n.z;return i[0]=(1-(v+g))*E,i[1]=(f+_)*E,i[2]=(p-b)*E,i[3]=0,i[4]=(f-_)*w,i[5]=(1-(d+g))*w,i[6]=(m+S)*w,i[7]=0,i[8]=(p+b)*R,i[9]=(m-S)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=ar.set(i[0],i[1],i[2]).length();const o=ar.set(i[4],i[5],i[6]).length(),c=ar.set(i[8],i[9],i[10]).length();r<0&&(a=-a),Qn.copy(this);const l=1/a,h=1/o,u=1/c;return Qn.elements[0]*=l,Qn.elements[1]*=l,Qn.elements[2]*=l,Qn.elements[4]*=h,Qn.elements[5]*=h,Qn.elements[6]*=h,Qn.elements[8]*=u,Qn.elements[9]*=u,Qn.elements[10]*=u,t.setFromRotationMatrix(Qn),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,i,r,a,o=Ri,c=!1){const l=this.elements,h=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i);let p,v;if(c)p=r/(a-r),v=a*r/(a-r);else if(o===Ri)p=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Ya)p=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,a,o=Ri,c=!1){const l=this.elements,h=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i);let p,v;if(c)p=1/(a-r),v=a/(a-r);else if(o===Ri)p=-2/(a-r),v=-(a+r)/(a-r);else if(o===Ya)p=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const ar=new C,Qn=new Ye,U2=new C(0,0,0),F2=new C(1,1,1),ss=new C,fo=new C,Un=new C,M0=new Ye,x0=new Es;class Ji{constructor(e=0,t=0,n=0,i=Ji.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Je(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Je(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:we("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return M0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(M0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return x0.setFromEuler(this),this.setFromQuaternion(x0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ji.DEFAULT_ORDER="XYZ";class id{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let k2=0;const _0=new C,or=new Es,Ni=new Ye,po=new C,ia=new C,z2=new C,B2=new Es,y0=new C(1,0,0),S0=new C(0,1,0),b0=new C(0,0,1),E0={type:"added"},H2={type:"removed"},cr={type:"childadded",child:null},ul={type:"childremoved",child:null};class bt extends Js{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:k2++}),this.uuid=ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=bt.DEFAULT_UP.clone();const e=new C,t=new Ji,n=new Es,i=new C(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ye},normalMatrix:{value:new ze}}),this.matrix=new Ye,this.matrixWorld=new Ye,this.matrixAutoUpdate=bt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new id,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.multiply(or),this}rotateOnWorldAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.premultiply(or),this}rotateX(e){return this.rotateOnAxis(y0,e)}rotateY(e){return this.rotateOnAxis(S0,e)}rotateZ(e){return this.rotateOnAxis(b0,e)}translateOnAxis(e,t){return _0.copy(e).applyQuaternion(this.quaternion),this.position.add(_0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(y0,e)}translateY(e){return this.translateOnAxis(S0,e)}translateZ(e){return this.translateOnAxis(b0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ni.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?po.copy(e):po.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),ia.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ni.lookAt(ia,po,this.up):Ni.lookAt(po,ia,this.up),this.quaternion.setFromRotationMatrix(Ni),i&&(Ni.extractRotation(i.matrixWorld),or.setFromRotationMatrix(Ni),this.quaternion.premultiply(or.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ke("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(E0),cr.child=e,this.dispatchEvent(cr),cr.child=null):ke("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(H2),ul.child=e,this.dispatchEvent(ul),ul.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ni.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ni.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ni),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(E0),cr.child=e,this.dispatchEvent(cr),cr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ia,e,z2),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ia,B2,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),p=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}bt.DEFAULT_UP=new C(0,1,0);bt.DEFAULT_MATRIX_AUTO_UPDATE=!0;bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class rn extends bt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const G2={type:"move"};class dl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new rn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new rn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new rn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,n),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(G2)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new rn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const gm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},rs={h:0,s:0,l:0},mo={h:0,s:0,l:0};function fl(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ln){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,et.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=et.workingColorSpace){return this.r=e,this.g=t,this.b=n,et.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=et.workingColorSpace){if(e=td(e,1),t=Je(t,0,1),n=Je(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=fl(a,r,e+1/3),this.g=fl(a,r,e),this.b=fl(a,r,e-1/3)}return et.colorSpaceToWorking(this,i),this}setStyle(e,t=Ln){function n(r){r!==void 0&&parseFloat(r)<1&&we("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:we("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);we("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ln){const n=gm[e.toLowerCase()];return n!==void 0?this.setHex(n,t):we("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ki(e.r),this.g=Ki(e.g),this.b=Ki(e.b),this}copyLinearToSRGB(e){return this.r=Hr(e.r),this.g=Hr(e.g),this.b=Hr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ln){return et.workingToColorSpace(vn.copy(this),e),Math.round(Je(vn.r*255,0,255))*65536+Math.round(Je(vn.g*255,0,255))*256+Math.round(Je(vn.b*255,0,255))}getHexString(e=Ln){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.workingToColorSpace(vn.copy(this),t);const n=vn.r,i=vn.g,r=vn.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=et.workingColorSpace){return et.workingToColorSpace(vn.copy(this),t),e.r=vn.r,e.g=vn.g,e.b=vn.b,e}getStyle(e=Ln){et.workingToColorSpace(vn.copy(this),e);const t=vn.r,n=vn.g,i=vn.b;return e!==Ln?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(rs),this.setHSL(rs.h+e,rs.s+t,rs.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(rs),e.getHSL(mo);const n=La(rs.h,mo.h,t),i=La(rs.s,mo.s,t),r=La(rs.l,mo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const vn=new oe;oe.NAMES=gm;class Tc{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=n}clone(){return new Tc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Zr extends bt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ji,this.environmentIntensity=1,this.environmentRotation=new Ji,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const ei=new C,Oi=new C,pl=new C,Ui=new C,lr=new C,hr=new C,w0=new C,ml=new C,gl=new C,vl=new C,Ml=new nt,xl=new nt,_l=new nt;class Zn{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ei.subVectors(e,t),i.cross(ei);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){ei.subVectors(i,t),Oi.subVectors(n,t),pl.subVectors(e,t);const a=ei.dot(ei),o=ei.dot(Oi),c=ei.dot(pl),l=Oi.dot(Oi),h=Oi.dot(pl),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(a*h-o*c)*d;return r.set(1-f-p,p,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ui)===null?!1:Ui.x>=0&&Ui.y>=0&&Ui.x+Ui.y<=1}static getInterpolation(e,t,n,i,r,a,o,c){return this.getBarycoord(e,t,n,i,Ui)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Ui.x),c.addScaledVector(a,Ui.y),c.addScaledVector(o,Ui.z),c)}static getInterpolatedAttribute(e,t,n,i,r,a){return Ml.setScalar(0),xl.setScalar(0),_l.setScalar(0),Ml.fromBufferAttribute(e,t),xl.fromBufferAttribute(e,n),_l.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(Ml,r.x),a.addScaledVector(xl,r.y),a.addScaledVector(_l,r.z),a}static isFrontFacing(e,t,n,i){return ei.subVectors(n,t),Oi.subVectors(e,t),ei.cross(Oi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ei.subVectors(this.c,this.b),Oi.subVectors(this.a,this.b),ei.cross(Oi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;lr.subVectors(i,n),hr.subVectors(r,n),ml.subVectors(e,n);const c=lr.dot(ml),l=hr.dot(ml);if(c<=0&&l<=0)return t.copy(n);gl.subVectors(e,i);const h=lr.dot(gl),u=hr.dot(gl);if(h>=0&&u<=h)return t.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(lr,a);vl.subVectors(e,r);const f=lr.dot(vl),p=hr.dot(vl);if(p>=0&&f<=p)return t.copy(r);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(hr,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return w0.subVectors(r,i),o=(u-h)/(u-h+(f-p)),t.copy(i).addScaledVector(w0,o);const g=1/(m+v+d);return a=v*g,o=d*g,t.copy(n).addScaledVector(lr,a).addScaledVector(hr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class hi{constructor(e=new C(1/0,1/0,1/0),t=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(ti.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(ti.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=ti.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,ti):ti.fromBufferAttribute(r,a),ti.applyMatrix4(e.matrixWorld),this.expandByPoint(ti);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),go.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),go.copy(n.boundingBox)),go.applyMatrix4(e.matrixWorld),this.union(go)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ti),ti.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(sa),vo.subVectors(this.max,sa),ur.subVectors(e.a,sa),dr.subVectors(e.b,sa),fr.subVectors(e.c,sa),as.subVectors(dr,ur),os.subVectors(fr,dr),Ts.subVectors(ur,fr);let t=[0,-as.z,as.y,0,-os.z,os.y,0,-Ts.z,Ts.y,as.z,0,-as.x,os.z,0,-os.x,Ts.z,0,-Ts.x,-as.y,as.x,0,-os.y,os.x,0,-Ts.y,Ts.x,0];return!yl(t,ur,dr,fr,vo)||(t=[1,0,0,0,1,0,0,0,1],!yl(t,ur,dr,fr,vo))?!1:(Mo.crossVectors(as,os),t=[Mo.x,Mo.y,Mo.z],yl(t,ur,dr,fr,vo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ti).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ti).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Fi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Fi=[new C,new C,new C,new C,new C,new C,new C,new C],ti=new C,go=new hi,ur=new C,dr=new C,fr=new C,as=new C,os=new C,Ts=new C,sa=new C,vo=new C,Mo=new C,Rs=new C;function yl(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){Rs.fromArray(s,r);const o=i.x*Math.abs(Rs.x)+i.y*Math.abs(Rs.y)+i.z*Math.abs(Rs.z),c=e.dot(Rs),l=t.dot(Rs),h=n.dot(Rs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Wi=V2();function V2(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function W2(s){Math.abs(s)>65504&&we("DataUtils.toHalfFloat(): Value out of range."),s=Je(s,-65504,65504),Wi.floatView[0]=s;const e=Wi.uint32View[0],t=e>>23&511;return Wi.baseTable[t]+((e&8388607)>>Wi.shiftTable[t])}function X2(s){const e=s>>10;return Wi.uint32View[0]=Wi.mantissaTable[Wi.offsetTable[e]+(s&1023)]+Wi.exponentTable[e],Wi.floatView[0]}class $i{static toHalfFloat(e){return W2(e)}static fromHalfFloat(e){return X2(e)}}const Xt=new C,xo=new Ae;let q2=0;class rt extends Js{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:q2++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ou,this.updateRanges=[],this.gpuType=Tn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xo.fromBufferAttribute(this,t),xo.applyMatrix3(e),this.setXY(t,xo.x,xo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix3(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix4(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.applyNormalMatrix(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.transformDirection(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=oi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=oi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=oi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=oi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=oi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ou&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class vm extends rt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class sd extends rt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class It extends rt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Y2=new hi,ra=new C,Sl=new C;class ji{constructor(e=new C,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Y2.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ra.subVectors(e,this.center);const t=ra.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(ra,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Sl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ra.copy(e.center).add(Sl)),this.expandByPoint(ra.copy(e.center).sub(Sl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let K2=0;const Xn=new Ye,bl=new bt,pr=new C,Fn=new hi,aa=new hi,Jt=new C;class yt extends Js{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:K2++}),this.uuid=ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(h2(e)?sd:vm)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Xn.makeRotationFromQuaternion(e),this.applyMatrix4(Xn),this}rotateX(e){return Xn.makeRotationX(e),this.applyMatrix4(Xn),this}rotateY(e){return Xn.makeRotationY(e),this.applyMatrix4(Xn),this}rotateZ(e){return Xn.makeRotationZ(e),this.applyMatrix4(Xn),this}translate(e,t,n){return Xn.makeTranslation(e,t,n),this.applyMatrix4(Xn),this}scale(e,t,n){return Xn.makeScale(e,t,n),this.applyMatrix4(Xn),this}lookAt(e){return bl.lookAt(e),bl.updateMatrix(),this.applyMatrix4(bl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pr).negate(),this.translate(pr.x,pr.y,pr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new It(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&we("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new hi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];Fn.setFromBufferAttribute(r),this.morphTargetsRelative?(Jt.addVectors(this.boundingBox.min,Fn.min),this.boundingBox.expandByPoint(Jt),Jt.addVectors(this.boundingBox.max,Fn.max),this.boundingBox.expandByPoint(Jt)):(this.boundingBox.expandByPoint(Fn.min),this.boundingBox.expandByPoint(Fn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ke('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ji);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(e){const n=this.boundingSphere.center;if(Fn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];aa.setFromBufferAttribute(o),this.morphTargetsRelative?(Jt.addVectors(Fn.min,aa.min),Fn.expandByPoint(Jt),Jt.addVectors(Fn.max,aa.max),Fn.expandByPoint(Jt)):(Fn.expandByPoint(aa.min),Fn.expandByPoint(aa.max))}Fn.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)Jt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Jt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Jt.fromBufferAttribute(o,l),c&&(pr.fromBufferAttribute(e,l),Jt.add(pr)),i=Math.max(i,n.distanceToSquared(Jt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ke('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new rt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let M=0;M<n.count;M++)o[M]=new C,c[M]=new C;const l=new C,h=new C,u=new C,d=new Ae,f=new Ae,p=new Ae,v=new C,m=new C;function g(M,A,I){l.fromBufferAttribute(n,M),h.fromBufferAttribute(n,A),u.fromBufferAttribute(n,I),d.fromBufferAttribute(r,M),f.fromBufferAttribute(r,A),p.fromBufferAttribute(r,I),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const D=1/(f.x*p.y-p.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(D),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(D),o[M].add(v),o[A].add(v),o[I].add(v),c[M].add(m),c[A].add(m),c[I].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let M=0,A=S.length;M<A;++M){const I=S[M],D=I.start,P=I.count;for(let F=D,H=D+P;F<H;F+=3)g(e.getX(F+0),e.getX(F+1),e.getX(F+2))}const b=new C,_=new C,E=new C,w=new C;function R(M){E.fromBufferAttribute(i,M),w.copy(E);const A=o[M];b.copy(A),b.sub(E.multiplyScalar(E.dot(A))).normalize(),_.crossVectors(w,A);const D=_.dot(c[M])<0?-1:1;a.setXYZW(M,b.x,b.y,b.z,D)}for(let M=0,A=S.length;M<A;++M){const I=S[M],D=I.start,P=I.count;for(let F=D,H=D+P;F<H;F+=3)R(e.getX(F+0)),R(e.getX(F+1)),R(e.getX(F+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new rt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new C,r=new C,a=new C,o=new C,c=new C,l=new C,h=new C,u=new C;if(e)for(let d=0,f=e.count;d<f;d+=3){const p=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,p),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),o.fromBufferAttribute(n,p),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Jt.fromBufferAttribute(e,t),Jt.normalize(),e.setXYZ(t,Jt.x,Jt.y,Jt.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new rt(d,h,u)}if(this.index===null)return we("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new yt,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=e(c,n);t.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,n);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(i[c]=h,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $2{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ou,this.updateRanges=[],this.version=0,this.uuid=ci()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const yn=new C;class Rc{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.applyMatrix4(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.applyNormalMatrix(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.transformDirection(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=oi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=oi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=oi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=oi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=oi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ac("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new rt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Rc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ac("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Z2=0;class Qi extends Js{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Z2++}),this.uuid=ci(),this.name="",this.type="Material",this.blending=zr,this.side=Ss,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_h,this.blendDst=yh,this.blendEquation=Os,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oe(0,0,0),this.blendAlpha=0,this.depthFunc=Yr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=d0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=sr,this.stencilZFail=sr,this.stencilZPass=sr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){we(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){we(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==zr&&(n.blending=this.blending),this.side!==Ss&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==_h&&(n.blendSrc=this.blendSrc),this.blendDst!==yh&&(n.blendDst=this.blendDst),this.blendEquation!==Os&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Yr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==d0&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==sr&&(n.stencilFail=this.stencilFail),this.stencilZFail!==sr&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==sr&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new oe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ae().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ae().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ea extends Qi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let mr;const oa=new C,gr=new C,vr=new C,Mr=new Ae,ca=new Ae,Mm=new Ye,_o=new C,la=new C,yo=new C,A0=new Ae,El=new Ae,T0=new Ae;class xr extends bt{constructor(e=new Ea){if(super(),this.isSprite=!0,this.type="Sprite",mr===void 0){mr=new yt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new $2(t,5);mr.setIndex([0,1,2,0,2,3]),mr.setAttribute("position",new Rc(n,3,0,!1)),mr.setAttribute("uv",new Rc(n,2,3,!1))}this.geometry=mr,this.material=e,this.center=new Ae(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ke('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),gr.setFromMatrixScale(this.matrixWorld),Mm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),vr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&gr.multiplyScalar(-vr.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;So(_o.set(-.5,-.5,0),vr,a,gr,i,r),So(la.set(.5,-.5,0),vr,a,gr,i,r),So(yo.set(.5,.5,0),vr,a,gr,i,r),A0.set(0,0),El.set(1,0),T0.set(1,1);let o=e.ray.intersectTriangle(_o,la,yo,!1,oa);if(o===null&&(So(la.set(-.5,.5,0),vr,a,gr,i,r),El.set(0,1),o=e.ray.intersectTriangle(_o,yo,la,!1,oa),o===null))return;const c=e.ray.origin.distanceTo(oa);c<e.near||c>e.far||t.push({distance:c,point:oa.clone(),uv:Zn.getInterpolation(oa,_o,la,yo,A0,El,T0,new Ae),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function So(s,e,t,n,i,r){Mr.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(ca.x=r*Mr.x-i*Mr.y,ca.y=i*Mr.x+r*Mr.y):ca.copy(Mr),s.copy(e),s.x+=ca.x,s.y+=ca.y,s.applyMatrix4(Mm)}const ki=new C,wl=new C,bo=new C,cs=new C,Al=new C,Eo=new C,Tl=new C;class Za{constructor(e=new C,t=new C(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ki.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ki.copy(this.origin).addScaledVector(this.direction,t),ki.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){wl.copy(e).add(t).multiplyScalar(.5),bo.copy(t).sub(e).normalize(),cs.copy(this.origin).sub(wl);const r=e.distanceTo(t)*.5,a=-this.direction.dot(bo),o=cs.dot(this.direction),c=-cs.dot(bo),l=cs.lengthSq(),h=Math.abs(1-a*a);let u,d,f,p;if(h>0)if(u=a*c-o,d=a*o-c,p=r*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(wl).addScaledVector(bo,d),f}intersectSphere(e,t){ki.subVectors(e.center,this.origin);const n=ki.dot(this.direction),i=ki.dot(ki)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ki)!==null}intersectTriangle(e,t,n,i,r){Al.subVectors(t,e),Eo.subVectors(n,e),Tl.crossVectors(Al,Eo);let a=this.direction.dot(Tl),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;cs.subVectors(this.origin,e);const c=o*this.direction.dot(Eo.crossVectors(cs,Eo));if(c<0)return null;const l=o*this.direction.dot(Al.cross(cs));if(l<0||c+l>a)return null;const h=-o*cs.dot(Tl);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Jn extends Qi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ji,this.combine=qu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const R0=new Ye,Ds=new Za,wo=new ji,D0=new C,Ao=new C,To=new C,Ro=new C,Rl=new C,Do=new C,C0=new C,Co=new C;class We extends bt{constructor(e=new yt,t=new Jn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){Do.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Rl.fromBufferAttribute(u,e),a?Do.addScaledVector(Rl,h):Do.addScaledVector(Rl.sub(t),h))}t.add(Do)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),wo.copy(n.boundingSphere),wo.applyMatrix4(r),Ds.copy(e.ray).recast(e.near),!(wo.containsPoint(Ds.origin)===!1&&(Ds.intersectSphere(wo,D0)===null||Ds.origin.distanceToSquared(D0)>(e.far-e.near)**2))&&(R0.copy(r).invert(),Ds.copy(e.ray).applyMatrix4(R0),!(n.boundingBox!==null&&Ds.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ds)))}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),b=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let _=S,E=b;_<E;_+=3){const w=o.getX(_),R=o.getX(_+1),M=o.getX(_+2);i=Io(this,g,e,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=o.getX(m),b=o.getX(m+1),_=o.getX(m+2);i=Io(this,a,e,n,l,h,u,S,b,_),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),b=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let _=S,E=b;_<E;_+=3){const w=_,R=_+1,M=_+2;i=Io(this,g,e,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=m,b=m+1,_=m+2;i=Io(this,a,e,n,l,h,u,S,b,_),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function J2(s,e,t,n,i,r,a,o){let c;if(e.side===Ct?c=n.intersectTriangle(a,r,i,!0,o):c=n.intersectTriangle(i,r,a,e.side===Ss,o),c===null)return null;Co.copy(o),Co.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Co);return l<t.near||l>t.far?null:{distance:l,point:Co.clone(),object:s}}function Io(s,e,t,n,i,r,a,o,c,l){s.getVertexPosition(o,Ao),s.getVertexPosition(c,To),s.getVertexPosition(l,Ro);const h=J2(s,e,t,n,Ao,To,Ro,C0);if(h){const u=new C;Zn.getBarycoord(C0,Ao,To,Ro,u),i&&(h.uv=Zn.getInterpolatedAttribute(i,o,c,l,u,new Ae)),r&&(h.uv1=Zn.getInterpolatedAttribute(r,o,c,l,u,new Ae)),a&&(h.normal=Zn.getInterpolatedAttribute(a,o,c,l,u,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new C,materialIndex:0};Zn.getNormal(Ao,To,Ro,d.normal),h.face=d,h.barycoord=u}return h}const ha=new nt,I0=new nt,P0=new nt,j2=new nt,L0=new Ye,Po=new C,Dl=new ji,N0=new Ye,Cl=new Za;class UE extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=o0,this.bindMatrix=new Ye,this.bindMatrixInverse=new Ye,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new hi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Po),this.boundingBox.expandByPoint(Po)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ji),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Po),this.boundingSphere.expandByPoint(Po)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Dl.copy(this.boundingSphere),Dl.applyMatrix4(i),e.ray.intersectsSphere(Dl)!==!1&&(N0.copy(i).invert(),Cl.copy(e.ray).applyMatrix4(N0),!(this.boundingBox!==null&&Cl.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Cl)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new nt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===o0?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Q1?this.bindMatrixInverse.copy(this.bindMatrix).invert():we("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;I0.fromBufferAttribute(i.attributes.skinIndex,e),P0.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4?(ha.copy(t),t.set(0,0,0,0)):(ha.set(...t,1),t.set(0,0,0)),ha.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=P0.getComponent(r);if(a!==0){const o=I0.getComponent(r);L0.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(j2.copy(ha).applyMatrix4(L0),a)}}return t.isVector4&&(t.w=ha.w),t.applyMatrix4(this.bindMatrixInverse)}}class Q2 extends bt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class js extends on{constructor(e=null,t=1,n=1,i,r,a,o,c,l=Tt,h=Tt,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const O0=new Ye,ev=new Ye;class xm{constructor(e=[],t=[]){this.uuid=ci(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){we("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ye)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ye;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:ev;O0.multiplyMatrices(o,t[r]),O0.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new xm(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new js(t,e,e,_n,Tn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let a=t[r];a===void 0&&(we("Skeleton: No bone found with UUID:",r),a=new Q2),this.bones.push(a),this.boneInverses.push(new Ye().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class U0 extends rt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const _r=new Ye,F0=new Ye,Lo=[],k0=new hi,tv=new Ye,ua=new We,da=new ji;class FE extends We{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new U0(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,tv)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new hi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_r),k0.copy(e.boundingBox).applyMatrix4(_r),this.boundingBox.union(k0)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ji),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_r),da.copy(e.boundingSphere).applyMatrix4(_r),this.boundingSphere.union(da)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(ua.geometry=this.geometry,ua.material=this.material,ua.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),da.copy(this.boundingSphere),da.applyMatrix4(n),e.ray.intersectsSphere(da)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,_r),F0.multiplyMatrices(n,_r),ua.matrixWorld=F0,ua.raycast(e,Lo);for(let a=0,o=Lo.length;a<o;a++){const c=Lo[a];c.instanceId=r,c.object=this,t.push(c)}Lo.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new U0(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new js(new Float32Array(i*this.count),i,this.count,Vc,Tn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=i*e;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Il=new C,nv=new C,iv=new ze;class Ls{constructor(e=new C(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Il.subVectors(n,t).cross(nv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const i=e.delta(Il),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||iv.getNormalMatrix(e),i=this.coplanarPoint(Il).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Cs=new ji,sv=new Ae(.5,.5),No=new C;class rd{constructor(e=new Ls,t=new Ls,n=new Ls,i=new Ls,r=new Ls,a=new Ls){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ri,n=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],p=r[8],v=r[9],m=r[10],g=r[11],S=r[12],b=r[13],_=r[14],E=r[15];if(i[0].setComponents(l-a,f-h,g-p,E-S).normalize(),i[1].setComponents(l+a,f+h,g+p,E+S).normalize(),i[2].setComponents(l+o,f+u,g+v,E+b).normalize(),i[3].setComponents(l-o,f-u,g-v,E-b).normalize(),n)i[4].setComponents(c,d,m,_).normalize(),i[5].setComponents(l-c,f-d,g-m,E-_).normalize();else if(i[4].setComponents(l-c,f-d,g-m,E-_).normalize(),t===Ri)i[5].setComponents(l+c,f+d,g+m,E+_).normalize();else if(t===Ya)i[5].setComponents(c,d,m,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Cs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Cs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Cs)}intersectsSprite(e){Cs.center.set(0,0,0);const t=sv.distanceTo(e.center);return Cs.radius=.7071067811865476+t,Cs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Cs)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(No.x=i.normal.x>0?e.max.x:e.min.x,No.y=i.normal.y>0?e.max.y:e.min.y,No.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(No)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class rv extends Qi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Dc=new C,Cc=new C,z0=new Ye,fa=new Za,Oo=new ji,Pl=new C,B0=new C;class _m extends bt{constructor(e=new yt,t=new rv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Dc.fromBufferAttribute(t,i-1),Cc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Dc.distanceTo(Cc);e.setAttribute("lineDistance",new It(n,1))}else we("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Oo.copy(n.boundingSphere),Oo.applyMatrix4(i),Oo.radius+=r,e.ray.intersectsSphere(Oo)===!1)return;z0.copy(i).invert(),fa.copy(e.ray).applyMatrix4(z0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),S=h.getX(v+1),b=Uo(this,e,fa,c,g,S,v);b&&t.push(b)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=Uo(this,e,fa,c,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=Uo(this,e,fa,c,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=Uo(this,e,fa,c,p-1,f,p-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Uo(s,e,t,n,i,r,a){const o=s.geometry.attributes.position;if(Dc.fromBufferAttribute(o,i),Cc.fromBufferAttribute(o,r),t.distanceSqToSegment(Dc,Cc,Pl,B0)>n)return;Pl.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(Pl);if(!(l<e.near||l>e.far))return{distance:l,point:B0.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const H0=new C,G0=new C;class kE extends _m{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)H0.fromBufferAttribute(t,i),G0.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+H0.distanceTo(G0);e.setAttribute("lineDistance",new It(n,1))}else we("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class zE extends _m{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class ad extends Qi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const V0=new Ye,cu=new Za,Fo=new ji,ko=new C;class Na extends bt{constructor(e=new yt,t=new ad){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Fo.copy(n.boundingSphere),Fo.applyMatrix4(i),Fo.radius+=r,e.ray.intersectsSphere(Fo)===!1)return;V0.copy(i).invert(),cu.copy(e.ray).applyMatrix4(V0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);ko.fromBufferAttribute(u,m),W0(ko,m,c,i,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let p=d,v=f;p<v;p++)ko.fromBufferAttribute(u,p),W0(ko,p,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function W0(s,e,t,n,i,r,a){const o=cu.distanceSqToPoint(s);if(o<t){const c=new C;cu.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class ym extends on{constructor(e=[],t=qs,n,i,r,a,o,c,l,h){super(e,t,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Li extends on{constructor(e,t,n,i,r,a,o,c,l){super(e,t,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ks extends on{constructor(e,t,n=li,i,r,a,o=Tt,c=Tt,l,h=Zi,u=1){if(h!==Zi&&h!==Hs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,i,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new nd(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class av extends Ks{constructor(e,t=li,n=qs,i,r,a=Tt,o=Tt,c,l=Zi){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,i,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Sm extends on{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class jn extends yt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,n,t,e,a,r,0),p("z","y","x",1,-1,n,t,-e,a,r,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new It(l,3)),this.setAttribute("normal",new It(h,3)),this.setAttribute("uv",new It(u,2));function p(v,m,g,S,b,_,E,w,R,M,A){const I=_/R,D=E/M,P=_/2,F=E/2,H=w/2,O=R+1,V=M+1;let z=0,Y=0;const ee=new C;for(let J=0;J<V;J++){const ne=J*D-F;for(let ae=0;ae<O;ae++){const Ve=ae*I-P;ee[v]=Ve*S,ee[m]=ne*b,ee[g]=H,l.push(ee.x,ee.y,ee.z),ee[v]=0,ee[m]=0,ee[g]=w>0?1:-1,h.push(ee.x,ee.y,ee.z),u.push(ae/R),u.push(1-J/M),z+=1}}for(let J=0;J<M;J++)for(let ne=0;ne<R;ne++){const ae=d+ne+O*J,Ve=d+ne+O*(J+1),je=d+(ne+1)+O*(J+1),Be=d+(ne+1)+O*J;c.push(ae,Ve,Be),c.push(Ve,je,Be),Y+=6}o.addGroup(f,Y,A),f+=Y,d+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class od extends yt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],c=[],l=new C,h=new Ae;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=n+u/t*i;l.x=e*Math.cos(f),l.y=e*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new It(a,3)),this.setAttribute("normal",new It(o,3)),this.setAttribute("uv",new It(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new od(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class es extends yt{constructor(e=1,t=1,n=1,i=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=n/2;let g=0;S(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(h),this.setAttribute("position",new It(u,3)),this.setAttribute("normal",new It(d,3)),this.setAttribute("uv",new It(f,2));function S(){const _=new C,E=new C;let w=0;const R=(t-e)/n;for(let M=0;M<=r;M++){const A=[],I=M/r,D=I*(t-e)+e;for(let P=0;P<=i;P++){const F=P/i,H=F*c+o,O=Math.sin(H),V=Math.cos(H);E.x=D*O,E.y=-I*n+m,E.z=D*V,u.push(E.x,E.y,E.z),_.set(O,R,V).normalize(),d.push(_.x,_.y,_.z),f.push(F,1-I),A.push(p++)}v.push(A)}for(let M=0;M<i;M++)for(let A=0;A<r;A++){const I=v[A][M],D=v[A+1][M],P=v[A+1][M+1],F=v[A][M+1];(e>0||A!==0)&&(h.push(I,D,F),w+=3),(t>0||A!==r-1)&&(h.push(D,P,F),w+=3)}l.addGroup(g,w,0),g+=w}function b(_){const E=p,w=new Ae,R=new C;let M=0;const A=_===!0?e:t,I=_===!0?1:-1;for(let P=1;P<=i;P++)u.push(0,m*I,0),d.push(0,I,0),f.push(.5,.5),p++;const D=p;for(let P=0;P<=i;P++){const H=P/i*c+o,O=Math.cos(H),V=Math.sin(H);R.x=A*V,R.y=m*I,R.z=A*O,u.push(R.x,R.y,R.z),d.push(0,I,0),w.x=O*.5+.5,w.y=V*.5*I+.5,f.push(w.x,w.y),p++}for(let P=0;P<i;P++){const F=E+P,H=D+P;_===!0?h.push(H,H+1,F):h.push(H+1,H,F),M+=3}l.addGroup(g,M,_===!0?1:2),g+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new es(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ja extends es{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Ja(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ui extends yt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(i),l=o+1,h=c+1,u=e/o,d=t/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const S=g*d-a;for(let b=0;b<l;b++){const _=b*u-r;p.push(_,-S,0),v.push(0,0,1),m.push(b/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let S=0;S<o;S++){const b=S+l*g,_=S+l*(g+1),E=S+1+l*(g+1),w=S+1+l*g;f.push(b,_,w),f.push(_,E,w)}this.setIndex(f),this.setAttribute("position",new It(p,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ui(e.width,e.height,e.widthSegments,e.heightSegments)}}class fn extends yt{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new C,d=new C,f=[],p=[],v=[],m=[];for(let g=0;g<=n;g++){const S=[],b=g/n,_=a+b*o,E=e*Math.cos(_),w=Math.sqrt(e*e-E*E);let R=0;g===0&&a===0?R=.5/t:g===n&&c===Math.PI&&(R=-.5/t);for(let M=0;M<=t;M++){const A=M/t,I=i+A*r;u.x=-w*Math.cos(I),u.y=E,u.z=w*Math.sin(I),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+R,1-b),S.push(l++)}h.push(S)}for(let g=0;g<n;g++)for(let S=0;S<t;S++){const b=h[g][S+1],_=h[g][S],E=h[g+1][S],w=h[g+1][S+1];(g!==0||a>0)&&f.push(b,_,w),(g!==n-1||c<Math.PI)&&f.push(_,E,w)}this.setIndex(f),this.setAttribute("position",new It(p,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Jr(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];if(X0(i))i.isRenderTargetTexture?(we("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone();else if(Array.isArray(i))if(X0(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();e[t][n]=r}else e[t][n]=i.slice();else e[t][n]=i}}return e}function Sn(s){const e={};for(let t=0;t<s.length;t++){const n=Jr(s[t]);for(const i in n)e[i]=n[i]}return e}function X0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function ov(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function bm(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:et.workingColorSpace}const cv={clone:Jr,merge:Sn};var lv=`void main() {
607
+ */const Xu="185",C1=0,s0=1,I1=2,Ia=1,P1=2,ba=3,Ss=0,Ct=1,ai=2,Ci=0,zr=1,Gn=2,r0=3,a0=4,L1=5,Os=100,N1=101,O1=102,U1=103,F1=104,k1=200,z1=201,B1=202,H1=203,_h=204,yh=205,G1=206,V1=207,W1=208,X1=209,q1=210,Y1=211,K1=212,$1=213,Z1=214,Sh=0,bh=1,Eh=2,Yr=3,wh=4,Ah=5,Th=6,Rh=7,qu=0,J1=1,j1=2,Ii=0,Qp=1,em=2,tm=3,nm=4,im=5,sm=6,rm=7,o0="attached",Q1="detached",am=300,qs=301,Kr=302,il=303,sl=304,Gc=306,Wa=1e3,An=1001,Dh=1002,Tt=1003,e2=1004,uo=1005,dt=1006,rl=1007,Bs=1008,Hn=1009,om=1010,cm=1011,Xa=1012,Yu=1013,li=1014,Tn=1015,cn=1016,Ku=1017,$u=1018,qa=1020,lm=35902,hm=35899,um=1021,dm=1022,_n=1023,Zi=1026,Hs=1027,Vc=1028,Zu=1029,Ys=1030,Ju=1031,ju=1033,cc=33776,lc=33777,hc=33778,uc=33779,Ch=35840,Ih=35841,Ph=35842,Lh=35843,Nh=36196,Oh=37492,Uh=37496,Fh=37488,kh=37489,xc=37490,zh=37491,Bh=37808,Hh=37809,Gh=37810,Vh=37811,Wh=37812,Xh=37813,qh=37814,Yh=37815,Kh=37816,$h=37817,Zh=37818,Jh=37819,jh=37820,Qh=37821,eu=36492,tu=36494,nu=36495,iu=36283,su=36284,_c=36285,ru=36286,yc=2300,au=2301,al=2302,c0=2303,l0=2400,h0=2401,u0=2402,t2=2500,PE=0,LE=1,NE=2,n2=3200,Sc=0,i2=1,vs="",Ln="srgb",bc="srgb-linear",Ec="linear",lt="srgb",sr=7680,d0=519,s2=512,r2=513,a2=514,Qu=515,o2=516,c2=517,ed=518,l2=519,ou=35044,wc="300 es",Ri=2e3,Ya=2001;function h2(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function u2(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ka(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function d2(){const s=Ka("canvas");return s.style.display="block",s}const f0={};function Ac(...s){const e="THREE."+s.shift();console.log(e,...s)}function fm(s){const e=s[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=s[1];t&&t.isStackTrace?s[0]+=" "+t.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function we(...s){s=fm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...s)}}function ke(...s){s=fm(s);const e="THREE."+s.shift();{const t=s[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...s)}}function Br(...s){const e=s.join(" ");e in f0||(f0[e]=!0,we(...s))}function f2(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const p2={[Sh]:bh,[Eh]:Th,[wh]:Rh,[Yr]:Ah,[bh]:Sh,[Th]:Eh,[Rh]:wh,[Ah]:Yr};class Js{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const gn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let p0=1234567;const Pa=Math.PI/180,$r=180/Math.PI;function ci(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(gn[s&255]+gn[s>>8&255]+gn[s>>16&255]+gn[s>>24&255]+"-"+gn[e&255]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[t&63|128]+gn[t>>8&255]+"-"+gn[t>>16&255]+gn[t>>24&255]+gn[n&255]+gn[n>>8&255]+gn[n>>16&255]+gn[n>>24&255]).toLowerCase()}function Je(s,e,t){return Math.max(e,Math.min(t,s))}function td(s,e){return(s%e+e)%e}function m2(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function g2(s,e,t){return s!==e?(t-s)/(e-s):0}function La(s,e,t){return(1-t)*s+t*e}function v2(s,e,t,n){return La(s,e,1-Math.exp(-t*n))}function M2(s,e=1){return e-Math.abs(td(s,e*2)-e)}function x2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function _2(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function y2(s,e){return s+Math.floor(Math.random()*(e-s+1))}function S2(s,e){return s+Math.random()*(e-s)}function b2(s){return s*(.5-Math.random())}function E2(s){s!==void 0&&(p0=s);let e=p0+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function w2(s){return s*Pa}function A2(s){return s*$r}function T2(s){return(s&s-1)===0&&s!==0}function R2(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function D2(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function C2(s,e,t,n,i){const r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),u=r((e-n)/2),d=a((e-n)/2),f=r((n-e)/2),p=a((n-e)/2);switch(i){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*p,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*p,o*l);break;case"ZYZ":s.set(c*p,c*f,o*h,o*l);break;default:we("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function oi(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ht(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const OE={DEG2RAD:Pa,RAD2DEG:$r,generateUUID:ci,clamp:Je,euclideanModulo:td,mapLinear:m2,inverseLerp:g2,lerp:La,damp:v2,pingpong:M2,smoothstep:x2,smootherstep:_2,randInt:y2,randFloat:S2,randFloatSpread:b2,seededRandom:E2,degToRad:w2,radToDeg:A2,isPowerOfTwo:T2,ceilPowerOfTwo:R2,floorPowerOfTwo:D2,setQuaternionFromProperEuler:C2,normalize:ht,denormalize:oi};class Ae{static{Ae.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}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(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Es{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,o){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3],d=r[a+0],f=r[a+1],p=r[a+2],v=r[a+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const S=Math.acos(m),b=Math.sin(S);g=Math.sin(g*S)/b,o=Math.sin(o*S)/b,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const S=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=S,l*=S,h*=S,u*=S}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+h*u+c*f-l*d,e[t+1]=c*p+h*d+l*u-o*f,e[t+2]=l*p+h*f+o*d-c*u,e[t+3]=h*p-o*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/2),p=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:we("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+a*o+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,t=Math.sin(t*l)/h,this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+i*t,this._z=this._z*c+r*t,this._w=this._w*c+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{static{C.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(m0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(m0.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*i-o*n),h=2*(o*t-r*i),u=2*(r*n-a*t);return this.x=t+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=i+c*u+r*h-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ol.copy(this).projectOnVector(e),this.sub(ol)}reflect(e){return this.sub(ol.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Je(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ol=new C,m0=new Es;class Be{static{Be.prototype.isMatrix3=!0}constructor(e,t,n,i,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,c,l)}set(e,t,n,i,r,a,o,c,l){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],v=i[0],m=i[3],g=i[6],S=i[1],b=i[4],_=i[7],E=i[2],w=i[5],R=i[8];return r[0]=a*v+o*S+c*E,r[3]=a*m+o*b+c*w,r[6]=a*g+o*_+c*R,r[1]=l*v+h*S+u*E,r[4]=l*m+h*b+u*w,r[7]=l*g+h*_+u*R,r[2]=d*v+f*S+p*E,r[5]=d*m+f*b+p*w,r[8]=d*g+f*_+p*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8];return t*a*h-t*o*l-n*r*h+n*o*c+i*r*l-i*a*c}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,p=t*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return e[0]=u*v,e[1]=(i*l-h*n)*v,e[2]=(o*n-i*a)*v,e[3]=d*v,e[4]=(h*t-i*c)*v,e[5]=(i*r-o*t)*v,e[6]=f*v,e[7]=(n*c-l*t)*v,e[8]=(a*t-n*r)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-i*l,i*c,-i*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return Br("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(cl.makeScale(e,t)),this}rotate(e){return Br("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(cl.makeRotation(-e)),this}translate(e,t){return Br("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(cl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const cl=new Be,g0=new Be().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),v0=new Be().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function I2(){const s={enabled:!0,workingColorSpace:bc,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===lt&&(i.r=Ki(i.r),i.g=Ki(i.g),i.b=Ki(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===lt&&(i.r=Hr(i.r),i.g=Hr(i.g),i.b=Hr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===vs?Ec:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return Br("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return Br("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[bc]:{primaries:e,whitePoint:n,transfer:Ec,toXYZ:g0,fromXYZ:v0,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ln},outputColorSpaceConfig:{drawingBufferColorSpace:Ln}},[Ln]:{primaries:e,whitePoint:n,transfer:lt,toXYZ:g0,fromXYZ:v0,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ln}}}),s}const et=I2();function Ki(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Hr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let rr;class P2{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{rr===void 0&&(rr=Ka("canvas")),rr.width=e.width,rr.height=e.height;const i=rr.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=rr}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ka("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Ki(r[a]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Ki(t[n]/255)*255):t[n]=Ki(t[n]);return{data:t,width:e.width,height:e.height}}else return we("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let L2=0;class nd{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:L2++}),this.uuid=ci(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(ll(i[a].image)):r.push(ll(i[a]))}else r=ll(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function ll(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?P2.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(we("Texture: Unable to serialize Texture."),{})}let N2=0;const hl=new C;class on extends Js{constructor(e=on.DEFAULT_IMAGE,t=on.DEFAULT_MAPPING,n=An,i=An,r=dt,a=Bs,o=_n,c=Hn,l=on.DEFAULT_ANISOTROPY,h=vs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:N2++}),this.uuid=ci(),this.name="",this.source=new nd(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ae(0,0),this.repeat=new Ae(1,1),this.center=new Ae(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Be,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(hl).x}get height(){return this.source.getSize(hl).y}get depth(){return this.source.getSize(hl).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){we(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){we(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==am)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Wa:e.x=e.x-Math.floor(e.x);break;case An:e.x=e.x<0?0:1;break;case Dh:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Wa:e.y=e.y-Math.floor(e.y);break;case An:e.y=e.y<0?0:1;break;case Dh:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}on.DEFAULT_IMAGE=null;on.DEFAULT_MAPPING=am;on.DEFAULT_ANISOTROPY=1;class nt{static{nt.prototype.isVector4=!0}constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){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: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(l+1)/2,_=(f+1)/2,E=(g+1)/2,w=(h+d)/4,R=(u+v)/4,M=(p+m)/4;return b>_&&b>E?b<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(b),i=w/n,r=R/n):_>E?_<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(_),n=w/i,r=M/i):E<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(E),n=R/r,i=M/r),this.set(n,i,r,t),this}let S=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(S)<.001&&(S=1),this.x=(m-p)/S,this.y=(u-v)/S,this.z=(d-h)/S,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),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 O2 extends Js{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:dt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new nt(0,0,e,t),this.scissorTest=!1,this.viewport=new nt(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:n.depth},r=new on(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){const t={minFilter:dt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const i=Object.assign({},e.textures[t].image);this.textures[t].source=new nd(i)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class dn extends O2{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class pm extends on{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Tt,this.minFilter=Tt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class mm extends on{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Tt,this.minFilter=Tt,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ye{static{Ye.prototype.isMatrix4=!0}constructor(e,t,n,i,r,a,o,c,l,h,u,d,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,a,o,c,l,h,u,d,f,p,v,m)}set(e,t,n,i,r,a,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,g[15]=m,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 Ye().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,i=1/ar.setFromMatrixColumn(e,0).length(),r=1/ar.setFromMatrixColumn(e,1).length(),a=1/ar.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,f=a*u,p=o*h,v=o*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+p*l,t[5]=d-v*l,t[9]=-o*c,t[2]=v-d*l,t[6]=p+f*l,t[10]=a*c}else if(e.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d+v*o,t[4]=p*o-f,t[8]=a*l,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=f*o-p,t[6]=v+d*o,t[10]=a*c}else if(e.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;t[0]=d-v*o,t[4]=-a*u,t[8]=p+f*o,t[1]=f+p*o,t[5]=a*h,t[9]=v-d*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){const d=a*h,f=a*u,p=o*h,v=o*u;t[0]=c*h,t[4]=p*l-f,t[8]=d*l+v,t[1]=c*u,t[5]=v*l+d,t[9]=f*l-p,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){const d=a*c,f=a*l,p=o*c,v=o*l;t[0]=c*h,t[4]=v-d*u,t[8]=p*u+f,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=f*u+p,t[10]=d-v*u}else if(e.order==="XZY"){const d=a*c,f=a*l,p=o*c,v=o*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+v,t[5]=a*h,t[9]=f*u-p,t[2]=p*u-f,t[6]=o*h,t[10]=v*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(U2,e,F2)}lookAt(e,t,n){const i=this.elements;return Un.subVectors(e,t),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),ss.crossVectors(n,Un),ss.lengthSq()===0&&(Math.abs(n.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),ss.crossVectors(n,Un)),ss.normalize(),fo.crossVectors(Un,ss),i[0]=ss.x,i[4]=fo.x,i[8]=Un.x,i[1]=ss.y,i[5]=fo.y,i[9]=Un.y,i[2]=ss.z,i[6]=fo.z,i[10]=Un.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],v=n[6],m=n[10],g=n[14],S=n[3],b=n[7],_=n[11],E=n[15],w=i[0],R=i[4],M=i[8],A=i[12],I=i[1],D=i[5],P=i[9],F=i[13],H=i[2],O=i[6],V=i[10],z=i[14],Y=i[3],ee=i[7],J=i[11],ne=i[15];return r[0]=a*w+o*I+c*H+l*Y,r[4]=a*R+o*D+c*O+l*ee,r[8]=a*M+o*P+c*V+l*J,r[12]=a*A+o*F+c*z+l*ne,r[1]=h*w+u*I+d*H+f*Y,r[5]=h*R+u*D+d*O+f*ee,r[9]=h*M+u*P+d*V+f*J,r[13]=h*A+u*F+d*z+f*ne,r[2]=p*w+v*I+m*H+g*Y,r[6]=p*R+v*D+m*O+g*ee,r[10]=p*M+v*P+m*V+g*J,r[14]=p*A+v*F+m*z+g*ne,r[3]=S*w+b*I+_*H+E*Y,r[7]=S*R+b*D+_*O+E*ee,r[11]=S*M+b*P+_*V+E*J,r[15]=S*A+b*F+_*z+E*ne,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],f=e[14],p=e[3],v=e[7],m=e[11],g=e[15],S=c*f-l*d,b=o*f-l*u,_=o*d-c*u,E=a*f-l*h,w=a*d-c*h,R=a*u-o*h;return t*(v*S-m*b+g*_)-n*(p*S-m*E+g*w)+i*(p*b-v*E+g*R)-r*(p*_-v*w+m*R)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[1],a=e[5],o=e[9],c=e[2],l=e[6],h=e[10];return t*(a*h-o*l)-n*(r*h-o*c)+i*(r*l-a*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],f=e[11],p=e[12],v=e[13],m=e[14],g=e[15],S=t*o-n*a,b=t*c-i*a,_=t*l-r*a,E=n*c-i*o,w=n*l-r*o,R=i*l-r*c,M=h*v-u*p,A=h*m-d*p,I=h*g-f*p,D=u*m-d*v,P=u*g-f*v,F=d*g-f*m,H=S*F-b*P+_*D+E*I-w*A+R*M;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/H;return e[0]=(o*F-c*P+l*D)*O,e[1]=(i*P-n*F-r*D)*O,e[2]=(v*R-m*w+g*E)*O,e[3]=(d*w-u*R-f*E)*O,e[4]=(c*I-a*F-l*A)*O,e[5]=(t*F-i*I+r*A)*O,e[6]=(m*_-p*R-g*b)*O,e[7]=(h*R-d*_+f*b)*O,e[8]=(a*P-o*I+l*M)*O,e[9]=(n*I-t*P-r*M)*O,e[10]=(p*w-v*_+g*S)*O,e[11]=(u*_-h*w-f*S)*O,e[12]=(o*A-a*D-c*M)*O,e[13]=(t*D-n*A+i*M)*O,e[14]=(v*b-p*E-m*S)*O,e[15]=(h*E-u*b+d*S)*O,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,c=e.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,p=r*u,v=a*h,m=a*u,g=o*u,S=c*l,b=c*h,_=c*u,E=n.x,w=n.y,R=n.z;return i[0]=(1-(v+g))*E,i[1]=(f+_)*E,i[2]=(p-b)*E,i[3]=0,i[4]=(f-_)*w,i[5]=(1-(d+g))*w,i[6]=(m+S)*w,i[7]=0,i[8]=(p+b)*R,i[9]=(m-S)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;e.x=i[12],e.y=i[13],e.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=ar.set(i[0],i[1],i[2]).length();const o=ar.set(i[4],i[5],i[6]).length(),c=ar.set(i[8],i[9],i[10]).length();r<0&&(a=-a),Qn.copy(this);const l=1/a,h=1/o,u=1/c;return Qn.elements[0]*=l,Qn.elements[1]*=l,Qn.elements[2]*=l,Qn.elements[4]*=h,Qn.elements[5]*=h,Qn.elements[6]*=h,Qn.elements[8]*=u,Qn.elements[9]*=u,Qn.elements[10]*=u,t.setFromRotationMatrix(Qn),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,i,r,a,o=Ri,c=!1){const l=this.elements,h=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),f=(n+i)/(n-i);let p,v;if(c)p=r/(a-r),v=a*r/(a-r);else if(o===Ri)p=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Ya)p=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,a,o=Ri,c=!1){const l=this.elements,h=2/(t-e),u=2/(n-i),d=-(t+e)/(t-e),f=-(n+i)/(n-i);let p,v;if(c)p=1/(a-r),v=a/(a-r);else if(o===Ri)p=-2/(a-r),v=-(a+r)/(a-r);else if(o===Ya)p=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const ar=new C,Qn=new Ye,U2=new C(0,0,0),F2=new C(1,1,1),ss=new C,fo=new C,Un=new C,M0=new Ye,x0=new Es;class Ji{constructor(e=0,t=0,n=0,i=Ji.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(t){case"XYZ":this._y=Math.asin(Je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Je(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Je(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:we("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return M0.makeRotationFromQuaternion(e),this.setFromRotationMatrix(M0,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return x0.setFromEuler(this),this.setFromQuaternion(x0,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ji.DEFAULT_ORDER="XYZ";class id{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let k2=0;const _0=new C,or=new Es,Ni=new Ye,po=new C,ia=new C,z2=new C,B2=new Es,y0=new C(1,0,0),S0=new C(0,1,0),b0=new C(0,0,1),E0={type:"added"},H2={type:"removed"},cr={type:"childadded",child:null},ul={type:"childremoved",child:null};class bt extends Js{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:k2++}),this.uuid=ci(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=bt.DEFAULT_UP.clone();const e=new C,t=new Ji,n=new Es,i=new C(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Ye},normalMatrix:{value:new Be}}),this.matrix=new Ye,this.matrixWorld=new Ye,this.matrixAutoUpdate=bt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new id,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.multiply(or),this}rotateOnWorldAxis(e,t){return or.setFromAxisAngle(e,t),this.quaternion.premultiply(or),this}rotateX(e){return this.rotateOnAxis(y0,e)}rotateY(e){return this.rotateOnAxis(S0,e)}rotateZ(e){return this.rotateOnAxis(b0,e)}translateOnAxis(e,t){return _0.copy(e).applyQuaternion(this.quaternion),this.position.add(_0.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(y0,e)}translateY(e){return this.translateOnAxis(S0,e)}translateZ(e){return this.translateOnAxis(b0,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ni.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?po.copy(e):po.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),ia.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ni.lookAt(ia,po,this.up):Ni.lookAt(po,ia,this.up),this.quaternion.setFromRotationMatrix(Ni),i&&(Ni.extractRotation(i.matrixWorld),or.setFromRotationMatrix(Ni),this.quaternion.premultiply(or.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ke("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(E0),cr.child=e,this.dispatchEvent(cr),cr.child=null):ke("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(H2),ul.child=e,this.dispatchEvent(ul),ul.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ni.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ni.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ni),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(E0),cr.child=e,this.dispatchEvent(cr),cr.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ia,e,z2),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ia,B2,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,i=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*i,r[13]+=n-r[1]*t-r[5]*n-r[9]*i,r[14]+=i-r[2]*t-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const i=this.parent;if(e===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));i.material=o}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(r(e.animations,c))}}if(t){const o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),f=a(e.animations),p=a(e.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}bt.DEFAULT_UP=new C(0,1,0);bt.DEFAULT_MATRIX_AUTO_UPDATE=!0;bt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class rn extends bt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const G2={type:"move"};class dl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new rn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new rn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new rn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(const v of e.hand.values()){const m=t.getJointPose(v,n),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(G2)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new rn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const gm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},rs={h:0,s:0,l:0},mo={h:0,s:0,l:0};function fl(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class oe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ln){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,et.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=et.workingColorSpace){return this.r=e,this.g=t,this.b=n,et.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=et.workingColorSpace){if(e=td(e,1),t=Je(t,0,1),n=Je(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=fl(a,r,e+1/3),this.g=fl(a,r,e),this.b=fl(a,r,e-1/3)}return et.colorSpaceToWorking(this,i),this}setStyle(e,t=Ln){function n(r){r!==void 0&&parseFloat(r)<1&&we("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:we("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);we("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ln){const n=gm[e.toLowerCase()];return n!==void 0?this.setHex(n,t):we("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ki(e.r),this.g=Ki(e.g),this.b=Ki(e.b),this}copyLinearToSRGB(e){return this.r=Hr(e.r),this.g=Hr(e.g),this.b=Hr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ln){return et.workingToColorSpace(vn.copy(this),e),Math.round(Je(vn.r*255,0,255))*65536+Math.round(Je(vn.g*255,0,255))*256+Math.round(Je(vn.b*255,0,255))}getHexString(e=Ln){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.workingToColorSpace(vn.copy(this),t);const n=vn.r,i=vn.g,r=vn.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=et.workingColorSpace){return et.workingToColorSpace(vn.copy(this),t),e.r=vn.r,e.g=vn.g,e.b=vn.b,e}getStyle(e=Ln){et.workingToColorSpace(vn.copy(this),e);const t=vn.r,n=vn.g,i=vn.b;return e!==Ln?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(rs),this.setHSL(rs.h+e,rs.s+t,rs.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(rs),e.getHSL(mo);const n=La(rs.h,mo.h,t),i=La(rs.s,mo.s,t),r=La(rs.l,mo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const vn=new oe;oe.NAMES=gm;class Tc{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new oe(e),this.near=t,this.far=n}clone(){return new Tc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Zr extends bt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ji,this.environmentIntensity=1,this.environmentRotation=new Ji,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const ei=new C,Oi=new C,pl=new C,Ui=new C,lr=new C,hr=new C,w0=new C,ml=new C,gl=new C,vl=new C,Ml=new nt,xl=new nt,_l=new nt;class Zn{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ei.subVectors(e,t),i.cross(ei);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){ei.subVectors(i,t),Oi.subVectors(n,t),pl.subVectors(e,t);const a=ei.dot(ei),o=ei.dot(Oi),c=ei.dot(pl),l=Oi.dot(Oi),h=Oi.dot(pl),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(a*h-o*c)*d;return r.set(1-f-p,p,f)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ui)===null?!1:Ui.x>=0&&Ui.y>=0&&Ui.x+Ui.y<=1}static getInterpolation(e,t,n,i,r,a,o,c){return this.getBarycoord(e,t,n,i,Ui)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Ui.x),c.addScaledVector(a,Ui.y),c.addScaledVector(o,Ui.z),c)}static getInterpolatedAttribute(e,t,n,i,r,a){return Ml.setScalar(0),xl.setScalar(0),_l.setScalar(0),Ml.fromBufferAttribute(e,t),xl.fromBufferAttribute(e,n),_l.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(Ml,r.x),a.addScaledVector(xl,r.y),a.addScaledVector(_l,r.z),a}static isFrontFacing(e,t,n,i){return ei.subVectors(n,t),Oi.subVectors(e,t),ei.cross(Oi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ei.subVectors(this.c,this.b),Oi.subVectors(this.a,this.b),ei.cross(Oi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return Zn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Zn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,o;lr.subVectors(i,n),hr.subVectors(r,n),ml.subVectors(e,n);const c=lr.dot(ml),l=hr.dot(ml);if(c<=0&&l<=0)return t.copy(n);gl.subVectors(e,i);const h=lr.dot(gl),u=hr.dot(gl);if(h>=0&&u<=h)return t.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),t.copy(n).addScaledVector(lr,a);vl.subVectors(e,r);const f=lr.dot(vl),p=hr.dot(vl);if(p>=0&&f<=p)return t.copy(r);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(hr,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return w0.subVectors(r,i),o=(u-h)/(u-h+(f-p)),t.copy(i).addScaledVector(w0,o);const g=1/(m+v+d);return a=v*g,o=d*g,t.copy(n).addScaledVector(lr,a).addScaledVector(hr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class hi{constructor(e=new C(1/0,1/0,1/0),t=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(ti.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(ti.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=ti.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,ti):ti.fromBufferAttribute(r,a),ti.applyMatrix4(e.matrixWorld),this.expandByPoint(ti);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),go.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),go.copy(n.boundingBox)),go.applyMatrix4(e.matrixWorld),this.union(go)}const i=e.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ti),ti.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(sa),vo.subVectors(this.max,sa),ur.subVectors(e.a,sa),dr.subVectors(e.b,sa),fr.subVectors(e.c,sa),as.subVectors(dr,ur),os.subVectors(fr,dr),Ts.subVectors(ur,fr);let t=[0,-as.z,as.y,0,-os.z,os.y,0,-Ts.z,Ts.y,as.z,0,-as.x,os.z,0,-os.x,Ts.z,0,-Ts.x,-as.y,as.x,0,-os.y,os.x,0,-Ts.y,Ts.x,0];return!yl(t,ur,dr,fr,vo)||(t=[1,0,0,0,1,0,0,0,1],!yl(t,ur,dr,fr,vo))?!1:(Mo.crossVectors(as,os),t=[Mo.x,Mo.y,Mo.z],yl(t,ur,dr,fr,vo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ti).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(ti).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Fi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Fi=[new C,new C,new C,new C,new C,new C,new C,new C],ti=new C,go=new hi,ur=new C,dr=new C,fr=new C,as=new C,os=new C,Ts=new C,sa=new C,vo=new C,Mo=new C,Rs=new C;function yl(s,e,t,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){Rs.fromArray(s,r);const o=i.x*Math.abs(Rs.x)+i.y*Math.abs(Rs.y)+i.z*Math.abs(Rs.z),c=e.dot(Rs),l=t.dot(Rs),h=n.dot(Rs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Wi=V2();function V2(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function W2(s){Math.abs(s)>65504&&we("DataUtils.toHalfFloat(): Value out of range."),s=Je(s,-65504,65504),Wi.floatView[0]=s;const e=Wi.uint32View[0],t=e>>23&511;return Wi.baseTable[t]+((e&8388607)>>Wi.shiftTable[t])}function X2(s){const e=s>>10;return Wi.uint32View[0]=Wi.mantissaTable[Wi.offsetTable[e]+(s&1023)]+Wi.exponentTable[e],Wi.floatView[0]}class $i{static toHalfFloat(e){return W2(e)}static fromHalfFloat(e){return X2(e)}}const Xt=new C,xo=new Ae;let q2=0;class rt extends Js{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:q2++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ou,this.updateRanges=[],this.gpuType=Tn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xo.fromBufferAttribute(this,t),xo.applyMatrix3(e),this.setXY(t,xo.x,xo.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix3(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.applyMatrix4(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.applyNormalMatrix(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Xt.fromBufferAttribute(this,t),Xt.transformDirection(e),this.setXYZ(t,Xt.x,Xt.y,Xt.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=oi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=oi(t,this.array)),t}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=oi(t,this.array)),t}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=oi(t,this.array)),t}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=oi(t,this.array)),t}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ou&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class vm extends rt{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class sd extends rt{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class It extends rt{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Y2=new hi,ra=new C,Sl=new C;class ji{constructor(e=new C,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Y2.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;r<a;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ra.subVectors(e,this.center);const t=ra.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(ra,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Sl.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ra.copy(e.center).add(Sl)),this.expandByPoint(ra.copy(e.center).sub(Sl))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let K2=0;const Xn=new Ye,bl=new bt,pr=new C,Fn=new hi,aa=new hi,Jt=new C;class yt extends Js{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:K2++}),this.uuid=ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(h2(e)?sd:vm)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Be().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Xn.makeRotationFromQuaternion(e),this.applyMatrix4(Xn),this}rotateX(e){return Xn.makeRotationX(e),this.applyMatrix4(Xn),this}rotateY(e){return Xn.makeRotationY(e),this.applyMatrix4(Xn),this}rotateZ(e){return Xn.makeRotationZ(e),this.applyMatrix4(Xn),this}translate(e,t,n){return Xn.makeTranslation(e,t,n),this.applyMatrix4(Xn),this}scale(e,t,n){return Xn.makeScale(e,t,n),this.applyMatrix4(Xn),this}lookAt(e){return bl.lookAt(e),bl.updateMatrix(),this.applyMatrix4(bl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pr).negate(),this.translate(pr.x,pr.y,pr.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new It(n,3))}else{const n=Math.min(e.length,t.count);for(let i=0;i<n;i++){const r=e[i];t.setXYZ(i,r.x,r.y,r.z||0)}e.length>t.count&&we("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new hi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];Fn.setFromBufferAttribute(r),this.morphTargetsRelative?(Jt.addVectors(this.boundingBox.min,Fn.min),this.boundingBox.expandByPoint(Jt),Jt.addVectors(this.boundingBox.max,Fn.max),this.boundingBox.expandByPoint(Jt)):(this.boundingBox.expandByPoint(Fn.min),this.boundingBox.expandByPoint(Fn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ke('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ji);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(e){const n=this.boundingSphere.center;if(Fn.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];aa.setFromBufferAttribute(o),this.morphTargetsRelative?(Jt.addVectors(Fn.min,aa.min),Fn.expandByPoint(Jt),Jt.addVectors(Fn.max,aa.max),Fn.expandByPoint(Jt)):(Fn.expandByPoint(aa.min),Fn.expandByPoint(aa.max))}Fn.getCenter(n);let i=0;for(let r=0,a=e.count;r<a;r++)Jt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Jt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Jt.fromBufferAttribute(o,l),c&&(pr.fromBufferAttribute(e,l),Jt.add(pr)),i=Math.max(i,n.distanceToSquared(Jt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&ke('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ke("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,i=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new rt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let M=0;M<n.count;M++)o[M]=new C,c[M]=new C;const l=new C,h=new C,u=new C,d=new Ae,f=new Ae,p=new Ae,v=new C,m=new C;function g(M,A,I){l.fromBufferAttribute(n,M),h.fromBufferAttribute(n,A),u.fromBufferAttribute(n,I),d.fromBufferAttribute(r,M),f.fromBufferAttribute(r,A),p.fromBufferAttribute(r,I),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const D=1/(f.x*p.y-p.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(D),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(D),o[M].add(v),o[A].add(v),o[I].add(v),c[M].add(m),c[A].add(m),c[I].add(m))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let M=0,A=S.length;M<A;++M){const I=S[M],D=I.start,P=I.count;for(let F=D,H=D+P;F<H;F+=3)g(e.getX(F+0),e.getX(F+1),e.getX(F+2))}const b=new C,_=new C,E=new C,w=new C;function R(M){E.fromBufferAttribute(i,M),w.copy(E);const A=o[M];b.copy(A),b.sub(E.multiplyScalar(E.dot(A))).normalize(),_.crossVectors(w,A);const D=_.dot(c[M])<0?-1:1;a.setXYZW(M,b.x,b.y,b.z,D)}for(let M=0,A=S.length;M<A;++M){const I=S[M],D=I.start,P=I.count;for(let F=D,H=D+P;F<H;F+=3)R(e.getX(F+0)),R(e.getX(F+1)),R(e.getX(F+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new rt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new C,r=new C,a=new C,o=new C,c=new C,l=new C,h=new C,u=new C;if(e)for(let d=0,f=e.count;d<f;d+=3){const p=e.getX(d+0),v=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,p),r.fromBufferAttribute(t,v),a.fromBufferAttribute(t,m),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),o.fromBufferAttribute(n,p),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=t.count;d<f;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Jt.fromBufferAttribute(e,t),Jt.normalize(),e.setXYZ(t,Jt.x,Jt.y,Jt.z)}toNonIndexed(){function e(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new rt(d,h,u)}if(this.index===null)return we("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new yt,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=e(c,n);t.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=e(d,n);c.push(f)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(e.data))}h.length>0&&(i[c]=h,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class $2{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ou,this.updateRanges=[],this.version=0,this.uuid=ci()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=ci()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const yn=new C;class Rc{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.applyMatrix4(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.applyNormalMatrix(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)yn.fromBufferAttribute(this,t),yn.transformDirection(e),this.setXYZ(t,yn.x,yn.y,yn.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=oi(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=ht(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=ht(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=oi(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=oi(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=oi(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=oi(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=ht(t,this.array),n=ht(n,this.array),i=ht(i,this.array),r=ht(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ac("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new rt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Rc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ac("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Z2=0;class Qi extends Js{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Z2++}),this.uuid=ci(),this.name="",this.type="Material",this.blending=zr,this.side=Ss,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_h,this.blendDst=yh,this.blendEquation=Os,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new oe(0,0,0),this.blendAlpha=0,this.depthFunc=Yr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=d0,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=sr,this.stencilZFail=sr,this.stencilZPass=sr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){we(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){we(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==zr&&(n.blending=this.blending),this.side!==Ss&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==_h&&(n.blendSrc=this.blendSrc),this.blendDst!==yh&&(n.blendDst=this.blendDst),this.blendEquation!==Os&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Yr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==d0&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==sr&&(n.stencilFail=this.stencilFail),this.stencilZFail!==sr&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==sr&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(t){const r=i(e.textures),a=i(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new oe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ae().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ae().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Ea extends Qi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let mr;const oa=new C,gr=new C,vr=new C,Mr=new Ae,ca=new Ae,Mm=new Ye,_o=new C,la=new C,yo=new C,A0=new Ae,El=new Ae,T0=new Ae;class xr extends bt{constructor(e=new Ea){if(super(),this.isSprite=!0,this.type="Sprite",mr===void 0){mr=new yt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new $2(t,5);mr.setIndex([0,1,2,0,2,3]),mr.setAttribute("position",new Rc(n,3,0,!1)),mr.setAttribute("uv",new Rc(n,2,3,!1))}this.geometry=mr,this.material=e,this.center=new Ae(.5,.5),this.count=1}raycast(e,t){e.camera===null&&ke('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),gr.setFromMatrixScale(this.matrixWorld),Mm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),vr.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&gr.multiplyScalar(-vr.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;So(_o.set(-.5,-.5,0),vr,a,gr,i,r),So(la.set(.5,-.5,0),vr,a,gr,i,r),So(yo.set(.5,.5,0),vr,a,gr,i,r),A0.set(0,0),El.set(1,0),T0.set(1,1);let o=e.ray.intersectTriangle(_o,la,yo,!1,oa);if(o===null&&(So(la.set(-.5,.5,0),vr,a,gr,i,r),El.set(0,1),o=e.ray.intersectTriangle(_o,yo,la,!1,oa),o===null))return;const c=e.ray.origin.distanceTo(oa);c<e.near||c>e.far||t.push({distance:c,point:oa.clone(),uv:Zn.getInterpolation(oa,_o,la,yo,A0,El,T0,new Ae),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function So(s,e,t,n,i,r){Mr.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(ca.x=r*Mr.x-i*Mr.y,ca.y=i*Mr.x+r*Mr.y):ca.copy(Mr),s.copy(e),s.x+=ca.x,s.y+=ca.y,s.applyMatrix4(Mm)}const ki=new C,wl=new C,bo=new C,cs=new C,Al=new C,Eo=new C,Tl=new C;class Za{constructor(e=new C,t=new C(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ki.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ki.copy(this.origin).addScaledVector(this.direction,t),ki.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){wl.copy(e).add(t).multiplyScalar(.5),bo.copy(t).sub(e).normalize(),cs.copy(this.origin).sub(wl);const r=e.distanceTo(t)*.5,a=-this.direction.dot(bo),o=cs.dot(this.direction),c=-cs.dot(bo),l=cs.lengthSq(),h=Math.abs(1-a*a);let u,d,f,p;if(h>0)if(u=a*c-o,d=a*o-c,p=r*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(wl).addScaledVector(bo,d),f}intersectSphere(e,t){ki.subVectors(e.center,this.origin);const n=ki.dot(this.direction),i=ki.dot(ki)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(o=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,ki)!==null}intersectTriangle(e,t,n,i,r){Al.subVectors(t,e),Eo.subVectors(n,e),Tl.crossVectors(Al,Eo);let a=this.direction.dot(Tl),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;cs.subVectors(this.origin,e);const c=o*this.direction.dot(Eo.crossVectors(cs,Eo));if(c<0)return null;const l=o*this.direction.dot(Al.cross(cs));if(l<0||c+l>a)return null;const h=-o*cs.dot(Tl);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Jn extends Qi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ji,this.combine=qu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const R0=new Ye,Ds=new Za,wo=new ji,D0=new C,Ao=new C,To=new C,Ro=new C,Rl=new C,Do=new C,C0=new C,Co=new C;class We extends bt{constructor(e=new yt,t=new Jn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const o=this.morphTargetInfluences;if(r&&o){Do.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Rl.fromBufferAttribute(u,e),a?Do.addScaledVector(Rl,h):Do.addScaledVector(Rl.sub(t),h))}t.add(Do)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),wo.copy(n.boundingSphere),wo.applyMatrix4(r),Ds.copy(e.ray).recast(e.near),!(wo.containsPoint(Ds.origin)===!1&&(Ds.intersectSphere(wo,D0)===null||Ds.origin.distanceToSquared(D0)>(e.far-e.near)**2))&&(R0.copy(r).invert(),Ds.copy(e.ray).applyMatrix4(R0),!(n.boundingBox!==null&&Ds.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ds)))}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),b=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let _=S,E=b;_<E;_+=3){const w=o.getX(_),R=o.getX(_+1),M=o.getX(_+2);i=Io(this,g,e,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=o.getX(m),b=o.getX(m+1),_=o.getX(m+2);i=Io(this,a,e,n,l,h,u,S,b,_),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=a[m.materialIndex],S=Math.max(m.start,f.start),b=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let _=S,E=b;_<E;_+=3){const w=_,R=_+1,M=_+2;i=Io(this,g,e,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const S=m,b=m+1,_=m+2;i=Io(this,a,e,n,l,h,u,S,b,_),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}}function J2(s,e,t,n,i,r,a,o){let c;if(e.side===Ct?c=n.intersectTriangle(a,r,i,!0,o):c=n.intersectTriangle(i,r,a,e.side===Ss,o),c===null)return null;Co.copy(o),Co.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Co);return l<t.near||l>t.far?null:{distance:l,point:Co.clone(),object:s}}function Io(s,e,t,n,i,r,a,o,c,l){s.getVertexPosition(o,Ao),s.getVertexPosition(c,To),s.getVertexPosition(l,Ro);const h=J2(s,e,t,n,Ao,To,Ro,C0);if(h){const u=new C;Zn.getBarycoord(C0,Ao,To,Ro,u),i&&(h.uv=Zn.getInterpolatedAttribute(i,o,c,l,u,new Ae)),r&&(h.uv1=Zn.getInterpolatedAttribute(r,o,c,l,u,new Ae)),a&&(h.normal=Zn.getInterpolatedAttribute(a,o,c,l,u,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new C,materialIndex:0};Zn.getNormal(Ao,To,Ro,d.normal),h.face=d,h.barycoord=u}return h}const ha=new nt,I0=new nt,P0=new nt,j2=new nt,L0=new Ye,Po=new C,Dl=new ji,N0=new Ye,Cl=new Za;class UE extends We{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=o0,this.bindMatrix=new Ye,this.bindMatrixInverse=new Ye,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new hi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Po),this.boundingBox.expandByPoint(Po)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new ji),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Po),this.boundingSphere.expandByPoint(Po)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Dl.copy(this.boundingSphere),Dl.applyMatrix4(i),e.ray.intersectsSphere(Dl)!==!1&&(N0.copy(i).invert(),Cl.copy(e.ray).applyMatrix4(N0),!(this.boundingBox!==null&&Cl.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Cl)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new nt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===o0?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Q1?this.bindMatrixInverse.copy(this.bindMatrix).invert():we("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;I0.fromBufferAttribute(i.attributes.skinIndex,e),P0.fromBufferAttribute(i.attributes.skinWeight,e),t.isVector4?(ha.copy(t),t.set(0,0,0,0)):(ha.set(...t,1),t.set(0,0,0)),ha.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=P0.getComponent(r);if(a!==0){const o=I0.getComponent(r);L0.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(j2.copy(ha).applyMatrix4(L0),a)}}return t.isVector4&&(t.w=ha.w),t.applyMatrix4(this.bindMatrixInverse)}}class Q2 extends bt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class js extends on{constructor(e=null,t=1,n=1,i,r,a,o,c,l=Tt,h=Tt,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const O0=new Ye,ev=new Ye;class xm{constructor(e=[],t=[]){this.uuid=ci(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){we("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ye)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ye;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=e.length;r<a;r++){const o=e[r]?e[r].matrixWorld:ev;O0.multiplyMatrices(o,t[r]),O0.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new xm(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new js(t,e,e,_n,Tn);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let a=t[r];a===void 0&&(we("Skeleton: No bone found with UUID:",r),a=new Q2),this.bones.push(a),this.boneInverses.push(new Ye().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const a=t[i];e.bones.push(a.uuid);const o=n[i];e.boneInverses.push(o.toArray())}return e}}class U0 extends rt{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const _r=new Ye,F0=new Ye,Lo=[],k0=new hi,tv=new Ye,ua=new We,da=new ji;class FE extends We{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new U0(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,tv)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new hi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_r),k0.copy(e.boundingBox).applyMatrix4(_r),this.boundingBox.union(k0)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new ji),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,_r),da.copy(e.boundingSphere).applyMatrix4(_r),this.boundingSphere.union(da)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){return this.instanceColor===null?t.setRGB(1,1,1):t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){return t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=e*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(e,t){const n=this.matrixWorld,i=this.count;if(ua.geometry=this.geometry,ua.material=this.material,ua.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),da.copy(this.boundingSphere),da.applyMatrix4(n),e.ray.intersectsSphere(da)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,_r),F0.multiplyMatrices(n,_r),ua.matrixWorld=F0,ua.raycast(e,Lo);for(let a=0,o=Lo.length;a<o;a++){const c=Lo[a];c.instanceId=r,c.object=this,t.push(c)}Lo.length=0}}setColorAt(e,t){return this.instanceColor===null&&(this.instanceColor=new U0(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3),this}setMatrixAt(e,t){return t.toArray(this.instanceMatrix.array,e*16),this}setMorphAt(e,t){const n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new js(new Float32Array(i*this.count),i,this.count,Vc,Tn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=i*e;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Il=new C,nv=new C,iv=new Be;class Ls{constructor(e=new C(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Il.subVectors(n,t).cross(nv.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const i=e.delta(Il),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||iv.getNormalMatrix(e),i=this.coplanarPoint(Il).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Cs=new ji,sv=new Ae(.5,.5),No=new C;class rd{constructor(e=new Ls,t=new Ls,n=new Ls,i=new Ls,r=new Ls,a=new Ls){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Ri,n=!1){const i=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],p=r[8],v=r[9],m=r[10],g=r[11],S=r[12],b=r[13],_=r[14],E=r[15];if(i[0].setComponents(l-a,f-h,g-p,E-S).normalize(),i[1].setComponents(l+a,f+h,g+p,E+S).normalize(),i[2].setComponents(l+o,f+u,g+v,E+b).normalize(),i[3].setComponents(l-o,f-u,g-v,E-b).normalize(),n)i[4].setComponents(c,d,m,_).normalize(),i[5].setComponents(l-c,f-d,g-m,E-_).normalize();else if(i[4].setComponents(l-c,f-d,g-m,E-_).normalize(),t===Ri)i[5].setComponents(l+c,f+d,g+m,E+_).normalize();else if(t===Ya)i[5].setComponents(c,d,m,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Cs.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Cs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Cs)}intersectsSprite(e){Cs.center.set(0,0,0);const t=sv.distanceTo(e.center);return Cs.radius=.7071067811865476+t,Cs.applyMatrix4(e.matrixWorld),this.intersectsSphere(Cs)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(No.x=i.normal.x>0?e.max.x:e.min.x,No.y=i.normal.y>0?e.max.y:e.min.y,No.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(No)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class rv extends Qi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new oe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Dc=new C,Cc=new C,z0=new Ye,fa=new Za,Oo=new ji,Pl=new C,B0=new C;class _m extends bt{constructor(e=new yt,t=new rv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Dc.fromBufferAttribute(t,i-1),Cc.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Dc.distanceTo(Cc);e.setAttribute("lineDistance",new It(n,1))}else we("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Oo.copy(n.boundingSphere),Oo.applyMatrix4(i),Oo.radius+=r,e.ray.intersectsSphere(Oo)===!1)return;z0.copy(i).invert(),fa.copy(e.ray).applyMatrix4(z0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),S=h.getX(v+1),b=Uo(this,e,fa,c,g,S,v);b&&t.push(b)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=Uo(this,e,fa,c,v,m,p-1);g&&t.push(g)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,m=p-1;v<m;v+=l){const g=Uo(this,e,fa,c,v,v+1,v);g&&t.push(g)}if(this.isLineLoop){const v=Uo(this,e,fa,c,p-1,f,p-1);v&&t.push(v)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Uo(s,e,t,n,i,r,a){const o=s.geometry.attributes.position;if(Dc.fromBufferAttribute(o,i),Cc.fromBufferAttribute(o,r),t.distanceSqToSegment(Dc,Cc,Pl,B0)>n)return;Pl.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(Pl);if(!(l<e.near||l>e.far))return{distance:l,point:B0.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const H0=new C,G0=new C;class kE extends _m{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)H0.fromBufferAttribute(t,i),G0.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+H0.distanceTo(G0);e.setAttribute("lineDistance",new It(n,1))}else we("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class zE extends _m{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class ad extends Qi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new oe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const V0=new Ye,cu=new Za,Fo=new ji,ko=new C;class Na extends bt{constructor(e=new yt,t=new ad){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Fo.copy(n.boundingSphere),Fo.applyMatrix4(i),Fo.radius+=r,e.ray.intersectsSphere(Fo)===!1)return;V0.copy(i).invert(),cu.copy(e.ray).applyMatrix4(V0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);ko.fromBufferAttribute(u,m),W0(ko,m,c,i,e,t,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let p=d,v=f;p<v;p++)ko.fromBufferAttribute(u,p),W0(ko,p,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function W0(s,e,t,n,i,r,a){const o=cu.distanceSqToPoint(s);if(o<t){const c=new C;cu.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class ym extends on{constructor(e=[],t=qs,n,i,r,a,o,c,l,h){super(e,t,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Li extends on{constructor(e,t,n,i,r,a,o,c,l){super(e,t,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ks extends on{constructor(e,t,n=li,i,r,a,o=Tt,c=Tt,l,h=Zi,u=1){if(h!==Zi&&h!==Hs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,i,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new nd(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class av extends Ks{constructor(e,t=li,n=qs,i,r,a=Tt,o=Tt,c,l=Zi){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,i,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class Sm extends on{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class jn extends yt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,n,t,e,a,r,0),p("z","y","x",1,-1,n,t,-e,a,r,1),p("x","z","y",1,1,e,n,t,i,a,2),p("x","z","y",1,-1,e,n,-t,i,a,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new It(l,3)),this.setAttribute("normal",new It(h,3)),this.setAttribute("uv",new It(u,2));function p(v,m,g,S,b,_,E,w,R,M,A){const I=_/R,D=E/M,P=_/2,F=E/2,H=w/2,O=R+1,V=M+1;let z=0,Y=0;const ee=new C;for(let J=0;J<V;J++){const ne=J*D-F;for(let ae=0;ae<O;ae++){const Ve=ae*I-P;ee[v]=Ve*S,ee[m]=ne*b,ee[g]=H,l.push(ee.x,ee.y,ee.z),ee[v]=0,ee[m]=0,ee[g]=w>0?1:-1,h.push(ee.x,ee.y,ee.z),u.push(ae/R),u.push(1-J/M),z+=1}}for(let J=0;J<M;J++)for(let ne=0;ne<R;ne++){const ae=d+ne+O*J,Ve=d+ne+O*(J+1),je=d+(ne+1)+O*(J+1),He=d+(ne+1)+O*J;c.push(ae,Ve,He),c.push(Ve,je,He),Y+=6}o.addGroup(f,Y,A),f+=Y,d+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new jn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class od extends yt{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],c=[],l=new C,h=new Ae;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const f=n+u/t*i;l.x=e*Math.cos(f),l.y=e*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new It(a,3)),this.setAttribute("normal",new It(o,3)),this.setAttribute("uv",new It(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new od(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class es extends yt{constructor(e=1,t=1,n=1,i=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=n/2;let g=0;S(),a===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(h),this.setAttribute("position",new It(u,3)),this.setAttribute("normal",new It(d,3)),this.setAttribute("uv",new It(f,2));function S(){const _=new C,E=new C;let w=0;const R=(t-e)/n;for(let M=0;M<=r;M++){const A=[],I=M/r,D=I*(t-e)+e;for(let P=0;P<=i;P++){const F=P/i,H=F*c+o,O=Math.sin(H),V=Math.cos(H);E.x=D*O,E.y=-I*n+m,E.z=D*V,u.push(E.x,E.y,E.z),_.set(O,R,V).normalize(),d.push(_.x,_.y,_.z),f.push(F,1-I),A.push(p++)}v.push(A)}for(let M=0;M<i;M++)for(let A=0;A<r;A++){const I=v[A][M],D=v[A+1][M],P=v[A+1][M+1],F=v[A][M+1];(e>0||A!==0)&&(h.push(I,D,F),w+=3),(t>0||A!==r-1)&&(h.push(D,P,F),w+=3)}l.addGroup(g,w,0),g+=w}function b(_){const E=p,w=new Ae,R=new C;let M=0;const A=_===!0?e:t,I=_===!0?1:-1;for(let P=1;P<=i;P++)u.push(0,m*I,0),d.push(0,I,0),f.push(.5,.5),p++;const D=p;for(let P=0;P<=i;P++){const H=P/i*c+o,O=Math.cos(H),V=Math.sin(H);R.x=A*V,R.y=m*I,R.z=A*O,u.push(R.x,R.y,R.z),d.push(0,I,0),w.x=O*.5+.5,w.y=V*.5*I+.5,f.push(w.x,w.y),p++}for(let P=0;P<i;P++){const F=E+P,H=D+P;_===!0?h.push(H,H+1,F):h.push(H+1,H,F),M+=3}l.addGroup(g,M,_===!0?1:2),g+=M}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new es(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ja extends es{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Ja(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ui extends yt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(i),l=o+1,h=c+1,u=e/o,d=t/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const S=g*d-a;for(let b=0;b<l;b++){const _=b*u-r;p.push(_,-S,0),v.push(0,0,1),m.push(b/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let S=0;S<o;S++){const b=S+l*g,_=S+l*(g+1),E=S+1+l*(g+1),w=S+1+l*g;f.push(b,_,w),f.push(_,E,w)}this.setIndex(f),this.setAttribute("position",new It(p,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ui(e.width,e.height,e.widthSegments,e.heightSegments)}}class fn extends yt{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new C,d=new C,f=[],p=[],v=[],m=[];for(let g=0;g<=n;g++){const S=[],b=g/n,_=a+b*o,E=e*Math.cos(_),w=Math.sqrt(e*e-E*E);let R=0;g===0&&a===0?R=.5/t:g===n&&c===Math.PI&&(R=-.5/t);for(let M=0;M<=t;M++){const A=M/t,I=i+A*r;u.x=-w*Math.cos(I),u.y=E,u.z=w*Math.sin(I),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+R,1-b),S.push(l++)}h.push(S)}for(let g=0;g<n;g++)for(let S=0;S<t;S++){const b=h[g][S+1],_=h[g][S],E=h[g+1][S],w=h[g+1][S+1];(g!==0||a>0)&&f.push(b,_,w),(g!==n-1||c<Math.PI)&&f.push(_,E,w)}this.setIndex(f),this.setAttribute("position",new It(p,3)),this.setAttribute("normal",new It(v,3)),this.setAttribute("uv",new It(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Jr(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];if(X0(i))i.isRenderTargetTexture?(we("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone();else if(Array.isArray(i))if(X0(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();e[t][n]=r}else e[t][n]=i.slice();else e[t][n]=i}}return e}function Sn(s){const e={};for(let t=0;t<s.length;t++){const n=Jr(s[t]);for(const i in n)e[i]=n[i]}return e}function X0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function ov(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function bm(s){const e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:et.workingColorSpace}const cv={clone:Jr,merge:Sn};var lv=`void main() {
608
608
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
609
609
  }`,hv=`void main() {
610
610
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
611
- }`;class Rt extends Qi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=lv,this.fragmentShader=hv,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Jr(e.uniforms),this.uniformsGroups=ov(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ae().fromArray(i.value);break;case"v3":this.uniforms[n].value=new C().fromArray(i.value);break;case"v4":this.uniforms[n].value=new nt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ye().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Em extends Rt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class uv extends Qi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Sc,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ji,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class BE extends uv{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ae(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class ja extends Qi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Sc,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ji,this.combine=qu,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class dv extends Qi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=n2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class fv extends Qi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function zo(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function pv(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function q0(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let c=0;c!==e;++c)i[a++]=s[o+c]}return i}function mv(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}class Qa{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break e}a=t.length;break t}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class gv extends Qa{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:l0,endingEnd:l0}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,a=e+1,o=i[r],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case h0:r=e,o=2*t-n;break;case u0:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case h0:a=e,c=2*n-t;break;case u0:a=1,c=n+i[1]-i[0];break;default:a=e-1,c=t}const l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(i-t),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,S=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,b=(-1-f)*m+(1.5+f)*v+.5*p,_=f*m-f*v;for(let E=0;E!==o;++E)r[E]=g*a[h+E]+S*a[l+E]+b*a[c+E]+_*a[u+E];return r}}class vv extends Qa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class Mv extends Qa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class xv extends Qa{interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(n-t)/(i-t),v=1-p;for(let m=0;m!==o;++m)r[m]=a[l+m]*v+a[c+m]*p;return r}const d=o*2,f=e-1;for(let p=0;p!==o;++p){const v=a[l+p],m=a[c+p],g=f*d+p*2,S=u[g],b=u[g+1],_=e*d+p*2,E=h[_],w=h[_+1];let R=(n-t)/(i-t),M,A,I,D,P;for(let F=0;F<8;F++){M=R*R,A=M*R,I=1-R,D=I*I,P=D*I;const O=P*t+3*D*R*S+3*I*M*E+A*i-n;if(Math.abs(O)<1e-10)break;const V=3*D*(S-t)+6*I*R*(E-S)+3*M*(i-E);if(Math.abs(V)<1e-10)break;R=R-O/V,R=Math.max(0,Math.min(1,R))}r[p]=P*v+3*D*R*b+3*I*M*w+A*m}return r}}class di{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=zo(t,this.TimeBufferType),this.values=zo(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:zo(e.times,Array),values:zo(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Mv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new vv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new gv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new xv(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case yc:t=this.InterpolantFactoryMethodDiscrete;break;case au:t=this.InterpolantFactoryMethodLinear;break;case al:t=this.InterpolantFactoryMethodSmooth;break;case c0:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return we("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yc;case this.InterpolantFactoryMethodLinear:return au;case this.InterpolantFactoryMethodSmooth:return al;case this.InterpolantFactoryMethodBezier:return c0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ke("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(ke("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){ke("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){ke("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(i!==void 0&&u2(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){ke("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===al,r=e.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(i)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let p=0;p!==n;++p){const v=t[u+p];if(v!==t[d+p]||v!==t[f+p]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}di.prototype.ValueTypeName="";di.prototype.TimeBufferType=Float32Array;di.prototype.ValueBufferType=Float32Array;di.prototype.DefaultInterpolation=au;class Qr extends di{constructor(e,t,n){super(e,t,n)}}Qr.prototype.ValueTypeName="bool";Qr.prototype.ValueBufferType=Array;Qr.prototype.DefaultInterpolation=yc;Qr.prototype.InterpolantFactoryMethodLinear=void 0;Qr.prototype.InterpolantFactoryMethodSmooth=void 0;class wm extends di{constructor(e,t,n,i){super(e,t,n,i)}}wm.prototype.ValueTypeName="color";class cd extends di{constructor(e,t,n,i){super(e,t,n,i)}}cd.prototype.ValueTypeName="number";class _v extends Qa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let h=l+o;l!==h;l+=4)Es.slerpFlat(r,0,a,l-o,a,l,c);return r}}class ld extends di{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new _v(this.times,this.values,this.getValueSize(),e)}}ld.prototype.ValueTypeName="quaternion";ld.prototype.InterpolantFactoryMethodSmooth=void 0;class ea extends di{constructor(e,t,n){super(e,t,n)}}ea.prototype.ValueTypeName="string";ea.prototype.ValueBufferType=Array;ea.prototype.DefaultInterpolation=yc;ea.prototype.InterpolantFactoryMethodLinear=void 0;ea.prototype.InterpolantFactoryMethodSmooth=void 0;class Am extends di{constructor(e,t,n,i){super(e,t,n,i)}}Am.prototype.ValueTypeName="vector";class HE{constructor(e="",t=-1,n=[],i=t2){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ci(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Sv(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(di.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=pv(c);c=q0(c,1,h),l=q0(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new cd(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function yv(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return cd;case"vector":case"vector2":case"vector3":case"vector4":return Am;case"color":return wm;case"quaternion":return ld;case"bool":case"boolean":return Qr;case"string":return ea}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Sv(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=yv(s.type);if(s.times===void 0){const t=[],n=[];mv(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Yi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(Y0(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!Y0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function Y0(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class bv{constructor(e,t,n){const i=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const Ev=new bv;class eo{constructor(e){this.manager=e!==void 0?e:Ev,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}eo.DEFAULT_MATERIAL_NAME="__DEFAULT";const zi={};class wv extends Error{constructor(e,t){super(e),this.response=t}}class GE extends eo{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Yi.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(zi[e]!==void 0){zi[e].push({onLoad:t,onProgress:n,onError:i});return}zi[e]=[],zi[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&we("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=zi[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){S();function S(){u.read().then(({done:b,value:_})=>{if(b)g.close();else{v+=_.byteLength;const E=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let w=0,R=h.length;w<R;w++){const M=h[w];M.onProgress&&M.onProgress(E)}g.enqueue(_),S()}},b=>{g.error(b)})}}});return new Response(m)}else throw new wv(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{Yi.add(`file:${e}`,l);const h=zi[e];delete zi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=zi[e];if(h===void 0)throw this.manager.itemError(e),l;delete zi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const yr=new WeakMap;class Av extends eo{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Yi.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=yr.get(a);u===void 0&&(u=[],yr.set(a,u)),u.push({onLoad:t,onError:i})}return a}const o=Ka("img");function c(){h(),t&&t(this);const u=yr.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}yr.delete(this),r.manager.itemEnd(e)}function l(u){h(),i&&i(u),Yi.remove(`image:${e}`);const d=yr.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}yr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Yi.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class VE extends eo{constructor(e){super(e)}load(e,t,n,i){const r=new on,a=new Av(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Wc extends bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Tv extends Wc{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Ll=new Ye,K0=new C,$0=new C;class hd{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ae(512,512),this.mapType=Hn,this.map=null,this.mapPass=null,this.matrix=new Ye,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rd,this._frameExtents=new Ae(1,1),this._viewportCount=1,this._viewports=[new nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;K0.setFromMatrixPosition(e.matrixWorld),t.position.copy(K0),$0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt($0),t.updateMatrixWorld(),Ll.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ll,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Ya||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ll)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Bo=new C,Ho=new Es,vi=new C;class Tm extends bt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ye,this.projectionMatrix=new Ye,this.projectionMatrixInverse=new Ye,this.coordinateSystem=Ri,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Bo,Ho,vi),vi.x===1&&vi.y===1&&vi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Bo,Ho,vi.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Bo,Ho,vi),vi.x===1&&vi.y===1&&vi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Bo,Ho,vi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ls=new C,Z0=new Ae,J0=new Ae;class Nn extends Tm{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=$r*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Pa*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $r*2*Math.atan(Math.tan(Pa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ls.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ls.x,ls.y).multiplyScalar(-e/ls.z),ls.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ls.x,ls.y).multiplyScalar(-e/ls.z)}getViewSize(e,t){return this.getViewBounds(e,Z0,J0),t.subVectors(J0,Z0)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Pa*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,t-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Rv extends hd{constructor(){super(new Nn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=$r*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class WE extends Wc{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Rv}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class Dv extends hd{constructor(){super(new Nn(90,1,.5,500)),this.isPointLightShadow=!0}}class Cv extends Wc{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Dv}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class ws extends Tm{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Iv extends hd{constructor(){super(new ws(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class j0 extends Wc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.shadow=new Iv}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class XE{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const Nl=new WeakMap;class qE extends eo{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&we("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&we("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Yi.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{Nl.has(a)===!0?(i&&i(Nl.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Yi.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e)}).catch(function(l){i&&i(l),Nl.set(c,l),Yi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Yi.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Sr=-90,br=1;class Pv extends bt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Nn(Sr,br,e,t);i.layers=this.layers,this.add(i);const r=new Nn(Sr,br,e,t);r.layers=this.layers,this.add(r);const a=new Nn(Sr,br,e,t);a.layers=this.layers,this.add(a);const o=new Nn(Sr,br,e,t);o.layers=this.layers,this.add(o);const c=new Nn(Sr,br,e,t);c.layers=this.layers,this.add(c);const l=new Nn(Sr,br,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Ri)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Ya)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Lv extends Nn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const ud="\\[\\]\\.:\\/",Nv=new RegExp("["+ud+"]","g"),dd="[^"+ud+"]",Ov="[^"+ud.replace("\\.","")+"]",Uv=/((?:WC+[\/:])*)/.source.replace("WC",dd),Fv=/(WCOD+)?/.source.replace("WCOD",Ov),kv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dd),zv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dd),Bv=new RegExp("^"+Uv+Fv+kv+zv+"$"),Hv=["material","materials","bones","map"];class Gv{constructor(e,t,n){const i=n||pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class pt{constructor(e,t,n){this.path=t,this.parsedPath=n||pt.parseTrackName(t),this.node=pt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new pt.Composite(e,t,n):new pt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Nv,"")}static parseTrackName(e){const t=Bv.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);Hv.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const c=n(o.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=pt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){we("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ke("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[i];if(a===void 0){const l=t.nodeName;ke("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}pt.Composite=Gv;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Q0=new Ye;class Ol{constructor(e,t,n=0,i=1/0){this.ray=new Za(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new id,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):ke("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Q0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Q0),this}intersectObject(e,t=!0,n=[]){return lu(e,this,n,t),n.sort(ef),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)lu(e[i],this,n,t);return n.sort(ef),n}}function ef(s,e){return s.distance-e.distance}function lu(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)lu(r[a],e,t,!0)}}class Rm{static{Rm.prototype.isMatrix2=!0}constructor(e,t,n,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}function tf(s,e,t,n){const i=Vv(n);switch(t){case um:return s*e;case Vc:return s*e/i.components*i.byteLength;case Zu:return s*e/i.components*i.byteLength;case Ys:return s*e*2/i.components*i.byteLength;case Ju:return s*e*2/i.components*i.byteLength;case dm:return s*e*3/i.components*i.byteLength;case _n:return s*e*4/i.components*i.byteLength;case ju:return s*e*4/i.components*i.byteLength;case cc:case lc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case hc:case uc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Ih:case Lh:return Math.max(s,16)*Math.max(e,8)/4;case Ch:case Ph:return Math.max(s,8)*Math.max(e,8)/2;case Nh:case Oh:case Fh:case kh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Uh:case xc:case zh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Bh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Hh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Gh:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Vh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Wh:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Xh:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case qh:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case Yh:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Kh:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case $h:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Zh:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Jh:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case jh:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case Qh:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case eu:case tu:case nu:return Math.ceil(s/4)*Math.ceil(e/4)*16;case iu:case su:return Math.ceil(s/4)*Math.ceil(e/4)*8;case _c:case ru:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Vv(s){switch(s){case Hn:case om:return{byteLength:1,components:1};case Xa:case cm:case cn:return{byteLength:2,components:1};case Ku:case $u:return{byteLength:2,components:4};case li:case Yu:case Tn:return{byteLength:4,components:1};case lm:case hm:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Xu}}));typeof window<"u"&&(window.__THREE__?we("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Xu);/**
611
+ }`;class Rt extends Qi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=lv,this.fragmentShader=hv,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Jr(e.uniforms),this.uniformsGroups=ov(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?t.uniforms[i]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[i]={type:"m4",value:a.toArray()}:t.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const i=e.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=t[i.value]||null;break;case"c":this.uniforms[n].value=new oe().setHex(i.value);break;case"v2":this.uniforms[n].value=new Ae().fromArray(i.value);break;case"v3":this.uniforms[n].value=new C().fromArray(i.value);break;case"v4":this.uniforms[n].value=new nt().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Be().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Ye().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Em extends Rt{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class uv extends Qi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new oe(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Sc,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ji,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class BE extends uv{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ae(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Je(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new oe(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new oe(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new oe(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class ja extends Qi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new oe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new oe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Sc,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ji,this.combine=qu,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class dv extends Qi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=n2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class fv extends Qi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function zo(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function pv(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function q0(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=t[r]*e;for(let c=0;c!==e;++c)i[a++]=s[o+c]}return i}function mv(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(e.push(r.time),t.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(e.push(r.time),a.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(e.push(r.time),t.push(a)),r=s[i++];while(r!==void 0)}class Qa{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<i)){for(let o=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=t[++n],e<i)break e}a=t.length;break t}if(!(e>=r)){const o=t[1];e<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){const o=n+a>>>1;e<t[o]?a=o:n=o+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let a=0;a!==i;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class gv extends Qa{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:l0,endingEnd:l0}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,a=e+1,o=i[r],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case h0:r=e,o=2*t-n;break;case u0:r=i.length-2,o=t+i[r]-i[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case h0:a=e,c=2*n-t;break;case u0:a=1,c=n+i[1]-i[0];break;default:a=e-1,c=t}const l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-t)/(i-t),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,S=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,b=(-1-f)*m+(1.5+f)*v+.5*p,_=f*m-f*v;for(let E=0;E!==o;++E)r[E]=g*a[h+E]+S*a[l+E]+b*a[c+E]+_*a[u+E];return r}}class vv extends Qa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class Mv extends Qa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class xv extends Qa{interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(n-t)/(i-t),v=1-p;for(let m=0;m!==o;++m)r[m]=a[l+m]*v+a[c+m]*p;return r}const d=o*2,f=e-1;for(let p=0;p!==o;++p){const v=a[l+p],m=a[c+p],g=f*d+p*2,S=u[g],b=u[g+1],_=e*d+p*2,E=h[_],w=h[_+1];let R=(n-t)/(i-t),M,A,I,D,P;for(let F=0;F<8;F++){M=R*R,A=M*R,I=1-R,D=I*I,P=D*I;const O=P*t+3*D*R*S+3*I*M*E+A*i-n;if(Math.abs(O)<1e-10)break;const V=3*D*(S-t)+6*I*R*(E-S)+3*M*(i-E);if(Math.abs(V)<1e-10)break;R=R-O/V,R=Math.max(0,Math.min(1,R))}r[p]=P*v+3*D*R*b+3*I*M*w+A*m}return r}}class di{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=zo(t,this.TimeBufferType),this.values=zo(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:zo(e.times,Array),values:zo(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Mv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new vv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new gv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){const t=new xv(this.times,this.values,this.getValueSize(),e);return this.settings&&(t.inTangents=this.settings.inTangents,t.outTangents=this.settings.outTangents),t}setInterpolation(e){let t;switch(e){case yc:t=this.InterpolantFactoryMethodDiscrete;break;case au:t=this.InterpolantFactoryMethodLinear;break;case al:t=this.InterpolantFactoryMethodSmooth;break;case c0:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return we("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return yc;case this.InterpolantFactoryMethodLinear:return au;case this.InterpolantFactoryMethodSmooth:return al;case this.InterpolantFactoryMethodBezier:return c0}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(ke("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(ke("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){ke("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){ke("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(i!==void 0&&u2(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){ke("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===al,r=e.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(i)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let p=0;p!==n;++p){const v=t[u+p];if(v!==t[d+p]||v!==t[f+p]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++a}}if(r>0){e[a]=e[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)t[c+l]=t[o+l];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}di.prototype.ValueTypeName="";di.prototype.TimeBufferType=Float32Array;di.prototype.ValueBufferType=Float32Array;di.prototype.DefaultInterpolation=au;class Qr extends di{constructor(e,t,n){super(e,t,n)}}Qr.prototype.ValueTypeName="bool";Qr.prototype.ValueBufferType=Array;Qr.prototype.DefaultInterpolation=yc;Qr.prototype.InterpolantFactoryMethodLinear=void 0;Qr.prototype.InterpolantFactoryMethodSmooth=void 0;class wm extends di{constructor(e,t,n,i){super(e,t,n,i)}}wm.prototype.ValueTypeName="color";class cd extends di{constructor(e,t,n,i){super(e,t,n,i)}}cd.prototype.ValueTypeName="number";class _v extends Qa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(i-t);let l=e*o;for(let h=l+o;l!==h;l+=4)Es.slerpFlat(r,0,a,l-o,a,l,c);return r}}class ld extends di{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new _v(this.times,this.values,this.getValueSize(),e)}}ld.prototype.ValueTypeName="quaternion";ld.prototype.InterpolantFactoryMethodSmooth=void 0;class ea extends di{constructor(e,t,n){super(e,t,n)}}ea.prototype.ValueTypeName="string";ea.prototype.ValueBufferType=Array;ea.prototype.DefaultInterpolation=yc;ea.prototype.InterpolantFactoryMethodLinear=void 0;ea.prototype.InterpolantFactoryMethodSmooth=void 0;class Am extends di{constructor(e,t,n,i){super(e,t,n,i)}}Am.prototype.ValueTypeName="vector";class HE{constructor(e="",t=-1,n=[],i=t2){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ci(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Sv(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let r=0,a=n.length;r!==a;++r)t.push(di.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=pv(c);c=q0(c,1,h),l=q0(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new cd(".morphTargetInfluences["+t[o].name+"]",c,l).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=e.length;o<c;o++){const l=e[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function yv(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return cd;case"vector":case"vector2":case"vector3":case"vector4":return Am;case"color":return wm;case"quaternion":return ld;case"bool":case"boolean":return Qr;case"string":return ea}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Sv(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=yv(s.type);if(s.times===void 0){const t=[],n=[];mv(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const Yi={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(Y0(s)||(this.files[s]=e))},get:function(s){if(this.enabled!==!1&&!Y0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function Y0(s){try{const e=s.slice(s.indexOf(":")+1);return new URL(e).protocol==="blob:"}catch{return!1}}class bv{constructor(e,t,n){const i=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const Ev=new bv;class eo{constructor(e){this.manager=e!==void 0?e:Ev,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}eo.DEFAULT_MATERIAL_NAME="__DEFAULT";const zi={};class wv extends Error{constructor(e,t){super(e),this.response=t}}class GE extends eo{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=Yi.get(`file:${e}`);if(r!==void 0){this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0);return}if(zi[e]!==void 0){zi[e].push({onLoad:t,onProgress:n,onError:i});return}zi[e]=[],zi[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&we("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=zi[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,p=f!==0;let v=0;const m=new ReadableStream({start(g){S();function S(){u.read().then(({done:b,value:_})=>{if(b)g.close();else{v+=_.byteLength;const E=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let w=0,R=h.length;w<R;w++){const M=h[w];M.onProgress&&M.onProgress(E)}g.enqueue(_),S()}},b=>{g.error(b)})}}});return new Response(m)}else throw new wv(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o==="")return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(p=>f.decode(p))}}}).then(l=>{Yi.add(`file:${e}`,l);const h=zi[e];delete zi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=zi[e];if(h===void 0)throw this.manager.itemError(e),l;delete zi[e];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const yr=new WeakMap;class Av extends eo{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Yi.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(e),setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);else{let u=yr.get(a);u===void 0&&(u=[],yr.set(a,u)),u.push({onLoad:t,onError:i})}return a}const o=Ka("img");function c(){h(),t&&t(this);const u=yr.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}yr.delete(this),r.manager.itemEnd(e)}function l(u){h(),i&&i(u),Yi.remove(`image:${e}`);const d=yr.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}yr.delete(this),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Yi.add(`image:${e}`,o),r.manager.itemStart(e),o.src=e,o}}class VE extends eo{constructor(e){super(e)}load(e,t,n,i){const r=new on,a=new Av(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(o){r.image=o,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Wc extends bt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new oe(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Tv extends Wc{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new oe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Ll=new Ye,K0=new C,$0=new C;class hd{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ae(512,512),this.mapType=Hn,this.map=null,this.mapPass=null,this.matrix=new Ye,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new rd,this._frameExtents=new Ae(1,1),this._viewportCount=1,this._viewports=[new nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;K0.setFromMatrixPosition(e.matrixWorld),t.position.copy(K0),$0.setFromMatrixPosition(e.target.matrixWorld),t.lookAt($0),t.updateMatrixWorld(),Ll.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ll,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===Ya||t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ll)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Bo=new C,Ho=new Es,vi=new C;class Tm extends bt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ye,this.projectionMatrix=new Ye,this.projectionMatrixInverse=new Ye,this.coordinateSystem=Ri,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Bo,Ho,vi),vi.x===1&&vi.y===1&&vi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Bo,Ho,vi.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Bo,Ho,vi),vi.x===1&&vi.y===1&&vi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Bo,Ho,vi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const ls=new C,Z0=new Ae,J0=new Ae;class Nn extends Tm{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=$r*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Pa*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $r*2*Math.atan(Math.tan(Pa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){ls.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(ls.x,ls.y).multiplyScalar(-e/ls.z),ls.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(ls.x,ls.y).multiplyScalar(-e/ls.z)}getViewSize(e,t){return this.getViewBounds(e,Z0,J0),t.subVectors(J0,Z0)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Pa*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,t-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Rv extends hd{constructor(){super(new Nn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=$r*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class WE extends Wc{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new Rv}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class Dv extends hd{constructor(){super(new Nn(90,1,.5,500)),this.isPointLightShadow=!0}}class Cv extends Wc{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Dv}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class ws extends Tm{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class Iv extends hd{constructor(){super(new ws(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class j0 extends Wc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(bt.DEFAULT_UP),this.updateMatrix(),this.target=new bt,this.shadow=new Iv}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class XE{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}const Nl=new WeakMap;class qE extends eo{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&we("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&we("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=Yi.get(`image-bitmap:${e}`);if(a!==void 0){if(r.manager.itemStart(e),a.then){a.then(l=>{Nl.has(a)===!0?(i&&i(Nl.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)):(t&&t(l),r.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(e,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Yi.add(`image-bitmap:${e}`,l),t&&t(l),r.manager.itemEnd(e)}).catch(function(l){i&&i(l),Nl.set(c,l),Yi.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});Yi.add(`image-bitmap:${e}`,c),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Sr=-90,br=1;class Pv extends bt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Nn(Sr,br,e,t);i.layers=this.layers,this.add(i);const r=new Nn(Sr,br,e,t);r.layers=this.layers,this.add(r);const a=new Nn(Sr,br,e,t);a.layers=this.layers,this.add(a);const o=new Nn(Sr,br,e,t);o.layers=this.layers,this.add(o);const c=new Nn(Sr,br,e,t);c.layers=this.layers,this.add(c);const l=new Nn(Sr,br,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,o,c]=t;for(const l of t)this.remove(l);if(e===Ri)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Ya)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class Lv extends Nn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const ud="\\[\\]\\.:\\/",Nv=new RegExp("["+ud+"]","g"),dd="[^"+ud+"]",Ov="[^"+ud.replace("\\.","")+"]",Uv=/((?:WC+[\/:])*)/.source.replace("WC",dd),Fv=/(WCOD+)?/.source.replace("WCOD",Ov),kv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",dd),zv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",dd),Bv=new RegExp("^"+Uv+Fv+kv+zv+"$"),Hv=["material","materials","bones","map"];class Gv{constructor(e,t,n){const i=n||pt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class pt{constructor(e,t,n){this.path=t,this.parsedPath=n||pt.parseTrackName(t),this.node=pt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new pt.Composite(e,t,n):new pt(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Nv,"")}static parseTrackName(e){const t=Bv.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);Hv.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===t||o.uuid===t)return o;const c=n(o.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=pt.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){we("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ke("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const a=e[i];if(a===void 0){const l=t.nodeName;ke("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let o=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?o=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}pt.Composite=Gv;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const Q0=new Ye;class Ol{constructor(e,t,n=0,i=1/0){this.ray=new Za(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new id,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):ke("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Q0.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Q0),this}intersectObject(e,t=!0,n=[]){return lu(e,this,n,t),n.sort(ef),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)lu(e[i],this,n,t);return n.sort(ef),n}}function ef(s,e){return s.distance-e.distance}function lu(s,e,t,n){let i=!0;if(s.layers.test(e.layers)&&s.raycast(e,t)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)lu(r[a],e,t,!0)}}class Rm{static{Rm.prototype.isMatrix2=!0}constructor(e,t,n,i){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,i){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=i,this}}function tf(s,e,t,n){const i=Vv(n);switch(t){case um:return s*e;case Vc:return s*e/i.components*i.byteLength;case Zu:return s*e/i.components*i.byteLength;case Ys:return s*e*2/i.components*i.byteLength;case Ju:return s*e*2/i.components*i.byteLength;case dm:return s*e*3/i.components*i.byteLength;case _n:return s*e*4/i.components*i.byteLength;case ju:return s*e*4/i.components*i.byteLength;case cc:case lc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case hc:case uc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Ih:case Lh:return Math.max(s,16)*Math.max(e,8)/4;case Ch:case Ph:return Math.max(s,8)*Math.max(e,8)/2;case Nh:case Oh:case Fh:case kh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Uh:case xc:case zh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Bh:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Hh:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Gh:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case Vh:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Wh:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Xh:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case qh:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case Yh:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case Kh:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case $h:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Zh:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case Jh:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case jh:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case Qh:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case eu:case tu:case nu:return Math.ceil(s/4)*Math.ceil(e/4)*16;case iu:case su:return Math.ceil(s/4)*Math.ceil(e/4)*8;case _c:case ru:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Vv(s){switch(s){case Hn:case om:return{byteLength:1,components:1};case Xa:case cm:case cn:return{byteLength:2,components:1};case Ku:case $u:return{byteLength:2,components:4};case li:case Yu:case Tn:return{byteLength:4,components:1};case lm:case hm:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Xu}}));typeof window<"u"&&(window.__THREE__?we("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Xu);/**
612
612
  * @license
613
613
  * Copyright 2010-2026 Three.js Authors
614
614
  * SPDX-License-Identifier: MIT
@@ -4278,7 +4278,7 @@ void main() {
4278
4278
  #include <tonemapping_fragment>
4279
4279
  #include <colorspace_fragment>
4280
4280
  #include <fog_fragment>
4281
- }`,Ke={alphahash_fragment:Xv,alphahash_pars_fragment:qv,alphamap_fragment:Yv,alphamap_pars_fragment:Kv,alphatest_fragment:$v,alphatest_pars_fragment:Zv,aomap_fragment:Jv,aomap_pars_fragment:jv,batching_pars_vertex:Qv,batching_vertex:eM,begin_vertex:tM,beginnormal_vertex:nM,bsdfs:iM,iridescence_fragment:sM,bumpmap_pars_fragment:rM,clipping_planes_fragment:aM,clipping_planes_pars_fragment:oM,clipping_planes_pars_vertex:cM,clipping_planes_vertex:lM,color_fragment:hM,color_pars_fragment:uM,color_pars_vertex:dM,color_vertex:fM,common:pM,cube_uv_reflection_fragment:mM,defaultnormal_vertex:gM,displacementmap_pars_vertex:vM,displacementmap_vertex:MM,emissivemap_fragment:xM,emissivemap_pars_fragment:_M,colorspace_fragment:yM,colorspace_pars_fragment:SM,envmap_fragment:bM,envmap_common_pars_fragment:EM,envmap_pars_fragment:wM,envmap_pars_vertex:AM,envmap_physical_pars_fragment:FM,envmap_vertex:TM,fog_vertex:RM,fog_pars_vertex:DM,fog_fragment:CM,fog_pars_fragment:IM,gradientmap_pars_fragment:PM,lightmap_pars_fragment:LM,lights_lambert_fragment:NM,lights_lambert_pars_fragment:OM,lights_pars_begin:UM,lights_toon_fragment:kM,lights_toon_pars_fragment:zM,lights_phong_fragment:BM,lights_phong_pars_fragment:HM,lights_physical_fragment:GM,lights_physical_pars_fragment:VM,lights_fragment_begin:WM,lights_fragment_maps:XM,lights_fragment_end:qM,lightprobes_pars_fragment:YM,logdepthbuf_fragment:KM,logdepthbuf_pars_fragment:$M,logdepthbuf_pars_vertex:ZM,logdepthbuf_vertex:JM,map_fragment:jM,map_pars_fragment:QM,map_particle_fragment:ex,map_particle_pars_fragment:tx,metalnessmap_fragment:nx,metalnessmap_pars_fragment:ix,morphinstance_vertex:sx,morphcolor_vertex:rx,morphnormal_vertex:ax,morphtarget_pars_vertex:ox,morphtarget_vertex:cx,normal_fragment_begin:lx,normal_fragment_maps:hx,normal_pars_fragment:ux,normal_pars_vertex:dx,normal_vertex:fx,normalmap_pars_fragment:px,clearcoat_normal_fragment_begin:mx,clearcoat_normal_fragment_maps:gx,clearcoat_pars_fragment:vx,iridescence_pars_fragment:Mx,opaque_fragment:xx,packing:_x,premultiplied_alpha_fragment:yx,project_vertex:Sx,dithering_fragment:bx,dithering_pars_fragment:Ex,roughnessmap_fragment:wx,roughnessmap_pars_fragment:Ax,shadowmap_pars_fragment:Tx,shadowmap_pars_vertex:Rx,shadowmap_vertex:Dx,shadowmask_pars_fragment:Cx,skinbase_vertex:Ix,skinning_pars_vertex:Px,skinning_vertex:Lx,skinnormal_vertex:Nx,specularmap_fragment:Ox,specularmap_pars_fragment:Ux,tonemapping_fragment:Fx,tonemapping_pars_fragment:kx,transmission_fragment:zx,transmission_pars_fragment:Bx,uv_pars_fragment:Hx,uv_pars_vertex:Gx,uv_vertex:Vx,worldpos_vertex:Wx,background_vert:Xx,background_frag:qx,backgroundCube_vert:Yx,backgroundCube_frag:Kx,cube_vert:$x,cube_frag:Zx,depth_vert:Jx,depth_frag:jx,distance_vert:Qx,distance_frag:e3,equirect_vert:t3,equirect_frag:n3,linedashed_vert:i3,linedashed_frag:s3,meshbasic_vert:r3,meshbasic_frag:a3,meshlambert_vert:o3,meshlambert_frag:c3,meshmatcap_vert:l3,meshmatcap_frag:h3,meshnormal_vert:u3,meshnormal_frag:d3,meshphong_vert:f3,meshphong_frag:p3,meshphysical_vert:m3,meshphysical_frag:g3,meshtoon_vert:v3,meshtoon_frag:M3,points_vert:x3,points_frag:_3,shadow_vert:y3,shadow_frag:S3,sprite_vert:b3,sprite_frag:E3},pe={common:{diffuse:{value:new oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new oe(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},bi={basic:{uniforms:Sn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:Sn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:Sn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},specular:{value:new oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:Sn([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:Sn([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new oe(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:Sn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:Sn([pe.points,pe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:Sn([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:Sn([pe.common,pe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:Sn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:Sn([pe.sprite,pe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:Sn([pe.common,pe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:Sn([pe.lights,pe.fog,{color:{value:new oe(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};bi.physical={uniforms:Sn([bi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new oe(0)},specularColor:{value:new oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const Go={r:0,b:0,g:0},w3=new Ye,Cm=new ze;Cm.set(-1,0,0,0,1,0,0,0,1);function A3(s,e,t,n,i,r){const a=new oe(0);let o=i===!0?0:1,c,l,h=null,u=0,d=null;function f(S){let b=S.isScene===!0?S.background:null;if(b&&b.isTexture){const _=S.backgroundBlurriness>0;b=e.get(b,_)}return b}function p(S){let b=!1;const _=f(S);_===null?m(a,o):_&&_.isColor&&(m(_,1),b=!0);const E=s.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(S,b){const _=f(b);_&&(_.isCubeTexture||_.mapping===Gc)?(l===void 0&&(l=new We(new jn(1,1,1),new Rt({name:"BackgroundCubeMaterial",uniforms:Jr(bi.backgroundCube.uniforms),vertexShader:bi.backgroundCube.vertexShader,fragmentShader:bi.backgroundCube.fragmentShader,side:Ct,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(E,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(w3.makeRotationFromEuler(b.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Cm),l.material.toneMapped=et.getTransfer(_.colorSpace)!==lt,(h!==_||u!==_.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new We(new ui(2,2),new Rt({name:"BackgroundMaterial",uniforms:Jr(bi.background.uniforms),vertexShader:bi.background.vertexShader,fragmentShader:bi.background.fragmentShader,side:Ss,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.toneMapped=et.getTransfer(_.colorSpace)!==lt,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||u!==_.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function m(S,b){S.getRGB(Go,bm(s)),t.buffers.color.setClear(Go.r,Go.g,Go.b,b,r)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,b=1){a.set(S),o=b,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,m(a,o)},render:p,addToRenderList:v,dispose:g}}function T3(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(D,P,F,H,O){let V=!1;const z=u(D,H,F,P);r!==z&&(r=z,l(r.object)),V=f(D,H,F,O),V&&p(D,H,F,O),O!==null&&e.update(O,s.ELEMENT_ARRAY_BUFFER),(V||a)&&(a=!1,_(D,P,F,H),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function c(){return s.createVertexArray()}function l(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function u(D,P,F,H){const O=H.wireframe===!0;let V=n[P.id];V===void 0&&(V={},n[P.id]=V);const z=D.isInstancedMesh===!0?D.id:0;let Y=V[z];Y===void 0&&(Y={},V[z]=Y);let ee=Y[F.id];ee===void 0&&(ee={},Y[F.id]=ee);let J=ee[O];return J===void 0&&(J=d(c()),ee[O]=J),J}function d(D){const P=[],F=[],H=[];for(let O=0;O<t;O++)P[O]=0,F[O]=0,H[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:F,attributeDivisors:H,object:D,attributes:{},index:null}}function f(D,P,F,H){const O=r.attributes,V=P.attributes;let z=0;const Y=F.getAttributes();for(const ee in Y)if(Y[ee].location>=0){const ne=O[ee];let ae=V[ee];if(ae===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor)),ne===void 0||ne.attribute!==ae||ae&&ne.data!==ae.data)return!0;z++}return r.attributesNum!==z||r.index!==H}function p(D,P,F,H){const O={},V=P.attributes;let z=0;const Y=F.getAttributes();for(const ee in Y)if(Y[ee].location>=0){let ne=V[ee];ne===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(ne=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(ne=D.instanceColor));const ae={};ae.attribute=ne,ne&&ne.data&&(ae.data=ne.data),O[ee]=ae,z++}r.attributes=O,r.attributesNum=z,r.index=H}function v(){const D=r.newAttributes;for(let P=0,F=D.length;P<F;P++)D[P]=0}function m(D){g(D,0)}function g(D,P){const F=r.newAttributes,H=r.enabledAttributes,O=r.attributeDivisors;F[D]=1,H[D]===0&&(s.enableVertexAttribArray(D),H[D]=1),O[D]!==P&&(s.vertexAttribDivisor(D,P),O[D]=P)}function S(){const D=r.newAttributes,P=r.enabledAttributes;for(let F=0,H=P.length;F<H;F++)P[F]!==D[F]&&(s.disableVertexAttribArray(F),P[F]=0)}function b(D,P,F,H,O,V,z){z===!0?s.vertexAttribIPointer(D,P,F,O,V):s.vertexAttribPointer(D,P,F,H,O,V)}function _(D,P,F,H){v();const O=H.attributes,V=F.getAttributes(),z=P.defaultAttributeValues;for(const Y in V){const ee=V[Y];if(ee.location>=0){let J=O[Y];if(J===void 0&&(Y==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),Y==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const ne=J.normalized,ae=J.itemSize,Ve=e.get(J);if(Ve===void 0)continue;const je=Ve.buffer,Be=Ve.type,K=Ve.bytesPerElement,re=Be===s.INT||Be===s.UNSIGNED_INT||J.gpuType===Yu;if(J.isInterleavedBufferAttribute){const ie=J.data,B=ie.stride,Ee=J.offset;if(ie.isInstancedInterleavedBuffer){for(let Pe=0;Pe<ee.locationSize;Pe++)g(ee.location+Pe,ie.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let Pe=0;Pe<ee.locationSize;Pe++)m(ee.location+Pe);s.bindBuffer(s.ARRAY_BUFFER,je);for(let Pe=0;Pe<ee.locationSize;Pe++)b(ee.location+Pe,ae/ee.locationSize,Be,ne,B*K,(Ee+ae/ee.locationSize*Pe)*K,re)}else{if(J.isInstancedBufferAttribute){for(let ie=0;ie<ee.locationSize;ie++)g(ee.location+ie,J.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let ie=0;ie<ee.locationSize;ie++)m(ee.location+ie);s.bindBuffer(s.ARRAY_BUFFER,je);for(let ie=0;ie<ee.locationSize;ie++)b(ee.location+ie,ae/ee.locationSize,Be,ne,ae*K,ae/ee.locationSize*ie*K,re)}}else if(z!==void 0){const ne=z[Y];if(ne!==void 0)switch(ne.length){case 2:s.vertexAttrib2fv(ee.location,ne);break;case 3:s.vertexAttrib3fv(ee.location,ne);break;case 4:s.vertexAttrib4fv(ee.location,ne);break;default:s.vertexAttrib1fv(ee.location,ne)}}}}S()}function E(){A();for(const D in n){const P=n[D];for(const F in P){const H=P[F];for(const O in H){const V=H[O];for(const z in V)h(V[z].object),delete V[z];delete H[O]}}delete n[D]}}function w(D){if(n[D.id]===void 0)return;const P=n[D.id];for(const F in P){const H=P[F];for(const O in H){const V=H[O];for(const z in V)h(V[z].object),delete V[z];delete H[O]}}delete n[D.id]}function R(D){for(const P in n){const F=n[P];for(const H in F){const O=F[H];if(O[D.id]===void 0)continue;const V=O[D.id];for(const z in V)h(V[z].object),delete V[z];delete O[D.id]}}}function M(D){for(const P in n){const F=n[P],H=D.isInstancedMesh===!0?D.id:0,O=F[H];if(O!==void 0){for(const V in O){const z=O[V];for(const Y in z)h(z[Y].object),delete z[Y];delete O[V]}delete F[H],Object.keys(F).length===0&&delete n[P]}}}function A(){I(),a=!0,r!==i&&(r=i,l(r.object))}function I(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:E,releaseStatesOfGeometry:w,releaseStatesOfObject:M,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:S}}function R3(s,e,t){let n;function i(c){n=c}function r(c,l){s.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(s.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function D3(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==_n&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const M=R===cn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Hn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Tn&&!M)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(we("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&we("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),g=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),b=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),E=s.getParameter(s.MAX_SAMPLES),w=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:S,maxVaryings:b,maxFragmentUniforms:_,maxSamples:E,samples:w}}function C3(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new Ls,o=new ze,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=s.get(u);if(!i||p===null||p.length===0||r&&!m)r?h(null):l();else{const S=r?0:n,b=S*4;let _=g.clippingState||null;c.value=_,_=h(p,d,b,f);for(let E=0;E!==b;++E)_[E]=t[E];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<g)&&(m=new Float32Array(g));for(let b=0,_=f;b!==v;++b,_+=4)a.copy(u[b]).applyMatrix4(S,o),a.normal.toArray(m,_),m[_+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const xs=4,nf=[.125,.215,.35,.446,.526,.582],Us=20,I3=256,pa=new ws,sf=new oe;let Ul=null,Fl=0,kl=0,zl=!1;const P3=new C;class rf{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:o=P3}=r;Ul=this._renderer.getRenderTarget(),Fl=this._renderer.getActiveCubeFace(),kl=this._renderer.getActiveMipmapLevel(),zl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,i,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=cf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=of(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ul,Fl,kl),this._renderer.xr.enabled=zl,e.scissorTest=!1,Er(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===qs||e.mapping===Kr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ul=this._renderer.getRenderTarget(),Fl=this._renderer.getActiveCubeFace(),kl=this._renderer.getActiveMipmapLevel(),zl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:dt,minFilter:dt,generateMipmaps:!1,type:cn,format:_n,colorSpace:bc,depthBuffer:!1},i=af(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=af(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=L3(r)),this._blurMaterial=O3(r,e,t),this._ggxMaterial=N3(r,e,t)}return i}_compileMaterial(e){const t=new We(new yt,e);this._renderer.compile(t,pa)}_sceneToCubeUV(e,t,n,i,r){const c=new Nn(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(sf),u.toneMapping=Ii,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new We(new jn,new Jn({name:"PMREM.Background",side:Ct,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const S=e.background;S?S.isColor&&(m.color.copy(S),e.background=null,g=!0):(m.color.copy(sf),g=!0);for(let b=0;b<6;b++){const _=b%3;_===0?(c.up.set(0,l[b],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[b],r.y,r.z)):_===1?(c.up.set(0,0,l[b]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[b],r.z)):(c.up.set(0,l[b],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[b]));const E=this._cubeSize;Er(i,_*E,b>2?E:0,E,E),u.setRenderTarget(i),g&&u.render(v,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=S}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===qs||e.mapping===Kr;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=cf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=of());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;Er(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,pa)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[n],m=3*v*(n>p-xs?n-p+xs:0),g=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=p-t,Er(r,m,g,3*v,2*v),i.setRenderTarget(r),i.render(o,pa),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=p-n,Er(e,m,g,3*v,2*v),i.setRenderTarget(e),i.render(o,pa)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ke("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Us-1),v=r/p,m=isFinite(r)?1+Math.floor(h*v):Us;m>Us&&we(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Us}`);const g=[];let S=0;for(let R=0;R<Us;++R){const M=R/v,A=Math.exp(-M*M/2);g.push(A),R===0?S+=A:R<m&&(S+=2*A)}for(let R=0;R<g.length;R++)g[R]=g[R]/S;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:b}=this;d.dTheta.value=p,d.mipInt.value=b-n;const _=this._sizeLods[i],E=3*_*(i>b-xs?i-b+xs:0),w=4*(this._cubeSize-_);Er(t,E,w,3*_,2*_),c.setRenderTarget(t),c.render(u,pa)}}function L3(s){const e=[],t=[],n=[];let i=s;const r=s-xs+1+nf.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);e.push(o);let c=1/o;a>s-xs?c=nf[a-s+xs-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,S=new Float32Array(v*p*f),b=new Float32Array(m*p*f),_=new Float32Array(g*p*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,M=w>2?0:-1,A=[R,M,0,R+2/3,M,0,R+2/3,M+1,0,R,M,0,R+2/3,M+1,0,R,M+1,0];S.set(A,v*p*w),b.set(d,m*p*w);const I=[w,w,w,w,w,w];_.set(I,g*p*w)}const E=new yt;E.setAttribute("position",new rt(S,v)),E.setAttribute("uv",new rt(b,m)),E.setAttribute("faceIndex",new rt(_,g)),n.push(new We(E,null)),i>xs&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function af(s,e,t){const n=new dn(s,e,t);return n.texture.mapping=Gc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Er(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function N3(s,e,t){return new Rt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:I3,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Xc(),fragmentShader:`
4281
+ }`,Ke={alphahash_fragment:Xv,alphahash_pars_fragment:qv,alphamap_fragment:Yv,alphamap_pars_fragment:Kv,alphatest_fragment:$v,alphatest_pars_fragment:Zv,aomap_fragment:Jv,aomap_pars_fragment:jv,batching_pars_vertex:Qv,batching_vertex:eM,begin_vertex:tM,beginnormal_vertex:nM,bsdfs:iM,iridescence_fragment:sM,bumpmap_pars_fragment:rM,clipping_planes_fragment:aM,clipping_planes_pars_fragment:oM,clipping_planes_pars_vertex:cM,clipping_planes_vertex:lM,color_fragment:hM,color_pars_fragment:uM,color_pars_vertex:dM,color_vertex:fM,common:pM,cube_uv_reflection_fragment:mM,defaultnormal_vertex:gM,displacementmap_pars_vertex:vM,displacementmap_vertex:MM,emissivemap_fragment:xM,emissivemap_pars_fragment:_M,colorspace_fragment:yM,colorspace_pars_fragment:SM,envmap_fragment:bM,envmap_common_pars_fragment:EM,envmap_pars_fragment:wM,envmap_pars_vertex:AM,envmap_physical_pars_fragment:FM,envmap_vertex:TM,fog_vertex:RM,fog_pars_vertex:DM,fog_fragment:CM,fog_pars_fragment:IM,gradientmap_pars_fragment:PM,lightmap_pars_fragment:LM,lights_lambert_fragment:NM,lights_lambert_pars_fragment:OM,lights_pars_begin:UM,lights_toon_fragment:kM,lights_toon_pars_fragment:zM,lights_phong_fragment:BM,lights_phong_pars_fragment:HM,lights_physical_fragment:GM,lights_physical_pars_fragment:VM,lights_fragment_begin:WM,lights_fragment_maps:XM,lights_fragment_end:qM,lightprobes_pars_fragment:YM,logdepthbuf_fragment:KM,logdepthbuf_pars_fragment:$M,logdepthbuf_pars_vertex:ZM,logdepthbuf_vertex:JM,map_fragment:jM,map_pars_fragment:QM,map_particle_fragment:ex,map_particle_pars_fragment:tx,metalnessmap_fragment:nx,metalnessmap_pars_fragment:ix,morphinstance_vertex:sx,morphcolor_vertex:rx,morphnormal_vertex:ax,morphtarget_pars_vertex:ox,morphtarget_vertex:cx,normal_fragment_begin:lx,normal_fragment_maps:hx,normal_pars_fragment:ux,normal_pars_vertex:dx,normal_vertex:fx,normalmap_pars_fragment:px,clearcoat_normal_fragment_begin:mx,clearcoat_normal_fragment_maps:gx,clearcoat_pars_fragment:vx,iridescence_pars_fragment:Mx,opaque_fragment:xx,packing:_x,premultiplied_alpha_fragment:yx,project_vertex:Sx,dithering_fragment:bx,dithering_pars_fragment:Ex,roughnessmap_fragment:wx,roughnessmap_pars_fragment:Ax,shadowmap_pars_fragment:Tx,shadowmap_pars_vertex:Rx,shadowmap_vertex:Dx,shadowmask_pars_fragment:Cx,skinbase_vertex:Ix,skinning_pars_vertex:Px,skinning_vertex:Lx,skinnormal_vertex:Nx,specularmap_fragment:Ox,specularmap_pars_fragment:Ux,tonemapping_fragment:Fx,tonemapping_pars_fragment:kx,transmission_fragment:zx,transmission_pars_fragment:Bx,uv_pars_fragment:Hx,uv_pars_vertex:Gx,uv_vertex:Vx,worldpos_vertex:Wx,background_vert:Xx,background_frag:qx,backgroundCube_vert:Yx,backgroundCube_frag:Kx,cube_vert:$x,cube_frag:Zx,depth_vert:Jx,depth_frag:jx,distance_vert:Qx,distance_frag:e3,equirect_vert:t3,equirect_frag:n3,linedashed_vert:i3,linedashed_frag:s3,meshbasic_vert:r3,meshbasic_frag:a3,meshlambert_vert:o3,meshlambert_frag:c3,meshmatcap_vert:l3,meshmatcap_frag:h3,meshnormal_vert:u3,meshnormal_frag:d3,meshphong_vert:f3,meshphong_frag:p3,meshphysical_vert:m3,meshphysical_frag:g3,meshtoon_vert:v3,meshtoon_frag:M3,points_vert:x3,points_frag:_3,shadow_vert:y3,shadow_frag:S3,sprite_vert:b3,sprite_frag:E3},pe={common:{diffuse:{value:new oe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Be}},envmap:{envMap:{value:null},envMapRotation:{value:new Be},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Be}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Be}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Be},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Be},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Be},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Be}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Be}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Be}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new oe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new oe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0},uvTransform:{value:new Be}},sprite:{diffuse:{value:new oe(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Be},alphaMap:{value:null},alphaMapTransform:{value:new Be},alphaTest:{value:0}}},bi={basic:{uniforms:Sn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.fog]),vertexShader:Ke.meshbasic_vert,fragmentShader:Ke.meshbasic_frag},lambert:{uniforms:Sn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},envMapIntensity:{value:1}}]),vertexShader:Ke.meshlambert_vert,fragmentShader:Ke.meshlambert_frag},phong:{uniforms:Sn([pe.common,pe.specularmap,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},specular:{value:new oe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphong_vert,fragmentShader:Ke.meshphong_frag},standard:{uniforms:Sn([pe.common,pe.envmap,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.roughnessmap,pe.metalnessmap,pe.fog,pe.lights,{emissive:{value:new oe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag},toon:{uniforms:Sn([pe.common,pe.aomap,pe.lightmap,pe.emissivemap,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.gradientmap,pe.fog,pe.lights,{emissive:{value:new oe(0)}}]),vertexShader:Ke.meshtoon_vert,fragmentShader:Ke.meshtoon_frag},matcap:{uniforms:Sn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,pe.fog,{matcap:{value:null}}]),vertexShader:Ke.meshmatcap_vert,fragmentShader:Ke.meshmatcap_frag},points:{uniforms:Sn([pe.points,pe.fog]),vertexShader:Ke.points_vert,fragmentShader:Ke.points_frag},dashed:{uniforms:Sn([pe.common,pe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ke.linedashed_vert,fragmentShader:Ke.linedashed_frag},depth:{uniforms:Sn([pe.common,pe.displacementmap]),vertexShader:Ke.depth_vert,fragmentShader:Ke.depth_frag},normal:{uniforms:Sn([pe.common,pe.bumpmap,pe.normalmap,pe.displacementmap,{opacity:{value:1}}]),vertexShader:Ke.meshnormal_vert,fragmentShader:Ke.meshnormal_frag},sprite:{uniforms:Sn([pe.sprite,pe.fog]),vertexShader:Ke.sprite_vert,fragmentShader:Ke.sprite_frag},background:{uniforms:{uvTransform:{value:new Be},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ke.background_vert,fragmentShader:Ke.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Be}},vertexShader:Ke.backgroundCube_vert,fragmentShader:Ke.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ke.cube_vert,fragmentShader:Ke.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ke.equirect_vert,fragmentShader:Ke.equirect_frag},distance:{uniforms:Sn([pe.common,pe.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ke.distance_vert,fragmentShader:Ke.distance_frag},shadow:{uniforms:Sn([pe.lights,pe.fog,{color:{value:new oe(0)},opacity:{value:1}}]),vertexShader:Ke.shadow_vert,fragmentShader:Ke.shadow_frag}};bi.physical={uniforms:Sn([bi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Be},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Be},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Be},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Be},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Be},sheen:{value:0},sheenColor:{value:new oe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Be},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Be},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Be},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Be},attenuationDistance:{value:0},attenuationColor:{value:new oe(0)},specularColor:{value:new oe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Be},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Be},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Be}}]),vertexShader:Ke.meshphysical_vert,fragmentShader:Ke.meshphysical_frag};const Go={r:0,b:0,g:0},w3=new Ye,Cm=new Be;Cm.set(-1,0,0,0,1,0,0,0,1);function A3(s,e,t,n,i,r){const a=new oe(0);let o=i===!0?0:1,c,l,h=null,u=0,d=null;function f(S){let b=S.isScene===!0?S.background:null;if(b&&b.isTexture){const _=S.backgroundBlurriness>0;b=e.get(b,_)}return b}function p(S){let b=!1;const _=f(S);_===null?m(a,o):_&&_.isColor&&(m(_,1),b=!0);const E=s.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(s.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(S,b){const _=f(b);_&&(_.isCubeTexture||_.mapping===Gc)?(l===void 0&&(l=new We(new jn(1,1,1),new Rt({name:"BackgroundCubeMaterial",uniforms:Jr(bi.backgroundCube.uniforms),vertexShader:bi.backgroundCube.vertexShader,fragmentShader:bi.backgroundCube.fragmentShader,side:Ct,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(E,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(w3.makeRotationFromEuler(b.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Cm),l.material.toneMapped=et.getTransfer(_.colorSpace)!==lt,(h!==_||u!==_.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new We(new ui(2,2),new Rt({name:"BackgroundMaterial",uniforms:Jr(bi.background.uniforms),vertexShader:bi.background.vertexShader,fragmentShader:bi.background.fragmentShader,side:Ss,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.toneMapped=et.getTransfer(_.colorSpace)!==lt,_.matrixAutoUpdate===!0&&_.updateMatrix(),c.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||u!==_.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function m(S,b){S.getRGB(Go,bm(s)),t.buffers.color.setClear(Go.r,Go.g,Go.b,b,r)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(S,b=1){a.set(S),o=b,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,m(a,o)},render:p,addToRenderList:v,dispose:g}}function T3(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(D,P,F,H,O){let V=!1;const z=u(D,H,F,P);r!==z&&(r=z,l(r.object)),V=f(D,H,F,O),V&&p(D,H,F,O),O!==null&&e.update(O,s.ELEMENT_ARRAY_BUFFER),(V||a)&&(a=!1,_(D,P,F,H),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(O).buffer))}function c(){return s.createVertexArray()}function l(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function u(D,P,F,H){const O=H.wireframe===!0;let V=n[P.id];V===void 0&&(V={},n[P.id]=V);const z=D.isInstancedMesh===!0?D.id:0;let Y=V[z];Y===void 0&&(Y={},V[z]=Y);let ee=Y[F.id];ee===void 0&&(ee={},Y[F.id]=ee);let J=ee[O];return J===void 0&&(J=d(c()),ee[O]=J),J}function d(D){const P=[],F=[],H=[];for(let O=0;O<t;O++)P[O]=0,F[O]=0,H[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:F,attributeDivisors:H,object:D,attributes:{},index:null}}function f(D,P,F,H){const O=r.attributes,V=P.attributes;let z=0;const Y=F.getAttributes();for(const ee in Y)if(Y[ee].location>=0){const ne=O[ee];let ae=V[ee];if(ae===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor)),ne===void 0||ne.attribute!==ae||ae&&ne.data!==ae.data)return!0;z++}return r.attributesNum!==z||r.index!==H}function p(D,P,F,H){const O={},V=P.attributes;let z=0;const Y=F.getAttributes();for(const ee in Y)if(Y[ee].location>=0){let ne=V[ee];ne===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(ne=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(ne=D.instanceColor));const ae={};ae.attribute=ne,ne&&ne.data&&(ae.data=ne.data),O[ee]=ae,z++}r.attributes=O,r.attributesNum=z,r.index=H}function v(){const D=r.newAttributes;for(let P=0,F=D.length;P<F;P++)D[P]=0}function m(D){g(D,0)}function g(D,P){const F=r.newAttributes,H=r.enabledAttributes,O=r.attributeDivisors;F[D]=1,H[D]===0&&(s.enableVertexAttribArray(D),H[D]=1),O[D]!==P&&(s.vertexAttribDivisor(D,P),O[D]=P)}function S(){const D=r.newAttributes,P=r.enabledAttributes;for(let F=0,H=P.length;F<H;F++)P[F]!==D[F]&&(s.disableVertexAttribArray(F),P[F]=0)}function b(D,P,F,H,O,V,z){z===!0?s.vertexAttribIPointer(D,P,F,O,V):s.vertexAttribPointer(D,P,F,H,O,V)}function _(D,P,F,H){v();const O=H.attributes,V=F.getAttributes(),z=P.defaultAttributeValues;for(const Y in V){const ee=V[Y];if(ee.location>=0){let J=O[Y];if(J===void 0&&(Y==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),Y==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const ne=J.normalized,ae=J.itemSize,Ve=e.get(J);if(Ve===void 0)continue;const je=Ve.buffer,He=Ve.type,K=Ve.bytesPerElement,re=He===s.INT||He===s.UNSIGNED_INT||J.gpuType===Yu;if(J.isInterleavedBufferAttribute){const ie=J.data,B=ie.stride,Ee=J.offset;if(ie.isInstancedInterleavedBuffer){for(let Pe=0;Pe<ee.locationSize;Pe++)g(ee.location+Pe,ie.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let Pe=0;Pe<ee.locationSize;Pe++)m(ee.location+Pe);s.bindBuffer(s.ARRAY_BUFFER,je);for(let Pe=0;Pe<ee.locationSize;Pe++)b(ee.location+Pe,ae/ee.locationSize,He,ne,B*K,(Ee+ae/ee.locationSize*Pe)*K,re)}else{if(J.isInstancedBufferAttribute){for(let ie=0;ie<ee.locationSize;ie++)g(ee.location+ie,J.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let ie=0;ie<ee.locationSize;ie++)m(ee.location+ie);s.bindBuffer(s.ARRAY_BUFFER,je);for(let ie=0;ie<ee.locationSize;ie++)b(ee.location+ie,ae/ee.locationSize,He,ne,ae*K,ae/ee.locationSize*ie*K,re)}}else if(z!==void 0){const ne=z[Y];if(ne!==void 0)switch(ne.length){case 2:s.vertexAttrib2fv(ee.location,ne);break;case 3:s.vertexAttrib3fv(ee.location,ne);break;case 4:s.vertexAttrib4fv(ee.location,ne);break;default:s.vertexAttrib1fv(ee.location,ne)}}}}S()}function E(){A();for(const D in n){const P=n[D];for(const F in P){const H=P[F];for(const O in H){const V=H[O];for(const z in V)h(V[z].object),delete V[z];delete H[O]}}delete n[D]}}function w(D){if(n[D.id]===void 0)return;const P=n[D.id];for(const F in P){const H=P[F];for(const O in H){const V=H[O];for(const z in V)h(V[z].object),delete V[z];delete H[O]}}delete n[D.id]}function R(D){for(const P in n){const F=n[P];for(const H in F){const O=F[H];if(O[D.id]===void 0)continue;const V=O[D.id];for(const z in V)h(V[z].object),delete V[z];delete O[D.id]}}}function M(D){for(const P in n){const F=n[P],H=D.isInstancedMesh===!0?D.id:0,O=F[H];if(O!==void 0){for(const V in O){const z=O[V];for(const Y in z)h(z[Y].object),delete z[Y];delete O[V]}delete F[H],Object.keys(F).length===0&&delete n[P]}}}function A(){I(),a=!0,r!==i&&(r=i,l(r.object))}function I(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:E,releaseStatesOfGeometry:w,releaseStatesOfObject:M,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:m,disableUnusedAttributes:S}}function R3(s,e,t){let n;function i(c){n=c}function r(c,l){s.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(s.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function o(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function D3(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==_n&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const M=R===cn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==Hn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Tn&&!M)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp";const h=c(l);h!==l&&(we("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&we("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),p=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),g=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),b=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),E=s.getParameter(s.MAX_SAMPLES),w=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:S,maxVaryings:b,maxFragmentUniforms:_,maxSamples:E,samples:w}}function C3(s){const e=this;let t=null,n=0,i=!1,r=!1;const a=new Ls,o=new Be,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=s.get(u);if(!i||p===null||p.length===0||r&&!m)r?h(null):l();else{const S=r?0:n,b=S*4;let _=g.clippingState||null;c.value=_,_=h(p,d,b,f);for(let E=0;E!==b;++E)_[E]=t[E];g.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(m===null||m.length<g)&&(m=new Float32Array(g));for(let b=0,_=f;b!==v;++b,_+=4)a.copy(u[b]).applyMatrix4(S,o),a.normal.toArray(m,_),m[_+3]=a.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,m}}const xs=4,nf=[.125,.215,.35,.446,.526,.582],Us=20,I3=256,pa=new ws,sf=new oe;let Ul=null,Fl=0,kl=0,zl=!1;const P3=new C;class rf{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){const{size:a=256,position:o=P3}=r;Ul=this._renderer.getRenderTarget(),Fl=this._renderer.getActiveCubeFace(),kl=this._renderer.getActiveMipmapLevel(),zl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(e,n,i,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=cf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=of(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Ul,Fl,kl),this._renderer.xr.enabled=zl,e.scissorTest=!1,Er(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===qs||e.mapping===Kr?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Ul=this._renderer.getRenderTarget(),Fl=this._renderer.getActiveCubeFace(),kl=this._renderer.getActiveMipmapLevel(),zl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:dt,minFilter:dt,generateMipmaps:!1,type:cn,format:_n,colorSpace:bc,depthBuffer:!1},i=af(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=af(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=L3(r)),this._blurMaterial=O3(r,e,t),this._ggxMaterial=N3(r,e,t)}return i}_compileMaterial(e){const t=new We(new yt,e);this._renderer.compile(t,pa)}_sceneToCubeUV(e,t,n,i,r){const c=new Nn(90,1,t,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(sf),u.toneMapping=Ii,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new We(new jn,new Jn({name:"PMREM.Background",side:Ct,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const S=e.background;S?S.isColor&&(m.color.copy(S),e.background=null,g=!0):(m.color.copy(sf),g=!0);for(let b=0;b<6;b++){const _=b%3;_===0?(c.up.set(0,l[b],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[b],r.y,r.z)):_===1?(c.up.set(0,0,l[b]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[b],r.z)):(c.up.set(0,l[b],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[b]));const E=this._cubeSize;Er(i,_*E,b>2?E:0,E,E),u.setRenderTarget(i),g&&u.render(v,c),u.render(e,c)}u.toneMapping=f,u.autoClear=d,e.background=S}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===qs||e.mapping===Kr;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=cf()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=of());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const c=this._cubeSize;Er(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,pa)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[n],m=3*v*(n>p-xs?n-p+xs:0),g=4*(this._cubeSize-v);c.envMap.value=e.texture,c.roughness.value=f,c.mipInt.value=p-t,Er(r,m,g,3*v,2*v),i.setRenderTarget(r),i.render(o,pa),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=p-n,Er(e,m,g,3*v,2*v),i.setRenderTarget(e),i.render(o,pa)}_blur(e,t,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&ke("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Us-1),v=r/p,m=isFinite(r)?1+Math.floor(h*v):Us;m>Us&&we(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Us}`);const g=[];let S=0;for(let R=0;R<Us;++R){const M=R/v,A=Math.exp(-M*M/2);g.push(A),R===0?S+=A:R<m&&(S+=2*A)}for(let R=0;R<g.length;R++)g[R]=g[R]/S;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:b}=this;d.dTheta.value=p,d.mipInt.value=b-n;const _=this._sizeLods[i],E=3*_*(i>b-xs?i-b+xs:0),w=4*(this._cubeSize-_);Er(t,E,w,3*_,2*_),c.setRenderTarget(t),c.render(u,pa)}}function L3(s){const e=[],t=[],n=[];let i=s;const r=s-xs+1+nf.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);e.push(o);let c=1/o;a>s-xs?c=nf[a-s+xs-1]:a===0&&(c=0),t.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,m=2,g=1,S=new Float32Array(v*p*f),b=new Float32Array(m*p*f),_=new Float32Array(g*p*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,M=w>2?0:-1,A=[R,M,0,R+2/3,M,0,R+2/3,M+1,0,R,M,0,R+2/3,M+1,0,R,M+1,0];S.set(A,v*p*w),b.set(d,m*p*w);const I=[w,w,w,w,w,w];_.set(I,g*p*w)}const E=new yt;E.setAttribute("position",new rt(S,v)),E.setAttribute("uv",new rt(b,m)),E.setAttribute("faceIndex",new rt(_,g)),n.push(new We(E,null)),i>xs&&i--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function af(s,e,t){const n=new dn(s,e,t);return n.texture.mapping=Gc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Er(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function N3(s,e,t){return new Rt({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:I3,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Xc(),fragmentShader:`
4282
4282
 
4283
4283
  precision highp float;
4284
4284
  precision highp int;
@@ -4615,7 +4615,7 @@ void main() {
4615
4615
  #endif
4616
4616
  }`,depthTest:!1,depthWrite:!1}),h=new We(c,l),u=new ws(-1,1,1,-1,0,1);let d=null,f=null,p=!1,v,m=null,g=[],S=!1;this.setSize=function(b,_){a.setSize(b,_),o.setSize(b,_);for(let E=0;E<g.length;E++){const w=g[E];w.setSize&&w.setSize(b,_)}},this.setEffects=function(b){g=b,S=g.length>0&&g[0].isRenderPass===!0;const _=a.width,E=a.height;for(let w=0;w<g.length;w++){const R=g[w];R.setSize&&R.setSize(_,E)}},this.begin=function(b,_){if(p||b.toneMapping===Ii&&g.length===0)return!1;if(m=_,_!==null){const E=_.width,w=_.height;(a.width!==E||a.height!==w)&&this.setSize(E,w)}return S===!1&&b.setRenderTarget(a),v=b.toneMapping,b.toneMapping=Ii,!0},this.hasRenderPass=function(){return S},this.end=function(b,_){b.toneMapping=v,p=!0;let E=a,w=o;for(let R=0;R<g.length;R++){const M=g[R];if(M.enabled!==!1&&(M.render(b,w,E,_),M.needsSwap!==!1)){const A=E;E=w,w=A}}if(d!==b.outputColorSpace||f!==b.toneMapping){d=b.outputColorSpace,f=b.toneMapping,l.defines={},et.getTransfer(d)===lt&&(l.defines.SRGB_TRANSFER="");const R=V3[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=E.texture,b.setRenderTarget(m),b.render(h,u),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const Pm=new on,hu=new Ks(1,1),Lm=new pm,Nm=new mm,Om=new ym,lf=[],hf=[],uf=new Float32Array(16),df=new Float32Array(9),ff=new Float32Array(4);function ta(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=lf[i];if(r===void 0&&(r=new Float32Array(i),lf[i]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,s[a].toArray(r,o)}return r}function $t(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function Zt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function qc(s,e){let t=hf[e];t===void 0&&(t=new Int32Array(e),hf[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function X3(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function q3(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if($t(t,e))return;s.uniform2fv(this.addr,e),Zt(t,e)}}function Y3(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if($t(t,e))return;s.uniform3fv(this.addr,e),Zt(t,e)}}function K3(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if($t(t,e))return;s.uniform4fv(this.addr,e),Zt(t,e)}}function $3(s,e){const t=this.cache,n=e.elements;if(n===void 0){if($t(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),Zt(t,e)}else{if($t(t,n))return;ff.set(n),s.uniformMatrix2fv(this.addr,!1,ff),Zt(t,n)}}function Z3(s,e){const t=this.cache,n=e.elements;if(n===void 0){if($t(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),Zt(t,e)}else{if($t(t,n))return;df.set(n),s.uniformMatrix3fv(this.addr,!1,df),Zt(t,n)}}function J3(s,e){const t=this.cache,n=e.elements;if(n===void 0){if($t(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),Zt(t,e)}else{if($t(t,n))return;uf.set(n),s.uniformMatrix4fv(this.addr,!1,uf),Zt(t,n)}}function j3(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function Q3(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if($t(t,e))return;s.uniform2iv(this.addr,e),Zt(t,e)}}function e_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if($t(t,e))return;s.uniform3iv(this.addr,e),Zt(t,e)}}function t_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if($t(t,e))return;s.uniform4iv(this.addr,e),Zt(t,e)}}function n_(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function i_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if($t(t,e))return;s.uniform2uiv(this.addr,e),Zt(t,e)}}function s_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if($t(t,e))return;s.uniform3uiv(this.addr,e),Zt(t,e)}}function r_(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if($t(t,e))return;s.uniform4uiv(this.addr,e),Zt(t,e)}}function a_(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(hu.compareFunction=t.isReversedDepthBuffer()?ed:Qu,r=hu):r=Pm,t.setTexture2D(e||r,i)}function o_(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Nm,i)}function c_(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Om,i)}function l_(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Lm,i)}function h_(s){switch(s){case 5126:return X3;case 35664:return q3;case 35665:return Y3;case 35666:return K3;case 35674:return $3;case 35675:return Z3;case 35676:return J3;case 5124:case 35670:return j3;case 35667:case 35671:return Q3;case 35668:case 35672:return e_;case 35669:case 35673:return t_;case 5125:return n_;case 36294:return i_;case 36295:return s_;case 36296:return r_;case 35678:case 36198:case 36298:case 36306:case 35682:return a_;case 35679:case 36299:case 36307:return o_;case 35680:case 36300:case 36308:case 36293:return c_;case 36289:case 36303:case 36311:case 36292:return l_}}function u_(s,e){s.uniform1fv(this.addr,e)}function d_(s,e){const t=ta(e,this.size,2);s.uniform2fv(this.addr,t)}function f_(s,e){const t=ta(e,this.size,3);s.uniform3fv(this.addr,t)}function p_(s,e){const t=ta(e,this.size,4);s.uniform4fv(this.addr,t)}function m_(s,e){const t=ta(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function g_(s,e){const t=ta(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function v_(s,e){const t=ta(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function M_(s,e){s.uniform1iv(this.addr,e)}function x_(s,e){s.uniform2iv(this.addr,e)}function __(s,e){s.uniform3iv(this.addr,e)}function y_(s,e){s.uniform4iv(this.addr,e)}function S_(s,e){s.uniform1uiv(this.addr,e)}function b_(s,e){s.uniform2uiv(this.addr,e)}function E_(s,e){s.uniform3uiv(this.addr,e)}function w_(s,e){s.uniform4uiv(this.addr,e)}function A_(s,e,t){const n=this.cache,i=e.length,r=qc(t,i);$t(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=hu:a=Pm;for(let o=0;o!==i;++o)t.setTexture2D(e[o]||a,r[o])}function T_(s,e,t){const n=this.cache,i=e.length,r=qc(t,i);$t(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));for(let a=0;a!==i;++a)t.setTexture3D(e[a]||Nm,r[a])}function R_(s,e,t){const n=this.cache,i=e.length,r=qc(t,i);$t(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));for(let a=0;a!==i;++a)t.setTextureCube(e[a]||Om,r[a])}function D_(s,e,t){const n=this.cache,i=e.length,r=qc(t,i);$t(n,r)||(s.uniform1iv(this.addr,r),Zt(n,r));for(let a=0;a!==i;++a)t.setTexture2DArray(e[a]||Lm,r[a])}function C_(s){switch(s){case 5126:return u_;case 35664:return d_;case 35665:return f_;case 35666:return p_;case 35674:return m_;case 35675:return g_;case 35676:return v_;case 5124:case 35670:return M_;case 35667:case 35671:return x_;case 35668:case 35672:return __;case 35669:case 35673:return y_;case 5125:return S_;case 36294:return b_;case 36295:return E_;case 36296:return w_;case 35678:case 36198:case 36298:case 36306:case 35682:return A_;case 35679:case 36299:case 36307:return T_;case 35680:case 36300:case 36308:case 36293:return R_;case 36289:case 36303:case 36311:case 36292:return D_}}class I_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=h_(t.type)}}class P_{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=C_(t.type)}}class L_{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(e,t[o.id],n)}}}const Bl=/(\w+)(\])?(\[|\.)?/g;function pf(s,e){s.seq.push(e),s.map[e.id]=e}function N_(s,e,t){const n=s.name,i=n.length;for(Bl.lastIndex=0;;){const r=Bl.exec(n),a=Bl.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===i){pf(t,l===void 0?new I_(o,s,e):new P_(o,s,e));break}else{let u=t.map[o];u===void 0&&(u=new L_(o),pf(t,u)),t=u}}}class dc{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);N_(o,c,this)}const i=[],r=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?i.push(a):r.push(a);i.length>0&&(this.seq=i.concat(r))}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){const o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const a=e[i];a.id in t&&n.push(a)}return n}}function mf(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const O_=37297;let U_=0;function F_(s,e){const t=s.split(`
4617
4617
  `),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=i;a<r;a++){const o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
4618
- `)}const gf=new ze;function k_(s){et._getMatrix(gf,et.workingColorSpace,s);const e=`mat3( ${gf.elements.map(t=>t.toFixed(4))} )`;switch(et.getTransfer(s)){case Ec:return[e,"LinearTransferOETF"];case lt:return[e,"sRGBTransferOETF"];default:return we("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function vf(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4618
+ `)}const gf=new Be;function k_(s){et._getMatrix(gf,et.workingColorSpace,s);const e=`mat3( ${gf.elements.map(t=>t.toFixed(4))} )`;switch(et.getTransfer(s)){case Ec:return[e,"LinearTransferOETF"];case lt:return[e,"sRGBTransferOETF"];default:return we("WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function vf(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),r=(s.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+`
4619
4619
 
4620
4620
  `+r+`
4621
4621
 
@@ -4664,7 +4664,7 @@ Material Type: `+D.type+`
4664
4664
 
4665
4665
  Program Info Log: `+O+`
4666
4666
  `+J+`
4667
- `+ne)}else O!==""?we("WebGLProgram: Program Info Log:",O):(V===""||z==="")&&(ee=!1);ee&&(D.diagnostics={runnable:Y,programLog:O,vertexShader:{log:V,prefix:m},fragmentShader:{log:z,prefix:g}})}i.deleteShader(E),i.deleteShader(w),M=new dc(i,v),A=X_(i,v)}let M;this.getUniforms=function(){return M===void 0&&R(this),M};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=i.getProgramParameter(v,O_)),I},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=U_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=E,this.fragmentShader=w,this}let oy=0;class cy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new ly(e),t.set(e,n)),n}}class ly{constructor(e){this.id=oy++,this.code=e,this.usedTimes=0}}function hy(s){return s===Ys||s===xc||s===_c}function uy(s,e,t,n,i,r){const a=new id,o=new cy,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(M){return c.add(M),M===0?"uv":`uv${M}`}function v(M,A,I,D,P,F){const H=D.fog,O=P.geometry,V=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?D.environment:null,z=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap,Y=e.get(M.envMap||V,z),ee=Y&&Y.mapping===Gc?Y.image.height:null,J=f[M.type];M.precision!==null&&(d=n.getMaxPrecision(M.precision),d!==M.precision&&we("WebGLProgram.getParameters:",M.precision,"not supported, using",d,"instead."));const ne=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ae=ne!==void 0?ne.length:0;let Ve=0;O.morphAttributes.position!==void 0&&(Ve=1),O.morphAttributes.normal!==void 0&&(Ve=2),O.morphAttributes.color!==void 0&&(Ve=3);let je,Be,K,re;if(J){const ye=bi[J];je=ye.vertexShader,Be=ye.fragmentShader}else{je=M.vertexShader,Be=M.fragmentShader;const ye=o.getVertexShaderStage(M),Ot=o.getFragmentShaderStage(M);o.update(M,ye,Ot),K=ye.id,re=Ot.id}const ie=s.getRenderTarget(),B=s.state.buffers.depth.getReversed(),Ee=P.isInstancedMesh===!0,Pe=P.isBatchedMesh===!0,Re=!!M.map,xe=!!M.matcap,Ne=!!Y,Oe=!!M.aoMap,Ue=!!M.lightMap,at=!!M.bumpMap&&M.wireframe===!1,ot=!!M.normalMap,Lt=!!M.displacementMap,Et=!!M.emissiveMap,Nt=!!M.metalnessMap,Wt=!!M.roughnessMap,N=M.anisotropy>0,Rn=M.clearcoat>0,ct=M.dispersion>0,T=M.iridescence>0,x=M.sheen>0,k=M.transmission>0,X=N&&!!M.anisotropyMap,$=Rn&&!!M.clearcoatMap,se=Rn&&!!M.clearcoatNormalMap,le=Rn&&!!M.clearcoatRoughnessMap,Z=T&&!!M.iridescenceMap,Q=T&&!!M.iridescenceThicknessMap,he=x&&!!M.sheenColorMap,De=x&&!!M.sheenRoughnessMap,fe=!!M.specularMap,ue=!!M.specularColorMap,Le=!!M.specularIntensityMap,Fe=k&&!!M.transmissionMap,Xe=k&&!!M.thicknessMap,L=!!M.gradientMap,ce=!!M.alphaMap,j=M.alphaTest>0,de=!!M.alphaHash,ve=!!M.extensions;let te=Ii;M.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(te=s.toneMapping);const Te={shaderID:J,shaderType:M.type,shaderName:M.name,vertexShader:je,fragmentShader:Be,defines:M.defines,customVertexShaderID:K,customFragmentShaderID:re,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:d,batching:Pe,batchingColor:Pe&&P._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&P.instanceColor!==null,instancingMorph:Ee&&P.morphTexture!==null,outputColorSpace:ie===null?s.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:et.workingColorSpace,alphaToCoverage:!!M.alphaToCoverage,map:Re,matcap:xe,envMap:Ne,envMapMode:Ne&&Y.mapping,envMapCubeUVHeight:ee,aoMap:Oe,lightMap:Ue,bumpMap:at,normalMap:ot,displacementMap:Lt,emissiveMap:Et,normalMapObjectSpace:ot&&M.normalMapType===i2,normalMapTangentSpace:ot&&M.normalMapType===Sc,packedNormalMap:ot&&M.normalMapType===Sc&&hy(M.normalMap.format),metalnessMap:Nt,roughnessMap:Wt,anisotropy:N,anisotropyMap:X,clearcoat:Rn,clearcoatMap:$,clearcoatNormalMap:se,clearcoatRoughnessMap:le,dispersion:ct,iridescence:T,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:x,sheenColorMap:he,sheenRoughnessMap:De,specularMap:fe,specularColorMap:ue,specularIntensityMap:Le,transmission:k,transmissionMap:Fe,thicknessMap:Xe,gradientMap:L,opaque:M.transparent===!1&&M.blending===zr&&M.alphaToCoverage===!1,alphaMap:ce,alphaTest:j,alphaHash:de,combine:M.combine,mapUv:Re&&p(M.map.channel),aoMapUv:Oe&&p(M.aoMap.channel),lightMapUv:Ue&&p(M.lightMap.channel),bumpMapUv:at&&p(M.bumpMap.channel),normalMapUv:ot&&p(M.normalMap.channel),displacementMapUv:Lt&&p(M.displacementMap.channel),emissiveMapUv:Et&&p(M.emissiveMap.channel),metalnessMapUv:Nt&&p(M.metalnessMap.channel),roughnessMapUv:Wt&&p(M.roughnessMap.channel),anisotropyMapUv:X&&p(M.anisotropyMap.channel),clearcoatMapUv:$&&p(M.clearcoatMap.channel),clearcoatNormalMapUv:se&&p(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&p(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(M.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(M.iridescenceThicknessMap.channel),sheenColorMapUv:he&&p(M.sheenColorMap.channel),sheenRoughnessMapUv:De&&p(M.sheenRoughnessMap.channel),specularMapUv:fe&&p(M.specularMap.channel),specularColorMapUv:ue&&p(M.specularColorMap.channel),specularIntensityMapUv:Le&&p(M.specularIntensityMap.channel),transmissionMapUv:Fe&&p(M.transmissionMap.channel),thicknessMapUv:Xe&&p(M.thicknessMap.channel),alphaMapUv:ce&&p(M.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ot||N),vertexNormals:!!O.attributes.normal,vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!O.attributes.uv&&(Re||ce),fog:!!H,useFog:M.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:M.wireframe===!1&&(M.flatShading===!0||O.attributes.normal===void 0&&ot===!1&&(M.isMeshLambertMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isMeshPhysicalMaterial)),sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:B,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:Ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:F.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:M.dithering,shadowMapEnabled:s.shadowMap.enabled&&I.length>0,shadowMapType:s.shadowMap.type,toneMapping:te,decodeVideoTexture:Re&&M.map.isVideoTexture===!0&&et.getTransfer(M.map.colorSpace)===lt,decodeVideoTextureEmissive:Et&&M.emissiveMap.isVideoTexture===!0&&et.getTransfer(M.emissiveMap.colorSpace)===lt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===ai,flipSided:M.side===Ct,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ve&&M.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&M.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return Te.vertexUv1s=c.has(1),Te.vertexUv2s=c.has(2),Te.vertexUv3s=c.has(3),c.clear(),Te}function m(M){const A=[];if(M.shaderID?A.push(M.shaderID):(A.push(M.customVertexShaderID),A.push(M.customFragmentShaderID)),M.defines!==void 0)for(const I in M.defines)A.push(I),A.push(M.defines[I]);return M.isRawShaderMaterial===!1&&(g(A,M),S(A,M),A.push(s.outputColorSpace)),A.push(M.customProgramCacheKey),A.join()}function g(M,A){M.push(A.precision),M.push(A.outputColorSpace),M.push(A.envMapMode),M.push(A.envMapCubeUVHeight),M.push(A.mapUv),M.push(A.alphaMapUv),M.push(A.lightMapUv),M.push(A.aoMapUv),M.push(A.bumpMapUv),M.push(A.normalMapUv),M.push(A.displacementMapUv),M.push(A.emissiveMapUv),M.push(A.metalnessMapUv),M.push(A.roughnessMapUv),M.push(A.anisotropyMapUv),M.push(A.clearcoatMapUv),M.push(A.clearcoatNormalMapUv),M.push(A.clearcoatRoughnessMapUv),M.push(A.iridescenceMapUv),M.push(A.iridescenceThicknessMapUv),M.push(A.sheenColorMapUv),M.push(A.sheenRoughnessMapUv),M.push(A.specularMapUv),M.push(A.specularColorMapUv),M.push(A.specularIntensityMapUv),M.push(A.transmissionMapUv),M.push(A.thicknessMapUv),M.push(A.combine),M.push(A.fogExp2),M.push(A.sizeAttenuation),M.push(A.morphTargetsCount),M.push(A.morphAttributeCount),M.push(A.numDirLights),M.push(A.numPointLights),M.push(A.numSpotLights),M.push(A.numSpotLightMaps),M.push(A.numHemiLights),M.push(A.numRectAreaLights),M.push(A.numDirLightShadows),M.push(A.numPointLightShadows),M.push(A.numSpotLightShadows),M.push(A.numSpotLightShadowsWithMaps),M.push(A.numLightProbes),M.push(A.shadowMapType),M.push(A.toneMapping),M.push(A.numClippingPlanes),M.push(A.numClipIntersection),M.push(A.depthPacking)}function S(M,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),M.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),M.push(a.mask)}function b(M){const A=f[M.type];let I;if(A){const D=bi[A];I=cv.clone(D.uniforms)}else I=M.uniforms;return I}function _(M,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new ay(s,A,M,i),l.push(I),h.set(A,I)),I}function E(M){if(--M.usedTimes===0){const A=l.indexOf(M);l[A]=l[l.length-1],l.pop(),h.delete(M.cacheKey),M.destroy()}}function w(M){o.remove(M)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:b,acquireProgram:_,releaseProgram:E,releaseShaderCache:w,programs:l,dispose:R}}function dy(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function fy(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Sf(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function bf(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let S=s[e];return S===void 0?(S={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},s[e]=S):(S.id=d.id,S.object=d,S.geometry=f,S.material=p,S.materialVariant=a(d),S.groupOrder=v,S.renderOrder=d.renderOrder,S.z=m,S.group=g),e++,S}function c(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?n.push(S):p.transparent===!0?i.push(S):t.push(S)}function l(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?n.unshift(S):p.transparent===!0?i.unshift(S):t.unshift(S)}function h(d,f,p){t.length>1&&t.sort(d||fy),n.length>1&&n.sort(f||Sf),i.length>1&&i.sort(f||Sf),p&&(t.reverse(),n.reverse(),i.reverse())}function u(){for(let d=e,f=s.length;d<f;d++){const p=s[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:c,unshift:l,finish:u,sort:h}}function py(){let s=new WeakMap;function e(n,i){const r=s.get(n);let a;return r===void 0?(a=new bf,s.set(n,[a])):i>=r.length?(a=new bf,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function my(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new oe};break;case"SpotLight":t={position:new C,direction:new C,color:new oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new oe,groundColor:new oe};break;case"RectAreaLight":t={color:new oe,position:new C,halfWidth:new C,halfHeight:new C};break}return s[e.id]=t,t}}}function gy(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let vy=0;function My(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function xy(s){const e=new my,t=gy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new C);const i=new C,r=new Ye,a=new Ye;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,S=0,b=0,_=0,E=0,w=0,R=0;l.sort(My);for(let A=0,I=l.length;A<I;A++){const D=l[A],P=D.color,F=D.intensity,H=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Ys?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=P.r*F,u+=P.g*F,d+=P.b*F;else if(D.isLightProbe){for(let V=0;V<9;V++)n.probe[V].addScaledVector(D.sh.coefficients[V],F);R++}else if(D.isDirectionalLight){const V=e.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const z=D.shadow,Y=t.get(D);Y.shadowIntensity=z.intensity,Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,n.directionalShadow[f]=Y,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=V,f++}else if(D.isSpotLight){const V=e.get(D);V.position.setFromMatrixPosition(D.matrixWorld),V.color.copy(P).multiplyScalar(F),V.distance=H,V.coneCos=Math.cos(D.angle),V.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),V.decay=D.decay,n.spot[v]=V;const z=D.shadow;if(D.map&&(n.spotLightMap[E]=D.map,E++,z.updateMatrices(D),D.castShadow&&w++),n.spotLightMatrix[v]=z.matrix,D.castShadow){const Y=t.get(D);Y.shadowIntensity=z.intensity,Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,n.spotShadow[v]=Y,n.spotShadowMap[v]=O,_++}v++}else if(D.isRectAreaLight){const V=e.get(D);V.color.copy(P).multiplyScalar(F),V.halfWidth.set(D.width*.5,0,0),V.halfHeight.set(0,D.height*.5,0),n.rectArea[m]=V,m++}else if(D.isPointLight){const V=e.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),V.distance=D.distance,V.decay=D.decay,D.castShadow){const z=D.shadow,Y=t.get(D);Y.shadowIntensity=z.intensity,Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,Y.shadowCameraNear=z.camera.near,Y.shadowCameraFar=z.camera.far,n.pointShadow[p]=Y,n.pointShadowMap[p]=O,n.pointShadowMatrix[p]=D.shadow.matrix,b++}n.point[p]=V,p++}else if(D.isHemisphereLight){const V=e.get(D);V.skyColor.copy(D.color).multiplyScalar(F),V.groundColor.copy(D.groundColor).multiplyScalar(F),n.hemi[g]=V,g++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pe.LTC_FLOAT_1,n.rectAreaLTC2=pe.LTC_FLOAT_2):(n.rectAreaLTC1=pe.LTC_HALF_1,n.rectAreaLTC2=pe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const M=n.hash;(M.directionalLength!==f||M.pointLength!==p||M.spotLength!==v||M.rectAreaLength!==m||M.hemiLength!==g||M.numDirectionalShadows!==S||M.numPointShadows!==b||M.numSpotShadows!==_||M.numSpotMaps!==E||M.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=m,n.point.length=p,n.hemi.length=g,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=b,n.pointShadowMap.length=b,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=_+E-w,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,M.directionalLength=f,M.pointLength=p,M.spotLength=v,M.rectAreaLength=m,M.hemiLength=g,M.numDirectionalShadows=S,M.numPointShadows=b,M.numSpotShadows=_,M.numSpotMaps=E,M.numLightProbes=R,n.version=vy++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,S=l.length;g<S;g++){const b=l[g];if(b.isDirectionalLight){const _=n.directional[u];_.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(m),u++}else if(b.isSpotLight){const _=n.spot[f];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(m),_.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(m),f++}else if(b.isRectAreaLight){const _=n.rectArea[p];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(m),a.identity(),r.copy(b.matrixWorld),r.premultiply(m),a.extractRotation(r),_.halfWidth.set(b.width*.5,0,0),_.halfHeight.set(0,b.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),p++}else if(b.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(m),d++}else if(b.isHemisphereLight){const _=n.hemi[v];_.direction.setFromMatrixPosition(b.matrixWorld),_.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:n}}function Ef(s){const e=new xy(s),t=[],n=[],i=[];function r(d){u.camera=d,t.length=0,n.length=0,i.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function c(d){i.push(d)}function l(){e.setup(t)}function h(d){e.setupView(t,d)}const u={lightsArray:t,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function _y(s){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new Ef(s),e.set(i,[o])):r>=a.length?(o=new Ef(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const yy=`void main() {
4667
+ `+ne)}else O!==""?we("WebGLProgram: Program Info Log:",O):(V===""||z==="")&&(ee=!1);ee&&(D.diagnostics={runnable:Y,programLog:O,vertexShader:{log:V,prefix:m},fragmentShader:{log:z,prefix:g}})}i.deleteShader(E),i.deleteShader(w),M=new dc(i,v),A=X_(i,v)}let M;this.getUniforms=function(){return M===void 0&&R(this),M};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=i.getProgramParameter(v,O_)),I},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=U_++,this.cacheKey=e,this.usedTimes=1,this.program=v,this.vertexShader=E,this.fragmentShader=w,this}let oy=0;class cy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new ly(e),t.set(e,n)),n}}class ly{constructor(e){this.id=oy++,this.code=e,this.usedTimes=0}}function hy(s){return s===Ys||s===xc||s===_c}function uy(s,e,t,n,i,r){const a=new id,o=new cy,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(M){return c.add(M),M===0?"uv":`uv${M}`}function v(M,A,I,D,P,F){const H=D.fog,O=P.geometry,V=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?D.environment:null,z=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap,Y=e.get(M.envMap||V,z),ee=Y&&Y.mapping===Gc?Y.image.height:null,J=f[M.type];M.precision!==null&&(d=n.getMaxPrecision(M.precision),d!==M.precision&&we("WebGLProgram.getParameters:",M.precision,"not supported, using",d,"instead."));const ne=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ae=ne!==void 0?ne.length:0;let Ve=0;O.morphAttributes.position!==void 0&&(Ve=1),O.morphAttributes.normal!==void 0&&(Ve=2),O.morphAttributes.color!==void 0&&(Ve=3);let je,He,K,re;if(J){const ye=bi[J];je=ye.vertexShader,He=ye.fragmentShader}else{je=M.vertexShader,He=M.fragmentShader;const ye=o.getVertexShaderStage(M),Ot=o.getFragmentShaderStage(M);o.update(M,ye,Ot),K=ye.id,re=Ot.id}const ie=s.getRenderTarget(),B=s.state.buffers.depth.getReversed(),Ee=P.isInstancedMesh===!0,Pe=P.isBatchedMesh===!0,Re=!!M.map,xe=!!M.matcap,Ne=!!Y,Oe=!!M.aoMap,Ue=!!M.lightMap,at=!!M.bumpMap&&M.wireframe===!1,ot=!!M.normalMap,Lt=!!M.displacementMap,Et=!!M.emissiveMap,Nt=!!M.metalnessMap,Wt=!!M.roughnessMap,N=M.anisotropy>0,Rn=M.clearcoat>0,ct=M.dispersion>0,T=M.iridescence>0,x=M.sheen>0,k=M.transmission>0,X=N&&!!M.anisotropyMap,$=Rn&&!!M.clearcoatMap,se=Rn&&!!M.clearcoatNormalMap,le=Rn&&!!M.clearcoatRoughnessMap,Z=T&&!!M.iridescenceMap,Q=T&&!!M.iridescenceThicknessMap,he=x&&!!M.sheenColorMap,De=x&&!!M.sheenRoughnessMap,fe=!!M.specularMap,ue=!!M.specularColorMap,Le=!!M.specularIntensityMap,Fe=k&&!!M.transmissionMap,Xe=k&&!!M.thicknessMap,L=!!M.gradientMap,ce=!!M.alphaMap,j=M.alphaTest>0,de=!!M.alphaHash,ve=!!M.extensions;let te=Ii;M.toneMapped&&(ie===null||ie.isXRRenderTarget===!0)&&(te=s.toneMapping);const Te={shaderID:J,shaderType:M.type,shaderName:M.name,vertexShader:je,fragmentShader:He,defines:M.defines,customVertexShaderID:K,customFragmentShaderID:re,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:d,batching:Pe,batchingColor:Pe&&P._colorsTexture!==null,instancing:Ee,instancingColor:Ee&&P.instanceColor!==null,instancingMorph:Ee&&P.morphTexture!==null,outputColorSpace:ie===null?s.outputColorSpace:ie.isXRRenderTarget===!0?ie.texture.colorSpace:et.workingColorSpace,alphaToCoverage:!!M.alphaToCoverage,map:Re,matcap:xe,envMap:Ne,envMapMode:Ne&&Y.mapping,envMapCubeUVHeight:ee,aoMap:Oe,lightMap:Ue,bumpMap:at,normalMap:ot,displacementMap:Lt,emissiveMap:Et,normalMapObjectSpace:ot&&M.normalMapType===i2,normalMapTangentSpace:ot&&M.normalMapType===Sc,packedNormalMap:ot&&M.normalMapType===Sc&&hy(M.normalMap.format),metalnessMap:Nt,roughnessMap:Wt,anisotropy:N,anisotropyMap:X,clearcoat:Rn,clearcoatMap:$,clearcoatNormalMap:se,clearcoatRoughnessMap:le,dispersion:ct,iridescence:T,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:x,sheenColorMap:he,sheenRoughnessMap:De,specularMap:fe,specularColorMap:ue,specularIntensityMap:Le,transmission:k,transmissionMap:Fe,thicknessMap:Xe,gradientMap:L,opaque:M.transparent===!1&&M.blending===zr&&M.alphaToCoverage===!1,alphaMap:ce,alphaTest:j,alphaHash:de,combine:M.combine,mapUv:Re&&p(M.map.channel),aoMapUv:Oe&&p(M.aoMap.channel),lightMapUv:Ue&&p(M.lightMap.channel),bumpMapUv:at&&p(M.bumpMap.channel),normalMapUv:ot&&p(M.normalMap.channel),displacementMapUv:Lt&&p(M.displacementMap.channel),emissiveMapUv:Et&&p(M.emissiveMap.channel),metalnessMapUv:Nt&&p(M.metalnessMap.channel),roughnessMapUv:Wt&&p(M.roughnessMap.channel),anisotropyMapUv:X&&p(M.anisotropyMap.channel),clearcoatMapUv:$&&p(M.clearcoatMap.channel),clearcoatNormalMapUv:se&&p(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&p(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(M.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(M.iridescenceThicknessMap.channel),sheenColorMapUv:he&&p(M.sheenColorMap.channel),sheenRoughnessMapUv:De&&p(M.sheenRoughnessMap.channel),specularMapUv:fe&&p(M.specularMap.channel),specularColorMapUv:ue&&p(M.specularColorMap.channel),specularIntensityMapUv:Le&&p(M.specularIntensityMap.channel),transmissionMapUv:Fe&&p(M.transmissionMap.channel),thicknessMapUv:Xe&&p(M.thicknessMap.channel),alphaMapUv:ce&&p(M.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ot||N),vertexNormals:!!O.attributes.normal,vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!O.attributes.uv&&(Re||ce),fog:!!H,useFog:M.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:M.wireframe===!1&&(M.flatShading===!0||O.attributes.normal===void 0&&ot===!1&&(M.isMeshLambertMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isMeshPhysicalMaterial)),sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:B,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:Ve,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:F.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:M.dithering,shadowMapEnabled:s.shadowMap.enabled&&I.length>0,shadowMapType:s.shadowMap.type,toneMapping:te,decodeVideoTexture:Re&&M.map.isVideoTexture===!0&&et.getTransfer(M.map.colorSpace)===lt,decodeVideoTextureEmissive:Et&&M.emissiveMap.isVideoTexture===!0&&et.getTransfer(M.emissiveMap.colorSpace)===lt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===ai,flipSided:M.side===Ct,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:ve&&M.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ve&&M.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return Te.vertexUv1s=c.has(1),Te.vertexUv2s=c.has(2),Te.vertexUv3s=c.has(3),c.clear(),Te}function m(M){const A=[];if(M.shaderID?A.push(M.shaderID):(A.push(M.customVertexShaderID),A.push(M.customFragmentShaderID)),M.defines!==void 0)for(const I in M.defines)A.push(I),A.push(M.defines[I]);return M.isRawShaderMaterial===!1&&(g(A,M),S(A,M),A.push(s.outputColorSpace)),A.push(M.customProgramCacheKey),A.join()}function g(M,A){M.push(A.precision),M.push(A.outputColorSpace),M.push(A.envMapMode),M.push(A.envMapCubeUVHeight),M.push(A.mapUv),M.push(A.alphaMapUv),M.push(A.lightMapUv),M.push(A.aoMapUv),M.push(A.bumpMapUv),M.push(A.normalMapUv),M.push(A.displacementMapUv),M.push(A.emissiveMapUv),M.push(A.metalnessMapUv),M.push(A.roughnessMapUv),M.push(A.anisotropyMapUv),M.push(A.clearcoatMapUv),M.push(A.clearcoatNormalMapUv),M.push(A.clearcoatRoughnessMapUv),M.push(A.iridescenceMapUv),M.push(A.iridescenceThicknessMapUv),M.push(A.sheenColorMapUv),M.push(A.sheenRoughnessMapUv),M.push(A.specularMapUv),M.push(A.specularColorMapUv),M.push(A.specularIntensityMapUv),M.push(A.transmissionMapUv),M.push(A.thicknessMapUv),M.push(A.combine),M.push(A.fogExp2),M.push(A.sizeAttenuation),M.push(A.morphTargetsCount),M.push(A.morphAttributeCount),M.push(A.numDirLights),M.push(A.numPointLights),M.push(A.numSpotLights),M.push(A.numSpotLightMaps),M.push(A.numHemiLights),M.push(A.numRectAreaLights),M.push(A.numDirLightShadows),M.push(A.numPointLightShadows),M.push(A.numSpotLightShadows),M.push(A.numSpotLightShadowsWithMaps),M.push(A.numLightProbes),M.push(A.shadowMapType),M.push(A.toneMapping),M.push(A.numClippingPlanes),M.push(A.numClipIntersection),M.push(A.depthPacking)}function S(M,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),M.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),M.push(a.mask)}function b(M){const A=f[M.type];let I;if(A){const D=bi[A];I=cv.clone(D.uniforms)}else I=M.uniforms;return I}function _(M,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new ay(s,A,M,i),l.push(I),h.set(A,I)),I}function E(M){if(--M.usedTimes===0){const A=l.indexOf(M);l[A]=l[l.length-1],l.pop(),h.delete(M.cacheKey),M.destroy()}}function w(M){o.remove(M)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:b,acquireProgram:_,releaseProgram:E,releaseShaderCache:w,programs:l,dispose:R}}function dy(){let s=new WeakMap;function e(a){return s.has(a)}function t(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function fy(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.materialVariant!==e.materialVariant?s.materialVariant-e.materialVariant:s.z!==e.z?s.z-e.z:s.id-e.id}function Sf(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function bf(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let S=s[e];return S===void 0?(S={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},s[e]=S):(S.id=d.id,S.object=d,S.geometry=f,S.material=p,S.materialVariant=a(d),S.groupOrder=v,S.renderOrder=d.renderOrder,S.z=m,S.group=g),e++,S}function c(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?n.push(S):p.transparent===!0?i.push(S):t.push(S)}function l(d,f,p,v,m,g){const S=o(d,f,p,v,m,g);p.transmission>0?n.unshift(S):p.transparent===!0?i.unshift(S):t.unshift(S)}function h(d,f,p){t.length>1&&t.sort(d||fy),n.length>1&&n.sort(f||Sf),i.length>1&&i.sort(f||Sf),p&&(t.reverse(),n.reverse(),i.reverse())}function u(){for(let d=e,f=s.length;d<f;d++){const p=s[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:c,unshift:l,finish:u,sort:h}}function py(){let s=new WeakMap;function e(n,i){const r=s.get(n);let a;return r===void 0?(a=new bf,s.set(n,[a])):i>=r.length?(a=new bf,r.push(a)):a=r[i],a}function t(){s=new WeakMap}return{get:e,dispose:t}}function my(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new oe};break;case"SpotLight":t={position:new C,direction:new C,color:new oe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new oe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new oe,groundColor:new oe};break;case"RectAreaLight":t={color:new oe,position:new C,halfWidth:new C,halfHeight:new C};break}return s[e.id]=t,t}}}function gy(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let vy=0;function My(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function xy(s){const e=new my,t=gy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new C);const i=new C,r=new Ye,a=new Ye;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,S=0,b=0,_=0,E=0,w=0,R=0;l.sort(My);for(let A=0,I=l.length;A<I;A++){const D=l[A],P=D.color,F=D.intensity,H=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Ys?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=P.r*F,u+=P.g*F,d+=P.b*F;else if(D.isLightProbe){for(let V=0;V<9;V++)n.probe[V].addScaledVector(D.sh.coefficients[V],F);R++}else if(D.isDirectionalLight){const V=e.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const z=D.shadow,Y=t.get(D);Y.shadowIntensity=z.intensity,Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,n.directionalShadow[f]=Y,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=V,f++}else if(D.isSpotLight){const V=e.get(D);V.position.setFromMatrixPosition(D.matrixWorld),V.color.copy(P).multiplyScalar(F),V.distance=H,V.coneCos=Math.cos(D.angle),V.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),V.decay=D.decay,n.spot[v]=V;const z=D.shadow;if(D.map&&(n.spotLightMap[E]=D.map,E++,z.updateMatrices(D),D.castShadow&&w++),n.spotLightMatrix[v]=z.matrix,D.castShadow){const Y=t.get(D);Y.shadowIntensity=z.intensity,Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,n.spotShadow[v]=Y,n.spotShadowMap[v]=O,_++}v++}else if(D.isRectAreaLight){const V=e.get(D);V.color.copy(P).multiplyScalar(F),V.halfWidth.set(D.width*.5,0,0),V.halfHeight.set(0,D.height*.5,0),n.rectArea[m]=V,m++}else if(D.isPointLight){const V=e.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),V.distance=D.distance,V.decay=D.decay,D.castShadow){const z=D.shadow,Y=t.get(D);Y.shadowIntensity=z.intensity,Y.shadowBias=z.bias,Y.shadowNormalBias=z.normalBias,Y.shadowRadius=z.radius,Y.shadowMapSize=z.mapSize,Y.shadowCameraNear=z.camera.near,Y.shadowCameraFar=z.camera.far,n.pointShadow[p]=Y,n.pointShadowMap[p]=O,n.pointShadowMatrix[p]=D.shadow.matrix,b++}n.point[p]=V,p++}else if(D.isHemisphereLight){const V=e.get(D);V.skyColor.copy(D.color).multiplyScalar(F),V.groundColor.copy(D.groundColor).multiplyScalar(F),n.hemi[g]=V,g++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pe.LTC_FLOAT_1,n.rectAreaLTC2=pe.LTC_FLOAT_2):(n.rectAreaLTC1=pe.LTC_HALF_1,n.rectAreaLTC2=pe.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const M=n.hash;(M.directionalLength!==f||M.pointLength!==p||M.spotLength!==v||M.rectAreaLength!==m||M.hemiLength!==g||M.numDirectionalShadows!==S||M.numPointShadows!==b||M.numSpotShadows!==_||M.numSpotMaps!==E||M.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=m,n.point.length=p,n.hemi.length=g,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=b,n.pointShadowMap.length=b,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=_+E-w,n.spotLightMap.length=E,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,M.directionalLength=f,M.pointLength=p,M.spotLength=v,M.rectAreaLength=m,M.hemiLength=g,M.numDirectionalShadows=S,M.numPointShadows=b,M.numSpotShadows=_,M.numSpotMaps=E,M.numLightProbes=R,n.version=vy++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,S=l.length;g<S;g++){const b=l[g];if(b.isDirectionalLight){const _=n.directional[u];_.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(m),u++}else if(b.isSpotLight){const _=n.spot[f];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(m),_.direction.setFromMatrixPosition(b.matrixWorld),i.setFromMatrixPosition(b.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(m),f++}else if(b.isRectAreaLight){const _=n.rectArea[p];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(m),a.identity(),r.copy(b.matrixWorld),r.premultiply(m),a.extractRotation(r),_.halfWidth.set(b.width*.5,0,0),_.halfHeight.set(0,b.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),p++}else if(b.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(b.matrixWorld),_.position.applyMatrix4(m),d++}else if(b.isHemisphereLight){const _=n.hemi[v];_.direction.setFromMatrixPosition(b.matrixWorld),_.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:n}}function Ef(s){const e=new xy(s),t=[],n=[],i=[];function r(d){u.camera=d,t.length=0,n.length=0,i.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function c(d){i.push(d)}function l(){e.setup(t)}function h(d){e.setupView(t,d)}const u={lightsArray:t,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function _y(s){let e=new WeakMap;function t(i,r=0){const a=e.get(i);let o;return a===void 0?(o=new Ef(s),e.set(i,[o])):r>=a.length?(o=new Ef(s),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const yy=`void main() {
4668
4668
  gl_Position = vec4( position, 1.0 );
4669
4669
  }`,Sy=`uniform sampler2D shadow_pass;
4670
4670
  uniform vec2 resolution;
@@ -4691,7 +4691,7 @@ void main() {
4691
4691
  squared_mean = squared_mean / samples;
4692
4692
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4693
4693
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4694
- }`,by=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],Ey=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],wf=new Ye,ma=new C,Hl=new C;function wy(s,e,t){let n=new rd;const i=new Ae,r=new Ae,a=new nt,o=new dv,c=new fv,l={},h=t.maxTextureSize,u={[Ss]:Ct,[Ct]:Ss,[ai]:ai},d=new Rt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:yy,fragmentShader:Sy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new yt;p.setAttribute("position",new rt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ia;let g=this.type;this.render=function(w,R,M){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===P1&&(we("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Ia);const A=s.getRenderTarget(),I=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),P=s.state;P.setBlending(Ci),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const F=g!==this.type;F&&R.traverse(function(H){H.material&&(Array.isArray(H.material)?H.material.forEach(O=>O.needsUpdate=!0):H.material.needsUpdate=!0)});for(let H=0,O=w.length;H<O;H++){const V=w[H],z=V.shadow;if(z===void 0){we("WebGLShadowMap:",V,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;i.copy(z.mapSize);const Y=z.getFrameExtents();i.multiply(Y),r.copy(z.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Y.x),i.x=r.x*Y.x,z.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Y.y),i.y=r.y*Y.y,z.mapSize.y=r.y));const ee=s.state.buffers.depth.getReversed();if(z.camera._reversedDepth=ee,z.map===null||F===!0){if(z.map!==null&&(z.map.depthTexture!==null&&(z.map.depthTexture.dispose(),z.map.depthTexture=null),z.map.dispose()),this.type===ba){if(V.isPointLight){we("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new dn(i.x,i.y,{format:Ys,type:cn,minFilter:dt,magFilter:dt,generateMipmaps:!1}),z.map.texture.name=V.name+".shadowMap",z.map.depthTexture=new Ks(i.x,i.y,Tn),z.map.depthTexture.name=V.name+".shadowMapDepth",z.map.depthTexture.format=Zi,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Tt,z.map.depthTexture.magFilter=Tt}else V.isPointLight?(z.map=new Im(i.x),z.map.depthTexture=new av(i.x,li)):(z.map=new dn(i.x,i.y),z.map.depthTexture=new Ks(i.x,i.y,li)),z.map.depthTexture.name=V.name+".shadowMap",z.map.depthTexture.format=Zi,this.type===Ia?(z.map.depthTexture.compareFunction=ee?ed:Qu,z.map.depthTexture.minFilter=dt,z.map.depthTexture.magFilter=dt):(z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Tt,z.map.depthTexture.magFilter=Tt);z.camera.updateProjectionMatrix()}const J=z.map.isWebGLCubeRenderTarget?6:1;for(let ne=0;ne<J;ne++){if(z.map.isWebGLCubeRenderTarget)s.setRenderTarget(z.map,ne),s.clear();else{ne===0&&(s.setRenderTarget(z.map),s.clear());const ae=z.getViewport(ne);a.set(r.x*ae.x,r.y*ae.y,r.x*ae.z,r.y*ae.w),P.viewport(a)}if(V.isPointLight){const ae=z.camera,Ve=z.matrix,je=V.distance||ae.far;je!==ae.far&&(ae.far=je,ae.updateProjectionMatrix()),ma.setFromMatrixPosition(V.matrixWorld),ae.position.copy(ma),Hl.copy(ae.position),Hl.add(by[ne]),ae.up.copy(Ey[ne]),ae.lookAt(Hl),ae.updateMatrixWorld(),Ve.makeTranslation(-ma.x,-ma.y,-ma.z),wf.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),z._frustum.setFromProjectionMatrix(wf,ae.coordinateSystem,ae.reversedDepth)}else z.updateMatrices(V);n=z.getFrustum(),_(R,M,z.camera,V,this.type)}z.isPointLightShadow!==!0&&this.type===ba&&S(z,M),z.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(A,I,D)};function S(w,R){const M=e.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new dn(i.x,i.y,{format:Ys,type:cn})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(R,null,M,d,v,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(R,null,M,f,v,null)}function b(w,R,M,A){let I=null;const D=M.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(D!==void 0)I=D;else if(I=M.isPointLight===!0?c:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const P=I.uuid,F=R.uuid;let H=l[P];H===void 0&&(H={},l[P]=H);let O=H[F];O===void 0&&(O=I.clone(),H[F]=O,R.addEventListener("dispose",E)),I=O}if(I.visible=R.visible,I.wireframe=R.wireframe,A===ba?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:u[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,M.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const P=s.properties.get(I);P.light=M}return I}function _(w,R,M,A,I){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&I===ba)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);const F=e.update(w),H=w.material;if(Array.isArray(H)){const O=F.groups;for(let V=0,z=O.length;V<z;V++){const Y=O[V],ee=H[Y.materialIndex];if(ee&&ee.visible){const J=b(w,ee,A,I);w.onBeforeShadow(s,w,R,M,F,J,Y),s.renderBufferDirect(M,null,F,J,w,Y),w.onAfterShadow(s,w,R,M,F,J,Y)}}}else if(H.visible){const O=b(w,H,A,I);w.onBeforeShadow(s,w,R,M,F,O,null),s.renderBufferDirect(M,null,F,O,w,null),w.onAfterShadow(s,w,R,M,F,O,null)}}const P=w.children;for(let F=0,H=P.length;F<H;F++)_(P[F],R,M,A,I)}function E(w){w.target.removeEventListener("dispose",E);for(const M in l){const A=l[M],I=w.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function Ay(s,e){function t(){let L=!1;const ce=new nt;let j=null;const de=new nt(0,0,0,0);return{setMask:function(ve){j!==ve&&!L&&(s.colorMask(ve,ve,ve,ve),j=ve)},setLocked:function(ve){L=ve},setClear:function(ve,te,Te,ye,Ot){Ot===!0&&(ve*=ye,te*=ye,Te*=ye),ce.set(ve,te,Te,ye),de.equals(ce)===!1&&(s.clearColor(ve,te,Te,ye),de.copy(ce))},reset:function(){L=!1,j=null,de.set(-1,0,0,0)}}}function n(){let L=!1,ce=!1,j=null,de=null,ve=null;return{setReversed:function(te){if(ce!==te){const Te=e.get("EXT_clip_control");te?Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.ZERO_TO_ONE_EXT):Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.NEGATIVE_ONE_TO_ONE_EXT),ce=te;const ye=ve;ve=null,this.setClear(ye)}},getReversed:function(){return ce},setTest:function(te){te?ie(s.DEPTH_TEST):B(s.DEPTH_TEST)},setMask:function(te){j!==te&&!L&&(s.depthMask(te),j=te)},setFunc:function(te){if(ce&&(te=p2[te]),de!==te){switch(te){case Sh:s.depthFunc(s.NEVER);break;case bh:s.depthFunc(s.ALWAYS);break;case Eh:s.depthFunc(s.LESS);break;case Yr:s.depthFunc(s.LEQUAL);break;case wh:s.depthFunc(s.EQUAL);break;case Ah:s.depthFunc(s.GEQUAL);break;case Th:s.depthFunc(s.GREATER);break;case Rh:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}de=te}},setLocked:function(te){L=te},setClear:function(te){ve!==te&&(ve=te,ce&&(te=1-te),s.clearDepth(te))},reset:function(){L=!1,j=null,de=null,ve=null,ce=!1}}}function i(){let L=!1,ce=null,j=null,de=null,ve=null,te=null,Te=null,ye=null,Ot=null;return{setTest:function(vt){L||(vt?ie(s.STENCIL_TEST):B(s.STENCIL_TEST))},setMask:function(vt){ce!==vt&&!L&&(s.stencilMask(vt),ce=vt)},setFunc:function(vt,fi,pi){(j!==vt||de!==fi||ve!==pi)&&(s.stencilFunc(vt,fi,pi),j=vt,de=fi,ve=pi)},setOp:function(vt,fi,pi){(te!==vt||Te!==fi||ye!==pi)&&(s.stencilOp(vt,fi,pi),te=vt,Te=fi,ye=pi)},setLocked:function(vt){L=vt},setClear:function(vt){Ot!==vt&&(s.clearStencil(vt),Ot=vt)},reset:function(){L=!1,ce=null,j=null,de=null,ve=null,te=null,Te=null,ye=null,Ot=null}}}const r=new t,a=new n,o=new i,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,b=null,_=null,E=null,w=null,R=null,M=new oe(0,0,0),A=0,I=!1,D=null,P=null,F=null,H=null,O=null;const V=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let z=!1,Y=0;const ee=s.getParameter(s.VERSION);ee.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(ee)[1]),z=Y>=1):ee.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),z=Y>=2);let J=null,ne={};const ae=s.getParameter(s.SCISSOR_BOX),Ve=s.getParameter(s.VIEWPORT),je=new nt().fromArray(ae),Be=new nt().fromArray(Ve);function K(L,ce,j,de){const ve=new Uint8Array(4),te=s.createTexture();s.bindTexture(L,te),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Te=0;Te<j;Te++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(ce,0,s.RGBA,1,1,de,0,s.RGBA,s.UNSIGNED_BYTE,ve):s.texImage2D(ce+Te,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ve);return te}const re={};re[s.TEXTURE_2D]=K(s.TEXTURE_2D,s.TEXTURE_2D,1),re[s.TEXTURE_CUBE_MAP]=K(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[s.TEXTURE_2D_ARRAY]=K(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),re[s.TEXTURE_3D]=K(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ie(s.DEPTH_TEST),a.setFunc(Yr),at(!1),ot(s0),ie(s.CULL_FACE),Oe(Ci);function ie(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function B(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Ee(L,ce){return d[L]!==ce?(s.bindFramebuffer(L,ce),d[L]=ce,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=ce),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=ce),!0):!1}function Pe(L,ce){let j=p,de=!1;if(L){j=f.get(ce),j===void 0&&(j=[],f.set(ce,j));const ve=L.textures;if(j.length!==ve.length||j[0]!==s.COLOR_ATTACHMENT0){for(let te=0,Te=ve.length;te<Te;te++)j[te]=s.COLOR_ATTACHMENT0+te;j.length=ve.length,de=!0}}else j[0]!==s.BACK&&(j[0]=s.BACK,de=!0);de&&s.drawBuffers(j)}function Re(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const xe={[Os]:s.FUNC_ADD,[N1]:s.FUNC_SUBTRACT,[O1]:s.FUNC_REVERSE_SUBTRACT};xe[U1]=s.MIN,xe[F1]=s.MAX;const Ne={[k1]:s.ZERO,[z1]:s.ONE,[B1]:s.SRC_COLOR,[_h]:s.SRC_ALPHA,[q1]:s.SRC_ALPHA_SATURATE,[W1]:s.DST_COLOR,[G1]:s.DST_ALPHA,[H1]:s.ONE_MINUS_SRC_COLOR,[yh]:s.ONE_MINUS_SRC_ALPHA,[X1]:s.ONE_MINUS_DST_COLOR,[V1]:s.ONE_MINUS_DST_ALPHA,[Y1]:s.CONSTANT_COLOR,[K1]:s.ONE_MINUS_CONSTANT_COLOR,[$1]:s.CONSTANT_ALPHA,[Z1]:s.ONE_MINUS_CONSTANT_ALPHA};function Oe(L,ce,j,de,ve,te,Te,ye,Ot,vt){if(L===Ci){m===!0&&(B(s.BLEND),m=!1);return}if(m===!1&&(ie(s.BLEND),m=!0),L!==L1){if(L!==g||vt!==I){if((S!==Os||E!==Os)&&(s.blendEquation(s.FUNC_ADD),S=Os,E=Os),vt)switch(L){case zr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Gn:s.blendFunc(s.ONE,s.ONE);break;case r0:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case a0:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:ke("WebGLState: Invalid blending: ",L);break}else switch(L){case zr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Gn:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case r0:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case a0:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",L);break}b=null,_=null,w=null,R=null,M.set(0,0,0),A=0,g=L,I=vt}return}ve=ve||ce,te=te||j,Te=Te||de,(ce!==S||ve!==E)&&(s.blendEquationSeparate(xe[ce],xe[ve]),S=ce,E=ve),(j!==b||de!==_||te!==w||Te!==R)&&(s.blendFuncSeparate(Ne[j],Ne[de],Ne[te],Ne[Te]),b=j,_=de,w=te,R=Te),(ye.equals(M)===!1||Ot!==A)&&(s.blendColor(ye.r,ye.g,ye.b,Ot),M.copy(ye),A=Ot),g=L,I=!1}function Ue(L,ce){L.side===ai?B(s.CULL_FACE):ie(s.CULL_FACE);let j=L.side===Ct;ce&&(j=!j),at(j),L.blending===zr&&L.transparent===!1?Oe(Ci):Oe(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const de=L.stencilWrite;o.setTest(de),de&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Et(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ie(s.SAMPLE_ALPHA_TO_COVERAGE):B(s.SAMPLE_ALPHA_TO_COVERAGE)}function at(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function ot(L){L!==C1?(ie(s.CULL_FACE),L!==P&&(L===s0?s.cullFace(s.BACK):L===I1?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):B(s.CULL_FACE),P=L}function Lt(L){L!==F&&(z&&s.lineWidth(L),F=L)}function Et(L,ce,j){L?(ie(s.POLYGON_OFFSET_FILL),(H!==ce||O!==j)&&(H=ce,O=j,a.getReversed()&&(ce=-ce),s.polygonOffset(ce,j))):B(s.POLYGON_OFFSET_FILL)}function Nt(L){L?ie(s.SCISSOR_TEST):B(s.SCISSOR_TEST)}function Wt(L){L===void 0&&(L=s.TEXTURE0+V-1),J!==L&&(s.activeTexture(L),J=L)}function N(L,ce,j){j===void 0&&(J===null?j=s.TEXTURE0+V-1:j=J);let de=ne[j];de===void 0&&(de={type:void 0,texture:void 0},ne[j]=de),(de.type!==L||de.texture!==ce)&&(J!==j&&(s.activeTexture(j),J=j),s.bindTexture(L,ce||re[L]),de.type=L,de.texture=ce)}function Rn(){const L=ne[J];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ct(){try{s.compressedTexImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function x(){try{s.texSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function k(){try{s.texSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function X(){try{s.compressedTexSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function $(){try{s.compressedTexSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function se(){try{s.texStorage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function le(){try{s.texStorage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function Z(){try{s.texImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function he(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function De(L,ce){u[L]!==ce&&(s.pixelStorei(L,ce),u[L]=ce)}function fe(L){je.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),je.copy(L))}function ue(L){Be.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),Be.copy(L))}function Le(L,ce){let j=l.get(ce);j===void 0&&(j=new WeakMap,l.set(ce,j));let de=j.get(L);de===void 0&&(de=s.getUniformBlockIndex(ce,L.name),j.set(L,de))}function Fe(L,ce){const de=l.get(ce).get(L);c.get(ce)!==de&&(s.uniformBlockBinding(ce,de,L.__bindingPointIndex),c.set(ce,de))}function Xe(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,ne={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,b=null,_=null,E=null,w=null,R=null,M=new oe(0,0,0),A=0,I=!1,D=null,P=null,F=null,H=null,O=null,je.set(0,0,s.canvas.width,s.canvas.height),Be.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ie,disable:B,bindFramebuffer:Ee,drawBuffers:Pe,useProgram:Re,setBlending:Oe,setMaterial:Ue,setFlipSided:at,setCullFace:ot,setLineWidth:Lt,setPolygonOffset:Et,setScissorTest:Nt,activeTexture:Wt,bindTexture:N,unbindTexture:Rn,compressedTexImage2D:ct,compressedTexImage3D:T,texImage2D:Z,texImage3D:Q,pixelStorei:De,getParameter:he,updateUBOMapping:Le,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:le,texSubImage2D:x,texSubImage3D:k,compressedTexSubImage2D:X,compressedTexSubImage3D:$,scissor:fe,viewport:ue,reset:Xe}}function Ty(s,e,t,n,i,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ae,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(T,x){return p?new OffscreenCanvas(T,x):Ka("canvas")}function m(T,x,k){let X=1;const $=ct(T);if(($.width>k||$.height>k)&&(X=k/Math.max($.width,$.height)),X<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const se=Math.floor(X*$.width),le=Math.floor(X*$.height);d===void 0&&(d=v(se,le));const Z=x?v(se,le):d;return Z.width=se,Z.height=le,Z.getContext("2d").drawImage(T,0,0,se,le),we("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+se+"x"+le+")."),Z}else return"data"in T&&we("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function g(T){return T.generateMipmaps}function S(T){s.generateMipmap(T)}function b(T){return T.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?s.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function _(T,x,k,X,$,se=!1){if(T!==null){if(s[T]!==void 0)return s[T];we("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let le;X&&(le=e.get("EXT_texture_norm16"),le||we("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=x;if(x===s.RED&&(k===s.FLOAT&&(Z=s.R32F),k===s.HALF_FLOAT&&(Z=s.R16F),k===s.UNSIGNED_BYTE&&(Z=s.R8),k===s.UNSIGNED_SHORT&&le&&(Z=le.R16_EXT),k===s.SHORT&&le&&(Z=le.R16_SNORM_EXT)),x===s.RED_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.R8UI),k===s.UNSIGNED_SHORT&&(Z=s.R16UI),k===s.UNSIGNED_INT&&(Z=s.R32UI),k===s.BYTE&&(Z=s.R8I),k===s.SHORT&&(Z=s.R16I),k===s.INT&&(Z=s.R32I)),x===s.RG&&(k===s.FLOAT&&(Z=s.RG32F),k===s.HALF_FLOAT&&(Z=s.RG16F),k===s.UNSIGNED_BYTE&&(Z=s.RG8),k===s.UNSIGNED_SHORT&&le&&(Z=le.RG16_EXT),k===s.SHORT&&le&&(Z=le.RG16_SNORM_EXT)),x===s.RG_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.RG8UI),k===s.UNSIGNED_SHORT&&(Z=s.RG16UI),k===s.UNSIGNED_INT&&(Z=s.RG32UI),k===s.BYTE&&(Z=s.RG8I),k===s.SHORT&&(Z=s.RG16I),k===s.INT&&(Z=s.RG32I)),x===s.RGB_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.RGB8UI),k===s.UNSIGNED_SHORT&&(Z=s.RGB16UI),k===s.UNSIGNED_INT&&(Z=s.RGB32UI),k===s.BYTE&&(Z=s.RGB8I),k===s.SHORT&&(Z=s.RGB16I),k===s.INT&&(Z=s.RGB32I)),x===s.RGBA_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.RGBA8UI),k===s.UNSIGNED_SHORT&&(Z=s.RGBA16UI),k===s.UNSIGNED_INT&&(Z=s.RGBA32UI),k===s.BYTE&&(Z=s.RGBA8I),k===s.SHORT&&(Z=s.RGBA16I),k===s.INT&&(Z=s.RGBA32I)),x===s.RGB&&(k===s.UNSIGNED_SHORT&&le&&(Z=le.RGB16_EXT),k===s.SHORT&&le&&(Z=le.RGB16_SNORM_EXT),k===s.UNSIGNED_INT_5_9_9_9_REV&&(Z=s.RGB9_E5),k===s.UNSIGNED_INT_10F_11F_11F_REV&&(Z=s.R11F_G11F_B10F)),x===s.RGBA){const Q=se?Ec:et.getTransfer($);k===s.FLOAT&&(Z=s.RGBA32F),k===s.HALF_FLOAT&&(Z=s.RGBA16F),k===s.UNSIGNED_BYTE&&(Z=Q===lt?s.SRGB8_ALPHA8:s.RGBA8),k===s.UNSIGNED_SHORT&&le&&(Z=le.RGBA16_EXT),k===s.SHORT&&le&&(Z=le.RGBA16_SNORM_EXT),k===s.UNSIGNED_SHORT_4_4_4_4&&(Z=s.RGBA4),k===s.UNSIGNED_SHORT_5_5_5_1&&(Z=s.RGB5_A1)}return(Z===s.R16F||Z===s.R32F||Z===s.RG16F||Z===s.RG32F||Z===s.RGBA16F||Z===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Z}function E(T,x){let k;return T?x===null||x===li||x===qa?k=s.DEPTH24_STENCIL8:x===Tn?k=s.DEPTH32F_STENCIL8:x===Xa&&(k=s.DEPTH24_STENCIL8,we("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===li||x===qa?k=s.DEPTH_COMPONENT24:x===Tn?k=s.DEPTH_COMPONENT32F:x===Xa&&(k=s.DEPTH_COMPONENT16),k}function w(T,x){return g(T)===!0||T.isFramebufferTexture&&T.minFilter!==Tt&&T.minFilter!==dt?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function R(T){const x=T.target;x.removeEventListener("dispose",R),A(x),x.isVideoTexture&&h.delete(x),x.isHTMLTexture&&u.delete(x)}function M(T){const x=T.target;x.removeEventListener("dispose",M),D(x)}function A(T){const x=n.get(T);if(x.__webglInit===void 0)return;const k=T.source,X=f.get(k);if(X){const $=X[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(T),Object.keys(X).length===0&&f.delete(k)}n.remove(T)}function I(T){const x=n.get(T);s.deleteTexture(x.__webglTexture);const k=T.source,X=f.get(k);delete X[x.__cacheKey],a.memory.textures--}function D(T){const x=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let $=0;$<x.__webglFramebuffer[X].length;$++)s.deleteFramebuffer(x.__webglFramebuffer[X][$]);else s.deleteFramebuffer(x.__webglFramebuffer[X]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[X])}else{if(Array.isArray(x.__webglFramebuffer))for(let X=0;X<x.__webglFramebuffer.length;X++)s.deleteFramebuffer(x.__webglFramebuffer[X]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let X=0;X<x.__webglColorRenderbuffer.length;X++)x.__webglColorRenderbuffer[X]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[X]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const k=T.textures;for(let X=0,$=k.length;X<$;X++){const se=n.get(k[X]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(k[X])}n.remove(T)}let P=0;function F(){P=0}function H(){return P}function O(T){P=T}function V(){const T=P;return T>=i.maxTextures&&we("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),P+=1,T}function z(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function Y(T,x){const k=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&k.__version!==T.version){const X=T.image;if(X===null)we("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)we("WebGLRenderer: Texture marked for update but image is incomplete");else{B(k,T,x);return}}else T.isExternalTexture&&(k.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,k.__webglTexture,s.TEXTURE0+x)}function ee(T,x){const k=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&k.__version!==T.version){B(k,T,x);return}else T.isExternalTexture&&(k.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,k.__webglTexture,s.TEXTURE0+x)}function J(T,x){const k=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&k.__version!==T.version){B(k,T,x);return}t.bindTexture(s.TEXTURE_3D,k.__webglTexture,s.TEXTURE0+x)}function ne(T,x){const k=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&k.__version!==T.version){Ee(k,T,x);return}t.bindTexture(s.TEXTURE_CUBE_MAP,k.__webglTexture,s.TEXTURE0+x)}const ae={[Wa]:s.REPEAT,[An]:s.CLAMP_TO_EDGE,[Dh]:s.MIRRORED_REPEAT},Ve={[Tt]:s.NEAREST,[e2]:s.NEAREST_MIPMAP_NEAREST,[uo]:s.NEAREST_MIPMAP_LINEAR,[dt]:s.LINEAR,[rl]:s.LINEAR_MIPMAP_NEAREST,[Bs]:s.LINEAR_MIPMAP_LINEAR},je={[s2]:s.NEVER,[l2]:s.ALWAYS,[r2]:s.LESS,[Qu]:s.LEQUAL,[a2]:s.EQUAL,[ed]:s.GEQUAL,[o2]:s.GREATER,[c2]:s.NOTEQUAL};function Be(T,x){if(x.type===Tn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===dt||x.magFilter===rl||x.magFilter===uo||x.magFilter===Bs||x.minFilter===dt||x.minFilter===rl||x.minFilter===uo||x.minFilter===Bs)&&we("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(T,s.TEXTURE_WRAP_S,ae[x.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,ae[x.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,ae[x.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Ve[x.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Ve[x.minFilter]),x.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,je[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Tt||x.minFilter!==uo&&x.minFilter!==Bs||x.type===Tn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const k=e.get("EXT_texture_filter_anisotropic");s.texParameterf(T,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function K(T,x){let k=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",R));const X=x.source;let $=f.get(X);$===void 0&&($={},f.set(X,$));const se=z(x);if(se!==T.__cacheKey){$[se]===void 0&&($[se]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,k=!0),$[se].usedTimes++;const le=$[T.__cacheKey];le!==void 0&&($[T.__cacheKey].usedTimes--,le.usedTimes===0&&I(x)),T.__cacheKey=se,T.__webglTexture=$[se].texture}return k}function re(T,x,k){return Math.floor(Math.floor(T/k)/x)}function ie(T,x,k,X){const se=T.updateRanges;if(se.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,x.width,x.height,k,X,x.data);else{se.sort((De,fe)=>De.start-fe.start);let le=0;for(let De=1;De<se.length;De++){const fe=se[le],ue=se[De],Le=fe.start+fe.count,Fe=re(ue.start,x.width,4),Xe=re(fe.start,x.width,4);ue.start<=Le+1&&Fe===Xe&&re(ue.start+ue.count-1,x.width,4)===Fe?fe.count=Math.max(fe.count,ue.start+ue.count-fe.start):(++le,se[le]=ue)}se.length=le+1;const Z=t.getParameter(s.UNPACK_ROW_LENGTH),Q=t.getParameter(s.UNPACK_SKIP_PIXELS),he=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,x.width);for(let De=0,fe=se.length;De<fe;De++){const ue=se[De],Le=Math.floor(ue.start/4),Fe=Math.ceil(ue.count/4),Xe=Le%x.width,L=Math.floor(Le/x.width),ce=Fe,j=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(s.UNPACK_SKIP_ROWS,L),t.texSubImage2D(s.TEXTURE_2D,0,Xe,L,ce,j,k,X,x.data)}T.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,Z),t.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(s.UNPACK_SKIP_ROWS,he)}}function B(T,x,k){let X=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(X=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(X=s.TEXTURE_3D);const $=K(T,x),se=x.source;t.bindTexture(X,T.__webglTexture,s.TEXTURE0+k);const le=n.get(se);if(se.version!==le.__version||$===!0){if(t.activeTexture(s.TEXTURE0+k),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){const j=et.getPrimaries(et.workingColorSpace),de=x.colorSpace===vs?null:et.getPrimaries(x.colorSpace),ve=x.colorSpace===vs||j===de?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment);let Q=m(x.image,!1,i.maxTextureSize);Q=Rn(x,Q);const he=r.convert(x.format,x.colorSpace),De=r.convert(x.type);let fe=_(x.internalFormat,he,De,x.normalized,x.colorSpace,x.isVideoTexture);Be(X,x);let ue;const Le=x.mipmaps,Fe=x.isVideoTexture!==!0,Xe=le.__version===void 0||$===!0,L=se.dataReady,ce=w(x,Q);if(x.isDepthTexture)fe=E(x.format===Hs,x.type),Xe&&(Fe?t.texStorage2D(s.TEXTURE_2D,1,fe,Q.width,Q.height):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,null));else if(x.isDataTexture)if(Le.length>0){Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data);x.generateMipmaps=!1}else Fe?(Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Q.width,Q.height),L&&ie(x,Q,he,De)):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Fe&&Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Le[0].width,Le[0].height,Q.depth);for(let j=0,de=Le.length;j<de;j++)if(ue=Le[j],x.format!==_n)if(he!==null)if(Fe){if(L)if(x.layerUpdates.size>0){const ve=tf(ue.width,ue.height,x.format,x.type);for(const te of x.layerUpdates){const Te=ue.data.subarray(te*ve/ue.data.BYTES_PER_ELEMENT,(te+1)*ve/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,te,ue.width,ue.height,1,he,Te)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,ue.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,ue.data,0,0);else we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?L&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,De,ue.data):t.texImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,he,De,ue.data)}else{Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],x.format!==_n?he!==null?Fe?L&&t.compressedTexSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,ue.data):t.compressedTexImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,ue.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data)}else if(x.isDataArrayTexture)if(Fe){if(Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Q.width,Q.height,Q.depth),L)if(x.layerUpdates.size>0){const j=tf(Q.width,Q.height,x.format,x.type);for(const de of x.layerUpdates){const ve=Q.data.subarray(de*j/Q.data.BYTES_PER_ELEMENT,(de+1)*j/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,he,De,ve)}x.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(x.isData3DTexture)Fe?(Xe&&t.texStorage3D(s.TEXTURE_3D,ce,fe,Q.width,Q.height,Q.depth),L&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)):t.texImage3D(s.TEXTURE_3D,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(x.isFramebufferTexture){if(Xe)if(Fe)t.texStorage2D(s.TEXTURE_2D,ce,fe,Q.width,Q.height);else{let j=Q.width,de=Q.height;for(let ve=0;ve<ce;ve++)t.texImage2D(s.TEXTURE_2D,ve,fe,j,de,0,he,De,null),j>>=1,de>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in s){const j=s.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(x),j.onpaint=de=>{const ve=de.changedElements;for(const te of u)ve.includes(te.image)&&(te.needsUpdate=!0)},j.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const ve=s.RGBA,te=s.RGBA,Te=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ve,te,Te,Q)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Fe&&Xe){const j=ct(Le[0]);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,he,De,ue):t.texImage2D(s.TEXTURE_2D,j,fe,he,De,ue);x.generateMipmaps=!1}else if(Fe){if(Xe){const j=ct(Q);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}L&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,he,De,Q)}else t.texImage2D(s.TEXTURE_2D,0,fe,he,De,Q);g(x)&&S(X),le.__version=se.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Ee(T,x,k){if(x.image.length!==6)return;const X=K(T,x),$=x.source;t.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+k);const se=n.get($);if($.version!==se.__version||X===!0){t.activeTexture(s.TEXTURE0+k);const le=et.getPrimaries(et.workingColorSpace),Z=x.colorSpace===vs?null:et.getPrimaries(x.colorSpace),Q=x.colorSpace===vs||le===Z?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const he=x.isCompressedTexture||x.image[0].isCompressedTexture,De=x.image[0]&&x.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!De?fe[te]=m(x.image[te],!0,i.maxCubemapSize):fe[te]=De?x.image[te].image:x.image[te],fe[te]=Rn(x,fe[te]);const ue=fe[0],Le=r.convert(x.format,x.colorSpace),Fe=r.convert(x.type),Xe=_(x.internalFormat,Le,Fe,x.normalized,x.colorSpace),L=x.isVideoTexture!==!0,ce=se.__version===void 0||X===!0,j=$.dataReady;let de=w(x,ue);Be(s.TEXTURE_CUBE_MAP,x);let ve;if(he){L&&ce&&t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,ue.width,ue.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];x.format!==_n?Le!==null?L?j&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,ye.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,ye.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,Fe,ye.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,Le,Fe,ye.data)}}}else{if(ve=x.mipmaps,L&&ce){ve.length>0&&de++;const te=ct(fe[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,te.width,te.height)}for(let te=0;te<6;te++)if(De){L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Le,Fe,fe[te].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,fe[te].width,fe[te].height,0,Le,Fe,fe[te].data);for(let Te=0;Te<ve.length;Te++){const Ot=ve[Te].image[te].image;L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Ot.width,Ot.height,Le,Fe,Ot.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Ot.width,Ot.height,0,Le,Fe,Ot.data)}}else{L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Le,Fe,fe[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,Le,Fe,fe[te]);for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Le,Fe,ye.image[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Le,Fe,ye.image[te])}}}g(x)&&S(s.TEXTURE_CUBE_MAP),se.__version=$.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Pe(T,x,k,X,$,se){const le=r.convert(k.format,k.colorSpace),Z=r.convert(k.type),Q=_(k.internalFormat,le,Z,k.normalized,k.colorSpace),he=n.get(x),De=n.get(k);if(De.__renderTarget=x,!he.__hasExternalTextures){const fe=Math.max(1,x.width>>se),ue=Math.max(1,x.height>>se);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?t.texImage3D($,se,Q,fe,ue,x.depth,0,le,Z,null):t.texImage2D($,se,Q,fe,ue,0,le,Z,null)}t.bindFramebuffer(s.FRAMEBUFFER,T),Wt(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,X,$,De.__webglTexture,0,Nt(x)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,X,$,De.__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Re(T,x,k){if(s.bindRenderbuffer(s.RENDERBUFFER,T),x.depthBuffer){const X=x.depthTexture,$=X&&X.isDepthTexture?X.type:null,se=E(x.stencilBuffer,$),le=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Wt(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Nt(x),se,x.width,x.height):k?s.renderbufferStorageMultisample(s.RENDERBUFFER,Nt(x),se,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,se,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,le,s.RENDERBUFFER,T)}else{const X=x.textures;for(let $=0;$<X.length;$++){const se=X[$],le=r.convert(se.format,se.colorSpace),Z=r.convert(se.type),Q=_(se.internalFormat,le,Z,se.normalized,se.colorSpace);Wt(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Nt(x),Q,x.width,x.height):k?s.renderbufferStorageMultisample(s.RENDERBUFFER,Nt(x),Q,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,Q,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function xe(T,x,k){const X=x.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=n.get(x.depthTexture);if($.__renderTarget=x,(!$.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),X){if($.__webglInit===void 0&&($.__webglInit=!0,x.depthTexture.addEventListener("dispose",R)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),Be(s.TEXTURE_CUBE_MAP,x.depthTexture);const he=r.convert(x.depthTexture.format),De=r.convert(x.depthTexture.type);let fe;x.depthTexture.format===Zi?fe=s.DEPTH_COMPONENT24:x.depthTexture.format===Hs&&(fe=s.DEPTH24_STENCIL8);for(let ue=0;ue<6;ue++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,fe,x.width,x.height,0,he,De,null)}}else Y(x.depthTexture,0);const se=$.__webglTexture,le=Nt(x),Z=X?s.TEXTURE_CUBE_MAP_POSITIVE_X+k:s.TEXTURE_2D,Q=x.depthTexture.format===Hs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(x.depthTexture.format===Zi)Wt(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else if(x.depthTexture.format===Hs)Wt(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(T){const x=n.get(T),k=T.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==T.depthTexture){const X=T.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),X){const $=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",$)};X.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=X}if(T.depthTexture&&!x.__autoAllocateDepthBuffer)if(k)for(let X=0;X<6;X++)xe(x.__webglFramebuffer[X],T,X);else{const X=T.texture.mipmaps;X&&X.length>0?xe(x.__webglFramebuffer[0],T,0):xe(x.__webglFramebuffer,T,0)}else if(k){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=s.createRenderbuffer(),Re(x.__webglDepthbuffer[X],T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=x.__webglDepthbuffer[X];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}else{const X=T.texture.mipmaps;if(X&&X.length>0?t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),Re(x.__webglDepthbuffer,T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Oe(T,x,k){const X=n.get(T);x!==void 0&&Pe(X.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),k!==void 0&&Ne(T)}function Ue(T){const x=T.texture,k=n.get(T),X=n.get(x);T.addEventListener("dispose",M);const $=T.textures,se=T.isWebGLCubeRenderTarget===!0,le=$.length>1;if(le||(X.__webglTexture===void 0&&(X.__webglTexture=s.createTexture()),X.__version=x.version,a.memory.textures++),se){k.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0){k.__webglFramebuffer[Z]=[];for(let Q=0;Q<x.mipmaps.length;Q++)k.__webglFramebuffer[Z][Q]=s.createFramebuffer()}else k.__webglFramebuffer[Z]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){k.__webglFramebuffer=[];for(let Z=0;Z<x.mipmaps.length;Z++)k.__webglFramebuffer[Z]=s.createFramebuffer()}else k.__webglFramebuffer=s.createFramebuffer();if(le)for(let Z=0,Q=$.length;Z<Q;Z++){const he=n.get($[Z]);he.__webglTexture===void 0&&(he.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Wt(T)===!1){k.__webglMultisampledFramebuffer=s.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];k.__webglColorRenderbuffer[Z]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,k.__webglColorRenderbuffer[Z]);const he=r.convert(Q.format,Q.colorSpace),De=r.convert(Q.type),fe=_(Q.internalFormat,he,De,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ue=Nt(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,ue,fe,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Z,s.RENDERBUFFER,k.__webglColorRenderbuffer[Z])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(k.__webglDepthRenderbuffer=s.createRenderbuffer(),Re(k.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture),Be(s.TEXTURE_CUBE_MAP,x);for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)Pe(k.__webglFramebuffer[Z][Q],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Pe(k.__webglFramebuffer[Z],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(x)&&S(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(le){for(let Z=0,Q=$.length;Z<Q;Z++){const he=$[Z],De=n.get(he);let fe=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(fe=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(fe,De.__webglTexture),Be(fe,he),Pe(k.__webglFramebuffer,T,he,s.COLOR_ATTACHMENT0+Z,fe,0),g(he)&&S(fe)}t.unbindTexture()}else{let Z=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Z=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(Z,X.__webglTexture),Be(Z,x),x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)Pe(k.__webglFramebuffer[Q],T,x,s.COLOR_ATTACHMENT0,Z,Q);else Pe(k.__webglFramebuffer,T,x,s.COLOR_ATTACHMENT0,Z,0);g(x)&&S(Z),t.unbindTexture()}T.depthBuffer&&Ne(T)}function at(T){const x=T.textures;for(let k=0,X=x.length;k<X;k++){const $=x[k];if(g($)){const se=b(T),le=n.get($).__webglTexture;t.bindTexture(se,le),S(se),t.unbindTexture()}}}const ot=[],Lt=[];function Et(T){if(T.samples>0){if(Wt(T)===!1){const x=T.textures,k=T.width,X=T.height;let $=s.COLOR_BUFFER_BIT;const se=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,le=n.get(T),Z=x.length>1;if(Z)for(let he=0;he<x.length;he++)t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,le.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer);for(let he=0;he<x.length;he++){if(T.resolveDepthBuffer&&(T.depthBuffer&&($|=s.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&($|=s.STENCIL_BUFFER_BIT)),Z){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=n.get(x[he]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,De,0)}s.blitFramebuffer(0,0,k,X,0,0,k,X,$,s.NEAREST),c===!0&&(ot.length=0,Lt.length=0,ot.push(s.COLOR_ATTACHMENT0+he),T.depthBuffer&&T.resolveDepthBuffer===!1&&(ot.push(se),Lt.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Lt)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ot))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Z)for(let he=0;he<x.length;he++){t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=n.get(x[he]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,De,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const x=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function Nt(T){return Math.min(i.maxSamples,T.samples)}function Wt(T){const x=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function N(T){const x=a.render.frame;h.get(T)!==x&&(h.set(T,x),T.update())}function Rn(T,x){const k=T.colorSpace,X=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||k!==bc&&k!==vs&&(et.getTransfer(k)===lt?(X!==_n||$!==Hn)&&we("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ke("WebGLTextures: Unsupported texture color space:",k)),x}function ct(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=F,this.getTextureUnits=H,this.setTextureUnits=O,this.setTexture2D=Y,this.setTexture2DArray=ee,this.setTexture3D=J,this.setTextureCube=ne,this.rebindTextures=Oe,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=at,this.updateMultisampleRenderTarget=Et,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Wt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ry(s,e){function t(n,i=vs){let r;const a=et.getTransfer(i);if(n===Hn)return s.UNSIGNED_BYTE;if(n===Ku)return s.UNSIGNED_SHORT_4_4_4_4;if(n===$u)return s.UNSIGNED_SHORT_5_5_5_1;if(n===lm)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===hm)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===om)return s.BYTE;if(n===cm)return s.SHORT;if(n===Xa)return s.UNSIGNED_SHORT;if(n===Yu)return s.INT;if(n===li)return s.UNSIGNED_INT;if(n===Tn)return s.FLOAT;if(n===cn)return s.HALF_FLOAT;if(n===um)return s.ALPHA;if(n===dm)return s.RGB;if(n===_n)return s.RGBA;if(n===Zi)return s.DEPTH_COMPONENT;if(n===Hs)return s.DEPTH_STENCIL;if(n===Vc)return s.RED;if(n===Zu)return s.RED_INTEGER;if(n===Ys)return s.RG;if(n===Ju)return s.RG_INTEGER;if(n===ju)return s.RGBA_INTEGER;if(n===cc||n===lc||n===hc||n===uc)if(a===lt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===cc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===lc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===hc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===uc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===cc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===lc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===hc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===uc)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ch||n===Ih||n===Ph||n===Lh)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ch)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ih)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ph)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Lh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Nh||n===Oh||n===Uh||n===Fh||n===kh||n===xc||n===zh)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Nh||n===Oh)return a===lt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Uh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Fh)return r.COMPRESSED_R11_EAC;if(n===kh)return r.COMPRESSED_SIGNED_R11_EAC;if(n===xc)return r.COMPRESSED_RG11_EAC;if(n===zh)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Bh||n===Hh||n===Gh||n===Vh||n===Wh||n===Xh||n===qh||n===Yh||n===Kh||n===$h||n===Zh||n===Jh||n===jh||n===Qh)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Bh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Hh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Gh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Vh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Wh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Xh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===qh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Yh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Kh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===$h)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Zh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Jh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===jh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Qh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===eu||n===tu||n===nu)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===eu)return a===lt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===tu)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===nu)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===iu||n===su||n===_c||n===ru)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===iu)return r.COMPRESSED_RED_RGTC1_EXT;if(n===su)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===_c)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ru)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===qa?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const Dy=`
4694
+ }`,by=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],Ey=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],wf=new Ye,ma=new C,Hl=new C;function wy(s,e,t){let n=new rd;const i=new Ae,r=new Ae,a=new nt,o=new dv,c=new fv,l={},h=t.maxTextureSize,u={[Ss]:Ct,[Ct]:Ss,[ai]:ai},d=new Rt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:yy,fragmentShader:Sy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new yt;p.setAttribute("position",new rt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new We(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ia;let g=this.type;this.render=function(w,R,M){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;this.type===P1&&(we("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Ia);const A=s.getRenderTarget(),I=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),P=s.state;P.setBlending(Ci),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const F=g!==this.type;F&&R.traverse(function(H){H.material&&(Array.isArray(H.material)?H.material.forEach(O=>O.needsUpdate=!0):H.material.needsUpdate=!0)});for(let H=0,O=w.length;H<O;H++){const V=w[H],z=V.shadow;if(z===void 0){we("WebGLShadowMap:",V,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;i.copy(z.mapSize);const Y=z.getFrameExtents();i.multiply(Y),r.copy(z.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Y.x),i.x=r.x*Y.x,z.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Y.y),i.y=r.y*Y.y,z.mapSize.y=r.y));const ee=s.state.buffers.depth.getReversed();if(z.camera._reversedDepth=ee,z.map===null||F===!0){if(z.map!==null&&(z.map.depthTexture!==null&&(z.map.depthTexture.dispose(),z.map.depthTexture=null),z.map.dispose()),this.type===ba){if(V.isPointLight){we("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new dn(i.x,i.y,{format:Ys,type:cn,minFilter:dt,magFilter:dt,generateMipmaps:!1}),z.map.texture.name=V.name+".shadowMap",z.map.depthTexture=new Ks(i.x,i.y,Tn),z.map.depthTexture.name=V.name+".shadowMapDepth",z.map.depthTexture.format=Zi,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Tt,z.map.depthTexture.magFilter=Tt}else V.isPointLight?(z.map=new Im(i.x),z.map.depthTexture=new av(i.x,li)):(z.map=new dn(i.x,i.y),z.map.depthTexture=new Ks(i.x,i.y,li)),z.map.depthTexture.name=V.name+".shadowMap",z.map.depthTexture.format=Zi,this.type===Ia?(z.map.depthTexture.compareFunction=ee?ed:Qu,z.map.depthTexture.minFilter=dt,z.map.depthTexture.magFilter=dt):(z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Tt,z.map.depthTexture.magFilter=Tt);z.camera.updateProjectionMatrix()}const J=z.map.isWebGLCubeRenderTarget?6:1;for(let ne=0;ne<J;ne++){if(z.map.isWebGLCubeRenderTarget)s.setRenderTarget(z.map,ne),s.clear();else{ne===0&&(s.setRenderTarget(z.map),s.clear());const ae=z.getViewport(ne);a.set(r.x*ae.x,r.y*ae.y,r.x*ae.z,r.y*ae.w),P.viewport(a)}if(V.isPointLight){const ae=z.camera,Ve=z.matrix,je=V.distance||ae.far;je!==ae.far&&(ae.far=je,ae.updateProjectionMatrix()),ma.setFromMatrixPosition(V.matrixWorld),ae.position.copy(ma),Hl.copy(ae.position),Hl.add(by[ne]),ae.up.copy(Ey[ne]),ae.lookAt(Hl),ae.updateMatrixWorld(),Ve.makeTranslation(-ma.x,-ma.y,-ma.z),wf.multiplyMatrices(ae.projectionMatrix,ae.matrixWorldInverse),z._frustum.setFromProjectionMatrix(wf,ae.coordinateSystem,ae.reversedDepth)}else z.updateMatrices(V);n=z.getFrustum(),_(R,M,z.camera,V,this.type)}z.isPointLightShadow!==!0&&this.type===ba&&S(z,M),z.needsUpdate=!1}g=this.type,m.needsUpdate=!1,s.setRenderTarget(A,I,D)};function S(w,R){const M=e.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new dn(i.x,i.y,{format:Ys,type:cn})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(R,null,M,d,v,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(R,null,M,f,v,null)}function b(w,R,M,A){let I=null;const D=M.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(D!==void 0)I=D;else if(I=M.isPointLight===!0?c:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const P=I.uuid,F=R.uuid;let H=l[P];H===void 0&&(H={},l[P]=H);let O=H[F];O===void 0&&(O=I.clone(),H[F]=O,R.addEventListener("dispose",E)),I=O}if(I.visible=R.visible,I.wireframe=R.wireframe,A===ba?I.side=R.shadowSide!==null?R.shadowSide:R.side:I.side=R.shadowSide!==null?R.shadowSide:u[R.side],I.alphaMap=R.alphaMap,I.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,I.map=R.map,I.clipShadows=R.clipShadows,I.clippingPlanes=R.clippingPlanes,I.clipIntersection=R.clipIntersection,I.displacementMap=R.displacementMap,I.displacementScale=R.displacementScale,I.displacementBias=R.displacementBias,I.wireframeLinewidth=R.wireframeLinewidth,I.linewidth=R.linewidth,M.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const P=s.properties.get(I);P.light=M}return I}function _(w,R,M,A,I){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&I===ba)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);const F=e.update(w),H=w.material;if(Array.isArray(H)){const O=F.groups;for(let V=0,z=O.length;V<z;V++){const Y=O[V],ee=H[Y.materialIndex];if(ee&&ee.visible){const J=b(w,ee,A,I);w.onBeforeShadow(s,w,R,M,F,J,Y),s.renderBufferDirect(M,null,F,J,w,Y),w.onAfterShadow(s,w,R,M,F,J,Y)}}}else if(H.visible){const O=b(w,H,A,I);w.onBeforeShadow(s,w,R,M,F,O,null),s.renderBufferDirect(M,null,F,O,w,null),w.onAfterShadow(s,w,R,M,F,O,null)}}const P=w.children;for(let F=0,H=P.length;F<H;F++)_(P[F],R,M,A,I)}function E(w){w.target.removeEventListener("dispose",E);for(const M in l){const A=l[M],I=w.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function Ay(s,e){function t(){let L=!1;const ce=new nt;let j=null;const de=new nt(0,0,0,0);return{setMask:function(ve){j!==ve&&!L&&(s.colorMask(ve,ve,ve,ve),j=ve)},setLocked:function(ve){L=ve},setClear:function(ve,te,Te,ye,Ot){Ot===!0&&(ve*=ye,te*=ye,Te*=ye),ce.set(ve,te,Te,ye),de.equals(ce)===!1&&(s.clearColor(ve,te,Te,ye),de.copy(ce))},reset:function(){L=!1,j=null,de.set(-1,0,0,0)}}}function n(){let L=!1,ce=!1,j=null,de=null,ve=null;return{setReversed:function(te){if(ce!==te){const Te=e.get("EXT_clip_control");te?Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.ZERO_TO_ONE_EXT):Te.clipControlEXT(Te.LOWER_LEFT_EXT,Te.NEGATIVE_ONE_TO_ONE_EXT),ce=te;const ye=ve;ve=null,this.setClear(ye)}},getReversed:function(){return ce},setTest:function(te){te?ie(s.DEPTH_TEST):B(s.DEPTH_TEST)},setMask:function(te){j!==te&&!L&&(s.depthMask(te),j=te)},setFunc:function(te){if(ce&&(te=p2[te]),de!==te){switch(te){case Sh:s.depthFunc(s.NEVER);break;case bh:s.depthFunc(s.ALWAYS);break;case Eh:s.depthFunc(s.LESS);break;case Yr:s.depthFunc(s.LEQUAL);break;case wh:s.depthFunc(s.EQUAL);break;case Ah:s.depthFunc(s.GEQUAL);break;case Th:s.depthFunc(s.GREATER);break;case Rh:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}de=te}},setLocked:function(te){L=te},setClear:function(te){ve!==te&&(ve=te,ce&&(te=1-te),s.clearDepth(te))},reset:function(){L=!1,j=null,de=null,ve=null,ce=!1}}}function i(){let L=!1,ce=null,j=null,de=null,ve=null,te=null,Te=null,ye=null,Ot=null;return{setTest:function(vt){L||(vt?ie(s.STENCIL_TEST):B(s.STENCIL_TEST))},setMask:function(vt){ce!==vt&&!L&&(s.stencilMask(vt),ce=vt)},setFunc:function(vt,fi,pi){(j!==vt||de!==fi||ve!==pi)&&(s.stencilFunc(vt,fi,pi),j=vt,de=fi,ve=pi)},setOp:function(vt,fi,pi){(te!==vt||Te!==fi||ye!==pi)&&(s.stencilOp(vt,fi,pi),te=vt,Te=fi,ye=pi)},setLocked:function(vt){L=vt},setClear:function(vt){Ot!==vt&&(s.clearStencil(vt),Ot=vt)},reset:function(){L=!1,ce=null,j=null,de=null,ve=null,te=null,Te=null,ye=null,Ot=null}}}const r=new t,a=new n,o=new i,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,b=null,_=null,E=null,w=null,R=null,M=new oe(0,0,0),A=0,I=!1,D=null,P=null,F=null,H=null,O=null;const V=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let z=!1,Y=0;const ee=s.getParameter(s.VERSION);ee.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(ee)[1]),z=Y>=1):ee.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(ee)[1]),z=Y>=2);let J=null,ne={};const ae=s.getParameter(s.SCISSOR_BOX),Ve=s.getParameter(s.VIEWPORT),je=new nt().fromArray(ae),He=new nt().fromArray(Ve);function K(L,ce,j,de){const ve=new Uint8Array(4),te=s.createTexture();s.bindTexture(L,te),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Te=0;Te<j;Te++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(ce,0,s.RGBA,1,1,de,0,s.RGBA,s.UNSIGNED_BYTE,ve):s.texImage2D(ce+Te,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ve);return te}const re={};re[s.TEXTURE_2D]=K(s.TEXTURE_2D,s.TEXTURE_2D,1),re[s.TEXTURE_CUBE_MAP]=K(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[s.TEXTURE_2D_ARRAY]=K(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),re[s.TEXTURE_3D]=K(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ie(s.DEPTH_TEST),a.setFunc(Yr),at(!1),ot(s0),ie(s.CULL_FACE),Oe(Ci);function ie(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function B(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Ee(L,ce){return d[L]!==ce?(s.bindFramebuffer(L,ce),d[L]=ce,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=ce),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=ce),!0):!1}function Pe(L,ce){let j=p,de=!1;if(L){j=f.get(ce),j===void 0&&(j=[],f.set(ce,j));const ve=L.textures;if(j.length!==ve.length||j[0]!==s.COLOR_ATTACHMENT0){for(let te=0,Te=ve.length;te<Te;te++)j[te]=s.COLOR_ATTACHMENT0+te;j.length=ve.length,de=!0}}else j[0]!==s.BACK&&(j[0]=s.BACK,de=!0);de&&s.drawBuffers(j)}function Re(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const xe={[Os]:s.FUNC_ADD,[N1]:s.FUNC_SUBTRACT,[O1]:s.FUNC_REVERSE_SUBTRACT};xe[U1]=s.MIN,xe[F1]=s.MAX;const Ne={[k1]:s.ZERO,[z1]:s.ONE,[B1]:s.SRC_COLOR,[_h]:s.SRC_ALPHA,[q1]:s.SRC_ALPHA_SATURATE,[W1]:s.DST_COLOR,[G1]:s.DST_ALPHA,[H1]:s.ONE_MINUS_SRC_COLOR,[yh]:s.ONE_MINUS_SRC_ALPHA,[X1]:s.ONE_MINUS_DST_COLOR,[V1]:s.ONE_MINUS_DST_ALPHA,[Y1]:s.CONSTANT_COLOR,[K1]:s.ONE_MINUS_CONSTANT_COLOR,[$1]:s.CONSTANT_ALPHA,[Z1]:s.ONE_MINUS_CONSTANT_ALPHA};function Oe(L,ce,j,de,ve,te,Te,ye,Ot,vt){if(L===Ci){m===!0&&(B(s.BLEND),m=!1);return}if(m===!1&&(ie(s.BLEND),m=!0),L!==L1){if(L!==g||vt!==I){if((S!==Os||E!==Os)&&(s.blendEquation(s.FUNC_ADD),S=Os,E=Os),vt)switch(L){case zr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Gn:s.blendFunc(s.ONE,s.ONE);break;case r0:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case a0:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:ke("WebGLState: Invalid blending: ",L);break}else switch(L){case zr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Gn:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case r0:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case a0:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",L);break}b=null,_=null,w=null,R=null,M.set(0,0,0),A=0,g=L,I=vt}return}ve=ve||ce,te=te||j,Te=Te||de,(ce!==S||ve!==E)&&(s.blendEquationSeparate(xe[ce],xe[ve]),S=ce,E=ve),(j!==b||de!==_||te!==w||Te!==R)&&(s.blendFuncSeparate(Ne[j],Ne[de],Ne[te],Ne[Te]),b=j,_=de,w=te,R=Te),(ye.equals(M)===!1||Ot!==A)&&(s.blendColor(ye.r,ye.g,ye.b,Ot),M.copy(ye),A=Ot),g=L,I=!1}function Ue(L,ce){L.side===ai?B(s.CULL_FACE):ie(s.CULL_FACE);let j=L.side===Ct;ce&&(j=!j),at(j),L.blending===zr&&L.transparent===!1?Oe(Ci):Oe(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const de=L.stencilWrite;o.setTest(de),de&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Et(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?ie(s.SAMPLE_ALPHA_TO_COVERAGE):B(s.SAMPLE_ALPHA_TO_COVERAGE)}function at(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function ot(L){L!==C1?(ie(s.CULL_FACE),L!==P&&(L===s0?s.cullFace(s.BACK):L===I1?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):B(s.CULL_FACE),P=L}function Lt(L){L!==F&&(z&&s.lineWidth(L),F=L)}function Et(L,ce,j){L?(ie(s.POLYGON_OFFSET_FILL),(H!==ce||O!==j)&&(H=ce,O=j,a.getReversed()&&(ce=-ce),s.polygonOffset(ce,j))):B(s.POLYGON_OFFSET_FILL)}function Nt(L){L?ie(s.SCISSOR_TEST):B(s.SCISSOR_TEST)}function Wt(L){L===void 0&&(L=s.TEXTURE0+V-1),J!==L&&(s.activeTexture(L),J=L)}function N(L,ce,j){j===void 0&&(J===null?j=s.TEXTURE0+V-1:j=J);let de=ne[j];de===void 0&&(de={type:void 0,texture:void 0},ne[j]=de),(de.type!==L||de.texture!==ce)&&(J!==j&&(s.activeTexture(j),J=j),s.bindTexture(L,ce||re[L]),de.type=L,de.texture=ce)}function Rn(){const L=ne[J];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ct(){try{s.compressedTexImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function x(){try{s.texSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function k(){try{s.texSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function X(){try{s.compressedTexSubImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function $(){try{s.compressedTexSubImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function se(){try{s.texStorage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function le(){try{s.texStorage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function Z(){try{s.texImage2D(...arguments)}catch(L){ke("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){ke("WebGLState:",L)}}function he(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function De(L,ce){u[L]!==ce&&(s.pixelStorei(L,ce),u[L]=ce)}function fe(L){je.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),je.copy(L))}function ue(L){He.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),He.copy(L))}function Le(L,ce){let j=l.get(ce);j===void 0&&(j=new WeakMap,l.set(ce,j));let de=j.get(L);de===void 0&&(de=s.getUniformBlockIndex(ce,L.name),j.set(L,de))}function Fe(L,ce){const de=l.get(ce).get(L);c.get(ce)!==de&&(s.uniformBlockBinding(ce,de,L.__bindingPointIndex),c.set(ce,de))}function Xe(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,ne={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,S=null,b=null,_=null,E=null,w=null,R=null,M=new oe(0,0,0),A=0,I=!1,D=null,P=null,F=null,H=null,O=null,je.set(0,0,s.canvas.width,s.canvas.height),He.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ie,disable:B,bindFramebuffer:Ee,drawBuffers:Pe,useProgram:Re,setBlending:Oe,setMaterial:Ue,setFlipSided:at,setCullFace:ot,setLineWidth:Lt,setPolygonOffset:Et,setScissorTest:Nt,activeTexture:Wt,bindTexture:N,unbindTexture:Rn,compressedTexImage2D:ct,compressedTexImage3D:T,texImage2D:Z,texImage3D:Q,pixelStorei:De,getParameter:he,updateUBOMapping:Le,uniformBlockBinding:Fe,texStorage2D:se,texStorage3D:le,texSubImage2D:x,texSubImage3D:k,compressedTexSubImage2D:X,compressedTexSubImage3D:$,scissor:fe,viewport:ue,reset:Xe}}function Ty(s,e,t,n,i,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ae,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(T,x){return p?new OffscreenCanvas(T,x):Ka("canvas")}function m(T,x,k){let X=1;const $=ct(T);if(($.width>k||$.height>k)&&(X=k/Math.max($.width,$.height)),X<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const se=Math.floor(X*$.width),le=Math.floor(X*$.height);d===void 0&&(d=v(se,le));const Z=x?v(se,le):d;return Z.width=se,Z.height=le,Z.getContext("2d").drawImage(T,0,0,se,le),we("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+se+"x"+le+")."),Z}else return"data"in T&&we("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function g(T){return T.generateMipmaps}function S(T){s.generateMipmap(T)}function b(T){return T.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?s.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function _(T,x,k,X,$,se=!1){if(T!==null){if(s[T]!==void 0)return s[T];we("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let le;X&&(le=e.get("EXT_texture_norm16"),le||we("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=x;if(x===s.RED&&(k===s.FLOAT&&(Z=s.R32F),k===s.HALF_FLOAT&&(Z=s.R16F),k===s.UNSIGNED_BYTE&&(Z=s.R8),k===s.UNSIGNED_SHORT&&le&&(Z=le.R16_EXT),k===s.SHORT&&le&&(Z=le.R16_SNORM_EXT)),x===s.RED_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.R8UI),k===s.UNSIGNED_SHORT&&(Z=s.R16UI),k===s.UNSIGNED_INT&&(Z=s.R32UI),k===s.BYTE&&(Z=s.R8I),k===s.SHORT&&(Z=s.R16I),k===s.INT&&(Z=s.R32I)),x===s.RG&&(k===s.FLOAT&&(Z=s.RG32F),k===s.HALF_FLOAT&&(Z=s.RG16F),k===s.UNSIGNED_BYTE&&(Z=s.RG8),k===s.UNSIGNED_SHORT&&le&&(Z=le.RG16_EXT),k===s.SHORT&&le&&(Z=le.RG16_SNORM_EXT)),x===s.RG_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.RG8UI),k===s.UNSIGNED_SHORT&&(Z=s.RG16UI),k===s.UNSIGNED_INT&&(Z=s.RG32UI),k===s.BYTE&&(Z=s.RG8I),k===s.SHORT&&(Z=s.RG16I),k===s.INT&&(Z=s.RG32I)),x===s.RGB_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.RGB8UI),k===s.UNSIGNED_SHORT&&(Z=s.RGB16UI),k===s.UNSIGNED_INT&&(Z=s.RGB32UI),k===s.BYTE&&(Z=s.RGB8I),k===s.SHORT&&(Z=s.RGB16I),k===s.INT&&(Z=s.RGB32I)),x===s.RGBA_INTEGER&&(k===s.UNSIGNED_BYTE&&(Z=s.RGBA8UI),k===s.UNSIGNED_SHORT&&(Z=s.RGBA16UI),k===s.UNSIGNED_INT&&(Z=s.RGBA32UI),k===s.BYTE&&(Z=s.RGBA8I),k===s.SHORT&&(Z=s.RGBA16I),k===s.INT&&(Z=s.RGBA32I)),x===s.RGB&&(k===s.UNSIGNED_SHORT&&le&&(Z=le.RGB16_EXT),k===s.SHORT&&le&&(Z=le.RGB16_SNORM_EXT),k===s.UNSIGNED_INT_5_9_9_9_REV&&(Z=s.RGB9_E5),k===s.UNSIGNED_INT_10F_11F_11F_REV&&(Z=s.R11F_G11F_B10F)),x===s.RGBA){const Q=se?Ec:et.getTransfer($);k===s.FLOAT&&(Z=s.RGBA32F),k===s.HALF_FLOAT&&(Z=s.RGBA16F),k===s.UNSIGNED_BYTE&&(Z=Q===lt?s.SRGB8_ALPHA8:s.RGBA8),k===s.UNSIGNED_SHORT&&le&&(Z=le.RGBA16_EXT),k===s.SHORT&&le&&(Z=le.RGBA16_SNORM_EXT),k===s.UNSIGNED_SHORT_4_4_4_4&&(Z=s.RGBA4),k===s.UNSIGNED_SHORT_5_5_5_1&&(Z=s.RGB5_A1)}return(Z===s.R16F||Z===s.R32F||Z===s.RG16F||Z===s.RG32F||Z===s.RGBA16F||Z===s.RGBA32F)&&e.get("EXT_color_buffer_float"),Z}function E(T,x){let k;return T?x===null||x===li||x===qa?k=s.DEPTH24_STENCIL8:x===Tn?k=s.DEPTH32F_STENCIL8:x===Xa&&(k=s.DEPTH24_STENCIL8,we("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===li||x===qa?k=s.DEPTH_COMPONENT24:x===Tn?k=s.DEPTH_COMPONENT32F:x===Xa&&(k=s.DEPTH_COMPONENT16),k}function w(T,x){return g(T)===!0||T.isFramebufferTexture&&T.minFilter!==Tt&&T.minFilter!==dt?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function R(T){const x=T.target;x.removeEventListener("dispose",R),A(x),x.isVideoTexture&&h.delete(x),x.isHTMLTexture&&u.delete(x)}function M(T){const x=T.target;x.removeEventListener("dispose",M),D(x)}function A(T){const x=n.get(T);if(x.__webglInit===void 0)return;const k=T.source,X=f.get(k);if(X){const $=X[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(T),Object.keys(X).length===0&&f.delete(k)}n.remove(T)}function I(T){const x=n.get(T);s.deleteTexture(x.__webglTexture);const k=T.source,X=f.get(k);delete X[x.__cacheKey],a.memory.textures--}function D(T){const x=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let $=0;$<x.__webglFramebuffer[X].length;$++)s.deleteFramebuffer(x.__webglFramebuffer[X][$]);else s.deleteFramebuffer(x.__webglFramebuffer[X]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[X])}else{if(Array.isArray(x.__webglFramebuffer))for(let X=0;X<x.__webglFramebuffer.length;X++)s.deleteFramebuffer(x.__webglFramebuffer[X]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let X=0;X<x.__webglColorRenderbuffer.length;X++)x.__webglColorRenderbuffer[X]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[X]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const k=T.textures;for(let X=0,$=k.length;X<$;X++){const se=n.get(k[X]);se.__webglTexture&&(s.deleteTexture(se.__webglTexture),a.memory.textures--),n.remove(k[X])}n.remove(T)}let P=0;function F(){P=0}function H(){return P}function O(T){P=T}function V(){const T=P;return T>=i.maxTextures&&we("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),P+=1,T}function z(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function Y(T,x){const k=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&k.__version!==T.version){const X=T.image;if(X===null)we("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)we("WebGLRenderer: Texture marked for update but image is incomplete");else{B(k,T,x);return}}else T.isExternalTexture&&(k.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D,k.__webglTexture,s.TEXTURE0+x)}function ee(T,x){const k=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&k.__version!==T.version){B(k,T,x);return}else T.isExternalTexture&&(k.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(s.TEXTURE_2D_ARRAY,k.__webglTexture,s.TEXTURE0+x)}function J(T,x){const k=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&k.__version!==T.version){B(k,T,x);return}t.bindTexture(s.TEXTURE_3D,k.__webglTexture,s.TEXTURE0+x)}function ne(T,x){const k=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&k.__version!==T.version){Ee(k,T,x);return}t.bindTexture(s.TEXTURE_CUBE_MAP,k.__webglTexture,s.TEXTURE0+x)}const ae={[Wa]:s.REPEAT,[An]:s.CLAMP_TO_EDGE,[Dh]:s.MIRRORED_REPEAT},Ve={[Tt]:s.NEAREST,[e2]:s.NEAREST_MIPMAP_NEAREST,[uo]:s.NEAREST_MIPMAP_LINEAR,[dt]:s.LINEAR,[rl]:s.LINEAR_MIPMAP_NEAREST,[Bs]:s.LINEAR_MIPMAP_LINEAR},je={[s2]:s.NEVER,[l2]:s.ALWAYS,[r2]:s.LESS,[Qu]:s.LEQUAL,[a2]:s.EQUAL,[ed]:s.GEQUAL,[o2]:s.GREATER,[c2]:s.NOTEQUAL};function He(T,x){if(x.type===Tn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===dt||x.magFilter===rl||x.magFilter===uo||x.magFilter===Bs||x.minFilter===dt||x.minFilter===rl||x.minFilter===uo||x.minFilter===Bs)&&we("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(T,s.TEXTURE_WRAP_S,ae[x.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,ae[x.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,ae[x.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Ve[x.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Ve[x.minFilter]),x.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,je[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Tt||x.minFilter!==uo&&x.minFilter!==Bs||x.type===Tn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const k=e.get("EXT_texture_filter_anisotropic");s.texParameterf(T,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function K(T,x){let k=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",R));const X=x.source;let $=f.get(X);$===void 0&&($={},f.set(X,$));const se=z(x);if(se!==T.__cacheKey){$[se]===void 0&&($[se]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,k=!0),$[se].usedTimes++;const le=$[T.__cacheKey];le!==void 0&&($[T.__cacheKey].usedTimes--,le.usedTimes===0&&I(x)),T.__cacheKey=se,T.__webglTexture=$[se].texture}return k}function re(T,x,k){return Math.floor(Math.floor(T/k)/x)}function ie(T,x,k,X){const se=T.updateRanges;if(se.length===0)t.texSubImage2D(s.TEXTURE_2D,0,0,0,x.width,x.height,k,X,x.data);else{se.sort((De,fe)=>De.start-fe.start);let le=0;for(let De=1;De<se.length;De++){const fe=se[le],ue=se[De],Le=fe.start+fe.count,Fe=re(ue.start,x.width,4),Xe=re(fe.start,x.width,4);ue.start<=Le+1&&Fe===Xe&&re(ue.start+ue.count-1,x.width,4)===Fe?fe.count=Math.max(fe.count,ue.start+ue.count-fe.start):(++le,se[le]=ue)}se.length=le+1;const Z=t.getParameter(s.UNPACK_ROW_LENGTH),Q=t.getParameter(s.UNPACK_SKIP_PIXELS),he=t.getParameter(s.UNPACK_SKIP_ROWS);t.pixelStorei(s.UNPACK_ROW_LENGTH,x.width);for(let De=0,fe=se.length;De<fe;De++){const ue=se[De],Le=Math.floor(ue.start/4),Fe=Math.ceil(ue.count/4),Xe=Le%x.width,L=Math.floor(Le/x.width),ce=Fe,j=1;t.pixelStorei(s.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(s.UNPACK_SKIP_ROWS,L),t.texSubImage2D(s.TEXTURE_2D,0,Xe,L,ce,j,k,X,x.data)}T.clearUpdateRanges(),t.pixelStorei(s.UNPACK_ROW_LENGTH,Z),t.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(s.UNPACK_SKIP_ROWS,he)}}function B(T,x,k){let X=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(X=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(X=s.TEXTURE_3D);const $=K(T,x),se=x.source;t.bindTexture(X,T.__webglTexture,s.TEXTURE0+k);const le=n.get(se);if(se.version!==le.__version||$===!0){if(t.activeTexture(s.TEXTURE0+k),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){const j=et.getPrimaries(et.workingColorSpace),de=x.colorSpace===vs?null:et.getPrimaries(x.colorSpace),ve=x.colorSpace===vs||j===de?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,ve)}t.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment);let Q=m(x.image,!1,i.maxTextureSize);Q=Rn(x,Q);const he=r.convert(x.format,x.colorSpace),De=r.convert(x.type);let fe=_(x.internalFormat,he,De,x.normalized,x.colorSpace,x.isVideoTexture);He(X,x);let ue;const Le=x.mipmaps,Fe=x.isVideoTexture!==!0,Xe=le.__version===void 0||$===!0,L=se.dataReady,ce=w(x,Q);if(x.isDepthTexture)fe=E(x.format===Hs,x.type),Xe&&(Fe?t.texStorage2D(s.TEXTURE_2D,1,fe,Q.width,Q.height):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,null));else if(x.isDataTexture)if(Le.length>0){Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data);x.generateMipmaps=!1}else Fe?(Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Q.width,Q.height),L&&ie(x,Q,he,De)):t.texImage2D(s.TEXTURE_2D,0,fe,Q.width,Q.height,0,he,De,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Fe&&Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Le[0].width,Le[0].height,Q.depth);for(let j=0,de=Le.length;j<de;j++)if(ue=Le[j],x.format!==_n)if(he!==null)if(Fe){if(L)if(x.layerUpdates.size>0){const ve=tf(ue.width,ue.height,x.format,x.type);for(const te of x.layerUpdates){const Te=ue.data.subarray(te*ve/ue.data.BYTES_PER_ELEMENT,(te+1)*ve/ue.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,te,ue.width,ue.height,1,he,Te)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,ue.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,ue.data,0,0);else we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?L&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ue.width,ue.height,Q.depth,he,De,ue.data):t.texImage3D(s.TEXTURE_2D_ARRAY,j,fe,ue.width,ue.height,Q.depth,0,he,De,ue.data)}else{Fe&&Xe&&t.texStorage2D(s.TEXTURE_2D,ce,fe,Le[0].width,Le[0].height);for(let j=0,de=Le.length;j<de;j++)ue=Le[j],x.format!==_n?he!==null?Fe?L&&t.compressedTexSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,ue.data):t.compressedTexImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,ue.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,ue.width,ue.height,he,De,ue.data):t.texImage2D(s.TEXTURE_2D,j,fe,ue.width,ue.height,0,he,De,ue.data)}else if(x.isDataArrayTexture)if(Fe){if(Xe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ce,fe,Q.width,Q.height,Q.depth),L)if(x.layerUpdates.size>0){const j=tf(Q.width,Q.height,x.format,x.type);for(const de of x.layerUpdates){const ve=Q.data.subarray(de*j/Q.data.BYTES_PER_ELEMENT,(de+1)*j/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,he,De,ve)}x.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(x.isData3DTexture)Fe?(Xe&&t.texStorage3D(s.TEXTURE_3D,ce,fe,Q.width,Q.height,Q.depth),L&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,he,De,Q.data)):t.texImage3D(s.TEXTURE_3D,0,fe,Q.width,Q.height,Q.depth,0,he,De,Q.data);else if(x.isFramebufferTexture){if(Xe)if(Fe)t.texStorage2D(s.TEXTURE_2D,ce,fe,Q.width,Q.height);else{let j=Q.width,de=Q.height;for(let ve=0;ve<ce;ve++)t.texImage2D(s.TEXTURE_2D,ve,fe,j,de,0,he,De,null),j>>=1,de>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in s){const j=s.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(x),j.onpaint=de=>{const ve=de.changedElements;for(const te of u)ve.includes(te.image)&&(te.needsUpdate=!0)},j.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const ve=s.RGBA,te=s.RGBA,Te=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,ve,te,Te,Q)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Le.length>0){if(Fe&&Xe){const j=ct(Le[0]);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}for(let j=0,de=Le.length;j<de;j++)ue=Le[j],Fe?L&&t.texSubImage2D(s.TEXTURE_2D,j,0,0,he,De,ue):t.texImage2D(s.TEXTURE_2D,j,fe,he,De,ue);x.generateMipmaps=!1}else if(Fe){if(Xe){const j=ct(Q);t.texStorage2D(s.TEXTURE_2D,ce,fe,j.width,j.height)}L&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,he,De,Q)}else t.texImage2D(s.TEXTURE_2D,0,fe,he,De,Q);g(x)&&S(X),le.__version=se.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Ee(T,x,k){if(x.image.length!==6)return;const X=K(T,x),$=x.source;t.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+k);const se=n.get($);if($.version!==se.__version||X===!0){t.activeTexture(s.TEXTURE0+k);const le=et.getPrimaries(et.workingColorSpace),Z=x.colorSpace===vs?null:et.getPrimaries(x.colorSpace),Q=x.colorSpace===vs||le===Z?s.NONE:s.BROWSER_DEFAULT_WEBGL;t.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),t.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const he=x.isCompressedTexture||x.image[0].isCompressedTexture,De=x.image[0]&&x.image[0].isDataTexture,fe=[];for(let te=0;te<6;te++)!he&&!De?fe[te]=m(x.image[te],!0,i.maxCubemapSize):fe[te]=De?x.image[te].image:x.image[te],fe[te]=Rn(x,fe[te]);const ue=fe[0],Le=r.convert(x.format,x.colorSpace),Fe=r.convert(x.type),Xe=_(x.internalFormat,Le,Fe,x.normalized,x.colorSpace),L=x.isVideoTexture!==!0,ce=se.__version===void 0||X===!0,j=$.dataReady;let de=w(x,ue);He(s.TEXTURE_CUBE_MAP,x);let ve;if(he){L&&ce&&t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,ue.width,ue.height);for(let te=0;te<6;te++){ve=fe[te].mipmaps;for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];x.format!==_n?Le!==null?L?j&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,ye.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,ye.data):we("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,0,0,ye.width,ye.height,Le,Fe,ye.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te,Xe,ye.width,ye.height,0,Le,Fe,ye.data)}}}else{if(ve=x.mipmaps,L&&ce){ve.length>0&&de++;const te=ct(fe[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,de,Xe,te.width,te.height)}for(let te=0;te<6;te++)if(De){L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,fe[te].width,fe[te].height,Le,Fe,fe[te].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,fe[te].width,fe[te].height,0,Le,Fe,fe[te].data);for(let Te=0;Te<ve.length;Te++){const Ot=ve[Te].image[te].image;L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Ot.width,Ot.height,Le,Fe,Ot.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Ot.width,Ot.height,0,Le,Fe,Ot.data)}}else{L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,0,0,Le,Fe,fe[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,0,Xe,Le,Fe,fe[te]);for(let Te=0;Te<ve.length;Te++){const ye=ve[Te];L?j&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,0,0,Le,Fe,ye.image[te]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+te,Te+1,Xe,Le,Fe,ye.image[te])}}}g(x)&&S(s.TEXTURE_CUBE_MAP),se.__version=$.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Pe(T,x,k,X,$,se){const le=r.convert(k.format,k.colorSpace),Z=r.convert(k.type),Q=_(k.internalFormat,le,Z,k.normalized,k.colorSpace),he=n.get(x),De=n.get(k);if(De.__renderTarget=x,!he.__hasExternalTextures){const fe=Math.max(1,x.width>>se),ue=Math.max(1,x.height>>se);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?t.texImage3D($,se,Q,fe,ue,x.depth,0,le,Z,null):t.texImage2D($,se,Q,fe,ue,0,le,Z,null)}t.bindFramebuffer(s.FRAMEBUFFER,T),Wt(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,X,$,De.__webglTexture,0,Nt(x)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,X,$,De.__webglTexture,se),t.bindFramebuffer(s.FRAMEBUFFER,null)}function Re(T,x,k){if(s.bindRenderbuffer(s.RENDERBUFFER,T),x.depthBuffer){const X=x.depthTexture,$=X&&X.isDepthTexture?X.type:null,se=E(x.stencilBuffer,$),le=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Wt(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Nt(x),se,x.width,x.height):k?s.renderbufferStorageMultisample(s.RENDERBUFFER,Nt(x),se,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,se,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,le,s.RENDERBUFFER,T)}else{const X=x.textures;for(let $=0;$<X.length;$++){const se=X[$],le=r.convert(se.format,se.colorSpace),Z=r.convert(se.type),Q=_(se.internalFormat,le,Z,se.normalized,se.colorSpace);Wt(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Nt(x),Q,x.width,x.height):k?s.renderbufferStorageMultisample(s.RENDERBUFFER,Nt(x),Q,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,Q,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function xe(T,x,k){const X=x.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(s.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=n.get(x.depthTexture);if($.__renderTarget=x,(!$.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),X){if($.__webglInit===void 0&&($.__webglInit=!0,x.depthTexture.addEventListener("dispose",R)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),t.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),He(s.TEXTURE_CUBE_MAP,x.depthTexture);const he=r.convert(x.depthTexture.format),De=r.convert(x.depthTexture.type);let fe;x.depthTexture.format===Zi?fe=s.DEPTH_COMPONENT24:x.depthTexture.format===Hs&&(fe=s.DEPTH24_STENCIL8);for(let ue=0;ue<6;ue++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ue,0,fe,x.width,x.height,0,he,De,null)}}else Y(x.depthTexture,0);const se=$.__webglTexture,le=Nt(x),Z=X?s.TEXTURE_CUBE_MAP_POSITIVE_X+k:s.TEXTURE_2D,Q=x.depthTexture.format===Hs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(x.depthTexture.format===Zi)Wt(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else if(x.depthTexture.format===Hs)Wt(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,se,0,le):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,se,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ne(T){const x=n.get(T),k=T.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==T.depthTexture){const X=T.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),X){const $=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",$)};X.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=X}if(T.depthTexture&&!x.__autoAllocateDepthBuffer)if(k)for(let X=0;X<6;X++)xe(x.__webglFramebuffer[X],T,X);else{const X=T.texture.mipmaps;X&&X.length>0?xe(x.__webglFramebuffer[0],T,0):xe(x.__webglFramebuffer,T,0)}else if(k){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=s.createRenderbuffer(),Re(x.__webglDepthbuffer[X],T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=x.__webglDepthbuffer[X];s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}else{const X=T.texture.mipmaps;if(X&&X.length>0?t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),Re(x.__webglDepthbuffer,T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,se=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,se),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,se)}}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Oe(T,x,k){const X=n.get(T);x!==void 0&&Pe(X.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),k!==void 0&&Ne(T)}function Ue(T){const x=T.texture,k=n.get(T),X=n.get(x);T.addEventListener("dispose",M);const $=T.textures,se=T.isWebGLCubeRenderTarget===!0,le=$.length>1;if(le||(X.__webglTexture===void 0&&(X.__webglTexture=s.createTexture()),X.__version=x.version,a.memory.textures++),se){k.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0){k.__webglFramebuffer[Z]=[];for(let Q=0;Q<x.mipmaps.length;Q++)k.__webglFramebuffer[Z][Q]=s.createFramebuffer()}else k.__webglFramebuffer[Z]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){k.__webglFramebuffer=[];for(let Z=0;Z<x.mipmaps.length;Z++)k.__webglFramebuffer[Z]=s.createFramebuffer()}else k.__webglFramebuffer=s.createFramebuffer();if(le)for(let Z=0,Q=$.length;Z<Q;Z++){const he=n.get($[Z]);he.__webglTexture===void 0&&(he.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Wt(T)===!1){k.__webglMultisampledFramebuffer=s.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];k.__webglColorRenderbuffer[Z]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,k.__webglColorRenderbuffer[Z]);const he=r.convert(Q.format,Q.colorSpace),De=r.convert(Q.type),fe=_(Q.internalFormat,he,De,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ue=Nt(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,ue,fe,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Z,s.RENDERBUFFER,k.__webglColorRenderbuffer[Z])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(k.__webglDepthRenderbuffer=s.createRenderbuffer(),Re(k.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(se){t.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture),He(s.TEXTURE_CUBE_MAP,x);for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)Pe(k.__webglFramebuffer[Z][Q],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Pe(k.__webglFramebuffer[Z],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(x)&&S(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(le){for(let Z=0,Q=$.length;Z<Q;Z++){const he=$[Z],De=n.get(he);let fe=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(fe=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(fe,De.__webglTexture),He(fe,he),Pe(k.__webglFramebuffer,T,he,s.COLOR_ATTACHMENT0+Z,fe,0),g(he)&&S(fe)}t.unbindTexture()}else{let Z=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Z=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(Z,X.__webglTexture),He(Z,x),x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)Pe(k.__webglFramebuffer[Q],T,x,s.COLOR_ATTACHMENT0,Z,Q);else Pe(k.__webglFramebuffer,T,x,s.COLOR_ATTACHMENT0,Z,0);g(x)&&S(Z),t.unbindTexture()}T.depthBuffer&&Ne(T)}function at(T){const x=T.textures;for(let k=0,X=x.length;k<X;k++){const $=x[k];if(g($)){const se=b(T),le=n.get($).__webglTexture;t.bindTexture(se,le),S(se),t.unbindTexture()}}}const ot=[],Lt=[];function Et(T){if(T.samples>0){if(Wt(T)===!1){const x=T.textures,k=T.width,X=T.height;let $=s.COLOR_BUFFER_BIT;const se=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,le=n.get(T),Z=x.length>1;if(Z)for(let he=0;he<x.length;he++)t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,le.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer[0]):t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglFramebuffer);for(let he=0;he<x.length;he++){if(T.resolveDepthBuffer&&(T.depthBuffer&&($|=s.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&($|=s.STENCIL_BUFFER_BIT)),Z){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=n.get(x[he]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,De,0)}s.blitFramebuffer(0,0,k,X,0,0,k,X,$,s.NEAREST),c===!0&&(ot.length=0,Lt.length=0,ot.push(s.COLOR_ATTACHMENT0+he),T.depthBuffer&&T.resolveDepthBuffer===!1&&(ot.push(se),Lt.push(se),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Lt)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ot))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Z)for(let he=0;he<x.length;he++){t.bindFramebuffer(s.FRAMEBUFFER,le.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,le.__webglColorRenderbuffer[he]);const De=n.get(x[he]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,le.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,De,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,le.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const x=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function Nt(T){return Math.min(i.maxSamples,T.samples)}function Wt(T){const x=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function N(T){const x=a.render.frame;h.get(T)!==x&&(h.set(T,x),T.update())}function Rn(T,x){const k=T.colorSpace,X=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||k!==bc&&k!==vs&&(et.getTransfer(k)===lt?(X!==_n||$!==Hn)&&we("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ke("WebGLTextures: Unsupported texture color space:",k)),x}function ct(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=F,this.getTextureUnits=H,this.setTextureUnits=O,this.setTexture2D=Y,this.setTexture2DArray=ee,this.setTexture3D=J,this.setTextureCube=ne,this.rebindTextures=Oe,this.setupRenderTarget=Ue,this.updateRenderTargetMipmap=at,this.updateMultisampleRenderTarget=Et,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=Wt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ry(s,e){function t(n,i=vs){let r;const a=et.getTransfer(i);if(n===Hn)return s.UNSIGNED_BYTE;if(n===Ku)return s.UNSIGNED_SHORT_4_4_4_4;if(n===$u)return s.UNSIGNED_SHORT_5_5_5_1;if(n===lm)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===hm)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===om)return s.BYTE;if(n===cm)return s.SHORT;if(n===Xa)return s.UNSIGNED_SHORT;if(n===Yu)return s.INT;if(n===li)return s.UNSIGNED_INT;if(n===Tn)return s.FLOAT;if(n===cn)return s.HALF_FLOAT;if(n===um)return s.ALPHA;if(n===dm)return s.RGB;if(n===_n)return s.RGBA;if(n===Zi)return s.DEPTH_COMPONENT;if(n===Hs)return s.DEPTH_STENCIL;if(n===Vc)return s.RED;if(n===Zu)return s.RED_INTEGER;if(n===Ys)return s.RG;if(n===Ju)return s.RG_INTEGER;if(n===ju)return s.RGBA_INTEGER;if(n===cc||n===lc||n===hc||n===uc)if(a===lt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===cc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===lc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===hc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===uc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===cc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===lc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===hc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===uc)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ch||n===Ih||n===Ph||n===Lh)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ch)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ih)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ph)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Lh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Nh||n===Oh||n===Uh||n===Fh||n===kh||n===xc||n===zh)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Nh||n===Oh)return a===lt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Uh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Fh)return r.COMPRESSED_R11_EAC;if(n===kh)return r.COMPRESSED_SIGNED_R11_EAC;if(n===xc)return r.COMPRESSED_RG11_EAC;if(n===zh)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Bh||n===Hh||n===Gh||n===Vh||n===Wh||n===Xh||n===qh||n===Yh||n===Kh||n===$h||n===Zh||n===Jh||n===jh||n===Qh)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Bh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Hh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Gh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Vh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Wh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Xh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===qh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Yh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Kh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===$h)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Zh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Jh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===jh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Qh)return a===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===eu||n===tu||n===nu)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===eu)return a===lt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===tu)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===nu)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===iu||n===su||n===_c||n===ru)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===iu)return r.COMPRESSED_RED_RGTC1_EXT;if(n===su)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===_c)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ru)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===qa?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const Dy=`
4695
4695
  void main() {
4696
4696
 
4697
4697
  gl_Position = vec4( position, 1.0 );
@@ -4715,7 +4715,7 @@ void main() {
4715
4715
 
4716
4716
  }
4717
4717
 
4718
- }`;class Iy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Sm(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Rt({vertexShader:Dy,fragmentShader:Cy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new We(new ui(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Py extends Js{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new Iy,g={},S=t.getContextAttributes();let b=null,_=null;const E=[],w=[],R=new Ae;let M=null;const A=new Nn;A.viewport=new nt;const I=new Nn;I.viewport=new nt;const D=[A,I],P=new Lv;let F=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let re=E[K];return re===void 0&&(re=new dl,E[K]=re),re.getTargetRaySpace()},this.getControllerGrip=function(K){let re=E[K];return re===void 0&&(re=new dl,E[K]=re),re.getGripSpace()},this.getHand=function(K){let re=E[K];return re===void 0&&(re=new dl,E[K]=re),re.getHandSpace()};function O(K){const re=w.indexOf(K.inputSource);if(re===-1)return;const ie=E[re];ie!==void 0&&(ie.update(K.inputSource,K.frame,l||a),ie.dispatchEvent({type:K.type,data:K.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",z);for(let K=0;K<E.length;K++){const re=w[K];re!==null&&(w[K]=null,E[K].disconnect(re))}F=null,H=null,m.reset();for(const K in g)delete g[K];e.setRenderTarget(b),f=null,d=null,u=null,i=null,_=null,Be.stop(),n.isPresenting=!1,e.setPixelRatio(M),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&we("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,n.isPresenting===!0&&we("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(i,t)),u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(K){if(i=K,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",V),i.addEventListener("inputsourceschange",z),S.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ie=null,B=null,Ee=null;S.depth&&(Ee=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ie=S.stencil?Hs:Zi,B=S.stencil?qa:li);const Pe={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Pe),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new dn(d.textureWidth,d.textureHeight,{format:_n,type:Hn,depthTexture:new Ks(d.textureWidth,d.textureHeight,B,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ie={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,ie),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new dn(f.framebufferWidth,f.framebufferHeight,{format:_n,type:Hn,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),Be.setContext(i),Be.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function z(K){for(let re=0;re<K.removed.length;re++){const ie=K.removed[re],B=w.indexOf(ie);B>=0&&(w[B]=null,E[B].disconnect(ie))}for(let re=0;re<K.added.length;re++){const ie=K.added[re];let B=w.indexOf(ie);if(B===-1){for(let Pe=0;Pe<E.length;Pe++)if(Pe>=w.length){w.push(ie),B=Pe;break}else if(w[Pe]===null){w[Pe]=ie,B=Pe;break}if(B===-1)break}const Ee=E[B];Ee&&Ee.connect(ie)}}const Y=new C,ee=new C;function J(K,re,ie){Y.setFromMatrixPosition(re.matrixWorld),ee.setFromMatrixPosition(ie.matrixWorld);const B=Y.distanceTo(ee),Ee=re.projectionMatrix.elements,Pe=ie.projectionMatrix.elements,Re=Ee[14]/(Ee[10]-1),xe=Ee[14]/(Ee[10]+1),Ne=(Ee[9]+1)/Ee[5],Oe=(Ee[9]-1)/Ee[5],Ue=(Ee[8]-1)/Ee[0],at=(Pe[8]+1)/Pe[0],ot=Re*Ue,Lt=Re*at,Et=B/(-Ue+at),Nt=Et*-Ue;if(re.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Nt),K.translateZ(Et),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Ee[10]===-1)K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Wt=Re+Et,N=xe+Et,Rn=ot-Nt,ct=Lt+(B-Nt),T=Ne*xe/N*Wt,x=Oe*xe/N*Wt;K.projectionMatrix.makePerspective(Rn,ct,T,x,Wt,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function ne(K,re){re===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(re.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(i===null)return;let re=K.near,ie=K.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ie=m.depthFar)),P.near=I.near=A.near=re,P.far=I.far=A.far=ie,(F!==P.near||H!==P.far)&&(i.updateRenderState({depthNear:P.near,depthFar:P.far}),F=P.near,H=P.far),P.layers.mask=K.layers.mask|6,A.layers.mask=P.layers.mask&-5,I.layers.mask=P.layers.mask&-3;const B=K.parent,Ee=P.cameras;ne(P,B);for(let Pe=0;Pe<Ee.length;Pe++)ne(Ee[Pe],B);Ee.length===2?J(P,A,I):P.projectionMatrix.copy(A.projectionMatrix),ae(K,P,B)};function ae(K,re,ie){ie===null?K.matrix.copy(re.matrixWorld):(K.matrix.copy(ie.matrixWorld),K.matrix.invert(),K.matrix.multiply(re.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=$r*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(K){c=K,d!==null&&(d.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(P)},this.getCameraTexture=function(K){return g[K]};let Ve=null;function je(K,re){if(h=re.getViewerPose(l||a),p=re,h!==null){const ie=h.views;f!==null&&(e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_));let B=!1;ie.length!==P.cameras.length&&(P.cameras.length=0,B=!0);for(let xe=0;xe<ie.length;xe++){const Ne=ie[xe];let Oe=null;if(f!==null)Oe=f.getViewport(Ne);else{const at=u.getViewSubImage(d,Ne);Oe=at.viewport,xe===0&&(e.setRenderTargetTextures(_,at.colorTexture,at.depthStencilTexture),e.setRenderTarget(_))}let Ue=D[xe];Ue===void 0&&(Ue=new Nn,Ue.layers.enable(xe),Ue.viewport=new nt,D[xe]=Ue),Ue.matrix.fromArray(Ne.transform.matrix),Ue.matrix.decompose(Ue.position,Ue.quaternion,Ue.scale),Ue.projectionMatrix.fromArray(Ne.projectionMatrix),Ue.projectionMatrixInverse.copy(Ue.projectionMatrix).invert(),Ue.viewport.set(Oe.x,Oe.y,Oe.width,Oe.height),xe===0&&(P.matrix.copy(Ue.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),B===!0&&P.cameras.push(Ue)}const Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();const xe=u.getDepthInformation(ie[0]);xe&&xe.isValid&&xe.texture&&m.init(xe,i.renderState)}if(Ee&&Ee.includes("camera-access")&&v){e.state.unbindTexture(),u=n.getBinding();for(let xe=0;xe<ie.length;xe++){const Ne=ie[xe].camera;if(Ne){let Oe=g[Ne];Oe||(Oe=new Sm,g[Ne]=Oe);const Ue=u.getCameraImage(Ne);Oe.sourceTexture=Ue}}}}for(let ie=0;ie<E.length;ie++){const B=w[ie],Ee=E[ie];B!==null&&Ee!==void 0&&Ee.update(B,re,l||a)}Ve&&Ve(K,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),p=null}const Be=new Dm;Be.setAnimationLoop(je),this.setAnimationLoop=function(K){Ve=K},this.dispose=function(){}}}const Ly=new Ye,Um=new ze;Um.set(-1,0,0,0,1,0,0,0,1);function Ny(s,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function n(m,g){g.color.getRGB(m.fogColor.value,bm(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function i(m,g,S,b,_){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?r(m,g):g.isMeshLambertMaterial?(r(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(r(m,g),u(m,g)):g.isMeshPhongMaterial?(r(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,_)):g.isMeshMatcapMaterial?(r(m,g),p(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),v(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,S,b):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ct&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ct&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const S=e.get(g),b=S.envMap,_=S.envMapRotation;b&&(m.envMap.value=b,m.envMapRotation.value.setFromMatrix4(Ly.makeRotationFromEuler(_)).transpose(),b.isCubeTexture&&b.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Um),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,S,b){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*S,m.scale.value=b*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,S){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ct&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const S=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Oy(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,E){const w=E.program;n.uniformBlockBinding(_,w)}function l(_,E){let w=i[_.id];w===void 0&&(m(_),w=h(_),i[_.id]=w,_.addEventListener("dispose",S));const R=E.program;n.updateUBOMapping(_,R);const M=e.render.frame;r[_.id]!==M&&(d(_),r[_.id]=M)}function h(_){const E=u();_.__bindingPointIndex=E;const w=s.createBuffer(),R=_.__size,M=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,w),s.bufferData(s.UNIFORM_BUFFER,R,M),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,E,w),w}function u(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(_){const E=i[_.id],w=_.uniforms,R=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,E);for(let M=0,A=w.length;M<A;M++){const I=w[M];if(Array.isArray(I))for(let D=0,P=I.length;D<P;D++)f(I[D],M,D,R);else f(I,M,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(_,E,w,R){if(v(_,E,w,R)===!0){const M=_.__offset,A=_.value;if(Array.isArray(A)){let I=0;for(let D=0;D<A.length;D++){const P=A[D],F=g(P);p(P,_.__data,I),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(I+=F.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,_.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,M,_.__data)}}function p(_,E,w){typeof _=="number"||typeof _=="boolean"?E[0]=_:_.isMatrix3?(E[0]=_.elements[0],E[1]=_.elements[1],E[2]=_.elements[2],E[3]=0,E[4]=_.elements[3],E[5]=_.elements[4],E[6]=_.elements[5],E[7]=0,E[8]=_.elements[6],E[9]=_.elements[7],E[10]=_.elements[8],E[11]=0):ArrayBuffer.isView(_)?E.set(new _.constructor(_.buffer,_.byteOffset,E.length)):_.toArray(E,w)}function v(_,E,w,R){const M=_.value,A=E+"_"+w;if(R[A]===void 0)return typeof M=="number"||typeof M=="boolean"?R[A]=M:ArrayBuffer.isView(M)?R[A]=M.slice():R[A]=M.clone(),!0;{const I=R[A];if(typeof M=="number"||typeof M=="boolean"){if(I!==M)return R[A]=M,!0}else{if(ArrayBuffer.isView(M))return!0;if(I.equals(M)===!1)return I.copy(M),!0}}return!1}function m(_){const E=_.uniforms;let w=0;const R=16;for(let A=0,I=E.length;A<I;A++){const D=Array.isArray(E[A])?E[A]:[E[A]];for(let P=0,F=D.length;P<F;P++){const H=D[P],O=Array.isArray(H.value)?H.value:[H.value];for(let V=0,z=O.length;V<z;V++){const Y=O[V],ee=g(Y),J=w%R,ne=J%ee.boundary,ae=J+ne;w+=ne,ae!==0&&R-ae<ee.storage&&(w+=R-ae),H.__data=new Float32Array(ee.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=w,w+=ee.storage}}}const M=w%R;return M>0&&(w+=R-M),_.__size=w,_.__cache={},this}function g(_){const E={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(E.boundary=4,E.storage=4):_.isVector2?(E.boundary=8,E.storage=8):_.isVector3||_.isColor?(E.boundary=16,E.storage=12):_.isVector4?(E.boundary=16,E.storage=16):_.isMatrix3?(E.boundary=48,E.storage=48):_.isMatrix4?(E.boundary=64,E.storage=64):_.isTexture?we("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(E.boundary=16,E.storage=_.byteLength):we("WebGLRenderer: Unsupported uniform value type.",_),E}function S(_){const E=_.target;E.removeEventListener("dispose",S);const w=a.indexOf(E.__bindingPointIndex);a.splice(w,1),s.deleteBuffer(i[E.id]),delete i[E.id],delete r[E.id]}function b(){for(const _ in i)s.deleteBuffer(i[_]);a=[],i={},r={}}return{bind:c,update:l,dispose:b}}const Uy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Mi=null;function Fy(){return Mi===null&&(Mi=new js(Uy,16,16,Ys,cn),Mi.name="DFG_LUT",Mi.minFilter=dt,Mi.magFilter=dt,Mi.wrapS=An,Mi.wrapT=An,Mi.generateMipmaps=!1,Mi.needsUpdate=!0),Mi}class ky{constructor(e={}){const{canvas:t=d2(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Hn}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const v=f,m=new Set([ju,Ju,Zu]),g=new Set([Hn,li,Xa,qa,Ku,$u]),S=new Uint32Array(4),b=new Int32Array(4),_=new C;let E=null,w=null;const R=[],M=[];let A=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ii,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let D=!1,P=null,F=null,H=null,O=null;this._outputColorSpace=Ln;let V=0,z=0,Y=null,ee=-1,J=null;const ne=new nt,ae=new nt;let Ve=null;const je=new oe(0);let Be=0,K=t.width,re=t.height,ie=1,B=null,Ee=null;const Pe=new nt(0,0,K,re),Re=new nt(0,0,K,re);let xe=!1;const Ne=new rd;let Oe=!1,Ue=!1;const at=new Ye,ot=new C,Lt=new nt,Et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Nt=!1;function Wt(){return Y===null?ie:1}let N=n;function Rn(y,U){return t.getContext(y,U)}try{const y={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Xu}`),t.addEventListener("webglcontextlost",Ot,!1),t.addEventListener("webglcontextrestored",vt,!1),t.addEventListener("webglcontextcreationerror",fi,!1),N===null){const U="webgl2";if(N=Rn(U,y),N===null)throw Rn(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw ke("WebGLRenderer: "+y.message),y}let ct,T,x,k,X,$,se,le,Z,Q,he,De,fe,ue,Le,Fe,Xe,L,ce,j,de,ve,te;function Te(){ct=new F3(N),ct.init(),de=new Ry(N,ct),T=new D3(N,ct,e,de),x=new Ay(N,ct),T.reversedDepthBuffer&&d&&x.buffers.depth.setReversed(!0),F=N.createFramebuffer(),H=N.createFramebuffer(),O=N.createFramebuffer(),k=new B3(N),X=new dy,$=new Ty(N,ct,x,X,T,de,k),se=new U3(I),le=new Wv(N),ve=new T3(N,le),Z=new k3(N,le,k,ve),Q=new G3(N,Z,le,ve,k),L=new H3(N,T,$),Le=new C3(X),he=new uy(I,se,ct,T,ve,Le),De=new Ny(I,X),fe=new py,ue=new _y(ct),Xe=new A3(I,se,x,Q,p,c),Fe=new wy(I,Q,T),te=new Oy(N,k,T,x),ce=new R3(N,ct,k),j=new z3(N,ct,k),k.programs=he.programs,I.capabilities=T,I.extensions=ct,I.properties=X,I.renderLists=fe,I.shadowMap=Fe,I.state=x,I.info=k}Te(),v!==Hn&&(A=new W3(v,t.width,t.height,o,i,r));const ye=new Py(I,N);this.xr=ye,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=ct.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=ct.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(y){y!==void 0&&(ie=y,this.setSize(K,re,!1))},this.getSize=function(y){return y.set(K,re)},this.setSize=function(y,U,q=!0){if(ye.isPresenting){we("WebGLRenderer: Can't change size while VR device is presenting.");return}K=y,re=U,t.width=Math.floor(y*ie),t.height=Math.floor(U*ie),q===!0&&(t.style.width=y+"px",t.style.height=U+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(K*ie,re*ie).floor()},this.setDrawingBufferSize=function(y,U,q){K=y,re=U,ie=q,t.width=Math.floor(y*q),t.height=Math.floor(U*q),this.setViewport(0,0,y,U)},this.setEffects=function(y){if(v===Hn){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let U=0;U<y.length;U++)if(y[U].isOutputPass===!0){we("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(ne)},this.getViewport=function(y){return y.copy(Pe)},this.setViewport=function(y,U,q,G){y.isVector4?Pe.set(y.x,y.y,y.z,y.w):Pe.set(y,U,q,G),x.viewport(ne.copy(Pe).multiplyScalar(ie).round())},this.getScissor=function(y){return y.copy(Re)},this.setScissor=function(y,U,q,G){y.isVector4?Re.set(y.x,y.y,y.z,y.w):Re.set(y,U,q,G),x.scissor(ae.copy(Re).multiplyScalar(ie).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(y){x.setScissorTest(xe=y)},this.setOpaqueSort=function(y){B=y},this.setTransparentSort=function(y){Ee=y},this.getClearColor=function(y){return y.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,q=!0){let G=0;if(y){let W=!1;if(Y!==null){const ge=Y.texture.format;W=m.has(ge)}if(W){const ge=Y.texture.type,_e=g.has(ge),me=Xe.getClearColor(),be=Xe.getClearAlpha(),Ce=me.r,qe=me.g,$e=me.b;_e?(S[0]=Ce,S[1]=qe,S[2]=$e,S[3]=be,N.clearBufferuiv(N.COLOR,0,S)):(b[0]=Ce,b[1]=qe,b[2]=$e,b[3]=be,N.clearBufferiv(N.COLOR,0,b))}else G|=N.COLOR_BUFFER_BIT}U&&(G|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(G|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&N.clear(G)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),P=y},this.dispose=function(){t.removeEventListener("webglcontextlost",Ot,!1),t.removeEventListener("webglcontextrestored",vt,!1),t.removeEventListener("webglcontextcreationerror",fi,!1),Xe.dispose(),fe.dispose(),ue.dispose(),X.dispose(),se.dispose(),Q.dispose(),ve.dispose(),te.dispose(),he.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",Td),ye.removeEventListener("sessionend",Rd),As.stop()};function Ot(y){y.preventDefault(),Ac("WebGLRenderer: Context Lost."),D=!0}function vt(){Ac("WebGLRenderer: Context Restored."),D=!1;const y=k.autoReset,U=Fe.enabled,q=Fe.autoUpdate,G=Fe.needsUpdate,W=Fe.type;Te(),k.autoReset=y,Fe.enabled=U,Fe.autoUpdate=q,Fe.needsUpdate=G,Fe.type=W}function fi(y){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function pi(y){const U=y.target;U.removeEventListener("dispose",pi),_g(U)}function _g(y){yg(y),X.remove(y)}function yg(y){const U=X.get(y).programs;U!==void 0&&(U.forEach(function(q){he.releaseProgram(q)}),y.isShaderMaterial&&he.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,q,G,W,ge){U===null&&(U=Et);const _e=W.isMesh&&W.matrixWorld.determinantAffine()<0,me=Eg(y,U,q,G,W);x.setMaterial(G,_e);let be=q.index,Ce=1;if(G.wireframe===!0){if(be=Z.getWireframeAttribute(q),be===void 0)return;Ce=2}const qe=q.drawRange,$e=q.attributes.position;let Ie=qe.start*Ce,ft=(qe.start+qe.count)*Ce;ge!==null&&(Ie=Math.max(Ie,ge.start*Ce),ft=Math.min(ft,(ge.start+ge.count)*Ce)),be!==null?(Ie=Math.max(Ie,0),ft=Math.min(ft,be.count)):$e!=null&&(Ie=Math.max(Ie,0),ft=Math.min(ft,$e.count));const zt=ft-Ie;if(zt<0||zt===1/0)return;ve.setup(W,G,me,q,be);let Ut,mt=ce;if(be!==null&&(Ut=le.get(be),mt=j,mt.setIndex(Ut)),W.isMesh)G.wireframe===!0?(x.setLineWidth(G.wireframeLinewidth*Wt()),mt.setMode(N.LINES)):mt.setMode(N.TRIANGLES);else if(W.isLine){let mn=G.linewidth;mn===void 0&&(mn=1),x.setLineWidth(mn*Wt()),W.isLineSegments?mt.setMode(N.LINES):W.isLineLoop?mt.setMode(N.LINE_LOOP):mt.setMode(N.LINE_STRIP)}else W.isPoints?mt.setMode(N.POINTS):W.isSprite&&mt.setMode(N.TRIANGLES);if(W.isBatchedMesh)if(ct.get("WEBGL_multi_draw"))mt.renderMultiDraw(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount);else{const mn=W._multiDrawStarts,Me=W._multiDrawCounts,On=W._multiDrawCount,tt=be?le.get(be).bytesPerElement:1,Vn=X.get(G).currentProgram.getUniforms();for(let mi=0;mi<On;mi++)Vn.setValue(N,"_gl_DrawID",mi),mt.render(mn[mi]/tt,Me[mi])}else if(W.isInstancedMesh)mt.renderInstances(Ie,zt,W.count);else if(q.isInstancedBufferGeometry){const mn=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Me=Math.min(q.instanceCount,mn);mt.renderInstances(Ie,zt,Me)}else mt.render(Ie,zt)};function Ad(y,U,q){y.transparent===!0&&y.side===ai&&y.forceSinglePass===!1?(y.side=Ct,y.needsUpdate=!0,so(y,U,q),y.side=Ss,y.needsUpdate=!0,so(y,U,q),y.side=ai):so(y,U,q)}this.compile=function(y,U,q=null){q===null&&(q=y),w=ue.get(q),w.init(U),M.push(w),q.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),y!==q&&y.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),w.setupLights();const G=new Set;return y.traverse(function(W){if(!(W.isMesh||W.isPoints||W.isLine||W.isSprite))return;const ge=W.material;if(ge)if(Array.isArray(ge))for(let _e=0;_e<ge.length;_e++){const me=ge[_e];Ad(me,q,W),G.add(me)}else Ad(ge,q,W),G.add(ge)}),w=M.pop(),G},this.compileAsync=function(y,U,q=null){const G=this.compile(y,U,q);return new Promise(W=>{function ge(){if(G.forEach(function(_e){X.get(_e).currentProgram.isReady()&&G.delete(_e)}),G.size===0){W(y);return}setTimeout(ge,10)}ct.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let Qc=null;function Sg(y){Qc&&Qc(y)}function Td(){As.stop()}function Rd(){As.start()}const As=new Dm;As.setAnimationLoop(Sg),typeof self<"u"&&As.setContext(self),this.setAnimationLoop=function(y){Qc=y,ye.setAnimationLoop(y),y===null?As.stop():As.start()},ye.addEventListener("sessionstart",Td),ye.addEventListener("sessionend",Rd),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;P!==null&&P.renderStart(y,U);const q=ye.enabled===!0&&ye.isPresenting===!0,G=A!==null&&(Y===null||q)&&A.begin(I,Y);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(U),U=ye.getCamera()),y.isScene===!0&&y.onBeforeRender(I,y,U,Y),w=ue.get(y,M.length),w.init(U),w.state.textureUnits=$.getTextureUnits(),M.push(w),at.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ne.setFromProjectionMatrix(at,Ri,U.reversedDepth),Ue=this.localClippingEnabled,Oe=Le.init(this.clippingPlanes,Ue),E=fe.get(y,R.length),E.init(),R.push(E),ye.enabled===!0&&ye.isPresenting===!0){const _e=I.xr.getDepthSensingMesh();_e!==null&&el(_e,U,-1/0,I.sortObjects)}el(y,U,0,I.sortObjects),E.finish(),I.sortObjects===!0&&E.sort(B,Ee,U.reversedDepth),Nt=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,Nt&&Xe.addToRenderList(E,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&Le.beginShadows();const W=w.state.shadowsArray;if(Fe.render(W,y,U),Oe===!0&&Le.endShadows(),(G&&A.hasRenderPass())===!1){const _e=E.opaque,me=E.transmissive;if(w.setupLights(),U.isArrayCamera){const be=U.cameras;if(me.length>0)for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Cd(_e,me,y,$e)}Nt&&Xe.render(y);for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Dd(E,y,$e,$e.viewport)}}else me.length>0&&Cd(_e,me,y,U),Nt&&Xe.render(y),Dd(E,y,U)}Y!==null&&z===0&&($.updateMultisampleRenderTarget(Y),$.updateRenderTargetMipmap(Y)),G&&A.end(I),y.isScene===!0&&y.onAfterRender(I,y,U),ve.resetDefaultState(),ee=-1,J=null,M.pop(),M.length>0?(w=M[M.length-1],$.setTextureUnits(w.state.textureUnits),Oe===!0&&Le.setGlobalState(I.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?E=R[R.length-1]:E=null,P!==null&&P.renderEnd()};function el(y,U,q,G){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)q=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Ne.intersectsSprite(y)){G&&Lt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(at);const _e=Q.update(y),me=y.material;me.visible&&E.push(y,_e,me,q,Lt.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Ne.intersectsObject(y))){const _e=Q.update(y),me=y.material;if(G&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Lt.copy(y.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Lt.copy(_e.boundingSphere.center)),Lt.applyMatrix4(y.matrixWorld).applyMatrix4(at)),Array.isArray(me)){const be=_e.groups;for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce],Ie=me[$e.materialIndex];Ie&&Ie.visible&&E.push(y,_e,Ie,q,Lt.z,$e)}}else me.visible&&E.push(y,_e,me,q,Lt.z,null)}}const ge=y.children;for(let _e=0,me=ge.length;_e<me;_e++)el(ge[_e],U,q,G)}function Dd(y,U,q,G){const{opaque:W,transmissive:ge,transparent:_e}=y;w.setupLightsView(q),Oe===!0&&Le.setGlobalState(I.clippingPlanes,q),G&&x.viewport(ne.copy(G)),W.length>0&&io(W,U,q),ge.length>0&&io(ge,U,q),_e.length>0&&io(_e,U,q),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function Cd(y,U,q,G){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[G.id]===void 0){const Ie=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[G.id]=new dn(1,1,{generateMipmaps:!0,type:Ie?cn:Hn,minFilter:Bs,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:et.workingColorSpace})}const ge=w.state.transmissionRenderTarget[G.id],_e=G.viewport||ne;ge.setSize(_e.z*I.transmissionResolutionScale,_e.w*I.transmissionResolutionScale);const me=I.getRenderTarget(),be=I.getActiveCubeFace(),Ce=I.getActiveMipmapLevel();I.setRenderTarget(ge),I.getClearColor(je),Be=I.getClearAlpha(),Be<1&&I.setClearColor(16777215,.5),I.clear(),Nt&&Xe.render(q);const qe=I.toneMapping;I.toneMapping=Ii;const $e=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),w.setupLightsView(G),Oe===!0&&Le.setGlobalState(I.clippingPlanes,G),io(y,q,G),$.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Ie=!1;for(let ft=0,zt=U.length;ft<zt;ft++){const Ut=U[ft],{object:mt,geometry:mn,material:Me,group:On}=Ut;if(Me.side===ai&&mt.layers.test(G.layers)){const tt=Me.side;Me.side=Ct,Me.needsUpdate=!0,Id(mt,q,G,mn,Me,On),Me.side=tt,Me.needsUpdate=!0,Ie=!0}}Ie===!0&&($.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge))}I.setRenderTarget(me,be,Ce),I.setClearColor(je,Be),$e!==void 0&&(G.viewport=$e),I.toneMapping=qe}function io(y,U,q){const G=U.isScene===!0?U.overrideMaterial:null;for(let W=0,ge=y.length;W<ge;W++){const _e=y[W],{object:me,geometry:be,group:Ce}=_e;let qe=_e.material;qe.allowOverride===!0&&G!==null&&(qe=G),me.layers.test(q.layers)&&Id(me,U,q,be,qe,Ce)}}function Id(y,U,q,G,W,ge){y.onBeforeRender(I,U,q,G,W,ge),y.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),W.onBeforeRender(I,U,q,G,y,ge),W.transparent===!0&&W.side===ai&&W.forceSinglePass===!1?(W.side=Ct,W.needsUpdate=!0,I.renderBufferDirect(q,U,G,W,y,ge),W.side=Ss,W.needsUpdate=!0,I.renderBufferDirect(q,U,G,W,y,ge),W.side=ai):I.renderBufferDirect(q,U,G,W,y,ge),y.onAfterRender(I,U,q,G,W,ge)}function so(y,U,q){U.isScene!==!0&&(U=Et);const G=X.get(y),W=w.state.lights,ge=w.state.shadowsArray,_e=W.state.version,me=he.getParameters(y,W.state,ge,U,q,w.state.lightProbeGridArray),be=he.getProgramCacheKey(me);let Ce=G.programs;G.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?U.environment:null,G.fog=U.fog;const qe=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;G.envMap=se.get(y.envMap||G.environment,qe),G.envMapRotation=G.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Ce===void 0&&(y.addEventListener("dispose",pi),Ce=new Map,G.programs=Ce);let $e=Ce.get(be);if($e!==void 0){if(G.currentProgram===$e&&G.lightsStateVersion===_e)return Ld(y,me),$e}else me.uniforms=he.getUniforms(y),P!==null&&y.isNodeMaterial&&P.build(y,q,me),y.onBeforeCompile(me,I),$e=he.acquireProgram(me,be),Ce.set(be,$e),G.uniforms=me.uniforms;const Ie=G.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ie.clippingPlanes=Le.uniform),Ld(y,me),G.needsLights=Ag(y),G.lightsStateVersion=_e,G.needsLights&&(Ie.ambientLightColor.value=W.state.ambient,Ie.lightProbe.value=W.state.probe,Ie.directionalLights.value=W.state.directional,Ie.directionalLightShadows.value=W.state.directionalShadow,Ie.spotLights.value=W.state.spot,Ie.spotLightShadows.value=W.state.spotShadow,Ie.rectAreaLights.value=W.state.rectArea,Ie.ltc_1.value=W.state.rectAreaLTC1,Ie.ltc_2.value=W.state.rectAreaLTC2,Ie.pointLights.value=W.state.point,Ie.pointLightShadows.value=W.state.pointShadow,Ie.hemisphereLights.value=W.state.hemi,Ie.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Ie.spotLightMatrix.value=W.state.spotLightMatrix,Ie.spotLightMap.value=W.state.spotLightMap,Ie.pointShadowMatrix.value=W.state.pointShadowMatrix),G.lightProbeGrid=w.state.lightProbeGridArray.length>0,G.currentProgram=$e,G.uniformsList=null,$e}function Pd(y){if(y.uniformsList===null){const U=y.currentProgram.getUniforms();y.uniformsList=dc.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function Ld(y,U){const q=X.get(y);q.outputColorSpace=U.outputColorSpace,q.batching=U.batching,q.batchingColor=U.batchingColor,q.instancing=U.instancing,q.instancingColor=U.instancingColor,q.instancingMorph=U.instancingMorph,q.skinning=U.skinning,q.morphTargets=U.morphTargets,q.morphNormals=U.morphNormals,q.morphColors=U.morphColors,q.morphTargetsCount=U.morphTargetsCount,q.numClippingPlanes=U.numClippingPlanes,q.numIntersection=U.numClipIntersection,q.vertexAlphas=U.vertexAlphas,q.vertexTangents=U.vertexTangents,q.toneMapping=U.toneMapping}function bg(y,U){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;_.setFromMatrixPosition(U.matrixWorld);for(let q=0,G=y.length;q<G;q++){const W=y[q];if(W.texture!==null&&W.boundingBox.containsPoint(_))return W}return null}function Eg(y,U,q,G,W){U.isScene!==!0&&(U=Et),$.resetTextureUnits();const ge=U.fog,_e=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?U.environment:null,me=Y===null?I.outputColorSpace:Y.isXRRenderTarget===!0?Y.texture.colorSpace:et.workingColorSpace,be=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Ce=se.get(G.envMap||_e,be),qe=G.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,$e=!!q.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ie=!!q.morphAttributes.position,ft=!!q.morphAttributes.normal,zt=!!q.morphAttributes.color;let Ut=Ii;G.toneMapped&&(Y===null||Y.isXRRenderTarget===!0)&&(Ut=I.toneMapping);const mt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,mn=mt!==void 0?mt.length:0,Me=X.get(G),On=w.state.lights;if(Oe===!0&&(Ue===!0||y!==J)){const Mt=y===J&&G.id===ee;Le.setState(G,y,Mt)}let tt=!1;G.version===Me.__version?(Me.needsLights&&Me.lightsStateVersion!==On.state.version||Me.outputColorSpace!==me||W.isBatchedMesh&&Me.batching===!1||!W.isBatchedMesh&&Me.batching===!0||W.isBatchedMesh&&Me.batchingColor===!0&&W.colorTexture===null||W.isBatchedMesh&&Me.batchingColor===!1&&W.colorTexture!==null||W.isInstancedMesh&&Me.instancing===!1||!W.isInstancedMesh&&Me.instancing===!0||W.isSkinnedMesh&&Me.skinning===!1||!W.isSkinnedMesh&&Me.skinning===!0||W.isInstancedMesh&&Me.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&Me.instancingColor===!1&&W.instanceColor!==null||W.isInstancedMesh&&Me.instancingMorph===!0&&W.morphTexture===null||W.isInstancedMesh&&Me.instancingMorph===!1&&W.morphTexture!==null||Me.envMap!==Ce||G.fog===!0&&Me.fog!==ge||Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==Le.numPlanes||Me.numIntersection!==Le.numIntersection)||Me.vertexAlphas!==qe||Me.vertexTangents!==$e||Me.morphTargets!==Ie||Me.morphNormals!==ft||Me.morphColors!==zt||Me.toneMapping!==Ut||Me.morphTargetsCount!==mn||!!Me.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(tt=!0):(tt=!0,Me.__version=G.version);let Vn=Me.currentProgram;tt===!0&&(Vn=so(G,U,W),P&&G.isNodeMaterial&&P.onUpdateProgram(G,Vn,Me));let mi=!1,ts=!1,Qs=!1;const gt=Vn.getUniforms(),Bt=Me.uniforms;if(x.useProgram(Vn.program)&&(mi=!0,ts=!0,Qs=!0),G.id!==ee&&(ee=G.id,ts=!0),Me.needsLights){const Mt=bg(w.state.lightProbeGridArray,W);Me.lightProbeGrid!==Mt&&(Me.lightProbeGrid=Mt,ts=!0)}if(mi||J!==y){x.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),gt.setValue(N,"projectionMatrix",y.projectionMatrix),gt.setValue(N,"viewMatrix",y.matrixWorldInverse);const is=gt.map.cameraPosition;is!==void 0&&is.setValue(N,ot.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&gt.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&gt.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),J!==y&&(J=y,ts=!0,Qs=!0)}if(Me.needsLights&&(On.state.directionalShadowMap.length>0&&gt.setValue(N,"directionalShadowMap",On.state.directionalShadowMap,$),On.state.spotShadowMap.length>0&&gt.setValue(N,"spotShadowMap",On.state.spotShadowMap,$),On.state.pointShadowMap.length>0&&gt.setValue(N,"pointShadowMap",On.state.pointShadowMap,$)),W.isSkinnedMesh){gt.setOptional(N,W,"bindMatrix"),gt.setOptional(N,W,"bindMatrixInverse");const Mt=W.skeleton;Mt&&(Mt.boneTexture===null&&Mt.computeBoneTexture(),gt.setValue(N,"boneTexture",Mt.boneTexture,$))}W.isBatchedMesh&&(gt.setOptional(N,W,"batchingTexture"),gt.setValue(N,"batchingTexture",W._matricesTexture,$),gt.setOptional(N,W,"batchingIdTexture"),gt.setValue(N,"batchingIdTexture",W._indirectTexture,$),gt.setOptional(N,W,"batchingColorTexture"),W._colorsTexture!==null&&gt.setValue(N,"batchingColorTexture",W._colorsTexture,$));const ns=q.morphAttributes;if((ns.position!==void 0||ns.normal!==void 0||ns.color!==void 0)&&L.update(W,q,Vn),(ts||Me.receiveShadow!==W.receiveShadow)&&(Me.receiveShadow=W.receiveShadow,gt.setValue(N,"receiveShadow",W.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&U.environment!==null&&(Bt.envMapIntensity.value=U.environmentIntensity),Bt.dfgLUT!==void 0&&(Bt.dfgLUT.value=Fy()),ts){if(gt.setValue(N,"toneMappingExposure",I.toneMappingExposure),Me.needsLights&&wg(Bt,Qs),ge&&G.fog===!0&&De.refreshFogUniforms(Bt,ge),De.refreshMaterialUniforms(Bt,G,ie,re,w.state.transmissionRenderTarget[y.id]),Me.needsLights&&Me.lightProbeGrid){const Mt=Me.lightProbeGrid;Bt.probesSH.value=Mt.texture,Bt.probesMin.value.copy(Mt.boundingBox.min),Bt.probesMax.value.copy(Mt.boundingBox.max),Bt.probesResolution.value.copy(Mt.resolution)}dc.upload(N,Pd(Me),Bt,$)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(dc.upload(N,Pd(Me),Bt,$),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&gt.setValue(N,"center",W.center),gt.setValue(N,"modelViewMatrix",W.modelViewMatrix),gt.setValue(N,"normalMatrix",W.normalMatrix),gt.setValue(N,"modelMatrix",W.matrixWorld),G.uniformsGroups!==void 0){const Mt=G.uniformsGroups;for(let is=0,er=Mt.length;is<er;is++){const Nd=Mt[is];te.update(Nd,Vn),te.bind(Nd,Vn)}}return Vn}function wg(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function Ag(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return Y},this.setRenderTargetTextures=function(y,U,q){const G=X.get(y);G.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),X.get(y.texture).__webglTexture=U,X.get(y.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:q,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){const q=X.get(y);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(y,U=0,q=0){Y=y,V=U,z=q;let G=null,W=!1,ge=!1;if(y){const me=X.get(y);if(me.__useDefaultFramebuffer!==void 0){x.bindFramebuffer(N.FRAMEBUFFER,me.__webglFramebuffer),ne.copy(y.viewport),ae.copy(y.scissor),Ve=y.scissorTest,x.viewport(ne),x.scissor(ae),x.setScissorTest(Ve),ee=-1;return}else if(me.__webglFramebuffer===void 0)$.setupRenderTarget(y);else if(me.__hasExternalTextures)$.rebindTextures(y,X.get(y.texture).__webglTexture,X.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const qe=y.depthTexture;if(me.__boundDepthTexture!==qe){if(qe!==null&&X.has(qe)&&(y.width!==qe.image.width||y.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(y)}}const be=y.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(ge=!0);const Ce=X.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Ce[U])?G=Ce[U][q]:G=Ce[U],W=!0):y.samples>0&&$.useMultisampledRTT(y)===!1?G=X.get(y).__webglMultisampledFramebuffer:Array.isArray(Ce)?G=Ce[q]:G=Ce,ne.copy(y.viewport),ae.copy(y.scissor),Ve=y.scissorTest}else ne.copy(Pe).multiplyScalar(ie).floor(),ae.copy(Re).multiplyScalar(ie).floor(),Ve=xe;if(q!==0&&(G=F),x.bindFramebuffer(N.FRAMEBUFFER,G)&&x.drawBuffers(y,G),x.viewport(ne),x.scissor(ae),x.setScissorTest(Ve),W){const me=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,me.__webglTexture,q)}else if(ge){const me=U;for(let be=0;be<y.textures.length;be++){const Ce=X.get(y.textures[be]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+be,Ce.__webglTexture,q,me)}}else if(y!==null&&q!==0){const me=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,me.__webglTexture,q)}ee=-1},this.readRenderTargetPixels=function(y,U,q,G,W,ge,_e,me=0){if(!(y&&y.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){x.bindFramebuffer(N.FRAMEBUFFER,be);try{const Ce=y.textures[me],qe=Ce.format,$e=Ce.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable($e)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W&&N.readPixels(U,q,G,W,de.convert(qe),de.convert($e),ge)}finally{const Ce=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,Ce)}}},this.readRenderTargetPixelsAsync=async function(y,U,q,G,W,ge,_e,me=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W){x.bindFramebuffer(N.FRAMEBUFFER,be);const Ce=y.textures[me],qe=Ce.format,$e=Ce.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ie=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ie),N.bufferData(N.PIXEL_PACK_BUFFER,ge.byteLength,N.STREAM_READ),N.readPixels(U,q,G,W,de.convert(qe),de.convert($e),0);const ft=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,ft);const zt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await f2(N,zt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ie),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,ge),N.deleteBuffer(Ie),N.deleteSync(zt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,q=0){const G=Math.pow(2,-q),W=Math.floor(y.image.width*G),ge=Math.floor(y.image.height*G),_e=U!==null?U.x:0,me=U!==null?U.y:0;$.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,q,0,0,_e,me,W,ge),x.unbindTexture()},this.copyTextureToTexture=function(y,U,q=null,G=null,W=0,ge=0){let _e,me,be,Ce,qe,$e,Ie,ft,zt;const Ut=y.isCompressedTexture?y.mipmaps[ge]:y.image;if(q!==null)_e=q.max.x-q.min.x,me=q.max.y-q.min.y,be=q.isBox3?q.max.z-q.min.z:1,Ce=q.min.x,qe=q.min.y,$e=q.isBox3?q.min.z:0;else{const Bt=Math.pow(2,-W);_e=Math.floor(Ut.width*Bt),me=Math.floor(Ut.height*Bt),y.isDataArrayTexture?be=Ut.depth:y.isData3DTexture?be=Math.floor(Ut.depth*Bt):be=1,Ce=0,qe=0,$e=0}G!==null?(Ie=G.x,ft=G.y,zt=G.z):(Ie=0,ft=0,zt=0);const mt=de.convert(U.format),mn=de.convert(U.type);let Me;U.isData3DTexture?($.setTexture3D(U,0),Me=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),Me=N.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),Me=N.TEXTURE_2D),x.activeTexture(N.TEXTURE0),x.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),x.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),x.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);const On=x.getParameter(N.UNPACK_ROW_LENGTH),tt=x.getParameter(N.UNPACK_IMAGE_HEIGHT),Vn=x.getParameter(N.UNPACK_SKIP_PIXELS),mi=x.getParameter(N.UNPACK_SKIP_ROWS),ts=x.getParameter(N.UNPACK_SKIP_IMAGES);x.pixelStorei(N.UNPACK_ROW_LENGTH,Ut.width),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Ut.height),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Ce),x.pixelStorei(N.UNPACK_SKIP_ROWS,qe),x.pixelStorei(N.UNPACK_SKIP_IMAGES,$e);const Qs=y.isDataArrayTexture||y.isData3DTexture,gt=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){const Bt=X.get(y),ns=X.get(U),Mt=X.get(Bt.__renderTarget),is=X.get(ns.__renderTarget);x.bindFramebuffer(N.READ_FRAMEBUFFER,Mt.__webglFramebuffer),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,is.__webglFramebuffer);for(let er=0;er<be;er++)Qs&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(y).__webglTexture,W,$e+er),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(U).__webglTexture,ge,zt+er)),N.blitFramebuffer(Ce,qe,_e,me,Ie,ft,_e,me,N.DEPTH_BUFFER_BIT,N.NEAREST);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(W!==0||y.isRenderTargetTexture||X.has(y)){const Bt=X.get(y),ns=X.get(U);x.bindFramebuffer(N.READ_FRAMEBUFFER,H),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let Mt=0;Mt<be;Mt++)Qs?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Bt.__webglTexture,W,$e+Mt):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Bt.__webglTexture,W),gt?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,ns.__webglTexture,ge,zt+Mt):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ns.__webglTexture,ge),W!==0?N.blitFramebuffer(Ce,qe,_e,me,Ie,ft,_e,me,N.COLOR_BUFFER_BIT,N.NEAREST):gt?N.copyTexSubImage3D(Me,ge,Ie,ft,zt+Mt,Ce,qe,_e,me):N.copyTexSubImage2D(Me,ge,Ie,ft,Ce,qe,_e,me);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else gt?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(Me,ge,Ie,ft,zt,_e,me,be,mt,mn,Ut.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(Me,ge,Ie,ft,zt,_e,me,be,mt,Ut.data):N.texSubImage3D(Me,ge,Ie,ft,zt,_e,me,be,mt,mn,Ut):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,ge,Ie,ft,_e,me,mt,mn,Ut.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,ge,Ie,ft,Ut.width,Ut.height,mt,Ut.data):N.texSubImage2D(N.TEXTURE_2D,ge,Ie,ft,_e,me,mt,mn,Ut);x.pixelStorei(N.UNPACK_ROW_LENGTH,On),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,tt),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Vn),x.pixelStorei(N.UNPACK_SKIP_ROWS,mi),x.pixelStorei(N.UNPACK_SKIP_IMAGES,ts),ge===0&&U.generateMipmaps&&N.generateMipmap(Me),x.unbindTexture()},this.initRenderTarget=function(y){X.get(y).__webglFramebuffer===void 0&&$.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?$.setTextureCube(y,0):y.isData3DTexture?$.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?$.setTexture2DArray(y,0):$.setTexture2D(y,0),x.unbindTexture()},this.resetState=function(){V=0,z=0,Y=null,x.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ri}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=et._getDrawingBufferColorSpace(e),t.unpackColorSpace=et._getUnpackColorSpace()}}const zy=`
4718
+ }`;class Iy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Sm(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Rt({vertexShader:Dy,fragmentShader:Cy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new We(new ui(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Py extends Js{constructor(e,t){super();const n=this;let i=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new Iy,g={},S=t.getContextAttributes();let b=null,_=null;const E=[],w=[],R=new Ae;let M=null;const A=new Nn;A.viewport=new nt;const I=new Nn;I.viewport=new nt;const D=[A,I],P=new Lv;let F=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let re=E[K];return re===void 0&&(re=new dl,E[K]=re),re.getTargetRaySpace()},this.getControllerGrip=function(K){let re=E[K];return re===void 0&&(re=new dl,E[K]=re),re.getGripSpace()},this.getHand=function(K){let re=E[K];return re===void 0&&(re=new dl,E[K]=re),re.getHandSpace()};function O(K){const re=w.indexOf(K.inputSource);if(re===-1)return;const ie=E[re];ie!==void 0&&(ie.update(K.inputSource,K.frame,l||a),ie.dispatchEvent({type:K.type,data:K.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",z);for(let K=0;K<E.length;K++){const re=w[K];re!==null&&(w[K]=null,E[K].disconnect(re))}F=null,H=null,m.reset();for(const K in g)delete g[K];e.setRenderTarget(b),f=null,d=null,u=null,i=null,_=null,He.stop(),n.isPresenting=!1,e.setPixelRatio(M),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&we("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,n.isPresenting===!0&&we("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(i,t)),u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(K){if(i=K,i!==null){if(b=e.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",V),i.addEventListener("inputsourceschange",z),S.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ie=null,B=null,Ee=null;S.depth&&(Ee=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ie=S.stencil?Hs:Zi,B=S.stencil?qa:li);const Pe={colorFormat:t.RGBA8,depthFormat:Ee,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Pe),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),_=new dn(d.textureWidth,d.textureHeight,{format:_n,type:Hn,depthTexture:new Ks(d.textureWidth,d.textureHeight,B,void 0,void 0,void 0,void 0,void 0,void 0,ie),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ie={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,t,ie),i.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new dn(f.framebufferWidth,f.framebufferHeight,{format:_n,type:Hn,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),He.setContext(i),He.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function z(K){for(let re=0;re<K.removed.length;re++){const ie=K.removed[re],B=w.indexOf(ie);B>=0&&(w[B]=null,E[B].disconnect(ie))}for(let re=0;re<K.added.length;re++){const ie=K.added[re];let B=w.indexOf(ie);if(B===-1){for(let Pe=0;Pe<E.length;Pe++)if(Pe>=w.length){w.push(ie),B=Pe;break}else if(w[Pe]===null){w[Pe]=ie,B=Pe;break}if(B===-1)break}const Ee=E[B];Ee&&Ee.connect(ie)}}const Y=new C,ee=new C;function J(K,re,ie){Y.setFromMatrixPosition(re.matrixWorld),ee.setFromMatrixPosition(ie.matrixWorld);const B=Y.distanceTo(ee),Ee=re.projectionMatrix.elements,Pe=ie.projectionMatrix.elements,Re=Ee[14]/(Ee[10]-1),xe=Ee[14]/(Ee[10]+1),Ne=(Ee[9]+1)/Ee[5],Oe=(Ee[9]-1)/Ee[5],Ue=(Ee[8]-1)/Ee[0],at=(Pe[8]+1)/Pe[0],ot=Re*Ue,Lt=Re*at,Et=B/(-Ue+at),Nt=Et*-Ue;if(re.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Nt),K.translateZ(Et),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Ee[10]===-1)K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const Wt=Re+Et,N=xe+Et,Rn=ot-Nt,ct=Lt+(B-Nt),T=Ne*xe/N*Wt,x=Oe*xe/N*Wt;K.projectionMatrix.makePerspective(Rn,ct,T,x,Wt,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function ne(K,re){re===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(re.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(i===null)return;let re=K.near,ie=K.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ie=m.depthFar)),P.near=I.near=A.near=re,P.far=I.far=A.far=ie,(F!==P.near||H!==P.far)&&(i.updateRenderState({depthNear:P.near,depthFar:P.far}),F=P.near,H=P.far),P.layers.mask=K.layers.mask|6,A.layers.mask=P.layers.mask&-5,I.layers.mask=P.layers.mask&-3;const B=K.parent,Ee=P.cameras;ne(P,B);for(let Pe=0;Pe<Ee.length;Pe++)ne(Ee[Pe],B);Ee.length===2?J(P,A,I):P.projectionMatrix.copy(A.projectionMatrix),ae(K,P,B)};function ae(K,re,ie){ie===null?K.matrix.copy(re.matrixWorld):(K.matrix.copy(ie.matrixWorld),K.matrix.invert(),K.matrix.multiply(re.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(re.projectionMatrix),K.projectionMatrixInverse.copy(re.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=$r*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(K){c=K,d!==null&&(d.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(P)},this.getCameraTexture=function(K){return g[K]};let Ve=null;function je(K,re){if(h=re.getViewerPose(l||a),p=re,h!==null){const ie=h.views;f!==null&&(e.setRenderTargetFramebuffer(_,f.framebuffer),e.setRenderTarget(_));let B=!1;ie.length!==P.cameras.length&&(P.cameras.length=0,B=!0);for(let xe=0;xe<ie.length;xe++){const Ne=ie[xe];let Oe=null;if(f!==null)Oe=f.getViewport(Ne);else{const at=u.getViewSubImage(d,Ne);Oe=at.viewport,xe===0&&(e.setRenderTargetTextures(_,at.colorTexture,at.depthStencilTexture),e.setRenderTarget(_))}let Ue=D[xe];Ue===void 0&&(Ue=new Nn,Ue.layers.enable(xe),Ue.viewport=new nt,D[xe]=Ue),Ue.matrix.fromArray(Ne.transform.matrix),Ue.matrix.decompose(Ue.position,Ue.quaternion,Ue.scale),Ue.projectionMatrix.fromArray(Ne.projectionMatrix),Ue.projectionMatrixInverse.copy(Ue.projectionMatrix).invert(),Ue.viewport.set(Oe.x,Oe.y,Oe.width,Oe.height),xe===0&&(P.matrix.copy(Ue.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),B===!0&&P.cameras.push(Ue)}const Ee=i.enabledFeatures;if(Ee&&Ee.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();const xe=u.getDepthInformation(ie[0]);xe&&xe.isValid&&xe.texture&&m.init(xe,i.renderState)}if(Ee&&Ee.includes("camera-access")&&v){e.state.unbindTexture(),u=n.getBinding();for(let xe=0;xe<ie.length;xe++){const Ne=ie[xe].camera;if(Ne){let Oe=g[Ne];Oe||(Oe=new Sm,g[Ne]=Oe);const Ue=u.getCameraImage(Ne);Oe.sourceTexture=Ue}}}}for(let ie=0;ie<E.length;ie++){const B=w[ie],Ee=E[ie];B!==null&&Ee!==void 0&&Ee.update(B,re,l||a)}Ve&&Ve(K,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),p=null}const He=new Dm;He.setAnimationLoop(je),this.setAnimationLoop=function(K){Ve=K},this.dispose=function(){}}}const Ly=new Ye,Um=new Be;Um.set(-1,0,0,0,1,0,0,0,1);function Ny(s,e){function t(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function n(m,g){g.color.getRGB(m.fogColor.value,bm(s)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function i(m,g,S,b,_){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?r(m,g):g.isMeshLambertMaterial?(r(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(r(m,g),u(m,g)):g.isMeshPhongMaterial?(r(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(r(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,_)):g.isMeshMatcapMaterial?(r(m,g),p(m,g)):g.isMeshDepthMaterial?r(m,g):g.isMeshDistanceMaterial?(r(m,g),v(m,g)):g.isMeshNormalMaterial?r(m,g):g.isLineBasicMaterial?(a(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,S,b):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function r(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,t(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ct&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,t(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ct&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,t(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,t(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,t(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const S=e.get(g),b=S.envMap,_=S.envMapRotation;b&&(m.envMap.value=b,m.envMapRotation.value.setFromMatrix4(Ly.makeRotationFromEuler(_)).transpose(),b.isCubeTexture&&b.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Um),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,S,b){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*S,m.scale.value=b*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,S){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ct&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=S.texture,m.transmissionSamplerSize.value.set(S.width,S.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const S=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(S.matrixWorld),m.nearDistance.value=S.shadow.camera.near,m.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Oy(s,e,t,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,E){const w=E.program;n.uniformBlockBinding(_,w)}function l(_,E){let w=i[_.id];w===void 0&&(m(_),w=h(_),i[_.id]=w,_.addEventListener("dispose",S));const R=E.program;n.updateUBOMapping(_,R);const M=e.render.frame;r[_.id]!==M&&(d(_),r[_.id]=M)}function h(_){const E=u();_.__bindingPointIndex=E;const w=s.createBuffer(),R=_.__size,M=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,w),s.bufferData(s.UNIFORM_BUFFER,R,M),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,E,w),w}function u(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return ke("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(_){const E=i[_.id],w=_.uniforms,R=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,E);for(let M=0,A=w.length;M<A;M++){const I=w[M];if(Array.isArray(I))for(let D=0,P=I.length;D<P;D++)f(I[D],M,D,R);else f(I,M,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(_,E,w,R){if(v(_,E,w,R)===!0){const M=_.__offset,A=_.value;if(Array.isArray(A)){let I=0;for(let D=0;D<A.length;D++){const P=A[D],F=g(P);p(P,_.__data,I),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(I+=F.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,_.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,M,_.__data)}}function p(_,E,w){typeof _=="number"||typeof _=="boolean"?E[0]=_:_.isMatrix3?(E[0]=_.elements[0],E[1]=_.elements[1],E[2]=_.elements[2],E[3]=0,E[4]=_.elements[3],E[5]=_.elements[4],E[6]=_.elements[5],E[7]=0,E[8]=_.elements[6],E[9]=_.elements[7],E[10]=_.elements[8],E[11]=0):ArrayBuffer.isView(_)?E.set(new _.constructor(_.buffer,_.byteOffset,E.length)):_.toArray(E,w)}function v(_,E,w,R){const M=_.value,A=E+"_"+w;if(R[A]===void 0)return typeof M=="number"||typeof M=="boolean"?R[A]=M:ArrayBuffer.isView(M)?R[A]=M.slice():R[A]=M.clone(),!0;{const I=R[A];if(typeof M=="number"||typeof M=="boolean"){if(I!==M)return R[A]=M,!0}else{if(ArrayBuffer.isView(M))return!0;if(I.equals(M)===!1)return I.copy(M),!0}}return!1}function m(_){const E=_.uniforms;let w=0;const R=16;for(let A=0,I=E.length;A<I;A++){const D=Array.isArray(E[A])?E[A]:[E[A]];for(let P=0,F=D.length;P<F;P++){const H=D[P],O=Array.isArray(H.value)?H.value:[H.value];for(let V=0,z=O.length;V<z;V++){const Y=O[V],ee=g(Y),J=w%R,ne=J%ee.boundary,ae=J+ne;w+=ne,ae!==0&&R-ae<ee.storage&&(w+=R-ae),H.__data=new Float32Array(ee.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=w,w+=ee.storage}}}const M=w%R;return M>0&&(w+=R-M),_.__size=w,_.__cache={},this}function g(_){const E={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(E.boundary=4,E.storage=4):_.isVector2?(E.boundary=8,E.storage=8):_.isVector3||_.isColor?(E.boundary=16,E.storage=12):_.isVector4?(E.boundary=16,E.storage=16):_.isMatrix3?(E.boundary=48,E.storage=48):_.isMatrix4?(E.boundary=64,E.storage=64):_.isTexture?we("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(E.boundary=16,E.storage=_.byteLength):we("WebGLRenderer: Unsupported uniform value type.",_),E}function S(_){const E=_.target;E.removeEventListener("dispose",S);const w=a.indexOf(E.__bindingPointIndex);a.splice(w,1),s.deleteBuffer(i[E.id]),delete i[E.id],delete r[E.id]}function b(){for(const _ in i)s.deleteBuffer(i[_]);a=[],i={},r={}}return{bind:c,update:l,dispose:b}}const Uy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Mi=null;function Fy(){return Mi===null&&(Mi=new js(Uy,16,16,Ys,cn),Mi.name="DFG_LUT",Mi.minFilter=dt,Mi.magFilter=dt,Mi.wrapS=An,Mi.wrapT=An,Mi.generateMipmaps=!1,Mi.needsUpdate=!0),Mi}class ky{constructor(e={}){const{canvas:t=d2(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Hn}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const v=f,m=new Set([ju,Ju,Zu]),g=new Set([Hn,li,Xa,qa,Ku,$u]),S=new Uint32Array(4),b=new Int32Array(4),_=new C;let E=null,w=null;const R=[],M=[];let A=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ii,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let D=!1,P=null,F=null,H=null,O=null;this._outputColorSpace=Ln;let V=0,z=0,Y=null,ee=-1,J=null;const ne=new nt,ae=new nt;let Ve=null;const je=new oe(0);let He=0,K=t.width,re=t.height,ie=1,B=null,Ee=null;const Pe=new nt(0,0,K,re),Re=new nt(0,0,K,re);let xe=!1;const Ne=new rd;let Oe=!1,Ue=!1;const at=new Ye,ot=new C,Lt=new nt,Et={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Nt=!1;function Wt(){return Y===null?ie:1}let N=n;function Rn(y,U){return t.getContext(y,U)}try{const y={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Xu}`),t.addEventListener("webglcontextlost",Ot,!1),t.addEventListener("webglcontextrestored",vt,!1),t.addEventListener("webglcontextcreationerror",fi,!1),N===null){const U="webgl2";if(N=Rn(U,y),N===null)throw Rn(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw ke("WebGLRenderer: "+y.message),y}let ct,T,x,k,X,$,se,le,Z,Q,he,De,fe,ue,Le,Fe,Xe,L,ce,j,de,ve,te;function Te(){ct=new F3(N),ct.init(),de=new Ry(N,ct),T=new D3(N,ct,e,de),x=new Ay(N,ct),T.reversedDepthBuffer&&d&&x.buffers.depth.setReversed(!0),F=N.createFramebuffer(),H=N.createFramebuffer(),O=N.createFramebuffer(),k=new B3(N),X=new dy,$=new Ty(N,ct,x,X,T,de,k),se=new U3(I),le=new Wv(N),ve=new T3(N,le),Z=new k3(N,le,k,ve),Q=new G3(N,Z,le,ve,k),L=new H3(N,T,$),Le=new C3(X),he=new uy(I,se,ct,T,ve,Le),De=new Ny(I,X),fe=new py,ue=new _y(ct),Xe=new A3(I,se,x,Q,p,c),Fe=new wy(I,Q,T),te=new Oy(N,k,T,x),ce=new R3(N,ct,k),j=new z3(N,ct,k),k.programs=he.programs,I.capabilities=T,I.extensions=ct,I.properties=X,I.renderLists=fe,I.shadowMap=Fe,I.state=x,I.info=k}Te(),v!==Hn&&(A=new W3(v,t.width,t.height,o,i,r));const ye=new Py(I,N);this.xr=ye,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=ct.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=ct.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return ie},this.setPixelRatio=function(y){y!==void 0&&(ie=y,this.setSize(K,re,!1))},this.getSize=function(y){return y.set(K,re)},this.setSize=function(y,U,q=!0){if(ye.isPresenting){we("WebGLRenderer: Can't change size while VR device is presenting.");return}K=y,re=U,t.width=Math.floor(y*ie),t.height=Math.floor(U*ie),q===!0&&(t.style.width=y+"px",t.style.height=U+"px"),A!==null&&A.setSize(t.width,t.height),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(K*ie,re*ie).floor()},this.setDrawingBufferSize=function(y,U,q){K=y,re=U,ie=q,t.width=Math.floor(y*q),t.height=Math.floor(U*q),this.setViewport(0,0,y,U)},this.setEffects=function(y){if(v===Hn){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let U=0;U<y.length;U++)if(y[U].isOutputPass===!0){we("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(ne)},this.getViewport=function(y){return y.copy(Pe)},this.setViewport=function(y,U,q,G){y.isVector4?Pe.set(y.x,y.y,y.z,y.w):Pe.set(y,U,q,G),x.viewport(ne.copy(Pe).multiplyScalar(ie).round())},this.getScissor=function(y){return y.copy(Re)},this.setScissor=function(y,U,q,G){y.isVector4?Re.set(y.x,y.y,y.z,y.w):Re.set(y,U,q,G),x.scissor(ae.copy(Re).multiplyScalar(ie).round())},this.getScissorTest=function(){return xe},this.setScissorTest=function(y){x.setScissorTest(xe=y)},this.setOpaqueSort=function(y){B=y},this.setTransparentSort=function(y){Ee=y},this.getClearColor=function(y){return y.copy(Xe.getClearColor())},this.setClearColor=function(){Xe.setClearColor(...arguments)},this.getClearAlpha=function(){return Xe.getClearAlpha()},this.setClearAlpha=function(){Xe.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,q=!0){let G=0;if(y){let W=!1;if(Y!==null){const ge=Y.texture.format;W=m.has(ge)}if(W){const ge=Y.texture.type,_e=g.has(ge),me=Xe.getClearColor(),be=Xe.getClearAlpha(),Ce=me.r,qe=me.g,$e=me.b;_e?(S[0]=Ce,S[1]=qe,S[2]=$e,S[3]=be,N.clearBufferuiv(N.COLOR,0,S)):(b[0]=Ce,b[1]=qe,b[2]=$e,b[3]=be,N.clearBufferiv(N.COLOR,0,b))}else G|=N.COLOR_BUFFER_BIT}U&&(G|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(G|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&N.clear(G)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),P=y},this.dispose=function(){t.removeEventListener("webglcontextlost",Ot,!1),t.removeEventListener("webglcontextrestored",vt,!1),t.removeEventListener("webglcontextcreationerror",fi,!1),Xe.dispose(),fe.dispose(),ue.dispose(),X.dispose(),se.dispose(),Q.dispose(),ve.dispose(),te.dispose(),he.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",Td),ye.removeEventListener("sessionend",Rd),As.stop()};function Ot(y){y.preventDefault(),Ac("WebGLRenderer: Context Lost."),D=!0}function vt(){Ac("WebGLRenderer: Context Restored."),D=!1;const y=k.autoReset,U=Fe.enabled,q=Fe.autoUpdate,G=Fe.needsUpdate,W=Fe.type;Te(),k.autoReset=y,Fe.enabled=U,Fe.autoUpdate=q,Fe.needsUpdate=G,Fe.type=W}function fi(y){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function pi(y){const U=y.target;U.removeEventListener("dispose",pi),_g(U)}function _g(y){yg(y),X.remove(y)}function yg(y){const U=X.get(y).programs;U!==void 0&&(U.forEach(function(q){he.releaseProgram(q)}),y.isShaderMaterial&&he.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,q,G,W,ge){U===null&&(U=Et);const _e=W.isMesh&&W.matrixWorld.determinantAffine()<0,me=Eg(y,U,q,G,W);x.setMaterial(G,_e);let be=q.index,Ce=1;if(G.wireframe===!0){if(be=Z.getWireframeAttribute(q),be===void 0)return;Ce=2}const qe=q.drawRange,$e=q.attributes.position;let Ie=qe.start*Ce,ft=(qe.start+qe.count)*Ce;ge!==null&&(Ie=Math.max(Ie,ge.start*Ce),ft=Math.min(ft,(ge.start+ge.count)*Ce)),be!==null?(Ie=Math.max(Ie,0),ft=Math.min(ft,be.count)):$e!=null&&(Ie=Math.max(Ie,0),ft=Math.min(ft,$e.count));const zt=ft-Ie;if(zt<0||zt===1/0)return;ve.setup(W,G,me,q,be);let Ut,mt=ce;if(be!==null&&(Ut=le.get(be),mt=j,mt.setIndex(Ut)),W.isMesh)G.wireframe===!0?(x.setLineWidth(G.wireframeLinewidth*Wt()),mt.setMode(N.LINES)):mt.setMode(N.TRIANGLES);else if(W.isLine){let mn=G.linewidth;mn===void 0&&(mn=1),x.setLineWidth(mn*Wt()),W.isLineSegments?mt.setMode(N.LINES):W.isLineLoop?mt.setMode(N.LINE_LOOP):mt.setMode(N.LINE_STRIP)}else W.isPoints?mt.setMode(N.POINTS):W.isSprite&&mt.setMode(N.TRIANGLES);if(W.isBatchedMesh)if(ct.get("WEBGL_multi_draw"))mt.renderMultiDraw(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount);else{const mn=W._multiDrawStarts,Me=W._multiDrawCounts,On=W._multiDrawCount,tt=be?le.get(be).bytesPerElement:1,Vn=X.get(G).currentProgram.getUniforms();for(let mi=0;mi<On;mi++)Vn.setValue(N,"_gl_DrawID",mi),mt.render(mn[mi]/tt,Me[mi])}else if(W.isInstancedMesh)mt.renderInstances(Ie,zt,W.count);else if(q.isInstancedBufferGeometry){const mn=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Me=Math.min(q.instanceCount,mn);mt.renderInstances(Ie,zt,Me)}else mt.render(Ie,zt)};function Ad(y,U,q){y.transparent===!0&&y.side===ai&&y.forceSinglePass===!1?(y.side=Ct,y.needsUpdate=!0,so(y,U,q),y.side=Ss,y.needsUpdate=!0,so(y,U,q),y.side=ai):so(y,U,q)}this.compile=function(y,U,q=null){q===null&&(q=y),w=ue.get(q),w.init(U),M.push(w),q.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),y!==q&&y.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),w.setupLights();const G=new Set;return y.traverse(function(W){if(!(W.isMesh||W.isPoints||W.isLine||W.isSprite))return;const ge=W.material;if(ge)if(Array.isArray(ge))for(let _e=0;_e<ge.length;_e++){const me=ge[_e];Ad(me,q,W),G.add(me)}else Ad(ge,q,W),G.add(ge)}),w=M.pop(),G},this.compileAsync=function(y,U,q=null){const G=this.compile(y,U,q);return new Promise(W=>{function ge(){if(G.forEach(function(_e){X.get(_e).currentProgram.isReady()&&G.delete(_e)}),G.size===0){W(y);return}setTimeout(ge,10)}ct.get("KHR_parallel_shader_compile")!==null?ge():setTimeout(ge,10)})};let Qc=null;function Sg(y){Qc&&Qc(y)}function Td(){As.stop()}function Rd(){As.start()}const As=new Dm;As.setAnimationLoop(Sg),typeof self<"u"&&As.setContext(self),this.setAnimationLoop=function(y){Qc=y,ye.setAnimationLoop(y),y===null?As.stop():As.start()},ye.addEventListener("sessionstart",Td),ye.addEventListener("sessionend",Rd),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;P!==null&&P.renderStart(y,U);const q=ye.enabled===!0&&ye.isPresenting===!0,G=A!==null&&(Y===null||q)&&A.begin(I,Y);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(U),U=ye.getCamera()),y.isScene===!0&&y.onBeforeRender(I,y,U,Y),w=ue.get(y,M.length),w.init(U),w.state.textureUnits=$.getTextureUnits(),M.push(w),at.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ne.setFromProjectionMatrix(at,Ri,U.reversedDepth),Ue=this.localClippingEnabled,Oe=Le.init(this.clippingPlanes,Ue),E=fe.get(y,R.length),E.init(),R.push(E),ye.enabled===!0&&ye.isPresenting===!0){const _e=I.xr.getDepthSensingMesh();_e!==null&&el(_e,U,-1/0,I.sortObjects)}el(y,U,0,I.sortObjects),E.finish(),I.sortObjects===!0&&E.sort(B,Ee,U.reversedDepth),Nt=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,Nt&&Xe.addToRenderList(E,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&Le.beginShadows();const W=w.state.shadowsArray;if(Fe.render(W,y,U),Oe===!0&&Le.endShadows(),(G&&A.hasRenderPass())===!1){const _e=E.opaque,me=E.transmissive;if(w.setupLights(),U.isArrayCamera){const be=U.cameras;if(me.length>0)for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Cd(_e,me,y,$e)}Nt&&Xe.render(y);for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce];Dd(E,y,$e,$e.viewport)}}else me.length>0&&Cd(_e,me,y,U),Nt&&Xe.render(y),Dd(E,y,U)}Y!==null&&z===0&&($.updateMultisampleRenderTarget(Y),$.updateRenderTargetMipmap(Y)),G&&A.end(I),y.isScene===!0&&y.onAfterRender(I,y,U),ve.resetDefaultState(),ee=-1,J=null,M.pop(),M.length>0?(w=M[M.length-1],$.setTextureUnits(w.state.textureUnits),Oe===!0&&Le.setGlobalState(I.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?E=R[R.length-1]:E=null,P!==null&&P.renderEnd()};function el(y,U,q,G){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)q=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Ne.intersectsSprite(y)){G&&Lt.setFromMatrixPosition(y.matrixWorld).applyMatrix4(at);const _e=Q.update(y),me=y.material;me.visible&&E.push(y,_e,me,q,Lt.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Ne.intersectsObject(y))){const _e=Q.update(y),me=y.material;if(G&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Lt.copy(y.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),Lt.copy(_e.boundingSphere.center)),Lt.applyMatrix4(y.matrixWorld).applyMatrix4(at)),Array.isArray(me)){const be=_e.groups;for(let Ce=0,qe=be.length;Ce<qe;Ce++){const $e=be[Ce],Ie=me[$e.materialIndex];Ie&&Ie.visible&&E.push(y,_e,Ie,q,Lt.z,$e)}}else me.visible&&E.push(y,_e,me,q,Lt.z,null)}}const ge=y.children;for(let _e=0,me=ge.length;_e<me;_e++)el(ge[_e],U,q,G)}function Dd(y,U,q,G){const{opaque:W,transmissive:ge,transparent:_e}=y;w.setupLightsView(q),Oe===!0&&Le.setGlobalState(I.clippingPlanes,q),G&&x.viewport(ne.copy(G)),W.length>0&&io(W,U,q),ge.length>0&&io(ge,U,q),_e.length>0&&io(_e,U,q),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function Cd(y,U,q,G){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[G.id]===void 0){const Ie=ct.has("EXT_color_buffer_half_float")||ct.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[G.id]=new dn(1,1,{generateMipmaps:!0,type:Ie?cn:Hn,minFilter:Bs,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:et.workingColorSpace})}const ge=w.state.transmissionRenderTarget[G.id],_e=G.viewport||ne;ge.setSize(_e.z*I.transmissionResolutionScale,_e.w*I.transmissionResolutionScale);const me=I.getRenderTarget(),be=I.getActiveCubeFace(),Ce=I.getActiveMipmapLevel();I.setRenderTarget(ge),I.getClearColor(je),He=I.getClearAlpha(),He<1&&I.setClearColor(16777215,.5),I.clear(),Nt&&Xe.render(q);const qe=I.toneMapping;I.toneMapping=Ii;const $e=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),w.setupLightsView(G),Oe===!0&&Le.setGlobalState(I.clippingPlanes,G),io(y,q,G),$.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge),ct.has("WEBGL_multisampled_render_to_texture")===!1){let Ie=!1;for(let ft=0,zt=U.length;ft<zt;ft++){const Ut=U[ft],{object:mt,geometry:mn,material:Me,group:On}=Ut;if(Me.side===ai&&mt.layers.test(G.layers)){const tt=Me.side;Me.side=Ct,Me.needsUpdate=!0,Id(mt,q,G,mn,Me,On),Me.side=tt,Me.needsUpdate=!0,Ie=!0}}Ie===!0&&($.updateMultisampleRenderTarget(ge),$.updateRenderTargetMipmap(ge))}I.setRenderTarget(me,be,Ce),I.setClearColor(je,He),$e!==void 0&&(G.viewport=$e),I.toneMapping=qe}function io(y,U,q){const G=U.isScene===!0?U.overrideMaterial:null;for(let W=0,ge=y.length;W<ge;W++){const _e=y[W],{object:me,geometry:be,group:Ce}=_e;let qe=_e.material;qe.allowOverride===!0&&G!==null&&(qe=G),me.layers.test(q.layers)&&Id(me,U,q,be,qe,Ce)}}function Id(y,U,q,G,W,ge){y.onBeforeRender(I,U,q,G,W,ge),y.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),W.onBeforeRender(I,U,q,G,y,ge),W.transparent===!0&&W.side===ai&&W.forceSinglePass===!1?(W.side=Ct,W.needsUpdate=!0,I.renderBufferDirect(q,U,G,W,y,ge),W.side=Ss,W.needsUpdate=!0,I.renderBufferDirect(q,U,G,W,y,ge),W.side=ai):I.renderBufferDirect(q,U,G,W,y,ge),y.onAfterRender(I,U,q,G,W,ge)}function so(y,U,q){U.isScene!==!0&&(U=Et);const G=X.get(y),W=w.state.lights,ge=w.state.shadowsArray,_e=W.state.version,me=he.getParameters(y,W.state,ge,U,q,w.state.lightProbeGridArray),be=he.getProgramCacheKey(me);let Ce=G.programs;G.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?U.environment:null,G.fog=U.fog;const qe=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;G.envMap=se.get(y.envMap||G.environment,qe),G.envMapRotation=G.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Ce===void 0&&(y.addEventListener("dispose",pi),Ce=new Map,G.programs=Ce);let $e=Ce.get(be);if($e!==void 0){if(G.currentProgram===$e&&G.lightsStateVersion===_e)return Ld(y,me),$e}else me.uniforms=he.getUniforms(y),P!==null&&y.isNodeMaterial&&P.build(y,q,me),y.onBeforeCompile(me,I),$e=he.acquireProgram(me,be),Ce.set(be,$e),G.uniforms=me.uniforms;const Ie=G.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ie.clippingPlanes=Le.uniform),Ld(y,me),G.needsLights=Ag(y),G.lightsStateVersion=_e,G.needsLights&&(Ie.ambientLightColor.value=W.state.ambient,Ie.lightProbe.value=W.state.probe,Ie.directionalLights.value=W.state.directional,Ie.directionalLightShadows.value=W.state.directionalShadow,Ie.spotLights.value=W.state.spot,Ie.spotLightShadows.value=W.state.spotShadow,Ie.rectAreaLights.value=W.state.rectArea,Ie.ltc_1.value=W.state.rectAreaLTC1,Ie.ltc_2.value=W.state.rectAreaLTC2,Ie.pointLights.value=W.state.point,Ie.pointLightShadows.value=W.state.pointShadow,Ie.hemisphereLights.value=W.state.hemi,Ie.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Ie.spotLightMatrix.value=W.state.spotLightMatrix,Ie.spotLightMap.value=W.state.spotLightMap,Ie.pointShadowMatrix.value=W.state.pointShadowMatrix),G.lightProbeGrid=w.state.lightProbeGridArray.length>0,G.currentProgram=$e,G.uniformsList=null,$e}function Pd(y){if(y.uniformsList===null){const U=y.currentProgram.getUniforms();y.uniformsList=dc.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function Ld(y,U){const q=X.get(y);q.outputColorSpace=U.outputColorSpace,q.batching=U.batching,q.batchingColor=U.batchingColor,q.instancing=U.instancing,q.instancingColor=U.instancingColor,q.instancingMorph=U.instancingMorph,q.skinning=U.skinning,q.morphTargets=U.morphTargets,q.morphNormals=U.morphNormals,q.morphColors=U.morphColors,q.morphTargetsCount=U.morphTargetsCount,q.numClippingPlanes=U.numClippingPlanes,q.numIntersection=U.numClipIntersection,q.vertexAlphas=U.vertexAlphas,q.vertexTangents=U.vertexTangents,q.toneMapping=U.toneMapping}function bg(y,U){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;_.setFromMatrixPosition(U.matrixWorld);for(let q=0,G=y.length;q<G;q++){const W=y[q];if(W.texture!==null&&W.boundingBox.containsPoint(_))return W}return null}function Eg(y,U,q,G,W){U.isScene!==!0&&(U=Et),$.resetTextureUnits();const ge=U.fog,_e=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?U.environment:null,me=Y===null?I.outputColorSpace:Y.isXRRenderTarget===!0?Y.texture.colorSpace:et.workingColorSpace,be=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Ce=se.get(G.envMap||_e,be),qe=G.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,$e=!!q.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ie=!!q.morphAttributes.position,ft=!!q.morphAttributes.normal,zt=!!q.morphAttributes.color;let Ut=Ii;G.toneMapped&&(Y===null||Y.isXRRenderTarget===!0)&&(Ut=I.toneMapping);const mt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,mn=mt!==void 0?mt.length:0,Me=X.get(G),On=w.state.lights;if(Oe===!0&&(Ue===!0||y!==J)){const Mt=y===J&&G.id===ee;Le.setState(G,y,Mt)}let tt=!1;G.version===Me.__version?(Me.needsLights&&Me.lightsStateVersion!==On.state.version||Me.outputColorSpace!==me||W.isBatchedMesh&&Me.batching===!1||!W.isBatchedMesh&&Me.batching===!0||W.isBatchedMesh&&Me.batchingColor===!0&&W.colorTexture===null||W.isBatchedMesh&&Me.batchingColor===!1&&W.colorTexture!==null||W.isInstancedMesh&&Me.instancing===!1||!W.isInstancedMesh&&Me.instancing===!0||W.isSkinnedMesh&&Me.skinning===!1||!W.isSkinnedMesh&&Me.skinning===!0||W.isInstancedMesh&&Me.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&Me.instancingColor===!1&&W.instanceColor!==null||W.isInstancedMesh&&Me.instancingMorph===!0&&W.morphTexture===null||W.isInstancedMesh&&Me.instancingMorph===!1&&W.morphTexture!==null||Me.envMap!==Ce||G.fog===!0&&Me.fog!==ge||Me.numClippingPlanes!==void 0&&(Me.numClippingPlanes!==Le.numPlanes||Me.numIntersection!==Le.numIntersection)||Me.vertexAlphas!==qe||Me.vertexTangents!==$e||Me.morphTargets!==Ie||Me.morphNormals!==ft||Me.morphColors!==zt||Me.toneMapping!==Ut||Me.morphTargetsCount!==mn||!!Me.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(tt=!0):(tt=!0,Me.__version=G.version);let Vn=Me.currentProgram;tt===!0&&(Vn=so(G,U,W),P&&G.isNodeMaterial&&P.onUpdateProgram(G,Vn,Me));let mi=!1,ts=!1,Qs=!1;const gt=Vn.getUniforms(),Bt=Me.uniforms;if(x.useProgram(Vn.program)&&(mi=!0,ts=!0,Qs=!0),G.id!==ee&&(ee=G.id,ts=!0),Me.needsLights){const Mt=bg(w.state.lightProbeGridArray,W);Me.lightProbeGrid!==Mt&&(Me.lightProbeGrid=Mt,ts=!0)}if(mi||J!==y){x.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),gt.setValue(N,"projectionMatrix",y.projectionMatrix),gt.setValue(N,"viewMatrix",y.matrixWorldInverse);const is=gt.map.cameraPosition;is!==void 0&&is.setValue(N,ot.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&gt.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&gt.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),J!==y&&(J=y,ts=!0,Qs=!0)}if(Me.needsLights&&(On.state.directionalShadowMap.length>0&&gt.setValue(N,"directionalShadowMap",On.state.directionalShadowMap,$),On.state.spotShadowMap.length>0&&gt.setValue(N,"spotShadowMap",On.state.spotShadowMap,$),On.state.pointShadowMap.length>0&&gt.setValue(N,"pointShadowMap",On.state.pointShadowMap,$)),W.isSkinnedMesh){gt.setOptional(N,W,"bindMatrix"),gt.setOptional(N,W,"bindMatrixInverse");const Mt=W.skeleton;Mt&&(Mt.boneTexture===null&&Mt.computeBoneTexture(),gt.setValue(N,"boneTexture",Mt.boneTexture,$))}W.isBatchedMesh&&(gt.setOptional(N,W,"batchingTexture"),gt.setValue(N,"batchingTexture",W._matricesTexture,$),gt.setOptional(N,W,"batchingIdTexture"),gt.setValue(N,"batchingIdTexture",W._indirectTexture,$),gt.setOptional(N,W,"batchingColorTexture"),W._colorsTexture!==null&&gt.setValue(N,"batchingColorTexture",W._colorsTexture,$));const ns=q.morphAttributes;if((ns.position!==void 0||ns.normal!==void 0||ns.color!==void 0)&&L.update(W,q,Vn),(ts||Me.receiveShadow!==W.receiveShadow)&&(Me.receiveShadow=W.receiveShadow,gt.setValue(N,"receiveShadow",W.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&U.environment!==null&&(Bt.envMapIntensity.value=U.environmentIntensity),Bt.dfgLUT!==void 0&&(Bt.dfgLUT.value=Fy()),ts){if(gt.setValue(N,"toneMappingExposure",I.toneMappingExposure),Me.needsLights&&wg(Bt,Qs),ge&&G.fog===!0&&De.refreshFogUniforms(Bt,ge),De.refreshMaterialUniforms(Bt,G,ie,re,w.state.transmissionRenderTarget[y.id]),Me.needsLights&&Me.lightProbeGrid){const Mt=Me.lightProbeGrid;Bt.probesSH.value=Mt.texture,Bt.probesMin.value.copy(Mt.boundingBox.min),Bt.probesMax.value.copy(Mt.boundingBox.max),Bt.probesResolution.value.copy(Mt.resolution)}dc.upload(N,Pd(Me),Bt,$)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(dc.upload(N,Pd(Me),Bt,$),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&gt.setValue(N,"center",W.center),gt.setValue(N,"modelViewMatrix",W.modelViewMatrix),gt.setValue(N,"normalMatrix",W.normalMatrix),gt.setValue(N,"modelMatrix",W.matrixWorld),G.uniformsGroups!==void 0){const Mt=G.uniformsGroups;for(let is=0,er=Mt.length;is<er;is++){const Nd=Mt[is];te.update(Nd,Vn),te.bind(Nd,Vn)}}return Vn}function wg(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function Ag(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return Y},this.setRenderTargetTextures=function(y,U,q){const G=X.get(y);G.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),X.get(y.texture).__webglTexture=U,X.get(y.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:q,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){const q=X.get(y);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(y,U=0,q=0){Y=y,V=U,z=q;let G=null,W=!1,ge=!1;if(y){const me=X.get(y);if(me.__useDefaultFramebuffer!==void 0){x.bindFramebuffer(N.FRAMEBUFFER,me.__webglFramebuffer),ne.copy(y.viewport),ae.copy(y.scissor),Ve=y.scissorTest,x.viewport(ne),x.scissor(ae),x.setScissorTest(Ve),ee=-1;return}else if(me.__webglFramebuffer===void 0)$.setupRenderTarget(y);else if(me.__hasExternalTextures)$.rebindTextures(y,X.get(y.texture).__webglTexture,X.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const qe=y.depthTexture;if(me.__boundDepthTexture!==qe){if(qe!==null&&X.has(qe)&&(y.width!==qe.image.width||y.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(y)}}const be=y.texture;(be.isData3DTexture||be.isDataArrayTexture||be.isCompressedArrayTexture)&&(ge=!0);const Ce=X.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Ce[U])?G=Ce[U][q]:G=Ce[U],W=!0):y.samples>0&&$.useMultisampledRTT(y)===!1?G=X.get(y).__webglMultisampledFramebuffer:Array.isArray(Ce)?G=Ce[q]:G=Ce,ne.copy(y.viewport),ae.copy(y.scissor),Ve=y.scissorTest}else ne.copy(Pe).multiplyScalar(ie).floor(),ae.copy(Re).multiplyScalar(ie).floor(),Ve=xe;if(q!==0&&(G=F),x.bindFramebuffer(N.FRAMEBUFFER,G)&&x.drawBuffers(y,G),x.viewport(ne),x.scissor(ae),x.setScissorTest(Ve),W){const me=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,me.__webglTexture,q)}else if(ge){const me=U;for(let be=0;be<y.textures.length;be++){const Ce=X.get(y.textures[be]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+be,Ce.__webglTexture,q,me)}}else if(y!==null&&q!==0){const me=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,me.__webglTexture,q)}ee=-1},this.readRenderTargetPixels=function(y,U,q,G,W,ge,_e,me=0){if(!(y&&y.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let be=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be){x.bindFramebuffer(N.FRAMEBUFFER,be);try{const Ce=y.textures[me],qe=Ce.format,$e=Ce.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable($e)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W&&N.readPixels(U,q,G,W,de.convert(qe),de.convert($e),ge)}finally{const Ce=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,Ce)}}},this.readRenderTargetPixelsAsync=async function(y,U,q,G,W,ge,_e,me=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let be=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(be=be[_e]),be)if(U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W){x.bindFramebuffer(N.FRAMEBUFFER,be);const Ce=y.textures[me],qe=Ce.format,$e=Ce.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+me),!T.textureFormatReadable(qe))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ie=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ie),N.bufferData(N.PIXEL_PACK_BUFFER,ge.byteLength,N.STREAM_READ),N.readPixels(U,q,G,W,de.convert(qe),de.convert($e),0);const ft=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,ft);const zt=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await f2(N,zt,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ie),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,ge),N.deleteBuffer(Ie),N.deleteSync(zt),ge}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,q=0){const G=Math.pow(2,-q),W=Math.floor(y.image.width*G),ge=Math.floor(y.image.height*G),_e=U!==null?U.x:0,me=U!==null?U.y:0;$.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,q,0,0,_e,me,W,ge),x.unbindTexture()},this.copyTextureToTexture=function(y,U,q=null,G=null,W=0,ge=0){let _e,me,be,Ce,qe,$e,Ie,ft,zt;const Ut=y.isCompressedTexture?y.mipmaps[ge]:y.image;if(q!==null)_e=q.max.x-q.min.x,me=q.max.y-q.min.y,be=q.isBox3?q.max.z-q.min.z:1,Ce=q.min.x,qe=q.min.y,$e=q.isBox3?q.min.z:0;else{const Bt=Math.pow(2,-W);_e=Math.floor(Ut.width*Bt),me=Math.floor(Ut.height*Bt),y.isDataArrayTexture?be=Ut.depth:y.isData3DTexture?be=Math.floor(Ut.depth*Bt):be=1,Ce=0,qe=0,$e=0}G!==null?(Ie=G.x,ft=G.y,zt=G.z):(Ie=0,ft=0,zt=0);const mt=de.convert(U.format),mn=de.convert(U.type);let Me;U.isData3DTexture?($.setTexture3D(U,0),Me=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),Me=N.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),Me=N.TEXTURE_2D),x.activeTexture(N.TEXTURE0),x.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),x.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),x.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);const On=x.getParameter(N.UNPACK_ROW_LENGTH),tt=x.getParameter(N.UNPACK_IMAGE_HEIGHT),Vn=x.getParameter(N.UNPACK_SKIP_PIXELS),mi=x.getParameter(N.UNPACK_SKIP_ROWS),ts=x.getParameter(N.UNPACK_SKIP_IMAGES);x.pixelStorei(N.UNPACK_ROW_LENGTH,Ut.width),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Ut.height),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Ce),x.pixelStorei(N.UNPACK_SKIP_ROWS,qe),x.pixelStorei(N.UNPACK_SKIP_IMAGES,$e);const Qs=y.isDataArrayTexture||y.isData3DTexture,gt=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){const Bt=X.get(y),ns=X.get(U),Mt=X.get(Bt.__renderTarget),is=X.get(ns.__renderTarget);x.bindFramebuffer(N.READ_FRAMEBUFFER,Mt.__webglFramebuffer),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,is.__webglFramebuffer);for(let er=0;er<be;er++)Qs&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(y).__webglTexture,W,$e+er),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(U).__webglTexture,ge,zt+er)),N.blitFramebuffer(Ce,qe,_e,me,Ie,ft,_e,me,N.DEPTH_BUFFER_BIT,N.NEAREST);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(W!==0||y.isRenderTargetTexture||X.has(y)){const Bt=X.get(y),ns=X.get(U);x.bindFramebuffer(N.READ_FRAMEBUFFER,H),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let Mt=0;Mt<be;Mt++)Qs?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Bt.__webglTexture,W,$e+Mt):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Bt.__webglTexture,W),gt?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,ns.__webglTexture,ge,zt+Mt):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,ns.__webglTexture,ge),W!==0?N.blitFramebuffer(Ce,qe,_e,me,Ie,ft,_e,me,N.COLOR_BUFFER_BIT,N.NEAREST):gt?N.copyTexSubImage3D(Me,ge,Ie,ft,zt+Mt,Ce,qe,_e,me):N.copyTexSubImage2D(Me,ge,Ie,ft,Ce,qe,_e,me);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else gt?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(Me,ge,Ie,ft,zt,_e,me,be,mt,mn,Ut.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(Me,ge,Ie,ft,zt,_e,me,be,mt,Ut.data):N.texSubImage3D(Me,ge,Ie,ft,zt,_e,me,be,mt,mn,Ut):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,ge,Ie,ft,_e,me,mt,mn,Ut.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,ge,Ie,ft,Ut.width,Ut.height,mt,Ut.data):N.texSubImage2D(N.TEXTURE_2D,ge,Ie,ft,_e,me,mt,mn,Ut);x.pixelStorei(N.UNPACK_ROW_LENGTH,On),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,tt),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Vn),x.pixelStorei(N.UNPACK_SKIP_ROWS,mi),x.pixelStorei(N.UNPACK_SKIP_IMAGES,ts),ge===0&&U.generateMipmaps&&N.generateMipmap(Me),x.unbindTexture()},this.initRenderTarget=function(y){X.get(y).__webglFramebuffer===void 0&&$.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?$.setTextureCube(y,0):y.isData3DTexture?$.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?$.setTexture2DArray(y,0):$.setTexture2D(y,0),x.unbindTexture()},this.resetState=function(){V=0,z=0,Y=null,x.reset(),ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Ri}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=et._getDrawingBufferColorSpace(e),t.unpackColorSpace=et._getUnpackColorSpace()}}const zy=`
4719
4719
  varying vec3 vDir;
4720
4720
 
4721
4721
  void main() {
@@ -5087,7 +5087,7 @@ float transmissionAt(vec3 dir, float distanceM) {
5087
5087
  if (transmission < 0.015) break;
5088
5088
  }
5089
5089
  return transmission;
5090
- }`,n=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(e+t).replace(n,i=>s+i)}class Ic{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new C(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.4,.45,.5)},hazeColor:{value:new oe(.5,.6,.7)},offsetM:{value:new C},seedOffset:{value:new C},localCenter:{value:new C},localSize:{value:new C},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:ga},()=>new C)},holeSize:{value:Array.from({length:ga},()=>new C)},holeRotation:{value:new Array(ga).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const n=new Rt({uniforms:this.uniforms,vertexShader:qy,fragmentShader:mu,transparent:!0,depthWrite:!1,depthTest:!0,side:Ct});this.mesh=new We(new fn(t,32,16),n),this.mesh.frustumCulled=!1}update(e,t,n,i=[]){const r=this.uniforms;r.localSize.value.set(n?.widthM??0,n?.thicknessM??0,n?.depthM??0),r.localCenter.value.set(n?.eastM??0,n?n.baseM+n.thicknessM/2:0,-(n?.northM??0)),r.localRotation.value=(n?.rotationDeg??0)*Math.PI/180,r.holeCount.value=Math.min(ga,i.length),i.slice(0,ga).forEach((o,c)=>{r.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),r.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),r.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),r.baseM.value=Math.max(0,e.baseM),r.thicknessM.value=Math.max(10,e.thicknessM),r.coverage.value=Math.max(0,Math.min(1,e.coverage)),r.sizeM.value=Math.max(50,e.sizeM),r.density.value=Math.max(0,Math.min(2,e.density)),r.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),r.eyeM.value=Math.max(.1,t),r.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const a=pu(e);r.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=r.density.value>0&&(n!==void 0||r.coverage.value>0)}static thresholdFor(e){const t=Math.min(.999,Math.max(.001,e));return .645-.23*(Math.sqrt(3)/Math.PI)*Math.log(t/(1-t))}densityAt(e){const t=this.uniforms,n=(F,H,O)=>{const V=Math.max(0,Math.min(1,(O-F)/(H-F)));return V*V*(3-2*V)},i=(F,H,O)=>F+(H-F)*O,r=t.eyeM.value+e.y,a=2*Ir*r+e.x**2+r**2+e.z**2,o=a/(Math.sqrt(Ir**2+a)+Ir),c=(o-t.baseM.value)/t.thicknessM.value,l=t.localSize.value.x>0;if(c<=0||c>=1||t.coverage.value<=0&&!l)return 0;const h=(F,H,O)=>{const V=e.x+t.offsetM.value.x-F.x,z=e.z+t.offsetM.value.z-F.z,Y=Math.cos(O),ee=Math.sin(O);return Math.hypot((Y*V-ee*z)/(H.x*.5),(o-F.y)/(H.y*.5),(ee*V+Y*z)/(H.z*.5))},u=l?h(t.localCenter.value,t.localSize.value,t.localRotation.value):0;if(u>1.3)return 0;const d=[e.x,e.y,e.z].map((F,H)=>(F+t.offsetM.value.getComponent(H))/(t.sizeM.value*4)+t.seedOffset.value.getComponent(H)),f=t.noiseMap.value.image.data,p=(F,H,O)=>{const V=[F,H,O].map(J=>(J%1+1)%1*Gt-.5),z=V.map(Math.floor),Y=V.map((J,ne)=>J-z[ne]);let ee=0;for(let J=0;J<2;J++)for(let ne=0;ne<2;ne++)for(let ae=0;ae<2;ae++){const Ve=(z[0]+ae+Gt)%Gt,je=(z[1]+ne+Gt)%Gt,Be=(z[2]+J+Gt)%Gt;ee+=f[Ve+Gt*(je+Gt*Be)]/255*(ae?Y[0]:1-Y[0])*(ne?Y[1]:1-Y[1])*(J?Y[2]:1-Y[2])}return ee},v=[d[0]*.173,Gl,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let S=n(.2,.8,p(d[0],Gl,d[2])*.65+p(m,Gl+.37,g)*.35);const b=n(8e3,4e4,Math.hypot(e.x,e.y,e.z)),_=i(p(d[0]*2,d[1]*3,d[2]*2),.5,b),E=i(p(d[0]*7,d[1]*7,d[2]*7),.5,b);let w=Ic.thresholdFor(t.coverage.value),R=1,M=0;if(l){const F=u+(_-.5)*.18;M=1-n(.35,1,F),R=1-n(.85,1.15,F),S=i(S,1,M),w=Math.min(w,Ic.thresholdFor(.5))}for(let F=0;F<t.holeCount.value;F++)R*=n(.85,1.15,h(t.holeCenter.value[F],t.holeSize.value[F],t.holeRotation.value[F])+(_-.5)*.18);if(R<.001)return 0;let A=n(w-.1,w+.1,S);if(A=i(A,1,n(.92,1,t.coverage.value)),A=i(A,Math.max(t.coverage.value,M),b),A<.001)return 0;const I=i(.45+.55*_,.96,t.flatness.value),D=n(0,.09,c)*(1-n(I-.22,I,c)),P=i(Math.max(0,A-(1-_)*.38-(1-E)*.1),A*.8,t.flatness.value);return D*P*t.density.value*R}transmissionAt(e,t=1/0){const n=this.uniforms,i=Xy(e.y,n.eyeM.value,n.baseM.value,n.thicknessM.value);if(!i)return 1;let[r,a]=i;if(n.localSize.value.x>0){const h=n.localCenter.value.clone().sub(n.offsetM.value);h.y-=n.eyeM.value+(h.x**2+h.z**2)/(2*Ir);const u=n.localSize.value.length()*.5+25,d=e.x*h.x+e.y*h.y+e.z*h.z,f=d*d-h.lengthSq()+u*u;if(f<0)return 1;r=Math.max(r,d-Math.sqrt(f)),a=Math.min(a,d+Math.sqrt(f))}const o=Math.min(a,t,r+18e3);if(o<=r)return 1;const c=(o-r)/48;let l=1;for(let h=0;h<48;h++){const u=r+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x:e.x*u,y:e.y*u,z:e.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class hn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=hn.build(24);static build(e){const t=[];let n=0,i=0,r=0;for(let a=0;a<e;a++){const o=hn.VIOLET_NM+(a+.5)/e*(hn.DEEP_RED_NM-hn.VIOLET_NM),[c,l,h]=hn.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};n+=u.r,i+=u.g,r+=u.b,t.push(u)}for(const a of t)a.r/=n,a.g/=i,a.b/=r;return t}static tristimulus(e,t,n){let i=0,r=0,a=0;for(let c=0;c<e.length;c++){const[l,h,u]=hn.colourMatching(e[c]);i+=l*t[c],r+=h*t[c],a+=u*t[c]}const o=683*n;return[i*o,r*o,a*o]}static scotopic(e){const t=e/1e3;return .992*Math.exp(-321.9*(t-.5)**2)}static linearSrgbOf([e,t,n]){return[3.2406*e-1.5372*t-.4986*n,-.9689*e+1.8758*t+.0415*n,.0557*e-.204*t+1.057*n]}static colourMatching(e){const t=(n,i,r)=>{const a=(e-n)/(e<n?i:r);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class Pc{static reflectance(e,t,n){const r=t/n*Math.sqrt(Math.max(0,1-e*e));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*e-t*a)/(n*e+t*a),c=(t*e-n*a)/(t*e+n*a);return(o*o+c*c)/2}}class tn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(tn.ANCHOR_BLUE-tn.ANCHOR_RED)/(1/(tn.BLUE_NM*tn.BLUE_NM)-1/(tn.RED_NM*tn.RED_NM));static A=tn.ANCHOR_RED-tn.B/(tn.RED_NM*tn.RED_NM);static indexAt(e){return tn.A+tn.B/(e*e)}}class Gr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const n=Math.min(1,Math.max(0,e)),i=Math.sqrt(Math.max(0,1-n*n)),r=n/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(n),c=Math.asin(r),l=Pc.reflectance(i,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=Gr.folded(Math.PI-2*o),t[h].weight=l,h++;const u=Pc.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Gr.MAX_CHORDS&&h<t.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=Gr.folded(p),t[h].weight=d*(1-u),h++,d*=u}return h}static folded(e){const t=2*Math.PI;let n=e%t;return n<0&&(n+=t),n>Math.PI?t-n:n}}class Ht{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Gr;previous=Ht.emergences();current=Ht.emergences();tally=new Float32Array(Ht.BINS*3);radiance=new Float32Array(Ht.BINS*3);scratch=new Float32Array(Ht.BINS*3);static emergences(){return Array.from({length:Gr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of hn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ht.BINS,data:this.radiance,binDeg:180/Ht.BINS}}sweep(e){this.drop.refractiveIndex=tn.indexAt(e.wavelengthNm);const t=Ht.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const i=1/t;for(let r=1;r<=t;r++){const a=this.drop.trace(Math.sqrt(r/t),this.current);for(let o=0;o<Math.min(a,n);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*i,e)}n=a,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let n=0;n<e.length;n++)t[n].chords=e[n].chords,t[n].scatteringAngle=e[n].scatteringAngle,t[n].weight=e[n].weight}deposit(e,t,n,i){if(n<=0)return;const r=Ht.BINS,a=Math.PI/r,o=Math.min(e,t),c=Math.max(e,t),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,n,i);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/l,i)}}add(e,t,n){const i=e*3,r=t*hn.SAMPLES.length;this.tally[i]+=r*n.r,this.tally[i+1]+=r*n.g,this.tally[i+2]+=r*n.b}toRadiance(){const e=Ht.BINS,t=Math.PI/e;for(let n=0;n<e;n++){const i=2*Math.PI*(Math.cos(n*t)-Math.cos((n+1)*t)),r=i>0?this.backwardShare((n+.5)*(180/e))/i:0,a=n*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(e){const t=180-e;if(t<=Ht.FULL_UNTIL_DEG)return 1;if(t>=Ht.FADED_BY_DEG)return 0;const n=(t-Ht.FULL_UNTIL_DEG)/(Ht.FADED_BY_DEG-Ht.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=Ht.BINS,t=Ht.SOURCE_RADIUS_DEG*e/180,n=Math.max(1,Math.ceil(t)),i=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,t*t-a*a),c=Math.sqrt(o);i.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(e-1,Math.max(0,a+u))*3,f=i[u+n];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class Gs{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ht;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ht.BINS*4),this.texture=new js(this.texels,Ht.BINS,1,_n,cn),this.texture.minFilter=dt,this.texture.magFilter=dt,this.texture.wrapS=An,this.texture.wrapT=An,this.texture.needsUpdate=!0,this.material=new Rt({uniforms:{uSource:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Gs.GAIN}},vertexShader:`
5090
+ }`,n=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(e+t).replace(n,i=>s+i)}class Ic{mesh;uniforms;constructor(e,t){this.uniforms={noiseMap:{value:e},sunDir:{value:new C(0,1,0)},sunColor:{value:new oe(1,1,1)},ambientColor:{value:new oe(.4,.45,.5)},hazeColor:{value:new oe(.5,.6,.7)},offsetM:{value:new C},seedOffset:{value:new C},localCenter:{value:new C},localSize:{value:new C},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:ga},()=>new C)},holeSize:{value:Array.from({length:ga},()=>new C)},holeRotation:{value:new Array(ga).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const n=new Rt({uniforms:this.uniforms,vertexShader:qy,fragmentShader:mu,transparent:!0,depthWrite:!1,depthTest:!0,side:Ct});this.mesh=new We(new fn(t,32,16),n),this.mesh.frustumCulled=!1}update(e,t,n,i=[]){const r=this.uniforms;r.localSize.value.set(n?.widthM??0,n?.thicknessM??0,n?.depthM??0),r.localCenter.value.set(n?.eastM??0,n?n.baseM+n.thicknessM/2:0,-(n?.northM??0)),r.localRotation.value=(n?.rotationDeg??0)*Math.PI/180,r.holeCount.value=Math.min(ga,i.length),i.slice(0,ga).forEach((o,c)=>{r.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),r.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),r.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),r.baseM.value=Math.max(0,e.baseM),r.thicknessM.value=Math.max(10,e.thicknessM),r.coverage.value=Math.max(0,Math.min(1,e.coverage)),r.sizeM.value=Math.max(50,e.sizeM),r.density.value=Math.max(0,Math.min(2,e.density)),r.darkness.value=Math.max(0,Math.min(1,e.darkness??0)),r.eyeM.value=Math.max(.1,t),r.flatness.value=e.type==="stratus"?1:e.type==="stratocumulus"?.45:0;const a=pu(e);r.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=r.density.value>0&&(n!==void 0||r.coverage.value>0)}static thresholdFor(e){const t=Math.min(.999,Math.max(.001,e));return .645-.23*(Math.sqrt(3)/Math.PI)*Math.log(t/(1-t))}densityAt(e){const t=this.uniforms,n=(F,H,O)=>{const V=Math.max(0,Math.min(1,(O-F)/(H-F)));return V*V*(3-2*V)},i=(F,H,O)=>F+(H-F)*O,r=t.eyeM.value+e.y,a=2*Ir*r+e.x**2+r**2+e.z**2,o=a/(Math.sqrt(Ir**2+a)+Ir),c=(o-t.baseM.value)/t.thicknessM.value,l=t.localSize.value.x>0;if(c<=0||c>=1||t.coverage.value<=0&&!l)return 0;const h=(F,H,O)=>{const V=e.x+t.offsetM.value.x-F.x,z=e.z+t.offsetM.value.z-F.z,Y=Math.cos(O),ee=Math.sin(O);return Math.hypot((Y*V-ee*z)/(H.x*.5),(o-F.y)/(H.y*.5),(ee*V+Y*z)/(H.z*.5))},u=l?h(t.localCenter.value,t.localSize.value,t.localRotation.value):0;if(u>1.3)return 0;const d=[e.x,e.y,e.z].map((F,H)=>(F+t.offsetM.value.getComponent(H))/(t.sizeM.value*4)+t.seedOffset.value.getComponent(H)),f=t.noiseMap.value.image.data,p=(F,H,O)=>{const V=[F,H,O].map(J=>(J%1+1)%1*Gt-.5),z=V.map(Math.floor),Y=V.map((J,ne)=>J-z[ne]);let ee=0;for(let J=0;J<2;J++)for(let ne=0;ne<2;ne++)for(let ae=0;ae<2;ae++){const Ve=(z[0]+ae+Gt)%Gt,je=(z[1]+ne+Gt)%Gt,He=(z[2]+J+Gt)%Gt;ee+=f[Ve+Gt*(je+Gt*He)]/255*(ae?Y[0]:1-Y[0])*(ne?Y[1]:1-Y[1])*(J?Y[2]:1-Y[2])}return ee},v=[d[0]*.173,Gl,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let S=n(.2,.8,p(d[0],Gl,d[2])*.65+p(m,Gl+.37,g)*.35);const b=n(8e3,4e4,Math.hypot(e.x,e.y,e.z)),_=i(p(d[0]*2,d[1]*3,d[2]*2),.5,b),E=i(p(d[0]*7,d[1]*7,d[2]*7),.5,b);let w=Ic.thresholdFor(t.coverage.value),R=1,M=0;if(l){const F=u+(_-.5)*.18;M=1-n(.35,1,F),R=1-n(.85,1.15,F),S=i(S,1,M),w=Math.min(w,Ic.thresholdFor(.5))}for(let F=0;F<t.holeCount.value;F++)R*=n(.85,1.15,h(t.holeCenter.value[F],t.holeSize.value[F],t.holeRotation.value[F])+(_-.5)*.18);if(R<.001)return 0;let A=n(w-.1,w+.1,S);if(A=i(A,1,n(.92,1,t.coverage.value)),A=i(A,Math.max(t.coverage.value,M),b),A<.001)return 0;const I=i(.45+.55*_,.96,t.flatness.value),D=n(0,.09,c)*(1-n(I-.22,I,c)),P=i(Math.max(0,A-(1-_)*.38-(1-E)*.1),A*.8,t.flatness.value);return D*P*t.density.value*R}transmissionAt(e,t=1/0){const n=this.uniforms,i=Xy(e.y,n.eyeM.value,n.baseM.value,n.thicknessM.value);if(!i)return 1;let[r,a]=i;if(n.localSize.value.x>0){const h=n.localCenter.value.clone().sub(n.offsetM.value);h.y-=n.eyeM.value+(h.x**2+h.z**2)/(2*Ir);const u=n.localSize.value.length()*.5+25,d=e.x*h.x+e.y*h.y+e.z*h.z,f=d*d-h.lengthSq()+u*u;if(f<0)return 1;r=Math.max(r,d-Math.sqrt(f)),a=Math.min(a,d+Math.sqrt(f))}const o=Math.min(a,t,r+18e3);if(o<=r)return 1;const c=(o-r)/48;let l=1;for(let h=0;h<48;h++){const u=r+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x:e.x*u,y:e.y*u,z:e.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class hn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=hn.build(24);static build(e){const t=[];let n=0,i=0,r=0;for(let a=0;a<e;a++){const o=hn.VIOLET_NM+(a+.5)/e*(hn.DEEP_RED_NM-hn.VIOLET_NM),[c,l,h]=hn.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};n+=u.r,i+=u.g,r+=u.b,t.push(u)}for(const a of t)a.r/=n,a.g/=i,a.b/=r;return t}static tristimulus(e,t,n){let i=0,r=0,a=0;for(let c=0;c<e.length;c++){const[l,h,u]=hn.colourMatching(e[c]);i+=l*t[c],r+=h*t[c],a+=u*t[c]}const o=683*n;return[i*o,r*o,a*o]}static scotopic(e){const t=e/1e3;return .992*Math.exp(-321.9*(t-.5)**2)}static linearSrgbOf([e,t,n]){return[3.2406*e-1.5372*t-.4986*n,-.9689*e+1.8758*t+.0415*n,.0557*e-.204*t+1.057*n]}static colourMatching(e){const t=(n,i,r)=>{const a=(e-n)/(e<n?i:r);return Math.exp(-.5*a*a)};return[1.056*t(599.8,37.9,31)+.362*t(442,16,26.7)-.065*t(501.1,20.4,26.2),.821*t(568.8,46.9,40.5)+.286*t(530.9,16.3,31.1),1.217*t(437,11.8,36)+.681*t(459,26,13.8)]}}class Pc{static reflectance(e,t,n){const r=t/n*Math.sqrt(Math.max(0,1-e*e));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*e-t*a)/(n*e+t*a),c=(t*e-n*a)/(t*e+n*a);return(o*o+c*c)/2}}class tn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(tn.ANCHOR_BLUE-tn.ANCHOR_RED)/(1/(tn.BLUE_NM*tn.BLUE_NM)-1/(tn.RED_NM*tn.RED_NM));static A=tn.ANCHOR_RED-tn.B/(tn.RED_NM*tn.RED_NM);static indexAt(e){return tn.A+tn.B/(e*e)}}class Gr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(e){this.index=e}trace(e,t){const n=Math.min(1,Math.max(0,e)),i=Math.sqrt(Math.max(0,1-n*n)),r=n/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(n),c=Math.asin(r),l=Pc.reflectance(i,1,this.index);let h=0;t[h].chords=0,t[h].scatteringAngle=Gr.folded(Math.PI-2*o),t[h].weight=l,h++;const u=Pc.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Gr.MAX_CHORDS&&h<t.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);t[h].chords=f,t[h].scatteringAngle=Gr.folded(p),t[h].weight=d*(1-u),h++,d*=u}return h}static folded(e){const t=2*Math.PI;let n=e%t;return n<0&&(n+=t),n>Math.PI?t-n:n}}class Ht{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Gr;previous=Ht.emergences();current=Ht.emergences();tally=new Float32Array(Ht.BINS*3);radiance=new Float32Array(Ht.BINS*3);scratch=new Float32Array(Ht.BINS*3);static emergences(){return Array.from({length:Gr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const e of hn.SAMPLES)this.sweep(e);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ht.BINS,data:this.radiance,binDeg:180/Ht.BINS}}sweep(e){this.drop.refractiveIndex=tn.indexAt(e.wavelengthNm);const t=Ht.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const i=1/t;for(let r=1;r<=t;r++){const a=this.drop.trace(Math.sqrt(r/t),this.current);for(let o=0;o<Math.min(a,n);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*i,e)}n=a,this.copyInto(this.current,this.previous)}}copyInto(e,t){for(let n=0;n<e.length;n++)t[n].chords=e[n].chords,t[n].scatteringAngle=e[n].scatteringAngle,t[n].weight=e[n].weight}deposit(e,t,n,i){if(n<=0)return;const r=Ht.BINS,a=Math.PI/r,o=Math.min(e,t),c=Math.max(e,t),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,n,i);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/l,i)}}add(e,t,n){const i=e*3,r=t*hn.SAMPLES.length;this.tally[i]+=r*n.r,this.tally[i+1]+=r*n.g,this.tally[i+2]+=r*n.b}toRadiance(){const e=Ht.BINS,t=Math.PI/e;for(let n=0;n<e;n++){const i=2*Math.PI*(Math.cos(n*t)-Math.cos((n+1)*t)),r=i>0?this.backwardShare((n+.5)*(180/e))/i:0,a=n*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(e){const t=180-e;if(t<=Ht.FULL_UNTIL_DEG)return 1;if(t>=Ht.FADED_BY_DEG)return 0;const n=(t-Ht.FULL_UNTIL_DEG)/(Ht.FADED_BY_DEG-Ht.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const e=Ht.BINS,t=Ht.SOURCE_RADIUS_DEG*e/180,n=Math.max(1,Math.ceil(t)),i=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,t*t-a*a),c=Math.sqrt(o);i.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<e;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(e-1,Math.max(0,a+u))*3,f=i[u+n];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class Gs{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ht;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ht.BINS*4),this.texture=new js(this.texels,Ht.BINS,1,_n,cn),this.texture.minFilter=dt,this.texture.magFilter=dt,this.texture.wrapS=An,this.texture.wrapT=An,this.texture.needsUpdate=!0,this.material=new Rt({uniforms:{uSource:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Gs.GAIN}},vertexShader:`
5091
5091
  varying vec3 vDirection;
5092
5092
  void main() {
5093
5093
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5176,7 +5176,7 @@ vec3 encodeSrgb(vec3 linear) {
5176
5176
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
5177
5177
  * @author Don Cross <cosinekitty@gmail.com>
5178
5178
  * @license MIT
5179
- */const pd=173.1446326846693,Fs=14959787069098932e-8,ut=.017453292519943295,If=.26179938779914946,Pi=57.29577951308232,Gm=3.819718634205488,yS=365.24217,Pf=new Date("2000-01-01T12:00:00Z"),Bi=2*Math.PI,us=3600*(180/Math.PI),Pr=484813681109536e-20,Vm=10800*60,SS=2*Vm,Lf=7292115e-11,bS=Vm/Math.PI,ES=-.17-5*Math.log10(bS),xu=.996647180302104,wS=xu*xu,_u=6378.1366,AS=_u/Fs,Wm=81.30056,md=.0002959122082855911,yu=2825345909524226e-22,Su=8459715185680659e-23,bu=1292024916781969e-23,Eu=1524358900784276e-23;function Oc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function an(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function wr(s){return s-Math.floor(s)}function TS(s,e){const t=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const n=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*e.x+s.y*e.y+s.z*e.z)/Math.sqrt(t*n);return i<=-1?180:i>=1?0:Pi*Math.acos(i)}var Se;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(Se||(Se={}));const RS=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],DS=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function CS(s){const e=RS.indexOf(s);return e>=0?DS[e]:null}function gd(s){const e=CS(s);return e&&e.dist>0?e:null}var pn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(pn||(pn={}));const Di={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function IS(s){var e,t,n,i,r,a,o;const c=2e3+(s-14)/yS;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,n=e*t,i=t*t,r=t*n,a=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*i+.022174192*r+.0090316521*a):c<1600?(e=(c-1e3)/100,t=e*e,n=e*t,i=t*t,r=t*n,a=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*i-.005050998*r+.0083572073*a):c<1700?(e=c-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):c<1800?(e=c-1700,t=e*e,n=e*t,i=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-i/1174e3):c<1860?(e=c-1800,t=e*e,n=e*t,i=t*t,r=t*n,a=n*n,o=n*i,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*i+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(e=c-1860,t=e*e,n=e*t,i=t*t,r=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*i+r/233174):c<1920?(e=c-1900,t=e*e,n=e*t,i=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*i):c<1941?(e=c-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):c<1961?(e=c-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):c<1986?(e=c-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):c<2005?(e=c-2e3,t=e*e,n=e*t,i=t*t,r=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*i+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let PS=IS;function Nf(s){return s+PS(s)/86400}class Vr{constructor(e){if(e instanceof Vr){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-Pf.getTime())/t,this.tt=Nf(this.ut);return}if(Number.isFinite(e)){this.date=new Date(Pf.getTime()+e*t),this.ut=e,this.tt=Nf(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new Vr(e);for(;;){const n=e-t.tt;if(Math.abs(n)<1e-12)return t;t=t.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(e){return new Vr(this.ut+e)}}function Pt(s){return s instanceof Vr?s:new Vr(s)}function LS(s){function e(d){return d%SS*Pr}const t=s.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),i=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(i-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(i+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Xm(s){var e=s.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var Wo;function no(s){if(!Wo||Math.abs(Wo.tt-s.tt)>1e-6){const e=LS(s),t=Xm(s),n=t+e.deps/3600;Wo={tt:s.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*ut)/15,mobl:t,tobl:n}}return Wo}function NS(s,e){const t=s*ut,n=Math.cos(t),i=Math.sin(t);return[e[0],e[1]*n-e[2]*i,e[1]*i+e[2]*n]}function OS(s,e){return NS(Xm(s),e)}function US(s){const e=s.tt/36525;function t(Re,xe){const Ne=[];let Oe;for(Oe=0;Oe<=xe-Re;++Oe)Ne.push(0);return{min:Re,array:Ne}}function n(Re,xe,Ne,Oe){const Ue=[];for(let at=0;at<=xe-Re;++at)Ue.push(t(Ne,Oe));return{min:Re,array:Ue}}function i(Re,xe,Ne){const Oe=Re.array[xe-Re.min];return Oe.array[Ne-Oe.min]}function r(Re,xe,Ne,Oe){const Ue=Re.array[xe-Re.min];Ue.array[Ne-Ue.min]=Oe}let a,o,c,l,h,u,d,f,p,v,m,g,S,b,_,E,w,R,M,A,I,D,P,F=n(-6,6,1,4),H=n(-6,6,1,4);function O(Re,xe){return i(F,Re,xe)}function V(Re,xe){return i(H,Re,xe)}function z(Re,xe,Ne){return r(F,Re,xe,Ne)}function Y(Re,xe,Ne){return r(H,Re,xe,Ne)}function ee(Re,xe,Ne,Oe,Ue){Ue(Re*Ne-xe*Oe,xe*Ne+Re*Oe)}function J(Re){return Math.sin(Bi*Re)}d=e*e,p=0,P=0,m=0,g=3422.7;var ne=J(.19833+.05611*e),ae=J(.27869+.04508*e),Ve=J(.16827-.36903*e),je=J(.34734-5.37261*e),Be=J(.10498-5.37899*e),K=J(.42681-.41855*e),re=J(.14943-5.37511*e);for(R=.84*ne+.31*ae+14.27*Ve+7.26*je+.28*Be+.24*K,M=2.94*ne+.31*ae+14.27*Ve+9.34*je+1.12*Be+.83*K,A=-6.4*ne-1.89*K,I=.21*ne+.31*ae+14.27*Ve-88.7*je-15.3*Be+.24*K-1.86*re,D=R-A,f=-3332e-9*J(.59734-5.37261*e)-539e-9*J(.35498-5.37899*e)-64e-9*J(.39943-5.37511*e),S=Bi*wr(.60643382+1336.85522467*e-313e-8*d)+R/us,b=Bi*wr(.37489701+1325.55240982*e+2565e-8*d)+M/us,_=Bi*wr(.99312619+99.99735956*e-44e-8*d)+A/us,E=Bi*wr(.25909118+1342.2278298*e-892e-8*d)+I/us,w=Bi*wr(.82736186+1236.85308708*e-397e-8*d)+D/us,h=1;h<=4;++h){switch(h){case 1:c=b,o=4,l=1.000002208;break;case 2:c=_,o=3,l=.997504612-.002495388*e;break;case 3:c=E,o=4,l=1.000002708+139.978*f;break;case 4:c=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(z(0,h,1),z(1,h,Math.cos(c)*l),Y(0,h,0),Y(1,h,Math.sin(c)*l),u=2;u<=o;++u)ee(O(u-1,h),V(u-1,h),O(1,h),V(1,h),(Re,xe)=>(z(u,h,Re),Y(u,h,xe)));for(u=1;u<=o;++u)z(-u,h,O(u,h)),Y(-u,h,-V(u,h))}function ie(Re,xe,Ne,Oe){for(var Ue={x:1,y:0},at=[0,Re,xe,Ne,Oe],ot=1;ot<=4;++ot)at[ot]!==0&&ee(Ue.x,Ue.y,O(at[ot],ot),V(at[ot],ot),(Lt,Et)=>(Ue.x=Lt,Ue.y=Et));return Ue}function B(Re,xe,Ne,Oe,Ue,at,ot,Lt){var Et=ie(Ue,at,ot,Lt);p+=Re*Et.y,P+=xe*Et.y,m+=Ne*Et.x,g+=Oe*Et.x}B(13.902,14.06,-.001,.2607,0,0,0,4),B(.403,-4.01,.394,.0023,0,0,0,3),B(2369.912,2373.36,.601,28.2333,0,0,0,2),B(-125.154,-112.79,-.725,-.9781,0,0,0,1),B(1.979,6.98,-.445,.0433,1,0,0,4),B(191.953,192.72,.029,3.0861,1,0,0,2),B(-8.466,-13.51,.455,-.1093,1,0,0,1),B(22639.5,22609.07,.079,186.5398,1,0,0,0),B(18.609,3.59,-.094,.0118,1,0,0,-1),B(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),B(3.215,5.44,.192,-.0386,1,0,0,-3),B(-38.428,-38.64,.001,.6008,1,0,0,-4),B(-.393,-1.43,-.092,.0086,1,0,0,-6),B(-.289,-1.59,.123,-.0053,0,1,0,4),B(-24.42,-25.1,.04,-.3,0,1,0,2),B(18.023,17.93,.007,.1494,0,1,0,1),B(-668.146,-126.98,-1.302,-.3997,0,1,0,0),B(.56,.32,-.001,-.0037,0,1,0,-1),B(-165.145,-165.06,.054,1.9178,0,1,0,-2),B(-1.877,-6.46,-.416,.0339,0,1,0,-4),B(.213,1.02,-.074,.0054,2,0,0,4),B(14.387,14.78,-.017,.2833,2,0,0,2),B(-.586,-1.2,.054,-.01,2,0,0,1),B(769.016,767.96,.107,10.1657,2,0,0,0),B(1.75,2.01,-.018,.0155,2,0,0,-1),B(-211.656,-152.53,5.679,-.3039,2,0,0,-2),B(1.225,.91,-.03,-.0088,2,0,0,-3),B(-30.773,-34.07,-.308,.3722,2,0,0,-4),B(-.57,-1.4,-.074,.0109,2,0,0,-6),B(-2.921,-11.75,.787,-.0484,1,1,0,2),B(1.267,1.52,-.022,.0164,1,1,0,1),B(-109.673,-115.18,.461,-.949,1,1,0,0),B(-205.962,-182.36,2.056,1.4437,1,1,0,-2),B(.233,.36,.012,-.0025,1,1,0,-3),B(-4.391,-9.66,-.471,.0673,1,1,0,-4),B(.283,1.53,-.111,.006,1,-1,0,4),B(14.577,31.7,-1.54,.2302,1,-1,0,2),B(147.687,138.76,.679,1.1528,1,-1,0,0),B(-1.089,.55,.021,0,1,-1,0,-1),B(28.475,23.59,-.443,-.2257,1,-1,0,-2),B(-.276,-.38,-.006,-.0036,1,-1,0,-3),B(.636,2.27,.146,-.0102,1,-1,0,-4),B(-.189,-1.68,.131,-.0028,0,2,0,2),B(-7.486,-.66,-.037,-.0086,0,2,0,0),B(-8.096,-16.35,-.74,.0918,0,2,0,-2),B(-5.741,-.04,0,-9e-4,0,0,2,2),B(.255,0,0,0,0,0,2,1),B(-411.608,-.2,0,-.0124,0,0,2,0),B(.584,.84,0,.0071,0,0,2,-1),B(-55.173,-52.14,0,-.1052,0,0,2,-2),B(.254,.25,0,-.0017,0,0,2,-3),B(.025,-1.67,0,.0031,0,0,2,-4),B(1.06,2.96,-.166,.0243,3,0,0,2),B(36.124,50.64,-1.3,.6215,3,0,0,0),B(-13.193,-16.4,.258,-.1187,3,0,0,-2),B(-1.187,-.74,.042,.0074,3,0,0,-4),B(-.293,-.31,-.002,.0046,3,0,0,-6),B(-.29,-1.45,.116,-.0051,2,1,0,2),B(-7.649,-10.56,.259,-.1038,2,1,0,0),B(-8.627,-7.59,.078,-.0192,2,1,0,-2),B(-2.74,-2.54,.022,.0324,2,1,0,-4),B(1.181,3.32,-.212,.0213,2,-1,0,2),B(9.703,11.67,-.151,.1268,2,-1,0,0),B(-.352,-.37,.001,-.0028,2,-1,0,-1),B(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),B(.36,.2,-.012,-.0043,2,-1,0,-4),B(-1.167,-1.25,.008,-.0106,1,2,0,0),B(-7.412,-6.12,.117,.0484,1,2,0,-2),B(-.311,-.65,-.032,.0044,1,2,0,-4),B(.757,1.82,-.105,.0112,1,-2,0,2),B(2.58,2.32,.027,.0196,1,-2,0,0),B(2.533,2.4,-.014,-.0212,1,-2,0,-2),B(-.344,-.57,-.025,.0036,0,3,0,-2),B(-.992,-.02,0,0,1,0,2,2),B(-45.099,-.02,0,-.001,1,0,2,0),B(-.179,-9.52,0,-.0833,1,0,2,-2),B(-.301,-.33,0,.0014,1,0,2,-4),B(-6.382,-3.37,0,-.0481,1,0,-2,2),B(39.528,85.13,0,-.7136,1,0,-2,0),B(9.366,.71,0,-.0112,1,0,-2,-2),B(.202,.02,0,0,1,0,-2,-4),B(.415,.1,0,.0013,0,1,2,0),B(-2.152,-2.26,0,-.0066,0,1,2,-2),B(-1.44,-1.3,0,.0014,0,1,-2,2),B(.384,-.04,0,0,0,1,-2,-2),B(1.938,3.6,-.145,.0401,4,0,0,0),B(-.952,-1.58,.052,-.013,4,0,0,-2),B(-.551,-.94,.032,-.0097,3,1,0,0),B(-.482,-.57,.005,-.0045,3,1,0,-2),B(.681,.96,-.026,.0115,3,-1,0,0),B(-.297,-.27,.002,-9e-4,2,2,0,-2),B(.254,.21,-.003,0,2,-2,0,-2),B(-.25,-.22,.004,.0014,1,3,0,-2),B(-3.996,0,0,4e-4,2,0,2,0),B(.557,-.75,0,-.009,2,0,2,-2),B(-.459,-.38,0,-.0053,2,0,-2,2),B(-1.298,.74,0,4e-4,2,0,-2,0),B(.538,1.14,0,-.0141,2,0,-2,-2),B(.263,.02,0,0,1,1,2,0),B(.426,.07,0,-6e-4,1,1,-2,-2),B(-.304,.03,0,3e-4,1,-1,2,0),B(-.372,-.19,0,-.0027,1,-1,-2,2),B(.418,0,0,0,0,0,4,0),B(-.33,-.04,0,0,3,0,2,0);function Ee(Re,xe,Ne,Oe,Ue){return Re*ie(xe,Ne,Oe,Ue).y}v=0,v+=Ee(-526.069,0,0,1,-2),v+=Ee(-3.352,0,0,1,-4),v+=Ee(44.297,1,0,1,-2),v+=Ee(-6,1,0,1,-4),v+=Ee(20.599,-1,0,1,0),v+=Ee(-30.598,-1,0,1,-2),v+=Ee(-24.649,-2,0,1,0),v+=Ee(-2,-2,0,1,-2),v+=Ee(-22.571,0,1,1,-2),v+=Ee(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*e)+.31*J(.0466-125.1025*e)+.35*J(.5785-25.1042*e)+.66*J(.4591+1335.8075*e)+.64*J(.313-91.568*e)+1.14*J(.148+1331.2898*e)+.21*J(.5918+1056.5859*e)+.44*J(.5784+1322.8595*e)+.24*J(.2275-5.7374*e)+.28*J(.2965+2.6929*e)+.33*J(.3132+6.3368*e),a=E+P/us;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Bi*wr((S+p/us)/Bi),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:us*AS/(.999953253*g)}}function qm(s,e){return[s.rot[0][0]*e[0]+s.rot[1][0]*e[1]+s.rot[2][0]*e[2],s.rot[0][1]*e[0]+s.rot[1][1]*e[1]+s.rot[2][1]*e[2],s.rot[0][2]*e[0]+s.rot[1][2]*e[1]+s.rot[2][2]*e[2]]}function Uc(s,e,t){const n=vd(e,t);return qm(n,s)}function vd(s,e){const t=s.tt/36525;let n=84381.406,i=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+n,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;n*=Pr,i*=Pr,r*=Pr,a*=Pr;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-i),h=Math.cos(-i),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,b=-f*l*c+p*d*h*c-o*p*u,_=-f*l*o+p*d*h*o+c*p*u,E=l*u,w=-u*h*c-o*d,R=-u*h*o+d*c;if(e===pn.Into2000)return new bs([[v,m,g],[S,b,_],[E,w,R]]);if(e===pn.From2000)return new bs([[v,S,E],[m,b,w],[g,_,R]]);throw"Invalid precess direction"}function FS(s){const e=.779057273264+.00273781191135448*s.ut,t=s.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let Xo;function Kc(s){if(!Xo||Xo.tt!==s.tt){const e=s.tt/36525;let t=15*no(s).ee;const n=FS(s);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;r<0&&(r+=24),Xo={tt:s.tt,st:r}}return Xo.st}function kS(s){const e=Pt(s);return Kc(e)}function Ym(s,e){const t=s.latitude*ut,n=Math.sin(t),i=Math.cos(t),r=1/Math.hypot(i,xu*n),a=wS*r,o=s.height/1e3,c=_u*r+o,l=_u*a+o,h=(15*e+s.longitude)*ut,u=Math.sin(h),d=Math.cos(h);return{pos:[c*i*d/Fs,c*i*u/Fs,l*n/Fs],vel:[-Lf*c*i*u*86400/Fs,Lf*c*i*d*86400/Fs,0]}}function wu(s,e,t){const n=Md(e,t);return qm(n,s)}function Md(s,e){const t=no(s),n=t.mobl*ut,i=t.tobl*ut,r=t.dpsi*Pr,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,S=u*l,b=h*a*l-o*c,_=h*o*l+a*c;if(e===pn.From2000)return new bs([[d,v,S],[f,m,b],[p,g,_]]);if(e===pn.Into2000)return new bs([[d,f,p],[v,m,g],[S,b,_]]);throw"Invalid precess direction"}function xd(s,e,t){return t===pn.Into2000?Uc(wu(s,e,t),e,t):wu(Uc(s,e,t),e,t)}function zS(s,e){const t=Kc(s),n=Ym(e,t).pos;return xd(n,s,pn.Into2000)}class _t{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class _s{constructor(e,t,n,i,r,a,o){this.x=e,this.y=t,this.z=n,this.vx=i,this.vy=r,this.vz=a,this.t=o}}class $c{constructor(e,t,n){this.lat=an(e),this.lon=an(t),this.dist=an(n)}}class Au{constructor(e,t,n,i){this.ra=an(e),this.dec=an(t),this.dist=an(n),this.vec=i}}class bs{constructor(e){this.rot=e}}class BS{constructor(e,t,n,i){this.azimuth=an(e),this.altitude=an(t),this.ra=an(n),this.dec=an(i)}}class HS{constructor(e,t,n){this.vec=e,this.elat=an(t),this.elon=an(n)}}function Km(s,e){return new _t(s[0],s[1],s[2],e)}function GS(s,e){const t=Km(s,e),n=t.x*t.x+t.y*t.y,i=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new Au(0,t.z<0?-90:90,i,t)}let r=Gm*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=Pi*Math.atan2(s[2],Math.sqrt(n));return new Au(r,a,i,t)}function Wl(s,e){const t=s*ut,n=Math.cos(t),i=Math.sin(t);return[n*e[0]+i*e[1],n*e[1]-i*e[0],e[2]]}function $m(s,e,t,n,i){let r=Pt(s);_d(e),an(t),an(n);const a=Math.sin(e.latitude*ut),o=Math.cos(e.latitude*ut),c=Math.sin(e.longitude*ut),l=Math.cos(e.longitude*ut),h=Math.sin(n*ut),u=Math.cos(n*ut),d=Math.sin(t*If),f=Math.cos(t*If);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*Kc(r);let S=Wl(g,p),b=Wl(g,v),_=Wl(g,m),E=[u*f,u*d,h];const w=E[0]*S[0]+E[1]*S[1]+E[2]*S[2],R=E[0]*b[0]+E[1]*b[1]+E[2]*b[2],M=E[0]*_[0]+E[1]*_[1]+E[2]*_[2];let A=Math.hypot(R,M),I;A>0?(I=-Pi*Math.atan2(M,R),I<0&&(I+=360)):I=0;let D=Pi*Math.atan2(A,w),P=t,F=n;if(i){let H=D,O=sg(i,90-D);if(D-=O,O>0&&D>3e-4){const V=Math.sin(D*ut),z=Math.cos(D*ut),Y=Math.sin(H*ut),ee=Math.cos(H*ut),J=[];for(let ne=0;ne<3;++ne)J.push((E[ne]-ee*S[ne])/Y*V+S[ne]*z);A=Math.hypot(J[0],J[1]),A>0?(P=Gm*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,F=Pi*Math.atan2(J[2],A)}}return new BS(I,90-D,P,F)}function _d(s){if(!(s instanceof yd))throw`Not an instance of the Observer class: ${s}`;if(an(s.latitude),an(s.longitude),an(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class yd{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,_d(this)}}function VS(s){const e=Pt(s).AddDays(-1/pd),t=Xr(Di.Earth,e),n=[-t.x,-t.y,-t.z],[i,r,a]=xd(n,e,pn.From2000),o=ut*no(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new _t(i,r,a,e);return Zm(h,c,l)}function WS(s,e,t,n,i){_d(t),Oc(n),Oc(i);const r=Pt(e),a=zS(r,t),o=Uu(s,r,i),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=xd(c,r,pn.From2000);return GS(l,r)}function XS(s,e,t){const n=Pt(s),i=Kc(n);let r=Ym(e,i).pos;return Km(r,n)}function Zm(s,e,t){const n=s.x,i=s.y*e+s.z*t,r=-s.y*t+s.z*e,a=Math.hypot(n,i);let o=0;a>0&&(o=Pi*Math.atan2(i,n),o<0&&(o+=360));let c=Pi*Math.atan2(r,a),l=new _t(n,i,r,s.t);return new HS(l,c,o)}function Tu(s){const e=no(s.t),t=[s.x,s.y,s.z],n=Uc(t,s.t,pn.From2000),[i,r,a]=wu(n,s.t,pn.From2000),o=new _t(i,r,a,s.t),c=e.tobl*ut;return Zm(o,Math.cos(c),Math.sin(c))}function jr(s){const e=Pt(s),t=US(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),i=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],r=OS(e,i),a=Uc(r,e,pn.Into2000);return new _t(a[0],a[1],a[2],e)}function Jm(s){const e=Pt(s),t=1e-5,n=e.AddDays(-t),i=e.AddDays(+t),r=jr(n),a=jr(i);return new _s((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*t),(a.y-r.y)/(2*t),(a.z-r.z)/(2*t),e)}function qS(s){const e=Pt(s),t=Jm(e),n=1+Wm;return new _s(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Wr(s,e,t){let n=1,i=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+e*h);let o=n*a;t&&(o%=Bi),i+=o,n*=e}return i}function Xl(s,e){let t=1,n=0,i=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+e*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}i+=r*n*c-t*o,n=t,t*=e,++r}return i}const Ra=365250,Ru=0,Du=1,Cu=2;function Iu(s){return new xn(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function jm(s,e,t){const n=t*Math.cos(e),i=Math.cos(s),r=Math.sin(s);return[n*i,n*r,t*Math.sin(e)]}function Xr(s,e){const t=e.tt/Ra,n=Wr(s[Ru],t,!0),i=Wr(s[Du],t,!1),r=Wr(s[Cu],t,!1),a=jm(n,i,r);return Iu(a).ToAstroVector(e)}function Pu(s,e){const t=e/Ra,n=Wr(s[Ru],t,!0),i=Wr(s[Du],t,!1),r=Wr(s[Cu],t,!1),a=Xl(s[Ru],t),o=Xl(s[Du],t),c=Xl(s[Cu],t),l=Math.cos(n),h=Math.sin(n),u=Math.cos(i),d=Math.sin(i),f=+(c*u*l)-r*d*l*o-r*u*h*a,p=+(c*u*h)-r*d*h*o+r*u*l*a,v=+(c*d)+r*u*o,m=jm(n,i,r),g=[f/Ra,p/Ra,v/Ra],S=Iu(m),b=Iu(g);return new $s(e,S,b)}function qo(s,e,t,n){const i=n/(n+md),r=Xr(Di[t],e);s.x+=i*r.x,s.y+=i*r.y,s.z+=i*r.z}function YS(s){const e=new _t(0,0,0,s);return qo(e,s,Se.Jupiter,yu),qo(e,s,Se.Saturn,Su),qo(e,s,Se.Uranus,bu),qo(e,s,Se.Neptune,Eu),e}const Lu=51,KS=29200,Lr=146,Hi=201,Vs=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class xn{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new xn(this.x,this.y,this.z)}ToAstroVector(e){return new _t(this.x,this.y,this.z,e)}static zero(){return new xn(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new xn(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new xn(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new xn(e*this.x,e*this.y,e*this.z)}div(e){return new xn(this.x/e,this.y/e,this.z/e)}mean(e){return new xn((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new xn(-this.x,-this.y,-this.z)}}class $s{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new $s(this.tt,this.r,this.v)}sub(e){return new $s(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function $S(s){let[e,[t,n,i],[r,a,o]]=s;return new $s(e,new xn(t,n,i),new xn(r,a,o))}function Yo(s,e,t,n){const i=n/(n+md),r=Pu(Di[t],e);return s.r.incr(r.r.mul(i)),s.v.incr(r.v.mul(i)),r}function va(s,e,t){const n=t.sub(s),i=n.quadrature();return n.mul(e/(i*Math.sqrt(i)))}class Zc{constructor(e){let t=new $s(e,new xn(0,0,0),new xn(0,0,0));this.Jupiter=Yo(t,e,Se.Jupiter,yu),this.Saturn=Yo(t,e,Se.Saturn,Su),this.Uranus=Yo(t,e,Se.Uranus,bu),this.Neptune=Yo(t,e,Se.Neptune,Eu),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new $s(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=va(e,md,this.Sun.r);return t.incr(va(e,yu,this.Jupiter.r)),t.incr(va(e,Su,this.Saturn.r)),t.incr(va(e,bu,this.Uranus.r)),t.incr(va(e,Eu,this.Neptune.r)),t}}class Jc{constructor(e,t,n,i){this.tt=e,this.r=t,this.v=n,this.a=i}clone(){return new Jc(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Qm{constructor(e,t){this.bary=e,this.grav=t}}function Fc(s,e,t,n){return new xn(e.x+s*(t.x+s*n.x/2),e.y+s*(t.y+s*n.y/2),e.z+s*(t.z+s*n.z/2))}function Of(s,e,t){return new xn(e.x+s*t.x,e.y+s*t.y,e.z+s*t.z)}function Nu(s,e){const t=s-e.tt,n=new Zc(s),i=Fc(t,e.r,e.v,e.a),r=n.Acceleration(i).mean(e.a),a=Fc(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=n.Acceleration(a),l=new Jc(s,a,o,c);return new Qm(n,l)}const ZS=[];function eg(s,e){const t=Math.floor(s);return t<0?0:t>=e?e-1:t}function Ou(s){const e=$S(s),t=new Zc(e.tt),n=e.r.add(t.Sun.r),i=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new Jc(e.tt,n,i,r);return new Qm(t,a)}function JS(s,e){const t=Vs[0][0];if(e<t||e>Vs[Lu-1][0])return null;const n=eg((e-t)/KS,Lu-1);if(!s[n]){const r=s[n]=[];r[0]=Ou(Vs[n]).grav,r[Hi-1]=Ou(Vs[n+1]).grav;let a,o=r[0].tt;for(a=1;a<Hi-1;++a)r[a]=Nu(o+=Lr,r[a-1]).grav;o=r[Hi-1].tt;var i=[];for(i[Hi-1]=r[Hi-1],a=Hi-2;a>0;--a)i[a]=Nu(o-=Lr,i[a+1]).grav;for(a=Hi-2;a>0;--a){const c=a/(Hi-1);r[a].r=r[a].r.mul(1-c).add(i[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(i[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(i[a].a.mul(c))}}return s[n]}function Uf(s,e,t){let n=Ou(s);const i=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<i;++r)n=Nu(r+1===i?e:n.grav.tt+t,n.grav);return n}function tg(s,e){let t,n,i;const r=JS(ZS,s.tt);if(r){const a=eg((s.tt-r[0].tt)/Lr,Hi-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=Fc(s.tt-o.tt,o.r,o.v,l),u=Of(s.tt-o.tt,o.v,l),d=Fc(s.tt-c.tt,c.r,c.v,l),f=Of(s.tt-c.tt,c.v,l),p=(s.tt-o.tt)/Lr;t=h.mul(1-p).add(d.mul(p)),n=u.mul(1-p).add(f.mul(p))}else{let a;s.tt<Vs[0][0]?a=Uf(Vs[0],s.tt,-Lr):a=Uf(Vs[Lu-1],s.tt,+Lr),t=a.grav.r,n=a.grav.v,i=a.bary}return i||(i=new Zc(s.tt)),t=t.sub(i.Sun.r),n=n.sub(i.Sun.v),new _s(t.x,t.y,t.z,n.x,n.y,n.z,s)}function ys(s,e){var t=Pt(e);if(s in Di)return Xr(Di[s],t);if(s===Se.Pluto){const a=tg(t);return new _t(a.x,a.y,a.z,t)}if(s===Se.Sun)return new _t(0,0,0,t);if(s===Se.Moon){var n=Xr(Di.Earth,t),i=jr(t);return new _t(n.x+i.x,n.y+i.y,n.z+i.z,t)}if(s===Se.EMB){const a=Xr(Di.Earth,t),o=jr(t),c=1+Wm;return new _t(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(s===Se.SSB)return YS(t);const r=gd(s);if(r){const a=new $c(r.dec,15*r.ra,r.dist);return Sd(a,t)}throw`HelioVector: Unknown body "${s}"`}function jS(s,e){let t=e,n=0;for(let i=0;i<10;++i){const r=s(t),a=r.Length()/pd;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(n=Math.abs(o.tt-t.tt),n<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class QS{constructor(e,t,n,i){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=i}Position(e){this.aberration&&(this.observerPos=ys(this.observerBody,e));const t=ys(this.targetBody,e);return new _t(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function e5(s,e,t,n){Oc(n);const i=Pt(s);if(gd(t)){const o=ys(t,i);if(n){const l=n5(e,i),h=new _t(o.x-l.x,o.y-l.y,o.z-l.z,i),u=pd/h.Length();return new _t(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,i)}const c=ys(e,i);return new _t(o.x-c.x,o.y-c.y,o.z-c.z,i)}let r;n?r=new _t(0,0,0,i):r=ys(e,i);const a=new QS(e,t,n,r);return jS(o=>a.Position(o),i)}function Uu(s,e,t){Oc(t);const n=Pt(e);switch(s){case Se.Earth:return new _t(0,0,0,n);case Se.Moon:return jr(n);default:const i=e5(n,Se.Earth,s,t);return i.t=n,i}}function t5(s,e){return new _s(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,e)}function n5(s,e){const t=Pt(e);switch(s){case Se.Sun:return new _s(0,0,0,0,0,0,t);case Se.SSB:const n=new Zc(t.tt);return new _s(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case Se.Mercury:case Se.Venus:case Se.Earth:case Se.Mars:case Se.Jupiter:case Se.Saturn:case Se.Uranus:case Se.Neptune:const i=Pu(Di[s],t.tt);return t5(i,t);case Se.Pluto:return tg(t);case Se.Moon:case Se.EMB:const r=Pu(Di.Earth,t.tt),a=s==Se.Moon?Jm(t):qS(t);return new _s(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,t);default:if(gd(s)){const o=ys(s,t);return new _s(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${s}"`}}function i5(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function s5(s,e,t){if(s===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Pt(t),i=Uu(s,n,!1),r=Tu(i),a=Uu(e,n,!1),o=Tu(a);return i5(r.elon-o.elon)}function r5(s,e,t,n){let i,r=0,a=0,o=0;switch(s){case Se.Mercury:i=-.6,r=4.98,a=-4.88,o=3.02;break;case Se.Venus:e<163.6?(i=-4.47,r=1.03,a=.57,o=.13):(i=.98,r=-1.02);break;case Se.Mars:i=-1.52,r=1.6;break;case Se.Jupiter:i=-9.4,r=.5;break;case Se.Uranus:i=-7.19,r=.25;break;case Se.Neptune:i=-6.87;break;case Se.Pluto:i=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=e/100;let l=i+c*(r+c*(a+c*o));return l+=5*Math.log10(t*n),l}function a5(s,e,t,n,i){const r=Tu(n),a=ut*28.06,o=ut*(169.51+382e-7*i.tt),c=ut*r.elat,l=ut*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*s;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(e*t),{mag:d,ring_tilt:Pi*h}}function o5(s,e,t){let n=s*ut,i=n*n,r=i*i,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/Fs;let c=t/o;return a+=5*Math.log10(e*c),a}class c5{constructor(e,t,n,i,r,a,o,c){this.time=e,this.mag=t,this.phase_angle=n,this.helio_dist=i,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ut*n))/2}}function ng(s,e){if(s===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Pt(e),n=Xr(Di.Earth,t);let i,r,a,o;s===Se.Sun?(a=new _t(-n.x,-n.y,-n.z,t),r=new _t(0,0,0,t),i=0):(s===Se.Moon?(a=jr(t),r=new _t(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=ys(s,e),a=new _t(r.x-n.x,r.y-n.y,r.z-n.z,t)),i=TS(a,r));let c=a.Length(),l=r.Length(),h;if(s===Se.Sun)o=ES+5*Math.log10(c);else if(s===Se.Moon)o=o5(i,l,c);else if(s===Se.Saturn){const u=a5(i,l,c,a,t);o=u.mag,h=u.ring_tilt}else o=r5(s,i,l,c);return new c5(t,o,i,l,c,a,r,h)}function l5(s){return s5(Se.Moon,Se.Sun,s)}var Ff;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(Ff||(Ff={}));function ig(s,e){return new bs([[e.rot[0][0]*s.rot[0][0]+e.rot[1][0]*s.rot[0][1]+e.rot[2][0]*s.rot[0][2],e.rot[0][1]*s.rot[0][0]+e.rot[1][1]*s.rot[0][1]+e.rot[2][1]*s.rot[0][2],e.rot[0][2]*s.rot[0][0]+e.rot[1][2]*s.rot[0][1]+e.rot[2][2]*s.rot[0][2]],[e.rot[0][0]*s.rot[1][0]+e.rot[1][0]*s.rot[1][1]+e.rot[2][0]*s.rot[1][2],e.rot[0][1]*s.rot[1][0]+e.rot[1][1]*s.rot[1][1]+e.rot[2][1]*s.rot[1][2],e.rot[0][2]*s.rot[1][0]+e.rot[1][2]*s.rot[1][1]+e.rot[2][2]*s.rot[1][2]],[e.rot[0][0]*s.rot[2][0]+e.rot[1][0]*s.rot[2][1]+e.rot[2][0]*s.rot[2][2],e.rot[0][1]*s.rot[2][0]+e.rot[1][1]*s.rot[2][1]+e.rot[2][1]*s.rot[2][2],e.rot[0][2]*s.rot[2][0]+e.rot[1][2]*s.rot[2][1]+e.rot[2][2]*s.rot[2][2]]])}function Sd(s,e){e=Pt(e);const t=s.lat*ut,n=s.lon*ut,i=s.dist*Math.cos(t);return new _t(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(t),e)}function bd(s){const e=h5(s);return new Au(e.lon/15,e.lat,e.dist,s)}function h5(s){const e=s.x*s.x+s.y*s.y,t=Math.sqrt(e+s.z*s.z);let n,i;if(e===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=Pi*Math.atan2(s.y,s.x),i<0&&(i+=360),n=Pi*Math.atan2(s.z,Math.sqrt(e));return new $c(n,i,t)}function sg(s,e){let t;if(an(e),e<-90||e>90)return 0;if(s==="normal"||s==="jplhor"){let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*ut)/60,s==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!s)t=0;else throw`Invalid refraction option: ${s}`;return t}function qr(s,e){return new _t(s.rot[0][0]*e.x+s.rot[1][0]*e.y+s.rot[2][0]*e.z,s.rot[0][1]*e.x+s.rot[1][1]*e.y+s.rot[2][1]*e.z,s.rot[0][2]*e.x+s.rot[1][2]*e.y+s.rot[2][2]*e.z,e.t)}function u5(){return new bs([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function d5(){return new bs([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function rg(s){s=Pt(s);const e=vd(s,pn.From2000),t=Md(s,pn.From2000);return ig(e,t)}function f5(s){s=Pt(s);const e=Md(s,pn.Into2000),t=vd(s,pn.Into2000);return ig(e,t)}function p5(s){const t=no(Pt(s)).tobl*ut,n=Math.cos(t),i=Math.sin(t);return new bs([[1,0,0],[0,+n,+i],[0,-i,+n]])}var kf;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(kf||(kf={}));var zf;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(zf||(zf={}));const m5=["Venus","Mars","Jupiter","Saturn"];function ag(s){return new yd(s.lat,s.lng,s.elevationM)}function Ed(s,e,t,n,i=!0){const r=$m(t,ag(n),s,e,i?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}class ri{up;north;west;constructor(e,t){const n=Pt(e),i=Math.sin(t.lat*Gi),r=Math.cos(t.lat*Gi),a=Math.sin(t.lng*Gi),o=Math.cos(t.lng*Gi),c=-15*kS(n),l=f5(n);this.up=ri.rotate(l,ri.spin(c,[r*o,r*a,i]),n),this.north=ri.rotate(l,ri.spin(c,[-i*o,-i*a,r]),n),this.west=ri.rotate(l,ri.spin(c,[a,-o,0]),n)}static ofJ2000(e,t,n,i,r=!0){const a=Pt(n),o=Sd(new $c(t,e*15,1),a),c=bd(qr(rg(a),o));return Ed(c.ra,c.dec,n,i,r)}position(e,t){const n=Math.sin(t*Gi),i=Math.cos(t*Gi),r=Math.sin(e*Hf),a=Math.cos(e*Hf),o=i*a,c=i*r,l=n,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-Bf*Math.atan2(d,u),p<0&&(p+=360));let v=Bf*Math.atan2(f,h);return v-=sg("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,n,i]){const r=Math.cos(e*Gi),a=Math.sin(e*Gi);return[r*t+a*n,r*n-a*t,i]}static rotate(e,[t,n,i],r){const a=qr(e,new _t(t,n,i,r));return[a.x,a.y,a.z]}}const Gi=Math.PI/180,Bf=180/Math.PI,Hf=15*Gi;function ql(s,e,t){const n=ag(t),i=WS(Se[s],e,n,!0,!0),r=$m(e,n,i.ra,i.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Yl(s,e){return ng(Se[s],e).mag}function g5(s){const e=l5(s),t=ng(Se.Moon,s);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const v5=2e3,M5=3,x5=20;function Ko(s,e,t){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??v5,r=s.month??(n?1:M5),a=s.day??(n?1:x5),o=t??Math.round(e/15);return new Date(Date.UTC(i,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class Ms{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Ms.patch(t.fragmentShader)}}static patch(e){return e.replace(Ms.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
5179
+ */const pd=173.1446326846693,Fs=14959787069098932e-8,ut=.017453292519943295,If=.26179938779914946,Pi=57.29577951308232,Gm=3.819718634205488,yS=365.24217,Pf=new Date("2000-01-01T12:00:00Z"),Bi=2*Math.PI,us=3600*(180/Math.PI),Pr=484813681109536e-20,Vm=10800*60,SS=2*Vm,Lf=7292115e-11,bS=Vm/Math.PI,ES=-.17-5*Math.log10(bS),xu=.996647180302104,wS=xu*xu,_u=6378.1366,AS=_u/Fs,Wm=81.30056,md=.0002959122082855911,yu=2825345909524226e-22,Su=8459715185680659e-23,bu=1292024916781969e-23,Eu=1524358900784276e-23;function Oc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function an(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function wr(s){return s-Math.floor(s)}function TS(s,e){const t=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const n=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*e.x+s.y*e.y+s.z*e.z)/Math.sqrt(t*n);return i<=-1?180:i>=1?0:Pi*Math.acos(i)}var Se;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(Se||(Se={}));const RS=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],DS=[{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0},{ra:0,dec:0,dist:0}];function CS(s){const e=RS.indexOf(s);return e>=0?DS[e]:null}function gd(s){const e=CS(s);return e&&e.dist>0?e:null}var pn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(pn||(pn={}));const Di={Mercury:[[[[4.40250710144,0,0],[.40989414977,1.48302034195,26087.9031415742],[.050462942,4.47785489551,52175.8062831484],[.00855346844,1.16520322459,78263.70942472259],[.00165590362,4.11969163423,104351.61256629678],[.00034561897,.77930768443,130439.51570787099],[7583476e-11,3.71348404924,156527.41884944518]],[[26087.90313685529,0,0],[.01131199811,6.21874197797,26087.9031415742],[.00292242298,3.04449355541,52175.8062831484],[.00075775081,6.08568821653,78263.70942472259],[.00019676525,2.80965111777,104351.61256629678]]],[[[.11737528961,1.98357498767,26087.9031415742],[.02388076996,5.03738959686,52175.8062831484],[.01222839532,3.14159265359,0],[.0054325181,1.79644363964,78263.70942472259],[.0012977877,4.83232503958,104351.61256629678],[.00031866927,1.58088495658,130439.51570787099],[7963301e-11,4.60972126127,156527.41884944518]],[[.00274646065,3.95008450011,26087.9031415742],[.00099737713,3.14159265359,0]]],[[[.39528271651,0,0],[.07834131818,6.19233722598,26087.9031415742],[.00795525558,2.95989690104,52175.8062831484],[.00121281764,6.01064153797,78263.70942472259],[.00021921969,2.77820093972,104351.61256629678],[4354065e-11,5.82894543774,130439.51570787099]],[[.0021734774,4.65617158665,26087.9031415742],[.00044141826,1.42385544001,52175.8062831484]]]],Venus:[[[[3.17614666774,0,0],[.01353968419,5.59313319619,10213.285546211],[.00089891645,5.30650047764,20426.571092422],[5477194e-11,4.41630661466,7860.4193924392],[3455741e-11,2.6996444782,11790.6290886588],[2372061e-11,2.99377542079,3930.2096962196],[1317168e-11,5.18668228402,26.2983197998],[1664146e-11,4.25018630147,1577.3435424478],[1438387e-11,4.15745084182,9683.5945811164],[1200521e-11,6.15357116043,30639.856638633]],[[10213.28554621638,0,0],[.00095617813,2.4640651111,10213.285546211],[7787201e-11,.6247848222,20426.571092422]]],[[[.05923638472,.26702775812,10213.285546211],[.00040107978,1.14737178112,20426.571092422],[.00032814918,3.14159265359,0]],[[.00287821243,1.88964962838,10213.285546211]]],[[[.72334820891,0,0],[.00489824182,4.02151831717,10213.285546211],[1658058e-11,4.90206728031,20426.571092422],[1378043e-11,1.12846591367,11790.6290886588],[1632096e-11,2.84548795207,7860.4193924392],[498395e-11,2.58682193892,9683.5945811164],[221985e-11,2.01346696541,19367.1891622328],[237454e-11,2.55136053886,15720.8387848784]],[[.00034551041,.89198706276,10213.285546211]]]],Earth:[[[[1.75347045673,0,0],[.03341656453,4.66925680415,6283.0758499914],[.00034894275,4.62610242189,12566.1516999828],[3417572e-11,2.82886579754,3.523118349],[3497056e-11,2.74411783405,5753.3848848968],[3135899e-11,3.62767041756,77713.7714681205],[2676218e-11,4.41808345438,7860.4193924392],[2342691e-11,6.13516214446,3930.2096962196],[1273165e-11,2.03709657878,529.6909650946],[1324294e-11,.74246341673,11506.7697697936],[901854e-11,2.04505446477,26.2983197998],[1199167e-11,1.10962946234,1577.3435424478],[857223e-11,3.50849152283,398.1490034082],[779786e-11,1.17882681962,5223.6939198022],[99025e-10,5.23268072088,5884.9268465832],[753141e-11,2.53339052847,5507.5532386674],[505267e-11,4.58292599973,18849.2275499742],[492392e-11,4.20505711826,775.522611324],[356672e-11,2.91954114478,.0673103028],[284125e-11,1.89869240932,796.2980068164],[242879e-11,.34481445893,5486.777843175],[317087e-11,5.84901948512,11790.6290886588],[271112e-11,.31486255375,10977.078804699],[206217e-11,4.80646631478,2544.3144198834],[205478e-11,1.86953770281,5573.1428014331],[202318e-11,2.45767790232,6069.7767545534],[126225e-11,1.08295459501,20.7753954924],[155516e-11,.83306084617,213.299095438]],[[6283.0758499914,0,0],[.00206058863,2.67823455808,6283.0758499914],[4303419e-11,2.63512233481,12566.1516999828]],[[8721859e-11,1.07253635559,6283.0758499914]]],[[],[[.00227777722,3.4137662053,6283.0758499914],[3805678e-11,3.37063423795,12566.1516999828]]],[[[1.00013988784,0,0],[.01670699632,3.09846350258,6283.0758499914],[.00013956024,3.05524609456,12566.1516999828],[308372e-10,5.19846674381,77713.7714681205],[1628463e-11,1.17387558054,5753.3848848968],[1575572e-11,2.84685214877,7860.4193924392],[924799e-11,5.45292236722,11506.7697697936],[542439e-11,4.56409151453,3930.2096962196],[47211e-10,3.66100022149,5884.9268465832],[85831e-11,1.27079125277,161000.6857376741],[57056e-11,2.01374292245,83996.84731811189],[55736e-11,5.2415979917,71430.69561812909],[174844e-11,3.01193636733,18849.2275499742],[243181e-11,4.2734953079,11790.6290886588]],[[.00103018607,1.10748968172,6283.0758499914],[1721238e-11,1.06442300386,12566.1516999828]],[[4359385e-11,5.78455133808,6283.0758499914]]]],Mars:[[[[6.20347711581,0,0],[.18656368093,5.0503710027,3340.6124266998],[.01108216816,5.40099836344,6681.2248533996],[.00091798406,5.75478744667,10021.8372800994],[.00027744987,5.97049513147,3.523118349],[.00010610235,2.93958560338,2281.2304965106],[.00012315897,.84956094002,2810.9214616052],[8926784e-11,4.15697846427,.0172536522],[8715691e-11,6.11005153139,13362.4497067992],[6797556e-11,.36462229657,398.1490034082],[7774872e-11,3.33968761376,5621.8429232104],[3575078e-11,1.6618650571,2544.3144198834],[4161108e-11,.22814971327,2942.4634232916],[3075252e-11,.85696614132,191.4482661116],[2628117e-11,.64806124465,3337.0893083508],[2937546e-11,6.07893711402,.0673103028],[2389414e-11,5.03896442664,796.2980068164],[2579844e-11,.02996736156,3344.1355450488],[1528141e-11,1.14979301996,6151.533888305],[1798806e-11,.65634057445,529.6909650946],[1264357e-11,3.62275122593,5092.1519581158],[1286228e-11,3.06796065034,2146.1654164752],[1546404e-11,2.91579701718,1751.539531416],[1024902e-11,3.69334099279,8962.4553499102],[891566e-11,.18293837498,16703.062133499],[858759e-11,2.4009381194,2914.0142358238],[832715e-11,2.46418619474,3340.5951730476],[83272e-10,4.49495782139,3340.629680352],[712902e-11,3.66335473479,1059.3819301892],[748723e-11,3.82248614017,155.4203994342],[723861e-11,.67497311481,3738.761430108],[635548e-11,2.92182225127,8432.7643848156],[655162e-11,.48864064125,3127.3133312618],[550474e-11,3.81001042328,.9803210682],[55275e-10,4.47479317037,1748.016413067],[425966e-11,.55364317304,6283.0758499914],[415131e-11,.49662285038,213.299095438],[472167e-11,3.62547124025,1194.4470102246],[306551e-11,.38052848348,6684.7479717486],[312141e-11,.99853944405,6677.7017350506],[293198e-11,4.22131299634,20.7753954924],[302375e-11,4.48618007156,3532.0606928114],[274027e-11,.54222167059,3340.545116397],[281079e-11,5.88163521788,1349.8674096588],[231183e-11,1.28242156993,3870.3033917944],[283602e-11,5.7688543494,3149.1641605882],[236117e-11,5.75503217933,3333.498879699],[274033e-11,.13372524985,3340.6797370026],[299395e-11,2.78323740866,6254.6266625236]],[[3340.61242700512,0,0],[.01457554523,3.60433733236,3340.6124266998],[.00168414711,3.92318567804,6681.2248533996],[.00020622975,4.26108844583,10021.8372800994],[3452392e-11,4.7321039319,3.523118349],[2586332e-11,4.60670058555,13362.4497067992],[841535e-11,4.45864030426,2281.2304965106]],[[.00058152577,2.04961712429,3340.6124266998],[.00013459579,2.45738706163,6681.2248533996]]],[[[.03197134986,3.76832042431,3340.6124266998],[.00298033234,4.10616996305,6681.2248533996],[.00289104742,0,0],[.00031365539,4.4465105309,10021.8372800994],[34841e-9,4.7881254926,13362.4497067992]],[[.00217310991,6.04472194776,3340.6124266998],[.00020976948,3.14159265359,0],[.00012834709,1.60810667915,6681.2248533996]]],[[[1.53033488271,0,0],[.1418495316,3.47971283528,3340.6124266998],[.00660776362,3.81783443019,6681.2248533996],[.00046179117,4.15595316782,10021.8372800994],[8109733e-11,5.55958416318,2810.9214616052],[7485318e-11,1.77239078402,5621.8429232104],[5523191e-11,1.3643630377,2281.2304965106],[382516e-10,4.49407183687,13362.4497067992],[2306537e-11,.09081579001,2544.3144198834],[1999396e-11,5.36059617709,3337.0893083508],[2484394e-11,4.9254563992,2942.4634232916],[1960195e-11,4.74249437639,3344.1355450488],[1167119e-11,2.11260868341,5092.1519581158],[1102816e-11,5.00908403998,398.1490034082],[899066e-11,4.40791133207,529.6909650946],[992252e-11,5.83861961952,6151.533888305],[807354e-11,2.10217065501,1059.3819301892],[797915e-11,3.44839203899,796.2980068164],[740975e-11,1.49906336885,2146.1654164752]],[[.01107433345,2.03250524857,3340.6124266998],[.00103175887,2.37071847807,6681.2248533996],[128772e-9,0,0],[.0001081588,2.70888095665,10021.8372800994]],[[.00044242249,.47930604954,3340.6124266998],[8138042e-11,.86998389204,6681.2248533996]]]],Jupiter:[[[[.59954691494,0,0],[.09695898719,5.06191793158,529.6909650946],[.00573610142,1.44406205629,7.1135470008],[.00306389205,5.41734730184,1059.3819301892],[.00097178296,4.14264726552,632.7837393132],[.00072903078,3.64042916389,522.5774180938],[.00064263975,3.41145165351,103.0927742186],[.00039806064,2.29376740788,419.4846438752],[.00038857767,1.27231755835,316.3918696566],[.00027964629,1.7845459182,536.8045120954],[.0001358973,5.7748104079,1589.0728952838],[8246349e-11,3.5822792584,206.1855484372],[8768704e-11,3.63000308199,949.1756089698],[7368042e-11,5.0810119427,735.8765135318],[626315e-10,.02497628807,213.299095438],[6114062e-11,4.51319998626,1162.4747044078],[4905396e-11,1.32084470588,110.2063212194],[5305285e-11,1.30671216791,14.2270940016],[5305441e-11,4.18625634012,1052.2683831884],[4647248e-11,4.69958103684,3.9321532631],[3045023e-11,4.31676431084,426.598190876],[2609999e-11,1.56667394063,846.0828347512],[2028191e-11,1.06376530715,3.1813937377],[1764763e-11,2.14148655117,1066.49547719],[1722972e-11,3.88036268267,1265.5674786264],[1920945e-11,.97168196472,639.897286314],[1633223e-11,3.58201833555,515.463871093],[1431999e-11,4.29685556046,625.6701923124],[973272e-11,4.09764549134,95.9792272178]],[[529.69096508814,0,0],[.00489503243,4.2208293947,529.6909650946],[.00228917222,6.02646855621,7.1135470008],[.00030099479,4.54540782858,1059.3819301892],[.0002072092,5.45943156902,522.5774180938],[.00012103653,.16994816098,536.8045120954],[6067987e-11,4.42422292017,103.0927742186],[5433968e-11,3.98480737746,419.4846438752],[4237744e-11,5.89008707199,14.2270940016]],[[.00047233601,4.32148536482,7.1135470008],[.00030649436,2.929777887,529.6909650946],[.00014837605,3.14159265359,0]]],[[[.02268615702,3.55852606721,529.6909650946],[.00109971634,3.90809347197,1059.3819301892],[.00110090358,0,0],[8101428e-11,3.60509572885,522.5774180938],[6043996e-11,4.25883108339,1589.0728952838],[6437782e-11,.30627119215,536.8045120954]],[[.00078203446,1.52377859742,529.6909650946]]],[[[5.20887429326,0,0],[.25209327119,3.49108639871,529.6909650946],[.00610599976,3.84115365948,1059.3819301892],[.00282029458,2.57419881293,632.7837393132],[.00187647346,2.07590383214,522.5774180938],[.00086792905,.71001145545,419.4846438752],[.00072062974,.21465724607,536.8045120954],[.00065517248,5.9799588479,316.3918696566],[.00029134542,1.67759379655,103.0927742186],[.00030135335,2.16132003734,949.1756089698],[.00023453271,3.54023522184,735.8765135318],[.00022283743,4.19362594399,1589.0728952838],[.00023947298,.2745803748,7.1135470008],[.00013032614,2.96042965363,1162.4747044078],[970336e-10,1.90669633585,206.1855484372],[.00012749023,2.71550286592,1052.2683831884],[7057931e-11,2.18184839926,1265.5674786264],[6137703e-11,6.26418240033,846.0828347512],[2616976e-11,2.00994012876,1581.959348283]],[[.0127180152,2.64937512894,529.6909650946],[.00061661816,3.00076460387,1059.3819301892],[.00053443713,3.89717383175,522.5774180938],[.00031185171,4.88276958012,536.8045120954],[.00041390269,0,0]]]],Saturn:[[[[.87401354025,0,0],[.11107659762,3.96205090159,213.299095438],[.01414150957,4.58581516874,7.1135470008],[.00398379389,.52112032699,206.1855484372],[.00350769243,3.30329907896,426.598190876],[.00206816305,.24658372002,103.0927742186],[792713e-9,3.84007056878,220.4126424388],[.00023990355,4.66976924553,110.2063212194],[.00016573588,.43719228296,419.4846438752],[.00014906995,5.76903183869,316.3918696566],[.0001582029,.93809155235,632.7837393132],[.00014609559,1.56518472,3.9321532631],[.00013160301,4.44891291899,14.2270940016],[.00015053543,2.71669915667,639.897286314],[.00013005299,5.98119023644,11.0457002639],[.00010725067,3.12939523827,202.2533951741],[5863206e-11,.23656938524,529.6909650946],[5227757e-11,4.20783365759,3.1813937377],[6126317e-11,1.76328667907,277.0349937414],[5019687e-11,3.17787728405,433.7117378768],[459255e-10,.61977744975,199.0720014364],[4005867e-11,2.24479718502,63.7358983034],[2953796e-11,.98280366998,95.9792272178],[387367e-10,3.22283226966,138.5174968707],[2461186e-11,2.03163875071,735.8765135318],[3269484e-11,.77492638211,949.1756089698],[1758145e-11,3.2658010994,522.5774180938],[1640172e-11,5.5050445305,846.0828347512],[1391327e-11,4.02333150505,323.5054166574],[1580648e-11,4.37265307169,309.2783226558],[1123498e-11,2.83726798446,415.5524906121],[1017275e-11,3.71700135395,227.5261894396],[848642e-11,3.1915017083,209.3669421749]],[[213.2990952169,0,0],[.01297370862,1.82834923978,213.299095438],[.00564345393,2.88499717272,7.1135470008],[.00093734369,1.06311793502,426.598190876],[.00107674962,2.27769131009,206.1855484372],[.00040244455,2.04108104671,220.4126424388],[.00019941774,1.2795439047,103.0927742186],[.00010511678,2.7488034213,14.2270940016],[6416106e-11,.38238295041,639.897286314],[4848994e-11,2.43037610229,419.4846438752],[4056892e-11,2.92133209468,110.2063212194],[3768635e-11,3.6496533078,3.9321532631]],[[.0011644133,1.17988132879,7.1135470008],[.00091841837,.0732519584,213.299095438],[.00036661728,0,0],[.00015274496,4.06493179167,206.1855484372]]],[[[.04330678039,3.60284428399,213.299095438],[.00240348302,2.85238489373,426.598190876],[.00084745939,0,0],[.00030863357,3.48441504555,220.4126424388],[.00034116062,.57297307557,206.1855484372],[.0001473407,2.11846596715,639.897286314],[9916667e-11,5.79003188904,419.4846438752],[6993564e-11,4.7360468972,7.1135470008],[4807588e-11,5.43305312061,316.3918696566]],[[.00198927992,4.93901017903,213.299095438],[.00036947916,3.14159265359,0],[.00017966989,.5197943111,426.598190876]]],[[[9.55758135486,0,0],[.52921382865,2.39226219573,213.299095438],[.01873679867,5.2354960466,206.1855484372],[.01464663929,1.64763042902,426.598190876],[.00821891141,5.93520042303,316.3918696566],[.00547506923,5.0153261898,103.0927742186],[.0037168465,2.27114821115,220.4126424388],[.00361778765,3.13904301847,7.1135470008],[.00140617506,5.70406606781,632.7837393132],[.00108974848,3.29313390175,110.2063212194],[.00069006962,5.94099540992,419.4846438752],[.00061053367,.94037691801,639.897286314],[.00048913294,1.55733638681,202.2533951741],[.00034143772,.19519102597,277.0349937414],[.00032401773,5.47084567016,949.1756089698],[.00020936596,.46349251129,735.8765135318],[9796004e-11,5.20477537945,1265.5674786264],[.00011993338,5.98050967385,846.0828347512],[208393e-9,1.52102476129,433.7117378768],[.00015298404,3.0594381494,529.6909650946],[6465823e-11,.17732249942,1052.2683831884],[.00011380257,1.7310542704,522.5774180938],[3419618e-11,4.94550542171,1581.959348283]],[[.0618298134,.2584351148,213.299095438],[.00506577242,.71114625261,206.1855484372],[.00341394029,5.79635741658,426.598190876],[.00188491195,.47215589652,220.4126424388],[.00186261486,3.14159265359,0],[.00143891146,1.40744822888,7.1135470008]],[[.00436902572,4.78671677509,213.299095438]]]],Uranus:[[[[5.48129294297,0,0],[.09260408234,.89106421507,74.7815985673],[.01504247898,3.6271926092,1.4844727083],[.00365981674,1.89962179044,73.297125859],[.00272328168,3.35823706307,149.5631971346],[.00070328461,5.39254450063,63.7358983034],[.00068892678,6.09292483287,76.2660712756],[.00061998615,2.26952066061,2.9689454166],[.00061950719,2.85098872691,11.0457002639],[.0002646877,3.14152083966,71.8126531507],[.00025710476,6.11379840493,454.9093665273],[.0002107885,4.36059339067,148.0787244263],[.00017818647,1.74436930289,36.6485629295],[.00014613507,4.73732166022,3.9321532631],[.00011162509,5.8268179635,224.3447957019],[.0001099791,.48865004018,138.5174968707],[9527478e-11,2.95516862826,35.1640902212],[7545601e-11,5.236265824,109.9456887885],[4220241e-11,3.23328220918,70.8494453042],[40519e-9,2.277550173,151.0476698429],[3354596e-11,1.0654900738,4.4534181249],[2926718e-11,4.62903718891,9.5612275556],[349034e-10,5.48306144511,146.594251718],[3144069e-11,4.75199570434,77.7505439839],[2922333e-11,5.35235361027,85.8272988312],[2272788e-11,4.36600400036,70.3281804424],[2051219e-11,1.51773566586,.1118745846],[2148602e-11,.60745949945,38.1330356378],[1991643e-11,4.92437588682,277.0349937414],[1376226e-11,2.04283539351,65.2203710117],[1666902e-11,3.62744066769,380.12776796],[1284107e-11,3.11347961505,202.2533951741],[1150429e-11,.93343589092,3.1813937377],[1533221e-11,2.58594681212,52.6901980395],[1281604e-11,.54271272721,222.8603229936],[1372139e-11,4.19641530878,111.4301614968],[1221029e-11,.1990065003,108.4612160802],[946181e-11,1.19253165736,127.4717966068],[1150989e-11,4.17898916639,33.6796175129]],[[74.7815986091,0,0],[.00154332863,5.24158770553,74.7815985673],[.00024456474,1.71260334156,1.4844727083],[9258442e-11,.4282973235,11.0457002639],[8265977e-11,1.50218091379,63.7358983034],[915016e-10,1.41213765216,149.5631971346]]],[[[.01346277648,2.61877810547,74.7815985673],[623414e-9,5.08111189648,149.5631971346],[.00061601196,3.14159265359,0],[9963722e-11,1.61603805646,76.2660712756],[992616e-10,.57630380333,73.297125859]],[[.00034101978,.01321929936,74.7815985673]]],[[[19.21264847206,0,0],[.88784984413,5.60377527014,74.7815985673],[.03440836062,.32836099706,73.297125859],[.0205565386,1.7829515933,149.5631971346],[.0064932241,4.52247285911,76.2660712756],[.00602247865,3.86003823674,63.7358983034],[.00496404167,1.40139935333,454.9093665273],[.00338525369,1.58002770318,138.5174968707],[.00243509114,1.57086606044,71.8126531507],[.00190522303,1.99809394714,1.4844727083],[.00161858838,2.79137786799,148.0787244263],[.00143706183,1.38368544947,11.0457002639],[.00093192405,.17437220467,36.6485629295],[.00071424548,4.24509236074,224.3447957019],[.00089806014,3.66105364565,109.9456887885],[.00039009723,1.66971401684,70.8494453042],[.00046677296,1.39976401694,35.1640902212],[.00039025624,3.36234773834,277.0349937414],[.00036755274,3.88649278513,146.594251718],[.00030348723,.70100838798,151.0476698429],[.00029156413,3.180563367,77.7505439839],[.00022637073,.72518687029,529.6909650946],[.00011959076,1.7504339214,984.6003316219],[.00025620756,5.25656086672,380.12776796]],[[.01479896629,3.67205697578,74.7815985673]]]],Neptune:[[[[5.31188633046,0,0],[.0179847553,2.9010127389,38.1330356378],[.01019727652,.48580922867,1.4844727083],[.00124531845,4.83008090676,36.6485629295],[.00042064466,5.41054993053,2.9689454166],[.00037714584,6.09221808686,35.1640902212],[.00033784738,1.24488874087,76.2660712756],[.00016482741,7727998e-11,491.5579294568],[9198584e-11,4.93747051954,39.6175083461],[899425e-10,.27462171806,175.1660598002]],[[38.13303563957,0,0],[.00016604172,4.86323329249,1.4844727083],[.00015744045,2.27887427527,38.1330356378]]],[[[.03088622933,1.44104372644,38.1330356378],[.00027780087,5.91271884599,76.2660712756],[.00027623609,0,0],[.00015355489,2.52123799551,36.6485629295],[.00015448133,3.50877079215,39.6175083461]]],[[[30.07013205828,0,0],[.27062259632,1.32999459377,38.1330356378],[.01691764014,3.25186135653,36.6485629295],[.00807830553,5.18592878704,1.4844727083],[.0053776051,4.52113935896,35.1640902212],[.00495725141,1.5710564165,491.5579294568],[.00274571975,1.84552258866,175.1660598002],[.0001201232,1.92059384991,1021.2488945514],[.00121801746,5.79754470298,76.2660712756],[.00100896068,.3770272493,73.297125859],[.00135134092,3.37220609835,39.6175083461],[7571796e-11,1.07149207335,388.4651552382]]]]};function IS(s){var e,t,n,i,r,a,o;const c=2e3+(s-14)/yS;return c<-500?(e=(c-1820)/100,-20+32*e*e):c<500?(e=c/100,t=e*e,n=e*t,i=t*t,r=t*n,a=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*i+.022174192*r+.0090316521*a):c<1600?(e=(c-1e3)/100,t=e*e,n=e*t,i=t*t,r=t*n,a=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*i-.005050998*r+.0083572073*a):c<1700?(e=c-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):c<1800?(e=c-1700,t=e*e,n=e*t,i=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-i/1174e3):c<1860?(e=c-1800,t=e*e,n=e*t,i=t*t,r=t*n,a=n*n,o=n*i,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*i+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(e=c-1860,t=e*e,n=e*t,i=t*t,r=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*i+r/233174):c<1920?(e=c-1900,t=e*e,n=e*t,i=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*i):c<1941?(e=c-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):c<1961?(e=c-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):c<1986?(e=c-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):c<2005?(e=c-2e3,t=e*e,n=e*t,i=t*t,r=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*i+2373599e-11*r):c<2050?(e=c-2e3,62.92+.32217*e+.005589*e*e):c<2150?(e=(c-1820)/100,-20+32*e*e-.5628*(2150-c)):(e=(c-1820)/100,-20+32*e*e)}let PS=IS;function Nf(s){return s+PS(s)/86400}class Vr{constructor(e){if(e instanceof Vr){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-Pf.getTime())/t,this.tt=Nf(this.ut);return}if(Number.isFinite(e)){this.date=new Date(Pf.getTime()+e*t),this.ut=e,this.tt=Nf(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new Vr(e);for(;;){const n=e-t.tt;if(Math.abs(n)<1e-12)return t;t=t.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(e){return new Vr(this.ut+e)}}function Pt(s){return s instanceof Vr?s:new Vr(s)}function LS(s){function e(d){return d%SS*Pr}const t=s.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),i=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*t)*o+33386*c,h=(92052331+9086*t)*c+15377*o,u=2*(i-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*t)*o-13696*c,h+=(5730336-3015*t)*c-4587*o,u=2*(i+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*t)*o+2796*c,h+=(978459-485*t)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*t)*o-698*c,h+=(-897492+470*t)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*t)*o+11817*c,h+=(73871-184*t)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Xm(s){var e=s.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var Wo;function no(s){if(!Wo||Math.abs(Wo.tt-s.tt)>1e-6){const e=LS(s),t=Xm(s),n=t+e.deps/3600;Wo={tt:s.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*ut)/15,mobl:t,tobl:n}}return Wo}function NS(s,e){const t=s*ut,n=Math.cos(t),i=Math.sin(t);return[e[0],e[1]*n-e[2]*i,e[1]*i+e[2]*n]}function OS(s,e){return NS(Xm(s),e)}function US(s){const e=s.tt/36525;function t(Re,xe){const Ne=[];let Oe;for(Oe=0;Oe<=xe-Re;++Oe)Ne.push(0);return{min:Re,array:Ne}}function n(Re,xe,Ne,Oe){const Ue=[];for(let at=0;at<=xe-Re;++at)Ue.push(t(Ne,Oe));return{min:Re,array:Ue}}function i(Re,xe,Ne){const Oe=Re.array[xe-Re.min];return Oe.array[Ne-Oe.min]}function r(Re,xe,Ne,Oe){const Ue=Re.array[xe-Re.min];Ue.array[Ne-Ue.min]=Oe}let a,o,c,l,h,u,d,f,p,v,m,g,S,b,_,E,w,R,M,A,I,D,P,F=n(-6,6,1,4),H=n(-6,6,1,4);function O(Re,xe){return i(F,Re,xe)}function V(Re,xe){return i(H,Re,xe)}function z(Re,xe,Ne){return r(F,Re,xe,Ne)}function Y(Re,xe,Ne){return r(H,Re,xe,Ne)}function ee(Re,xe,Ne,Oe,Ue){Ue(Re*Ne-xe*Oe,xe*Ne+Re*Oe)}function J(Re){return Math.sin(Bi*Re)}d=e*e,p=0,P=0,m=0,g=3422.7;var ne=J(.19833+.05611*e),ae=J(.27869+.04508*e),Ve=J(.16827-.36903*e),je=J(.34734-5.37261*e),He=J(.10498-5.37899*e),K=J(.42681-.41855*e),re=J(.14943-5.37511*e);for(R=.84*ne+.31*ae+14.27*Ve+7.26*je+.28*He+.24*K,M=2.94*ne+.31*ae+14.27*Ve+9.34*je+1.12*He+.83*K,A=-6.4*ne-1.89*K,I=.21*ne+.31*ae+14.27*Ve-88.7*je-15.3*He+.24*K-1.86*re,D=R-A,f=-3332e-9*J(.59734-5.37261*e)-539e-9*J(.35498-5.37899*e)-64e-9*J(.39943-5.37511*e),S=Bi*wr(.60643382+1336.85522467*e-313e-8*d)+R/us,b=Bi*wr(.37489701+1325.55240982*e+2565e-8*d)+M/us,_=Bi*wr(.99312619+99.99735956*e-44e-8*d)+A/us,E=Bi*wr(.25909118+1342.2278298*e-892e-8*d)+I/us,w=Bi*wr(.82736186+1236.85308708*e-397e-8*d)+D/us,h=1;h<=4;++h){switch(h){case 1:c=b,o=4,l=1.000002208;break;case 2:c=_,o=3,l=.997504612-.002495388*e;break;case 3:c=E,o=4,l=1.000002708+139.978*f;break;case 4:c=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(z(0,h,1),z(1,h,Math.cos(c)*l),Y(0,h,0),Y(1,h,Math.sin(c)*l),u=2;u<=o;++u)ee(O(u-1,h),V(u-1,h),O(1,h),V(1,h),(Re,xe)=>(z(u,h,Re),Y(u,h,xe)));for(u=1;u<=o;++u)z(-u,h,O(u,h)),Y(-u,h,-V(u,h))}function ie(Re,xe,Ne,Oe){for(var Ue={x:1,y:0},at=[0,Re,xe,Ne,Oe],ot=1;ot<=4;++ot)at[ot]!==0&&ee(Ue.x,Ue.y,O(at[ot],ot),V(at[ot],ot),(Lt,Et)=>(Ue.x=Lt,Ue.y=Et));return Ue}function B(Re,xe,Ne,Oe,Ue,at,ot,Lt){var Et=ie(Ue,at,ot,Lt);p+=Re*Et.y,P+=xe*Et.y,m+=Ne*Et.x,g+=Oe*Et.x}B(13.902,14.06,-.001,.2607,0,0,0,4),B(.403,-4.01,.394,.0023,0,0,0,3),B(2369.912,2373.36,.601,28.2333,0,0,0,2),B(-125.154,-112.79,-.725,-.9781,0,0,0,1),B(1.979,6.98,-.445,.0433,1,0,0,4),B(191.953,192.72,.029,3.0861,1,0,0,2),B(-8.466,-13.51,.455,-.1093,1,0,0,1),B(22639.5,22609.07,.079,186.5398,1,0,0,0),B(18.609,3.59,-.094,.0118,1,0,0,-1),B(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),B(3.215,5.44,.192,-.0386,1,0,0,-3),B(-38.428,-38.64,.001,.6008,1,0,0,-4),B(-.393,-1.43,-.092,.0086,1,0,0,-6),B(-.289,-1.59,.123,-.0053,0,1,0,4),B(-24.42,-25.1,.04,-.3,0,1,0,2),B(18.023,17.93,.007,.1494,0,1,0,1),B(-668.146,-126.98,-1.302,-.3997,0,1,0,0),B(.56,.32,-.001,-.0037,0,1,0,-1),B(-165.145,-165.06,.054,1.9178,0,1,0,-2),B(-1.877,-6.46,-.416,.0339,0,1,0,-4),B(.213,1.02,-.074,.0054,2,0,0,4),B(14.387,14.78,-.017,.2833,2,0,0,2),B(-.586,-1.2,.054,-.01,2,0,0,1),B(769.016,767.96,.107,10.1657,2,0,0,0),B(1.75,2.01,-.018,.0155,2,0,0,-1),B(-211.656,-152.53,5.679,-.3039,2,0,0,-2),B(1.225,.91,-.03,-.0088,2,0,0,-3),B(-30.773,-34.07,-.308,.3722,2,0,0,-4),B(-.57,-1.4,-.074,.0109,2,0,0,-6),B(-2.921,-11.75,.787,-.0484,1,1,0,2),B(1.267,1.52,-.022,.0164,1,1,0,1),B(-109.673,-115.18,.461,-.949,1,1,0,0),B(-205.962,-182.36,2.056,1.4437,1,1,0,-2),B(.233,.36,.012,-.0025,1,1,0,-3),B(-4.391,-9.66,-.471,.0673,1,1,0,-4),B(.283,1.53,-.111,.006,1,-1,0,4),B(14.577,31.7,-1.54,.2302,1,-1,0,2),B(147.687,138.76,.679,1.1528,1,-1,0,0),B(-1.089,.55,.021,0,1,-1,0,-1),B(28.475,23.59,-.443,-.2257,1,-1,0,-2),B(-.276,-.38,-.006,-.0036,1,-1,0,-3),B(.636,2.27,.146,-.0102,1,-1,0,-4),B(-.189,-1.68,.131,-.0028,0,2,0,2),B(-7.486,-.66,-.037,-.0086,0,2,0,0),B(-8.096,-16.35,-.74,.0918,0,2,0,-2),B(-5.741,-.04,0,-9e-4,0,0,2,2),B(.255,0,0,0,0,0,2,1),B(-411.608,-.2,0,-.0124,0,0,2,0),B(.584,.84,0,.0071,0,0,2,-1),B(-55.173,-52.14,0,-.1052,0,0,2,-2),B(.254,.25,0,-.0017,0,0,2,-3),B(.025,-1.67,0,.0031,0,0,2,-4),B(1.06,2.96,-.166,.0243,3,0,0,2),B(36.124,50.64,-1.3,.6215,3,0,0,0),B(-13.193,-16.4,.258,-.1187,3,0,0,-2),B(-1.187,-.74,.042,.0074,3,0,0,-4),B(-.293,-.31,-.002,.0046,3,0,0,-6),B(-.29,-1.45,.116,-.0051,2,1,0,2),B(-7.649,-10.56,.259,-.1038,2,1,0,0),B(-8.627,-7.59,.078,-.0192,2,1,0,-2),B(-2.74,-2.54,.022,.0324,2,1,0,-4),B(1.181,3.32,-.212,.0213,2,-1,0,2),B(9.703,11.67,-.151,.1268,2,-1,0,0),B(-.352,-.37,.001,-.0028,2,-1,0,-1),B(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),B(.36,.2,-.012,-.0043,2,-1,0,-4),B(-1.167,-1.25,.008,-.0106,1,2,0,0),B(-7.412,-6.12,.117,.0484,1,2,0,-2),B(-.311,-.65,-.032,.0044,1,2,0,-4),B(.757,1.82,-.105,.0112,1,-2,0,2),B(2.58,2.32,.027,.0196,1,-2,0,0),B(2.533,2.4,-.014,-.0212,1,-2,0,-2),B(-.344,-.57,-.025,.0036,0,3,0,-2),B(-.992,-.02,0,0,1,0,2,2),B(-45.099,-.02,0,-.001,1,0,2,0),B(-.179,-9.52,0,-.0833,1,0,2,-2),B(-.301,-.33,0,.0014,1,0,2,-4),B(-6.382,-3.37,0,-.0481,1,0,-2,2),B(39.528,85.13,0,-.7136,1,0,-2,0),B(9.366,.71,0,-.0112,1,0,-2,-2),B(.202,.02,0,0,1,0,-2,-4),B(.415,.1,0,.0013,0,1,2,0),B(-2.152,-2.26,0,-.0066,0,1,2,-2),B(-1.44,-1.3,0,.0014,0,1,-2,2),B(.384,-.04,0,0,0,1,-2,-2),B(1.938,3.6,-.145,.0401,4,0,0,0),B(-.952,-1.58,.052,-.013,4,0,0,-2),B(-.551,-.94,.032,-.0097,3,1,0,0),B(-.482,-.57,.005,-.0045,3,1,0,-2),B(.681,.96,-.026,.0115,3,-1,0,0),B(-.297,-.27,.002,-9e-4,2,2,0,-2),B(.254,.21,-.003,0,2,-2,0,-2),B(-.25,-.22,.004,.0014,1,3,0,-2),B(-3.996,0,0,4e-4,2,0,2,0),B(.557,-.75,0,-.009,2,0,2,-2),B(-.459,-.38,0,-.0053,2,0,-2,2),B(-1.298,.74,0,4e-4,2,0,-2,0),B(.538,1.14,0,-.0141,2,0,-2,-2),B(.263,.02,0,0,1,1,2,0),B(.426,.07,0,-6e-4,1,1,-2,-2),B(-.304,.03,0,3e-4,1,-1,2,0),B(-.372,-.19,0,-.0027,1,-1,-2,2),B(.418,0,0,0,0,0,4,0),B(-.33,-.04,0,0,3,0,2,0);function Ee(Re,xe,Ne,Oe,Ue){return Re*ie(xe,Ne,Oe,Ue).y}v=0,v+=Ee(-526.069,0,0,1,-2),v+=Ee(-3.352,0,0,1,-4),v+=Ee(44.297,1,0,1,-2),v+=Ee(-6,1,0,1,-4),v+=Ee(20.599,-1,0,1,0),v+=Ee(-30.598,-1,0,1,-2),v+=Ee(-24.649,-2,0,1,0),v+=Ee(-2,-2,0,1,-2),v+=Ee(-22.571,0,1,1,-2),v+=Ee(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*e)+.31*J(.0466-125.1025*e)+.35*J(.5785-25.1042*e)+.66*J(.4591+1335.8075*e)+.64*J(.313-91.568*e)+1.14*J(.148+1331.2898*e)+.21*J(.5918+1056.5859*e)+.44*J(.5784+1322.8595*e)+.24*J(.2275-5.7374*e)+.28*J(.2965+2.6929*e)+.33*J(.3132+6.3368*e),a=E+P/us;let Pe=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Bi*wr((S+p/us)/Bi),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:us*AS/(.999953253*g)}}function qm(s,e){return[s.rot[0][0]*e[0]+s.rot[1][0]*e[1]+s.rot[2][0]*e[2],s.rot[0][1]*e[0]+s.rot[1][1]*e[1]+s.rot[2][1]*e[2],s.rot[0][2]*e[0]+s.rot[1][2]*e[1]+s.rot[2][2]*e[2]]}function Uc(s,e,t){const n=vd(e,t);return qm(n,s)}function vd(s,e){const t=s.tt/36525;let n=84381.406,i=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+n,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;n*=Pr,i*=Pr,r*=Pr,a*=Pr;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-i),h=Math.cos(-i),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,b=-f*l*c+p*d*h*c-o*p*u,_=-f*l*o+p*d*h*o+c*p*u,E=l*u,w=-u*h*c-o*d,R=-u*h*o+d*c;if(e===pn.Into2000)return new bs([[v,m,g],[S,b,_],[E,w,R]]);if(e===pn.From2000)return new bs([[v,S,E],[m,b,w],[g,_,R]]);throw"Invalid precess direction"}function FS(s){const e=.779057273264+.00273781191135448*s.ut,t=s.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let Xo;function Kc(s){if(!Xo||Xo.tt!==s.tt){const e=s.tt/36525;let t=15*no(s).ee;const n=FS(s);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;r<0&&(r+=24),Xo={tt:s.tt,st:r}}return Xo.st}function kS(s){const e=Pt(s);return Kc(e)}function Ym(s,e){const t=s.latitude*ut,n=Math.sin(t),i=Math.cos(t),r=1/Math.hypot(i,xu*n),a=wS*r,o=s.height/1e3,c=_u*r+o,l=_u*a+o,h=(15*e+s.longitude)*ut,u=Math.sin(h),d=Math.cos(h);return{pos:[c*i*d/Fs,c*i*u/Fs,l*n/Fs],vel:[-Lf*c*i*u*86400/Fs,Lf*c*i*d*86400/Fs,0]}}function wu(s,e,t){const n=Md(e,t);return qm(n,s)}function Md(s,e){const t=no(s),n=t.mobl*ut,i=t.tobl*ut,r=t.dpsi*Pr,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,p=-u*o,v=u*c,m=h*a*c+o*l,g=h*o*c-a*l,S=u*l,b=h*a*l-o*c,_=h*o*l+a*c;if(e===pn.From2000)return new bs([[d,v,S],[f,m,b],[p,g,_]]);if(e===pn.Into2000)return new bs([[d,f,p],[v,m,g],[S,b,_]]);throw"Invalid precess direction"}function xd(s,e,t){return t===pn.Into2000?Uc(wu(s,e,t),e,t):wu(Uc(s,e,t),e,t)}function zS(s,e){const t=Kc(s),n=Ym(e,t).pos;return xd(n,s,pn.Into2000)}class _t{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class _s{constructor(e,t,n,i,r,a,o){this.x=e,this.y=t,this.z=n,this.vx=i,this.vy=r,this.vz=a,this.t=o}}class $c{constructor(e,t,n){this.lat=an(e),this.lon=an(t),this.dist=an(n)}}class Au{constructor(e,t,n,i){this.ra=an(e),this.dec=an(t),this.dist=an(n),this.vec=i}}class bs{constructor(e){this.rot=e}}class BS{constructor(e,t,n,i){this.azimuth=an(e),this.altitude=an(t),this.ra=an(n),this.dec=an(i)}}class HS{constructor(e,t,n){this.vec=e,this.elat=an(t),this.elon=an(n)}}function Km(s,e){return new _t(s[0],s[1],s[2],e)}function GS(s,e){const t=Km(s,e),n=t.x*t.x+t.y*t.y,i=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new Au(0,t.z<0?-90:90,i,t)}let r=Gm*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=Pi*Math.atan2(s[2],Math.sqrt(n));return new Au(r,a,i,t)}function Wl(s,e){const t=s*ut,n=Math.cos(t),i=Math.sin(t);return[n*e[0]+i*e[1],n*e[1]-i*e[0],e[2]]}function $m(s,e,t,n,i){let r=Pt(s);_d(e),an(t),an(n);const a=Math.sin(e.latitude*ut),o=Math.cos(e.latitude*ut),c=Math.sin(e.longitude*ut),l=Math.cos(e.longitude*ut),h=Math.sin(n*ut),u=Math.cos(n*ut),d=Math.sin(t*If),f=Math.cos(t*If);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],m=[c,-l,0];const g=-15*Kc(r);let S=Wl(g,p),b=Wl(g,v),_=Wl(g,m),E=[u*f,u*d,h];const w=E[0]*S[0]+E[1]*S[1]+E[2]*S[2],R=E[0]*b[0]+E[1]*b[1]+E[2]*b[2],M=E[0]*_[0]+E[1]*_[1]+E[2]*_[2];let A=Math.hypot(R,M),I;A>0?(I=-Pi*Math.atan2(M,R),I<0&&(I+=360)):I=0;let D=Pi*Math.atan2(A,w),P=t,F=n;if(i){let H=D,O=sg(i,90-D);if(D-=O,O>0&&D>3e-4){const V=Math.sin(D*ut),z=Math.cos(D*ut),Y=Math.sin(H*ut),ee=Math.cos(H*ut),J=[];for(let ne=0;ne<3;++ne)J.push((E[ne]-ee*S[ne])/Y*V+S[ne]*z);A=Math.hypot(J[0],J[1]),A>0?(P=Gm*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,F=Pi*Math.atan2(J[2],A)}}return new BS(I,90-D,P,F)}function _d(s){if(!(s instanceof yd))throw`Not an instance of the Observer class: ${s}`;if(an(s.latitude),an(s.longitude),an(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class yd{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,_d(this)}}function VS(s){const e=Pt(s).AddDays(-1/pd),t=Xr(Di.Earth,e),n=[-t.x,-t.y,-t.z],[i,r,a]=xd(n,e,pn.From2000),o=ut*no(e).tobl,c=Math.cos(o),l=Math.sin(o),h=new _t(i,r,a,e);return Zm(h,c,l)}function WS(s,e,t,n,i){_d(t),Oc(n),Oc(i);const r=Pt(e),a=zS(r,t),o=Uu(s,r,i),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=xd(c,r,pn.From2000);return GS(l,r)}function XS(s,e,t){const n=Pt(s),i=Kc(n);let r=Ym(e,i).pos;return Km(r,n)}function Zm(s,e,t){const n=s.x,i=s.y*e+s.z*t,r=-s.y*t+s.z*e,a=Math.hypot(n,i);let o=0;a>0&&(o=Pi*Math.atan2(i,n),o<0&&(o+=360));let c=Pi*Math.atan2(r,a),l=new _t(n,i,r,s.t);return new HS(l,c,o)}function Tu(s){const e=no(s.t),t=[s.x,s.y,s.z],n=Uc(t,s.t,pn.From2000),[i,r,a]=wu(n,s.t,pn.From2000),o=new _t(i,r,a,s.t),c=e.tobl*ut;return Zm(o,Math.cos(c),Math.sin(c))}function jr(s){const e=Pt(s),t=US(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),i=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],r=OS(e,i),a=Uc(r,e,pn.Into2000);return new _t(a[0],a[1],a[2],e)}function Jm(s){const e=Pt(s),t=1e-5,n=e.AddDays(-t),i=e.AddDays(+t),r=jr(n),a=jr(i);return new _s((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*t),(a.y-r.y)/(2*t),(a.z-r.z)/(2*t),e)}function qS(s){const e=Pt(s),t=Jm(e),n=1+Wm;return new _s(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Wr(s,e,t){let n=1,i=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+e*h);let o=n*a;t&&(o%=Bi),i+=o,n*=e}return i}function Xl(s,e){let t=1,n=0,i=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+e*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}i+=r*n*c-t*o,n=t,t*=e,++r}return i}const Ra=365250,Ru=0,Du=1,Cu=2;function Iu(s){return new xn(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function jm(s,e,t){const n=t*Math.cos(e),i=Math.cos(s),r=Math.sin(s);return[n*i,n*r,t*Math.sin(e)]}function Xr(s,e){const t=e.tt/Ra,n=Wr(s[Ru],t,!0),i=Wr(s[Du],t,!1),r=Wr(s[Cu],t,!1),a=jm(n,i,r);return Iu(a).ToAstroVector(e)}function Pu(s,e){const t=e/Ra,n=Wr(s[Ru],t,!0),i=Wr(s[Du],t,!1),r=Wr(s[Cu],t,!1),a=Xl(s[Ru],t),o=Xl(s[Du],t),c=Xl(s[Cu],t),l=Math.cos(n),h=Math.sin(n),u=Math.cos(i),d=Math.sin(i),f=+(c*u*l)-r*d*l*o-r*u*h*a,p=+(c*u*h)-r*d*h*o+r*u*l*a,v=+(c*d)+r*u*o,m=jm(n,i,r),g=[f/Ra,p/Ra,v/Ra],S=Iu(m),b=Iu(g);return new $s(e,S,b)}function qo(s,e,t,n){const i=n/(n+md),r=Xr(Di[t],e);s.x+=i*r.x,s.y+=i*r.y,s.z+=i*r.z}function YS(s){const e=new _t(0,0,0,s);return qo(e,s,Se.Jupiter,yu),qo(e,s,Se.Saturn,Su),qo(e,s,Se.Uranus,bu),qo(e,s,Se.Neptune,Eu),e}const Lu=51,KS=29200,Lr=146,Hi=201,Vs=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class xn{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new xn(this.x,this.y,this.z)}ToAstroVector(e){return new _t(this.x,this.y,this.z,e)}static zero(){return new xn(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new xn(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new xn(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new xn(e*this.x,e*this.y,e*this.z)}div(e){return new xn(this.x/e,this.y/e,this.z/e)}mean(e){return new xn((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new xn(-this.x,-this.y,-this.z)}}class $s{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new $s(this.tt,this.r,this.v)}sub(e){return new $s(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function $S(s){let[e,[t,n,i],[r,a,o]]=s;return new $s(e,new xn(t,n,i),new xn(r,a,o))}function Yo(s,e,t,n){const i=n/(n+md),r=Pu(Di[t],e);return s.r.incr(r.r.mul(i)),s.v.incr(r.v.mul(i)),r}function va(s,e,t){const n=t.sub(s),i=n.quadrature();return n.mul(e/(i*Math.sqrt(i)))}class Zc{constructor(e){let t=new $s(e,new xn(0,0,0),new xn(0,0,0));this.Jupiter=Yo(t,e,Se.Jupiter,yu),this.Saturn=Yo(t,e,Se.Saturn,Su),this.Uranus=Yo(t,e,Se.Uranus,bu),this.Neptune=Yo(t,e,Se.Neptune,Eu),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new $s(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=va(e,md,this.Sun.r);return t.incr(va(e,yu,this.Jupiter.r)),t.incr(va(e,Su,this.Saturn.r)),t.incr(va(e,bu,this.Uranus.r)),t.incr(va(e,Eu,this.Neptune.r)),t}}class Jc{constructor(e,t,n,i){this.tt=e,this.r=t,this.v=n,this.a=i}clone(){return new Jc(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Qm{constructor(e,t){this.bary=e,this.grav=t}}function Fc(s,e,t,n){return new xn(e.x+s*(t.x+s*n.x/2),e.y+s*(t.y+s*n.y/2),e.z+s*(t.z+s*n.z/2))}function Of(s,e,t){return new xn(e.x+s*t.x,e.y+s*t.y,e.z+s*t.z)}function Nu(s,e){const t=s-e.tt,n=new Zc(s),i=Fc(t,e.r,e.v,e.a),r=n.Acceleration(i).mean(e.a),a=Fc(t,e.r,e.v,r),o=e.v.add(r.mul(t)),c=n.Acceleration(a),l=new Jc(s,a,o,c);return new Qm(n,l)}const ZS=[];function eg(s,e){const t=Math.floor(s);return t<0?0:t>=e?e-1:t}function Ou(s){const e=$S(s),t=new Zc(e.tt),n=e.r.add(t.Sun.r),i=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new Jc(e.tt,n,i,r);return new Qm(t,a)}function JS(s,e){const t=Vs[0][0];if(e<t||e>Vs[Lu-1][0])return null;const n=eg((e-t)/KS,Lu-1);if(!s[n]){const r=s[n]=[];r[0]=Ou(Vs[n]).grav,r[Hi-1]=Ou(Vs[n+1]).grav;let a,o=r[0].tt;for(a=1;a<Hi-1;++a)r[a]=Nu(o+=Lr,r[a-1]).grav;o=r[Hi-1].tt;var i=[];for(i[Hi-1]=r[Hi-1],a=Hi-2;a>0;--a)i[a]=Nu(o-=Lr,i[a+1]).grav;for(a=Hi-2;a>0;--a){const c=a/(Hi-1);r[a].r=r[a].r.mul(1-c).add(i[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(i[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(i[a].a.mul(c))}}return s[n]}function Uf(s,e,t){let n=Ou(s);const i=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<i;++r)n=Nu(r+1===i?e:n.grav.tt+t,n.grav);return n}function tg(s,e){let t,n,i;const r=JS(ZS,s.tt);if(r){const a=eg((s.tt-r[0].tt)/Lr,Hi-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=Fc(s.tt-o.tt,o.r,o.v,l),u=Of(s.tt-o.tt,o.v,l),d=Fc(s.tt-c.tt,c.r,c.v,l),f=Of(s.tt-c.tt,c.v,l),p=(s.tt-o.tt)/Lr;t=h.mul(1-p).add(d.mul(p)),n=u.mul(1-p).add(f.mul(p))}else{let a;s.tt<Vs[0][0]?a=Uf(Vs[0],s.tt,-Lr):a=Uf(Vs[Lu-1],s.tt,+Lr),t=a.grav.r,n=a.grav.v,i=a.bary}return i||(i=new Zc(s.tt)),t=t.sub(i.Sun.r),n=n.sub(i.Sun.v),new _s(t.x,t.y,t.z,n.x,n.y,n.z,s)}function ys(s,e){var t=Pt(e);if(s in Di)return Xr(Di[s],t);if(s===Se.Pluto){const a=tg(t);return new _t(a.x,a.y,a.z,t)}if(s===Se.Sun)return new _t(0,0,0,t);if(s===Se.Moon){var n=Xr(Di.Earth,t),i=jr(t);return new _t(n.x+i.x,n.y+i.y,n.z+i.z,t)}if(s===Se.EMB){const a=Xr(Di.Earth,t),o=jr(t),c=1+Wm;return new _t(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,t)}if(s===Se.SSB)return YS(t);const r=gd(s);if(r){const a=new $c(r.dec,15*r.ra,r.dist);return Sd(a,t)}throw`HelioVector: Unknown body "${s}"`}function jS(s,e){let t=e,n=0;for(let i=0;i<10;++i){const r=s(t),a=r.Length()/pd;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(n=Math.abs(o.tt-t.tt),n<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class QS{constructor(e,t,n,i){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=i}Position(e){this.aberration&&(this.observerPos=ys(this.observerBody,e));const t=ys(this.targetBody,e);return new _t(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function e5(s,e,t,n){Oc(n);const i=Pt(s);if(gd(t)){const o=ys(t,i);if(n){const l=n5(e,i),h=new _t(o.x-l.x,o.y-l.y,o.z-l.z,i),u=pd/h.Length();return new _t(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,i)}const c=ys(e,i);return new _t(o.x-c.x,o.y-c.y,o.z-c.z,i)}let r;n?r=new _t(0,0,0,i):r=ys(e,i);const a=new QS(e,t,n,r);return jS(o=>a.Position(o),i)}function Uu(s,e,t){Oc(t);const n=Pt(e);switch(s){case Se.Earth:return new _t(0,0,0,n);case Se.Moon:return jr(n);default:const i=e5(n,Se.Earth,s,t);return i.t=n,i}}function t5(s,e){return new _s(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,e)}function n5(s,e){const t=Pt(e);switch(s){case Se.Sun:return new _s(0,0,0,0,0,0,t);case Se.SSB:const n=new Zc(t.tt);return new _s(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case Se.Mercury:case Se.Venus:case Se.Earth:case Se.Mars:case Se.Jupiter:case Se.Saturn:case Se.Uranus:case Se.Neptune:const i=Pu(Di[s],t.tt);return t5(i,t);case Se.Pluto:return tg(t);case Se.Moon:case Se.EMB:const r=Pu(Di.Earth,t.tt),a=s==Se.Moon?Jm(t):qS(t);return new _s(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,t);default:if(gd(s)){const o=ys(s,t);return new _s(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${s}"`}}function i5(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function s5(s,e,t){if(s===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Pt(t),i=Uu(s,n,!1),r=Tu(i),a=Uu(e,n,!1),o=Tu(a);return i5(r.elon-o.elon)}function r5(s,e,t,n){let i,r=0,a=0,o=0;switch(s){case Se.Mercury:i=-.6,r=4.98,a=-4.88,o=3.02;break;case Se.Venus:e<163.6?(i=-4.47,r=1.03,a=.57,o=.13):(i=.98,r=-1.02);break;case Se.Mars:i=-1.52,r=1.6;break;case Se.Jupiter:i=-9.4,r=.5;break;case Se.Uranus:i=-7.19,r=.25;break;case Se.Neptune:i=-6.87;break;case Se.Pluto:i=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=e/100;let l=i+c*(r+c*(a+c*o));return l+=5*Math.log10(t*n),l}function a5(s,e,t,n,i){const r=Tu(n),a=ut*28.06,o=ut*(169.51+382e-7*i.tt),c=ut*r.elat,l=ut*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*s;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(e*t),{mag:d,ring_tilt:Pi*h}}function o5(s,e,t){let n=s*ut,i=n*n,r=i*i,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/Fs;let c=t/o;return a+=5*Math.log10(e*c),a}class c5{constructor(e,t,n,i,r,a,o,c){this.time=e,this.mag=t,this.phase_angle=n,this.helio_dist=i,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ut*n))/2}}function ng(s,e){if(s===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Pt(e),n=Xr(Di.Earth,t);let i,r,a,o;s===Se.Sun?(a=new _t(-n.x,-n.y,-n.z,t),r=new _t(0,0,0,t),i=0):(s===Se.Moon?(a=jr(t),r=new _t(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=ys(s,e),a=new _t(r.x-n.x,r.y-n.y,r.z-n.z,t)),i=TS(a,r));let c=a.Length(),l=r.Length(),h;if(s===Se.Sun)o=ES+5*Math.log10(c);else if(s===Se.Moon)o=o5(i,l,c);else if(s===Se.Saturn){const u=a5(i,l,c,a,t);o=u.mag,h=u.ring_tilt}else o=r5(s,i,l,c);return new c5(t,o,i,l,c,a,r,h)}function l5(s){return s5(Se.Moon,Se.Sun,s)}var Ff;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(Ff||(Ff={}));function ig(s,e){return new bs([[e.rot[0][0]*s.rot[0][0]+e.rot[1][0]*s.rot[0][1]+e.rot[2][0]*s.rot[0][2],e.rot[0][1]*s.rot[0][0]+e.rot[1][1]*s.rot[0][1]+e.rot[2][1]*s.rot[0][2],e.rot[0][2]*s.rot[0][0]+e.rot[1][2]*s.rot[0][1]+e.rot[2][2]*s.rot[0][2]],[e.rot[0][0]*s.rot[1][0]+e.rot[1][0]*s.rot[1][1]+e.rot[2][0]*s.rot[1][2],e.rot[0][1]*s.rot[1][0]+e.rot[1][1]*s.rot[1][1]+e.rot[2][1]*s.rot[1][2],e.rot[0][2]*s.rot[1][0]+e.rot[1][2]*s.rot[1][1]+e.rot[2][2]*s.rot[1][2]],[e.rot[0][0]*s.rot[2][0]+e.rot[1][0]*s.rot[2][1]+e.rot[2][0]*s.rot[2][2],e.rot[0][1]*s.rot[2][0]+e.rot[1][1]*s.rot[2][1]+e.rot[2][1]*s.rot[2][2],e.rot[0][2]*s.rot[2][0]+e.rot[1][2]*s.rot[2][1]+e.rot[2][2]*s.rot[2][2]]])}function Sd(s,e){e=Pt(e);const t=s.lat*ut,n=s.lon*ut,i=s.dist*Math.cos(t);return new _t(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(t),e)}function bd(s){const e=h5(s);return new Au(e.lon/15,e.lat,e.dist,s)}function h5(s){const e=s.x*s.x+s.y*s.y,t=Math.sqrt(e+s.z*s.z);let n,i;if(e===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=Pi*Math.atan2(s.y,s.x),i<0&&(i+=360),n=Pi*Math.atan2(s.z,Math.sqrt(e));return new $c(n,i,t)}function sg(s,e){let t;if(an(e),e<-90||e>90)return 0;if(s==="normal"||s==="jplhor"){let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*ut)/60,s==="normal"&&e<-1&&(t*=(e+90)/89)}else if(!s)t=0;else throw`Invalid refraction option: ${s}`;return t}function qr(s,e){return new _t(s.rot[0][0]*e.x+s.rot[1][0]*e.y+s.rot[2][0]*e.z,s.rot[0][1]*e.x+s.rot[1][1]*e.y+s.rot[2][1]*e.z,s.rot[0][2]*e.x+s.rot[1][2]*e.y+s.rot[2][2]*e.z,e.t)}function u5(){return new bs([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function d5(){return new bs([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function rg(s){s=Pt(s);const e=vd(s,pn.From2000),t=Md(s,pn.From2000);return ig(e,t)}function f5(s){s=Pt(s);const e=Md(s,pn.Into2000),t=vd(s,pn.Into2000);return ig(e,t)}function p5(s){const t=no(Pt(s)).tobl*ut,n=Math.cos(t),i=Math.sin(t);return new bs([[1,0,0],[0,+n,+i],[0,-i,+n]])}var kf;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(kf||(kf={}));var zf;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(zf||(zf={}));const m5=["Venus","Mars","Jupiter","Saturn"];function ag(s){return new yd(s.lat,s.lng,s.elevationM)}function Ed(s,e,t,n,i=!0){const r=$m(t,ag(n),s,e,i?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}class ri{up;north;west;constructor(e,t){const n=Pt(e),i=Math.sin(t.lat*Gi),r=Math.cos(t.lat*Gi),a=Math.sin(t.lng*Gi),o=Math.cos(t.lng*Gi),c=-15*kS(n),l=f5(n);this.up=ri.rotate(l,ri.spin(c,[r*o,r*a,i]),n),this.north=ri.rotate(l,ri.spin(c,[-i*o,-i*a,r]),n),this.west=ri.rotate(l,ri.spin(c,[a,-o,0]),n)}static ofJ2000(e,t,n,i,r=!0){const a=Pt(n),o=Sd(new $c(t,e*15,1),a),c=bd(qr(rg(a),o));return Ed(c.ra,c.dec,n,i,r)}position(e,t){const n=Math.sin(t*Gi),i=Math.cos(t*Gi),r=Math.sin(e*Hf),a=Math.cos(e*Hf),o=i*a,c=i*r,l=n,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-Bf*Math.atan2(d,u),p<0&&(p+=360));let v=Bf*Math.atan2(f,h);return v-=sg("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(e,[t,n,i]){const r=Math.cos(e*Gi),a=Math.sin(e*Gi);return[r*t+a*n,r*n-a*t,i]}static rotate(e,[t,n,i],r){const a=qr(e,new _t(t,n,i,r));return[a.x,a.y,a.z]}}const Gi=Math.PI/180,Bf=180/Math.PI,Hf=15*Gi;function ql(s,e,t){const n=ag(t),i=WS(Se[s],e,n,!0,!0),r=$m(e,n,i.ra,i.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Yl(s,e){return ng(Se[s],e).mag}function g5(s){const e=l5(s),t=ng(Se.Moon,s);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const v5=2e3,M5=3,x5=20;function Ko(s,e,t){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??v5,r=s.month??(n?1:M5),a=s.day??(n?1:x5),o=t??Math.round(e/15);return new Date(Date.UTC(i,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class Ms{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Ms.patch(t.fragmentShader)}}static patch(e){return e.replace(Ms.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
5180
5180
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
5181
5181
  if ( distanceFromCentre > ${Ms.RIM.toFixed(2)} ) discard;
5182
5182
  float glare = 1.0 - smoothstep( ${Ms.CORE.toFixed(2)}, ${Ms.RIM.toFixed(2)}, distanceFromCentre );
@@ -5280,7 +5280,7 @@ void main() {
5280
5280
  float blur = max(vNearBlur, vHaze);
5281
5281
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${C5.toFixed(2)}));
5282
5282
  }
5283
- `;function L5(s){let e=s;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const N5=.14,Vf=4.5;let $o;function O5(){if($o)return $o;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createImageData(s,s),i=s/2,r=s*N5,a=s-r;for(let o=0;o<s;o++)for(let c=0;c<s;c++){const l=c+.5-i,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*Vf*Vf)),f=(o*s+c)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,d))}return t.putImageData(n,0,0),$o=new Li(e),$o}function U5(s){const e=L5(s.seed),t=new Float32Array(s.count*3),n=new Float32Array(s.count),i=s.radiusM;for(let l=0;l<s.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*s.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*s.heightM,t[l*3+2]=Math.sin(h)*u,n[l]=.85+e()*.3}const r=new yt;r.setAttribute("position",new rt(t,3)),r.setAttribute("aSpeed",new rt(n,1)),r.setDrawRange(0,s.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:s.overallSpeed},uPixelSize:{value:s.pixelSize},uOpacity:{value:s.opacity},uColor:{value:s.color},uUvSquash:{value:1},uSpeedStreak:{value:s.speedStreak},uWindOffset:{value:new Ae(0,0)},uDropVelocity:{value:new C(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:i},uTexture:{value:O5()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new Rt({uniforms:a,vertexShader:I5,fragmentShader:P5,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Na(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}class Zs{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return Zs.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(Zs.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class Qe{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(e,t){return this.radianceTowards(e,t)*Qe.anchor()}static anchor(){return Zs.fromMagPerArcsec2(Qe.PEAK_MAG_PER_ARCSEC2)/Qe.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const n=e*Math.PI/180,i=t*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=Math.cos(i)*Math.sin(n),o=Math.sin(i);let c=0,l=0,h=0;const u=Math.log(Qe.NEAR_LIMIT_KPC),d=Math.log(Qe.FAR_LIMIT_KPC)-u;for(let f=0;f<Qe.STEPS;f++){const p=Math.exp(u+d*f/(Qe.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=Qe.SUN_RADIUS_KPC+m*r,S=m*a,b=Qe.SUN_HEIGHT_KPC+m*o,_=Math.hypot(g,S),E=Math.exp(-(_-Qe.SUN_RADIUS_KPC)/Qe.DISK_SCALE_LENGTH_KPC-Math.abs(b)/Qe.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(_,b/Qe.BULGE_FLATTENING),R=Qe.BULGE_TO_LOCAL_DISK*Math.exp(-w/Qe.BULGE_SCALE_KPC);if(c+=(E+R)*v*10**(-.4*l),l+=Qe.EXTINCTION_MAG_PER_KPC*Math.exp(-(_-Qe.SUN_RADIUS_KPC)/Qe.DUST_SCALE_LENGTH_KPC-(Math.abs(b)-Qe.SUN_HEIGHT_KPC)/Qe.DUST_SCALE_HEIGHT_KPC)*v,l>Qe.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(Qe.LONGITUDE_STEPS*Qe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Qe.LATITUDE_STEPS}walk(e){const t=Qe.LONGITUDE_STEPS,n=Math.min(Qe.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const i=Zs.latitudeOfRowCoord((this.walked+.5)/Qe.LATITUDE_STEPS);for(let r=0;r<t;r++)this.values[this.walked*t+r]=this.radianceTowards(360*(r+.5)/t,i)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const i of this.values)i<e&&(e=i);const t=Qe.anchor(),n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-e)*t;return{width:Qe.LONGITUDE_STEPS,height:Qe.LATITUDE_STEPS,data:n}}}class Dt{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(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Dt.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const n=e*Math.PI/180,i=t*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=-Math.cos(i)*Math.sin(n),o=Math.sin(i),c=-r;let l=0,h=0;const u=Math.log(Dt.NEAR_LIMIT_AU),d=Math.log(Dt.FAR_LIMIT_AU)-u;for(let f=0;f<Dt.STEPS;f++){const p=Math.exp(u+d*f/(Dt.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*r,S=m*a,b=m*o,_=Math.hypot(g,S,b);if(_<Dt.SUBLIMATION_AU)continue;const E=b/_,w=_**-1.3*Math.exp(-2.6*Math.abs(E)),R=(c-m)/_;l+=w*this.scattering(R)*v/(_*_)}return l}scattering(e){let t=0;for(let n=0;n<Dt.LOBE_ASYMMETRY.length;n++){const i=Dt.LOBE_ASYMMETRY[n],r=1+i*i-2*i*e;t+=Dt.LOBE_WEIGHT[n]*(1-i*i)/(4*Math.PI*r**1.5)}return t}values=new Float32Array(Dt.LONGITUDE_STEPS*Dt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Dt.LATITUDE_STEPS}walk(e){const t=Dt.LONGITUDE_STEPS,n=Math.min(Dt.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const i=Zs.latitudeOfRowCoord((this.walked+.5)/Dt.LATITUDE_STEPS);for(let r=0;r<t;r++){const a=Zs.angleOfColumnCoord((r+.5)/t);this.values[this.walked*t+r]=this.radianceTowards(a,i)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const i of this.values)i<t&&(t=i);const n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-t)*e;return{width:Dt.LONGITUDE_STEPS,height:Dt.LATITUDE_STEPS,data:n}}}class Ge{static get NANOLAMBERTS_PER_S10(){return Ge.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Ge.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(e,t)=>{const n=-4-t;return{sunAltitudeDeg:n,magPerArcsec2:Ge.patatV(n)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(e){const t=90-e-95;return 11.84+1.518*t-.057*t*t}static moonlessMagPerArcsec2(e){const t=Ge.TWILIGHT;for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];if(e<=i.sunAltitudeDeg&&e>=r.sunAltitudeDeg){const a=(i.sunAltitudeDeg-e)/(i.sunAltitudeDeg-r.sunAltitudeDeg);return i.magPerArcsec2+(r.magPerArcsec2-i.magPerArcsec2)*a}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Ge.NANOLAMBERT_OFFSET-Ge.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Ge.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Ge.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Ge.EXTINCTION_PER_AIR_MASS*Ge.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Ge.toNanolamberts(Ge.moonlessMagPerArcsec2(e))-Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Ge.scatteringAt(90-e)*Ge.scatteredFraction(90);return Ge.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,n,i){return Ge.scatteringAt(n)*Ge.moonOutput(e,t)*Ge.scatteredFraction(i)}static moonOutput(e,t){if(t<=0)return 0;const n=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Ge.EXTINCTION_PER_AIR_MASS*Ge.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,n){const i=Ge.scatteredFraction(n),r=Ge.scatteringAt(e.separationDeg)*Ge.twilightOutput(e.altitudeDeg)*i,a=Ge.scatteringAt(t.separationDeg)*Ge.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*i;return Ge.fromNanolamberts(Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class ps{static RADIUS=890;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;maps=ks.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=ps.buildTexture(this.milkyWayTexels,Qe.LONGITUDE_STEPS,Qe.LATITUDE_STEPS,Wa),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=ps.buildTexture(this.zodiacalTexels,Dt.LONGITUDE_STEPS,Dt.LATITUDE_STEPS,An),this.material=new Rt({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new ze},uEclipticPole:{value:new C(0,1,0)},uSunLongitude:{value:new C(1,0,0)},uMoonDirection:{value:new C(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new C(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new C(0,0,0)},uMilkyWayTint:{value:new C(...ps.MILKY_WAY_TINT)},uZodiacalTint:{value:new C(...ps.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
5283
+ `;function L5(s){let e=s;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const N5=.14,Vf=4.5;let $o;function O5(){if($o)return $o;const s=128,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createImageData(s,s),i=s/2,r=s*N5,a=s-r;for(let o=0;o<s;o++)for(let c=0;c<s;c++){const l=c+.5-i,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*Vf*Vf)),f=(o*s+c)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,d))}return t.putImageData(n,0,0),$o=new Li(e),$o}function U5(s){const e=L5(s.seed),t=new Float32Array(s.count*3),n=new Float32Array(s.count),i=s.radiusM;for(let l=0;l<s.count;l++){const h=e()*Math.PI*2,u=Math.sqrt(e())*s.radiusM;t[l*3]=Math.cos(h)*u,t[l*3+1]=e()*s.heightM,t[l*3+2]=Math.sin(h)*u,n[l]=.85+e()*.3}const r=new yt;r.setAttribute("position",new rt(t,3)),r.setAttribute("aSpeed",new rt(n,1)),r.setDrawRange(0,s.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:s.overallSpeed},uPixelSize:{value:s.pixelSize},uOpacity:{value:s.opacity},uColor:{value:s.color},uUvSquash:{value:1},uSpeedStreak:{value:s.speedStreak},uWindOffset:{value:new Ae(0,0)},uDropVelocity:{value:new C(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:i},uTexture:{value:O5()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new Rt({uniforms:a,vertexShader:I5,fragmentShader:P5,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Na(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}class Zs{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(e){return Zs.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(e,1e-12))}static fromMagPerArcsec2(e){return 10**(.4*(Zs.S10_MAG_PER_ARCSEC2-e))}static latitudeOfRowCoord(e){const t=2*e-1;return 90*Math.sign(t)*t*t}static rowCoordOfLatitude(e){return(Math.sign(e)*Math.sqrt(Math.min(Math.abs(e),90)/90)+1)/2}static angleOfColumnCoord(e){return 180*e*e}static columnCoordOfAngle(e){return Math.sqrt(Math.min(Math.max(e,0),180)/180)}}class Qe{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(e,t){return this.radianceTowards(e,t)*Qe.anchor()}static anchor(){return Zs.fromMagPerArcsec2(Qe.PEAK_MAG_PER_ARCSEC2)/Qe.PEAK_RADIANCE}radianceTowards(e,t){return this.trace(e,t).light}extinctionTowards(e,t){return this.trace(e,t).extinctionMag}trace(e,t){const n=e*Math.PI/180,i=t*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=Math.cos(i)*Math.sin(n),o=Math.sin(i);let c=0,l=0,h=0;const u=Math.log(Qe.NEAR_LIMIT_KPC),d=Math.log(Qe.FAR_LIMIT_KPC)-u;for(let f=0;f<Qe.STEPS;f++){const p=Math.exp(u+d*f/(Qe.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=Qe.SUN_RADIUS_KPC+m*r,S=m*a,b=Qe.SUN_HEIGHT_KPC+m*o,_=Math.hypot(g,S),E=Math.exp(-(_-Qe.SUN_RADIUS_KPC)/Qe.DISK_SCALE_LENGTH_KPC-Math.abs(b)/Qe.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(_,b/Qe.BULGE_FLATTENING),R=Qe.BULGE_TO_LOCAL_DISK*Math.exp(-w/Qe.BULGE_SCALE_KPC);if(c+=(E+R)*v*10**(-.4*l),l+=Qe.EXTINCTION_MAG_PER_KPC*Math.exp(-(_-Qe.SUN_RADIUS_KPC)/Qe.DUST_SCALE_LENGTH_KPC-(Math.abs(b)-Qe.SUN_HEIGHT_KPC)/Qe.DUST_SCALE_HEIGHT_KPC)*v,l>Qe.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(Qe.LONGITUDE_STEPS*Qe.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Qe.LATITUDE_STEPS}walk(e){const t=Qe.LONGITUDE_STEPS,n=Math.min(Qe.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const i=Zs.latitudeOfRowCoord((this.walked+.5)/Qe.LATITUDE_STEPS);for(let r=0;r<t;r++)this.values[this.walked*t+r]=this.radianceTowards(360*(r+.5)/t,i)}}harvest(){let e=Number.POSITIVE_INFINITY;for(const i of this.values)i<e&&(e=i);const t=Qe.anchor(),n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-e)*t;return{width:Qe.LONGITUDE_STEPS,height:Qe.LATITUDE_STEPS,data:n}}}class Dt{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(e,t){return this.radianceTowards(e,t)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Dt.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(e,t){const n=e*Math.PI/180,i=t*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=-Math.cos(i)*Math.sin(n),o=Math.sin(i),c=-r;let l=0,h=0;const u=Math.log(Dt.NEAR_LIMIT_AU),d=Math.log(Dt.FAR_LIMIT_AU)-u;for(let f=0;f<Dt.STEPS;f++){const p=Math.exp(u+d*f/(Dt.STEPS-1)),v=p-h;h=p;const m=p-v/2,g=1+m*r,S=m*a,b=m*o,_=Math.hypot(g,S,b);if(_<Dt.SUBLIMATION_AU)continue;const E=b/_,w=_**-1.3*Math.exp(-2.6*Math.abs(E)),R=(c-m)/_;l+=w*this.scattering(R)*v/(_*_)}return l}scattering(e){let t=0;for(let n=0;n<Dt.LOBE_ASYMMETRY.length;n++){const i=Dt.LOBE_ASYMMETRY[n],r=1+i*i-2*i*e;t+=Dt.LOBE_WEIGHT[n]*(1-i*i)/(4*Math.PI*r**1.5)}return t}values=new Float32Array(Dt.LONGITUDE_STEPS*Dt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Dt.LATITUDE_STEPS}walk(e){const t=Dt.LONGITUDE_STEPS,n=Math.min(Dt.LATITUDE_STEPS,this.walked+e);for(;this.walked<n;this.walked++){const i=Zs.latitudeOfRowCoord((this.walked+.5)/Dt.LATITUDE_STEPS);for(let r=0;r<t;r++){const a=Zs.angleOfColumnCoord((r+.5)/t);this.values[this.walked*t+r]=this.radianceTowards(a,i)}}}harvest(){const e=this.anchor();let t=Number.POSITIVE_INFINITY;for(const i of this.values)i<t&&(t=i);const n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-t)*e;return{width:Dt.LONGITUDE_STEPS,height:Dt.LATITUDE_STEPS,data:n}}}class Ge{static get NANOLAMBERTS_PER_S10(){return Ge.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(e){return e*Ge.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},...Array.from({length:15},(e,t)=>{const n=-4-t;return{sunAltitudeDeg:n,magPerArcsec2:Ge.patatV(n)}}),{sunAltitudeDeg:-24,magPerArcsec2:22}];static patatV(e){const t=90-e-95;return 11.84+1.518*t-.057*t*t}static moonlessMagPerArcsec2(e){const t=Ge.TWILIGHT;for(let n=0;n<t.length-1;n++){const i=t[n],r=t[n+1];if(e<=i.sunAltitudeDeg&&e>=r.sunAltitudeDeg){const a=(i.sunAltitudeDeg-e)/(i.sunAltitudeDeg-r.sunAltitudeDeg);return i.magPerArcsec2+(r.magPerArcsec2-i.magPerArcsec2)*a}}return e>0?t[0].magPerArcsec2:t[t.length-1].magPerArcsec2}static toNanolamberts(e){return 34.08*Math.exp(Ge.NANOLAMBERT_OFFSET-Ge.PER_MAGNITUDE*e)}static fromNanolamberts(e){return(Ge.NANOLAMBERT_OFFSET-Math.log(Math.max(e,1e-6)/34.08))/Ge.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(e){const t=Math.cos(Math.max(e,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*t*t,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(e){const t=Math.min(Math.max(e,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(t)**2)+10**(6.15-Math.min(e,180)/40)}static scatteredFraction(e){return 1-10**(-.4*Ge.EXTINCTION_PER_AIR_MASS*Ge.airMass(e))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(e){return Math.max(0,Ge.toNanolamberts(Ge.moonlessMagPerArcsec2(e))-Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(e){const t=Ge.scatteringAt(90-e)*Ge.scatteredFraction(90);return Ge.twilightExcessNanolamberts(e)/t}static moonNanolamberts(e,t,n,i){return Ge.scatteringAt(n)*Ge.moonOutput(e,t)*Ge.scatteredFraction(i)}static moonOutput(e,t){if(t<=0)return 0;const n=Math.min(Math.abs(e),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Ge.EXTINCTION_PER_AIR_MASS*Ge.airMass(t))}static phaseAngleOf(e){return Math.acos(Math.min(Math.max(2*e-1,-1),1))*180/Math.PI}static magPerArcsec2(e,t,n){const i=Ge.scatteredFraction(n),r=Ge.scatteringAt(e.separationDeg)*Ge.twilightOutput(e.altitudeDeg)*i,a=Ge.scatteringAt(t.separationDeg)*Ge.moonOutput(t.phaseAngleDeg,t.altitudeDeg)*i;return Ge.fromNanolamberts(Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class ps{static RADIUS=890;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;maps=ks.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=ps.buildTexture(this.milkyWayTexels,Qe.LONGITUDE_STEPS,Qe.LATITUDE_STEPS,Wa),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=ps.buildTexture(this.zodiacalTexels,Dt.LONGITUDE_STEPS,Dt.LATITUDE_STEPS,An),this.material=new Rt({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new Be},uEclipticPole:{value:new C(0,1,0)},uSunLongitude:{value:new C(1,0,0)},uMoonDirection:{value:new C(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new C(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new C(0,0,0)},uMilkyWayTint:{value:new C(...ps.MILKY_WAY_TINT)},uZodiacalTint:{value:new C(...ps.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
5284
5284
  varying vec3 vDirection;
5285
5285
  void main() {
5286
5286
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5948,7 +5948,7 @@ void main()
5948
5948
  // values — and encoded only at the very end. See colorSpace.ts.
5949
5949
  gl_FragColor = vec4(forDestination(total / weight), colour.a);
5950
5950
  }
5951
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new ui(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,n,i){const r=this.material.uniforms;r.uApertureMm2.value=e*e/Math.max(.1,t),r.uFocusDistance.value=Math.max(0,n),r.uFocalLengthMm.value=e,r.uPixelsPerMm.value=this.height/Math.max(.1,i)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,n,i){const r=this.material.uniforms;r.uNear.value=n.near,r.uFar.value=n.far;const a=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,n),i?.(),e.setRenderTarget(a),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class wt{static MIN_RATIO=1;static STEP=.25;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(e,t){this.maxRatio=wt.clamp(e),this.ratio=this.maxRatio,this.timer=t?kc.create(t):void 0}get pixelRatio(){return this.ratio}get timesGpu(){return this.timer!==void 0}set maximum(e){this.maxRatio=wt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio)}get maximum(){return this.maxRatio}beginDrawing(){this.timer?.begin()}endDrawing(){this.timer?.end()}reset(){this.intervalMs=void 0,this.probe=void 0,this.timer?.reset()}update(e,t){const n=this.timer?.poll();if(!(this.timer&&n===void 0))return n!==void 0?this.followGpu(e,n):this.followIntervals(e,t)}followGpu(e,t){if(t>wt.GPU_LATE_MS)return this.lower(e,wt.LOWER_COOLDOWN_MS);if(t<wt.GPU_ROOM_MS)return this.raise(e,wt.RAISE_COOLDOWN_MS)}followIntervals(e,t){if(!(t>0)||t>1e3)return;this.intervalMs=this.intervalMs===void 0?t:this.intervalMs*.9+t*.1;const n=this.intervalMs>wt.INTERVAL_LATE_MS;if(this.probe){if(n)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+wt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=wt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+wt.PROBE_EVERY_MS);return}if(n){const i=this.lower(e,wt.LOWER_COOLDOWN_MS);return i!==void 0&&(this.nextProbeMs=e+wt.PROBE_EVERY_MS),i}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=wt.RAISE_COOLDOWN_MS){const i=this.ratio,r=this.raise(e,0);return r!==void 0&&(this.probe={sinceMs:e,ratioBefore:i}),r}}lower(e,t){if(!(this.ratio<=wt.MIN_RATIO||e-this.lastChangeMs<t))return this.ratio=wt.clamp(this.ratio-wt.STEP),this.lastChangeMs=e,this.ratio}raise(e,t){if(!(this.ratio>=this.maxRatio||e-this.lastChangeMs<t))return this.ratio=Math.min(this.maxRatio,wt.clamp(this.ratio+wt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(wt.MIN_RATIO,Math.round(e/wt.STEP)*wt.STEP):wt.MIN_RATIO}}class kc{constructor(e,t){this.gl=e,this.extension=t}static IN_FLIGHT_MAX=8;static create(e){if(!(e instanceof WebGL2RenderingContext))return;const t=e.getExtension("EXT_disjoint_timer_query_webgl2");return t?new kc(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=kc.IN_FLIGHT_MAX))try{const e=this.gl.createQuery();if(!e)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,e),this.active=e}catch{this.active=void 0}}end(){if(this.active){try{this.gl.endQuery(this.extension.TIME_ELAPSED_EXT),this.pending.push(this.active)}catch{}this.active=void 0}}poll(){const e=this.gl;try{for(let t=0;t<this.pending.length;t++){const n=this.pending[t];if(!e.getQueryParameter(n,e.QUERY_RESULT_AVAILABLE))continue;if(!e.getParameter(this.extension.GPU_DISJOINT_EXT)){const r=e.getQueryParameter(n,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?r:this.smoothedMs*.8+r*.2}e.deleteQuery(n),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class it{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const e=it.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const n=e*Math.PI/180,i=t*Math.sin(n/2);return i>1?Number.NaN:(2*Math.asin(i)-n)*180/Math.PI}static effectiveIndex(e,t){const n=t*Math.PI/180,i=Math.cos(n);return i<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(n)**2)/i}static parheliaAzimuthDeg(e,t=it.ICE_INDEX_RED){const n=it.minimumDeviationDeg(it.SIDE_PRISM_ANGLE_DEG,it.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=it.ICE_INDEX_RED){const n=it.parheliaAzimuthDeg(e,t);if(n===void 0)return;const i=e*Math.PI/180,r=Math.sin(i)**2,a=Math.cos(i)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=it.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=it.ICE_INDEX_RED){if(e<0||e>90-it.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(e*Math.PI/180),i=Math.sqrt(t*t-n*n);if(!(i>=1))return Math.asin(i)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return it.ringOf("halo22",it.SIDE_PRISM_ANGLE_DEG)}static halo46(){return it.ringOf("halo46",it.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=it.minimumDeviationDeg(t,it.ICE_INDEX_RED),i=it.minimumDeviationDeg(t,it.ICE_INDEX_BLUE);return{id:e,angleDeg:(n+i)/2,redAngleDeg:n,blueAngleDeg:i}}static strength(e,t,n=90,i=0){const r=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t))),o=n>=0?1:i<=0?0:Math.max(0,1+n/i);return r*a*o}static formsAt(e,t=0){if(e<=-t)return[];const n=[it.halo22(),it.halo46()],i=e>0?it.parheliaDistanceDeg(e):void 0;i!==void 0&&n.push({id:"parhelia",angleDeg:i,redAngleDeg:i,blueAngleDeg:it.parheliaDistanceDeg(e,it.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:it.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const r=it.circumzenithalAltitudeDeg(e);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),e>it.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<it.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Pn{static get WATER_INDEX_RED(){return tn.indexAt(tn.RED_NM)}static get WATER_INDEX_BLUE(){return tn.indexAt(tn.BLUE_NM)}static radiusDeg(e,t){const n=(t*t-1)/(e*e-1);if(n<0||n>1)return Number.NaN;const i=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(i)/t),a=2*(i-r)+(e-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return Pn.bowOf("primary",2,0)}static secondary(){return Pn.bowOf("secondary",3,0)}static bowOf(e,t,n){const i=Pn.radiusDeg(t,Pn.WATER_INDEX_RED),r=Pn.radiusDeg(t,Pn.WATER_INDEX_BLUE),a=(i+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:i,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:Pn.primary().redRadiusDeg,toDeg:Pn.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[Pn.bowOf("primary",2,e),Pn.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-Pn.FULL_MOON_MAGNITUDE)))}static strength(e,t,n){if(n<=0)return 0;const i=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t)));return i*r}}class zn{constructor(e){this.radius=e;const t=zn.SEGMENTS*zn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new yt;n.setAttribute("position",new rt(this.positions,3)),n.setAttribute("color",new rt(this.colors,3)),n.setDrawRange(0,0),this.object=new We(n,new Jn({vertexColors:!0,transparent:!0,blending:Gn,depthWrite:!1,fog:!1,side:ai})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=zn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(zn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(e,t,n){this.head=e&&nn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&nn(t.altitudeDeg,t.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,n=this.tip;if(!t||!n||this.brightness<=0){e.setDrawRange(0,0);return}const i=this.angleBetween(t,n);if(i<=0){e.setDrawRange(0,0);return}const r=i*zn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(zn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**zn.FADE_POWER;let l=0;for(let h=1;h<zn.POINTS;h++){const u=(h-1)/zn.SEGMENTS,d=h/zn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let l=0;l<zn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,i,h),f=this.across(n,c,r,h),p=this.across(t,c,i,u),v=this.across(n,c,r,u),m=(g,S)=>g===0?S:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,a))}return e}across(e,t,n,i){return{x:e.x+t.x*n*i,y:e.y+t.y*n*i,z:e.z+t.z*n*i}}push(e,t,n){const i=e*3;this.positions[i]=t.x,this.positions[i+1]=t.y,this.positions[i+2]=t.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.55,this.colors[i+1]=r*.75,this.colors[i+2]=r,e+1}slerp(e,t,n){const i=this.angleBetweenRadians(e,t);if(i<1e-9)return e;const r=Math.sin(i),a=Math.sin((1-n)*i)/r,o=Math.sin(n*i)/r;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const n=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class H5{object=new rn;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=fd.map(t=>{const n=new ad({vertexColors:!0,size:t.size,sizeAttenuation:!1,fog:!1});Ms.apply(n);const i=new Na(new yt,n);return i.frustumCulled=!1,this.object.add(i),i})}set(e,t,n){const i=this.tiers.map(()=>[]);this.drawn=[];for(const r of e){const a=n(r.position);if(a<=0)continue;const o=r.magnitude-2.5*Math.log10(a);if(o>t)continue;const c=Aa(o,t),l=Hm(c),{x:h,y:u,z:d}=nn(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),f=ds(r.position.altitudeDeg),p=Ta(c);i[l].push({x:h,y:u,z:d,r:p*f[0],g:p*f[1],b:p*f[2]}),this.drawn.push({satellite:r,direction:new C(h,u,d).normalize()})}this.tiers.forEach((r,a)=>{const o=i[a],c=new Float32Array(o.length*3),l=new Float32Array(o.length*3);o.forEach((u,d)=>{c.set([u.x,u.y,u.z],d*3),l.set([u.r,u.g,u.b],d*3)}),r.geometry.dispose();const h=new yt;h.setAttribute("position",new rt(c,3)),h.setAttribute("color",new rt(l,3)),r.geometry=h})}get count(){return this.drawn.length}nearest(e,t){let n,i=t;for(const r of this.drawn){const a=r.direction.dot(e);a>i&&(i=a,n=r.satellite)}return n}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class jc{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class Ws{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:n,velocityKmS:i,seed:r}=e;if(t<=0||n<=0)return[];const a=t*n/36e5,o=new jc(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(i-20)/52)),f=Ws.MAX_DURATION_MS-d*(Ws.MAX_DURATION_MS-Ws.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,n),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(e,t){return e.filter(n=>t>=n.t&&t<=n.t+n.durationMs).map(n=>({meteor:n,progress:(t-n.t)/n.durationMs}))}}class Nr{object=new rn;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new Jn({color:15659775,transparent:!0,opacity:0,blending:Gn,depthWrite:!1,fog:!1}),this.glow=new Jn({color:10466559,transparent:!0,opacity:0,blending:Gn,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(e,t,n){if(!e||!e.cloudToGround||t<=.01){this.object.visible=!1;return}const i=`${e.channelSeed}:${Math.round(n)}`;i!==this.flashKey&&this.build(e,n,i),this.core.opacity=Math.min(1,t*1.4),this.glow.opacity=t*.35,this.object.visible=!0}build(e,t,n){this.flashKey=n;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const i=new jc(e.channelSeed),r=Math.atan2(t,e.distanceM)*180/Math.PI,a=this.channel(i,e.azimuthDeg,r,0,1),o=[a],c=1+Math.floor(i.next()*2);for(let l=0;l<c;l++){const h=a[Math.floor(i.between(.15,.5)*a.length)];o.push(this.channel(i,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*i.between(.3,.7),.5))}for(const l of o)this.object.add(new We(this.ribbon(l,Nr.GLOW_WIDTH_DEG),this.glow)),this.object.add(new We(this.ribbon(l,Nr.CORE_WIDTH_DEG),this.core))}channel(e,t,n,i,r){const a=[],o=n-i;let c=t;for(let l=0;l<=Nr.SEGMENTS;l++){const h=n-o*l/Nr.SEGMENTS;a.push({azimuthDeg:c,altitudeDeg:h}),c+=e.between(-1,1)*o*.06*r}return a}ribbon(e,t){const n=new Float32Array(e.length*2*3),i=[],r=this.radius*Math.tan(t*Math.PI/180)/2,a=e.map(c=>{const{x:l,y:h,z:u}=nn(c.altitudeDeg,c.azimuthDeg,this.radius);return new C(l,h,u)});a.forEach((c,l)=>{const h=a[Math.min(l+1,a.length-1)],u=a[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(r);if(n.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),n.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<a.length-1){const p=l*2;i.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new yt;return o.setAttribute("position",new rt(n,3)),o.setIndex(i),o}dispose(){for(const e of this.object.children)e.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class Kt{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(e){const t=new jc(e.seed),n=[],{minS:i,maxS:r}=Kt.intervalFor(e.intensity??.5);let a=t.between(0,r)*1e3;for(;a<e.durationMs;){const o=t.next()<Kt.CLOUD_TO_GROUND_FRACTION,c=Kt.MIN_DISTANCE_M,l=Kt.MAX_DISTANCE_M,h=Math.sqrt(t.between(c*c,l*l)),u=o?1+Math.floor(t.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:t.between(.4,.9)}),f+=Kt.INTERSTROKE_MS*t.between(.5,1.6);n.push({t:a,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(t.next()*2**31)}),a+=t.between(i,r)*1e3}return n}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:Kt.MIN_INTERVAL_S-t*(Kt.MIN_INTERVAL_S-Kt.SEVERE_MIN_INTERVAL_S),maxS:Kt.MAX_INTERVAL_S-t*(Kt.MAX_INTERVAL_S-Kt.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let n=0;for(const i of e.strokes){const r=t-e.t-i.offsetMs;r<0||r>Kt.STROKE_DECAY_MS*6||(n+=i.intensity*Math.exp(-r/Kt.STROKE_DECAY_MS))}return Math.min(1,n)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+Kt.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/Kt.SOUND_SPEED_M_S*1e3}}class Cn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Cn.ANCHOR_BLUE-Cn.ANCHOR_RED)/(1/(Cn.BLUE_NM*Cn.BLUE_NM)-1/(Cn.RED_NM*Cn.RED_NM));static A=Cn.ANCHOR_RED-Cn.B/(Cn.RED_NM*Cn.RED_NM);static indexAt(e){return Cn.A+Cn.B/(e*e)}}class $a{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,i,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-t,c=e,l=0):(o=0,c=-n,l=t);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=t*l-n*c,d=n*o-e*l,f=e*c-t*o,p=r/2,v=a/2;for(let m=0;m<6;m++){const g=i+m*Math.PI/3,S=Math.cos(g),b=Math.sin(g);this.normals[m*3]=o*S+u*b,this.normals[m*3+1]=c*S+d*b,this.normals[m*3+2]=l*S+f*b,this.offsets[m]=p}this.normals[18]=e,this.normals[19]=t,this.normals[20]=n,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-n,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(e,t,n,i,r,a,o){let c=-t,l=e,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=t*h-n*l,f=n*c-e*h,p=e*l-t*c,v=c*i+d*r-e*this.radius*2,m=l*i+f*r-t*this.radius*2,g=h*i+p*r-n*this.radius*2;let S=-1,b=-1/0,_=1/0;for(let J=0;J<8;J++){const ne=this.normals[J*3],ae=this.normals[J*3+1],Ve=this.normals[J*3+2],je=ne*e+ae*t+Ve*n,Be=this.offsets[J]-(ne*v+ae*m+Ve*g);if(je>1e-9){const K=Be/je;K<_&&(_=K)}else if(je<-1e-9){const K=Be/je;K>b&&(b=K,S=J)}else if(Be<0)return 0}if(S<0||b>=_)return 0;let E=0;const w=this.normals[S*3],R=this.normals[S*3+1],M=this.normals[S*3+2],A=-(w*e+R*t+M*n),I=Pc.reflectance(A,1,a);o[E].x=e+2*A*w,o[E].y=t+2*A*R,o[E].z=n+2*A*M,o[E].weight=I,E++;const D=1/a,P=Math.sqrt(Math.max(0,1-D*D*(1-A*A)));let F=D*e+(D*A-P)*w,H=D*t+(D*A-P)*R,O=D*n+(D*A-P)*M,V=v+e*b,z=m+t*b,Y=g+n*b,ee=1-I;for(let J=0;J<$a.MAX_BOUNCES&&ee>$a.MIN_WEIGHT;J++){let ne=-1,ae=1/0;for(let B=0;B<8;B++){const Ee=this.normals[B*3],Pe=this.normals[B*3+1],Re=this.normals[B*3+2],xe=Ee*F+Pe*H+Re*O;if(xe<=1e-9)continue;const Ne=(this.offsets[B]-(Ee*V+Pe*z+Re*Y))/xe;Ne>1e-9&&Ne<ae&&(ae=Ne,ne=B)}if(ne<0)break;const Ve=this.normals[ne*3],je=this.normals[ne*3+1],Be=this.normals[ne*3+2],K=Ve*F+je*H+Be*O,re=a*Math.sqrt(Math.max(0,1-K*K));if(V+=F*ae,z+=H*ae,Y+=O*ae,re<1){const B=Math.sqrt(Math.max(0,1-re*re)),Ee=Pc.reflectance(K,a,1);if(o[E].x=a*F-(a*K-B)*Ve,o[E].y=a*H-(a*K-B)*je,o[E].z=a*O-(a*K-B)*Be,o[E].weight=ee*(1-Ee),E++,E>=o.length)return E;ee*=Ee}const ie=2*K;F-=ie*Ve,H-=ie*je,O-=ie*Be}return E}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class At{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 $a;emergent=Array.from({length:$a.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(At.AZIMUTH_BINS*At.ALTITUDE_BINS*3);radiance=new Float32Array(At.AZIMUTH_BINS*At.ALTITUDE_BINS*3);scratch=new Float32Array(At.AZIMUTH_BINS*At.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const i=At.WORST_TILT_DEG*(At.BEST_TILT_DEG/At.WORST_TILT_DEG)**this.alignment;this.tilt=i*Math.PI/180}trace(e){const t=At.AZIMUTH_BINS,n=At.ALTITUDE_BINS,i=this.tally,r=At.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(At.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,S=(this.random()*2-1)*g,b=(this.random()*2-1)*g,_=4*g*g,E=hn.SAMPLES[this.random()*hn.SAMPLES.length|0],w=this.crystal.trace(p,v,m,S,b,Cn.indexAt(E.wavelengthNm),this.emergent);for(let R=0;R<w;R++){const M=this.emergent[R],A=Math.hypot(M.x,M.y,M.z);if(A<1e-9||M.weight<=0)continue;const I=M.x/A,D=M.y/A,P=M.z/A;if(I*p+D*v+P*m>a)continue;const F=Math.asin(Math.max(-1,Math.min(1,-P))),H=Math.abs(Math.atan2(-D,-I)),O=Math.min(t-1,H/Math.PI*t|0),z=(Math.min(n-1,(F+Math.PI/2)/Math.PI*n|0)*t+O)*3,Y=M.weight*_*hn.SAMPLES.length;i[z]+=Y*E.r,i[z+1]+=Y*E.g,i[z+2]+=Y*E.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=At.AZIMUTH_BINS,t=At.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,n,i){return this.begin(e,t,i),this.trace(n),this.harvest()}toRadiance(e,t){const n=2*Math.PI/e,i=Math.max(1,this.traced),r=4*At.REFERENCE_MICRONS*At.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),c=Math.sin((a+1)/t*Math.PI-Math.PI/2),l=1/(n*(c-o)*i*r);for(let h=0;h<e;h++){const u=(a*e+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(e,t){const n=this.scratch,i=this.radiance;n.set(i);for(let a=0;a<t;a++){const o=a*e*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<e;h++){const u=o+h*3+c,d=h+1<e?n[u+3]:n[u];i[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(i);const r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,c=a+1<t?r:0,l=a*r;for(let h=l;h<l+r;h++)i[h]=(n[h+o]+2*n[h]+n[h+c])/4}}pickPopulation(){const e=this.random();let t=0;for(const n of At.POPULATIONS)if(t+=n.share,e<=t)return n;return At.POPULATIONS[At.POPULATIONS.length-1]}orient(e,t){const n=this.random()*2*Math.PI;let i=this.random()*2*Math.PI,r=0,a=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),e.orientation==="parry"&&(i=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(r,a,o,i,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),n=Math.max(1e-12,this.random()),i=1+Math.log(n+(1-n)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,i))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const n=this.gaussian()*e;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class yi{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;setCloudOffset(e){this.material.uniforms.uFieldOffset.value.copy(e)}object;material;sky=new At;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=yi.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=At.AZIMUTH_BINS,t=At.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new js(this.texels,e,t,_n,cn),this.texture.minFilter=dt,this.texture.magFilter=dt,this.texture.wrapS=An,this.texture.wrapT=An,this.texture.needsUpdate=!0,this.material=new Rt({uniforms:{uSource:{value:new C(0,1,0)},uUp:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new C},uMap:{value:this.texture},uGain:{value:yi.GAIN}},vertexShader:`
5951
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new We(new ui(2,2),this.material))}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(e,t,n,i){const r=this.material.uniforms;r.uApertureMm2.value=e*e/Math.max(.1,t),r.uFocusDistance.value=Math.max(0,n),r.uFocalLengthMm.value=e,r.uPixelsPerMm.value=this.height/Math.max(.1,i)}setEncodesOutput(e){this.material.uniforms.uEncodeOutput.value=e?1:0}render(e,t,n,i){const r=this.material.uniforms;r.uNear.value=n.near,r.uFar.value=n.far;const a=e.getRenderTarget();e.setRenderTarget(this.target),e.clear(),e.render(t,n),i?.(),e.setRenderTarget(a),e.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class wt{static MIN_RATIO=1;static STEP=.25;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(e,t){this.maxRatio=wt.clamp(e),this.ratio=this.maxRatio,this.timer=t?kc.create(t):void 0}get pixelRatio(){return this.ratio}get timesGpu(){return this.timer!==void 0}set maximum(e){this.maxRatio=wt.clamp(e),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio)}get maximum(){return this.maxRatio}beginDrawing(){this.timer?.begin()}endDrawing(){this.timer?.end()}reset(){this.intervalMs=void 0,this.probe=void 0,this.timer?.reset()}update(e,t){const n=this.timer?.poll();if(!(this.timer&&n===void 0))return n!==void 0?this.followGpu(e,n):this.followIntervals(e,t)}followGpu(e,t){if(t>wt.GPU_LATE_MS)return this.lower(e,wt.LOWER_COOLDOWN_MS);if(t<wt.GPU_ROOM_MS)return this.raise(e,wt.RAISE_COOLDOWN_MS)}followIntervals(e,t){if(!(t>0)||t>1e3)return;this.intervalMs=this.intervalMs===void 0?t:this.intervalMs*.9+t*.1;const n=this.intervalMs>wt.INTERVAL_LATE_MS;if(this.probe){if(n)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=e,this.nextProbeMs=e+wt.PROBE_BACKOFF_MS,this.ratio;e-this.probe.sinceMs>=wt.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=e+wt.PROBE_EVERY_MS);return}if(n){const i=this.lower(e,wt.LOWER_COOLDOWN_MS);return i!==void 0&&(this.nextProbeMs=e+wt.PROBE_EVERY_MS),i}if(this.ratio<this.maxRatio&&e>=this.nextProbeMs&&e-this.lastChangeMs>=wt.RAISE_COOLDOWN_MS){const i=this.ratio,r=this.raise(e,0);return r!==void 0&&(this.probe={sinceMs:e,ratioBefore:i}),r}}lower(e,t){if(!(this.ratio<=wt.MIN_RATIO||e-this.lastChangeMs<t))return this.ratio=wt.clamp(this.ratio-wt.STEP),this.lastChangeMs=e,this.ratio}raise(e,t){if(!(this.ratio>=this.maxRatio||e-this.lastChangeMs<t))return this.ratio=Math.min(this.maxRatio,wt.clamp(this.ratio+wt.STEP)),this.lastChangeMs=e,this.ratio}static clamp(e){return Number.isFinite(e)?Math.max(wt.MIN_RATIO,Math.round(e/wt.STEP)*wt.STEP):wt.MIN_RATIO}}class kc{constructor(e,t){this.gl=e,this.extension=t}static IN_FLIGHT_MAX=8;static create(e){if(!(e instanceof WebGL2RenderingContext))return;const t=e.getExtension("EXT_disjoint_timer_query_webgl2");return t?new kc(e,t):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=kc.IN_FLIGHT_MAX))try{const e=this.gl.createQuery();if(!e)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,e),this.active=e}catch{this.active=void 0}}end(){if(this.active){try{this.gl.endQuery(this.extension.TIME_ELAPSED_EXT),this.pending.push(this.active)}catch{}this.active=void 0}}poll(){const e=this.gl;try{for(let t=0;t<this.pending.length;t++){const n=this.pending[t];if(!e.getQueryParameter(n,e.QUERY_RESULT_AVAILABLE))continue;if(!e.getParameter(this.extension.GPU_DISJOINT_EXT)){const r=e.getQueryParameter(n,e.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?r:this.smoothedMs*.8+r*.2}e.deleteQuery(n),this.pending.splice(t,1),t--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class it{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const e=it.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const n=e*Math.PI/180,i=t*Math.sin(n/2);return i>1?Number.NaN:(2*Math.asin(i)-n)*180/Math.PI}static effectiveIndex(e,t){const n=t*Math.PI/180,i=Math.cos(n);return i<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(n)**2)/i}static parheliaAzimuthDeg(e,t=it.ICE_INDEX_RED){const n=it.minimumDeviationDeg(it.SIDE_PRISM_ANGLE_DEG,it.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(e,t=it.ICE_INDEX_RED){const n=it.parheliaAzimuthDeg(e,t);if(n===void 0)return;const i=e*Math.PI/180,r=Math.sin(i)**2,a=Math.cos(i)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const e=it.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(e*e-1)))*180/Math.PI}static circumzenithalAltitudeDeg(e,t=it.ICE_INDEX_RED){if(e<0||e>90-it.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(e*Math.PI/180),i=Math.sqrt(t*t-n*n);if(!(i>=1))return Math.asin(i)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(e){return Math.acos(6371e3/(6371e3+Math.max(0,e)))*180/Math.PI}static halo22(){return it.ringOf("halo22",it.SIDE_PRISM_ANGLE_DEG)}static halo46(){return it.ringOf("halo46",it.END_PRISM_ANGLE_DEG)}static ringOf(e,t){const n=it.minimumDeviationDeg(t,it.ICE_INDEX_RED),i=it.minimumDeviationDeg(t,it.ICE_INDEX_BLUE);return{id:e,angleDeg:(n+i)/2,redAngleDeg:n,blueAngleDeg:i}}static strength(e,t,n=90,i=0){const r=Math.max(0,Math.min(1,e)),a=Math.max(0,1-Math.max(0,Math.min(1,t))),o=n>=0?1:i<=0?0:Math.max(0,1+n/i);return r*a*o}static formsAt(e,t=0){if(e<=-t)return[];const n=[it.halo22(),it.halo46()],i=e>0?it.parheliaDistanceDeg(e):void 0;i!==void 0&&n.push({id:"parhelia",angleDeg:i,redAngleDeg:i,blueAngleDeg:it.parheliaDistanceDeg(e,it.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:it.halo22().angleDeg}),e>0&&n.push({id:"parhelicCircle",angleDeg:e});const r=it.circumzenithalAltitudeDeg(e);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),e>it.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),e<it.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Pn{static get WATER_INDEX_RED(){return tn.indexAt(tn.RED_NM)}static get WATER_INDEX_BLUE(){return tn.indexAt(tn.BLUE_NM)}static radiusDeg(e,t){const n=(t*t-1)/(e*e-1);if(n<0||n>1)return Number.NaN;const i=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(i)/t),a=2*(i-r)+(e-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return Pn.bowOf("primary",2,0)}static secondary(){return Pn.bowOf("secondary",3,0)}static bowOf(e,t,n){const i=Pn.radiusDeg(t,Pn.WATER_INDEX_RED),r=Pn.radiusDeg(t,Pn.WATER_INDEX_BLUE),a=(i+r)/2;return{id:e,radiusDeg:a,redRadiusDeg:i,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:Pn.primary().redRadiusDeg,toDeg:Pn.secondary().redRadiusDeg}}static formsAt(e){return e<0?[]:[Pn.bowOf("primary",2,e),Pn.bowOf("secondary",3,e)].filter(t=>t.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(e){return Math.min(1,10**(-.4*(e-Pn.FULL_MOON_MAGNITUDE)))}static strength(e,t,n){if(n<=0)return 0;const i=Math.max(0,Math.min(1,e)),r=Math.max(0,1-Math.max(0,Math.min(1,t)));return i*r}}class zn{constructor(e){this.radius=e;const t=zn.SEGMENTS*zn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new yt;n.setAttribute("position",new rt(this.positions,3)),n.setAttribute("color",new rt(this.colors,3)),n.setDrawRange(0,0),this.object=new We(n,new Jn({vertexColors:!0,transparent:!0,blending:Gn,depthWrite:!1,fog:!1,side:ai})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=zn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(zn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(e,t,n){this.head=e&&nn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&nn(t.altitudeDeg,t.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,n=this.tip;if(!t||!n||this.brightness<=0){e.setDrawRange(0,0);return}const i=this.angleBetween(t,n);if(i<=0){e.setDrawRange(0,0);return}const r=i*zn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(zn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**zn.FADE_POWER;let l=0;for(let h=1;h<zn.POINTS;h++){const u=(h-1)/zn.SEGMENTS,d=h/zn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}e.setDrawRange(0,l),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let l=0;l<zn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(t,c,i,h),f=this.across(n,c,r,h),p=this.across(t,c,i,u),v=this.across(n,c,r,u),m=(g,S)=>g===0?S:0;e=this.push(e,d,m(h,a)),e=this.push(e,f,m(h,o)),e=this.push(e,p,m(u,a)),e=this.push(e,f,m(h,o)),e=this.push(e,v,m(u,o)),e=this.push(e,p,m(u,a))}return e}across(e,t,n,i){return{x:e.x+t.x*n*i,y:e.y+t.y*n*i,z:e.z+t.z*n*i}}push(e,t,n){const i=e*3;this.positions[i]=t.x,this.positions[i+1]=t.y,this.positions[i+2]=t.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.55,this.colors[i+1]=r*.75,this.colors[i+2]=r,e+1}slerp(e,t,n){const i=this.angleBetweenRadians(e,t);if(i<1e-9)return e;const r=Math.sin(i),a=Math.sin((1-n)*i)/r,o=Math.sin(n*i)/r;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const n=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class H5{object=new rn;radius;tiers;drawn=[];constructor(e){this.radius=e,this.object.name="satellites",this.tiers=fd.map(t=>{const n=new ad({vertexColors:!0,size:t.size,sizeAttenuation:!1,fog:!1});Ms.apply(n);const i=new Na(new yt,n);return i.frustumCulled=!1,this.object.add(i),i})}set(e,t,n){const i=this.tiers.map(()=>[]);this.drawn=[];for(const r of e){const a=n(r.position);if(a<=0)continue;const o=r.magnitude-2.5*Math.log10(a);if(o>t)continue;const c=Aa(o,t),l=Hm(c),{x:h,y:u,z:d}=nn(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),f=ds(r.position.altitudeDeg),p=Ta(c);i[l].push({x:h,y:u,z:d,r:p*f[0],g:p*f[1],b:p*f[2]}),this.drawn.push({satellite:r,direction:new C(h,u,d).normalize()})}this.tiers.forEach((r,a)=>{const o=i[a],c=new Float32Array(o.length*3),l=new Float32Array(o.length*3);o.forEach((u,d)=>{c.set([u.x,u.y,u.z],d*3),l.set([u.r,u.g,u.b],d*3)}),r.geometry.dispose();const h=new yt;h.setAttribute("position",new rt(c,3)),h.setAttribute("color",new rt(l,3)),r.geometry=h})}get count(){return this.drawn.length}nearest(e,t){let n,i=t;for(const r of this.drawn){const a=r.direction.dot(e);a>i&&(i=a,n=r.satellite)}return n}dispose(){for(const e of this.tiers)e.geometry.dispose(),e.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class jc{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class Ws{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:n,velocityKmS:i,seed:r}=e;if(t<=0||n<=0)return[];const a=t*n/36e5,o=new jc(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(i-20)/52)),f=Ws.MAX_DURATION_MS-d*(Ws.MAX_DURATION_MS-Ws.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,n),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(e,t){return e.filter(n=>t>=n.t&&t<=n.t+n.durationMs).map(n=>({meteor:n,progress:(t-n.t)/n.durationMs}))}}class Nr{object=new rn;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;constructor(e){this.radius=e,this.object.name="lightning-bolt",this.core=new Jn({color:15659775,transparent:!0,opacity:0,blending:Gn,depthWrite:!1,fog:!1}),this.glow=new Jn({color:10466559,transparent:!0,opacity:0,blending:Gn,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(e,t,n){if(!e||!e.cloudToGround||t<=.01){this.object.visible=!1;return}const i=`${e.channelSeed}:${Math.round(n)}`;i!==this.flashKey&&this.build(e,n,i),this.core.opacity=Math.min(1,t*1.4),this.glow.opacity=t*.35,this.object.visible=!0}build(e,t,n){this.flashKey=n;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const i=new jc(e.channelSeed),r=Math.atan2(t,e.distanceM)*180/Math.PI,a=this.channel(i,e.azimuthDeg,r,0,1),o=[a],c=1+Math.floor(i.next()*2);for(let l=0;l<c;l++){const h=a[Math.floor(i.between(.15,.5)*a.length)];o.push(this.channel(i,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*i.between(.3,.7),.5))}for(const l of o)this.object.add(new We(this.ribbon(l,Nr.GLOW_WIDTH_DEG),this.glow)),this.object.add(new We(this.ribbon(l,Nr.CORE_WIDTH_DEG),this.core))}channel(e,t,n,i,r){const a=[],o=n-i;let c=t;for(let l=0;l<=Nr.SEGMENTS;l++){const h=n-o*l/Nr.SEGMENTS;a.push({azimuthDeg:c,altitudeDeg:h}),c+=e.between(-1,1)*o*.06*r}return a}ribbon(e,t){const n=new Float32Array(e.length*2*3),i=[],r=this.radius*Math.tan(t*Math.PI/180)/2,a=e.map(c=>{const{x:l,y:h,z:u}=nn(c.altitudeDeg,c.azimuthDeg,this.radius);return new C(l,h,u)});a.forEach((c,l)=>{const h=a[Math.min(l+1,a.length-1)],u=a[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(r);if(n.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),n.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<a.length-1){const p=l*2;i.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new yt;return o.setAttribute("position",new rt(n,3)),o.setIndex(i),o}dispose(){for(const e of this.object.children)e.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class Kt{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(e){const t=new jc(e.seed),n=[],{minS:i,maxS:r}=Kt.intervalFor(e.intensity??.5);let a=t.between(0,r)*1e3;for(;a<e.durationMs;){const o=t.next()<Kt.CLOUD_TO_GROUND_FRACTION,c=Kt.MIN_DISTANCE_M,l=Kt.MAX_DISTANCE_M,h=Math.sqrt(t.between(c*c,l*l)),u=o?1+Math.floor(t.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:t.between(.4,.9)}),f+=Kt.INTERSTROKE_MS*t.between(.5,1.6);n.push({t:a,azimuthDeg:t.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(t.next()*2**31)}),a+=t.between(i,r)*1e3}return n}static intervalFor(e){const t=Math.min(1,Math.max(0,(e-.5)/.5));return{minS:Kt.MIN_INTERVAL_S-t*(Kt.MIN_INTERVAL_S-Kt.SEVERE_MIN_INTERVAL_S),maxS:Kt.MAX_INTERVAL_S-t*(Kt.MAX_INTERVAL_S-Kt.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(e,t){let n=0;for(const i of e.strokes){const r=t-e.t-i.offsetMs;r<0||r>Kt.STROKE_DECAY_MS*6||(n+=i.intensity*Math.exp(-r/Kt.STROKE_DECAY_MS))}return Math.min(1,n)}static endOf(e){const t=e.strokes[e.strokes.length-1];return e.t+t.offsetMs+Kt.STROKE_DECAY_MS*6}static thunderDelayMs(e){return e.distanceM/Kt.SOUND_SPEED_M_S*1e3}}class Cn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Cn.ANCHOR_BLUE-Cn.ANCHOR_RED)/(1/(Cn.BLUE_NM*Cn.BLUE_NM)-1/(Cn.RED_NM*Cn.RED_NM));static A=Cn.ANCHOR_RED-Cn.B/(Cn.RED_NM*Cn.RED_NM);static indexAt(e){return Cn.A+Cn.B/(e*e)}}class $a{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(e,t,n,i,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-t,c=e,l=0):(o=0,c=-n,l=t);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=t*l-n*c,d=n*o-e*l,f=e*c-t*o,p=r/2,v=a/2;for(let m=0;m<6;m++){const g=i+m*Math.PI/3,S=Math.cos(g),b=Math.sin(g);this.normals[m*3]=o*S+u*b,this.normals[m*3+1]=c*S+d*b,this.normals[m*3+2]=l*S+f*b,this.offsets[m]=p}this.normals[18]=e,this.normals[19]=t,this.normals[20]=n,this.offsets[6]=v,this.normals[21]=-e,this.normals[22]=-t,this.normals[23]=-n,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(e,t,n,i,r,a,o){let c=-t,l=e,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=t*h-n*l,f=n*c-e*h,p=e*l-t*c,v=c*i+d*r-e*this.radius*2,m=l*i+f*r-t*this.radius*2,g=h*i+p*r-n*this.radius*2;let S=-1,b=-1/0,_=1/0;for(let J=0;J<8;J++){const ne=this.normals[J*3],ae=this.normals[J*3+1],Ve=this.normals[J*3+2],je=ne*e+ae*t+Ve*n,He=this.offsets[J]-(ne*v+ae*m+Ve*g);if(je>1e-9){const K=He/je;K<_&&(_=K)}else if(je<-1e-9){const K=He/je;K>b&&(b=K,S=J)}else if(He<0)return 0}if(S<0||b>=_)return 0;let E=0;const w=this.normals[S*3],R=this.normals[S*3+1],M=this.normals[S*3+2],A=-(w*e+R*t+M*n),I=Pc.reflectance(A,1,a);o[E].x=e+2*A*w,o[E].y=t+2*A*R,o[E].z=n+2*A*M,o[E].weight=I,E++;const D=1/a,P=Math.sqrt(Math.max(0,1-D*D*(1-A*A)));let F=D*e+(D*A-P)*w,H=D*t+(D*A-P)*R,O=D*n+(D*A-P)*M,V=v+e*b,z=m+t*b,Y=g+n*b,ee=1-I;for(let J=0;J<$a.MAX_BOUNCES&&ee>$a.MIN_WEIGHT;J++){let ne=-1,ae=1/0;for(let B=0;B<8;B++){const Ee=this.normals[B*3],Pe=this.normals[B*3+1],Re=this.normals[B*3+2],xe=Ee*F+Pe*H+Re*O;if(xe<=1e-9)continue;const Ne=(this.offsets[B]-(Ee*V+Pe*z+Re*Y))/xe;Ne>1e-9&&Ne<ae&&(ae=Ne,ne=B)}if(ne<0)break;const Ve=this.normals[ne*3],je=this.normals[ne*3+1],He=this.normals[ne*3+2],K=Ve*F+je*H+He*O,re=a*Math.sqrt(Math.max(0,1-K*K));if(V+=F*ae,z+=H*ae,Y+=O*ae,re<1){const B=Math.sqrt(Math.max(0,1-re*re)),Ee=Pc.reflectance(K,a,1);if(o[E].x=a*F-(a*K-B)*Ve,o[E].y=a*H-(a*K-B)*je,o[E].z=a*O-(a*K-B)*He,o[E].weight=ee*(1-Ee),E++,E>=o.length)return E;ee*=Ee}const ie=2*K;F-=ie*Ve,H-=ie*je,O-=ie*He}return E}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class At{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 $a;emergent=Array.from({length:$a.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(At.AZIMUTH_BINS*At.ALTITUDE_BINS*3);radiance=new Float32Array(At.AZIMUTH_BINS*At.ALTITUDE_BINS*3);scratch=new Float32Array(At.AZIMUTH_BINS*At.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(e,t,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=e*Math.PI/180,this.alignment=Math.min(1,Math.max(0,t));const i=At.WORST_TILT_DEG*(At.BEST_TILT_DEG/At.WORST_TILT_DEG)**this.alignment;this.tilt=i*Math.PI/180}trace(e){const t=At.AZIMUTH_BINS,n=At.ALTITUDE_BINS,i=this.tally,r=At.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(At.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<e;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,S=(this.random()*2-1)*g,b=(this.random()*2-1)*g,_=4*g*g,E=hn.SAMPLES[this.random()*hn.SAMPLES.length|0],w=this.crystal.trace(p,v,m,S,b,Cn.indexAt(E.wavelengthNm),this.emergent);for(let R=0;R<w;R++){const M=this.emergent[R],A=Math.hypot(M.x,M.y,M.z);if(A<1e-9||M.weight<=0)continue;const I=M.x/A,D=M.y/A,P=M.z/A;if(I*p+D*v+P*m>a)continue;const F=Math.asin(Math.max(-1,Math.min(1,-P))),H=Math.abs(Math.atan2(-D,-I)),O=Math.min(t-1,H/Math.PI*t|0),z=(Math.min(n-1,(F+Math.PI/2)/Math.PI*n|0)*t+O)*3,Y=M.weight*_*hn.SAMPLES.length;i[z]+=Y*E.r,i[z+1]+=Y*E.g,i[z+2]+=Y*E.b}}this.traced+=e}get tracedRays(){return this.traced}harvest(){const e=At.AZIMUTH_BINS,t=At.ALTITUDE_BINS;return this.toRadiance(e,t),this.smooth(e,t),{width:e,height:t,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(e,t,n,i){return this.begin(e,t,i),this.trace(n),this.harvest()}toRadiance(e,t){const n=2*Math.PI/e,i=Math.max(1,this.traced),r=4*At.REFERENCE_MICRONS*At.REFERENCE_MICRONS;for(let a=0;a<t;a++){const o=Math.sin(a/t*Math.PI-Math.PI/2),c=Math.sin((a+1)/t*Math.PI-Math.PI/2),l=1/(n*(c-o)*i*r);for(let h=0;h<e;h++){const u=(a*e+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(e,t){const n=this.scratch,i=this.radiance;n.set(i);for(let a=0;a<t;a++){const o=a*e*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<e;h++){const u=o+h*3+c,d=h+1<e?n[u+3]:n[u];i[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(i);const r=e*3;for(let a=0;a<t;a++){const o=a>0?-r:0,c=a+1<t?r:0,l=a*r;for(let h=l;h<l+r;h++)i[h]=(n[h+o]+2*n[h]+n[h+c])/4}}pickPopulation(){const e=this.random();let t=0;for(const n of At.POPULATIONS)if(t+=n.share,e<=t)return n;return At.POPULATIONS[At.POPULATIONS.length-1]}orient(e,t){const n=this.random()*2*Math.PI;let i=this.random()*2*Math.PI,r=0,a=0,o=1;switch(e.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(t);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),e.orientation==="parry"&&(i=Math.PI/2+this.gaussian()*t);break}}this.crystal.set(r,a,o,i,e.widthMicrons,e.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let e=this.seed;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}spreadAboutAnAxis(e){const t=1/Math.max(1e-6,e*e),n=Math.max(1e-12,this.random()),i=1+Math.log(n+(1-n)*Math.exp(-2*t))/t;return Math.max(-1,Math.min(1,i))}spreadAboutAPlane(e){for(let t=0;t<8;t++){const n=this.gaussian()*e;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const e=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),t=2*Math.PI*this.random();return this.spare=e*Math.sin(t),this.hasSpare=!0,e*Math.cos(t)}}class yi{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;setCloudOffset(e){this.material.uniforms.uFieldOffset.value.copy(e)}object;material;sky=new At;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=yi.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const e=At.AZIMUTH_BINS,t=At.ALTITUDE_BINS;this.texels=new Uint16Array(e*t*4),this.texture=new js(this.texels,e,t,_n,cn),this.texture.minFilter=dt,this.texture.magFilter=dt,this.texture.wrapS=An,this.texture.wrapT=An,this.texture.needsUpdate=!0,this.material=new Rt({uniforms:{uSource:{value:new C(0,1,0)},uUp:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new C},uMap:{value:this.texture},uGain:{value:yi.GAIN}},vertexShader:`
5952
5952
  varying vec3 vDirection;
5953
5953
  void main() {
5954
5954
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -6003,7 +6003,7 @@ void main()
6003
6003
  `+i.vertexShader,i.vertexShader=i.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
6004
6004
  cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let r=`varying vec3 cloudPoint;
6005
6005
  `,a="";t.forEach((o,c)=>{const l=`cloud${c}_`;for(const[h,u]of Object.entries(o.uniforms))i.uniforms[l+h]=u;r+=Yy(l),a+=`diffuseColor.a *= ${l}transmissionAt(normalize(cloudPoint), length(cloudPoint));
6006
- `}),i.fragmentShader=r+i.fragmentShader,i.fragmentShader=i.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},e.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new C;up=new C;lookAt=new Ye;vertex=new C;centre=new C;right=new C;above=new C;set(e,t){this.placed=e,this.frame=t;const n=new Set(e.map(i=>i.sourceId));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of e){let r=this.meshes.get(i.sourceId);r||(r=new We(new ui(1,1,ii.SEGMENTS,ii.SEGMENTS),new Jn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(r.material),r.frustumCulled=!1,r.layers.set(vg),this.scene.add(r),this.meshes.set(i.sourceId,r)),r.renderOrder=ob+i.renderOrder,r.visible=!i.hidden&&i.shape.transparency<1,r.visible&&this.paint(r,i,t)}}place(e,t,n){const i=this.frame;if(i)for(const r of this.placed){const a=this.meshes.get(r.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(r.sourceId);if(!o)continue;const{bounds:c}=r.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(r.aim){const d=n(ii.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<ii.FURTHEST_NDC&&Math.abs(d.ndcY)<ii.FURTHEST_NDC?(l=(d.ndcX+1)/2*i.canvasWidthPx,h=(1-d.ndcY)/2*i.canvasHeightPx):u=!1}u?this.curve(a,e,t,i,o,l,h,r.distanceM):this.flat(a,e,i,o,r.distanceM)}}static FURTHEST_NDC=4;curve(e,t,n,i,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=e.geometry.attributes.position,d=ii.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*r.height;for(let m=0;m<=d;m++){const g=l+m/d*r.width;n(g/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(xt.sizeMAt(c,i.projection.pxToDeg(r.width)),xt.sizeMAt(c,i.projection.pxToDeg(r.height)),1)}flat(e,t,n,i,r){const a=e.geometry.attributes.position,o=ii.SEGMENTS,c=xt.sizeMAt(r,n.projection.pxToDeg(i.width)),l=xt.sizeMAt(r,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,r),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*c).addScaledVector(this.above,d*l),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(e,t){const n=e.azimuthDeg*Math.PI/180,i=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,n){const{shape:i}=t,r=Va.paintExtent(i);this.extents.set(t.sourceId,r);const a=ii.signatureOf(i,n);if(this.signatures.get(t.sourceId)===a&&e.material.map)return;this.signatures.set(t.sourceId,a);const o=Math.min(n.scale,cb/Math.max(r.width,r.height,1)),c=Math.max(1,Math.ceil(r.width*o)),l=Math.max(1,Math.ceil(r.height*o)),h=e.material.map,u=h?.image??document.createElement("canvas"),d=u.width!==c||u.height!==l;d&&(u.width=c,u.height=l);const f=u.getContext("2d");if(!f)return;f.clearRect(0,0,c,l);const p=new Va(f);if(p.setStarPoints(n.starPoints),p.setRoll(n.rollRad),p.paintInto(i,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new Li(u);v.colorSpace=Ln,v.minFilter=dt,v.generateMipmaps=!1,e.material.map=v,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:n}=e;return JSON.stringify([e.kind,Math.round(n.width*10),Math.round(n.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const Mg=3,jo=800,_a=Math.PI/180;class zs{constructor(e,t,n=zs.fetchImage){this.scene=e,this.onImageLoaded=t,this.loadImage=n}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(e,t=this.views){this.references=e,this.views=t;const n=new Set(e.map(i=>i.id));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i));for(const[i,r]of this.images){const a=e.find(o=>o.id===i);a&&a.src===r.texture.userData.src||(r.texture.dispose(),this.images.delete(i))}for(const i of e){const r=this.images.get(i.id);if(!r){this.load(i);continue}this.build(i,r)}}setShown(e){this.shown=e;for(const t of this.meshes.values())t.visible=e&&this.opacityOf(t.userData.id)>0}setView(e,t){this.views.set(e,t);const n=this.meshes.get(e);n&&this.applyOpacity(n,e)}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}place(e){for(const t of this.meshes.values())t.visible&&(t.position.copy(e.position),t.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?jo:0}directionOfPixel(e,t,n,i){const r=this.images.get(e.id),a=r?r.width/r.height:1,o=Math.tan(e.registration.fovDeg/2*_a),c=o*a;return i.set((t*2-1)*c,(1-n*2)*o,-1).normalize(),i.applyQuaternion(zs.orientation(e))}aspectOf(e){const t=this.images.get(e);return t?t.width/t.height:void 0}failedToLoad(e){return this.failed.has(e)}load(e){const t=e.src;if(this.loading.has(e.id)||this.failed.has(t))return;const n=this.loadImage(t).then(i=>{this.loading.delete(e.id);const r=this.references.find(a=>a.id===e.id);if(!r||r.src!==t){i.texture.dispose();return}i.texture.userData.src=t,this.images.set(e.id,i),this.build(r,i),this.onImageLoaded()},()=>{this.loading.delete(e.id),this.failed.add(t)});this.loading.set(e.id,n)}static async fetchImage(e){const t=await fetch(e);if(!t.ok)throw new Error(`${e}: ${t.status}`);const n=await createImageBitmap(await t.blob(),{imageOrientation:"flipY"}),i=new on(n);return i.flipY=!1,i.colorSpace=Ln,i.minFilter=dt,i.magFilter=dt,i.generateMipmaps=!1,i.needsUpdate=!0,{texture:i,width:n.width,height:n.height}}build(e,t){const n=zs.signatureOf(e,t);let i=this.meshes.get(e.id);if(i&&this.signatures.get(e.id)===n){this.applyOpacity(i,e.id);return}i&&(this.dispose(i),this.meshes.delete(e.id)),i=new We(zs.geometryOf(e,t),new Jn({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(i.material.side=Ct),i.frustumCulled=!1,i.layers.set(Mg),i.userData.id=e.id,i.quaternion.copy(zs.orientation(e)),this.scene.add(i),this.meshes.set(e.id,i),this.signatures.set(e.id,n),this.applyOpacity(i,e.id)}static geometryOf(e,t){if(e.kind==="panorama"){const a=new fn(jo,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,a}const n=2*jo*Math.tan(e.registration.fovDeg/2*_a),i=n*(t.width/Math.max(t.height,1)),r=new ui(i,n);return r.translate(0,0,-jo),r}static orientation(e){const{headingDeg:t,pitchDeg:n,rollDeg:i}=e.registration,r=new bt;return r.rotation.set(n*_a,-t*_a,-(i??0)*_a,"YXZ"),r.quaternion}opacityOf(e){const t=this.references.find(i=>i.id===e);return this.views.get(e)?.opacity??t?.opacity??0}applyOpacity(e,t){const n=this.opacityOf(t);e.material.opacity=n,e.visible=this.shown&&n>0}static signatureOf(e,t){const{headingDeg:n,pitchDeg:i,rollDeg:r,fovDeg:a}=e.registration;return[e.kind,e.src,t.width,t.height,n,i,r??0,a].join("|")}dispose(e){this.scene.remove(e),e.geometry.dispose(),e.material.dispose()}disposeAll(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear();for(const e of this.images.values())e.texture.dispose();this.images.clear()}}class Ze{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(e,t)=>410+20*t);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(e={}){const t=Ze.WAVELENGTHS_NM.length,n=e.aerosolOpticalDepth??Ze.DEFAULT_AEROSOL_OPTICAL_DEPTH,i=e.ozoneDobson??Ze.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const r=i*2687e17/Ze.OZONE_HALF_WIDTH_M;for(let a=0;a<t;a++){const o=Ze.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ze.rayleighAt(o);const c=n/Ze.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=c,this.aerosolScattering[a]=c*Ze.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ze.OZONE_CROSS_SECTION[a]*1e-25*r}}static rayleighAt(e){const t=e/1e3,n=1/(t*t),i=t*t;return(1.0455996-341.29061*n-.9023085*i)/(1+.0027059889*n-85.968563*i)*1e-28*1e-4*2546899e19}static rayleighDensity(e){return Math.exp(-Math.max(e,0)/Ze.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Ze.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Ze.OZONE_PEAK_ALTITUDE_M)/Ze.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Ze.AEROSOL_ASYMMETRY){const n=t*t;return 3/(8*Math.PI)*(1-n)*(1+e*e)/((2+n)*Math.pow(Math.max(1+n-2*t*e,1e-6),1.5))}}class st{static RESPONSE_EXPONENT=.74;static DAYLIGHT_ANCHOR_CD_M2=3e3;static DAYLIGHT_ANCHOR_RESPONSE=.42;static NIGHT_ANCHOR_CD_M2=172e-6;static NIGHT_ANCHOR_RESPONSE=.006;static anchoredSemiSaturation(e,t){return e*(1/t-1)**(1/st.RESPONSE_EXPONENT)}static get ADAPTATION_EXPONENT(){const e=st.anchoredSemiSaturation(st.DAYLIGHT_ANCHOR_CD_M2,st.DAYLIGHT_ANCHOR_RESPONSE),t=st.anchoredSemiSaturation(st.NIGHT_ANCHOR_CD_M2,st.NIGHT_ANCHOR_RESPONSE);return Math.log(e/t)/Math.log(st.DAYLIGHT_ANCHOR_CD_M2/st.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return st.anchoredSemiSaturation(st.DAYLIGHT_ANCHOR_CD_M2,st.DAYLIGHT_ANCHOR_RESPONSE)/st.DAYLIGHT_ANCHOR_CD_M2**st.ADAPTATION_EXPONENT}static rodShare(e){return st.ROD_HALF_LUMINANCE_CD_M2/(st.ROD_HALF_LUMINANCE_CD_M2+Math.max(e,0))}static semiSaturation(e){return st.SEMI_SATURATION_SCALE*Math.max(e,1e-9)**st.ADAPTATION_EXPONENT}static response(e,t){const n=st.RESPONSE_EXPONENT,i=Math.max(e,0)**n;return i/(i+st.semiSaturation(t)**n)}static displayOf(e,t,n,i=st.rodShare(n)){const r=(1-i)*e[1]+i*t,a=st.response(r,n),[o,c,l]=hn.linearSrgbOf(e),h=Math.max(e[1],1e-12),u=st.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-i)*p/h+i*v/d)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}}class He{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=20;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new Zr;camera=new ws(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(e){this.renderer=e,this.supported=e.capabilities.isWebGL2&&e.extensions.has("EXT_color_buffer_float"),this.transmittance=new dn(He.TRANSMITTANCE_WIDTH,He.TRANSMITTANCE_HEIGHT,{count:4,type:cn,minFilter:dt,magFilter:dt,depthBuffer:!1}),this.multiple=new dn(He.MULTIPLE_SIZE,He.MULTIPLE_SIZE,{count:4,type:Tn,minFilter:Tt,magFilter:Tt,depthBuffer:!1});const t=()=>new dn(He.SKY_VIEW_WIDTH,He.SKY_VIEW_HEIGHT,{type:Tn,minFilter:Tt,magFilter:Tt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const n=He.mediumUniforms(),i=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},r=(a,o={})=>new Em({glslVersion:wc,uniforms:{...n,...i,...o},vertexShader:He.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=r(He.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=r(He.MULTIPLE_FRAGMENT),this.skyViewMaterial=r(He.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new We(new ui(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=He.MULTIPLE_SIZE)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(i=>Array.from(i,r=>r.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;const n=(i,r)=>{const a=this.transmittanceMaterial.uniforms[i].value;for(let o=0;o<4;o++)a[o].set(r[o*4]??0,r[o*4+1]??0,r[o*4+2]??0,r[o*4+3]??0)};n("uRayleigh",e.rayleighScattering),n("uAerosolScattering",e.aerosolScattering),n("uAerosolExtinction",e.aerosolExtinction),n("uOzone",e.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(e){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const t=He.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(He.shared.set(this.mediumKey,"building"),this.building=!0);const n=this.renderer.getRenderTarget();let i=Math.max(1,e);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,i--);const r=He.MULTIPLE_SIZE,a=He.MULTIPLE_BLOCK;for(;i>0&&this.multipleRows<r;i--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,a,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=a,this.multipleColumn>=r&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(n),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(e){this.building=!1;try{const t=await Promise.all([0,1,2,3].map(i=>this.readRaw(this.transmittance,i,Uint16Array))),n=await Promise.all([0,1,2,3].map(i=>this.readRaw(this.multiple,i,Float32Array)));this.mediumKey===e?He.shared.set(e,{transmittance:t,multiple:n}):He.shared.delete(e)}catch{He.shared.delete(e)}}async readRaw(e,t,n){const i=new n(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,i,void 0,t),i}adopt(e){const t=(r,a,o,c)=>{const l=new js(r,a,o,_n,c?cn:Tn);return l.minFilter=l.magFilter=c?dt:Tt,l.needsUpdate=!0,l},n=e.transmittance.map(r=>t(r,He.TRANSMITTANCE_WIDTH,He.TRANSMITTANCE_HEIGHT,!0)),i=e.multiple.map(r=>t(r,He.MULTIPLE_SIZE,He.MULTIPLE_SIZE,!1));n.forEach((r,a)=>this.tableUniforms[`uT${a}`].value=r),i.forEach((r,a)=>this.tableUniforms[`uM${a}`].value=r),this.adopted=[...n,...i]}releaseAdopted(){if(this.adopted){for(const e of this.adopted)e.dispose();this.adopted=void 0;for(let e=0;e<4;e++)this.tableUniforms[`uT${e}`].value=this.transmittance.textures[e],this.tableUniforms[`uM${e}`].value=this.multiple.textures[e]}}abandonBuilding(){this.building&&(this.building=!1,He.shared.get(this.mediumKey)==="building"&&He.shared.delete(this.mediumKey))}renderSkyViews(e,t,n){if(!this.ready)return;const i=this.renderer.getRenderTarget(),r=this.skyViewMaterial.uniforms;r.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e,2),r.uSourceMu.value=Math.sin(t*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),r.uSourceMu.value=Math.sin(n*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(i)}static skyViewUv(e,t,n){const i=Ze.GROUND_RADIUS_M+Math.max(e,2),r=Ze.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(i*i-r*r,0))/i,1)),o=Math.PI-a,c=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/a,1));return{u:Math.min(Math.max(Math.abs(n)/Math.PI,0),1),v:c}}async readTable(e,t){if(e==="multiple"){const r=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,r,void 0,t),r}const n=this.transmittance,i=new Uint16Array(n.width*n.height*4);return await this.renderer.readRenderTargetPixelsAsync(n,0,0,n.width,n.height,i,void 0,t),Float32Array.from(i,r=>$i.fromHalfFloat(r))}readSkyViewNow(e){const t=e==="sun"?this.sunView:this.moonView,n=new Float32Array(t.width*t.height*4),i=this.renderer.getContext();return i.bindBuffer(i.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(t,0,0,t.width,t.height,n),n}async readSkyView(e){const t=e==="sun"?this.sunView:this.moonView,n=new Float32Array(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,n),n}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(e,t){this.quad.material=e,this.renderer.setRenderTarget(t),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const e=()=>[new nt,new nt,new nt,new nt],t=(n,i)=>{const r=e();return Ze.WAVELENGTHS_NM.forEach((a,o)=>{r[Math.floor(o/4)].setComponent(o%4,n(a)*i*Ze.WAVELENGTH_STEP_NM*Ze.SOLAR_IRRADIANCE[o])}),r};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(n=>hn.colourMatching(n)[0],683)},uCieY:{value:t(n=>hn.colourMatching(n)[1],683)},uCieZ:{value:t(n=>hn.colourMatching(n)[2],683)},uScotopic:{value:t(n=>hn.scotopic(n),1700)}}}static VERTEX=`
6006
+ `}),i.fragmentShader=r+i.fragmentShader,i.fragmentShader=i.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},e.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new C;up=new C;lookAt=new Ye;vertex=new C;centre=new C;right=new C;above=new C;set(e,t){this.placed=e,this.frame=t;const n=new Set(e.map(i=>i.sourceId));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of e){let r=this.meshes.get(i.sourceId);r||(r=new We(new ui(1,1,ii.SEGMENTS,ii.SEGMENTS),new Jn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(r.material),r.frustumCulled=!1,r.layers.set(vg),this.scene.add(r),this.meshes.set(i.sourceId,r)),r.renderOrder=ob+i.renderOrder,r.visible=!i.hidden&&i.shape.transparency<1,r.visible&&this.paint(r,i,t)}}place(e,t,n){const i=this.frame;if(i)for(const r of this.placed){const a=this.meshes.get(r.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(r.sourceId);if(!o)continue;const{bounds:c}=r.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(r.aim){const d=n(ii.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<ii.FURTHEST_NDC&&Math.abs(d.ndcY)<ii.FURTHEST_NDC?(l=(d.ndcX+1)/2*i.canvasWidthPx,h=(1-d.ndcY)/2*i.canvasHeightPx):u=!1}u?this.curve(a,e,t,i,o,l,h,r.distanceM):this.flat(a,e,i,o,r.distanceM)}}static FURTHEST_NDC=4;curve(e,t,n,i,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=e.geometry.attributes.position,d=ii.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*r.height;for(let m=0;m<=d;m++){const g=l+m/d*r.width;n(g/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(t.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(xt.sizeMAt(c,i.projection.pxToDeg(r.width)),xt.sizeMAt(c,i.projection.pxToDeg(r.height)),1)}flat(e,t,n,i,r){const a=e.geometry.attributes.position,o=ii.SEGMENTS,c=xt.sizeMAt(r,n.projection.pxToDeg(i.width)),l=xt.sizeMAt(r,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(t.quaternion),this.centre.copy(t.position).addScaledVector(this.direction,r),this.lookAt.lookAt(t.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const p=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,p*c).addScaledVector(this.above,d*l),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,e.matrixAutoUpdate=!1,e.matrix.identity(),e.matrixWorldNeedsUpdate=!0,e.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(e,t){const n=e.azimuthDeg*Math.PI/180,i=e.altitudeDeg*Math.PI/180;return t.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}get furthestM(){return this.placed.reduce((e,t)=>Math.max(e,t.distanceM),0)}paint(e,t,n){const{shape:i}=t,r=Va.paintExtent(i);this.extents.set(t.sourceId,r);const a=ii.signatureOf(i,n);if(this.signatures.get(t.sourceId)===a&&e.material.map)return;this.signatures.set(t.sourceId,a);const o=Math.min(n.scale,cb/Math.max(r.width,r.height,1)),c=Math.max(1,Math.ceil(r.width*o)),l=Math.max(1,Math.ceil(r.height*o)),h=e.material.map,u=h?.image??document.createElement("canvas"),d=u.width!==c||u.height!==l;d&&(u.width=c,u.height=l);const f=u.getContext("2d");if(!f)return;f.clearRect(0,0,c,l);const p=new Va(f);if(p.setStarPoints(n.starPoints),p.setRoll(n.rollRad),p.paintInto(i,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new Li(u);v.colorSpace=Ln,v.minFilter=dt,v.generateMipmaps=!1,e.material.map=v,e.material.needsUpdate=!0}static signatureOf(e,t){const{bounds:n}=e;return JSON.stringify([e.kind,Math.round(n.width*10),Math.round(n.height*10),e.color,e.angle,e.transparency,e.haloScale,e.blur??0,e.brightness??0,e.kind==="polygon"?e.points:void 0,t.scale,t.starPoints,t.rollRad])}dispose(e){e.removeFromParent(),e.geometry.dispose(),e.material.map?.dispose(),e.material.dispose()}clear(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}const Mg=3,jo=800,_a=Math.PI/180;class zs{constructor(e,t,n=zs.fetchImage){this.scene=e,this.onImageLoaded=t,this.loadImage=n}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(e,t=this.views){this.references=e,this.views=t;const n=new Set(e.map(i=>i.id));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i));for(const[i,r]of this.images){const a=e.find(o=>o.id===i);a&&a.src===r.texture.userData.src||(r.texture.dispose(),this.images.delete(i))}for(const i of e){const r=this.images.get(i.id);if(!r){this.load(i);continue}this.build(i,r)}}setShown(e){this.shown=e;for(const t of this.meshes.values())t.visible=e&&this.opacityOf(t.userData.id)>0}setView(e,t){this.views.set(e,t);const n=this.meshes.get(e);n&&this.applyOpacity(n,e)}get any(){for(const e of this.meshes.values())if(e.visible)return!0;return!1}place(e){for(const t of this.meshes.values())t.visible&&(t.position.copy(e.position),t.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?jo:0}directionOfPixel(e,t,n,i){const r=this.images.get(e.id),a=r?r.width/r.height:1,o=Math.tan(e.registration.fovDeg/2*_a),c=o*a;return i.set((t*2-1)*c,(1-n*2)*o,-1).normalize(),i.applyQuaternion(zs.orientation(e))}aspectOf(e){const t=this.images.get(e);return t?t.width/t.height:void 0}failedToLoad(e){return this.failed.has(e)}load(e){const t=e.src;if(this.loading.has(e.id)||this.failed.has(t))return;const n=this.loadImage(t).then(i=>{this.loading.delete(e.id);const r=this.references.find(a=>a.id===e.id);if(!r||r.src!==t){i.texture.dispose();return}i.texture.userData.src=t,this.images.set(e.id,i),this.build(r,i),this.onImageLoaded()},()=>{this.loading.delete(e.id),this.failed.add(t)});this.loading.set(e.id,n)}static async fetchImage(e){const t=await fetch(e);if(!t.ok)throw new Error(`${e}: ${t.status}`);const n=await createImageBitmap(await t.blob(),{imageOrientation:"flipY"}),i=new on(n);return i.flipY=!1,i.colorSpace=Ln,i.minFilter=dt,i.magFilter=dt,i.generateMipmaps=!1,i.needsUpdate=!0,{texture:i,width:n.width,height:n.height}}build(e,t){const n=zs.signatureOf(e,t);let i=this.meshes.get(e.id);if(i&&this.signatures.get(e.id)===n){this.applyOpacity(i,e.id);return}i&&(this.dispose(i),this.meshes.delete(e.id)),i=new We(zs.geometryOf(e,t),new Jn({map:t.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),e.kind==="panorama"&&(i.material.side=Ct),i.frustumCulled=!1,i.layers.set(Mg),i.userData.id=e.id,i.quaternion.copy(zs.orientation(e)),this.scene.add(i),this.meshes.set(e.id,i),this.signatures.set(e.id,n),this.applyOpacity(i,e.id)}static geometryOf(e,t){if(e.kind==="panorama"){const a=new fn(jo,64,32,Math.PI/2,Math.PI*2),o=a.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,a}const n=2*jo*Math.tan(e.registration.fovDeg/2*_a),i=n*(t.width/Math.max(t.height,1)),r=new ui(i,n);return r.translate(0,0,-jo),r}static orientation(e){const{headingDeg:t,pitchDeg:n,rollDeg:i}=e.registration,r=new bt;return r.rotation.set(n*_a,-t*_a,-(i??0)*_a,"YXZ"),r.quaternion}opacityOf(e){const t=this.references.find(i=>i.id===e);return this.views.get(e)?.opacity??t?.opacity??0}applyOpacity(e,t){const n=this.opacityOf(t);e.material.opacity=n,e.visible=this.shown&&n>0}static signatureOf(e,t){const{headingDeg:n,pitchDeg:i,rollDeg:r,fovDeg:a}=e.registration;return[e.kind,e.src,t.width,t.height,n,i,r??0,a].join("|")}dispose(e){this.scene.remove(e),e.geometry.dispose(),e.material.dispose()}disposeAll(){for(const e of this.meshes.values())this.dispose(e);this.meshes.clear(),this.signatures.clear();for(const e of this.images.values())e.texture.dispose();this.images.clear()}}class Ze{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(e,t)=>410+20*t);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(e={}){const t=Ze.WAVELENGTHS_NM.length,n=e.aerosolOpticalDepth??Ze.DEFAULT_AEROSOL_OPTICAL_DEPTH,i=e.ozoneDobson??Ze.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(t),this.aerosolScattering=new Float64Array(t),this.aerosolExtinction=new Float64Array(t),this.ozoneAbsorption=new Float64Array(t);const r=i*2687e17/Ze.OZONE_HALF_WIDTH_M;for(let a=0;a<t;a++){const o=Ze.WAVELENGTHS_NM[a];this.rayleighScattering[a]=Ze.rayleighAt(o);const c=n/Ze.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[a]=c,this.aerosolScattering[a]=c*Ze.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[a]=Ze.OZONE_CROSS_SECTION[a]*1e-25*r}}static rayleighAt(e){const t=e/1e3,n=1/(t*t),i=t*t;return(1.0455996-341.29061*n-.9023085*i)/(1+.0027059889*n-85.968563*i)*1e-28*1e-4*2546899e19}static rayleighDensity(e){return Math.exp(-Math.max(e,0)/Ze.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(e){return Math.exp(-Math.max(e,0)/Ze.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(e){return Math.max(0,1-Math.abs(e-Ze.OZONE_PEAK_ALTITUDE_M)/Ze.OZONE_HALF_WIDTH_M)}static rayleighPhase(e){return 3/(16*Math.PI)*(1+e*e)}static aerosolPhase(e,t=Ze.AEROSOL_ASYMMETRY){const n=t*t;return 3/(8*Math.PI)*(1-n)*(1+e*e)/((2+n)*Math.pow(Math.max(1+n-2*t*e,1e-6),1.5))}}class st{static RESPONSE_EXPONENT=.74;static DAYLIGHT_ANCHOR_CD_M2=3e3;static DAYLIGHT_ANCHOR_RESPONSE=.42;static NIGHT_ANCHOR_CD_M2=172e-6;static NIGHT_ANCHOR_RESPONSE=.006;static anchoredSemiSaturation(e,t){return e*(1/t-1)**(1/st.RESPONSE_EXPONENT)}static get ADAPTATION_EXPONENT(){const e=st.anchoredSemiSaturation(st.DAYLIGHT_ANCHOR_CD_M2,st.DAYLIGHT_ANCHOR_RESPONSE),t=st.anchoredSemiSaturation(st.NIGHT_ANCHOR_CD_M2,st.NIGHT_ANCHOR_RESPONSE);return Math.log(e/t)/Math.log(st.DAYLIGHT_ANCHOR_CD_M2/st.NIGHT_ANCHOR_CD_M2)}static ROD_HALF_LUMINANCE_CD_M2=.04;static SCOTOPIC_TINT=[.853,.995,1.483];static get SEMI_SATURATION_SCALE(){return st.anchoredSemiSaturation(st.DAYLIGHT_ANCHOR_CD_M2,st.DAYLIGHT_ANCHOR_RESPONSE)/st.DAYLIGHT_ANCHOR_CD_M2**st.ADAPTATION_EXPONENT}static rodShare(e){return st.ROD_HALF_LUMINANCE_CD_M2/(st.ROD_HALF_LUMINANCE_CD_M2+Math.max(e,0))}static semiSaturation(e){return st.SEMI_SATURATION_SCALE*Math.max(e,1e-9)**st.ADAPTATION_EXPONENT}static response(e,t){const n=st.RESPONSE_EXPONENT,i=Math.max(e,0)**n;return i/(i+st.semiSaturation(t)**n)}static displayOf(e,t,n,i=st.rodShare(n)){const r=(1-i)*e[1]+i*t,a=st.response(r,n),[o,c,l]=hn.linearSrgbOf(e),h=Math.max(e[1],1e-12),u=st.SCOTOPIC_TINT,d=.2126*u[0]+.7152*u[1]+.0722*u[2],f=(p,v)=>Math.max(0,(1-i)*p/h+i*v/d)*a;return[f(o,u[0]),f(c,u[1]),f(l,u[2])]}}class ze{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_ROWS=16;static MULTIPLE_HEIGHT_POWER=2;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=12;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new Zr;camera=new ws(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(e){this.renderer=e,this.supported=e.capabilities.isWebGL2&&e.extensions.has("EXT_color_buffer_float"),this.transmittance=new dn(ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,{count:4,type:cn,minFilter:dt,magFilter:dt,depthBuffer:!1}),this.multiple=new dn(ze.MULTIPLE_SIZE,ze.MULTIPLE_ROWS,{count:4,type:Tn,minFilter:Tt,magFilter:Tt,depthBuffer:!1});const t=()=>new dn(ze.SKY_VIEW_WIDTH,ze.SKY_VIEW_HEIGHT,{type:Tn,minFilter:Tt,magFilter:Tt,depthBuffer:!1});this.sunView=t(),this.moonView=t();const n=ze.mediumUniforms(),i=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},r=(a,o={})=>new Em({glslVersion:wc,uniforms:{...n,...i,...o},vertexShader:ze.VERTEX,fragmentShader:a,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=r(ze.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=r(ze.MULTIPLE_FRAGMENT),this.skyViewMaterial=r(ze.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new We(new ui(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=ze.MULTIPLE_ROWS)}setMedium(e){const t=[e.rayleighScattering,e.aerosolScattering,e.aerosolExtinction,e.ozoneAbsorption].map(i=>Array.from(i,r=>r.toPrecision(6)).join(",")).join("|");if(t===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=t;const n=(i,r)=>{const a=this.transmittanceMaterial.uniforms[i].value;for(let o=0;o<4;o++)a[o].set(r[o*4]??0,r[o*4+1]??0,r[o*4+2]??0,r[o*4+3]??0)};n("uRayleigh",e.rayleighScattering),n("uAerosolScattering",e.aerosolScattering),n("uAerosolExtinction",e.aerosolExtinction),n("uOzone",e.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(e){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const t=ze.shared.get(this.mediumKey);if(t&&t!=="building")return this.adopt(t),!0;if(t==="building"&&!this.building)return!1;t||(ze.shared.set(this.mediumKey,"building"),this.building=!0);const n=this.renderer.getRenderTarget();let i=Math.max(1,e);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,i--);const r=ze.MULTIPLE_SIZE,a=ze.MULTIPLE_BLOCK;for(;i>0&&this.multipleRows<ze.MULTIPLE_ROWS;i--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,a,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=a,this.multipleColumn>=r&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(n),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(e){this.building=!1;try{const t=await Promise.all([0,1,2,3].map(i=>this.readRaw(this.transmittance,i,Uint16Array))),n=await Promise.all([0,1,2,3].map(i=>this.readRaw(this.multiple,i,Float32Array)));this.mediumKey===e?ze.shared.set(e,{transmittance:t,multiple:n}):ze.shared.delete(e)}catch{ze.shared.delete(e)}}async readRaw(e,t,n){const i=new n(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,i,void 0,t),i}adopt(e){const t=(r,a,o,c)=>{const l=new js(r,a,o,_n,c?cn:Tn);return l.minFilter=l.magFilter=c?dt:Tt,l.needsUpdate=!0,l},n=e.transmittance.map(r=>t(r,ze.TRANSMITTANCE_WIDTH,ze.TRANSMITTANCE_HEIGHT,!0)),i=e.multiple.map(r=>t(r,ze.MULTIPLE_SIZE,ze.MULTIPLE_ROWS,!1));n.forEach((r,a)=>this.tableUniforms[`uT${a}`].value=r),i.forEach((r,a)=>this.tableUniforms[`uM${a}`].value=r),this.adopted=[...n,...i]}releaseAdopted(){if(this.adopted){for(const e of this.adopted)e.dispose();this.adopted=void 0;for(let e=0;e<4;e++)this.tableUniforms[`uT${e}`].value=this.transmittance.textures[e],this.tableUniforms[`uM${e}`].value=this.multiple.textures[e]}}abandonBuilding(){this.building&&(this.building=!1,ze.shared.get(this.mediumKey)==="building"&&ze.shared.delete(this.mediumKey))}renderSkyViews(e,t,n){if(!this.ready)return;const i=this.renderer.getRenderTarget(),r=this.skyViewMaterial.uniforms;r.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e,2),r.uSourceMu.value=Math.sin(t*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),r.uSourceMu.value=Math.sin(n*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(i)}static skyViewUv(e,t,n){const i=Ze.GROUND_RADIUS_M+Math.max(e,2),r=Ze.GROUND_RADIUS_M,a=Math.acos(Math.min(Math.sqrt(Math.max(i*i-r*r,0))/i,1)),o=Math.PI-a,c=t<o?.5*(1-Math.sqrt(Math.max(1-t/o,0))):.5+.5*Math.sqrt(Math.min((t-o)/a,1));return{u:Math.min(Math.max(Math.abs(n)/Math.PI,0),1),v:c}}async readTable(e,t){if(e==="multiple"){const r=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,r,void 0,t),r}const n=this.transmittance,i=new Uint16Array(n.width*n.height*4);return await this.renderer.readRenderTargetPixelsAsync(n,0,0,n.width,n.height,i,void 0,t),Float32Array.from(i,r=>$i.fromHalfFloat(r))}readSkyViewNow(e){const t=e==="sun"?this.sunView:this.moonView,n=new Float32Array(t.width*t.height*4),i=this.renderer.getContext();return i.bindBuffer(i.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(t,0,0,t.width,t.height,n),n}async readSkyView(e){const t=e==="sun"?this.sunView:this.moonView,n=new Float32Array(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,n),n}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(e,t){this.quad.material=e,this.renderer.setRenderTarget(t),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const e=()=>[new nt,new nt,new nt,new nt],t=(n,i)=>{const r=e();return Ze.WAVELENGTHS_NM.forEach((a,o)=>{r[Math.floor(o/4)].setComponent(o%4,n(a)*i*Ze.WAVELENGTH_STEP_NM*Ze.SOLAR_IRRADIANCE[o])}),r};return{uRayleigh:{value:e()},uAerosolScattering:{value:e()},uAerosolExtinction:{value:e()},uOzone:{value:e()},uCieX:{value:t(n=>hn.colourMatching(n)[0],683)},uCieY:{value:t(n=>hn.colourMatching(n)[1],683)},uCieZ:{value:t(n=>hn.colourMatching(n)[2],683)},uScotopic:{value:t(n=>hn.scotopic(n),1700)}}}static VERTEX=`
6007
6007
  in vec3 position;
6008
6008
  void main() {
6009
6009
  gl_Position = vec4(position.xy, 0.0, 1.0);
@@ -6021,11 +6021,12 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6021
6021
  const float OZONE_PEAK = ${Ze.OZONE_PEAK_ALTITUDE_M.toFixed(1)};
6022
6022
  const float OZONE_HALF_WIDTH = ${Ze.OZONE_HALF_WIDTH_M.toFixed(1)};
6023
6023
  const float AEROSOL_G = ${Ze.AEROSOL_ASYMMETRY.toFixed(4)};
6024
- const float GROUND_ALBEDO = ${He.GROUND_ALBEDO.toFixed(4)};
6025
- const int STEPS = ${He.STEPS};
6026
- const int MULTIPLE_STEPS = ${He.MULTIPLE_STEPS};
6027
- const vec2 T_SIZE = vec2(${He.TRANSMITTANCE_WIDTH}.0, ${He.TRANSMITTANCE_HEIGHT}.0);
6028
- const float M_SIZE = ${He.MULTIPLE_SIZE}.0;
6024
+ const float GROUND_ALBEDO = ${ze.GROUND_ALBEDO.toFixed(4)};
6025
+ const int STEPS = ${ze.STEPS};
6026
+ const int MULTIPLE_STEPS = ${ze.MULTIPLE_STEPS};
6027
+ const vec2 T_SIZE = vec2(${ze.TRANSMITTANCE_WIDTH}.0, ${ze.TRANSMITTANCE_HEIGHT}.0);
6028
+ const vec2 M_SIZE = vec2(${ze.MULTIPLE_SIZE}.0, ${ze.MULTIPLE_ROWS}.0);
6029
+ const float M_HEIGHT_POWER = ${ze.MULTIPLE_HEIGHT_POWER.toFixed(1)};
6029
6030
 
6030
6031
  uniform vec4 uRayleigh[4];
6031
6032
  uniform vec4 uAerosolScattering[4];
@@ -6101,12 +6102,12 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6101
6102
  #ifdef BUILDING_MULTIPLE
6102
6103
  for (int k = 0; k < 4; k++) m[k] = vec4(0.0);
6103
6104
  #else
6104
- vec2 uv = vec2((muSun + 1.0) * 0.5, (r - GROUND) / (TOP - GROUND));
6105
- vec2 size = vec2(M_SIZE);
6106
- m[0] = fetchBilinear(uM0, uv, size);
6107
- m[1] = fetchBilinear(uM1, uv, size);
6108
- m[2] = fetchBilinear(uM2, uv, size);
6109
- m[3] = fetchBilinear(uM3, uv, size);
6105
+ float height = max(r - GROUND, 0.0) / (TOP - GROUND);
6106
+ vec2 uv = vec2((muSun + 1.0) * 0.5, pow(height, 1.0 / M_HEIGHT_POWER));
6107
+ m[0] = fetchBilinear(uM0, uv, M_SIZE);
6108
+ m[1] = fetchBilinear(uM1, uv, M_SIZE);
6109
+ m[2] = fetchBilinear(uM2, uv, M_SIZE);
6110
+ m[3] = fetchBilinear(uM3, uv, M_SIZE);
6110
6111
  #endif
6111
6112
  }
6112
6113
 
@@ -6168,7 +6169,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6168
6169
  }
6169
6170
  }
6170
6171
  `;static TRANSMITTANCE_FRAGMENT=`
6171
- ${He.COMMON}
6172
+ ${ze.COMMON}
6172
6173
  layout(location = 0) out vec4 out0;
6173
6174
  layout(location = 1) out vec4 out1;
6174
6175
  layout(location = 2) out vec4 out2;
@@ -6202,16 +6203,16 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6202
6203
  }
6203
6204
  `;static MULTIPLE_FRAGMENT=`
6204
6205
  #define BUILDING_MULTIPLE
6205
- ${He.COMMON}
6206
+ ${ze.COMMON}
6206
6207
  layout(location = 0) out vec4 out0;
6207
6208
  layout(location = 1) out vec4 out1;
6208
6209
  layout(location = 2) out vec4 out2;
6209
6210
  layout(location = 3) out vec4 out3;
6210
- const int DIRECTIONS = ${He.MULTIPLE_DIRECTIONS};
6211
+ const int DIRECTIONS = ${ze.MULTIPLE_DIRECTIONS};
6211
6212
 
6212
6213
  void main() {
6213
- vec2 uv = gl_FragCoord.xy / vec2(M_SIZE);
6214
- float r = clamp(GROUND + uv.y * (TOP - GROUND), GROUND + 1.0, TOP - 1.0);
6214
+ vec2 uv = gl_FragCoord.xy / M_SIZE;
6215
+ float r = clamp(GROUND + pow(uv.y, M_HEIGHT_POWER) * (TOP - GROUND), GROUND + 1.0, TOP - 1.0);
6215
6216
  float muSun = uv.x * 2.0 - 1.0;
6216
6217
  vec3 origin = vec3(0.0, r, 0.0);
6217
6218
  vec3 sun = vec3(0.0, muSun, sqrt(max(1.0 - muSun * muSun, 0.0)));
@@ -6244,7 +6245,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6244
6245
  out3 = result[3];
6245
6246
  }
6246
6247
  `;static SKY_VIEW_FRAGMENT=`
6247
- ${He.COMMON}
6248
+ ${ze.COMMON}
6248
6249
  uniform float uObserverRadius;
6249
6250
  uniform float uSourceMu;
6250
6251
  uniform vec4 uCieX[4];
@@ -6254,7 +6255,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6254
6255
  out vec4 outColor;
6255
6256
 
6256
6257
  void main() {
6257
- vec2 uv = gl_FragCoord.xy / vec2(${He.SKY_VIEW_WIDTH}.0, ${He.SKY_VIEW_HEIGHT}.0);
6258
+ vec2 uv = gl_FragCoord.xy / vec2(${ze.SKY_VIEW_WIDTH}.0, ${ze.SKY_VIEW_HEIGHT}.0);
6258
6259
  float r = uObserverRadius;
6259
6260
  float beta = acos(clamp(sqrt(max(r * r - GROUND * GROUND, 0.0)) / r, -1.0, 1.0));
6260
6261
  float zenithHorizon = PI - beta;
@@ -6278,7 +6279,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6278
6279
  }
6279
6280
  outColor = xyzs;
6280
6281
  }
6281
- `}class en{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(e,t){this.onChange=t,this.tables=new He(e),this.tables.setMedium(new Ze),this.material=new Rt({glslVersion:wc,side:Ct,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new Ae(0,-1)},uMoonAzimuth:{value:new Ae(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uAirglow:{value:new nt(...en.airglowXyzs())},uRodShare:{value:0},uSemiSaturationN:{value:1},uExposureScale:{value:1}},vertexShader:`
6282
+ `}class en{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(e,t){this.onChange=t,this.tables=new ze(e),this.tables.setMedium(new Ze),this.material=new Rt({glslVersion:wc,side:Ct,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new Ae(0,-1)},uMoonAzimuth:{value:new Ae(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Ze.GROUND_RADIUS_M+2},uAirglow:{value:new nt(...en.airglowXyzs())},uRodShare:{value:0},uSemiSaturationN:{value:1},uExposureScale:{value:1}},vertexShader:`
6282
6283
  varying vec3 vDirection;
6283
6284
  void main() {
6284
6285
  vDirection = (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition;
@@ -6304,7 +6305,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6304
6305
  const float GROUND = ${Ze.GROUND_RADIUS_M.toFixed(1)};
6305
6306
  const float AIRGLOW_RATIO = ${(Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+en.AIRGLOW_LAYER_ALTITUDE_M)).toFixed(6)};
6306
6307
  const float EXTINCTION = ${Ge.EXTINCTION_PER_AIR_MASS.toFixed(4)};
6307
- const vec2 VIEW_SIZE = vec2(${He.SKY_VIEW_WIDTH}.0, ${He.SKY_VIEW_HEIGHT}.0);
6308
+ const vec2 VIEW_SIZE = vec2(${ze.SKY_VIEW_WIDTH}.0, ${ze.SKY_VIEW_HEIGHT}.0);
6308
6309
  const float RESPONSE_EXPONENT = ${st.RESPONSE_EXPONENT.toFixed(4)};
6309
6310
  const vec3 SCOTOPIC_TINT = vec3(${st.SCOTOPIC_TINT.map(n=>n.toFixed(4)).join(", ")});
6310
6311
 
@@ -6360,7 +6361,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
6360
6361
  gl_FragColor = vec4(displayOf(light.xyz, light.w), 1.0);
6361
6362
  #include <colorspace_fragment>
6362
6363
  }
6363
- `})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(e,t){const n=e?10**(.4*t):1;n===this.exposureScale&&this.seenByEye===!e||(this.exposureScale=n,this.seenByEye=!e,this.material.uniforms.uExposureScale.value=n,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(e){this.tables.setMedium(new Ze(e)),this.tables.ready||(this.drawnKey="")}advance(e){!this.supported||this.tables.ready||this.tables.advance(e)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(e){this.state=e,this.tables.ready?this.draw(e):this.hasViews||this.applyAdaptation(en.predictedZenithLuminance(e))}dispose(){this.tables.dispose(),this.material.dispose()}draw(e){const t=[e.altitudeM.toFixed(0),e.sun.altitudeDeg.toFixed(3),e.moon.altitudeDeg.toFixed(3)].join(":"),n=this.material.uniforms;if(n.uSunAzimuth.value.copy(en.azimuthVector(e.sun.azimuthDeg)),n.uMoonAzimuth.value.copy(en.azimuthVector(e.moon.azimuthDeg)),n.uMoonScale.value=10**(-.4*(e.moon.magnitude-en.SUN_MAGNITUDE)),n.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e.altitudeM,2),t!==this.drawnKey){this.tables.renderSkyViews(e.altitudeM,e.sun.altitudeDeg,e.moon.altitudeDeg);const i=!this.hasViews;this.hasViews=!0,this.drawnKey=t,i&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),e),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;try{const[e,t]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),n=this.state;n&&this.adaptFromViews(e,t,n)}finally{this.reading=!1}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptFromViews(e,t,n){const i=10**(-.4*(n.moon.magnitude-en.SUN_MAGNITUDE)),r=en.airglowXyzs(),a=(u,d)=>{const f=(90-u)*Math.PI/180,p=He.skyViewUv(n.altitudeM,f,en.azimuthBetween(d,n.sun.azimuthDeg)),v=He.skyViewUv(n.altitudeM,f,en.azimuthBetween(d,n.moon.azimuthDeg)),m=en.bilinear(e,p.u,p.v),g=en.bilinear(t,v.u,v.v),S=u>0?en.airglowFactor(u):0;return[0,1,2,3].map(b=>m[b]+i*g[b]+r[b]*S)};let o=0,c=0;for(let u=5;u<90;u+=10){const d=Math.cos(u*Math.PI/180);for(let f=0;f<360;f+=30)o+=d*Math.log(Math.max(a(u,f)[1],1e-9)),c+=d}this.applyAdaptation(Math.exp(o/c));const l=(u,d)=>{const f=this.exposureScale,[p,v,m,g]=a(u,d),S=this.adaptingLuminance*f;return st.displayOf([p*f,v*f,m*f],g*f,S,this.seenByEye?st.rodShare(S):0)},h=[0,0,0];for(let u=0;u<360;u+=20){const d=l(2,u);for(let f=0;f<3;f++)h[f]+=d[f]/18}this.ambientColours={zenith:l(90,0),horizon:h},this.onChange()}applyAdaptation(e){this.adaptingLuminance=e;const t=e*this.exposureScale;this.material.uniforms.uRodShare.value=this.seenByEye?st.rodShare(t):0,this.material.uniforms.uSemiSaturationN.value=st.semiSaturation(t)**st.RESPONSE_EXPONENT}static predictedZenithLuminance(e){const t=i=>90-i.altitudeDeg,n=Ge.magPerArcsec2({altitudeDeg:e.sun.altitudeDeg,separationDeg:t(e.sun)},{phaseAngleDeg:e.moon.phaseAngleDeg,altitudeDeg:e.moon.altitudeDeg,separationDeg:t(e.moon)},90);return Ge.toNanolamberts(n)*en.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const e=Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2)*en.CANDELAS_PER_NANOLAMBERT;return[e*.3127/.329,e,e*(1-.3127-.329)/.329,e]}static airglowFactor(e){const t=Math.cos(e*Math.PI/180)**2,n=Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+en.AIRGLOW_LAYER_ALTITUDE_M),i=1/Math.sqrt(Math.max(1-n*n*t,1e-4)),r=1/Math.sqrt(Math.max(1-.96*t,.001));return i*10**(-.4*Ge.EXTINCTION_PER_AIR_MASS*(r-1))}static azimuthVector(e){const t=e*Math.PI/180;return new Ae(Math.sin(t),-Math.cos(t))}static azimuthBetween(e,t){const n=Math.abs(e-t)%360;return(n>180?360-n:n)*Math.PI/180}static bilinear(e,t,n){const i=He.SKY_VIEW_WIDTH,r=He.SKY_VIEW_HEIGHT,a=Math.min(Math.max(t*i-.5,0),i-1),o=Math.min(Math.max(n*r-.5,0),r-1),c=Math.floor(a),l=Math.floor(o),h=Math.min(c+1,i-1),u=Math.min(l+1,r-1),d=a-c,f=o-l,p=(v,m,g)=>e[(v*i+m)*4+g];return[0,1,2,3].map(v=>(p(l,c,v)*(1-d)+p(l,h,v)*d)*(1-f)+(p(u,c,v)*(1-d)+p(u,h,v)*d)*f)}}class Ur{static DRY_OPTICAL_DEPTH=.08;static GROWTH_EXPONENT=.3;static MAX_RELATIVE_HUMIDITY=.95;static OPTICAL_DEPTH_STEP=.02;static relativeHumidity(e,t){const n=i=>Math.exp(17.625*i/(243.04+i));return Math.min(Math.max(n(t)/n(e),0),1)}static opticalDepth(e){const t=Math.min(Math.max(e,0),Ur.MAX_RELATIVE_HUMIDITY);return Ur.DRY_OPTICAL_DEPTH*(1-t)**-.3}static steppedOpticalDepth(e){const t=Ur.OPTICAL_DEPTH_STEP;return Math.round(Ur.opticalDepth(e)/t)*t}}function lb(s,e){return JSON.stringify(s.cloudLayers)===JSON.stringify(e.cloudLayers)&&s.cloudCover===e.cloudCover&&s.cloudDarkness===e.cloudDarkness&&s.cloudBaseM===e.cloudBaseM&&s.highCloudCover===e.highCloudCover&&s.iceCrystalAlignment===e.iceCrystalAlignment&&s.lowerCloudCover===e.lowerCloudCover&&s.relativeHumidity===e.relativeHumidity&&s.precipitationType===e.precipitationType&&s.precipitationIntensity===e.precipitationIntensity&&s.windDirectionDeg===e.windDirectionDeg&&s.windSpeed===e.windSpeed&&s.storm===e.storm}const Qo=900,eh=1,rp=.5,Ca=900,hb=6371e3,ub=3e4;function ap(s){const e=Math.sqrt(2*hb*Math.max(s,0));return Math.max(Ca,Math.min(e,ub))}const th=.5,nh=850,op=.03,Tr=850,ih=4,sh=1.5,cp=-1,db=6,Hu=-4,lp=.2,ec=2600,fb=.97,pb=.38,hp=Hu,mb=3,gb=.15,vb=.6,Mb=40,xb=30,_b=[0,45,90,135,180,225,270,315],yb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},Sb=["en","fr"],bb=2,Eb=16,up=2500,dp=880,tc=40,fp=60,wb=10,Ab=1,Tb=150,Rb=55,Db=.5,Cb=2.05,pp=.265,mp=[[0,0],...Array.from({length:8},(s,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*pp,Math.sin(t)*pp]})],rh=700,ah=250/1e3,Ib=12,gp=5,oh=6,Ps=[.92,.92,.95],ch=[.15,.15,.19],vp={snow:{fallSpeedMPerS:2,size:.3,color:new oe(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new oe(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Cr=0,lh=0,Pb=150,Mp=3e3,ya=20,Lb=15,xp=Cr,Nb=40,_p=1,Ob=9;function yp(s){return _p+(Ob-_p)*s}const Ub=new oe(.75,.82,.92),Fb=10,kb=.5;function zb(s){return Fa(s/Fb,kb,1)}const Rr=200,Sp=.18,bp=.32,Bb=.35,Hb=new oe(.85,.9,.98),Ep=5,wp=.85,Ap=.01;function hh(s,e){return Math.round(s*(Ap+(1-Ap)*e))}const Tp=230,Rp=.7,Dp=.05,Gb=.6,Vb=.7,Wb=.15,Cp=.35,Xb=3,qb=1/12,Yb=.5,xi=new oe(.82,.86,1),Kb=2500,$b=1.6,Zb=1.2,Jb=2.2,jb={Venus:new oe(1,.96,.85),Mars:new oe(1,.55,.4),Jupiter:new oe(.95,.87,.72),Saturn:new oe(.92,.86,.68)};class Yn{renderer;scene=new Zr;phenomena=new ii(this.scene);references=new zs(this.scene,()=>this.render());camera;celestialGroup=new rn;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=rb[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new j0(16777215,0);celestialLightTarget=new bt;skyLight=new Tv(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new Ol;weather=zp;observerElevationM=0;siteElevationM=0;groundRadius=Ca;terrainRadius=Ca;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new C;cloudFieldOffset=new C;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new C;rainLastVerticalFacing=-1;rainViewportSize=new Ae;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new j0(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new C;sunVisible=!1;lensFlareScratch=new C;sunOcclusionRaycaster=new Ol;sunOcclusionDirectionScratch=new C;sunOcclusionRightScratch=new C;sunOcclusionUpScratch=new C;ufoOcclusionRaycaster=new Ol;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(e){return Math.max(3,Math.round(6e6/Math.max(1,e)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=R1()){this.renderer=new ky({canvas:e,antialias:!0}),this.resolution=new wt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Ia,this.camera=new Nn(60,e.width/Math.max(e.height,1),.1,Qo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(xi),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup);const n=new en(this.renderer,()=>{this.skyColoursStale=!0,this.render()});n.supported?this.scatteredSky=n:n.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}resize(e,t){this.cssSize.width=e,this.cssSize.height=t,this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(e){e!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=e,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(e,t={}){this.cloudOffsetM.set(e.x,0,e.z),this.cloudLayerOffsetsM=t,this.layeredClouds?.setOffsets(e,t),this.cloudFieldOffset.set(e.x*ah,0,e.z*ah);for(const n of[this.cloudUniforms,this.cirrusUniforms])n?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*Dn,n=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Dn;if(e.headingDeg!==void 0?this.camera.rotation.set(n,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Dn,t,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(ap(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/Ca),this.camera.far=Math.max(Qo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const i=un(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:c,z:l}=un(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<Tb*(i/Ca))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=i;const o=++this.terrainBuildToken;A5(e,t,this.terrainProviders,i).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=r?un(e,t,r.lat,r.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=Ab,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.render(),n?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),n?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=Rb*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=gS(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=ds(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=Cb**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;if(this.compassSprites.some(t=>t.visible!==e)){for(const t of this.compassSprites)t.visible=e;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(e){this.cloudTransmissionMemo.clear(),!lb(this.weather,e)&&(this.weather=e,this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:Ur.steppedOpticalDepth(e.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=Yb,this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),ln.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=ln.build(t,t.lit??!1);this.scene.add(n),this.decorGroups.set(t.id,n),t.kind==="streetlight"&&this.addStreetlightLight(t.id,n),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const n=e.model;if(!(!n||!ln.usesModel(e)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,r=n.url??i?.url,a=n.credit??i?.credit;if(!r||!a)return;const o=await ab(r);if(t!==this.decorModelToken)return;const c=this.decorGroups.get(e.id);if(!c)return;ln.applyModel(c,e,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(e.id,a),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${e.id}":`,i)}}updateDecorAnchoring(e,t,n=0){this.decorReferencePose=e,this.decorCurrentPose=t,this.decorTime=n;const i=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?un(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Vp(l.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const l=un(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=l.x-(r?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(r?0:this.gaitOffset.northM)}r||(i.x-=this.gaitOffset.eastM,i.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(r){const l=ln.occupantView(r),h=-(r.headingDeg??0)*Dn,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=r.eastM+i.x,p=-r.northM+i.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Dn,-(l.headingDeg+this.indoorLookYawDeg)*Dn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Vu(l,n),d=u.eastM+i.x+a.x,f=-u.northM+i.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=Pb}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Dn),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==g&&(ln.fitCropToGround(h,(S,b)=>this.groundYUnder(S,b)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Qo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,e-n.position.x,t-n.position.z):lh}groundYOfPatch(e,t,n){const i=e.geometry.getAttribute("position"),r=Math.round(Math.sqrt(i.count));if(r<2||r*r!==i.count)return lh;const a=i.getX(0),o=i.getX(r-1),c=i.getZ(0),l=i.getZ((r-1)*r),h=Fa((t-a)/(o-a)*(r-1),0,r-1),u=Fa((n-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return lh;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),p=h-d,v=u-f,m=(E,w)=>i.getY(E*r+w),g=m(f,d),S=m(f,d+1),b=m(f+1,d),_=m(f+1,d+1);return p+v<=1?g+(S-g)*p+(b-g)*v:_+(b-_)*(1-p)+(S-_)*(1-v)}groundUnderFootprint(e,t,n,i,r=0){return ln.groundUnderFootprint(e,t,n,i,(a,o)=>this.groundYUnder(a,o),r)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&ln.setLights(i,n.lights,e,i.position.distanceTo(this.camera.position),t),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=u1(n,e);ln.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const n=ln.bodyOf(t),i=n.children.find(a=>a.userData.emissive);if(!i)return;const r=new Cv(16764006,Mb,xb);r.position.copy(i.position).multiply(n.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,t.add(r),this.streetlightLights.set(e,r)}setAstronomy(e){this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&this.scatteredSky&&!this.scatteredSky.ambient&&(this.skyHoldUntilMs=performance.now()+up,setTimeout(()=>this.render(),up+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=Mu(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.setBodyMesh("sun",e.sun,ih,new oe(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,t),this.buildPlanets(e.planets,t),this.buildComet(e.comet,t),this.buildNovae(e.novae??[],t),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}applySkyColours(e){this.skyColoursStale=!1;const t=this.scatteredSky?.ambient??vu(e.sun.altitudeDeg),n=t.horizon;this.baseFogColor=[n[0],n[1],n[2]],this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCloudLighting(e.sun,this.baseFogColor),this.updateCelestialLight(e,t.zenith,n),this.buildSkyGlow(e,t.zenith),this.scene.fog instanceof Tc?(this.scene.fog.color.setRGB(...this.baseFogColor),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new Tc(new oe(...this.baseFogColor),this.groundRadius*.2,this.groundRadius)}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(e){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:e.sun.altitudeDeg,azimuthDeg:e.sun.azimuthDeg,magnitude:e.sun.magnitude},moon:{altitudeDeg:e.moon.altitudeDeg,azimuthDeg:e.moon.azimuthDeg,magnitude:e.moon.magnitude,phaseAngleDeg:Ge.phaseAngleOf(e.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const e=this.scatteredSky;!e||e.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(e.advance(this.skyHoldUntilMs?Eb:bb),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(e){if(e.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new H5(nh),this.celestialGroup.add(this.satelliteField.object));const t=Mu(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,n=>this.cloudTransmission(n)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=Math.cos(op*this.camera.fov*Math.PI/180),i=this.satelliteField.nearest(this.raycaster.ray.direction,n);return i&&this.groundHides(e,t)?void 0:i}updateCelestialLight(e,t,n){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=vb;const i=e.sun.altitudeDeg>=hp,r=!i&&e.moon.altitudeDeg>=hp;if(!i&&!r){this.celestialLight.intensity=0;return}const a=i?e.sun:e.moon,{x:o,y:c,z:l}=nn(a.altitudeDeg,a.azimuthDeg,Tr);this.celestialLight.position.set(o,c,l);const h=ds(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*Dn));this.celestialLight.intensity=(i?mb:gb)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new Qt,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=Yt.starPointsOf(e),n=Yt.flareArtifactsOf(e);t===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(e,t=!1){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0,this.scatteredSky?.setInstrument(t,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.scatteredSky?.ambient&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const e=this.compileOffThread().then(()=>{this.compiling===e&&(this.compiling=void 0,this.render())});this.compiling=e;return}if(!this.compiling){this.frameDirty=!1,this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const e=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const t=this.renderer.properties,n=performance.now()+Yn.COMPILE_WAIT_MS;return new Promise(i=>{const r=()=>{if(this.contextReleased)return i();for(const a of e){const o=t.get(a)?.currentProgram;(!o||o.isReady())&&e.delete(a)}e.size===0||performance.now()>n?i():setTimeout(r,10)};r()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(e){if(this.animationsRunning){const t=this.lastFrameTimeMs===void 0?0:e-this.lastFrameTimeMs;this.lastFrameTimeMs=e,this.hasAnimations()&&this.animate(e,t);const n=this.resolution.update(e,t);n!==void 0&&this.applyPixelRatio(n)}this.drawIfDirty()}animate(e,t){const n=Math.min(t/1e3,qb);this.updateTwinkle(e/1e3),this.updatePrecipitation(e/1e3,n),this.updateRain(n),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=e/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(e){this.resolution.maximum=e,this.renderer.getPixelRatio()!==this.resolution.pixelRatio&&this.applyPixelRatio(this.resolution.pixelRatio)}applyPixelRatio(e){this.renderer.setPixelRatio(e),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(e,t){const n=t?Math.max(1,Math.round(e)):1;if(n===this.exposureInstants&&(n===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=n,this.exposureInstantAt=t,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){if(this.onMapSubjectBounds){const r=this.mapSubjectBounds();e?this.exposureSubjectBounds.push(...r):this.onMapSubjectBounds(r)}const t=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(r,a,o)=>this.directionAtScreenPoint(r,a,o),r=>this.screenPointOf(r)),this.references.place(this.camera);const n=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!r),e&&this.renderer.setRenderTarget(e),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderOverlayPasses()):(this.renderer.render(this.scene,this.camera),this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(i);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(i)}renderOverlayPasses(){this.renderReferencesPass(),this.renderPhenomenaPass()}renderReferencesPass(){if(!this.references.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.camera.layers.set(Mg),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}setReferences(e){this.references.set(e)}referenceAspect(e){return this.references.aspectOf(e)}directionAt(e,t){return this.directionAtScreenPoint(e,t,new C)}referenceFailedToLoad(e){return this.references.failedToLoad(e)}setReferencesShown(e){this.references.setShown(e),this.render()}setReferenceView(e,t){this.references.setView(e,t),this.render()}renderPhenomenaPass(){if(!this.phenomena.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&Yn.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(eh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(vg),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}decorDepthMaterial=new Jn({colorWrite:!1});static markDecorDepth(e,t){e.traverse(n=>{if(!(n instanceof We))return;const i=Array.isArray(n.material)?n.material[0]:n.material;t&&i.depthWrite!==!1&&i.blending!==Gn?n.layers.enable(eh):n.layers.disable(eh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new Ae),t=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new Ky(t,n)),this.exposureAccumulation.resize(t,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const n=1/this.exposureInstants;this.resolution.beginDrawing();const i=performance.now()+Yn.EXPOSURE_BUDGET_MS,r=Yn.exposureInstantsPerFrame(t.instantTarget.width*t.instantTarget.height);let a=0;do{this.restateAt(e,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(t.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}t.add(this.renderer,n),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i&&a<r);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(r=>r.visible))return;const e=new Zr,t=new ws(-1,1,1,-1,0,2),n=tc/(dp*Math.tan(fp*Dn/2));for(const r of this.compassSprites){if(!r.visible)continue;const a=r.getWorldPosition(new C).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new xr(r.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(n/this.camera.aspect,n,1),e.add(c)}const i=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(e,t)}finally{this.renderer.autoClear=i}}onMapSubjectBounds;exposureSubjectBounds=[];mapSubjectBounds(){const e=[],t=new hi,n=new C;for(const i of this.decorObjects){if(!i.track?.length&&i.kind!=="aircraft"&&i.kind!=="vehicle")continue;const r=this.decorGroups.get(i.id);if(!r?.visible||(t.setFromObject(r),t.isEmpty()))continue;let a=1/0,o=-1/0,c=1/0,l=-1/0;for(const h of[t.min.x,t.max.x])for(const u of[t.min.y,t.max.y])for(const d of[t.min.z,t.max.z]){n.set(h,u,d).sub(this.camera.position).normalize();const f=this.screenPointOf(n);if(!f)continue;const p=(f.ndcX+1)/2,v=(1-f.ndcY)/2;a=Math.min(a,p),o=Math.max(o,p),c=Math.min(c,v),l=Math.max(l,v)}Number.isFinite(a)&&e.push({x:a,y:c,width:o-a,height:l-c})}return e}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Ae),n=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Ua(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Ae);if(Oa.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Oa(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){e.setFromCamera(new Ae(t,n),this.camera);return}const r=i.directionFor(t,n,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}pickCloudAt(e,t){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(e,t))}cloudDirectionAt(e,t){return this.directionAtScreenPoint(e,t,new C)}directionAtScreenPoint(e,t,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(t.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return Oa.ndcFor(t,this.camera.fov,i);const r=Math.tan(this.camera.fov/2*Dn);return{ndcX:t.x/-t.z/(i*r),ndcY:t.y/-t.z/r}}screenPointScratch=new C;screenPointQuaternion=new Es;screenPointSize=new Ae;updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,r=this.renderer.domElement.height;e.uniforms.uResolution.value.set(i,r),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of mp)this.isSunOccluded(t[0],t[1])||e++;return e/mp.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const n=this.decorGroups.get(t.id);n&&e.push(n)}return e}isSunOccluded(e=0,t=0){const n=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=i.length();if(i.normalize(),e!==0||t!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(i.z,0,-i.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,i).normalize();i.addScaledVector(c,e*o).addScaledVector(l,t*o).normalize()}if(this.groundBlocks(this.camera.position,i,r))return!0;if(n.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,i);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}groundBlocks(e,t,n,i=0){const r=this.groundMesh;if(r&&t.y<0){const m=(r.position.y-e.y)/t.y;if(m>i&&m<n){const g=e.x+t.x*m-r.position.x,S=e.z+t.z*m-r.position.z;if(Math.hypot(g,S)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=i,f=n;for(const[m,g,S]of[[e.x,t.x,l],[e.z,t.z,h]]){const b=Math.min(S[0],S[1]),_=Math.max(S[0],S[1]);if(Math.abs(g)<1e-12){if(m<b||m>_)return!1;continue}const E=(b-m)/g,w=(_-m)/g;d=Math.max(d,Math.min(E,w)),f=Math.min(f,Math.max(E,w))}if(!(f>d))return!1;const p=Math.hypot(t.x,t.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,S=e.x+t.x*g,b=e.y+t.y*g,_=e.z+t.z*g;if(b<=this.groundYUnder(S,_))return!0}return!1}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=rp;let i,r;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(n)?i=i===void 0?c.distance:Math.max(i,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:i,inFrontM:r}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(i&&!this.groundHides(e,t))return n.find(([,r])=>r===i.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=this.raycaster.ray.direction,i=Math.cos(op*this.camera.fov*Math.PI/180);let r,a=i;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(e,t)?void 0:r}groundHides(e,t){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t);const n=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(n.origin,n.direction,1/0,rp)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!i)return;let r=i.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear(),this.novaKeys.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())ln.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const e=t=>{this.frame(t),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(e,t=!1){const n=e&&t;if(e===this.animationsRunning&&n===this.framesDriven)return;const i=this.animationsRunning;this.animationsRunning=e,this.framesDriven=n,e&&!i&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),this.syncAnimationLoop(),(!e||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(e){const t=this.skyMesh?.geometry??new fn(Qo,32,16),n=t.attributes.position,i=t.getAttribute("color")??new It(new Float32Array(n.count*3),3);for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Jy(n.getX(a),n.getY(a),n.getZ(a)),l=rS(o,c,e.azimuthDeg,e.altitudeDeg);i.setXYZ(a,l[0],l[1],l[2])}if(i.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",i);const r=new Jn({vertexColors:!0,side:Ct,fog:!1,depthWrite:!1});this.skyGradientMaterial=r,this.skyMesh=new We(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=ap(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new od(this.groundRadius,48),n=new ja({color:new oe(th,th,th),fog:!0});this.groundMesh=new We(t,n),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e){const t=`${e.altitudeDeg.toFixed(1)}:${e.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([r,a])=>`${r}=${Math.round(a.x/10)},${Math.round(a.z/10)}`).join(";"),n=this.cloudTransmissionMemo.get(t);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const i=this.computeCloudTransmission(e);return this.cloudTransmissionMemo.set(t,i),i}cloudTransmissionMemo=new Map;computeCloudTransmission(e){const t=nn(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(t);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Ft.alphaAt(t,Math.abs(this.cloudLayerOffset()),i,this.cloudFieldOffset)*fb);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Ft.alphaAt(t,ec,r)*pb),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,n,i,r){if(t.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=nn(t.altitudeDeg,t.azimuthDeg,Tr),l=ds(t.altitudeDeg),h=this.cloudTransmission(t),u=new oe(i.r*l[0]*h,i.g*l[1]*h,i.b*l[2]*h);let d=this.bodyMeshes.get(e);d instanceof We?d.material.color.copy(u):(this.disposeMesh(d),d=new We(new fn(1,16,16),new Jn({color:u,fog:!1})),this.celestialGroup.add(d),this.bodyMeshes.set(e,d)),d.scale.setScalar(n),d.position.set(a,o,c),this.setHitArea(e,a,o,c,n);const f=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,c,f,u),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=B5(),this.lensFlare.uniforms.uOpacity.value=Db,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e,t){const n="moon";if(e.magnitude>t||e.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n);return}const{x:i,y:r,z:a}=nn(e.altitudeDeg,e.azimuthDeg,Tr),o=ds(e.altitudeDeg),c=new oe(o[0],o[1],o[2]),l=`${e.phase.phaseFraction<.5}:${Math.round(Fa(e.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(n);if(h instanceof xr)h.userData.phaseKey!==l&&(h.material.map?.dispose(),h.material.map=Pp(e.phase),h.userData.phaseKey=l),h.material.color.copy(c);else{this.disposeMesh(h),h=new xr(new Ea({map:Pp(e.phase),color:c,fog:!1})),h.userData.phaseKey=l;const u=ih*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h)}h.position.set(i,r,a),this.setHitArea(n,i,r,a,ih),this.setGlare(n,i,r,a,e.magnitude,c)}setHitArea(e,t,n,i,r){let a=this.hitAreas.get(e);if(!a){const c=new Ea({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new xr(c),this.celestialGroup.add(a),this.hitAreas.set(e,a)}a.position.set(t,n,i);const o=r*db;a.scale.set(o,o,1)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,i,r,a){const o=cS(r);if(o<=0){this.disposeGlare(e);return}const c=uS(o),l=this.glareSprites.get(e),h=l??new xr(new Ea({map:oE(),transparent:!0,blending:Gn,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=pS(o),h.position.set(t,n,i),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const n=e&&`comet:${e.id}`;if(!e||!n||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=Aa(e.magnitude,t),r=Ta(i);this.cometKey=n,this.setBodyMesh(n,e.position,sh*(.5+.5*i),new oe(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new zn(Tr),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,i)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new yi,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.highCloudCover(),i=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(i?.offset??this.cloudFieldOffset),n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:ec},0);return}const r=this.lowerCloudCover(),a=it.deckLitUntilDeg(it.DECK_HEIGHT_M),o=e.altitudeDeg>-a?e:t,c=it.strength(n,r,o.altitudeDeg,a)*(o===e?1:lp),{x:l,y:h,z:u}=nn(o.altitudeDeg,o.azimuthDeg,1),d=ds(o.altitudeDeg);this.iceHalos.update({x:l,y:h,z:u},o.altitudeDeg,c,[d[0],d[1],d[2]],{cover:i?.cover??n,layerHeight:i?.layerHeight??ec},i?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Gs,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=e.altitudeDeg>0,r=i?e:t,a=this.lowerCloudCover(),o=lp*Pn.moonlightShare(t.magnitude),c=Pn.strength(n,a,r.altitudeDeg)*(i?1:o);if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=nn(r.altitudeDeg,r.azimuthDeg,1),d=ds(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],i)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new ps,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=e.frame,r=ni.galactic(n,i),a=Yn.directionOf(r.centre),o=Yn.directionOf(r.rotation),c=Yn.directionOf(r.pole),l=new ze().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Yn.directionOf(ni.eclipticPole(n,i)),u=Yn.directionOf(e.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:Yn.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Ge.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new C(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:n,z:i}=nn(e.altitudeDeg,e.azimuthDeg,1);return new C(t,n,i).normalize()}buildNovae(e,t){const n=new Set;for(const i of e){if(i.magnitude>t)continue;const r=`nova:${i.id}`;n.add(r);const a=Aa(i.magnitude,t),o=Ta(a);this.setBodyMesh(r,i.position,sh*(.5+.5*a),new oe(o,o,o),i.magnitude)}for(const i of this.novaKeys)n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i));this.novaKeys=n}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(e,t){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const i of e){if(i.magnitude>t)continue;n.add(i.body);const r=Aa(i.magnitude,t),a=Ta(r),o=jb[i.body]??new oe(1,1,1),c=new oe(o.r*a,o.g*a,o.b*a),l=sh*(.5+.5*r);this.setBodyMesh(i.body,i.position,l,c,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(e,t){if(this.namedStars=[],!e||e.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:n,date:i,observer:r}=e,a=new ri(i,r),o=uh(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>t)break;const{altitudeDeg:u,azimuthDeg:d}=a.position(n.ra[l],n.dec[l]);if(u<cp)continue;const{x:f,y:p,z:v}=nn(u,d,nh);c.push({x:f,y:p,z:v,brightness:Aa(h,t),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of _5){if(l.mag>t)continue;const{altitudeDeg:h,azimuthDeg:u}=a.position(l.raHours,l.decDeg);if(h<cp)continue;const{x:d,y:f,z:p}=nn(h,u,nh);this.namedStars.push({star:l,direction:new C(d,f,p).normalize(),altitudeDeg:h})}this.starTiers=fd.map((l,h)=>{const u=c.filter(b=>Hm(b.brightness)===h),d=new Float32Array(u.length*3),f=new Float32Array(u.length),p=new Float32Array(u.length),v=new Float32Array(u.length);u.forEach((b,_)=>{d[_*3]=b.x,d[_*3+1]=b.y,d[_*3+2]=b.z,f[_]=b.brightness,p[_]=b.phase,v[_]=b.speedFactor});const m=new yt;m.setAttribute("position",new rt(d,3));const g=new rt(new Float32Array(u.length*3),3);m.setAttribute("color",g);let S=this.starTiers[h]?.points;if(S)S.geometry.dispose(),S.geometry=m;else{const b=new ad({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Ms.apply(b),S=new Na(m,b),this.celestialGroup.add(S)}return{points:S,colorAttribute:g,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let i=0;i<t.brightness.length;i++){const r=_S(t.brightness[i],{phase:t.phase[i],speedFactor:t.speedFactor[i]},e),a=Ta(t.brightness[i])*r;n[i*3]=a,n[i*3+1]=a,n[i*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Lc(this.celestialGroup,rh,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const e=this.lowerCloudCover();if(e<=0){this.disposeCloudSystem();return}const t=this.weather.cloudDarkness,n=new oe(Ps[0]+(ch[0]-Ps[0])*t,Ps[1]+(ch[1]-Ps[1])*t,Ps[2]+(ch[2]-Ps[2])*t);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=e,this.cloudUniforms.baseColor.value.copy(n),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:i,uniforms:r}=du(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=r,r.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=fu(rh);this.cloudMesh=new We(a,i),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type!=="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type==="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.highCloudCover}buildCirrus(){const e=this.weather.highCloudCover??0;if(this.layeredClouds||e<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=e,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:t,uniforms:n}=du(new oe(...Ps),e,ec,1);this.cirrusMaterial=t,this.cirrusUniforms=n,n.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new We(fu(rh*1.04),t),this.cirrusMesh.renderOrder=gp-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,e)}faceCloudDeck(e,t){const n=t<0;e.scale.y=n?-1:1,e.renderOrder=n?Lc.deckOrder(!0,0,1):gp}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*ah;return Math.sign(t||1)*Math.max(Math.abs(t),Ib)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(n.length===0&&!this.layeredClouds)return;const{x:i,y:r,z:a}=nn(e.altitudeDeg,e.azimuthDeg,1),o=ds(e.altitudeDeg),c=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*Dn)),l=this.lightningLevel*Zb,h=new oe(t[0]+xi.r*l,t[1]+xi.g*l,t[2]+xi.b*l);this.layeredClouds?.setLighting(new C(i,r,a),new oe(o[0]*c,.96*o[1]*c,.88*o[2]*c),h,h);for(const u of n)u.sunDir.value.set(i,r,a),u.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),u.ambientColor.value.copy(h)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=vp[e],n=t.poolSize,i=uh(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),f=new Float32Array(n),p=new Float32Array(n);for(let b=0;b<n;b++){const _=i()*Math.PI*2,E=i()*t.radiusM;r[b*3]=Math.cos(_)*E,r[b*3+1]=Cr+i()*(t.topYM-Cr),r[b*3+2]=Math.sin(_)*E,a[b]=i()*Math.PI*2,o[b]=.7+i()*.6,c[b]=.6+i()*.8,l[b]=.4+i()*1.2}const v=new yt;v.setAttribute("position",new rt(r,3)),v.setDrawRange(0,hh(n,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new oe(...this.baseFogColor)},uTexture:{value:Qb(e)},uNearFocusDistance:{value:Ep},uHazeDistance:{value:t.radiusM*wp}},g=new Rt({uniforms:m,vertexShader:rE,fragmentShader:aE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const S=new Na(v,g);S.renderOrder=oh,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=vp[n],r=this.weather.windDirectionDeg*Dn,a=Math.sin(r)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*i.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,S=n==="snow"&&u&&d,b=n==="hail"&&f&&p&&v&&m&&g;for(let _=0,E=0;_<c.length;_+=3,E++){if(b&&f[E]>0){if(f[E]-=t,f[E]<=0){const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A,f[E]=0}else{const M=1-f[E]/v[E];c[_+1]=Cr+Math.sin(Math.PI*M)*p[E],c[_]=nc(c[_]+(a+m[E])*t,i.radiusM),c[_+2]=nc(c[_+2]+(o+g[E])*t,i.radiusM)}continue}let w=0,R=0;if(S){const M=Gb*u[E],A=Vb*d[E];w=Math.sin(e*M*Math.PI*2+l[E])*A,R=Math.sin(e*M*Math.PI*2+l[E]+Math.PI/2)*A}if(c[_]+=(a+w)*t,c[_+1]-=i.fallSpeedMPerS*h[E]*t,c[_+2]+=(o+R)*t,c[_]=nc(c[_],i.radiusM),c[_+2]=nc(c[_+2],i.radiusM),c[_+1]<Cr){if(b){p[E]=Cp*(.2+Math.random()*1.6),v[E]=Wb*(.5+Math.random()),f[E]=v[E];const I=Math.random()*Math.PI*2,D=Xb*(p[E]/Cp);m[E]=Math.cos(I)*D,g[E]=Math.sin(I)*D,c[_+1]=Cr;continue}const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=yp(this.weather.precipitationIntensity);this.rainSystem=U5({count:Mp,radiusM:ya,heightM:Lb,bottomYM:xp,overallSpeed:Nb,color:Ub,opacity:.85,visibleCount:hh(Mp,this.weather.precipitationIntensity),speedStreak:zb(e),pixelSize:Tp,seed:9001,nearFocusDistanceM:Ep,hazeDistanceM:ya*wp,hazeColor:new oe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=oh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=uh(4242),t=new Float32Array(Rr*3),n=new Float32Array(Rr),i=new Float32Array(Rr),r=new Float32Array(Rr);for(let h=0;h<Rr;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*ya;t[h*3]=Math.cos(u)*d,t[h*3+1]=xp,t[h*3+2]=Math.sin(u)*d,i[h]=Ip(Sp,bp),n[h]=e()*i[h],r[h]=n[h]/i[h]}const a=new yt;a.setAttribute("position",new rt(t,3));const o=new rt(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,hh(Rr,this.weather.precipitationIntensity));const c=new Rt({uniforms:{uMaxSize:{value:Bb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:Hb},uTexture:{value:nE()}},vertexShader:iE,fragmentShader:sE,transparent:!0,depthWrite:!1}),l=new Na(a,c);l.renderOrder=oh,this.scene.add(l),this.rainSplashSystem={points:l,positions:t,life:n,duration:i,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*Dn;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-yp(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*Dn,i=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=ya,o=l=>(l%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+i*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Rp+(1-Rp)*(1-c),h=Dp+(1-Dp)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Tp*l*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:i,duration:r,lifeAttribute:a}=t,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(i[l]+=e,i[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*ya;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=Ip(Sp,bp),i[l]=0}o[l]=i[l]/r[l]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,n=0;if(this.lightningArmed)for(const o of this.lightningFlashes){if(o.t>e)break;const c=Kt.brightnessAt(o,e);c>n&&(t=o,n=c)}const i=t?Math.min(1,Math.max(.1,(Kb/t.distanceM)**2)):0,r=n*i*(t?.cloudToGround?1:.6);if(r===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=r,this.scene.fog){const o=this.scene.fog,c=Math.min(1,r);o.color.setRGB(this.baseFogColor[0]+(xi.r-this.baseFogColor[0])*c,this.baseFogColor[1]+(xi.g-this.baseFogColor[1])*c,this.baseFogColor[2]+(xi.b-this.baseFogColor[2])*c)}if(this.skyMesh){const o=r*$b;this.skyMesh.material.color.setRGB(1+o*xi.r,1+o*xi.g,1+o*xi.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=r*Jb,t){const{x:o,y:c,z:l}=nn(25,t.azimuthDeg,Tr);this.lightningLight.position.set(o,c,l)}this.lightningBolt||(this.lightningBolt=new Nr(Tr*.95),this.celestialGroup.add(this.lightningBolt.object));const a=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,n,a),this.render()}buildCompassLabels(){const e=Wu(navigator.languages,Sb),t=yb[e];this.compassSprites=_b.map((n,i)=>{const r=t[i],a=new Ea({map:cE(r),depthTest:!1,fog:!1}),o=new xr(a),{x:c,y:l,z:h}=nn(0,n,dp);return o.position.set(c,l,h),o.scale.set(tc,tc,1),o.renderOrder=wb,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=fp*Math.PI/360,n=tc*Math.tan(e)/Math.tan(t);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const n of Array.isArray(t)?t:[t]){const i=n.map;i&&i.dispose(),n.dispose()}}}const Dn=Math.PI/180;function Fa(s,e,t){return Math.max(e,Math.min(t,s))}function Ip(s,e){return s+Math.random()*(e-s)}function nc(s,e){return(s%(e*2)+e*3)%(e*2)-e}let ic,sc;function Qb(s){switch(s){case"snow":return eE();case"hail":return tE()}}function eE(){if(ic)return ic;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),ic=new Li(e),ic}function tE(){if(sc)return sc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),sc=new Li(e),sc}let rc;function nE(){if(rc)return rc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),rc=new Li(e),rc}const iE=`
6364
+ `})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(e,t){const n=e?10**(.4*t):1;n===this.exposureScale&&this.seenByEye===!e||(this.exposureScale=n,this.seenByEye=!e,this.material.uniforms.uExposureScale.value=n,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(e){this.tables.setMedium(new Ze(e)),this.tables.ready||(this.drawnKey="")}advance(e){!this.supported||this.tables.ready||this.tables.advance(e)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(e){this.state=e,this.tables.ready?this.draw(e):this.hasViews||this.applyAdaptation(en.predictedZenithLuminance(e))}dispose(){this.tables.dispose(),this.material.dispose()}draw(e){const t=[e.altitudeM.toFixed(0),e.sun.altitudeDeg.toFixed(3),e.moon.altitudeDeg.toFixed(3)].join(":"),n=this.material.uniforms;if(n.uSunAzimuth.value.copy(en.azimuthVector(e.sun.azimuthDeg)),n.uMoonAzimuth.value.copy(en.azimuthVector(e.moon.azimuthDeg)),n.uMoonScale.value=10**(-.4*(e.moon.magnitude-en.SUN_MAGNITUDE)),n.uObserverRadius.value=Ze.GROUND_RADIUS_M+Math.max(e.altitudeM,2),t!==this.drawnKey){this.tables.renderSkyViews(e.altitudeM,e.sun.altitudeDeg,e.moon.altitudeDeg);const i=!this.hasViews;this.hasViews=!0,this.drawnKey=t,i&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),e),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;try{const[e,t]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),n=this.state;n&&this.adaptFromViews(e,t,n)}finally{this.reading=!1}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptFromViews(e,t,n){const i=10**(-.4*(n.moon.magnitude-en.SUN_MAGNITUDE)),r=en.airglowXyzs(),a=(u,d)=>{const f=(90-u)*Math.PI/180,p=ze.skyViewUv(n.altitudeM,f,en.azimuthBetween(d,n.sun.azimuthDeg)),v=ze.skyViewUv(n.altitudeM,f,en.azimuthBetween(d,n.moon.azimuthDeg)),m=en.bilinear(e,p.u,p.v),g=en.bilinear(t,v.u,v.v),S=u>0?en.airglowFactor(u):0;return[0,1,2,3].map(b=>m[b]+i*g[b]+r[b]*S)};let o=0,c=0;for(let u=5;u<90;u+=10){const d=Math.cos(u*Math.PI/180);for(let f=0;f<360;f+=30)o+=d*Math.log(Math.max(a(u,f)[1],1e-9)),c+=d}this.applyAdaptation(Math.exp(o/c));const l=(u,d)=>{const f=this.exposureScale,[p,v,m,g]=a(u,d),S=this.adaptingLuminance*f;return st.displayOf([p*f,v*f,m*f],g*f,S,this.seenByEye?st.rodShare(S):0)},h=[0,0,0];for(let u=0;u<360;u+=20){const d=l(2,u);for(let f=0;f<3;f++)h[f]+=d[f]/18}this.ambientColours={zenith:l(90,0),horizon:h},this.onChange()}applyAdaptation(e){this.adaptingLuminance=e;const t=e*this.exposureScale;this.material.uniforms.uRodShare.value=this.seenByEye?st.rodShare(t):0,this.material.uniforms.uSemiSaturationN.value=st.semiSaturation(t)**st.RESPONSE_EXPONENT}static predictedZenithLuminance(e){const t=i=>90-i.altitudeDeg,n=Ge.magPerArcsec2({altitudeDeg:e.sun.altitudeDeg,separationDeg:t(e.sun)},{phaseAngleDeg:e.moon.phaseAngleDeg,altitudeDeg:e.moon.altitudeDeg,separationDeg:t(e.moon)},90);return Ge.toNanolamberts(n)*en.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const e=Ge.toNanolamberts(Ge.AIRGLOW_MAG_PER_ARCSEC2)*en.CANDELAS_PER_NANOLAMBERT;return[e*.3127/.329,e,e*(1-.3127-.329)/.329,e]}static airglowFactor(e){const t=Math.cos(e*Math.PI/180)**2,n=Ze.GROUND_RADIUS_M/(Ze.GROUND_RADIUS_M+en.AIRGLOW_LAYER_ALTITUDE_M),i=1/Math.sqrt(Math.max(1-n*n*t,1e-4)),r=1/Math.sqrt(Math.max(1-.96*t,.001));return i*10**(-.4*Ge.EXTINCTION_PER_AIR_MASS*(r-1))}static azimuthVector(e){const t=e*Math.PI/180;return new Ae(Math.sin(t),-Math.cos(t))}static azimuthBetween(e,t){const n=Math.abs(e-t)%360;return(n>180?360-n:n)*Math.PI/180}static bilinear(e,t,n){const i=ze.SKY_VIEW_WIDTH,r=ze.SKY_VIEW_HEIGHT,a=Math.min(Math.max(t*i-.5,0),i-1),o=Math.min(Math.max(n*r-.5,0),r-1),c=Math.floor(a),l=Math.floor(o),h=Math.min(c+1,i-1),u=Math.min(l+1,r-1),d=a-c,f=o-l,p=(v,m,g)=>e[(v*i+m)*4+g];return[0,1,2,3].map(v=>(p(l,c,v)*(1-d)+p(l,h,v)*d)*(1-f)+(p(u,c,v)*(1-d)+p(u,h,v)*d)*f)}}class Ur{static DRY_OPTICAL_DEPTH=.08;static GROWTH_EXPONENT=.3;static MAX_RELATIVE_HUMIDITY=.95;static OPTICAL_DEPTH_STEP=.02;static relativeHumidity(e,t){const n=i=>Math.exp(17.625*i/(243.04+i));return Math.min(Math.max(n(t)/n(e),0),1)}static opticalDepth(e){const t=Math.min(Math.max(e,0),Ur.MAX_RELATIVE_HUMIDITY);return Ur.DRY_OPTICAL_DEPTH*(1-t)**-.3}static steppedOpticalDepth(e){const t=Ur.OPTICAL_DEPTH_STEP;return Math.round(Ur.opticalDepth(e)/t)*t}}function lb(s,e){return JSON.stringify(s.cloudLayers)===JSON.stringify(e.cloudLayers)&&s.cloudCover===e.cloudCover&&s.cloudDarkness===e.cloudDarkness&&s.cloudBaseM===e.cloudBaseM&&s.highCloudCover===e.highCloudCover&&s.iceCrystalAlignment===e.iceCrystalAlignment&&s.lowerCloudCover===e.lowerCloudCover&&s.relativeHumidity===e.relativeHumidity&&s.precipitationType===e.precipitationType&&s.precipitationIntensity===e.precipitationIntensity&&s.windDirectionDeg===e.windDirectionDeg&&s.windSpeed===e.windSpeed&&s.storm===e.storm}const Qo=900,eh=1,rp=.5,Ca=900,hb=6371e3,ub=3e4;function ap(s){const e=Math.sqrt(2*hb*Math.max(s,0));return Math.max(Ca,Math.min(e,ub))}const th=.5,nh=850,op=.03,Tr=850,ih=4,sh=1.5,cp=-1,db=6,Hu=-4,lp=.2,ec=2600,fb=.97,pb=.38,hp=Hu,mb=3,gb=.15,vb=.6,Mb=40,xb=30,_b=[0,45,90,135,180,225,270,315],yb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},Sb=["en","fr"],bb=2,Eb=16,up=2500,dp=880,tc=40,fp=60,wb=10,Ab=1,Tb=150,Rb=55,Db=.5,Cb=2.05,pp=.265,mp=[[0,0],...Array.from({length:8},(s,e)=>{const t=e*Math.PI/4;return[Math.cos(t)*pp,Math.sin(t)*pp]})],rh=700,ah=250/1e3,Ib=12,gp=5,oh=6,Ps=[.92,.92,.95],ch=[.15,.15,.19],vp={snow:{fallSpeedMPerS:2,size:.3,color:new oe(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new oe(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Cr=0,lh=0,Pb=150,Mp=3e3,ya=20,Lb=15,xp=Cr,Nb=40,_p=1,Ob=9;function yp(s){return _p+(Ob-_p)*s}const Ub=new oe(.75,.82,.92),Fb=10,kb=.5;function zb(s){return Fa(s/Fb,kb,1)}const Rr=200,Sp=.18,bp=.32,Bb=.35,Hb=new oe(.85,.9,.98),Ep=5,wp=.85,Ap=.01;function hh(s,e){return Math.round(s*(Ap+(1-Ap)*e))}const Tp=230,Rp=.7,Dp=.05,Gb=.6,Vb=.7,Wb=.15,Cp=.35,Xb=3,qb=1/12,Yb=.5,xi=new oe(.82,.86,1),Kb=2500,$b=1.6,Zb=1.2,Jb=2.2,jb={Venus:new oe(1,.96,.85),Mars:new oe(1,.55,.4),Jupiter:new oe(.95,.87,.72),Saturn:new oe(.92,.86,.68)};class Yn{renderer;scene=new Zr;phenomena=new ii(this.scene);references=new zs(this.scene,()=>this.render());camera;celestialGroup=new rn;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=rb[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new j0(16777215,0);celestialLightTarget=new bt;skyLight=new Tv(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;resolution;cssSize={width:1,height:1};frameDirty=!1;flushFrameId=null;framesDriven=!1;lastFrameTimeMs;raycaster=new Ol;weather=zp;observerElevationM=0;siteElevationM=0;groundRadius=Ca;terrainRadius=Ca;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new C;cloudFieldOffset=new C;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new C;rainLastVerticalFacing=-1;rainViewportSize=new Ae;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new j0(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new C;sunVisible=!1;lensFlareScratch=new C;sunOcclusionRaycaster=new Ol;sunOcclusionDirectionScratch=new C;sunOcclusionRightScratch=new C;sunOcclusionUpScratch=new C;ufoOcclusionRaycaster=new Ol;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(e){return Math.max(3,Math.round(6e6/Math.max(1,e)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(e,t=R1()){this.renderer=new ky({canvas:e,antialias:!0}),this.resolution=new wt(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Ia,this.camera=new Nn(60,e.width/Math.max(e.height,1),.1,Qo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(xi),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup);const n=new en(this.renderer,()=>{this.skyColoursStale=!0,this.render()});n.supported?this.scatteredSky=n:n.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}resize(e,t){this.cssSize.width=e,this.cssSize.height=t,this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(e){e!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=e,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(e,t={}){this.cloudOffsetM.set(e.x,0,e.z),this.cloudLayerOffsetsM=t,this.layeredClouds?.setOffsets(e,t),this.cloudFieldOffset.set(e.x*ah,0,e.z*ah);for(const n of[this.cloudUniforms,this.cirrusUniforms])n?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(e){const t=((e.rollDeg??0)+this.gaitOffset.rollDeg)*Dn,n=(e.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Dn;if(e.headingDeg!==void 0?this.camera.rotation.set(n,-(e.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Dn,t,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,t,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(ap(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/Ca),this.camera.far=Math.max(Qo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&e.lat!==void 0&&e.lng!==void 0){const i=un(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+e.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:c,z:l}=un(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<Tb*(i/Ca))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:e,lng:t},this.terrainRadius=i;const o=++this.terrainBuildToken;A5(e,t,this.terrainProviders,i).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=r?un(e,t,r.lat,r.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=a&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=Ab,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.render(),n?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),n?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=Rb*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const e=this.lastSunPosition?.altitudeDeg??-90,t=gS(e)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=ds(e);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=Cb**2*Math.max(0,t)}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;if(this.compassSprites.some(t=>t.visible!==e)){for(const t of this.compassSprites)t.visible=e;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(e){this.cloudTransmissionMemo.clear(),!lb(this.weather,e)&&(this.weather=e,this.scatteredSky?.setConditions({aerosolOpticalDepth:e.relativeHumidity===void 0?void 0:Ur.steppedOpticalDepth(e.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=Yb,this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e,this.decorModelToken++,this.decorModelCredits.clear();for(const t of this.decorGroups.values())t.removeFromParent(),ln.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=ln.build(t,t.lit??!1);this.scene.add(n),this.decorGroups.set(t.id,n),t.kind==="streetlight"&&this.addStreetlightLight(t.id,n),this.loadDecorModel(t,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(e){this.decorModelProvider=e;const t=this.decorObjects;this.decorObjects=[],this.setDecor(t)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(e,t){const n=e.model;if(!(!n||!ln.usesModel(e)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,r=n.url??i?.url,a=n.credit??i?.credit;if(!r||!a)return;const o=await ab(r);if(t!==this.decorModelToken)return;const c=this.decorGroups.get(e.id);if(!c)return;ln.applyModel(c,e,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(e.id,a),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${e.id}":`,i)}}updateDecorAnchoring(e,t,n=0){this.decorReferencePose=e,this.decorCurrentPose=t,this.decorTime=n;const i=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?un(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Vp(l.kind));if(this.terrainMesh&&this.terrainOrigin&&t?.lat!==void 0&&t.lng!==void 0){const l=un(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=l.x-(r?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(r?0:this.gaitOffset.northM)}r||(i.x-=this.gaitOffset.eastM,i.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(r){const l=ln.occupantView(r),h=-(r.headingDeg??0)*Dn,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=r.eastM+i.x,p=-r.northM+i.z;a.x=-(f+u),a.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Dn,-(l.headingDeg+this.indoorLookYawDeg)*Dn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Vu(l,n),d=u.eastM+i.x+a.x,f=-u.northM+i.z+a.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=Pb}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Dn),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==g&&(ln.fitCropToGround(h,(S,b)=>this.groundYUnder(S,b)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Qo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(e,t){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,e-n.position.x,t-n.position.z):lh}groundYOfPatch(e,t,n){const i=e.geometry.getAttribute("position"),r=Math.round(Math.sqrt(i.count));if(r<2||r*r!==i.count)return lh;const a=i.getX(0),o=i.getX(r-1),c=i.getZ(0),l=i.getZ((r-1)*r),h=Fa((t-a)/(o-a)*(r-1),0,r-1),u=Fa((n-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return lh;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),p=h-d,v=u-f,m=(E,w)=>i.getY(E*r+w),g=m(f,d),S=m(f,d+1),b=m(f+1,d),_=m(f+1,d+1);return p+v<=1?g+(S-g)*p+(b-g)*v:_+(b-_)*(1-p)+(S-_)*(1-v)}groundUnderFootprint(e,t,n,i,r=0){return ln.groundUnderFootprint(e,t,n,i,(a,o)=>this.groundYUnder(a,o),r)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(e){this.gaitOffset=e}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(e,t){this.lookYawDeg=e,this.lookPitchDeg=t}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e,t=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&ln.setLights(i,n.lights,e,i.position.distanceTo(this.camera.position),t),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=u1(n,e);ln.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(e,t){const n=ln.bodyOf(t),i=n.children.find(a=>a.userData.emissive);if(!i)return;const r=new Cv(16764006,Mb,xb);r.position.copy(i.position).multiply(n.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,t.add(r),this.streetlightLights.set(e,r)}setAstronomy(e){this.lastAstronomy=e,this.scatteredSky?.update(this.scatteredSkyState(e)),this.skyHoldUntilMs===void 0&&this.scatteredSky&&!this.scatteredSky.ambient&&(this.skyHoldUntilMs=performance.now()+up,setTimeout(()=>this.render(),up+20)),this.pumpScatteredSky(),this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround();const t=Mu(e.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(e.stars,t),this.setBodyMesh("sun",e.sun,ih,new oe(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,t),this.buildPlanets(e.planets,t),this.buildComet(e.comet,t),this.buildNovae(e.novae??[],t),this.buildIceHalos(e.sun,e.moon),this.buildRainbow(e.sun,e.moon),this.applySkyColours(e),this.syncAnimationLoop(),this.render()}applySkyColours(e){this.skyColoursStale=!1;const t=this.scatteredSky?.ambient??vu(e.sun.altitudeDeg),n=t.horizon;this.baseFogColor=[n[0],n[1],n[2]],this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCloudLighting(e.sun,this.baseFogColor),this.updateCelestialLight(e,t.zenith,n),this.buildSkyGlow(e,t.zenith),this.scene.fog instanceof Tc?(this.scene.fog.color.setRGB(...this.baseFogColor),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new Tc(new oe(...this.baseFogColor),this.groundRadius*.2,this.groundRadius)}setSiteElevation(e){Math.abs(e-this.siteElevationM)<1||(this.siteElevationM=e,this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(e){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:e.sun.altitudeDeg,azimuthDeg:e.sun.azimuthDeg,magnitude:e.sun.magnitude},moon:{altitudeDeg:e.moon.altitudeDeg,azimuthDeg:e.moon.azimuthDeg,magnitude:e.moon.magnitude,phaseAngleDeg:Ge.phaseAngleOf(e.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const e=this.scatteredSky;!e||e.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(e.advance(this.skyHoldUntilMs?Eb:bb),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(e){if(e.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new H5(nh),this.celestialGroup.add(this.satelliteField.object));const t=Mu(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(e,t,n=>this.cloudTransmission(n)),this.render()}pickSatelliteAt(e,t){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=Math.cos(op*this.camera.fov*Math.PI/180),i=this.satelliteField.nearest(this.raycaster.ray.direction,n);return i&&this.groundHides(e,t)?void 0:i}updateCelestialLight(e,t,n){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=vb;const i=e.sun.altitudeDeg>=hp,r=!i&&e.moon.altitudeDeg>=hp;if(!i&&!r){this.celestialLight.intensity=0;return}const a=i?e.sun:e.moon,{x:o,y:c,z:l}=nn(a.altitudeDeg,a.azimuthDeg,Tr);this.celestialLight.position.set(o,c,l);const h=ds(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*Dn));this.celestialLight.intensity=(i?mb:gb)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new Qt,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setInstrument(e){this.projectionKind=e.projection;const t=Yt.starPointsOf(e),n=Yt.flareArtifactsOf(e);t===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=t,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=t,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(e,t=!1){this.instrumentMagnitudeGain=Number.isFinite(e)?e:0,this.scatteredSky?.setInstrument(t,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.scatteredSky?.ambient&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const e=this.compileOffThread().then(()=>{this.compiling===e&&(this.compiling=void 0,this.render())});this.compiling=e;return}if(!this.compiling){this.frameDirty=!1,this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const e=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const t=this.renderer.properties,n=performance.now()+Yn.COMPILE_WAIT_MS;return new Promise(i=>{const r=()=>{if(this.contextReleased)return i();for(const a of e){const o=t.get(a)?.currentProgram;(!o||o.isReady())&&e.delete(a)}e.size===0||performance.now()>n?i():setTimeout(r,10)};r()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(e){if(this.animationsRunning){const t=this.lastFrameTimeMs===void 0?0:e-this.lastFrameTimeMs;this.lastFrameTimeMs=e,this.hasAnimations()&&this.animate(e,t);const n=this.resolution.update(e,t);n!==void 0&&this.applyPixelRatio(n)}this.drawIfDirty()}animate(e,t){const n=Math.min(t/1e3,qb);this.updateTwinkle(e/1e3),this.updatePrecipitation(e/1e3,n),this.updateRain(n),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=e/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(e){this.resolution.maximum=e,this.renderer.getPixelRatio()!==this.resolution.pixelRatio&&this.applyPixelRatio(this.resolution.pixelRatio)}applyPixelRatio(e){this.renderer.setPixelRatio(e),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(e,t){const n=t?Math.max(1,Math.round(e)):1;if(n===this.exposureInstants&&(n===1||t===this.exposureInstantAt)){this.exposureInstantAt=t;return}this.exposureInstants=n,this.exposureInstantAt=t,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(e){if(this.onMapSubjectBounds){const r=this.mapSubjectBounds();e?this.exposureSubjectBounds.push(...r):this.onMapSubjectBounds(r)}const t=this.usableEquidistantPass();this.phenomena.setCloudLayers(this.layeredClouds?.volumes??[]),this.phenomena.place(this.camera,(r,a,o)=>this.directionAtScreenPoint(r,a,o),r=>this.screenPointOf(r)),this.references.place(this.camera);const n=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!t){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(e===void 0&&!r),e&&this.renderer.setRenderTarget(e),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderOverlayPasses()):(this.renderer.render(this.scene,this.camera),this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(i);return}t.setEncodesOutput(e===void 0),this.skyGlow?.setDestinationEncoded(!1),e&&this.renderer.setRenderTarget(e),t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderOverlayPasses()),e&&this.renderer.setRenderTarget(i)}renderOverlayPasses(){this.renderReferencesPass(),this.renderPhenomenaPass()}renderReferencesPass(){if(!this.references.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.camera.layers.set(Mg),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}setReferences(e){this.references.set(e)}referenceAspect(e){return this.references.aspectOf(e)}directionAt(e,t){return this.directionAtScreenPoint(e,t,new C)}referenceFailedToLoad(e){return this.references.failedToLoad(e)}setReferencesShown(e){this.references.setShown(e),this.render()}setReferenceView(e,t){this.references.setView(e,t),this.render()}renderPhenomenaPass(){if(!this.phenomena.any)return;const e=this.renderer.autoClear,t=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&Yn.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(eh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(vg),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=t}decorDepthMaterial=new Jn({colorWrite:!1});static markDecorDepth(e,t){e.traverse(n=>{if(!(n instanceof We))return;const i=Array.isArray(n.material)?n.material[0]:n.material;t&&i.depthWrite!==!1&&i.blending!==Gn?n.layers.enable(eh):n.layers.disable(eh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const e=this.renderer.getDrawingBufferSize(new Ae),t=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));this.exposureAccumulation||(this.exposureAccumulation=new Ky(t,n)),this.exposureAccumulation.resize(t,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const e=this.exposureInstantAt,t=this.exposureAccumulation;if(!e||!t)return;const n=1/this.exposureInstants;this.resolution.beginDrawing();const i=performance.now()+Yn.EXPOSURE_BUDGET_MS,r=Yn.exposureInstantsPerFrame(t.instantTarget.width*t.instantTarget.height);let a=0;do{this.restateAt(e,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(t.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}t.add(this.renderer,n),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i&&a<r);this.restateAt(e,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(r=>r.visible))return;const e=new Zr,t=new ws(-1,1,1,-1,0,2),n=tc/(dp*Math.tan(fp*Dn/2));for(const r of this.compassSprites){if(!r.visible)continue;const a=r.getWorldPosition(new C).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new xr(r.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(n/this.camera.aspect,n,1),e.add(c)}const i=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(e,t)}finally{this.renderer.autoClear=i}}onMapSubjectBounds;exposureSubjectBounds=[];mapSubjectBounds(){const e=[],t=new hi,n=new C;for(const i of this.decorObjects){if(!i.track?.length&&i.kind!=="aircraft"&&i.kind!=="vehicle")continue;const r=this.decorGroups.get(i.id);if(!r?.visible||(t.setFromObject(r),t.isEmpty()))continue;let a=1/0,o=-1/0,c=1/0,l=-1/0;for(const h of[t.min.x,t.max.x])for(const u of[t.min.y,t.max.y])for(const d of[t.min.z,t.max.z]){n.set(h,u,d).sub(this.camera.position).normalize();const f=this.screenPointOf(n);if(!f)continue;const p=(f.ndcX+1)/2,v=(1-f.ndcY)/2;a=Math.min(a,p),o=Math.max(o,p),c=Math.min(c,v),l=Math.max(l,v)}Number.isFinite(a)&&e.push({x:a,y:c,width:o-a,height:l-c})}return e}restateAt(e,t){this.restatingExposure=!0;try{e(t)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(e){const t=this.lensOptics;this.lensOptics=e,(t===void 0!=(e===void 0)||t&&e&&(t.focalLengthMm!==e.focalLengthMm||t.fNumber!==e.fNumber||t.focusDistance!==e.focusDistance||t.frameHeightMm!==e.frameHeightMm))&&(e&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.render())}usableDepthOfFieldPass(){const e=this.lensOptics;if(!e)return;const t=this.renderer.getDrawingBufferSize(new Ae),n=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new Ua(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(e.focalLengthMm,e.fNumber,e.focusDistance,e.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Ae);if(Oa.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Oa(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){e.setFromCamera(new Ae(t,n),this.camera);return}const r=i.directionFor(t,n,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}pickCloudAt(e,t){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(e,t))}cloudDirectionAt(e,t){return this.directionAtScreenPoint(e,t,new C)}directionAtScreenPoint(e,t,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(e){this.camera.updateMatrixWorld();const t=this.screenPointScratch.copy(e).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(t.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return Oa.ndcFor(t,this.camera.fov,i);const r=Math.tan(this.camera.fov/2*Dn);return{ndcX:t.x/-t.z/(i*r),ndcY:t.y/-t.z/r}}screenPointScratch=new C;screenPointQuaternion=new Es;screenPointSize=new Ae;updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}const t=this.sunVisibleFraction();if(t<=0){e.mesh.visible=!1;return}e.mesh.visible=!0,this.sunUnhiddenFraction=t,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,r=this.renderer.domElement.height;e.uniforms.uResolution.value.set(i,r),e.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let e=0;for(const t of mp)this.isSunOccluded(t[0],t[1])||e++;return e/mp.length}raycastableDecor(){const e=[];for(const t of this.decorObjects){if(t.kind==="crop")continue;const n=this.decorGroups.get(t.id);n&&e.push(n)}return e}isSunOccluded(e=0,t=0){const n=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=i.length();if(i.normalize(),e!==0||t!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(i.z,0,-i.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,i).normalize();i.addScaledVector(c,e*o).addScaledVector(l,t*o).normalize()}if(this.groundBlocks(this.camera.position,i,r))return!0;if(n.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,i);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}groundBlocks(e,t,n,i=0){const r=this.groundMesh;if(r&&t.y<0){const m=(r.position.y-e.y)/t.y;if(m>i&&m<n){const g=e.x+t.x*m-r.position.x,S=e.z+t.z*m-r.position.z;if(Math.hypot(g,S)<=this.groundRadius)return!0}}const a=this.terrainMesh;if(!a)return!1;const o=a.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[a.position.x+o.getX(0),a.position.x+o.getX(c-1)],h=[a.position.z+o.getZ(0),a.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=i,f=n;for(const[m,g,S]of[[e.x,t.x,l],[e.z,t.z,h]]){const b=Math.min(S[0],S[1]),_=Math.max(S[0],S[1]);if(Math.abs(g)<1e-12){if(m<b||m>_)return!1;continue}const E=(b-m)/g,w=(_-m)/g;d=Math.max(d,Math.min(E,w)),f=Math.min(f,Math.max(E,w))}if(!(f>d))return!1;const p=Math.hypot(t.x,t.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,S=e.x+t.x*g,b=e.y+t.y*g,_=e.z+t.z*g;if(b<=this.groundYUnder(S,_))return!0}return!1}setPhenomena(e,t){this.phenomena.set(e,t)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=rp;let i,r;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(n)?i=i===void 0?c.distance:Math.max(i,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:i,inFrontM:r}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(i&&!this.groundHides(e,t))return n.find(([,r])=>r===i.object)?.[0]}pickStarAt(e,t){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,e,t);const n=this.raycaster.ray.direction,i=Math.cos(op*this.camera.fov*Math.PI/180);let r,a=i;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(e,t)?void 0:r}groundHides(e,t){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t);const n=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(n.origin,n.direction,1/0,rp)}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!i)return;let r=i.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear(),this.novaKeys.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())ln.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const e=t=>{this.frame(t),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(e,t=!1){const n=e&&t;if(e===this.animationsRunning&&n===this.framesDriven)return;const i=this.animationsRunning;this.animationsRunning=e,this.framesDriven=n,e&&!i&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),this.syncAnimationLoop(),(!e||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(e){const t=this.skyMesh?.geometry??new fn(Qo,32,16),n=t.attributes.position,i=t.getAttribute("color")??new It(new Float32Array(n.count*3),3);for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Jy(n.getX(a),n.getY(a),n.getZ(a)),l=rS(o,c,e.azimuthDeg,e.altitudeDeg);i.setXYZ(a,l[0],l[1],l[2])}if(i.needsUpdate=!0,this.skyMesh)return;t.setAttribute("color",i);const r=new Jn({vertexColors:!0,side:Ct,fog:!1,depthWrite:!1});this.skyGradientMaterial=r,this.skyMesh=new We(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const e=ap(this.observerElevationM);if(this.groundMesh&&e===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=e;const t=new od(this.groundRadius,48),n=new ja({color:new oe(th,th,th),fog:!0});this.groundMesh=new We(t,n),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const e=this.groundMesh?.material;if(!e)return;const t=this.terrainMesh===void 0;e.depthWrite!==t&&(e.depthWrite=t,e.needsUpdate=!0)}cloudTransmission(e){const t=`${e.altitudeDeg.toFixed(1)}:${e.azimuthDeg.toFixed(1)}:${Math.round(this.cloudOffsetM.x/10)}:${Math.round(this.cloudOffsetM.z/10)}:${Math.round(this.observerElevationM)}:`+Object.entries(this.cloudLayerOffsetsM).map(([r,a])=>`${r}=${Math.round(a.x/10)},${Math.round(a.z/10)}`).join(";"),n=this.cloudTransmissionMemo.get(t);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const i=this.computeCloudTransmission(e);return this.cloudTransmissionMemo.set(t,i),i}cloudTransmissionMemo=new Map;computeCloudTransmission(e){const t=nn(e.altitudeDeg,e.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(t);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Ft.alphaAt(t,Math.abs(this.cloudLayerOffset()),i,this.cloudFieldOffset)*fb);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Ft.alphaAt(t,ec,r)*pb),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,n,i,r){if(t.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(e)),this.bodyMeshes.delete(e),this.disposeHitArea(e),this.disposeGlare(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=nn(t.altitudeDeg,t.azimuthDeg,Tr),l=ds(t.altitudeDeg),h=this.cloudTransmission(t),u=new oe(i.r*l[0]*h,i.g*l[1]*h,i.b*l[2]*h);let d=this.bodyMeshes.get(e);d instanceof We?d.material.color.copy(u):(this.disposeMesh(d),d=new We(new fn(1,16,16),new Jn({color:u,fog:!1})),this.celestialGroup.add(d),this.bodyMeshes.set(e,d)),d.scale.setScalar(n),d.position.set(a,o,c),this.setHitArea(e,a,o,c,n);const f=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,c,f,u),e==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=B5(),this.lensFlare.uniforms.uOpacity.value=Db,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(e,t){const n="moon";if(e.magnitude>t||e.altitudeDeg<Hu){this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n);return}const{x:i,y:r,z:a}=nn(e.altitudeDeg,e.azimuthDeg,Tr),o=ds(e.altitudeDeg),c=new oe(o[0],o[1],o[2]),l=`${e.phase.phaseFraction<.5}:${Math.round(Fa(e.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(n);if(h instanceof xr)h.userData.phaseKey!==l&&(h.material.map?.dispose(),h.material.map=Pp(e.phase),h.userData.phaseKey=l),h.material.color.copy(c);else{this.disposeMesh(h),h=new xr(new Ea({map:Pp(e.phase),color:c,fog:!1})),h.userData.phaseKey=l;const u=ih*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h)}h.position.set(i,r,a),this.setHitArea(n,i,r,a,ih),this.setGlare(n,i,r,a,e.magnitude,c)}setHitArea(e,t,n,i,r){let a=this.hitAreas.get(e);if(!a){const c=new Ea({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new xr(c),this.celestialGroup.add(a),this.hitAreas.set(e,a)}a.position.set(t,n,i);const o=r*db;a.scale.set(o,o,1)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,i,r,a){const o=cS(r);if(o<=0){this.disposeGlare(e);return}const c=uS(o),l=this.glareSprites.get(e),h=l??new xr(new Ea({map:oE(),transparent:!0,blending:Gn,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=pS(o),h.position.set(t,n,i),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const n=e&&`comet:${e.id}`;if(!e||!n||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=Aa(e.magnitude,t),r=Ta(i);this.cometKey=n,this.setBodyMesh(n,e.position,sh*(.5+.5*i),new oe(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new zn(Tr),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,i)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new yi,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.highCloudCover(),i=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(i?.offset??this.cloudFieldOffset),n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:ec},0);return}const r=this.lowerCloudCover(),a=it.deckLitUntilDeg(it.DECK_HEIGHT_M),o=e.altitudeDeg>-a?e:t,c=it.strength(n,r,o.altitudeDeg,a)*(o===e?1:lp),{x:l,y:h,z:u}=nn(o.altitudeDeg,o.azimuthDeg,1),d=ds(o.altitudeDeg);this.iceHalos.update({x:l,y:h,z:u},o.altitudeDeg,c,[d[0],d[1],d[2]],{cover:i?.cover??n,layerHeight:i?.layerHeight??ec},i?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(e,t){this.rainbow||(this.rainbow=new Gs,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=e.altitudeDeg>0,r=i?e:t,a=this.lowerCloudCover(),o=lp*Pn.moonlightShare(t.magnitude),c=Pn.strength(n,a,r.altitudeDeg)*(i?1:o);if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=nn(r.altitudeDeg,r.azimuthDeg,1),d=ds(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],i)}buildSkyGlow(e,t){if(!e.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new ps,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=e.frame,r=ni.galactic(n,i),a=Yn.directionOf(r.centre),o=Yn.directionOf(r.rotation),c=Yn.directionOf(r.pole),l=new Be().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Yn.directionOf(ni.eclipticPole(n,i)),u=Yn.directionOf(e.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:e.sun.altitudeDeg,moon:{direction:Yn.directionOf(e.moon),altitudeDeg:e.moon.altitudeDeg,phaseAngleDeg:Ge.phaseAngleOf(e.moon.phase.illuminatedFraction)},skyColor:new C(t[0],t[1],t[2])})}static directionOf(e){const{x:t,y:n,z:i}=nn(e.altitudeDeg,e.azimuthDeg,1);return new C(t,n,i).normalize()}buildNovae(e,t){const n=new Set;for(const i of e){if(i.magnitude>t)continue;const r=`nova:${i.id}`;n.add(r);const a=Aa(i.magnitude,t),o=Ta(a);this.setBodyMesh(r,i.position,sh*(.5+.5*a),new oe(o,o,o),i.magnitude)}for(const i of this.novaKeys)n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i));this.novaKeys=n}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(e,t){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const i of e){if(i.magnitude>t)continue;n.add(i.body);const r=Aa(i.magnitude,t),a=Ta(r),o=jb[i.body]??new oe(1,1,1),c=new oe(o.r*a,o.g*a,o.b*a),l=sh*(.5+.5*r);this.setBodyMesh(i.body,i.position,l,c,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(e,t){if(this.namedStars=[],!e||e.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:n,date:i,observer:r}=e,a=new ri(i,r),o=uh(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>t)break;const{altitudeDeg:u,azimuthDeg:d}=a.position(n.ra[l],n.dec[l]);if(u<cp)continue;const{x:f,y:p,z:v}=nn(u,d,nh);c.push({x:f,y:p,z:v,brightness:Aa(h,t),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of _5){if(l.mag>t)continue;const{altitudeDeg:h,azimuthDeg:u}=a.position(l.raHours,l.decDeg);if(h<cp)continue;const{x:d,y:f,z:p}=nn(h,u,nh);this.namedStars.push({star:l,direction:new C(d,f,p).normalize(),altitudeDeg:h})}this.starTiers=fd.map((l,h)=>{const u=c.filter(b=>Hm(b.brightness)===h),d=new Float32Array(u.length*3),f=new Float32Array(u.length),p=new Float32Array(u.length),v=new Float32Array(u.length);u.forEach((b,_)=>{d[_*3]=b.x,d[_*3+1]=b.y,d[_*3+2]=b.z,f[_]=b.brightness,p[_]=b.phase,v[_]=b.speedFactor});const m=new yt;m.setAttribute("position",new rt(d,3));const g=new rt(new Float32Array(u.length*3),3);m.setAttribute("color",g);let S=this.starTiers[h]?.points;if(S)S.geometry.dispose(),S.geometry=m;else{const b=new ad({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Ms.apply(b),S=new Na(m,b),this.celestialGroup.add(S)}return{points:S,colorAttribute:g,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let i=0;i<t.brightness.length;i++){const r=_S(t.brightness[i],{phase:t.phase[i],speedFactor:t.speedFactor[i]},e),a=Ta(t.brightness[i])*r;n[i*3]=a,n[i*3+1]=a,n[i*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new Lc(this.celestialGroup,rh,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const e=this.lowerCloudCover();if(e<=0){this.disposeCloudSystem();return}const t=this.weather.cloudDarkness,n=new oe(Ps[0]+(ch[0]-Ps[0])*t,Ps[1]+(ch[1]-Ps[1])*t,Ps[2]+(ch[2]-Ps[2])*t);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=e,this.cloudUniforms.baseColor.value.copy(n),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:i,uniforms:r}=du(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=r,r.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=fu(rh);this.cloudMesh=new We(a,i),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type!=="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(e=>e.type==="cirrus").reduce((e,t)=>e*(1-t.coverage),1):this.weather.highCloudCover}buildCirrus(){const e=this.weather.highCloudCover??0;if(this.layeredClouds||e<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=e,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:t,uniforms:n}=du(new oe(...Ps),e,ec,1);this.cirrusMaterial=t,this.cirrusUniforms=n,n.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new We(fu(rh*1.04),t),this.cirrusMesh.renderOrder=gp-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){this.layeredClouds?.update(this.weather,this.observerElevationM+1.6);const e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,e)}faceCloudDeck(e,t){const n=t<0;e.scale.y=n?-1:1,e.renderOrder=n?Lc.deckOrder(!0,0,1):gp}cloudLayerOffset(){const t=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*ah;return Math.sign(t||1)*Math.max(Math.abs(t),Ib)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(n.length===0&&!this.layeredClouds)return;const{x:i,y:r,z:a}=nn(e.altitudeDeg,e.azimuthDeg,1),o=ds(e.altitudeDeg),c=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*Dn)),l=this.lightningLevel*Zb,h=new oe(t[0]+xi.r*l,t[1]+xi.g*l,t[2]+xi.b*l);this.layeredClouds?.setLighting(new C(i,r,a),new oe(o[0]*c,.96*o[1]*c,.88*o[2]*c),h,h);for(const u of n)u.sunDir.value.set(i,r,a),u.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),u.ambientColor.value.copy(h)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=vp[e],n=t.poolSize,i=uh(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),f=new Float32Array(n),p=new Float32Array(n);for(let b=0;b<n;b++){const _=i()*Math.PI*2,E=i()*t.radiusM;r[b*3]=Math.cos(_)*E,r[b*3+1]=Cr+i()*(t.topYM-Cr),r[b*3+2]=Math.sin(_)*E,a[b]=i()*Math.PI*2,o[b]=.7+i()*.6,c[b]=.6+i()*.8,l[b]=.4+i()*1.2}const v=new yt;v.setAttribute("position",new rt(r,3)),v.setDrawRange(0,hh(n,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new oe(...this.baseFogColor)},uTexture:{value:Qb(e)},uNearFocusDistance:{value:Ep},uHazeDistance:{value:t.radiusM*wp}},g=new Rt({uniforms:m,vertexShader:rE,fragmentShader:aE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const S=new Na(v,g);S.renderOrder=oh,this.scene.add(S),this.precipitationPoints=S,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=vp[n],r=this.weather.windDirectionDeg*Dn,a=Math.sin(r)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*i.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,S=n==="snow"&&u&&d,b=n==="hail"&&f&&p&&v&&m&&g;for(let _=0,E=0;_<c.length;_+=3,E++){if(b&&f[E]>0){if(f[E]-=t,f[E]<=0){const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A,f[E]=0}else{const M=1-f[E]/v[E];c[_+1]=Cr+Math.sin(Math.PI*M)*p[E],c[_]=nc(c[_]+(a+m[E])*t,i.radiusM),c[_+2]=nc(c[_+2]+(o+g[E])*t,i.radiusM)}continue}let w=0,R=0;if(S){const M=Gb*u[E],A=Vb*d[E];w=Math.sin(e*M*Math.PI*2+l[E])*A,R=Math.sin(e*M*Math.PI*2+l[E]+Math.PI/2)*A}if(c[_]+=(a+w)*t,c[_+1]-=i.fallSpeedMPerS*h[E]*t,c[_+2]+=(o+R)*t,c[_]=nc(c[_],i.radiusM),c[_+2]=nc(c[_+2],i.radiusM),c[_+1]<Cr){if(b){p[E]=Cp*(.2+Math.random()*1.6),v[E]=Wb*(.5+Math.random()),f[E]=v[E];const I=Math.random()*Math.PI*2,D=Xb*(p[E]/Cp);m[E]=Math.cos(I)*D,g[E]=Math.sin(I)*D,c[_+1]=Cr;continue}const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=yp(this.weather.precipitationIntensity);this.rainSystem=U5({count:Mp,radiusM:ya,heightM:Lb,bottomYM:xp,overallSpeed:Nb,color:Ub,opacity:.85,visibleCount:hh(Mp,this.weather.precipitationIntensity),speedStreak:zb(e),pixelSize:Tp,seed:9001,nearFocusDistanceM:Ep,hazeDistanceM:ya*wp,hazeColor:new oe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=oh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=uh(4242),t=new Float32Array(Rr*3),n=new Float32Array(Rr),i=new Float32Array(Rr),r=new Float32Array(Rr);for(let h=0;h<Rr;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*ya;t[h*3]=Math.cos(u)*d,t[h*3+1]=xp,t[h*3+2]=Math.sin(u)*d,i[h]=Ip(Sp,bp),n[h]=e()*i[h],r[h]=n[h]/i[h]}const a=new yt;a.setAttribute("position",new rt(t,3));const o=new rt(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,hh(Rr,this.weather.precipitationIntensity));const c=new Rt({uniforms:{uMaxSize:{value:Bb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:Hb},uTexture:{value:nE()}},vertexShader:iE,fragmentShader:sE,transparent:!0,depthWrite:!1}),l=new Na(a,c);l.renderOrder=oh,this.scene.add(l),this.rainSplashSystem={points:l,positions:t,life:n,duration:i,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const e=this.rainSystem;if(!e)return;const t=this.weather.windDirectionDeg*Dn;e.uniforms.uDropVelocity.value.set(Math.sin(t)*this.weather.windSpeed,-yp(this.weather.precipitationIntensity),-Math.cos(t)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);e.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*Dn,i=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=ya,o=l=>(l%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+i*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Rp+(1-Rp)*(1-c),h=Dp+(1-Dp)*(1-c);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=Tp*l*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:i,duration:r,lifeAttribute:a}=t,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(i[l]+=e,i[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*ya;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=Ip(Sp,bp),i[l]=0}o[l]=i[l]/r[l]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}setLightning(e){this.lightningFlashes=e}updateLightning(e){let t,n=0;if(this.lightningArmed)for(const o of this.lightningFlashes){if(o.t>e)break;const c=Kt.brightnessAt(o,e);c>n&&(t=o,n=c)}const i=t?Math.min(1,Math.max(.1,(Kb/t.distanceM)**2)):0,r=n*i*(t?.cloudToGround?1:.6);if(r===this.lightningLevel&&!t?.cloudToGround)return;if(this.lightningLevel=r,this.scene.fog){const o=this.scene.fog,c=Math.min(1,r);o.color.setRGB(this.baseFogColor[0]+(xi.r-this.baseFogColor[0])*c,this.baseFogColor[1]+(xi.g-this.baseFogColor[1])*c,this.baseFogColor[2]+(xi.b-this.baseFogColor[2])*c)}if(this.skyMesh){const o=r*$b;this.skyMesh.material.color.setRGB(1+o*xi.r,1+o*xi.g,1+o*xi.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=r*Jb,t){const{x:o,y:c,z:l}=nn(25,t.azimuthDeg,Tr);this.lightningLight.position.set(o,c,l)}this.lightningBolt||(this.lightningBolt=new Nr(Tr*.95),this.celestialGroup.add(this.lightningBolt.object));const a=this.weather.cloudBaseM??1500;this.lightningBolt.set(t,n,a),this.render()}buildCompassLabels(){const e=Wu(navigator.languages,Sb),t=yb[e];this.compassSprites=_b.map((n,i)=>{const r=t[i],a=new Ea({map:cE(r),depthTest:!1,fog:!1}),o=new xr(a),{x:c,y:l,z:h}=nn(0,n,dp);return o.position.set(c,l,h),o.scale.set(tc,tc,1),o.renderOrder=wb,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const e=this.camera.fov*Math.PI/360,t=fp*Math.PI/360,n=tc*Math.tan(e)/Math.tan(t);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const n of Array.isArray(t)?t:[t]){const i=n.map;i&&i.dispose(),n.dispose()}}}const Dn=Math.PI/180;function Fa(s,e,t){return Math.max(e,Math.min(t,s))}function Ip(s,e){return s+Math.random()*(e-s)}function nc(s,e){return(s%(e*2)+e*3)%(e*2)-e}let ic,sc;function Qb(s){switch(s){case"snow":return eE();case"hail":return tE()}}function eE(){if(ic)return ic;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),ic=new Li(e),ic}function tE(){if(sc)return sc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),sc=new Li(e),sc}let rc;function nE(){if(rc)return rc;const s=64,e=document.createElement("canvas");e.width=s,e.height=s;const t=e.getContext("2d"),n=t.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,s,s),rc=new Li(e),rc}const iE=`
6364
6365
  uniform float uMaxSize;
6365
6366
  uniform float uScale;
6366
6367
  attribute float aLife;