@chanmeng666/archlang-3d 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- "use strict";(()=>{var ti={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ni={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Cc=0,Vo=1,Pc=2;var Us=1,Ic=2,Qi=3,ii=0,Vt=1,Mn=2,yi=0,es=1,Go=2,Ho=3,Wo=4,Lc=5;var vi=100,Dc=101,Nc=102,Uc=103,Fc=104,Oc=200,Bc=201,zc=202,kc=203,Xo=204,qo=205,Vc=206,Gc=207,Hc=208,Wc=209,Xc=210,qc=211,Yc=212,Zc=213,$c=214,Cr=0,Pr=1,Ir=2,Vi=3,Lr=4,Dr=5,Nr=6,Ur=7,ha=0,Jc=1,Kc=2,bn=0,Yo=1,Zo=2,$o=3,Jo=4,Ko=5,jo=6,Fs=7;var Qo=300,Mi=301,ts=302,ua=303,da=304,Fr=1e3,yn=1001,Or=1002,wt=1003,jc=1004;var Os=1005;var kt=1006,fa=1007;var kn=1008;var Xt=1009,el=1010,tl=1011,ns=1012,pa=1013,fn=1014,pn=1015,mn=1016,ma=1017,ga=1018,bi=1020,nl=35902,il=35899,sl=1021,rl=1022,gn=1023,Fn=1026,Vn=1027,al=1028,_a=1029,si=1030,xa=1031;var ya=1033,Bs=33776,zs=33777,ks=33778,Vs=33779,va=35840,Ma=35841,ba=35842,Sa=35843,Ea=36196,wa=37492,Ta=37496,Aa=37488,Ra=37489,Gs=37490,Ca=37491,Pa=37808,Ia=37809,La=37810,Da=37811,Na=37812,Ua=37813,Fa=37814,Oa=37815,Ba=37816,za=37817,ka=37818,Va=37819,Ga=37820,Ha=37821,Wa=36492,Xa=36494,qa=36495,Ya=36283,Za=36284,Hs=36285,$a=36286;var gs=2300,Br=2301,Ar=2302,No=2303,Uo=2400,Fo=2401,Oo=2402;var Qc=3200;var Ja=0,eh=1,Gn="",Jt="srgb",_s="srgb-linear",xs="linear",nt="srgb";var Rr=7680;var th=519,nh=512,ih=513,sh=514,ol=515,rh=516,ah=517,ll=518,cl=519,oh=35044;var hl="300 es",on=2e3,Gi=2001;function Iu(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Lu(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ys(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function lh(){let i=ys("canvas");return i.style.display="block",i}var tc={},Hi=null;function ul(...i){let e="THREE."+i.shift();Hi?Hi("log",e,...i):console.log(e,...i)}function ch(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ie(...i){i=ch(i);let e="THREE."+i.shift();if(Hi)Hi("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function Ue(...i){i=ch(i);let e="THREE."+i.shift();if(Hi)Hi("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function ps(...i){let e=i.join(" ");e in tc||(tc[e]=!0,Ie(...i))}function hh(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var uh={[Cr]:Cr,[Ir]:Nr,[Lr]:Lr,[Vi]:Dr,[Pr]:Pr,[Nr]:Ir,[Ur]:Ur,[Dr]:Vi},dn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}},Dt=["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"],nc=1234567,zi=Math.PI/180,Wi=180/Math.PI;function is(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Dt[i&255]+Dt[i>>8&255]+Dt[i>>16&255]+Dt[i>>24&255]+"-"+Dt[e&255]+Dt[e>>8&255]+"-"+Dt[e>>16&15|64]+Dt[e>>24&255]+"-"+Dt[t&63|128]+Dt[t>>8&255]+"-"+Dt[t>>16&255]+Dt[t>>24&255]+Dt[n&255]+Dt[n>>8&255]+Dt[n>>16&255]+Dt[n>>24&255]).toLowerCase()}function We(i,e,t){return Math.max(e,Math.min(t,i))}function dl(i,e){return(i%e+e)%e}function Du(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function Nu(i,e,t){return i!==e?(t-i)/(e-i):0}function ms(i,e,t){return(1-t)*i+t*e}function Uu(i,e,t,n){return ms(i,e,1-Math.exp(-t*n))}function Fu(i,e=1){return e-Math.abs(dl(i,e*2)-e)}function Ou(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Bu(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function zu(i,e){return i+Math.floor(Math.random()*(e-i+1))}function ku(i,e){return i+Math.random()*(e-i)}function Vu(i){return i*(.5-Math.random())}function Gu(i){i!==void 0&&(nc=i);let e=nc+=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 Hu(i){return i*zi}function Wu(i){return i*Wi}function Xu(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function qu(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function fl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Yu(i,e,t,n,s){let r=Math.cos,a=Math.sin,o=r(t/2),c=a(t/2),l=r((e+n)/2),h=a((e+n)/2),d=r((e-n)/2),u=a((e-n)/2),m=r((n-e)/2),_=a((n-e)/2);switch(s){case"XYX":i.set(o*h,c*d,c*u,o*l);break;case"YZY":i.set(c*u,o*h,c*d,o*l);break;case"ZXZ":i.set(c*d,c*u,o*h,o*l);break;case"XZX":i.set(o*h,c*_,c*m,o*l);break;case"YXY":i.set(c*m,o*h,c*_,o*l);break;case"ZYZ":i.set(c*_,c*m,o*h,o*l);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function pl(i){switch(i.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function dh(i,e){if(e.constructor===Float32Array)return i;let t=pl(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.max(i/t,-1)}function fh(i,e){if(e.constructor===Float32Array)return i;let t=pl(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.round(i*t)}var ml={DEG2RAD:zi,RAD2DEG:Wi,generateUUID:is,clamp:We,euclideanModulo:dl,mapLinear:Du,inverseLerp:Nu,lerp:ms,damp:Uu,pingpong:Fu,smoothstep:Ou,smootherstep:Bu,randInt:zu,randFloat:ku,randFloatSpread:Vu,seededRandom:Gu,degToRad:Hu,radToDeg:Wu,isPowerOfTwo:Xu,ceilPowerOfTwo:qu,floorPowerOfTwo:fl,setQuaternionFromProperEuler:Yu,normalize:fh,denormalize:dh},vl=class vl{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){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};vl.prototype.isVector2=!0;var Fe=vl,jt=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],m=r[a+1],_=r[a+2],y=r[a+3];if(d!==y||c!==u||l!==m||h!==_){let p=c*u+l*m+h*_+d*y;p<0&&(u=-u,m=-m,_=-_,y=-y,p=-p);let f=1-o;if(p<.9995){let S=Math.acos(p),A=Math.sin(S);f=Math.sin(f*S)/A,o=Math.sin(o*S)/A,c=c*f+u*o,l=l*f+m*o,h=h*f+_*o,d=d*f+y*o}else{c=c*f+u*o,l=l*f+m*o,h=h*f+_*o,d=d*f+y*o;let S=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=S,l*=S,h*=S,d*=S}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],u=r[a+1],m=r[a+2],_=r[a+3];return e[t]=o*_+h*d+c*m-l*u,e[t+1]=c*_+h*u+l*d-o*m,e[t+2]=l*_+h*m+o*u-c*d,e[t+3]=h*_-o*d-c*u-l*m,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,s){return this._x=e,this._y=t,this._z=n,this._w=s,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){let n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),u=c(n/2),m=c(s/2),_=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*m*_,this._y=l*m*d-u*h*_,this._z=l*h*_+u*m*d,this._w=l*h*d-u*m*_;break;case"YXZ":this._x=u*h*d+l*m*_,this._y=l*m*d-u*h*_,this._z=l*h*_-u*m*d,this._w=l*h*d+u*m*_;break;case"ZXY":this._x=u*h*d-l*m*_,this._y=l*m*d+u*h*_,this._z=l*h*_+u*m*d,this._w=l*h*d-u*m*_;break;case"ZYX":this._x=u*h*d-l*m*_,this._y=l*m*d+u*h*_,this._z=l*h*_-u*m*d,this._w=l*h*d+u*m*_;break;case"YZX":this._x=u*h*d+l*m*_,this._y=l*m*d+u*h*_,this._z=l*h*_-u*m*d,this._w=l*h*d-u*m*_;break;case"XZY":this._x=u*h*d-l*m*_,this._y=l*m*d-u*h*_,this._z=l*h*_+u*m*d,this._w=l*h*d+u*m*_;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],c=t[9],l=t[2],h=t[6],d=t[10],u=n+o+d;if(u>0){let m=.5/Math.sqrt(u+1);this._w=.25/m,this._x=(h-c)*m,this._y=(r-l)*m,this._z=(a-s)*m}else if(n>o&&n>d){let m=2*Math.sqrt(1+n-o-d);this._w=(h-c)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(r+l)/m}else if(o>d){let m=2*Math.sqrt(1+o-n-d);this._w=(r-l)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(c+h)/m}else{let m=2*Math.sqrt(1+d-n-o);this._w=(a-s)/m,this._x=(r+l)/m,this._y=(c+h)/m,this._z=.25*m}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(We(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),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){let n=e._x,s=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+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let c=1-t;if(o<.9995){let 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+s*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+s*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(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*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}},Ml=class Ml{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(ic.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ic.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,c=e.w,l=2*(a*s-o*n),h=2*(o*t-r*s),d=2*(r*n-a*t);return this.x=t+c*l+a*d-o*h,this.y=n+c*h+o*l-r*d,this.z=s+c*d+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){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(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){let n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,c=t.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return uo.copy(this).projectOnVector(e),this.sub(uo)}reflect(e){return this.sub(uo.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(We(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}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){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,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(){let 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}};Ml.prototype.isVector3=!0;var B=Ml,uo=new B,ic=new jt,bl=class bl{constructor(e,t,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,c,l)}set(e,t,n,s,r,a,o,c,l){let h=this.elements;return h[0]=e,h[1]=s,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){let 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){let 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){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],m=n[5],_=n[8],y=s[0],p=s[3],f=s[6],S=s[1],A=s[4],b=s[7],T=s[2],E=s[5],g=s[8];return r[0]=a*y+o*S+c*T,r[3]=a*p+o*A+c*E,r[6]=a*f+o*b+c*g,r[1]=l*y+h*S+d*T,r[4]=l*p+h*A+d*E,r[7]=l*f+h*b+d*g,r[2]=u*y+m*S+_*T,r[5]=u*p+m*A+_*E,r[8]=u*f+m*b+_*g,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],s=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+s*r*l-s*a*c}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],d=h*a-o*l,u=o*c-h*r,m=l*r-a*c,_=t*d+n*u+s*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/_;return e[0]=d*y,e[1]=(s*l-h*n)*y,e[2]=(o*n-s*a)*y,e[3]=u*y,e[4]=(h*t-s*c)*y,e[5]=(s*r-o*t)*y,e[6]=m*y,e[7]=(n*c-l*t)*y,e[8]=(a*t-n*r)*y,this}transpose(){let e,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){let 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,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+e,-s*l,s*c,-s*(-l*a+c*o)+o+t,0,0,1),this}scale(e,t){return ps("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(fo.makeScale(e,t)),this}rotate(e){return ps("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(fo.makeRotation(-e)),this}translate(e,t){return ps("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(fo.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){let 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){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])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){let 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)}};bl.prototype.isMatrix3=!0;var Oe=bl,fo=new Oe,sc=new Oe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),rc=new Oe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Zu(){let i={enabled:!0,workingColorSpace:_s,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===nt&&(s.r=Un(s.r),s.g=Un(s.g),s.b=Un(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===nt&&(s.r=ki(s.r),s.g=ki(s.g),s.b=ki(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Gn?xs:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[a].fromXYZ).multiply(this.spaces[r].toXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[_s]:{primaries:e,whitePoint:n,transfer:xs,toXYZ:sc,fromXYZ:rc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Jt},outputColorSpaceConfig:{drawingBufferColorSpace:Jt}},[Jt]:{primaries:e,whitePoint:n,transfer:nt,toXYZ:sc,fromXYZ:rc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Jt}}}),i}var Ze=Zu();function Un(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ki(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Ti,zr=class{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{Ti===void 0&&(Ti=ys("canvas")),Ti.width=e.width,Ti.height=e.height;let s=Ti.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Ti}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){let t=ys("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=Un(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Un(t[n]/255)*255):t[n]=Un(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},$u=0,Xi=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:$u++}),this.uuid=is(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let 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||0,t.height||0,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(po(s[a].image)):r.push(po(s[a]))}else r=po(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function po(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?zr.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ie("Texture: Unable to serialize Texture."),{})}var Ju=0,mo=new B,Ht=class i extends dn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=yn,s=yn,r=kt,a=kn,o=gn,c=Xt,l=i.DEFAULT_ANISOTROPY,h=Gn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ju++}),this.uuid=is(),this.name="",this.source=new Xi(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Fe(0,0),this.repeat=new Fe(1,1),this.center=new Fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Oe,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!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.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(mo).x}get height(){return this.source.getSize(mo).y}get depth(){return this.source.getSize(mo).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.mipmapsAutoUpdate=e.mipmapsAutoUpdate,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.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let 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,mipmapsAutoUpdate:this.mipmapsAutoUpdate,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!==Qo)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Fr:e.x=e.x-Math.floor(e.x);break;case yn:e.x=e.x<0?0:1;break;case Or: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 Fr:e.y=e.y-Math.floor(e.y);break;case yn:e.y=e.y<0?0:1;break;case Or: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++}};Ht.DEFAULT_IMAGE=null;Ht.DEFAULT_MAPPING=Qo;Ht.DEFAULT_ANISOTROPY=1;var Sl=class Sl{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}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,s){return this.x=e,this.y=t,this.z=n,this.w=s,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){let t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+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);let 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,s,r,c=e.elements,l=c[0],h=c[4],d=c[8],u=c[1],m=c[5],_=c[9],y=c[2],p=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-y)<.01&&Math.abs(_-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+y)<.1&&Math.abs(_+p)<.1&&Math.abs(l+m+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let A=(l+1)/2,b=(m+1)/2,T=(f+1)/2,E=(h+u)/4,g=(d+y)/4,M=(_+p)/4;return A>b&&A>T?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=E/n,r=g/n):b>T?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=E/s,r=M/s):T<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(T),n=g/r,s=M/r),this.set(n,s,r,t),this}let S=Math.sqrt((p-_)*(p-_)+(d-y)*(d-y)+(u-h)*(u-h));return Math.abs(S)<.001&&(S=1),this.x=(p-_)/S,this.y=(d-y)/S,this.z=(u-h)/S,this.w=Math.acos((l+m+f-1)/2),this}setFromMatrixPosition(e){let 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=We(this.x,e.x,t.x),this.y=We(this.y,e.y,t.y),this.z=We(this.z,e.z,t.z),this.w=We(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=We(this.x,e,t),this.y=We(this.y,e,t),this.z=We(this.z,e,t),this.w=We(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(We(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}};Sl.prototype.isVector4=!0;var dt=Sl,kr=class extends dn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:kt,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!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 dt(0,0,e,t),this.scissorTest=!1,this.viewport=new dt(0,0,e,t),this.textures=[];let s=n.count;for(let r=0;r<s;r++)this.textures[r]=new Ht({width:e,height:t,depth:n.depth}),this.textures[r].isRenderTargetTexture=!0,this.textures[r].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:kt,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.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),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===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===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 s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].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;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new Xi(s)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},Qt=class extends kr{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},vs=class extends Ht{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=wt,this.minFilter=wt,this.wrapR=yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var Vr=class extends Ht{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=wt,this.minFilter=wt,this.wrapR=yn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var ca=class ca{constructor(e,t,n,s,r,a,o,c,l,h,d,u,m,_,y,p){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,s,r,a,o,c,l,h,d,u,m,_,y,p)}set(e,t,n,s,r,a,o,c,l,h,d,u,m,_,y,p){let f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=m,f[7]=_,f[11]=y,f[15]=p,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 ca().fromArray(this.elements)}copy(e){let 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){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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();let t=this.elements,n=e.elements,s=1/Ai.setFromMatrixColumn(e,0).length(),r=1/Ai.setFromMatrixColumn(e,1).length(),a=1/Ai.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,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){let t=this.elements,n=e.x,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let u=a*h,m=a*d,_=o*h,y=o*d;t[0]=c*h,t[4]=-c*d,t[8]=l,t[1]=m+_*l,t[5]=u-y*l,t[9]=-o*c,t[2]=y-u*l,t[6]=_+m*l,t[10]=a*c}else if(e.order==="YXZ"){let u=c*h,m=c*d,_=l*h,y=l*d;t[0]=u+y*o,t[4]=_*o-m,t[8]=a*l,t[1]=a*d,t[5]=a*h,t[9]=-o,t[2]=m*o-_,t[6]=y+u*o,t[10]=a*c}else if(e.order==="ZXY"){let u=c*h,m=c*d,_=l*h,y=l*d;t[0]=u-y*o,t[4]=-a*d,t[8]=_+m*o,t[1]=m+_*o,t[5]=a*h,t[9]=y-u*o,t[2]=-a*l,t[6]=o,t[10]=a*c}else if(e.order==="ZYX"){let u=a*h,m=a*d,_=o*h,y=o*d;t[0]=c*h,t[4]=_*l-m,t[8]=u*l+y,t[1]=c*d,t[5]=y*l+u,t[9]=m*l-_,t[2]=-l,t[6]=o*c,t[10]=a*c}else if(e.order==="YZX"){let u=a*c,m=a*l,_=o*c,y=o*l;t[0]=c*h,t[4]=y-u*d,t[8]=_*d+m,t[1]=d,t[5]=a*h,t[9]=-o*h,t[2]=-l*h,t[6]=m*d+_,t[10]=u-y*d}else if(e.order==="XZY"){let u=a*c,m=a*l,_=o*c,y=o*l;t[0]=c*h,t[4]=-d,t[8]=l*h,t[1]=u*d+y,t[5]=a*h,t[9]=m*d-_,t[2]=_*d-m,t[6]=o*h,t[10]=y*d+u}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(Ku,e,ju)}lookAt(e,t,n){let s=this.elements;return Zt.subVectors(e,t),Zt.lengthSq()===0&&(Zt.z=1),Zt.normalize(),Xn.crossVectors(n,Zt),Xn.lengthSq()===0&&(Math.abs(n.z)===1?Zt.x+=1e-4:Zt.z+=1e-4,Zt.normalize(),Xn.crossVectors(n,Zt)),Xn.normalize(),nr.crossVectors(Zt,Xn),s[0]=Xn.x,s[4]=nr.x,s[8]=Zt.x,s[1]=Xn.y,s[5]=nr.y,s[9]=Zt.y,s[2]=Xn.z,s[6]=nr.z,s[10]=Zt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],m=n[13],_=n[2],y=n[6],p=n[10],f=n[14],S=n[3],A=n[7],b=n[11],T=n[15],E=s[0],g=s[4],M=s[8],U=s[12],I=s[1],D=s[5],F=s[9],H=s[13],C=s[2],Y=s[6],J=s[10],z=s[14],te=s[3],W=s[7],$=s[11],ae=s[15];return r[0]=a*E+o*I+c*C+l*te,r[4]=a*g+o*D+c*Y+l*W,r[8]=a*M+o*F+c*J+l*$,r[12]=a*U+o*H+c*z+l*ae,r[1]=h*E+d*I+u*C+m*te,r[5]=h*g+d*D+u*Y+m*W,r[9]=h*M+d*F+u*J+m*$,r[13]=h*U+d*H+u*z+m*ae,r[2]=_*E+y*I+p*C+f*te,r[6]=_*g+y*D+p*Y+f*W,r[10]=_*M+y*F+p*J+f*$,r[14]=_*U+y*H+p*z+f*ae,r[3]=S*E+A*I+b*C+T*te,r[7]=S*g+A*D+b*Y+T*W,r[11]=S*M+A*F+b*J+T*$,r[15]=S*U+A*H+b*z+T*ae,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],c=e[9],l=e[13],h=e[2],d=e[6],u=e[10],m=e[14],_=e[3],y=e[7],p=e[11],f=e[15],S=c*m-l*u,A=o*m-l*d,b=o*u-c*d,T=a*m-l*h,E=a*u-c*h,g=a*d-o*h;return t*(y*S-p*A+f*b)-n*(_*S-p*T+f*E)+s*(_*A-y*T+f*g)-r*(_*b-y*E+p*g)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=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)+s*(r*l-a*c)}transpose(){let e=this.elements,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){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],l=e[7],h=e[8],d=e[9],u=e[10],m=e[11],_=e[12],y=e[13],p=e[14],f=e[15],S=t*o-n*a,A=t*c-s*a,b=t*l-r*a,T=n*c-s*o,E=n*l-r*o,g=s*l-r*c,M=h*y-d*_,U=h*p-u*_,I=h*f-m*_,D=d*p-u*y,F=d*f-m*y,H=u*f-m*p,C=S*H-A*F+b*D+T*I-E*U+g*M;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let Y=1/C;return e[0]=(o*H-c*F+l*D)*Y,e[1]=(s*F-n*H-r*D)*Y,e[2]=(y*g-p*E+f*T)*Y,e[3]=(u*E-d*g-m*T)*Y,e[4]=(c*I-a*H-l*U)*Y,e[5]=(t*H-s*I+r*U)*Y,e[6]=(p*b-_*g-f*A)*Y,e[7]=(h*g-u*b+m*A)*Y,e[8]=(a*F-o*I+l*M)*Y,e[9]=(n*I-t*F-r*M)*Y,e[10]=(_*E-y*b+f*S)*Y,e[11]=(d*b-h*E-m*S)*Y,e[12]=(o*U-a*D-c*M)*Y,e[13]=(t*D-n*U+s*M)*Y,e[14]=(y*A-_*T-p*S)*Y,e[15]=(h*T-d*A+u*S)*Y,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let 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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}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){let 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){let 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){let 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){let n=Math.cos(t),s=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-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*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,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,a=t._y,o=t._z,c=t._w,l=r+r,h=a+a,d=o+o,u=r*l,m=r*h,_=r*d,y=a*h,p=a*d,f=o*d,S=c*l,A=c*h,b=c*d,T=n.x,E=n.y,g=n.z;return s[0]=(1-(y+f))*T,s[1]=(m+b)*T,s[2]=(_-A)*T,s[3]=0,s[4]=(m-b)*E,s[5]=(1-(u+f))*E,s[6]=(p+S)*E,s[7]=0,s[8]=(_+A)*g,s[9]=(p-S)*g,s[10]=(1-(u+y))*g,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Ai.set(s[0],s[1],s[2]).length(),o=Ai.set(s[4],s[5],s[6]).length(),c=Ai.set(s[8],s[9],s[10]).length();r<0&&(a=-a),cn.copy(this);let l=1/a,h=1/o,d=1/c;return cn.elements[0]*=l,cn.elements[1]*=l,cn.elements[2]*=l,cn.elements[4]*=h,cn.elements[5]*=h,cn.elements[6]*=h,cn.elements[8]*=d,cn.elements[9]*=d,cn.elements[10]*=d,t.setFromRotationMatrix(cn),n.x=a,n.y=o,n.z=c,this}makePerspective(e,t,n,s,r,a,o=on,c=!1){let l=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),m=(n+s)/(n-s),_,y;if(c)_=r/(a-r),y=a*r/(a-r);else if(o===on)_=-(a+r)/(a-r),y=-2*a*r/(a-r);else if(o===Gi)_=-a/(a-r),y=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=d,l[9]=m,l[13]=0,l[2]=0,l[6]=0,l[10]=_,l[14]=y,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=on,c=!1){let l=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),m=-(n+s)/(n-s),_,y;if(c)_=1/(a-r),y=a/(a-r);else if(o===on)_=-2/(a-r),y=-(a+r)/(a-r);else if(o===Gi)_=-1/(a-r),y=-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]=u,l[1]=0,l[5]=d,l[9]=0,l[13]=m,l[2]=0,l[6]=0,l[10]=_,l[14]=y,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])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){let 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}};ca.prototype.isMatrix4=!0;var ht=ca,Ai=new B,cn=new ht,Ku=new B(0,0,0),ju=new B(1,1,1),Xn=new B,nr=new B,Zt=new B,ac=new ht,oc=new jt,On=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,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){let s=e.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],m=s[10];switch(t){case"XYZ":this._y=Math.asin(We(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-We(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(We(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-We(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,m),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(We(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-We(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ac.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ac,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return oc.setFromEuler(this),this.setFromQuaternion(oc,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}};On.DEFAULT_ORDER="XYZ";var Ms=class{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}},Qu=0,lc=new B,Ri=new jt,Rn=new ht,ir=new B,cs=new B,ed=new B,td=new jt,cc=new B(1,0,0),hc=new B(0,1,0),uc=new B(0,0,1),dc={type:"added"},nd={type:"removed"},Ci={type:"childadded",child:null},go={type:"childremoved",child:null},Ct=class i extends dn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Qu++}),this.uuid=is(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new B,t=new On,n=new jt,s=new B(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:s},modelViewMatrix:{value:new ht},normalMatrix:{value:new Oe}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ms,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),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}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 Ri.setFromAxisAngle(e,t),this.quaternion.multiply(Ri),this}rotateOnWorldAxis(e,t){return Ri.setFromAxisAngle(e,t),this.quaternion.premultiply(Ri),this}rotateX(e){return this.rotateOnAxis(cc,e)}rotateY(e){return this.rotateOnAxis(hc,e)}rotateZ(e){return this.rotateOnAxis(uc,e)}translateOnAxis(e,t){return lc.copy(e).applyQuaternion(this.quaternion),this.position.add(lc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(cc,e)}translateY(e){return this.translateOnAxis(hc,e)}translateZ(e){return this.translateOnAxis(uc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Rn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ir.copy(e):ir.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),cs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Rn.lookAt(cs,ir,this.up):Rn.lookAt(ir,cs,this.up),this.quaternion.setFromRotationMatrix(Rn),s&&(Rn.extractRotation(s.matrixWorld),Ri.setFromRotationMatrix(Rn),this.quaternion.premultiply(Ri.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Ue("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(dc),Ci.child=e,this.dispatchEvent(Ci),Ci.child=null):Ue("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}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(nd),go.child=e,this.dispatchEvent(go),go.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Rn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Rn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Rn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(dc),Ci.child=e,this.dispatchEvent(Ci),Ci.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,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[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(cs,e,ed),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(cs,td,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}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);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let s=this.parent;if(e===!0&&s!==null&&s.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){let r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){let 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"});let s={};s.uuid=this.uuid,s.type=this.type,s.name=this.name,s.castShadow=this.castShadow,s.receiveShadow=this.receiveShadow,s.visible=this.visible,s.frustumCulled=this.frustumCulled,s.renderOrder=this.renderOrder,s.static=this.static,s.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.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?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let d=c[l];r(e.shapes,d)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(e.materials,this.material[c]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];s.animations.push(r(e.animations,c))}}if(t){let o=a(e.geometries),c=a(e.materials),l=a(e.textures),h=a(e.images),d=a(e.shapes),u=a(e.skeletons),m=a(e.animations),_=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),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),m.length>0&&(n.animations=m),_.length>0&&(n.nodes=_)}return n.object=s,n;function a(o){let c=[];for(let l in o){let 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++){let s=e.children[n];this.add(s.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Ct.DEFAULT_UP=new B(0,1,0);Ct.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ct.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Nn=class extends Ct{constructor(){super(),this.isGroup=!0,this.type="Group"}},id={type:"move"},qi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Nn,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 Nn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new B,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new B),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Nn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new B,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new B,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){let t=this._hand;if(t)for(let 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 s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){a=!0;for(let y of e.hand.values()){let p=t.getJointPose(y,n),f=this._getHandJoint(l,y);p!==null&&(f.matrix.fromArray(p.transform.matrix),f.matrix.decompose(f.position,f.quaternion,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=p.radius),f.visible=p!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),m=.02,_=.005;l.inputState.pinching&&u>m+_?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=m-_&&(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.quaternion,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&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(id)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Nn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},ph={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},qn={h:0,s:0,l:0},sr={h:0,s:0,l:0};function _o(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var ze=class{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){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ze.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ze.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ze.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ze.workingColorSpace){if(e=dl(e,1),t=We(t,0,1),n=We(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=_o(a,r,e+1/3),this.g=_o(a,r,e),this.b=_o(a,r,e-1/3)}return Ze.colorSpaceToWorking(this,s),this}setStyle(e,t=Jt){function n(r){r!==void 0&&parseFloat(r)<1&&Ie("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\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+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseFloat(r[1]))/100,Math.min(100,parseFloat(r[2]))/100,Math.min(100,parseFloat(r[3]))/100,t);break;case"hsl":case"hsla":if(r=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\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:Ie("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[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);Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jt){let n=ph[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ie("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=Un(e.r),this.g=Un(e.g),this.b=Un(e.b),this}copyLinearToSRGB(e){return this.r=ki(e.r),this.g=ki(e.g),this.b=ki(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jt){return Ze.workingToColorSpace(Nt.copy(this),e),Math.round(We(Nt.r*255,0,255))*65536+Math.round(We(Nt.g*255,0,255))*256+Math.round(We(Nt.b*255,0,255))}getHexString(e=Jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ze.workingColorSpace){Ze.workingToColorSpace(Nt.copy(this),t);let n=Nt.r,s=Nt.g,r=Nt.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-n)/d+2;break;case r:c=(n-s)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=Ze.workingColorSpace){return Ze.workingToColorSpace(Nt.copy(this),t),e.r=Nt.r,e.g=Nt.g,e.b=Nt.b,e}getStyle(e=Jt){Ze.workingToColorSpace(Nt.copy(this),e);let t=Nt.r,n=Nt.g,s=Nt.b;return e!==Jt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(qn),this.setHSL(qn.h+e,qn.s+t,qn.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(qn),e.getHSL(sr);let n=ms(qn.h,sr.h,t),s=ms(qn.s,sr.s,t),r=ms(qn.l,sr.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,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}},Nt=new ze;ze.NAMES=ph;var bs=class extends Ct{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 On,this.environmentIntensity=1,this.environmentRotation=new On,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background!==null?e.background.clone():null,this.environment=e.environment!==null?e.environment.clone():null,this.fog=e.fog!==null?e.fog.clone():null,this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial!==null?e.overrideMaterial.clone():null,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},hn=new B,Cn=new B,xo=new B,Pn=new B,Pi=new B,Ii=new B,fc=new B,yo=new B,vo=new B,Mo=new B,bo=new dt,So=new dt,Eo=new dt,Dn=class i{constructor(e=new B,t=new B,n=new B){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),hn.subVectors(e,t),s.cross(hn);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){hn.subVectors(s,t),Cn.subVectors(n,t),xo.subVectors(e,t);let a=hn.dot(hn),o=hn.dot(Cn),c=hn.dot(xo),l=Cn.dot(Cn),h=Cn.dot(xo),d=a*l-o*o;if(d===0)return r.set(0,0,0),null;let u=1/d,m=(l*c-o*h)*u,_=(a*h-o*c)*u;return r.set(1-m-_,_,m)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Pn)===null?!1:Pn.x>=0&&Pn.y>=0&&Pn.x+Pn.y<=1}static getInterpolation(e,t,n,s,r,a,o,c){return this.getBarycoord(e,t,n,s,Pn)===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,Pn.x),c.addScaledVector(a,Pn.y),c.addScaledVector(o,Pn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,a){return bo.setScalar(0),So.setScalar(0),Eo.setScalar(0),bo.fromBufferAttribute(e,t),So.fromBufferAttribute(e,n),Eo.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(bo,r.x),a.addScaledVector(So,r.y),a.addScaledVector(Eo,r.z),a}static isFrontFacing(e,t,n,s){return hn.subVectors(n,t),Cn.subVectors(e,t),hn.cross(Cn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),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 hn.subVectors(this.c,this.b),Cn.subVectors(this.a,this.b),hn.cross(Cn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,a,o;Pi.subVectors(s,n),Ii.subVectors(r,n),yo.subVectors(e,n);let c=Pi.dot(yo),l=Ii.dot(yo);if(c<=0&&l<=0)return t.copy(n);vo.subVectors(e,s);let h=Pi.dot(vo),d=Ii.dot(vo);if(h>=0&&d<=h)return t.copy(s);let u=c*d-h*l;if(u<=0&&c>=0&&h<=0&&c-h>0)return a=c/(c-h),t.copy(n).addScaledVector(Pi,a);Mo.subVectors(e,r);let m=Pi.dot(Mo),_=Ii.dot(Mo);if(_>=0&&m<=_)return t.copy(r);let y=m*l-c*_;if(y<=0&&l>=0&&_<=0)return o=l/(l-_),t.copy(n).addScaledVector(Ii,o);let p=h*_-m*d;if(p<=0&&d-h>=0&&m-_>=0)return fc.subVectors(r,s),o=(d-h)/(d-h+(m-_)),t.copy(s).addScaledVector(fc,o);let f=1/(p+y+u);return a=y*f,o=u*f,t.copy(n).addScaledVector(Pi,a).addScaledVector(Ii,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Jn=class{constructor(e=new B(1/0,1/0,1/0),t=new B(-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(un.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(un.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){let n=un.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);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,un):un.fromBufferAttribute(r,a),un.applyMatrix4(e.matrixWorld),this.expandByPoint(un);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),rr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),rr.copy(n.boundingBox)),rr.applyMatrix4(e.matrixWorld),this.union(rr)}let s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[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,un),un.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(hs),ar.subVectors(this.max,hs),Li.subVectors(e.a,hs),Di.subVectors(e.b,hs),Ni.subVectors(e.c,hs),Yn.subVectors(Di,Li),Zn.subVectors(Ni,Di),ui.subVectors(Li,Ni);let t=[0,-Yn.z,Yn.y,0,-Zn.z,Zn.y,0,-ui.z,ui.y,Yn.z,0,-Yn.x,Zn.z,0,-Zn.x,ui.z,0,-ui.x,-Yn.y,Yn.x,0,-Zn.y,Zn.x,0,-ui.y,ui.x,0];return!wo(t,Li,Di,Ni,ar)||(t=[1,0,0,0,1,0,0,0,1],!wo(t,Li,Di,Ni,ar))?!1:(or.crossVectors(Yn,Zn),t=[or.x,or.y,or.z],wo(t,Li,Di,Ni,ar))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,un).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(un).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:(In[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),In[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),In[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),In[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),In[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),In[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),In[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),In[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(In),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}},In=[new B,new B,new B,new B,new B,new B,new B,new B],un=new B,rr=new Jn,Li=new B,Di=new B,Ni=new B,Yn=new B,Zn=new B,ui=new B,hs=new B,ar=new B,or=new B,di=new B;function wo(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){di.fromArray(i,r);let o=s.x*Math.abs(di.x)+s.y*Math.abs(di.y)+s.z*Math.abs(di.z),c=e.dot(di),l=t.dot(di),h=n.dot(di);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var xt=new B,lr=new Fe,sd=0,Gt=class extends dn{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:sd++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=oh,this.updateRanges=[],this.gpuType=pn,this.version=0,this._normalizationScale=e!==void 0?pl(e):void 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._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];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++)lr.fromBufferAttribute(this,t),lr.applyMatrix3(e),this.setXY(t,lr.x,lr.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=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,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(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}_denormalize(e){let t=this._normalizationScale;return t!==void 0?Math.max(e/t,-1):dh(e,this.array)}_normalize(e){let t=this._normalizationScale;return t!==void 0?Math.round(e*t):fh(e,this.array)}};var Ss=class extends Gt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Es=class extends Gt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var zt=class extends Gt{constructor(e,t,n){super(new Float32Array(e),t,n)}},rd=new Jn,us=new B,To=new B,mi=class{constructor(e=new B,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){let n=this.center;t!==void 0?n.copy(t):rd.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),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){let 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){let 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;us.subVectors(e,this.center);let t=us.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(us,s/n),this.radius+=s}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):(To.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(us.copy(e.center).add(To)),this.expandByPoint(us.copy(e.center).sub(To))),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}},ad=0,an=new ht,Ao=new Ct,Ui=new B,$t=new Jn,ds=new Jn,Et=new B,Wt=class i extends dn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ad++}),this.uuid=is(),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(Iu(e)?Es:Ss)(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){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Oe().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return an.makeRotationFromQuaternion(e),this.applyMatrix4(an),this}rotateX(e){return an.makeRotationX(e),this.applyMatrix4(an),this}rotateY(e){return an.makeRotationY(e),this.applyMatrix4(an),this}rotateZ(e){return an.makeRotationZ(e),this.applyMatrix4(an),this}translate(e,t,n){return an.makeTranslation(e,t,n),this.applyMatrix4(an),this}scale(e,t,n){return an.makeScale(e,t,n),this.applyMatrix4(an),this}lookAt(e){return Ao.lookAt(e),Ao.updateMatrix(),this.applyMatrix4(Ao.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ui).negate(),this.translate(Ui.x,Ui.y,Ui.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new zt(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&Ie("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 Jn);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];$t.setFromBufferAttribute(r),this.morphTargetsRelative?(Et.addVectors(this.boundingBox.min,$t.min),this.boundingBox.expandByPoint(Et),Et.addVectors(this.boundingBox.max,$t.max),this.boundingBox.expandByPoint(Et)):(this.boundingBox.expandByPoint($t.min),this.boundingBox.expandByPoint($t.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ue('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 mi);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ue("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new B,1/0);return}if(e){let n=this.boundingSphere.center;if($t.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){let o=t[r];ds.setFromBufferAttribute(o),this.morphTargetsRelative?(Et.addVectors($t.min,ds.min),$t.expandByPoint(Et),Et.addVectors($t.max,ds.max),$t.expandByPoint(Et)):($t.expandByPoint(ds.min),$t.expandByPoint(ds.max))}$t.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)Et.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Et));if(t)for(let r=0,a=t.length;r<a;r++){let o=t[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Et.fromBufferAttribute(o,l),c&&(Ui.fromBufferAttribute(e,l),Et.add(Ui)),s=Math.max(s,n.distanceToSquared(Et))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Ue('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Ue("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new Gt(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));let o=[],c=[],l=new Uint8Array(n.count);for(let U=0;U<n.count;U++)o[U]=new B,c[U]=new B;let h=new B,d=new B,u=new B,m=new Fe,_=new Fe,y=new Fe,p=new B,f=new B;function S(U,I,D){l[U]=l[I]=l[D]=1,h.fromBufferAttribute(n,U),d.fromBufferAttribute(n,I),u.fromBufferAttribute(n,D),m.fromBufferAttribute(r,U),_.fromBufferAttribute(r,I),y.fromBufferAttribute(r,D),d.sub(h),u.sub(h),_.sub(m),y.sub(m);let F=1/(_.x*y.y-y.x*_.y);isFinite(F)&&(p.copy(d).multiplyScalar(y.y).addScaledVector(u,-_.y).multiplyScalar(F),f.copy(u).multiplyScalar(_.x).addScaledVector(d,-y.x).multiplyScalar(F),o[U].add(p),o[I].add(p),o[D].add(p),c[U].add(f),c[I].add(f),c[D].add(f))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let U=0,I=A.length;U<I;++U){let D=A[U],F=D.start,H=D.count;for(let C=F,Y=F+H;C<Y;C+=3)S(e.getX(C+0),e.getX(C+1),e.getX(C+2))}let b=new B,T=new B,E=new B,g=new B;function M(U){E.fromBufferAttribute(s,U),g.copy(E);let I=o[U];b.copy(I),b.sub(E.multiplyScalar(E.dot(I))).normalize(),T.crossVectors(g,I);let F=T.dot(c[U])<0?-1:1;a.setXYZW(U,b.x,b.y,b.z,F)}for(let U=0,I=n.count;U<I;++U)l[U]&&M(U);this._transformed=!0}computeVertexNormals(){let 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 Gt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,m=n.count;u<m;u++)n.setXYZ(u,0,0,0);let s=new B,r=new B,a=new B,o=new B,c=new B,l=new B,h=new B,d=new B;if(e)for(let u=0,m=e.count;u<m;u+=3){let _=e.getX(u+0),y=e.getX(u+1),p=e.getX(u+2);s.fromBufferAttribute(t,_),r.fromBufferAttribute(t,y),a.fromBufferAttribute(t,p),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,_),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,p),o.add(h),c.add(h),l.add(h),n.setXYZ(_,o.x,o.y,o.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let u=0,m=t.count;u<m;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),a.fromBufferAttribute(t,u+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Et.fromBufferAttribute(e,t),Et.normalize(),e.setXYZ(t,Et.x,Et.y,Et.z)}toNonIndexed(){function e(o,c){let l=o.array,h=o.itemSize,d=o.normalized,u=new l.constructor(c.length*h),m=0,_=0;for(let y=0,p=c.length;y<p;y++){o.isInterleavedBufferAttribute?m=c[y]*o.data.stride+o.offset:m=c[y]*h;for(let f=0;f<h;f++)u[_++]=l[m++]}return new Gt(u,h,d)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let o in s){let c=s[o],l=e(c,n);t.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let h=0,d=l.length;h<d;h++){let u=l[h],m=e(u,n);c.push(m)}t.morphAttributes[o]=c}t.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,c=a.length;o<c;o++){let l=a[o];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let 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,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d<u;d++){let m=l[d];h.push(m.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let 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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(t))}let r=e.morphAttributes;for(let l in r){let h=[],d=r[l];for(let u=0,m=d.length;u<m;u++)h.push(d[u].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let l=0,h=a.length;l<h;l++){let d=a[l];this.addGroup(d.start,d.count,d.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let 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"})}};var Ro=new B,od=new B,ld=new Oe,Kt=class{constructor(e=new B(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,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Ro.subVectors(n,t).cross(od.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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){let s=e.delta(Ro),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){let 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){let n=t||ld.getNormalMatrix(e),s=this.coplanarPoint(Ro).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.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)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},cd=0,Bn=class extends dn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:cd++}),this.uuid=is(),this.name="",this.type="Material",this.blending=es,this.side=ii,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Xo,this.blendDst=qo,this.blendEquation=vi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ze(0,0,0),this.blendAlpha=0,this.depthFunc=Vi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=th,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Rr,this.stencilZFail=Rr,this.stencilZPass=Rr,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(let t in e){let n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,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&&(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.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),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.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),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&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),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.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(t){let r=s(e.textures),a=s(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 ze().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.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),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.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new Kt().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),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.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),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 Fe().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 Fe().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),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;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++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++}};var Ln=new B,Co=new B,cr=new B,hr=new B,gi=class{constructor(e=new B,t=new B(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,Ln)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let 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){let t=Ln.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ln.copy(this.origin).addScaledVector(this.direction,t),Ln.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Co.copy(e).add(t).multiplyScalar(.5),cr.copy(t).sub(e).normalize(),hr.copy(this.origin).sub(Co);let r=e.distanceTo(t)*.5,a=-this.direction.dot(cr),o=hr.dot(this.direction),c=-hr.dot(cr),l=hr.lengthSq(),h=Math.abs(1-a*a),d,u,m,_;if(h>0)if(d=a*c-o,u=a*o-c,_=r*h,d>=0)if(u>=-_)if(u<=_){let y=1/h;d*=y,u*=y,m=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u<=-_?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l):u<=_?(d=0,u=Math.min(Math.max(-r,-c),r),m=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Co).addScaledVector(cr,u),m}intersectSphere(e,t){if(e.radius<0)return null;Ln.subVectors(e.center,this.origin);let n=Ln.dot(this.direction),s=Ln.dot(Ln)-n*n,r=e.radius*e.radius;if(s>r)return null;let a=Math.sqrt(r-s),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){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,s=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,s=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(e.min.z-u.z)*d,c=(e.max.z-u.z)*d):(o=(e.max.z-u.z)*d,c=(e.min.z-u.z)*d),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Ln)!==null}intersectTriangle(e,t,n,s,r){let a=this.origin,o=this.direction,c=o.x,l=o.y,h=o.z,d=e.x-a.x,u=e.y-a.y,m=e.z-a.z,_=t.x-a.x,y=t.y-a.y,p=t.z-a.z,f=n.x-a.x,S=n.y-a.y,A=n.z-a.z,b=Math.abs(c),T=Math.abs(l),E=Math.abs(h),g,M,U,I,D,F,H,C,Y,J,z,te;if(b>=T&&b>=E?(U=c,F=d,Y=_,te=f,c>=0?(g=l,M=h,I=u,D=m,H=y,C=p,J=S,z=A):(g=h,M=l,I=m,D=u,H=p,C=y,J=A,z=S)):T>=E?(U=l,F=u,Y=y,te=S,l>=0?(g=h,M=c,I=m,D=d,H=p,C=_,J=A,z=f):(g=c,M=h,I=d,D=m,H=_,C=p,J=f,z=A)):(U=h,F=m,Y=p,te=A,h>=0?(g=c,M=l,I=d,D=u,H=_,C=y,J=f,z=S):(g=l,M=c,I=u,D=d,H=y,C=_,J=S,z=f)),U===0)return null;let W=g/U,$=M/U,ae=1/U,_e=I-W*F,De=D-$*F,j=H-W*Y,pe=C-$*Y,ye=J-W*te,Re=z-$*te,fe=ye*pe-Re*j,Le=_e*Re-De*ye,pt=j*De-pe*_e;if(s){if(fe<0||Le<0||pt<0)return null}else if((fe<0||Le<0||pt<0)&&(fe>0||Le>0||pt>0))return null;let be=fe+Le+pt;if(be===0)return null;let $e=ae*(fe*F+Le*Y+pt*te);return(be>0?$e<0:$e>0)?null:this.at($e/be,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)}},Gr=class extends Bn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ze(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 On,this.combine=ha,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}},pc=new ht,fi=new gi,ur=new mi,mc=new B,dr=new B,fr=new B,pr=new B,Po=new B,mr=new B,gc=new B,gr=new B,en=class extends Ct{constructor(e=new Wt,t=new Gr){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():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let o=this.morphTargetInfluences;if(r&&o){mr.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],d=r[c];h!==0&&(Po.fromBufferAttribute(d,e),a?mr.addScaledVector(Po,h):mr.addScaledVector(Po.sub(t),h))}t.add(mr)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ur.copy(n.boundingSphere),ur.applyMatrix4(r),fi.copy(e.ray).recast(e.near),!(ur.containsPoint(fi.origin)===!1&&(fi.intersectSphere(ur,mc)===null||fi.origin.distanceToSquared(mc)>(e.far-e.near)**2))&&(pc.copy(r).invert(),fi.copy(e.ray).applyMatrix4(pc),!(n.boundingBox!==null&&fi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,fi)))}_computeIntersections(e,t,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,m=r.drawRange;if(o!==null)if(Array.isArray(a))for(let _=0,y=u.length;_<y;_++){let p=u[_],f=a[p.materialIndex],S=Math.max(p.start,m.start),A=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let b=S,T=A;b<T;b+=3){let E=o.getX(b),g=o.getX(b+1),M=o.getX(b+2);s=_r(this,f,e,n,l,h,d,E,g,M),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let _=Math.max(0,m.start),y=Math.min(o.count,m.start+m.count);for(let p=_,f=y;p<f;p+=3){let S=o.getX(p),A=o.getX(p+1),b=o.getX(p+2);s=_r(this,a,e,n,l,h,d,S,A,b),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let _=0,y=u.length;_<y;_++){let p=u[_],f=a[p.materialIndex],S=Math.max(p.start,m.start),A=Math.min(c.count,Math.min(p.start+p.count,m.start+m.count));for(let b=S,T=A;b<T;b+=3){let E=b,g=b+1,M=b+2;s=_r(this,f,e,n,l,h,d,E,g,M),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=p.materialIndex,t.push(s))}}else{let _=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let p=_,f=y;p<f;p+=3){let S=p,A=p+1,b=p+2;s=_r(this,a,e,n,l,h,d,S,A,b),s&&(s.faceIndex=Math.floor(p/3),t.push(s))}}}};function hd(i,e,t,n,s,r,a,o){let c;if(e.side===Vt?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,e.side===ii,o),c===null)return null;gr.copy(o),gr.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(gr);return l<t.near||l>t.far?null:{distance:l,point:gr.clone(),object:i}}function _r(i,e,t,n,s,r,a,o,c,l){i.getVertexPosition(o,dr),i.getVertexPosition(c,fr),i.getVertexPosition(l,pr);let h=hd(i,e,t,n,dr,fr,pr,gc);if(h){let d=new B;Dn.getBarycoord(gc,dr,fr,pr,d),s&&(h.uv=Dn.getInterpolatedAttribute(s,o,c,l,d,new Fe)),r&&(h.uv1=Dn.getInterpolatedAttribute(r,o,c,l,d,new Fe)),a&&(h.normal=Dn.getInterpolatedAttribute(a,o,c,l,d,new B),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a:o,b:c,c:l,normal:new B,materialIndex:0};Dn.getNormal(dr,fr,pr,u.normal),h.face=u,h.barycoord=d}return h}var Hr=class extends Ht{constructor(e=null,t=1,n=1,s,r,a,o,c,l=wt,h=wt,d,u){super(null,a,o,c,l,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var pi=new mi,ud=new Fe(.5,.5),xr=new B,Kn=class{constructor(e=new Kt,t=new Kt,n=new Kt,s=new Kt,r=new Kt,a=new Kt){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=on,n=!1){let s=this.planes,r=e.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],d=r[5],u=r[6],m=r[7],_=r[8],y=r[9],p=r[10],f=r[11],S=r[12],A=r[13],b=r[14],T=r[15];if(s[0].setComponents(l-a,m-h,f-_,T-S).normalize(),s[1].setComponents(l+a,m+h,f+_,T+S).normalize(),s[2].setComponents(l+o,m+d,f+y,T+A).normalize(),s[3].setComponents(l-o,m-d,f-y,T-A).normalize(),n)s[4].setComponents(c,u,p,b).normalize(),s[5].setComponents(l-c,m-u,f-p,T-b).normalize();else if(s[4].setComponents(l-c,m-u,f-p,T-b).normalize(),t===on)s[5].setComponents(l+c,m+u,f+p,T+b).normalize();else if(t===Gi)s[5].setComponents(c,u,p,b).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(),pi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),pi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(pi)}intersectsSprite(e){pi.center.set(0,0,0);let t=ud.distanceTo(e.center);return pi.radius=.7071067811865476+t,pi.applyMatrix4(e.matrixWorld),this.intersectsSphere(pi)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(xr.x=s.normal.x>0?e.max.x:e.min.x,xr.y=s.normal.y>0?e.max.y:e.min.y,xr.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(xr)<0)return!1}return!0}containsPoint(e){let 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)}},_c=new ht,Wr=class i{constructor(){this.coordinateSystem=on,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let s=0;s<t.length;s++){let r=t[s];_c.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[s]===void 0&&(n[s]=new Kn),n[s].setFromProjectionMatrix(_c,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let s=0;s<e._count;s++)t[s]===void 0&&(t[s]=new Kn),t[s].copy(n[s]);return this._count=e._count,this}clone(){return new i().copy(this)}};var _i=class extends Bn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ze(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}},Xr=new B,qr=new B,xc=new ht,fs=new gi,yr=new mi,Io=new B,yc=new B,Yr=class extends Ct{constructor(e=new Wt,t=new _i){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),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)Xr.fromBufferAttribute(t,s-1),qr.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=Xr.distanceTo(qr);e.setAttribute("lineDistance",new zt(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),yr.copy(n.boundingSphere),yr.applyMatrix4(s),yr.radius+=r,e.ray.intersectsSphere(yr)===!1)return;xc.copy(s).invert(),fs.copy(e.ray).applyMatrix4(xc);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let m=Math.max(0,a.start),_=Math.min(h.count,a.start+a.count);for(let y=m,p=_-1;y<p;y+=l){let f=h.getX(y),S=h.getX(y+1),A=vr(this,e,fs,c,f,S,y);A&&t.push(A)}if(this.isLineLoop){let y=h.getX(_-1),p=h.getX(m),f=vr(this,e,fs,c,y,p,_-1);f&&t.push(f)}}else{let m=Math.max(0,a.start),_=Math.min(u.count,a.start+a.count);for(let y=m,p=_-1;y<p;y+=l){let f=vr(this,e,fs,c,y,y+1,y);f&&t.push(f)}if(this.isLineLoop){let y=vr(this,e,fs,c,_-1,m,_-1);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function vr(i,e,t,n,s,r,a){let o=i.geometry.attributes.position;if(Xr.fromBufferAttribute(o,s),qr.fromBufferAttribute(o,r),t.distanceSqToSegment(Xr,qr,Io,yc)>n)return;Io.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Io);if(!(l<e.near||l>e.far))return{distance:l,point:yc.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}var vc=new B,Mc=new B,Yi=class extends Yr{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)vc.fromBufferAttribute(t,s),Mc.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+vc.distanceTo(Mc);e.setAttribute("lineDistance",new zt(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var ws=class extends Ht{constructor(e=[],t=Mi,n,s,r,a,o,c,l,h){super(e,t,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var zn=class extends Ht{constructor(e,t,n=fn,s,r,a,o=wt,c=wt,l,h=Fn,d=1){if(h!==Fn&&h!==Vn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,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 Xi(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Ts=class extends zn{constructor(e,t=fn,n=Mi,s,r,a=wt,o=wt,c,l=Fn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,c,l),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},As=class extends Ht{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Zi=class i extends Wt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],d=[],u=0,m=0;_("z","y","x",-1,-1,n,t,e,a,r,0),_("z","y","x",1,-1,n,t,-e,a,r,1),_("x","z","y",1,1,e,n,t,s,a,2),_("x","z","y",1,-1,e,n,-t,s,a,3),_("x","y","z",1,-1,e,t,n,s,r,4),_("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new zt(l,3)),this.setAttribute("normal",new zt(h,3)),this.setAttribute("uv",new zt(d,2));function _(y,p,f,S,A,b,T,E,g,M,U){let I=b/g,D=T/M,F=b/2,H=T/2,C=E/2,Y=g+1,J=M+1,z=0,te=0,W=new B;for(let $=0;$<J;$++){let ae=$*D-H;for(let _e=0;_e<Y;_e++){let De=_e*I-F;W[y]=De*S,W[p]=ae*A,W[f]=C,l.push(W.x,W.y,W.z),W[y]=0,W[p]=0,W[f]=E>0?1:-1,h.push(W.x,W.y,W.z),d.push(_e/g),d.push(1-$/M),z+=1}}for(let $=0;$<M;$++)for(let ae=0;ae<g;ae++){let _e=u+ae+Y*$,De=u+ae+Y*($+1),j=u+(ae+1)+Y*($+1),pe=u+(ae+1)+Y*$;c.push(_e,De,pe),c.push(De,j,pe),te+=6}o.addGroup(m,te,U),m+=te,u+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var Mr=new B,br=new B,Lo=new B,Sr=new Dn,Rs=class extends Wt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let s=Math.pow(10,4),r=Math.cos(zi*t),a=e.getIndex(),o=e.getAttribute("position"),c=a?a.count:o.count,l=[0,0,0],h=["a","b","c"],d=new Array(3),u=new Map,m=[];for(let _=0;_<c;_+=3){a?(l[0]=a.getX(_),l[1]=a.getX(_+1),l[2]=a.getX(_+2)):(l[0]=_,l[1]=_+1,l[2]=_+2);let{a:y,b:p,c:f}=Sr;if(y.fromBufferAttribute(o,l[0]),p.fromBufferAttribute(o,l[1]),f.fromBufferAttribute(o,l[2]),Sr.getNormal(Lo),d[0]=`${Math.round(y.x*s)},${Math.round(y.y*s)},${Math.round(y.z*s)}`,d[1]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,d[2]=`${Math.round(f.x*s)},${Math.round(f.y*s)},${Math.round(f.z*s)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let S=0;S<3;S++){let A=(S+1)%3,b=d[S],T=d[A],E=Sr[h[S]],g=Sr[h[A]],M=`${b}_${T}`,U=`${T}_${b}`,I=u.get(U);I?(Lo.dot(I.normal)<=r&&(m.push(E.x,E.y,E.z),m.push(g.x,g.y,g.z)),u.set(U,null)):u.has(M)||u.set(M,{index0:l[S],index1:l[A],normal:Lo.clone()})}}for(let _ of u.values())if(_){let{index0:y,index1:p}=_;Mr.fromBufferAttribute(o,y),br.fromBufferAttribute(o,p),m.push(Mr.x,Mr.y,Mr.z),m.push(br.x,br.y,br.z)}this.setAttribute("position",new zt(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};var Cs=class i extends Wt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,a=t/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,d=e/o,u=t/c,m=[],_=[],y=[],p=[];for(let f=0;f<h;f++){let S=f*u-a;for(let A=0;A<l;A++){let b=A*d-r;_.push(b,-S,0),y.push(0,0,1),p.push(A/o),p.push(1-f/c)}}for(let f=0;f<c;f++)for(let S=0;S<o;S++){let A=S+l*f,b=S+l*(f+1),T=S+1+l*(f+1),E=S+1+l*f;m.push(A,b,E),m.push(b,T,E)}this.setIndex(m),this.setAttribute("position",new zt(_,3)),this.setAttribute("normal",new zt(y,3)),this.setAttribute("uv",new zt(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}};function Si(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(bc(s))s.isRenderTargetTexture?(Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(bc(s[0])){let r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Ut(i){let e={};for(let t=0;t<i.length;t++){let n=Si(i[t]);for(let s in n)e[s]=n[s]}return e}function bc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function dd(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function gl(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ze.workingColorSpace}var mh={clone:Si,merge:Ut},fd=`void main() {
1
+ "use strict";(()=>{var ju=Object.defineProperty;var Qu=(i,e,t)=>e in i?ju(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var _n=(i,e,t)=>Qu(i,typeof e!="symbol"?e+"":e,t);var pi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},mi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Yc=0,sl=1,Zc=2;var Ys=1,$c=2,us=3,gi=0,Zt=1,pn=2,Ii=0,ds=1,rl=2,ol=3,al=4,Jc=5;var Li=100,Kc=101,jc=102,Qc=103,eh=104,th=200,nh=201,ih=202,sh=203,ll=204,cl=205,rh=206,oh=207,ah=208,lh=209,ch=210,hh=211,uh=212,dh=213,fh=214,Hr=0,Wr=1,Xr=2,ji=3,qr=4,Yr=5,Zr=6,$r=7,wo=0,ph=1,mh=2,Pn=0,hl=1,ul=2,dl=3,fl=4,pl=5,ml=6,Zs=7;var gl=300,Di=301,fs=302,Eo=303,To=304,Jr=1e3,An=1001,Kr=1002,It=1003,gh=1004;var $s=1005;var qt=1006,Ao=1007;var Kn=1008;var jt=1009,_l=1010,xl=1011,ps=1012,Ro=1013,Mn=1014,Sn=1015,wn=1016,Co=1017,Po=1018,Ni=1020,yl=35902,vl=35899,bl=1021,Ml=1022,En=1023,Yn=1026,jn=1027,Sl=1028,Io=1029,_i=1030,Lo=1031;var Do=1033,Js=33776,Ks=33777,js=33778,Qs=33779,No=35840,Uo=35841,Fo=35842,Oo=35843,Bo=36196,zo=37492,ko=37496,Vo=37488,Go=37489,er=37490,Ho=37491,Wo=37808,Xo=37809,qo=37810,Yo=37811,Zo=37812,$o=37813,Jo=37814,Ko=37815,jo=37816,Qo=37817,ea=37818,ta=37819,na=37820,ia=37821,sa=36492,ra=36494,oa=36495,aa=36283,la=36284,tr=36285,ca=36286;var Rs=2300,jr=2301,Vr=2302,Ka=2303,ja=2400,Qa=2401,el=2402;var _h=3200;var ha=0,xh=1,Qn="",rn="srgb",Cs="srgb-linear",Ps="linear",lt="srgb";var Gr=7680;var yh=519,vh=512,bh=513,Mh=514,wl=515,Sh=516,wh=517,El=518,Tl=519,Eh=35044;var Al="300 es",fn=2e3,Qi=2001;function ed(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function td(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Is(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Th(){let i=Is("canvas");return i.style.display="block",i}var yc={},es=null;function Rl(...i){let e="THREE."+i.shift();es?es("log",e,...i):console.log(e,...i)}function Ah(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ue(...i){i=Ah(i);let e="THREE."+i.shift();if(es)es("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function ze(...i){i=Ah(i);let e="THREE."+i.shift();if(es)es("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function Ts(...i){let e=i.join(" ");e in yc||(yc[e]=!0,Ue(...i))}function Rh(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}var Ch={[Hr]:Hr,[Xr]:Zr,[qr]:qr,[ji]:Yr,[Wr]:Wr,[Zr]:Xr,[$r]:$r,[Yr]:ji},bn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let s=n[e];if(s!==void 0){let r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let s=n.slice(0);for(let r=0,o=s.length;r<o;r++)s[r].call(this,e);e.target=null}}},zt=["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"],vc=1234567,Ji=Math.PI/180,ts=180/Math.PI;function ms(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(zt[i&255]+zt[i>>8&255]+zt[i>>16&255]+zt[i>>24&255]+"-"+zt[e&255]+zt[e>>8&255]+"-"+zt[e>>16&15|64]+zt[e>>24&255]+"-"+zt[t&63|128]+zt[t>>8&255]+"-"+zt[t>>16&255]+zt[t>>24&255]+zt[n&255]+zt[n>>8&255]+zt[n>>16&255]+zt[n>>24&255]).toLowerCase()}function Ze(i,e,t){return Math.max(e,Math.min(t,i))}function Cl(i,e){return(i%e+e)%e}function nd(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function id(i,e,t){return i!==e?(t-i)/(e-i):0}function As(i,e,t){return(1-t)*i+t*e}function sd(i,e,t,n){return As(i,e,1-Math.exp(-t*n))}function rd(i,e=1){return e-Math.abs(Cl(i,e*2)-e)}function od(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function ad(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function ld(i,e){return i+Math.floor(Math.random()*(e-i+1))}function cd(i,e){return i+Math.random()*(e-i)}function hd(i){return i*(.5-Math.random())}function ud(i){i!==void 0&&(vc=i);let e=vc+=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 dd(i){return i*Ji}function fd(i){return i*ts}function pd(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function md(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Pl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function gd(i,e,t,n,s){let r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+n)/2),h=o((e+n)/2),d=r((e-n)/2),u=o((e-n)/2),p=r((n-e)/2),_=o((n-e)/2);switch(s){case"XYX":i.set(a*h,c*d,c*u,a*l);break;case"YZY":i.set(c*u,a*h,c*d,a*l);break;case"ZXZ":i.set(c*d,c*u,a*h,a*l);break;case"XZX":i.set(a*h,c*_,c*p,a*l);break;case"YXY":i.set(c*p,a*h,c*_,a*l);break;case"ZYZ":i.set(c*_,c*p,a*h,a*l);break;default:Ue("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function Il(i){switch(i.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function Ph(i,e){if(e.constructor===Float32Array)return i;let t=Il(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.max(i/t,-1)}function Ih(i,e){if(e.constructor===Float32Array)return i;let t=Il(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.round(i*t)}var Ll={DEG2RAD:Ji,RAD2DEG:ts,generateUUID:ms,clamp:Ze,euclideanModulo:Cl,mapLinear:nd,inverseLerp:id,lerp:As,damp:sd,pingpong:rd,smoothstep:od,smootherstep:ad,randInt:ld,randFloat:cd,randFloatSpread:hd,seededRandom:ud,degToRad:dd,radToDeg:fd,isPowerOfTwo:pd,ceilPowerOfTwo:md,floorPowerOfTwo:Pl,setQuaternionFromProperEuler:gd,normalize:Ih,denormalize:Ph},Ol=class Ol{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){let t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[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=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ze(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*s+e.x,this.y=r*s+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ol.prototype.isVector2=!0;var ke=Ol,an=class{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,o,a){let c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[o+0],p=r[o+1],_=r[o+2],x=r[o+3];if(d!==x||c!==u||l!==p||h!==_){let m=c*u+l*p+h*_+d*x;m<0&&(u=-u,p=-p,_=-_,x=-x,m=-m);let f=1-a;if(m<.9995){let w=Math.acos(m),A=Math.sin(w);f=Math.sin(f*w)/A,a=Math.sin(a*w)/A,c=c*f+u*a,l=l*f+p*a,h=h*f+_*a,d=d*f+x*a}else{c=c*f+u*a,l=l*f+p*a,h=h*f+_*a,d=d*f+x*a;let w=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=w,l*=w,h*=w,d*=w}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=d}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[o],u=r[o+1],p=r[o+2],_=r[o+3];return e[t]=a*_+h*d+c*p-l*u,e[t+1]=c*_+h*u+l*d-a*p,e[t+2]=l*_+h*p+a*u-c*d,e[t+3]=h*_-a*d-c*u-l*p,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,s){return this._x=e,this._y=t,this._z=n,this._w=s,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){let n=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),h=a(s/2),d=a(r/2),u=c(n/2),p=c(s/2),_=c(r/2);switch(o){case"XYZ":this._x=u*h*d+l*p*_,this._y=l*p*d-u*h*_,this._z=l*h*_+u*p*d,this._w=l*h*d-u*p*_;break;case"YXZ":this._x=u*h*d+l*p*_,this._y=l*p*d-u*h*_,this._z=l*h*_-u*p*d,this._w=l*h*d+u*p*_;break;case"ZXY":this._x=u*h*d-l*p*_,this._y=l*p*d+u*h*_,this._z=l*h*_+u*p*d,this._w=l*h*d-u*p*_;break;case"ZYX":this._x=u*h*d-l*p*_,this._y=l*p*d+u*h*_,this._z=l*h*_-u*p*d,this._w=l*h*d+u*p*_;break;case"YZX":this._x=u*h*d+l*p*_,this._y=l*p*d+u*h*_,this._z=l*h*_-u*p*d,this._w=l*h*d-u*p*_;break;case"XZY":this._x=u*h*d-l*p*_,this._y=l*p*d-u*h*_,this._z=l*h*_+u*p*d,this._w=l*h*d+u*p*_;break;default:Ue("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],s=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],h=t[6],d=t[10],u=n+a+d;if(u>0){let p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(o-s)*p}else if(n>a&&n>d){let p=2*Math.sqrt(1+n-a-d);this._w=(h-c)/p,this._x=.25*p,this._y=(s+o)/p,this._z=(r+l)/p}else if(a>d){let p=2*Math.sqrt(1+a-n-d);this._w=(r-l)/p,this._x=(s+o)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+d-n-a);this._w=(o-s)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}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(Ze(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let s=Math.min(1,t/n);return this.slerp(e,s),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){let n=e._x,s=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+o*a+s*l-r*c,this._y=s*h+o*c+r*a-n*l,this._z=r*h+o*l+n*c-s*a,this._w=o*h-n*a-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,s=-s,r=-r,o=-o,a=-a);let c=1-t;if(a<.9995){let l=Math.acos(a),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+s*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this._onChangeCallback()}else this._x=this._x*c+n*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*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}},Bl=class Bl{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(bc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(bc.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,s=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*s-a*n),h=2*(a*t-r*s),d=2*(r*n-o*t);return this.x=t+c*l+o*d-a*h,this.y=n+c*h+a*l-r*d,this.z=s+c*d+r*h-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,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=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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){let n=e.x,s=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=s*c-r*a,this.y=r*o-n*c,this.z=n*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Ca.copy(this).projectOnVector(e),this.sub(Ca)}reflect(e){return this.sub(Ca.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Ze(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}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){let s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,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(){let 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}};Bl.prototype.isVector3=!0;var k=Bl,Ca=new k,bc=new an,zl=class zl{constructor(e,t,n,s,r,o,a,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,o,a,c,l)}set(e,t,n,s,r,o,a,c,l){let h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=o,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let 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){let 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){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],p=n[5],_=n[8],x=s[0],m=s[3],f=s[6],w=s[1],A=s[4],S=s[7],M=s[2],E=s[5],g=s[8];return r[0]=o*x+a*w+c*M,r[3]=o*m+a*A+c*E,r[6]=o*f+a*S+c*g,r[1]=l*x+h*w+d*M,r[4]=l*m+h*A+d*E,r[7]=l*f+h*S+d*g,r[2]=u*x+p*w+_*M,r[5]=u*m+p*A+_*E,r[8]=u*f+p*S+_*g,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8];return t*o*h-t*a*l-n*r*h+n*a*c+s*r*l-s*o*c}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],d=h*o-a*l,u=a*c-h*r,p=l*r-o*c,_=t*d+n*u+s*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/_;return e[0]=d*x,e[1]=(s*l-h*n)*x,e[2]=(a*n-s*o)*x,e[3]=u*x,e[4]=(h*t-s*c)*x,e[5]=(s*r-a*t)*x,e[6]=p*x,e[7]=(n*c-l*t)*x,e[8]=(o*t-n*r)*x,this}transpose(){let e,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){let 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,s,r,o,a){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-s*l,s*c,-s*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return Ts("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Pa.makeScale(e,t)),this}rotate(e){return Ts("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Pa.makeRotation(-e)),this}translate(e,t){return Ts("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Pa.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){let 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){let t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])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){let 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)}};zl.prototype.isMatrix3=!0;var Ge=zl,Pa=new Ge,Mc=new Ge().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Sc=new Ge().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function _d(){let i={enabled:!0,workingColorSpace:Cs,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===lt&&(s.r=qn(s.r),s.g=qn(s.g),s.b=qn(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===lt&&(s.r=Ki(s.r),s.g=Ki(s.g),s.b=Ki(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Qn?Ps:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,o){return s.copy(this.spaces[o].fromXYZ).multiply(this.spaces[r].toXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Cs]:{primaries:e,whitePoint:n,transfer:Ps,toXYZ:Mc,fromXYZ:Sc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:rn},outputColorSpaceConfig:{drawingBufferColorSpace:rn}},[rn]:{primaries:e,whitePoint:n,transfer:lt,toXYZ:Mc,fromXYZ:Sc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:rn}}}),i}var Qe=_d();function qn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ki(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Oi,Qr=class{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{Oi===void 0&&(Oi=Is("canvas")),Oi.width=e.width,Oi.height=e.height;let s=Oi.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=Oi}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){let t=Is("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let o=0;o<r.length;o++)r[o]=qn(r[o]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(qn(t[n]/255)*255):t[n]=qn(t[n]);return{data:t,width:e.width,height:e.height}}else return Ue("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},xd=0,ns=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:xd++}),this.uuid=ms(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let 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||0,t.height||0,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let o=0,a=s.length;o<a;o++)s[o].isDataTexture?r.push(Ia(s[o].image)):r.push(Ia(s[o]))}else r=Ia(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function Ia(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Qr.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ue("Texture: Unable to serialize Texture."),{})}var yd=0,La=new k,Jt=class i extends bn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=An,s=An,r=qt,o=Kn,a=En,c=jt,l=i.DEFAULT_ANISOTROPY,h=Qn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:yd++}),this.uuid=ms(),this.name="",this.source=new ns(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new ke(0,0),this.repeat=new ke(1,1),this.center=new ke(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ge,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!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.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(La).x}get height(){return this.source.getSize(La).y}get depth(){return this.source.getSize(La).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.mipmapsAutoUpdate=e.mipmapsAutoUpdate,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.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Ue(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ue(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let 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,mipmapsAutoUpdate:this.mipmapsAutoUpdate,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!==gl)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Jr:e.x=e.x-Math.floor(e.x);break;case An:e.x=e.x<0?0:1;break;case Kr: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 Jr:e.y=e.y-Math.floor(e.y);break;case An:e.y=e.y<0?0:1;break;case Kr: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++}};Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=gl;Jt.DEFAULT_ANISOTROPY=1;var kl=class kl{constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}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,s){return this.x=e,this.y=t,this.z=n,this.w=s,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){let t=this.x,n=this.y,s=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*s+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*s+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*s+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*s+o[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);let 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,s,r,c=e.elements,l=c[0],h=c[4],d=c[8],u=c[1],p=c[5],_=c[9],x=c[2],m=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-x)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+x)<.1&&Math.abs(_+m)<.1&&Math.abs(l+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let A=(l+1)/2,S=(p+1)/2,M=(f+1)/2,E=(h+u)/4,g=(d+x)/4,v=(_+m)/4;return A>S&&A>M?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=E/n,r=g/n):S>M?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=E/s,r=v/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),n=g/r,s=v/r),this.set(n,s,r,t),this}let w=Math.sqrt((m-_)*(m-_)+(d-x)*(d-x)+(u-h)*(u-h));return Math.abs(w)<.001&&(w=1),this.x=(m-_)/w,this.y=(d-x)/w,this.z=(u-h)/w,this.w=Math.acos((l+p+f-1)/2),this}setFromMatrixPosition(e){let 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=Ze(this.x,e.x,t.x),this.y=Ze(this.y,e.y,t.y),this.z=Ze(this.z,e.z,t.z),this.w=Ze(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ze(this.x,e,t),this.y=Ze(this.y,e,t),this.z=Ze(this.z,e,t),this.w=Ze(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ze(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}};kl.prototype.isVector4=!0;var gt=kl,eo=class extends bn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qt,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!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 gt(0,0,e,t),this.scissorTest=!1,this.viewport=new gt(0,0,e,t),this.textures=[];let s=n.count;for(let r=0;r<s;r++)this.textures[r]=new Jt({width:e,height:t,depth:n.depth}),this.textures[r].isRenderTargetTexture=!0,this.textures[r].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:qt,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.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),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===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===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 s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].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;let s=Object.assign({},e.textures[t].image);this.textures[t].source=new ns(s)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null)if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture;else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}},ln=class extends eo{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Ls=class extends Jt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=It,this.minFilter=It,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var to=class extends Jt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=It,this.minFilter=It,this.wrapR=An,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}};var So=class So{constructor(e,t,n,s,r,o,a,c,l,h,d,u,p,_,x,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,s,r,o,a,c,l,h,d,u,p,_,x,m)}set(e,t,n,s,r,o,a,c,l,h,d,u,p,_,x,m){let f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=s,f[1]=r,f[5]=o,f[9]=a,f[13]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=p,f[7]=_,f[11]=x,f[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 So().fromArray(this.elements)}copy(e){let 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){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let 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();let t=this.elements,n=e.elements,s=1/Bi.setFromMatrixColumn(e,0).length(),r=1/Bi.setFromMatrixColumn(e,1).length(),o=1/Bi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,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]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,s=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let u=o*h,p=o*d,_=a*h,x=a*d;t[0]=c*h,t[4]=-c*d,t[8]=l,t[1]=p+_*l,t[5]=u-x*l,t[9]=-a*c,t[2]=x-u*l,t[6]=_+p*l,t[10]=o*c}else if(e.order==="YXZ"){let u=c*h,p=c*d,_=l*h,x=l*d;t[0]=u+x*a,t[4]=_*a-p,t[8]=o*l,t[1]=o*d,t[5]=o*h,t[9]=-a,t[2]=p*a-_,t[6]=x+u*a,t[10]=o*c}else if(e.order==="ZXY"){let u=c*h,p=c*d,_=l*h,x=l*d;t[0]=u-x*a,t[4]=-o*d,t[8]=_+p*a,t[1]=p+_*a,t[5]=o*h,t[9]=x-u*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let u=o*h,p=o*d,_=a*h,x=a*d;t[0]=c*h,t[4]=_*l-p,t[8]=u*l+x,t[1]=c*d,t[5]=x*l+u,t[9]=p*l-_,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let u=o*c,p=o*l,_=a*c,x=a*l;t[0]=c*h,t[4]=x-u*d,t[8]=_*d+p,t[1]=d,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=p*d+_,t[10]=u-x*d}else if(e.order==="XZY"){let u=o*c,p=o*l,_=a*c,x=a*l;t[0]=c*h,t[4]=-d,t[8]=l*h,t[1]=u*d+x,t[5]=o*h,t[9]=p*d-_,t[2]=_*d-p,t[6]=a*h,t[10]=x*d+u}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(vd,e,bd)}lookAt(e,t,n){let s=this.elements;return nn.subVectors(e,t),nn.lengthSq()===0&&(nn.z=1),nn.normalize(),si.crossVectors(n,nn),si.lengthSq()===0&&(Math.abs(n.z)===1?nn.x+=1e-4:nn.z+=1e-4,nn.normalize(),si.crossVectors(n,nn)),si.normalize(),gr.crossVectors(nn,si),s[0]=si.x,s[4]=gr.x,s[8]=nn.x,s[1]=si.y,s[5]=gr.y,s[9]=nn.y,s[2]=si.z,s[6]=gr.z,s[10]=nn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,s=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],p=n[13],_=n[2],x=n[6],m=n[10],f=n[14],w=n[3],A=n[7],S=n[11],M=n[15],E=s[0],g=s[4],v=s[8],N=s[12],R=s[1],D=s[5],U=s[9],z=s[13],I=s[2],q=s[6],Z=s[10],B=s[14],ee=s[3],C=s[7],W=s[11],K=s[15];return r[0]=o*E+a*R+c*I+l*ee,r[4]=o*g+a*D+c*q+l*C,r[8]=o*v+a*U+c*Z+l*W,r[12]=o*N+a*z+c*B+l*K,r[1]=h*E+d*R+u*I+p*ee,r[5]=h*g+d*D+u*q+p*C,r[9]=h*v+d*U+u*Z+p*W,r[13]=h*N+d*z+u*B+p*K,r[2]=_*E+x*R+m*I+f*ee,r[6]=_*g+x*D+m*q+f*C,r[10]=_*v+x*U+m*Z+f*W,r[14]=_*N+x*z+m*B+f*K,r[3]=w*E+A*R+S*I+M*ee,r[7]=w*g+A*D+S*q+M*C,r[11]=w*v+A*U+S*Z+M*W,r[15]=w*N+A*z+S*B+M*K,this}multiplyScalar(e){let 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(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],h=e[2],d=e[6],u=e[10],p=e[14],_=e[3],x=e[7],m=e[11],f=e[15],w=c*p-l*u,A=a*p-l*d,S=a*u-c*d,M=o*p-l*h,E=o*u-c*h,g=o*d-a*h;return t*(x*w-m*A+f*S)-n*(_*w-m*M+f*E)+s*(_*A-x*M+f*g)-r*(_*S-x*E+m*g)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],o=e[5],a=e[9],c=e[2],l=e[6],h=e[10];return t*(o*h-a*l)-n*(r*h-a*c)+s*(r*l-o*c)}transpose(){let e=this.elements,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){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],d=e[9],u=e[10],p=e[11],_=e[12],x=e[13],m=e[14],f=e[15],w=t*a-n*o,A=t*c-s*o,S=t*l-r*o,M=n*c-s*a,E=n*l-r*a,g=s*l-r*c,v=h*x-d*_,N=h*m-u*_,R=h*f-p*_,D=d*m-u*x,U=d*f-p*x,z=u*f-p*m,I=w*z-A*U+S*D+M*R-E*N+g*v;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let q=1/I;return e[0]=(a*z-c*U+l*D)*q,e[1]=(s*U-n*z-r*D)*q,e[2]=(x*g-m*E+f*M)*q,e[3]=(u*E-d*g-p*M)*q,e[4]=(c*R-o*z-l*N)*q,e[5]=(t*z-s*R+r*N)*q,e[6]=(m*S-_*g-f*A)*q,e[7]=(h*g-u*S+p*A)*q,e[8]=(o*U-a*R+l*v)*q,e[9]=(n*R-t*U-r*v)*q,e[10]=(_*E-x*S+f*w)*q,e[11]=(d*S-h*E-p*w)*q,e[12]=(a*N-o*D-c*v)*q,e[13]=(t*D-n*N+s*v)*q,e[14]=(x*A-_*M-m*w)*q,e[15]=(h*M-d*A+u*w)*q,this}scale(e){let t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let 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],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}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){let 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){let 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){let 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){let n=Math.cos(t),s=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,h=r*a;return this.set(l*o+n,l*a-s*c,l*c+s*a,0,l*a+s*c,h*a+n,h*c-s*o,0,l*c-s*a,h*c+s*o,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,s,r,o){return this.set(1,n,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){let s=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,h=o+o,d=a+a,u=r*l,p=r*h,_=r*d,x=o*h,m=o*d,f=a*d,w=c*l,A=c*h,S=c*d,M=n.x,E=n.y,g=n.z;return s[0]=(1-(x+f))*M,s[1]=(p+S)*M,s[2]=(_-A)*M,s[3]=0,s[4]=(p-S)*E,s[5]=(1-(u+f))*E,s[6]=(m+w)*E,s[7]=0,s[8]=(_+A)*g,s[9]=(m-w)*g,s[10]=(1-(u+x))*g,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let o=Bi.set(s[0],s[1],s[2]).length(),a=Bi.set(s[4],s[5],s[6]).length(),c=Bi.set(s[8],s[9],s[10]).length();r<0&&(o=-o),xn.copy(this);let l=1/o,h=1/a,d=1/c;return xn.elements[0]*=l,xn.elements[1]*=l,xn.elements[2]*=l,xn.elements[4]*=h,xn.elements[5]*=h,xn.elements[6]*=h,xn.elements[8]*=d,xn.elements[9]*=d,xn.elements[10]*=d,t.setFromRotationMatrix(xn),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,s,r,o,a=fn,c=!1){let l=this.elements,h=2*r/(t-e),d=2*r/(n-s),u=(t+e)/(t-e),p=(n+s)/(n-s),_,x;if(c)_=r/(o-r),x=o*r/(o-r);else if(a===fn)_=-(o+r)/(o-r),x=-2*o*r/(o-r);else if(a===Qi)_=-o/(o-r),x=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=d,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=_,l[14]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,s,r,o,a=fn,c=!1){let l=this.elements,h=2/(t-e),d=2/(n-s),u=-(t+e)/(t-e),p=-(n+s)/(n-s),_,x;if(c)_=1/(o-r),x=o/(o-r);else if(a===fn)_=-2/(o-r),x=-(o+r)/(o-r);else if(a===Qi)_=-1/(o-r),x=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=d,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=_,l[14]=x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])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){let 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}};So.prototype.isMatrix4=!0;var ft=So,Bi=new k,xn=new ft,vd=new k(0,0,0),bd=new k(1,1,1),si=new k,gr=new k,nn=new k,wc=new ft,Ec=new an,Zn=class i{constructor(e=0,t=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}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,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,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){let s=e.elements,r=s[0],o=s[4],a=s[8],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],p=s[10];switch(t){case"XYZ":this._y=Math.asin(Ze(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ze(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ze(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Ze(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Ze(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Ze(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Ue("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return wc.makeRotationFromQuaternion(e),this.setFromRotationMatrix(wc,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ec.setFromEuler(this),this.setFromQuaternion(Ec,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}};Zn.DEFAULT_ORDER="XYZ";var Ds=class{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}},Md=0,Tc=new k,zi=new an,kn=new ft,_r=new k,bs=new k,Sd=new k,wd=new an,Ac=new k(1,0,0),Rc=new k(0,1,0),Cc=new k(0,0,1),Pc={type:"added"},Ed={type:"removed"},ki={type:"childadded",child:null},Da={type:"childremoved",child:null},Ut=class i extends bn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Md++}),this.uuid=ms(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new k,t=new Zn,n=new an,s=new k(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),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:s},modelViewMatrix:{value:new ft},normalMatrix:{value:new Ge}}),this.matrix=new ft,this.matrixWorld=new ft,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ds,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),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}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 zi.setFromAxisAngle(e,t),this.quaternion.multiply(zi),this}rotateOnWorldAxis(e,t){return zi.setFromAxisAngle(e,t),this.quaternion.premultiply(zi),this}rotateX(e){return this.rotateOnAxis(Ac,e)}rotateY(e){return this.rotateOnAxis(Rc,e)}rotateZ(e){return this.rotateOnAxis(Cc,e)}translateOnAxis(e,t){return Tc.copy(e).applyQuaternion(this.quaternion),this.position.add(Tc.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ac,e)}translateY(e){return this.translateOnAxis(Rc,e)}translateZ(e){return this.translateOnAxis(Cc,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?_r.copy(e):_r.set(e,t,n);let s=this.parent;this.updateWorldMatrix(!0,!1),bs.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kn.lookAt(bs,_r,this.up):kn.lookAt(_r,bs,this.up),this.quaternion.setFromRotationMatrix(kn),s&&(kn.extractRotation(s.matrixWorld),zi.setFromRotationMatrix(kn),this.quaternion.premultiply(zi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(ze("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(Pc),ki.child=e,this.dispatchEvent(ki),ki.child=null):ze("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}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ed),Da.child=e,this.dispatchEvent(Da),Da.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),kn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),kn.multiply(e.parent.matrixWorld)),e.applyMatrix4(kn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pc),ki.child=e,this.dispatchEvent(ki),ki.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,s=this.children.length;n<s;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let s=this.children;for(let r=0,o=s.length;r<o;r++)s[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(bs,e,Sd),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bs,wd,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}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);let t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let s=this.parent;if(e===!0&&s!==null&&s.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){let r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0,n)}}toJSON(e){let 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"});let s={};s.uuid=this.uuid,s.type=this.type,s.name=this.name,s.castShadow=this.castShadow,s.receiveShadow=this.receiveShadow,s.visible=this.visible,s.frustumCulled=this.frustumCulled,s.renderOrder=this.renderOrder,s.static=this.static,s.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(a=>({...a})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let d=c[l];r(e.shapes,d)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));s.material=a}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let a=0;a<this.children.length;a++)s.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];s.animations.push(r(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),h=o(e.images),d=o(e.shapes),u=o(e.skeletons),p=o(e.animations),_=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),_.length>0&&(n.nodes=_)}return n.object=s,n;function o(a){let c=[];for(let l in a){let h=a[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++){let s=e.children[n];this.add(s.clone())}return this}dispose(){this.dispatchEvent({type:"dispose"})}};Ut.DEFAULT_UP=new k(0,1,0);Ut.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ut.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Rn=class extends Ut{constructor(){super(),this.isGroup=!0,this.type="Group"}},Td={type:"move"},is=class{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 k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),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 k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k,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){let t=this._hand;if(t)for(let 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 s=null,r=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let x of e.hand.values()){let m=t.getJointPose(x,n),f=this._getHandJoint(l,x);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.quaternion,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),p=.02,_=.005;l.inputState.pinching&&u>p+_?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=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.quaternion,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})));a!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Td)))}return a!==null&&(a.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Rn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Lh={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},ri={h:0,s:0,l:0},xr={h:0,s:0,l:0};function Na(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var We=class{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){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=rn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Qe.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Qe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qe.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Qe.workingColorSpace){if(e=Cl(e,1),t=Ze(t,0,1),n=Ze(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=Na(o,r,e+1/3),this.g=Na(o,r,e),this.b=Na(o,r,e-1/3)}return Qe.colorSpaceToWorking(this,s),this}setStyle(e,t=rn){function n(r){r!==void 0&&parseFloat(r)<1&&Ue("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))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+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseFloat(r[1]))/100,Math.min(100,parseFloat(r[2]))/100,Math.min(100,parseFloat(r[3]))/100,t);break;case"hsl":case"hsla":if(r=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ue("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);Ue("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=rn){let n=Lh[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ue("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=qn(e.r),this.g=qn(e.g),this.b=qn(e.b),this}copyLinearToSRGB(e){return this.r=Ki(e.r),this.g=Ki(e.g),this.b=Ki(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=rn){return Qe.workingToColorSpace(kt.copy(this),e),Math.round(Ze(kt.r*255,0,255))*65536+Math.round(Ze(kt.g*255,0,255))*256+Math.round(Ze(kt.b*255,0,255))}getHexString(e=rn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qe.workingColorSpace){Qe.workingToColorSpace(kt.copy(this),t);let n=kt.r,s=kt.g,r=kt.b,o=Math.max(n,s,r),a=Math.min(n,s,r),c,l,h=(a+o)/2;if(a===o)c=0,l=0;else{let d=o-a;switch(l=h<=.5?d/(o+a):d/(2-o-a),o){case n:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-n)/d+2;break;case r:c=(n-s)/d+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=Qe.workingColorSpace){return Qe.workingToColorSpace(kt.copy(this),t),e.r=kt.r,e.g=kt.g,e.b=kt.b,e}getStyle(e=rn){Qe.workingToColorSpace(kt.copy(this),e);let t=kt.r,n=kt.g,s=kt.b;return e!==rn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(ri),this.setHSL(ri.h+e,ri.s+t,ri.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(ri),e.getHSL(xr);let n=As(ri.h,xr.h,t),s=As(ri.s,xr.s,t),r=As(ri.l,xr.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,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}},kt=new We;We.NAMES=Lh;var Ns=class extends Ut{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 Zn,this.environmentIntensity=1,this.environmentRotation=new Zn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background!==null?e.background.clone():null,this.environment=e.environment!==null?e.environment.clone():null,this.fog=e.fog!==null?e.fog.clone():null,this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial!==null?e.overrideMaterial.clone():null,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},yn=new k,Vn=new k,Ua=new k,Gn=new k,Vi=new k,Gi=new k,Ic=new k,Fa=new k,Oa=new k,Ba=new k,za=new gt,ka=new gt,Va=new gt,Xn=class i{constructor(e=new k,t=new k,n=new k){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),yn.subVectors(e,t),s.cross(yn);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){yn.subVectors(s,t),Vn.subVectors(n,t),Ua.subVectors(e,t);let o=yn.dot(yn),a=yn.dot(Vn),c=yn.dot(Ua),l=Vn.dot(Vn),h=Vn.dot(Ua),d=o*l-a*a;if(d===0)return r.set(0,0,0),null;let u=1/d,p=(l*c-a*h)*u,_=(o*h-a*c)*u;return r.set(1-p-_,_,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Gn)===null?!1:Gn.x>=0&&Gn.y>=0&&Gn.x+Gn.y<=1}static getInterpolation(e,t,n,s,r,o,a,c){return this.getBarycoord(e,t,n,s,Gn)===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,Gn.x),c.addScaledVector(o,Gn.y),c.addScaledVector(a,Gn.z),c)}static getInterpolatedAttribute(e,t,n,s,r,o){return za.setScalar(0),ka.setScalar(0),Va.setScalar(0),za.fromBufferAttribute(e,t),ka.fromBufferAttribute(e,n),Va.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(za,r.x),o.addScaledVector(ka,r.y),o.addScaledVector(Va,r.z),o}static isFrontFacing(e,t,n,s){return yn.subVectors(n,t),Vn.subVectors(e,t),yn.cross(Vn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),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 yn.subVectors(this.c,this.b),Vn.subVectors(this.a,this.b),yn.cross(Vn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return i.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,s=this.b,r=this.c,o,a;Vi.subVectors(s,n),Gi.subVectors(r,n),Fa.subVectors(e,n);let c=Vi.dot(Fa),l=Gi.dot(Fa);if(c<=0&&l<=0)return t.copy(n);Oa.subVectors(e,s);let h=Vi.dot(Oa),d=Gi.dot(Oa);if(h>=0&&d<=h)return t.copy(s);let u=c*d-h*l;if(u<=0&&c>=0&&h<=0&&c-h>0)return o=c/(c-h),t.copy(n).addScaledVector(Vi,o);Ba.subVectors(e,r);let p=Vi.dot(Ba),_=Gi.dot(Ba);if(_>=0&&p<=_)return t.copy(r);let x=p*l-c*_;if(x<=0&&l>=0&&_<=0)return a=l/(l-_),t.copy(n).addScaledVector(Gi,a);let m=h*_-p*d;if(m<=0&&d-h>=0&&p-_>=0)return Ic.subVectors(r,s),a=(d-h)/(d-h+(p-_)),t.copy(s).addScaledVector(Ic,a);let f=1/(m+x+u);return o=x*f,a=u*f,t.copy(n).addScaledVector(Vi,o).addScaledVector(Gi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ci=class{constructor(e=new k(1/0,1/0,1/0),t=new k(-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(vn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(vn.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){let n=vn.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);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,vn):vn.fromBufferAttribute(r,o),vn.applyMatrix4(e.matrixWorld),this.expandByPoint(vn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),yr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),yr.copy(n.boundingBox)),yr.applyMatrix4(e.matrixWorld),this.union(yr)}let s=e.children;for(let r=0,o=s.length;r<o;r++)this.expandByObject(s[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,vn),vn.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(Ms),vr.subVectors(this.max,Ms),Hi.subVectors(e.a,Ms),Wi.subVectors(e.b,Ms),Xi.subVectors(e.c,Ms),oi.subVectors(Wi,Hi),ai.subVectors(Xi,Wi),Si.subVectors(Hi,Xi);let t=[0,-oi.z,oi.y,0,-ai.z,ai.y,0,-Si.z,Si.y,oi.z,0,-oi.x,ai.z,0,-ai.x,Si.z,0,-Si.x,-oi.y,oi.x,0,-ai.y,ai.x,0,-Si.y,Si.x,0];return!Ga(t,Hi,Wi,Xi,vr)||(t=[1,0,0,0,1,0,0,0,1],!Ga(t,Hi,Wi,Xi,vr))?!1:(br.crossVectors(oi,ai),t=[br.x,br.y,br.z],Ga(t,Hi,Wi,Xi,vr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vn).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:(Hn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Hn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Hn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Hn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Hn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Hn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Hn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Hn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Hn),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}},Hn=[new k,new k,new k,new k,new k,new k,new k,new k],vn=new k,yr=new ci,Hi=new k,Wi=new k,Xi=new k,oi=new k,ai=new k,Si=new k,Ms=new k,vr=new k,br=new k,wi=new k;function Ga(i,e,t,n,s){for(let r=0,o=i.length-3;r<=o;r+=3){wi.fromArray(i,r);let a=s.x*Math.abs(wi.x)+s.y*Math.abs(wi.y)+s.z*Math.abs(wi.z),c=e.dot(wi),l=t.dot(wi),h=n.dot(wi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}var St=new k,Mr=new ke,Ad=0,Vt=class extends bn{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:Ad++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Eh,this.updateRanges=[],this.gpuType=Sn,this.version=0,this._normalizationScale=e!==void 0?Il(e):void 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._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];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++)Mr.fromBufferAttribute(this,t),Mr.applyMatrix3(e),this.setXY(t,Mr.x,Mr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.applyMatrix3(e),this.setXYZ(t,St.x,St.y,St.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.applyMatrix4(e),this.setXYZ(t,St.x,St.y,St.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.applyNormalMatrix(e),this.setXYZ(t,St.x,St.y,St.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)St.fromBufferAttribute(this,t),St.transformDirection(e),this.setXYZ(t,St.x,St.y,St.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=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),s=this._normalize(s),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,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(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:"dispose"})}_denormalize(e){let t=this._normalizationScale;return t!==void 0?Math.max(e/t,-1):Ph(e,this.array)}_normalize(e){let t=this._normalizationScale;return t!==void 0?Math.round(e*t):Ih(e,this.array)}};var Us=class extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Fs=class extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Xt=class extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}},Rd=new ci,Ss=new k,Ha=new k,Ai=class{constructor(e=new k,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){let n=this.center;t!==void 0?n.copy(t):Rd.setFromPoints(e).getCenter(n);let s=0;for(let r=0,o=e.length;r<o;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),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){let 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){let 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;Ss.subVectors(e,this.center);let t=Ss.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Ss,s/n),this.radius+=s}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):(Ha.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ss.copy(e.center).add(Ha)),this.expandByPoint(Ss.copy(e.center).sub(Ha))),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}},Cd=0,dn=new ft,Wa=new Ut,qi=new k,sn=new ci,ws=new ci,Pt=new k,Yt=class i extends bn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Cd++}),this.uuid=ms(),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(ed(e)?Fs:Us)(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){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ge().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return dn.makeRotationFromQuaternion(e),this.applyMatrix4(dn),this}rotateX(e){return dn.makeRotationX(e),this.applyMatrix4(dn),this}rotateY(e){return dn.makeRotationY(e),this.applyMatrix4(dn),this}rotateZ(e){return dn.makeRotationZ(e),this.applyMatrix4(dn),this}translate(e,t,n){return dn.makeTranslation(e,t,n),this.applyMatrix4(dn),this}scale(e,t,n){return dn.makeScale(e,t,n),this.applyMatrix4(dn),this}lookAt(e){return Wa.lookAt(e),Wa.updateMatrix(),this.applyMatrix4(Wa.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qi).negate(),this.translate(qi.x,qi.y,qi.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let s=0,r=e.length;s<r;s++){let o=e[s];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Xt(n,3))}else{let n=Math.min(e.length,t.count);for(let s=0;s<n;s++){let r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&Ue("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 ci);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new k(-1/0,-1/0,-1/0),new k(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){let r=t[n];sn.setFromBufferAttribute(r),this.morphTargetsRelative?(Pt.addVectors(this.boundingBox.min,sn.min),this.boundingBox.expandByPoint(Pt),Pt.addVectors(this.boundingBox.max,sn.max),this.boundingBox.expandByPoint(Pt)):(this.boundingBox.expandByPoint(sn.min),this.boundingBox.expandByPoint(sn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ze('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 Ai);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ze("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){let n=this.boundingSphere.center;if(sn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];ws.setFromBufferAttribute(a),this.morphTargetsRelative?(Pt.addVectors(sn.min,ws.min),sn.expandByPoint(Pt),Pt.addVectors(sn.max,ws.max),sn.expandByPoint(Pt)):(sn.expandByPoint(ws.min),sn.expandByPoint(ws.max))}sn.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)Pt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Pt));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)Pt.fromBufferAttribute(a,l),c&&(qi.fromBufferAttribute(e,l),Pt.add(qi)),s=Math.max(s,n.distanceToSquared(Pt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&ze('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){ze("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,s=t.normal,r=t.uv,o=this.getAttribute("tangent");(o===void 0||o.count!==n.count)&&(o=new Vt(new Float32Array(4*n.count),4),this.setAttribute("tangent",o));let a=[],c=[],l=new Uint8Array(n.count);for(let N=0;N<n.count;N++)a[N]=new k,c[N]=new k;let h=new k,d=new k,u=new k,p=new ke,_=new ke,x=new ke,m=new k,f=new k;function w(N,R,D){l[N]=l[R]=l[D]=1,h.fromBufferAttribute(n,N),d.fromBufferAttribute(n,R),u.fromBufferAttribute(n,D),p.fromBufferAttribute(r,N),_.fromBufferAttribute(r,R),x.fromBufferAttribute(r,D),d.sub(h),u.sub(h),_.sub(p),x.sub(p);let U=1/(_.x*x.y-x.x*_.y);isFinite(U)&&(m.copy(d).multiplyScalar(x.y).addScaledVector(u,-_.y).multiplyScalar(U),f.copy(u).multiplyScalar(_.x).addScaledVector(d,-x.x).multiplyScalar(U),a[N].add(m),a[R].add(m),a[D].add(m),c[N].add(f),c[R].add(f),c[D].add(f))}let A=this.groups;A.length===0&&(A=[{start:0,count:e.count}]);for(let N=0,R=A.length;N<R;++N){let D=A[N],U=D.start,z=D.count;for(let I=U,q=U+z;I<q;I+=3)w(e.getX(I+0),e.getX(I+1),e.getX(I+2))}let S=new k,M=new k,E=new k,g=new k;function v(N){E.fromBufferAttribute(s,N),g.copy(E);let R=a[N];S.copy(R),S.sub(E.multiplyScalar(E.dot(R))).normalize(),M.crossVectors(g,R);let U=M.dot(c[N])<0?-1:1;o.setXYZW(N,S.x,S.y,S.z,U)}for(let N=0,R=n.count;N<R;++N)l[N]&&v(N);this._transformed=!0}computeVertexNormals(){let 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 Vt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let u=0,p=n.count;u<p;u++)n.setXYZ(u,0,0,0);let s=new k,r=new k,o=new k,a=new k,c=new k,l=new k,h=new k,d=new k;if(e)for(let u=0,p=e.count;u<p;u+=3){let _=e.getX(u+0),x=e.getX(u+1),m=e.getX(u+2);s.fromBufferAttribute(t,_),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,m),h.subVectors(o,r),d.subVectors(s,r),h.cross(d),a.fromBufferAttribute(n,_),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),a.add(h),c.add(h),l.add(h),n.setXYZ(_,a.x,a.y,a.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let u=0,p=t.count;u<p;u+=3)s.fromBufferAttribute(t,u+0),r.fromBufferAttribute(t,u+1),o.fromBufferAttribute(t,u+2),h.subVectors(o,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Pt.fromBufferAttribute(e,t),Pt.normalize(),e.setXYZ(t,Pt.x,Pt.y,Pt.z)}toNonIndexed(){function e(a,c){let l=a.array,h=a.itemSize,d=a.normalized,u=new l.constructor(c.length*h),p=0,_=0;for(let x=0,m=c.length;x<m;x++){a.isInterleavedBufferAttribute?p=c[x]*a.data.stride+a.offset:p=c[x]*h;for(let f=0;f<h;f++)u[_++]=l[p++]}return new Vt(u,h,d)}if(this.index===null)return Ue("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,s=this.attributes;for(let a in s){let c=s[a],l=e(c,n);t.setAttribute(a,l)}let r=this.morphAttributes;for(let a in r){let c=[],l=r[a];for(let h=0,d=l.length;h<d;h++){let u=l[h],p=e(u,n);c.push(p)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let 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,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d<u;d++){let p=l[d];h.push(p.toJSON(e.data))}h.length>0&&(s[c]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let s=e.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(t))}let r=e.morphAttributes;for(let l in r){let h=[],d=r[l];for(let u=0,p=d.length;u<p;u++)h.push(d[u].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,h=o.length;l<h;l++){let d=o[l];this.addGroup(d.start,d.count,d.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let 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"})}};var Xa=new k,Pd=new k,Id=new Ge,on=class{constructor(e=new k(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,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let s=Xa.subVectors(n,t).cross(Pd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let 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){let s=e.delta(Xa),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let o=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(o<0||o>1)?null:t.copy(e.start).addScaledVector(s,o)}intersectsLine(e){let 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){let n=t||Id.getNormalMatrix(e),s=this.coplanarPoint(Xa).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.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)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},Ld=0,$n=class extends bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ld++}),this.uuid=ms(),this.name="",this.type="Material",this.blending=ds,this.side=gi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ll,this.blendDst=cl,this.blendEquation=Li,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new We(0,0,0),this.blendAlpha=0,this.depthFunc=ji,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gr,this.stencilZFail=Gr,this.stencilZPass=Gr,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(let t in e){let n=e[t];if(n===void 0){Ue(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Ue(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,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&&(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.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),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.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),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&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(r=>r.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),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.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let o=[];for(let a in r){let c=r[a];delete c.metadata,o.push(c)}return o}if(t){let r=s(e.textures),o=s(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}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 We().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.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),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.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new on().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),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.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),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 ke().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 ke().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),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;let t=e.clippingPlanes,n=null;if(t!==null){let s=t.length;n=new Array(s);for(let r=0;r!==s;++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++}};var Wn=new k,qa=new k,Sr=new k,wr=new k,Ri=class{constructor(e=new k,t=new k(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,Wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let 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){let t=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){qa.copy(e).add(t).multiplyScalar(.5),Sr.copy(t).sub(e).normalize(),wr.copy(this.origin).sub(qa);let r=e.distanceTo(t)*.5,o=-this.direction.dot(Sr),a=wr.dot(this.direction),c=-wr.dot(Sr),l=wr.lengthSq(),h=Math.abs(1-o*o),d,u,p,_;if(h>0)if(d=o*c-a,u=o*a-c,_=r*h,d>=0)if(u>=-_)if(u<=_){let x=1/h;d*=x,u*=x,p=d*(d+o*u+2*a)+u*(o*d+u+2*c)+l}else u=r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*c)+l;else u<=-_?(d=Math.max(0,-(-o*r+a)),u=d>0?-r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l):u<=_?(d=0,u=Math.min(Math.max(-r,-c),r),p=u*(u+2*c)+l):(d=Math.max(0,-(o*r+a)),u=d>0?r:Math.min(Math.max(-r,-c),r),p=-d*d+u*(u+2*c)+l);else u=o>0?-r:r,d=Math.max(0,-(o*u+a)),p=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qa).addScaledVector(Sr,u),p}intersectSphere(e,t){if(e.radius<0)return null;Wn.subVectors(e.center,this.origin);let n=Wn.dot(this.direction),s=Wn.dot(Wn)-n*n,r=e.radius*e.radius;if(s>r)return null;let o=Math.sqrt(r-s),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,o,a,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,s=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,s=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),d>=0?(a=(e.min.z-u.z)*d,c=(e.max.z-u.z)*d):(a=(e.max.z-u.z)*d,c=(e.min.z-u.z)*d),n>c||a>s)||((a>n||n!==n)&&(n=a),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,n,s,r){let o=this.origin,a=this.direction,c=a.x,l=a.y,h=a.z,d=e.x-o.x,u=e.y-o.y,p=e.z-o.z,_=t.x-o.x,x=t.y-o.y,m=t.z-o.z,f=n.x-o.x,w=n.y-o.y,A=n.z-o.z,S=Math.abs(c),M=Math.abs(l),E=Math.abs(h),g,v,N,R,D,U,z,I,q,Z,B,ee;if(S>=M&&S>=E?(N=c,U=d,q=_,ee=f,c>=0?(g=l,v=h,R=u,D=p,z=x,I=m,Z=w,B=A):(g=h,v=l,R=p,D=u,z=m,I=x,Z=A,B=w)):M>=E?(N=l,U=u,q=x,ee=w,l>=0?(g=h,v=c,R=p,D=d,z=m,I=_,Z=A,B=f):(g=c,v=h,R=d,D=p,z=_,I=m,Z=f,B=A)):(N=h,U=p,q=m,ee=A,h>=0?(g=c,v=l,R=d,D=u,z=_,I=x,Z=f,B=w):(g=l,v=c,R=u,D=d,z=x,I=_,Z=w,B=f)),N===0)return null;let C=g/N,W=v/N,K=1/N,ve=R-C*U,we=D-W*U,G=z-C*q,he=I-W*q,fe=Z-C*ee,Ee=B-W*ee,le=fe*he-Ee*G,ye=ve*Ee-we*fe,Ve=G*we-he*ve;if(s){if(le<0||ye<0||Ve<0)return null}else if((le<0||ye<0||Ve<0)&&(le>0||ye>0||Ve>0))return null;let Me=le+ye+Ve;if(Me===0)return null;let Fe=K*(le*U+ye*q+Ve*ee);return(Me>0?Fe<0:Fe>0)?null:this.at(Fe/Me,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)}},ss=class extends $n{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new We(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 Zn,this.combine=wo,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}},Lc=new ft,Ei=new Ri,Er=new Ai,Dc=new k,Tr=new k,Ar=new k,Rr=new k,Ya=new k,Cr=new k,Nc=new k,Pr=new k,Kt=class extends Ut{constructor(e=new Yt,t=new ss){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():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(s,e);let a=this.morphTargetInfluences;if(r&&a){Cr.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=a[c],d=r[c];h!==0&&(Ya.fromBufferAttribute(d,e),o?Cr.addScaledVector(Ya,h):Cr.addScaledVector(Ya.sub(t),h))}t.add(Cr)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Er.copy(n.boundingSphere),Er.applyMatrix4(r),Ei.copy(e.ray).recast(e.near),!(Er.containsPoint(Ei.origin)===!1&&(Ei.intersectSphere(Er,Dc)===null||Ei.origin.distanceToSquared(Dc)>(e.far-e.near)**2))&&(Lc.copy(r).invert(),Ei.copy(e.ray).applyMatrix4(Lc),!(n.boundingBox!==null&&Ei.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ei)))}_computeIntersections(e,t,n){let s,r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,x=u.length;_<x;_++){let m=u[_],f=o[m.materialIndex],w=Math.max(m.start,p.start),A=Math.min(a.count,Math.min(m.start+m.count,p.start+p.count));for(let S=w,M=A;S<M;S+=3){let E=a.getX(S),g=a.getX(S+1),v=a.getX(S+2);s=Ir(this,f,e,n,l,h,d,E,g,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let _=Math.max(0,p.start),x=Math.min(a.count,p.start+p.count);for(let m=_,f=x;m<f;m+=3){let w=a.getX(m),A=a.getX(m+1),S=a.getX(m+2);s=Ir(this,o,e,n,l,h,d,w,A,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(o))for(let _=0,x=u.length;_<x;_++){let m=u[_],f=o[m.materialIndex],w=Math.max(m.start,p.start),A=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let S=w,M=A;S<M;S+=3){let E=S,g=S+1,v=S+2;s=Ir(this,f,e,n,l,h,d,E,g,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let _=Math.max(0,p.start),x=Math.min(c.count,p.start+p.count);for(let m=_,f=x;m<f;m+=3){let w=m,A=m+1,S=m+2;s=Ir(this,o,e,n,l,h,d,w,A,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}};function Dd(i,e,t,n,s,r,o,a){let c;if(e.side===Zt?c=n.intersectTriangle(o,r,s,!0,a):c=n.intersectTriangle(s,r,o,e.side===gi,a),c===null)return null;Pr.copy(a),Pr.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(Pr);return l<t.near||l>t.far?null:{distance:l,point:Pr.clone(),object:i}}function Ir(i,e,t,n,s,r,o,a,c,l){i.getVertexPosition(a,Tr),i.getVertexPosition(c,Ar),i.getVertexPosition(l,Rr);let h=Dd(i,e,t,n,Tr,Ar,Rr,Nc);if(h){let d=new k;Xn.getBarycoord(Nc,Tr,Ar,Rr,d),s&&(h.uv=Xn.getInterpolatedAttribute(s,a,c,l,d,new ke)),r&&(h.uv1=Xn.getInterpolatedAttribute(r,a,c,l,d,new ke)),o&&(h.normal=Xn.getInterpolatedAttribute(o,a,c,l,d,new k),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a,b:c,c:l,normal:new k,materialIndex:0};Xn.getNormal(Tr,Ar,Rr,u.normal),h.face=u,h.barycoord=d}return h}var no=class extends Jt{constructor(e=null,t=1,n=1,s,r,o,a,c,l=It,h=It,d,u){super(null,o,a,c,l,h,s,r,d,u),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Ti=new Ai,Nd=new ke(.5,.5),Lr=new k,hi=class{constructor(e=new on,t=new on,n=new on,s=new on,r=new on,o=new on){this.planes=[e,t,n,s,r,o]}set(e,t,n,s,r,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(s),a[4].copy(r),a[5].copy(o),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=fn,n=!1){let s=this.planes,r=e.elements,o=r[0],a=r[1],c=r[2],l=r[3],h=r[4],d=r[5],u=r[6],p=r[7],_=r[8],x=r[9],m=r[10],f=r[11],w=r[12],A=r[13],S=r[14],M=r[15];if(s[0].setComponents(l-o,p-h,f-_,M-w).normalize(),s[1].setComponents(l+o,p+h,f+_,M+w).normalize(),s[2].setComponents(l+a,p+d,f+x,M+A).normalize(),s[3].setComponents(l-a,p-d,f-x,M-A).normalize(),n)s[4].setComponents(c,u,m,S).normalize(),s[5].setComponents(l-c,p-u,f-m,M-S).normalize();else if(s[4].setComponents(l-c,p-u,f-m,M-S).normalize(),t===fn)s[5].setComponents(l+c,p+u,f+m,M+S).normalize();else if(t===Qi)s[5].setComponents(c,u,m,S).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(),Ti.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ti.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ti)}intersectsSprite(e){Ti.center.set(0,0,0);let t=Nd.distanceTo(e.center);return Ti.radius=.7071067811865476+t,Ti.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ti)}intersectsSphere(e){let t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let s=t[n];if(Lr.x=s.normal.x>0?e.max.x:e.min.x,Lr.y=s.normal.y>0?e.max.y:e.min.y,Lr.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Lr)<0)return!1}return!0}containsPoint(e){let 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)}},Uc=new ft,io=class i{constructor(){this.coordinateSystem=fn,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let s=0;s<t.length;s++){let r=t[s];Uc.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[s]===void 0&&(n[s]=new hi),n[s].setFromProjectionMatrix(Uc,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let s=0;s<e._count;s++)t[s]===void 0&&(t[s]=new hi),t[s].copy(n[s]);return this._count=e._count,this}clone(){return new i().copy(this)}};var Ci=class extends $n{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new We(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}},so=new k,ro=new k,Fc=new ft,Es=new Ri,Dr=new Ai,Za=new k,Oc=new k,oo=class extends Ut{constructor(e=new Yt,t=new Ci){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),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let s=1,r=t.count;s<r;s++)so.fromBufferAttribute(t,s-1),ro.fromBufferAttribute(t,s),n[s]=n[s-1],n[s]+=so.distanceTo(ro);e.setAttribute("lineDistance",new Xt(n,1))}else Ue("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,s=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Dr.copy(n.boundingSphere),Dr.applyMatrix4(s),Dr.radius+=r,e.ray.intersectsSphere(Dr)===!1)return;Fc.copy(s).invert(),Es.copy(e.ray).applyMatrix4(Fc);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let p=Math.max(0,o.start),_=Math.min(h.count,o.start+o.count);for(let x=p,m=_-1;x<m;x+=l){let f=h.getX(x),w=h.getX(x+1),A=Nr(this,e,Es,c,f,w,x);A&&t.push(A)}if(this.isLineLoop){let x=h.getX(_-1),m=h.getX(p),f=Nr(this,e,Es,c,x,m,_-1);f&&t.push(f)}}else{let p=Math.max(0,o.start),_=Math.min(u.count,o.start+o.count);for(let x=p,m=_-1;x<m;x+=l){let f=Nr(this,e,Es,c,x,x+1,x);f&&t.push(f)}if(this.isLineLoop){let x=Nr(this,e,Es,c,_-1,p,_-1);x&&t.push(x)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=s.length;r<o;r++){let a=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Nr(i,e,t,n,s,r,o){let a=i.geometry.attributes.position;if(so.fromBufferAttribute(a,s),ro.fromBufferAttribute(a,r),t.distanceSqToSegment(so,ro,Za,Oc)>n)return;Za.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Za);if(!(l<e.near||l>e.far))return{distance:l,point:Oc.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Bc=new k,zc=new k,rs=class extends oo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let s=0,r=t.count;s<r;s+=2)Bc.fromBufferAttribute(t,s),zc.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Bc.distanceTo(zc);e.setAttribute("lineDistance",new Xt(n,1))}else Ue("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Os=class extends Jt{constructor(e=[],t=Di,n,s,r,o,a,c,l,h){super(e,t,n,s,r,o,a,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}};var Jn=class extends Jt{constructor(e,t,n=Mn,s,r,o,a=It,c=It,l,h=Yn,d=1){if(h!==Yn&&h!==jn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:e,height:t,depth:d};super(u,s,r,o,a,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 ns(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Bs=class extends Jn{constructor(e,t=Mn,n=Di,s,r,o=It,a=It,c,l=Yn){let h={width:e,height:e,depth:1},d=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,c,l),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},zs=class extends Jt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},os=class i extends Yt{constructor(e=1,t=1,n=1,s=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:o};let a=this;s=Math.floor(s),r=Math.floor(r),o=Math.floor(o);let c=[],l=[],h=[],d=[],u=0,p=0;_("z","y","x",-1,-1,n,t,e,o,r,0),_("z","y","x",1,-1,n,t,-e,o,r,1),_("x","z","y",1,1,e,n,t,s,o,2),_("x","z","y",1,-1,e,n,-t,s,o,3),_("x","y","z",1,-1,e,t,n,s,r,4),_("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Xt(l,3)),this.setAttribute("normal",new Xt(h,3)),this.setAttribute("uv",new Xt(d,2));function _(x,m,f,w,A,S,M,E,g,v,N){let R=S/g,D=M/v,U=S/2,z=M/2,I=E/2,q=g+1,Z=v+1,B=0,ee=0,C=new k;for(let W=0;W<Z;W++){let K=W*D-z;for(let ve=0;ve<q;ve++){let we=ve*R-U;C[x]=we*w,C[m]=K*A,C[f]=I,l.push(C.x,C.y,C.z),C[x]=0,C[m]=0,C[f]=E>0?1:-1,h.push(C.x,C.y,C.z),d.push(ve/g),d.push(1-W/v),B+=1}}for(let W=0;W<v;W++)for(let K=0;K<g;K++){let ve=u+K+q*W,we=u+K+q*(W+1),G=u+(K+1)+q*(W+1),he=u+(K+1)+q*W;c.push(ve,we,he),c.push(we,G,he),ee+=6}a.addGroup(p,ee,N),p+=ee,u+=B}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};var Ur=new k,Fr=new k,$a=new k,Or=new Xn,ks=class extends Yt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let s=Math.pow(10,4),r=Math.cos(Ji*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],h=["a","b","c"],d=new Array(3),u=new Map,p=[];for(let _=0;_<c;_+=3){o?(l[0]=o.getX(_),l[1]=o.getX(_+1),l[2]=o.getX(_+2)):(l[0]=_,l[1]=_+1,l[2]=_+2);let{a:x,b:m,c:f}=Or;if(x.fromBufferAttribute(a,l[0]),m.fromBufferAttribute(a,l[1]),f.fromBufferAttribute(a,l[2]),Or.getNormal($a),d[0]=`${Math.round(x.x*s)},${Math.round(x.y*s)},${Math.round(x.z*s)}`,d[1]=`${Math.round(m.x*s)},${Math.round(m.y*s)},${Math.round(m.z*s)}`,d[2]=`${Math.round(f.x*s)},${Math.round(f.y*s)},${Math.round(f.z*s)}`,!(d[0]===d[1]||d[1]===d[2]||d[2]===d[0]))for(let w=0;w<3;w++){let A=(w+1)%3,S=d[w],M=d[A],E=Or[h[w]],g=Or[h[A]],v=`${S}_${M}`,N=`${M}_${S}`,R=u.get(N);R?($a.dot(R.normal)<=r&&(p.push(E.x,E.y,E.z),p.push(g.x,g.y,g.z)),u.set(N,null)):u.has(v)||u.set(v,{index0:l[w],index1:l[A],normal:$a.clone()})}}for(let _ of u.values())if(_){let{index0:x,index1:m}=_;Ur.fromBufferAttribute(a,x),Fr.fromBufferAttribute(a,m),p.push(Ur.x,Ur.y,Ur.z),p.push(Fr.x,Fr.y,Fr.z)}this.setAttribute("position",new Xt(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};var Vs=class i extends Yt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};let r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(s),l=a+1,h=c+1,d=e/a,u=t/c,p=[],_=[],x=[],m=[];for(let f=0;f<h;f++){let w=f*u-o;for(let A=0;A<l;A++){let S=A*d-r;_.push(S,-w,0),x.push(0,0,1),m.push(A/a),m.push(1-f/c)}}for(let f=0;f<c;f++)for(let w=0;w<a;w++){let A=w+l*f,S=w+l*(f+1),M=w+1+l*(f+1),E=w+1+l*f;p.push(A,S,E),p.push(S,M,E)}this.setIndex(p),this.setAttribute("position",new Xt(_,3)),this.setAttribute("normal",new Xt(x,3)),this.setAttribute("uv",new Xt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}};function Ui(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let s=i[t][n];if(kc(s))s.isRenderTargetTexture?(Ue("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(kc(s[0])){let r=[];for(let o=0,a=s.length;o<a;o++)r[o]=s[o].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Gt(i){let e={};for(let t=0;t<i.length;t++){let n=Ui(i[t]);for(let s in n)e[s]=n[s]}return e}function kc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Ud(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Dl(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Qe.workingColorSpace}var Dh={clone:Ui,merge:Gt},Fd=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,pd=`void main() {
3
+ }`,Od=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
- }`,vn=class extends Bn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=fd,this.fragmentShader=pd,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=Si(e.uniforms),this.uniformsGroups=dd(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){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={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;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new ze().setHex(s.value);break;case"v2":this.uniforms[n].value=new Fe().fromArray(s.value);break;case"v3":this.uniforms[n].value=new B().fromArray(s.value);break;case"v4":this.uniforms[n].value=new dt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Oe().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ht().fromArray(s.value);break;default:this.uniforms[n].value=s.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(let 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}},Zr=class extends vn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var $i=class extends Bn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ze(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ze(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ja,this.normalScale=new Fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new On,this.combine=ha,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}},$r=class extends Bn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Qc,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}},Jr=class extends Bn{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 Fi(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Er(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var jn=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let a;t:{i:if(!(e<s)){for(let o=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=t[++n],e<s)break e}a=t.length;break t}if(!(e>=r)){let 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(s=r,r=t[--n-1],e>=r)break e}a=n,n=0;break t}break n}for(;n<a;){let o=n+a>>>1;e<t[o]?a=o:n=o+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let a=0;a!==s;++a)t[a]=n[r+a];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},Kr=class extends jn{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Uo,endingEnd:Uo}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,a=e+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case Fo:r=e,o=2*t-n;break;case Oo:r=s.length-2,o=t+s[r]-s[r+1];break;default:r=e,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Fo:a=e,c=2*n-t;break;case Oo:a=1,c=n+s[1]-s[0];break;default:a=e-1,c=t}let 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,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,m=this._weightNext,_=(n-t)/(s-t),y=_*_,p=y*_,f=-u*p+2*u*y-u*_,S=(1+u)*p+(-1.5-2*u)*y+(-.5+u)*_+1,A=(-1-m)*p+(1.5+m)*y+.5*_,b=m*p-m*y;for(let T=0;T!==o;++T)r[T]=f*a[h+T]+S*a[l+T]+A*a[c+T]+b*a[d+T];return r}},jr=class extends jn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=(n-t)/(s-t),d=1-h;for(let u=0;u!==o;++u)r[u]=a[l+u]*d+a[c+u]*h;return r}},Qr=class extends jn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},ea=class extends jn{interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=e*o,l=c-o,h=this.inTangents,d=this.outTangents;if(!h||!d){let _=(n-t)/(s-t),y=1-_;for(let p=0;p!==o;++p)r[p]=a[l+p]*y+a[c+p]*_;return r}let u=o*2,m=e-1;for(let _=0;_!==o;++_){let y=a[l+_],p=a[c+_],f=m*u+_*2,S=d[f],A=d[f+1],b=e*u+_*2,T=h[b],E=h[b+1],g=gd(n,t,S,T,s);r[_]=gh(g,y,A,E,p)}return r}};function gh(i,e,t,n,s){let r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function md(i,e,t,n,s){let r=1-i;return 3*r*r*(t-e)+6*r*i*(n-t)+3*i*i*(s-n)}function gd(i,e,t,n,s){let r=(i-e)/(s-e);for(let a=0;a<8;a++){let o=gh(r,e,t,n,s)-i;if(Math.abs(o)<1e-10)break;let c=md(r,e,t,n,s);if(Math.abs(c)<1e-10)break;r=Math.max(0,Math.min(1,r-o/c))}return r}var tn=class{constructor(e,t,n,s){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=Fi(t,this.TimeBufferType),this.values=Fi(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Fi(e.times,Array),values:Fi(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s),Er(e.settings)&&(n.settings={inTangents:Fi(e.settings.inTangents,Array),outTangents:Fi(e.settings.outTangents,Array)})}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Qr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new jr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Kr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new ea(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 gs:t=this.InterpolantFactoryMethodDiscrete;break;case Br:t=this.InterpolantFactoryMethodLinear;break;case Ar:t=this.InterpolantFactoryMethodSmooth;break;case No:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let 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 Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return gs;case this.InterpolantFactoryMethodLinear:return Br;case this.InterpolantFactoryMethodSmooth:return Ar;case this.InterpolantFactoryMethodBezier:return No}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e;Er(this.settings)&&(Sc(this.settings.inTangents,e),Sc(this.settings.outTangents,e))}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e;Er(this.settings)&&(Ec(this.settings.inTangents,e),Ec(this.settings.outTangents,e))}return this}trim(e,t){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<e;)++r;for(;a!==-1&&n[a]>t;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(Ue("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(Ue("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){Ue("KeyframeTrack: Time is not a valid number.",this,o,c),e=!1;break}if(a!==null&&a>c){Ue("KeyframeTrack: Out of order keys.",this,o,c,a),e=!1;break}a=c}if(s!==void 0&&Lu(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){Ue("KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Ar,r=e.length-1,a=1;for(let o=1;o<r;++o){let c=!1,l=e[o],h=e[o+1];if(l!==h&&(o!==1||l!==e[0]))if(s)c=!0;else{let d=o*n,u=d-n,m=d+n;for(let _=0;_!==n;++_){let y=t[d+_];if(y!==t[u+_]||y!==t[m+_]){c=!0;break}}}if(c){if(o!==a){e[a]=e[o];let d=o*n,u=a*n;for(let m=0;m!==n;++m)t[u+m]=t[d+m]}++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(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,Er(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Sc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function Ec(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}tn.prototype.ValueTypeName="";tn.prototype.TimeBufferType=Float32Array;tn.prototype.ValueBufferType=Float32Array;tn.prototype.DefaultInterpolation=Br;var Qn=class extends tn{constructor(e,t,n){super(e,t,n)}};Qn.prototype.ValueTypeName="bool";Qn.prototype.ValueBufferType=Array;Qn.prototype.DefaultInterpolation=gs;Qn.prototype.InterpolantFactoryMethodLinear=void 0;Qn.prototype.InterpolantFactoryMethodSmooth=void 0;var ta=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}};ta.prototype.ValueTypeName="color";var na=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}};na.prototype.ValueTypeName="number";var ia=class extends jn{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-t)/(s-t),l=e*o;for(let h=l+o;l!==h;l+=4)jt.slerpFlat(r,0,a,l-o,a,l,c);return r}},Ps=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new ia(this.times,this.values,this.getValueSize(),e)}};Ps.prototype.ValueTypeName="quaternion";Ps.prototype.InterpolantFactoryMethodSmooth=void 0;var ei=class extends tn{constructor(e,t,n){super(e,t,n)}};ei.prototype.ValueTypeName="string";ei.prototype.ValueBufferType=Array;ei.prototype.DefaultInterpolation=gs;ei.prototype.InterpolantFactoryMethodLinear=void 0;ei.prototype.InterpolantFactoryMethodSmooth=void 0;var sa=class extends tn{constructor(e,t,n,s){super(e,t,n,s)}};sa.prototype.ValueTypeName="vector";var ra=class{constructor(e,t,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.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,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=l.length;d<u;d+=2){let m=l[d],_=l[d+1];if(m.global&&(m.lastIndex=0),m.test(h))return _}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},_h=new ra,aa=class{constructor(e){this.manager=e!==void 0?e:_h,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},this.priority="auto",this.cache="default",typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,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}setPriority(e){return this.priority=e,this}setCache(e){return this.cache=e,this}abort(){return this}};aa.DEFAULT_MATERIAL_NAME="__DEFAULT";var Is=class extends Ct{static registerNode(e){this.prototype._lightNode=e}constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ze(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},Ls=class extends Is{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ct.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ze(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Do=new ht,wc=new B,Tc=new B,oa=class{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 Fe(512,512),this.mapType=Xt,this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Kn,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new dt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;wc.setFromMatrixPosition(e.matrixWorld),t.position.copy(wc),Tc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Tc),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,s){Do.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Do,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,a=s?s.z/r.x:1,o=s?s.w/r.y:1,c=s?s.x/r.x:0,l=s?s.y/r.y:0;e.coordinateSystem===Gi||e.reversedDepth?t.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,1,0,0,0,0,1):t.set(.5*a,0,0,.5*a+c,0,.5*o,0,.5*o+l,0,0,.5,.5,0,0,0,1),t.multiply(Do)}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.mapType=e.mapType,this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.mapType=this.mapType,e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},wr=new B,Tr=new jt,xn=new B,Ds=class extends Ct{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=on,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(wr,Tr,xn),xn.x===1&&xn.y===1&&xn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(wr,Tr,xn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(wr,Tr,xn),xn.x===1&&xn.y===1&&xn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(wr,Tr,xn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},$n=new B,Ac=new Fe,Rc=new Fe,Bt=class extends Ds{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,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){let t=.5*this.getFilmHeight()/e;this.fov=Wi*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(zi*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Wi*2*Math.atan(Math.tan(zi*.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){$n.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set($n.x,$n.y).multiplyScalar(-e/$n.z),$n.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set($n.x,$n.y).multiplyScalar(-e/$n.z)}getViewSize(e,t){return this.getViewBounds(e,Ac,Rc),t.subVectors(Rc,Ac)}setViewOffset(e,t,n,s,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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(zi*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,t-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}};var xi=class extends Ds{constructor(e=-1,t=1,n=1,s=-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=s,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,s,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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,a=n+e,o=s+t,c=s-t;if(this.view!==null&&this.view.enabled){let 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){let 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}},Bo=class extends oa{constructor(){super(new xi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},Ji=class extends Is{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ct.DEFAULT_UP),this.updateMatrix(),this.target=new Ct,this.shadow=new Bo}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){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var Oi=-90,Bi=1,Ki=class extends Ct{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Bt(Oi,Bi,e,t);s.layers=this.layers,this.add(s);let r=new Bt(Oi,Bi,e,t);r.layers=this.layers,this.add(r);let a=new Bt(Oi,Bi,e,t);a.layers=this.layers,this.add(a);let o=new Bt(Oi,Bi,e,t);o.layers=this.layers,this.add(o);let c=new Bt(Oi,Bi,e,t);c.layers=this.layers,this.add(c);let l=new Bt(Oi,Bi,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,c]=t;for(let l of t)this.remove(l);if(e===on)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.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===Gi)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.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(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let p=!1;e.isWebGLRenderer===!0?p=e.state.buffers.depth.getReversed():p=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.mipmapsAutoUpdate=y,e.setRenderTarget(n,5,s),p&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,m),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}},la=class extends Bt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var _l="\\[\\]\\.:\\/",_d=new RegExp("["+_l+"]","g"),xl="[^"+_l+"]",xd="[^"+_l.replace("\\.","")+"]",yd=/((?:WC+[\/:])*)/.source.replace("WC",xl),vd=/(WCOD+)?/.source.replace("WCOD",xd),Md=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",xl),bd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",xl),Sd=new RegExp("^"+yd+vd+Md+bd+"$"),Ed=["material","materials","bones","map"],zo=class{constructor(e,t,n){let s=n||ct.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},ct=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.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 i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(_d,"")}static parseTrackName(e){let t=Sd.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Ed.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===t||o.uuid===t)return o;let c=n(o.children);if(c)return c}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_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){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=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,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Ue("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){Ue("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){Ue("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Ue("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){Ue("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){Ue("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let a=e[s];if(a===void 0){let l=t.nodeName;Ue("PropertyBinding: Trying to update property for track: "+l+"."+s+" 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(s==="morphTargetInfluences"){if(!e.geometry){Ue("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Ue("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=s;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}};ct.Composite=zo;ct.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ct.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ct.prototype.GetterByBindingType=[ct.prototype._getValue_direct,ct.prototype._getValue_array,ct.prototype._getValue_arrayElement,ct.prototype._getValue_toArray];ct.prototype.SetterByBindingTypeAndVersioning=[[ct.prototype._setValue_direct,ct.prototype._setValue_direct_setNeedsUpdate,ct.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_array,ct.prototype._setValue_array_setNeedsUpdate,ct.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_arrayElement,ct.prototype._setValue_arrayElement_setNeedsUpdate,ct.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ct.prototype._setValue_fromArray,ct.prototype._setValue_fromArray_setNeedsUpdate,ct.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var q_=new Float32Array(1);var ji=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=We(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(We(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var El=class El{constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}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,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};El.prototype.isMatrix2=!0;var ko=El;var Ns=class extends dn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function yl(i,e,t,n){let s=wd(n);switch(t){case sl:return i*e;case al:return i*e/s.components*s.byteLength;case _a:return i*e/s.components*s.byteLength;case si:return i*e*2/s.components*s.byteLength;case xa:return i*e*2/s.components*s.byteLength;case rl:return i*e*3/s.components*s.byteLength;case gn:return i*e*4/s.components*s.byteLength;case ya:return i*e*4/s.components*s.byteLength;case Bs:case zs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ks:case Vs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ma:case Sa:return Math.max(i,16)*Math.max(e,8)/4;case va:case ba:return Math.max(i,8)*Math.max(e,8)/2;case Ea:case wa:case Aa:case Ra:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ta:case Gs:case Ca:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Pa:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ia:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case La:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Da:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Na:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Ua:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Fa:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Oa:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Ba:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case za:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case ka:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Va:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case Ga:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Ha:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Wa:case Xa:case qa:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Ya:case Za:return Math.ceil(i/4)*Math.ceil(e/4)*8;case Hs:case $a:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function wd(i){switch(i){case Xt:case el:return{byteLength:1,components:1};case ns:case tl:case mn:return{byteLength:2,components:1};case ma:case ga:return{byteLength:2,components:4};case fn:case pa:case pn:return{byteLength:4,components:1};case nl:case il:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"187"}}));typeof window<"u"&&(window.__THREE__?Ie("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="187");function zh(){let i=null,e=!1,t=null,n=null;function s(r,a){n=i.requestAnimationFrame(s),t(r,a)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Ad(i){let e=new WeakMap;function t(o,c){let l=o.array,h=o.usage,d=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,h),o.onUploadCallback();let m;if(l instanceof Float32Array)m=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)m=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=i.SHORT;else if(l instanceof Uint32Array)m=i.UNSIGNED_INT;else if(l instanceof Int32Array)m=i.INT;else if(l instanceof Int8Array)m=i.BYTE;else if(l instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:d}}function n(o,c,l){let h=c.array,d=c.updateRanges;if(i.bindBuffer(l,o),d.length===0)i.bufferSubData(l,0,h);else{d.sort((m,_)=>m.start-_.start);let u=0;for(let m=1;m<d.length;m++){let _=d[u],y=d[m];y.start<=_.start+_.count+1?_.count=Math.max(_.count,y.start+y.count-_.start):(++u,d[u]=y)}d.length=u+1;for(let m=0,_=d.length;m<_;m++){let y=d[m];i.bufferSubData(l,y.start*h.BYTES_PER_ELEMENT,h,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),e.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let c=e.get(o);c&&(i.deleteBuffer(c.buffer),e.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=e.get(o);(!h||h.version<o.version)&&e.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=e.get(o);if(l===void 0)e.set(o,t(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var Rd=`#ifdef USE_ALPHAHASH
5
+ }`,Cn=class extends $n{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Fd,this.fragmentShader=Od,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=Ui(e.uniforms),this.uniformsGroups=Ud(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){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let s in this.uniforms){let o=this.uniforms[s].value;o&&o.isTexture?t.uniforms[s]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[s]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[s]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[s]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[s]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[s]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[s]={type:"m4",value:o.toArray()}:t.uniforms[s]={value:o}}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;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new We().setHex(s.value);break;case"v2":this.uniforms[n].value=new ke().fromArray(s.value);break;case"v3":this.uniforms[n].value=new k().fromArray(s.value);break;case"v4":this.uniforms[n].value=new gt().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ge().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ft().fromArray(s.value);break;default:this.uniforms[n].value=s.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(let 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}},ao=class extends Cn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}};var as=class extends $n{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new We(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new We(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ha,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zn,this.combine=wo,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}},lo=class extends $n{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=_h,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}},co=class extends $n{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 Yi(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function Br(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}var ui=class{constructor(e,t,n,s){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,s=t[n],r=t[n-1];n:{e:{let o;t:{i:if(!(e<s)){for(let a=n+2;;){if(s===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=s,s=t[++n],e<s)break e}o=t.length;break t}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=t[--n-1],e>=r)break e}o=n,n=0;break t}break n}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(s=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,e,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s;for(let o=0;o!==s;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}},ho=class extends ui{constructor(e,t,n,s){super(e,t,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ja,endingEnd:ja}}intervalChanged_(e,t,n){let s=this.parameterPositions,r=e-2,o=e+1,a=s[r],c=s[o];if(a===void 0)switch(this.getSettings_().endingStart){case Qa:r=e,a=2*t-n;break;case el:r=s.length-2,a=t+s[r]-s[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Qa:o=e,c=2*n-t;break;case el:o=1,c=n+s[1]-s[0];break;default:o=e-1,c=t}let l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this._offsetPrev,d=this._offsetNext,u=this._weightPrev,p=this._weightNext,_=(n-t)/(s-t),x=_*_,m=x*_,f=-u*m+2*u*x-u*_,w=(1+u)*m+(-1.5-2*u)*x+(-.5+u)*_+1,A=(-1-p)*m+(1.5+p)*x+.5*_,S=p*m-p*x;for(let M=0;M!==a;++M)r[M]=f*o[h+M]+w*o[l+M]+A*o[c+M]+S*o[d+M];return r}},uo=class extends ui{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=(n-t)/(s-t),d=1-h;for(let u=0;u!==a;++u)r[u]=o[l+u]*d+o[c+u]*h;return r}},fo=class extends ui{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e){return this.copySampleValue_(e-1)}},po=class extends ui{interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this.inTangents,d=this.outTangents;if(!h||!d){let _=(n-t)/(s-t),x=1-_;for(let m=0;m!==a;++m)r[m]=o[l+m]*x+o[c+m]*_;return r}let u=a*2,p=e-1;for(let _=0;_!==a;++_){let x=o[l+_],m=o[c+_],f=p*u+_*2,w=d[f],A=d[f+1],S=e*u+_*2,M=h[S],E=h[S+1],g=zd(n,t,w,M,s);r[_]=Nh(g,x,A,E,m)}return r}};function Nh(i,e,t,n,s){let r=1-i;return r*r*r*e+3*r*r*i*t+3*r*i*i*n+i*i*i*s}function Bd(i,e,t,n,s){let r=1-i;return 3*r*r*(t-e)+6*r*i*(n-t)+3*i*i*(s-n)}function zd(i,e,t,n,s){let r=(i-e)/(s-e);for(let o=0;o<8;o++){let a=Nh(r,e,t,n,s)-i;if(Math.abs(a)<1e-10)break;let c=Bd(r,e,t,n,s);if(Math.abs(c)<1e-10)break;r=Math.max(0,Math.min(1,r-a/c))}return r}var cn=class{constructor(e,t,n,s){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=Yi(t,this.TimeBufferType),this.values=Yi(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Yi(e.times,Array),values:Yi(e.values,Array)};let s=e.getInterpolation();s!==e.DefaultInterpolation&&(n.interpolation=s),Br(e.settings)&&(n.settings={inTangents:Yi(e.settings.inTangents,Array),outTangents:Yi(e.settings.outTangents,Array)})}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new fo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new uo(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new ho(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodBezier(e){let t=new po(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 Rs:t=this.InterpolantFactoryMethodDiscrete;break;case jr:t=this.InterpolantFactoryMethodLinear;break;case Vr:t=this.InterpolantFactoryMethodSmooth;break;case Ka:t=this.InterpolantFactoryMethodBezier;break}if(t===void 0){let 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 Ue("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Rs;case this.InterpolantFactoryMethodLinear:return jr;case this.InterpolantFactoryMethodSmooth:return Vr;case this.InterpolantFactoryMethodBezier:return Ka}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]+=e;Br(this.settings)&&(Vc(this.settings.inTangents,e),Vc(this.settings.outTangents,e))}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,s=t.length;n!==s;++n)t[n]*=e;Br(this.settings)&&(Gc(this.settings.inTangents,e),Gc(this.settings.outTangents,e))}return this}trim(e,t){let n=this.times,s=n.length,r=0,o=s-1;for(;r!==s&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==s){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(ze("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(ze("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){ze("KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){ze("KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(s!==void 0&&td(s))for(let a=0,c=s.length;a!==c;++a){let l=s[a];if(isNaN(l)){ze("KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===Vr,r=e.length-1,o=1;for(let a=1;a<r;++a){let c=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(s)c=!0;else{let d=a*n,u=d-n,p=d+n;for(let _=0;_!==n;++_){let x=t[d+_];if(x!==t[u+_]||x!==t[p+_]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let d=a*n,u=o*n;for(let p=0;p!==n;++p)t[u+p]=t[d+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,s=new n(this.name,e,t);return s.createInterpolant=this.createInterpolant,Br(this.settings)&&(s.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),s}};function Vc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function Gc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}cn.prototype.ValueTypeName="";cn.prototype.TimeBufferType=Float32Array;cn.prototype.ValueBufferType=Float32Array;cn.prototype.DefaultInterpolation=jr;var di=class extends cn{constructor(e,t,n){super(e,t,n)}};di.prototype.ValueTypeName="bool";di.prototype.ValueBufferType=Array;di.prototype.DefaultInterpolation=Rs;di.prototype.InterpolantFactoryMethodLinear=void 0;di.prototype.InterpolantFactoryMethodSmooth=void 0;var mo=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};mo.prototype.ValueTypeName="color";var go=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};go.prototype.ValueTypeName="number";var _o=class extends ui{constructor(e,t,n,s){super(e,t,n,s)}interpolate_(e,t,n,s){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(s-t),l=e*a;for(let h=l+a;l!==h;l+=4)an.slerpFlat(r,0,o,l-a,o,l,c);return r}},Gs=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new _o(this.times,this.values,this.getValueSize(),e)}};Gs.prototype.ValueTypeName="quaternion";Gs.prototype.InterpolantFactoryMethodSmooth=void 0;var fi=class extends cn{constructor(e,t,n){super(e,t,n)}};fi.prototype.ValueTypeName="string";fi.prototype.ValueBufferType=Array;fi.prototype.DefaultInterpolation=Rs;fi.prototype.InterpolantFactoryMethodLinear=void 0;fi.prototype.InterpolantFactoryMethodSmooth=void 0;var xo=class extends cn{constructor(e,t,n,s){super(e,t,n,s)}};xo.prototype.ValueTypeName="vector";var yo=class{constructor(e,t,n){let s=this,r=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(h){a++,r===!1&&s.onStart!==void 0&&s.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,s.onProgress!==void 0&&s.onProgress(h,o,a),o===a&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.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,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=l.length;d<u;d+=2){let p=l[d],_=l[d+1];if(p.global&&(p.lastIndex=0),p.test(h))return _}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}},Uh=new yo,vo=class{constructor(e){this.manager=e!==void 0?e:Uh,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},this.priority="auto",this.cache="default",typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(e,t){let n=this;return new Promise(function(s,r){n.load(e,s,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}setPriority(e){return this.priority=e,this}setCache(e){return this.cache=e,this}abort(){return this}};vo.DEFAULT_MATERIAL_NAME="__DEFAULT";var Hs=class extends Ut{static registerNode(e){this.prototype._lightNode=e}constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new We(e),this.intensity=t}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}},Ws=class extends Hs{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new We(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){let t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}},Ja=new ft,Hc=new k,Wc=new k,bo=class{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 ke(512,512),this.mapType=jt,this.map=null,this.mapPass=null,this.matrix=new ft,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new hi,this._frameExtents=new ke(1,1),this._viewportCount=1,this._viewports=[new gt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getCamera(){return this.camera}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera;Hc.setFromMatrixPosition(e.matrixWorld),t.position.copy(Hc),Wc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Wc),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,s){Ja.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix(Ja,e.coordinateSystem,e.reversedDepth);let r=this._frameExtents,o=s?s.z/r.x:1,a=s?s.w/r.y:1,c=s?s.x/r.x:0,l=s?s.y/r.y:0;e.coordinateSystem===Qi||e.reversedDepth?t.set(.5*o,0,0,.5*o+c,0,.5*a,0,.5*a+l,0,0,1,0,0,0,0,1):t.set(.5*o,0,0,.5*o+c,0,.5*a,0,.5*a+l,0,0,.5,.5,0,0,0,1),t.multiply(Ja)}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.mapType=e.mapType,this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return e.intensity=this.intensity,e.bias=this.bias,e.normalBias=this.normalBias,e.radius=this.radius,e.blurSamples=this.blurSamples,e.mapSize=this.mapSize.toArray(),e.mapType=this.mapType,e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},zr=new k,kr=new an,Tn=new k,Xs=class extends Ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ft,this.projectionMatrix=new ft,this.projectionMatrixInverse=new ft,this.coordinateSystem=fn,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(zr,kr,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zr,kr,Tn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(zr,kr,Tn),Tn.x===1&&Tn.y===1&&Tn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zr,kr,Tn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},li=new k,Xc=new ke,qc=new ke,Wt=class extends Xs{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,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){let t=.5*this.getFilmHeight()/e;this.fov=ts*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ji*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ts*2*Math.atan(Math.tan(Ji*.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){li.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(li.x,li.y).multiplyScalar(-e/li.z),li.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(li.x,li.y).multiplyScalar(-e/li.z)}getViewSize(e,t){return this.getViewBounds(e,Xc,qc),t.subVectors(qc,Xc)}setViewOffset(e,t,n,s,r,o){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=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ji*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*s/c,t-=o.offsetY*n/l,s*=o.width/c,n*=o.height/l}let a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}};var Pi=class extends Xs{constructor(e=-1,t=1,n=1,s=-1,r=.1,o=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=s,this.near=r,this.far=o,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,s,r,o){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=s,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-e,o=n+e,a=s+t,c=s-t;if(this.view!==null&&this.view.enabled){let 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,o=r+l*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let 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}},tl=class extends bo{constructor(){super(new Pi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ls=class extends Hs{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ut.DEFAULT_UP),this.updateMatrix(),this.target=new Ut,this.shadow=new tl}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){let t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}};var Zi=-90,$i=1,cs=class extends Ut{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new Wt(Zi,$i,e,t);s.layers=this.layers,this.add(s);let r=new Wt(Zi,$i,e,t);r.layers=this.layers,this.add(r);let o=new Wt(Zi,$i,e,t);o.layers=this.layers,this.add(o);let a=new Wt(Zi,$i,e,t);a.layers=this.layers,this.add(a);let c=new Wt(Zi,$i,e,t);c.layers=this.layers,this.add(c);let l=new Wt(Zi,$i,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,s,r,o,a,c]=t;for(let l of t)this.remove(l);if(e===fn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Qi)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.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(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,c,l,h]=this.children,d=e.getRenderTarget(),u=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),n.texture.mipmapsAutoUpdate=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(d,u,p),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}},Mo=class extends Wt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var Nl="\\[\\]\\.:\\/",kd=new RegExp("["+Nl+"]","g"),Ul="[^"+Nl+"]",Vd="[^"+Nl.replace("\\.","")+"]",Gd=/((?:WC+[\/:])*)/.source.replace("WC",Ul),Hd=/(WCOD+)?/.source.replace("WCOD",Vd),Wd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ul),Xd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ul),qd=new RegExp("^"+Gd+Hd+Wd+Xd+"$"),Yd=["material","materials","bones","map"],nl=class{constructor(e,t,n){let s=n||dt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,s)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},dt=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.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 i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(kd,"")}static parseTrackName(e){let t=qd.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);Yd.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let c=n(a.children);if(c)return c}return null},s=n(e.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)e[t++]=n[s]}_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){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=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,t=this.parsedPath,n=t.objectName,s=t.propertyName,r=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ue("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ze("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){ze("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){ze("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ze("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){ze("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){ze("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[s];if(o===void 0){let l=t.nodeName;ze("PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?a=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!e.geometry){ze("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ze("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=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};dt.Composite=nl;dt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};dt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};dt.prototype.GetterByBindingType=[dt.prototype._getValue_direct,dt.prototype._getValue_array,dt.prototype._getValue_arrayElement,dt.prototype._getValue_toArray];dt.prototype.SetterByBindingTypeAndVersioning=[[dt.prototype._setValue_direct,dt.prototype._setValue_direct_setNeedsUpdate,dt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_array,dt.prototype._setValue_array_setNeedsUpdate,dt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_arrayElement,dt.prototype._setValue_arrayElement_setNeedsUpdate,dt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[dt.prototype._setValue_fromArray,dt.prototype._setValue_fromArray_setNeedsUpdate,dt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var v_=new Float32Array(1);var hs=class{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Ze(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Ze(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var Vl=class Vl{constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}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,s){let r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}};Vl.prototype.isMatrix2=!0;var il=Vl;var qs=class extends bn{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}};function Fl(i,e,t,n){let s=Zd(n);switch(t){case bl:return i*e;case Sl:return i*e/s.components*s.byteLength;case Io:return i*e/s.components*s.byteLength;case _i:return i*e*2/s.components*s.byteLength;case Lo:return i*e*2/s.components*s.byteLength;case Ml:return i*e*3/s.components*s.byteLength;case En:return i*e*4/s.components*s.byteLength;case Do:return i*e*4/s.components*s.byteLength;case Js:case Ks:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case js:case Qs:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Uo:case Oo:return Math.max(i,16)*Math.max(e,8)/4;case No:case Fo:return Math.max(i,8)*Math.max(e,8)/2;case Bo:case zo:case Vo:case Go:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case ko:case er:case Ho:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Wo:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Xo:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case qo:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Yo:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Zo:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case $o:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Jo:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Ko:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case jo:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Qo:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case ea:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case ta:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case na:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case ia:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case sa:case ra:case oa:return Math.ceil(i/4)*Math.ceil(e/4)*16;case aa:case la:return Math.ceil(i/4)*Math.ceil(e/4)*8;case tr:case ca:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Zd(i){switch(i){case jt:case _l:return{byteLength:1,components:1};case ps:case xl:case wn:return{byteLength:2,components:1};case Co:case Po:return{byteLength:2,components:4};case Mn:case Ro:case Sn:return{byteLength:4,components:1};case yl:case vl:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"187"}}));typeof window<"u"&&(window.__THREE__?Ue("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="187");function iu(){let i=null,e=!1,t=null,n=null;function s(r,o){n=i.requestAnimationFrame(s),t(r,o)}return{start:function(){e!==!0&&t!==null&&i!==null&&(n=i.requestAnimationFrame(s),e=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){i=r}}}function Jd(i){let e=new WeakMap;function t(a,c){let l=a.array,h=a.usage,d=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,h),a.onUploadCallback();let p;if(l instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=i.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=i.SHORT;else if(l instanceof Uint32Array)p=i.UNSIGNED_INT;else if(l instanceof Int32Array)p=i.INT;else if(l instanceof Int8Array)p=i.BYTE;else if(l instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:d}}function n(a,c,l){let h=c.array,d=c.updateRanges;if(i.bindBuffer(l,a),d.length===0)i.bufferSubData(l,0,h);else{d.sort((p,_)=>p.start-_.start);let u=0;for(let p=1;p<d.length;p++){let _=d[u],x=d[p];x.start<=_.start+_.count+1?_.count=Math.max(_.count,x.start+x.count-_.start):(++u,d[u]=x)}d.length=u+1;for(let p=0,_=d.length;p<_;p++){let x=d[p];i.bufferSubData(l,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(i.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:s,remove:r,update:o}}var Kd=`#ifdef USE_ALPHAHASH
6
6
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
7
- #endif`,Cd=`#ifdef USE_ALPHAHASH
7
+ #endif`,jd=`#ifdef USE_ALPHAHASH
8
8
  const float ALPHA_HASH_SCALE = 0.05;
9
9
  float hash2D( vec2 value ) {
10
10
  return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
@@ -39,20 +39,20 @@
39
39
  : cases.z;
40
40
  return clamp( threshold , 1.0e-6, 1.0 );
41
41
  }
42
- #endif`,Pd=`#ifdef USE_ALPHAMAP
42
+ #endif`,Qd=`#ifdef USE_ALPHAMAP
43
43
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
- #endif`,Id=`#ifdef USE_ALPHAMAP
44
+ #endif`,ef=`#ifdef USE_ALPHAMAP
45
45
  uniform sampler2D alphaMap;
46
- #endif`,Ld=`#ifdef USE_ALPHATEST
46
+ #endif`,tf=`#ifdef USE_ALPHATEST
47
47
  #ifdef ALPHA_TO_COVERAGE
48
48
  diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
49
49
  if ( diffuseColor.a == 0.0 ) discard;
50
50
  #else
51
51
  if ( diffuseColor.a < alphaTest ) discard;
52
52
  #endif
53
- #endif`,Dd=`#ifdef USE_ALPHATEST
53
+ #endif`,nf=`#ifdef USE_ALPHATEST
54
54
  uniform float alphaTest;
55
- #endif`,Nd=`#ifdef USE_AOMAP
55
+ #endif`,sf=`#ifdef USE_AOMAP
56
56
  float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
57
57
  reflectedLight.indirectDiffuse *= ambientOcclusion;
58
58
  #if defined( USE_CLEARCOAT )
@@ -65,10 +65,10 @@
65
65
  float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
66
66
  reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
67
67
  #endif
68
- #endif`,Ud=`#ifdef USE_AOMAP
68
+ #endif`,rf=`#ifdef USE_AOMAP
69
69
  uniform sampler2D aoMap;
70
70
  uniform float aoMapIntensity;
71
- #endif`,Fd=`#ifdef USE_BATCHING
71
+ #endif`,of=`#ifdef USE_BATCHING
72
72
  #if ! defined( GL_ANGLE_multi_draw )
73
73
  #define gl_DrawID _gl_DrawID
74
74
  uniform int _gl_DrawID;
@@ -102,15 +102,15 @@
102
102
  int y = j / size;
103
103
  return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
104
104
  }
105
- #endif`,Od=`#ifdef USE_BATCHING
105
+ #endif`,af=`#ifdef USE_BATCHING
106
106
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
107
- #endif`,Bd=`vec3 transformed = vec3( position );
107
+ #endif`,lf=`vec3 transformed = vec3( position );
108
108
  #ifdef USE_ALPHAHASH
109
109
  vPosition = vec3( position );
110
- #endif`,zd=`vec3 objectNormal = vec3( normal );
110
+ #endif`,cf=`vec3 objectNormal = vec3( normal );
111
111
  #ifdef USE_TANGENT
112
112
  vec3 objectTangent = vec3( tangent.xyz );
113
- #endif`,kd=`float G_BlinnPhong_Implicit( ) {
113
+ #endif`,hf=`float G_BlinnPhong_Implicit( ) {
114
114
  return 0.25;
115
115
  }
116
116
  float D_BlinnPhong( const in float shininess, const in float dotNH ) {
@@ -124,7 +124,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
124
124
  float G = G_BlinnPhong_Implicit( );
125
125
  float D = D_BlinnPhong( shininess, dotNH );
126
126
  return F * ( G * D );
127
- } // validated`,Vd=`#ifdef USE_IRIDESCENCE
127
+ } // validated`,uf=`#ifdef USE_IRIDESCENCE
128
128
  const mat3 XYZ_TO_REC709 = mat3(
129
129
  3.2404542, -0.9692660, 0.0556434,
130
130
  -1.5371385, 1.8760108, -0.2040259,
@@ -187,7 +187,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
187
187
  }
188
188
  return max( I, vec3( 0.0 ) );
189
189
  }
190
- #endif`,Gd=`#ifdef USE_BUMPMAP
190
+ #endif`,df=`#ifdef USE_BUMPMAP
191
191
  uniform sampler2D bumpMap;
192
192
  uniform float bumpScale;
193
193
  vec2 dHdxy_fwd() {
@@ -208,7 +208,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
208
208
  vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
209
209
  return normalize( abs( fDet ) * surf_norm - vGrad );
210
210
  }
211
- #endif`,Hd=`#if NUM_CLIPPING_PLANES > 0
211
+ #endif`,ff=`#if NUM_CLIPPING_PLANES > 0
212
212
  vec4 plane;
213
213
  #ifdef ALPHA_TO_COVERAGE
214
214
  float distanceToPlane, distanceGradient;
@@ -254,20 +254,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
254
254
  if ( clipped ) discard;
255
255
  #endif
256
256
  #endif
257
- #endif`,Wd=`#if NUM_CLIPPING_PLANES > 0
257
+ #endif`,pf=`#if NUM_CLIPPING_PLANES > 0
258
258
  varying vec3 vClipPosition;
259
259
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
260
- #endif`,Xd=`#if NUM_CLIPPING_PLANES > 0
260
+ #endif`,mf=`#if NUM_CLIPPING_PLANES > 0
261
261
  varying vec3 vClipPosition;
262
- #endif`,qd=`#if NUM_CLIPPING_PLANES > 0
262
+ #endif`,gf=`#if NUM_CLIPPING_PLANES > 0
263
263
  vClipPosition = - mvPosition.xyz;
264
- #endif`,Yd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
264
+ #endif`,_f=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
265
265
  diffuseColor *= vColor;
266
- #endif`,Zd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
266
+ #endif`,xf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
267
267
  varying vec4 vColor;
268
- #endif`,$d=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
268
+ #endif`,yf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
269
269
  varying vec4 vColor;
270
- #endif`,Jd=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
270
+ #endif`,vf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
271
271
  vColor = vec4( 1.0 );
272
272
  #endif
273
273
  #ifdef USE_COLOR_ALPHA
@@ -280,7 +280,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
280
280
  #endif
281
281
  #ifdef USE_BATCHING_COLOR
282
282
  vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
283
- #endif`,Kd=`#define PI 3.141592653589793
283
+ #endif`,bf=`#define PI 3.141592653589793
284
284
  #define PI2 6.283185307179586
285
285
  #define PI_HALF 1.5707963267948966
286
286
  #define RECIPROCAL_PI 0.3183098861837907
@@ -351,7 +351,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
351
351
  float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
352
352
  float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
353
353
  return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
354
- } // validated`,jd=`vec3 transformedNormal = objectNormal;
354
+ } // validated`,Mf=`vec3 transformedNormal = objectNormal;
355
355
  #ifdef USE_TANGENT
356
356
  vec3 transformedTangent = objectTangent;
357
357
  #endif
@@ -377,21 +377,21 @@ transformedNormal = normalMatrix * transformedNormal;
377
377
  #endif
378
378
  #ifdef USE_TANGENT
379
379
  transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
380
- #endif`,Qd=`#ifdef USE_DISPLACEMENTMAP
380
+ #endif`,Sf=`#ifdef USE_DISPLACEMENTMAP
381
381
  uniform sampler2D displacementMap;
382
382
  uniform float displacementScale;
383
383
  uniform float displacementBias;
384
- #endif`,ef=`#ifdef USE_DISPLACEMENTMAP
384
+ #endif`,wf=`#ifdef USE_DISPLACEMENTMAP
385
385
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
386
- #endif`,tf=`#ifdef USE_EMISSIVEMAP
386
+ #endif`,Ef=`#ifdef USE_EMISSIVEMAP
387
387
  vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
388
388
  #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
389
389
  emissiveColor = sRGBTransferEOTF( emissiveColor );
390
390
  #endif
391
391
  totalEmissiveRadiance *= emissiveColor.rgb;
392
- #endif`,nf=`#ifdef USE_EMISSIVEMAP
392
+ #endif`,Tf=`#ifdef USE_EMISSIVEMAP
393
393
  uniform sampler2D emissiveMap;
394
- #endif`,sf="gl_FragColor = linearToOutputTexel( gl_FragColor );",rf=`vec4 LinearTransferOETF( in vec4 value ) {
394
+ #endif`,Af="gl_FragColor = linearToOutputTexel( gl_FragColor );",Rf=`vec4 LinearTransferOETF( in vec4 value ) {
395
395
  return value;
396
396
  }
397
397
  vec4 sRGBTransferEOTF( in vec4 value ) {
@@ -399,7 +399,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
399
399
  }
400
400
  vec4 sRGBTransferOETF( in vec4 value ) {
401
401
  return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
402
- }`,af=`#ifdef USE_ENVMAP
402
+ }`,Cf=`#ifdef USE_ENVMAP
403
403
  #ifdef ENV_WORLDPOS
404
404
  vec3 cameraToFrag;
405
405
  if ( isOrthographic ) {
@@ -426,7 +426,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
426
426
  outgoingLight += envColor.xyz * specularStrength * reflectivity;
427
427
  #endif
428
428
  #endif
429
- #endif`,of=`#ifdef USE_ENVMAP
429
+ #endif`,Pf=`#ifdef USE_ENVMAP
430
430
  uniform float envMapIntensity;
431
431
  uniform mat3 envMapRotation;
432
432
  uniform samplerCube envMap;
@@ -436,7 +436,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
436
436
  return ENVMAP_MAX_LOD * r * ( 2.0 - r );
437
437
  }
438
438
  #endif
439
- #endif`,lf=`#ifdef USE_ENVMAP
439
+ #endif`,If=`#ifdef USE_ENVMAP
440
440
  uniform float reflectivity;
441
441
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
442
442
  #define ENV_WORLDPOS
@@ -447,7 +447,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
447
447
  #else
448
448
  varying vec3 vReflect;
449
449
  #endif
450
- #endif`,cf=`#ifdef USE_ENVMAP
450
+ #endif`,Lf=`#ifdef USE_ENVMAP
451
451
  #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
452
452
  #define ENV_WORLDPOS
453
453
  #endif
@@ -458,7 +458,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
458
458
  varying vec3 vReflect;
459
459
  uniform float refractionRatio;
460
460
  #endif
461
- #endif`,hf=`#ifdef USE_ENVMAP
461
+ #endif`,Df=`#ifdef USE_ENVMAP
462
462
  #ifdef ENV_WORLDPOS
463
463
  vWorldPosition = worldPosition.xyz;
464
464
  #else
@@ -475,18 +475,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
475
475
  vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
476
476
  #endif
477
477
  #endif
478
- #endif`,uf=`#ifdef USE_FOG
478
+ #endif`,Nf=`#ifdef USE_FOG
479
479
  vFogDepth = - mvPosition.z;
480
- #endif`,df=`#ifdef USE_FOG
480
+ #endif`,Uf=`#ifdef USE_FOG
481
481
  varying float vFogDepth;
482
- #endif`,ff=`#ifdef USE_FOG
482
+ #endif`,Ff=`#ifdef USE_FOG
483
483
  #ifdef FOG_EXP2
484
484
  float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
485
485
  #else
486
486
  float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
487
487
  #endif
488
488
  gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
489
- #endif`,pf=`#ifdef USE_FOG
489
+ #endif`,Of=`#ifdef USE_FOG
490
490
  uniform vec3 fogColor;
491
491
  varying float vFogDepth;
492
492
  #ifdef FOG_EXP2
@@ -495,7 +495,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
495
495
  uniform float fogNear;
496
496
  uniform float fogFar;
497
497
  #endif
498
- #endif`,mf=`#ifdef USE_GRADIENTMAP
498
+ #endif`,Bf=`#ifdef USE_GRADIENTMAP
499
499
  uniform sampler2D gradientMap;
500
500
  #endif
501
501
  vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
@@ -507,12 +507,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
507
507
  vec2 fw = fwidth( coord ) * 0.5;
508
508
  return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
509
509
  #endif
510
- }`,gf=`#ifdef USE_LIGHTMAP
510
+ }`,zf=`#ifdef USE_LIGHTMAP
511
511
  uniform sampler2D lightMap;
512
512
  uniform float lightMapIntensity;
513
- #endif`,_f=`LambertMaterial material;
513
+ #endif`,kf=`LambertMaterial material;
514
514
  material.diffuseColor = diffuseColor.rgb;
515
- material.specularStrength = specularStrength;`,xf=`varying vec3 vViewPosition;
515
+ material.specularStrength = specularStrength;`,Vf=`varying vec3 vViewPosition;
516
516
  struct LambertMaterial {
517
517
  vec3 diffuseColor;
518
518
  float specularStrength;
@@ -526,7 +526,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
526
526
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
527
527
  }
528
528
  #define RE_Direct RE_Direct_Lambert
529
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,yf=`uniform bool receiveShadow;
529
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Gf=`uniform bool receiveShadow;
530
530
  uniform vec3 ambientLightColor;
531
531
  #if defined( USE_LIGHT_PROBES )
532
532
  uniform vec3 lightProbe[ 9 ];
@@ -655,7 +655,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
655
655
  return irradiance;
656
656
  }
657
657
  #endif
658
- #include <lightprobes_pars_fragment>`,vf=`#ifdef USE_ENVMAP
658
+ #include <lightprobes_pars_fragment>`,Hf=`#ifdef USE_ENVMAP
659
659
  vec3 getIBLIrradiance( const in vec3 normal ) {
660
660
  #ifdef ENVMAP_TYPE_PMREM
661
661
  vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
@@ -712,8 +712,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
712
712
  }
713
713
  #endif
714
714
  #endif
715
- #endif`,Mf=`ToonMaterial material;
716
- material.diffuseColor = diffuseColor.rgb;`,bf=`varying vec3 vViewPosition;
715
+ #endif`,Wf=`ToonMaterial material;
716
+ material.diffuseColor = diffuseColor.rgb;`,Xf=`varying vec3 vViewPosition;
717
717
  struct ToonMaterial {
718
718
  vec3 diffuseColor;
719
719
  };
@@ -725,11 +725,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
725
725
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
726
726
  }
727
727
  #define RE_Direct RE_Direct_Toon
728
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Sf=`BlinnPhongMaterial material;
728
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qf=`BlinnPhongMaterial material;
729
729
  material.diffuseColor = diffuseColor.rgb;
730
730
  material.specularColor = specular;
731
731
  material.specularShininess = shininess;
732
- material.specularStrength = specularStrength;`,Ef=`varying vec3 vViewPosition;
732
+ material.specularStrength = specularStrength;`,Yf=`varying vec3 vViewPosition;
733
733
  struct BlinnPhongMaterial {
734
734
  vec3 diffuseColor;
735
735
  vec3 specularColor;
@@ -746,7 +746,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
746
746
  reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
747
747
  }
748
748
  #define RE_Direct RE_Direct_BlinnPhong
749
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,wf=`PhysicalMaterial material;
749
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Zf=`PhysicalMaterial material;
750
750
  material.diffuseColor = diffuseColor.rgb;
751
751
  material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
752
752
  material.metalness = metalnessFactor;
@@ -847,7 +847,7 @@ material.roughness = min( material.roughness, 1.0 );
847
847
  material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
848
848
  material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
849
849
  material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
850
- #endif`,Tf=`uniform sampler2D dfgLUT;
850
+ #endif`,$f=`uniform sampler2D dfgLUT;
851
851
  struct PhysicalMaterial {
852
852
  vec3 diffuseColor;
853
853
  vec3 diffuseContribution;
@@ -1270,7 +1270,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
1270
1270
  #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1271
1271
  float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1272
1272
  return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1273
- }`,Af=`
1273
+ }`,Jf=`
1274
1274
  vec3 geometryPosition = - vViewPosition;
1275
1275
  vec3 geometryNormal = normal;
1276
1276
  vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
@@ -1428,7 +1428,7 @@ IncidentLight directLight;
1428
1428
  #if defined( RE_IndirectSpecular )
1429
1429
  vec3 radiance = vec3( 0.0 );
1430
1430
  vec3 clearcoatRadiance = vec3( 0.0 );
1431
- #endif`,Rf=`#if defined( RE_IndirectDiffuse )
1431
+ #endif`,Kf=`#if defined( RE_IndirectDiffuse )
1432
1432
  #ifdef USE_LIGHTMAP
1433
1433
  vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1434
1434
  vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
@@ -1458,7 +1458,7 @@ IncidentLight directLight;
1458
1458
  #ifdef USE_CLEARCOAT
1459
1459
  clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1460
1460
  #endif
1461
- #endif`,Cf=`#if defined( RE_IndirectDiffuse )
1461
+ #endif`,jf=`#if defined( RE_IndirectDiffuse )
1462
1462
  #if defined( LAMBERT ) || defined( PHONG )
1463
1463
  irradiance += iblIrradiance;
1464
1464
  #endif
@@ -1466,7 +1466,7 @@ IncidentLight directLight;
1466
1466
  #endif
1467
1467
  #if defined( RE_IndirectSpecular )
1468
1468
  RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1469
- #endif`,Pf=`#if NUM_LIGHT_PROBE_GRIDS > 0
1469
+ #endif`,Qf=`#if NUM_LIGHT_PROBE_GRIDS > 0
1470
1470
  uniform highp sampler3D probesSH[ NUM_LIGHT_PROBE_GRIDS ];
1471
1471
  uniform vec3 probesMin[ NUM_LIGHT_PROBE_GRIDS ];
1472
1472
  uniform vec3 probesMax[ NUM_LIGHT_PROBE_GRIDS ];
@@ -1515,27 +1515,27 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
1515
1515
  result += c8 * 0.429043 * ( x * x - y * y );
1516
1516
  return max( result, vec3( 0.0 ) );
1517
1517
  }
1518
- #endif`,If=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1518
+ #endif`,ep=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1519
1519
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1520
- #endif`,Lf=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1520
+ #endif`,tp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1521
1521
  uniform float logDepthBufFC;
1522
1522
  varying float vFragDepth;
1523
1523
  varying float vIsPerspective;
1524
- #endif`,Df=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1524
+ #endif`,np=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1525
1525
  varying float vFragDepth;
1526
1526
  varying float vIsPerspective;
1527
- #endif`,Nf=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1527
+ #endif`,ip=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1528
1528
  vFragDepth = 1.0 + gl_Position.w;
1529
1529
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1530
- #endif`,Uf=`#ifdef USE_MAP
1530
+ #endif`,sp=`#ifdef USE_MAP
1531
1531
  vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1532
1532
  #ifdef DECODE_VIDEO_TEXTURE
1533
1533
  sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1534
1534
  #endif
1535
1535
  diffuseColor *= sampledDiffuseColor;
1536
- #endif`,Ff=`#ifdef USE_MAP
1536
+ #endif`,rp=`#ifdef USE_MAP
1537
1537
  uniform sampler2D map;
1538
- #endif`,Of=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1538
+ #endif`,op=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1539
1539
  #if defined( USE_POINTS_UV )
1540
1540
  vec2 uv = vUv;
1541
1541
  #else
@@ -1547,7 +1547,7 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
1547
1547
  #endif
1548
1548
  #ifdef USE_ALPHAMAP
1549
1549
  diffuseColor.a *= texture2D( alphaMap, uv ).g;
1550
- #endif`,Bf=`#if defined( USE_POINTS_UV )
1550
+ #endif`,ap=`#if defined( USE_POINTS_UV )
1551
1551
  varying vec2 vUv;
1552
1552
  #else
1553
1553
  #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
@@ -1559,19 +1559,19 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
1559
1559
  #endif
1560
1560
  #ifdef USE_ALPHAMAP
1561
1561
  uniform sampler2D alphaMap;
1562
- #endif`,zf=`float metalnessFactor = metalness;
1562
+ #endif`,lp=`float metalnessFactor = metalness;
1563
1563
  #ifdef USE_METALNESSMAP
1564
1564
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1565
1565
  metalnessFactor *= texelMetalness.b;
1566
- #endif`,kf=`#ifdef USE_METALNESSMAP
1566
+ #endif`,cp=`#ifdef USE_METALNESSMAP
1567
1567
  uniform sampler2D metalnessMap;
1568
- #endif`,Vf=`#ifdef USE_INSTANCING_MORPH
1568
+ #endif`,hp=`#ifdef USE_INSTANCING_MORPH
1569
1569
  float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1570
1570
  float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1571
1571
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1572
1572
  morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1573
1573
  }
1574
- #endif`,Gf=`#if defined( USE_MORPHCOLORS )
1574
+ #endif`,up=`#if defined( USE_MORPHCOLORS )
1575
1575
  #if defined( USE_COLOR_ALPHA )
1576
1576
  vColor *= morphTargetBaseInfluence;
1577
1577
  #elif defined( USE_COLOR )
@@ -1584,12 +1584,12 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
1584
1584
  if ( morphTargetInfluences[ i ] != 0.0 ) vColor.rgb += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1585
1585
  #endif
1586
1586
  }
1587
- #endif`,Hf=`#ifdef USE_MORPHNORMALS
1587
+ #endif`,dp=`#ifdef USE_MORPHNORMALS
1588
1588
  objectNormal *= morphTargetBaseInfluence;
1589
1589
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1590
1590
  if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1591
1591
  }
1592
- #endif`,Wf=`#ifdef USE_MORPHTARGETS
1592
+ #endif`,fp=`#ifdef USE_MORPHTARGETS
1593
1593
  #ifndef USE_INSTANCING_MORPH
1594
1594
  uniform float morphTargetBaseInfluence;
1595
1595
  uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
@@ -1603,12 +1603,12 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
1603
1603
  ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1604
1604
  return texelFetch( morphTargetsTexture, morphUV, 0 );
1605
1605
  }
1606
- #endif`,Xf=`#ifdef USE_MORPHTARGETS
1606
+ #endif`,pp=`#ifdef USE_MORPHTARGETS
1607
1607
  transformed *= morphTargetBaseInfluence;
1608
1608
  for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1609
1609
  if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1610
1610
  }
1611
- #endif`,qf=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1611
+ #endif`,mp=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1612
1612
  #ifdef FLAT_SHADED
1613
1613
  vec3 fdx = dFdx( vViewPosition );
1614
1614
  vec3 fdy = dFdy( vViewPosition );
@@ -1649,7 +1649,7 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3
1649
1649
  tbn2[1] *= faceDirection;
1650
1650
  #endif
1651
1651
  #endif
1652
- vec3 nonPerturbedNormal = normal;`,Yf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1652
+ vec3 nonPerturbedNormal = normal;`,gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1653
1653
  normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1654
1654
  #ifdef FLIP_SIDED
1655
1655
  normal = - normal;
@@ -1667,19 +1667,19 @@ vec3 nonPerturbedNormal = normal;`,Yf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1667
1667
  normal = normalize( tbn * mapN );
1668
1668
  #elif defined( USE_BUMPMAP )
1669
1669
  normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1670
- #endif`,Zf=`#ifndef FLAT_SHADED
1670
+ #endif`,_p=`#ifndef FLAT_SHADED
1671
1671
  varying vec3 vNormal;
1672
1672
  #ifdef USE_TANGENT
1673
1673
  varying vec3 vTangent;
1674
1674
  varying vec3 vBitangent;
1675
1675
  #endif
1676
- #endif`,$f=`#ifndef FLAT_SHADED
1676
+ #endif`,xp=`#ifndef FLAT_SHADED
1677
1677
  varying vec3 vNormal;
1678
1678
  #ifdef USE_TANGENT
1679
1679
  varying vec3 vTangent;
1680
1680
  varying vec3 vBitangent;
1681
1681
  #endif
1682
- #endif`,Jf=`#ifndef FLAT_SHADED
1682
+ #endif`,yp=`#ifndef FLAT_SHADED
1683
1683
  vNormal = normalize( transformedNormal );
1684
1684
  #ifdef USE_TANGENT
1685
1685
  vTangent = normalize( transformedTangent );
@@ -1688,7 +1688,7 @@ vec3 nonPerturbedNormal = normal;`,Yf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1688
1688
  vBitangent = - vBitangent;
1689
1689
  #endif
1690
1690
  #endif
1691
- #endif`,Kf=`#ifdef USE_NORMALMAP
1691
+ #endif`,vp=`#ifdef USE_NORMALMAP
1692
1692
  uniform sampler2D normalMap;
1693
1693
  uniform vec2 normalScale;
1694
1694
  #endif
@@ -1710,13 +1710,13 @@ vec3 nonPerturbedNormal = normal;`,Yf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1710
1710
  float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1711
1711
  return mat3( T * scale, B * scale, N );
1712
1712
  }
1713
- #endif`,jf=`#ifdef USE_CLEARCOAT
1713
+ #endif`,bp=`#ifdef USE_CLEARCOAT
1714
1714
  vec3 clearcoatNormal = nonPerturbedNormal;
1715
- #endif`,Qf=`#ifdef USE_CLEARCOAT_NORMALMAP
1715
+ #endif`,Mp=`#ifdef USE_CLEARCOAT_NORMALMAP
1716
1716
  vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1717
1717
  clearcoatMapN.xy *= clearcoatNormalScale;
1718
1718
  clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1719
- #endif`,ep=`#ifdef USE_CLEARCOATMAP
1719
+ #endif`,Sp=`#ifdef USE_CLEARCOATMAP
1720
1720
  uniform sampler2D clearcoatMap;
1721
1721
  #endif
1722
1722
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1725,18 +1725,18 @@ vec3 nonPerturbedNormal = normal;`,Yf=`#ifdef USE_NORMALMAP_OBJECTSPACE
1725
1725
  #endif
1726
1726
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1727
1727
  uniform sampler2D clearcoatRoughnessMap;
1728
- #endif`,tp=`#ifdef USE_IRIDESCENCEMAP
1728
+ #endif`,wp=`#ifdef USE_IRIDESCENCEMAP
1729
1729
  uniform sampler2D iridescenceMap;
1730
1730
  #endif
1731
1731
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1732
1732
  uniform sampler2D iridescenceThicknessMap;
1733
- #endif`,np=`#ifdef OPAQUE
1733
+ #endif`,Ep=`#ifdef OPAQUE
1734
1734
  diffuseColor.a = 1.0;
1735
1735
  #endif
1736
1736
  #ifdef USE_TRANSMISSION
1737
1737
  diffuseColor.a *= material.transmissionAlpha;
1738
1738
  #endif
1739
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,ip=`vec3 packNormalToRGB( const in vec3 normal ) {
1739
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Tp=`vec3 packNormalToRGB( const in vec3 normal ) {
1740
1740
  return normalize( normal ) * 0.5 + 0.5;
1741
1741
  }
1742
1742
  vec3 unpackRGBToNormal( const in vec3 rgb ) {
@@ -1815,9 +1815,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1815
1815
  #else
1816
1816
  return ( near * far ) / ( ( far - near ) * depth - far );
1817
1817
  #endif
1818
- }`,sp=`#ifdef PREMULTIPLIED_ALPHA
1818
+ }`,Ap=`#ifdef PREMULTIPLIED_ALPHA
1819
1819
  gl_FragColor.rgb *= gl_FragColor.a;
1820
- #endif`,rp=`vec4 mvPosition = vec4( transformed, 1.0 );
1820
+ #endif`,Rp=`vec4 mvPosition = vec4( transformed, 1.0 );
1821
1821
  #ifdef USE_BATCHING
1822
1822
  mvPosition = batchingMatrix * mvPosition;
1823
1823
  #endif
@@ -1825,22 +1825,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
1825
1825
  mvPosition = instanceMatrix * mvPosition;
1826
1826
  #endif
1827
1827
  mvPosition = modelViewMatrix * mvPosition;
1828
- gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
1828
+ gl_Position = projectionMatrix * mvPosition;`,Cp=`#ifdef DITHERING
1829
1829
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1830
- #endif`,op=`#ifdef DITHERING
1830
+ #endif`,Pp=`#ifdef DITHERING
1831
1831
  vec3 dithering( vec3 color ) {
1832
1832
  float grid_position = rand( gl_FragCoord.xy );
1833
1833
  vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1834
1834
  dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1835
1835
  return color + dither_shift_RGB;
1836
1836
  }
1837
- #endif`,lp=`float roughnessFactor = roughness;
1837
+ #endif`,Ip=`float roughnessFactor = roughness;
1838
1838
  #ifdef USE_ROUGHNESSMAP
1839
1839
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1840
1840
  roughnessFactor *= texelRoughness.g;
1841
- #endif`,cp=`#ifdef USE_ROUGHNESSMAP
1841
+ #endif`,Lp=`#ifdef USE_ROUGHNESSMAP
1842
1842
  uniform sampler2D roughnessMap;
1843
- #endif`,hp=`#if NUM_SPOT_LIGHT_COORDS > 0
1843
+ #endif`,Dp=`#if NUM_SPOT_LIGHT_COORDS > 0
1844
1844
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1845
1845
  #endif
1846
1846
  #if NUM_SPOT_LIGHT_MAPS > 0
@@ -2094,7 +2094,7 @@ gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
2094
2094
  }
2095
2095
  #endif
2096
2096
  #endif
2097
- #endif`,up=`#if NUM_SPOT_LIGHT_COORDS > 0
2097
+ #endif`,Np=`#if NUM_SPOT_LIGHT_COORDS > 0
2098
2098
  uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
2099
2099
  varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
2100
2100
  #endif
@@ -2139,7 +2139,7 @@ gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
2139
2139
  };
2140
2140
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2141
2141
  #endif
2142
- #endif`,dp=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2142
+ #endif`,Up=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
2143
2143
  #ifdef HAS_NORMAL
2144
2144
  vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
2145
2145
  #else
@@ -2179,7 +2179,7 @@ gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
2179
2179
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2180
2180
  }
2181
2181
  #pragma unroll_loop_end
2182
- #endif`,fp=`float getShadowMask() {
2182
+ #endif`,Fp=`float getShadowMask() {
2183
2183
  float shadow = 1.0;
2184
2184
  #ifdef USE_SHADOWMAP
2185
2185
  #if NUM_SUN_LIGHT_SHADOWS > 0
@@ -2220,12 +2220,12 @@ gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
2220
2220
  #endif
2221
2221
  #endif
2222
2222
  return shadow;
2223
- }`,pp=`#ifdef USE_SKINNING
2223
+ }`,Op=`#ifdef USE_SKINNING
2224
2224
  mat4 boneMatX = getBoneMatrix( skinIndex.x );
2225
2225
  mat4 boneMatY = getBoneMatrix( skinIndex.y );
2226
2226
  mat4 boneMatZ = getBoneMatrix( skinIndex.z );
2227
2227
  mat4 boneMatW = getBoneMatrix( skinIndex.w );
2228
- #endif`,mp=`#ifdef USE_SKINNING
2228
+ #endif`,Bp=`#ifdef USE_SKINNING
2229
2229
  uniform mat4 bindMatrix;
2230
2230
  uniform mat4 bindMatrixInverse;
2231
2231
  uniform highp sampler2D boneTexture;
@@ -2240,7 +2240,7 @@ gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
2240
2240
  vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2241
2241
  return mat4( v1, v2, v3, v4 );
2242
2242
  }
2243
- #endif`,gp=`#ifdef USE_SKINNING
2243
+ #endif`,zp=`#ifdef USE_SKINNING
2244
2244
  vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2245
2245
  vec4 skinned = vec4( 0.0 );
2246
2246
  skinned += boneMatX * skinVertex * skinWeight.x;
@@ -2248,7 +2248,7 @@ gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
2248
2248
  skinned += boneMatZ * skinVertex * skinWeight.z;
2249
2249
  skinned += boneMatW * skinVertex * skinWeight.w;
2250
2250
  transformed = ( bindMatrixInverse * skinned ).xyz;
2251
- #endif`,_p=`#ifdef USE_SKINNING
2251
+ #endif`,kp=`#ifdef USE_SKINNING
2252
2252
  mat4 skinMatrix = mat4( 0.0 );
2253
2253
  skinMatrix += skinWeight.x * boneMatX;
2254
2254
  skinMatrix += skinWeight.y * boneMatY;
@@ -2259,17 +2259,17 @@ gl_Position = projectionMatrix * mvPosition;`,ap=`#ifdef DITHERING
2259
2259
  #ifdef USE_TANGENT
2260
2260
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2261
2261
  #endif
2262
- #endif`,xp=`float specularStrength;
2262
+ #endif`,Vp=`float specularStrength;
2263
2263
  #ifdef USE_SPECULARMAP
2264
2264
  vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2265
2265
  specularStrength = texelSpecular.r;
2266
2266
  #else
2267
2267
  specularStrength = 1.0;
2268
- #endif`,yp=`#ifdef USE_SPECULARMAP
2268
+ #endif`,Gp=`#ifdef USE_SPECULARMAP
2269
2269
  uniform sampler2D specularMap;
2270
- #endif`,vp=`#if defined( TONE_MAPPING )
2270
+ #endif`,Hp=`#if defined( TONE_MAPPING )
2271
2271
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2272
- #endif`,Mp=`#ifndef saturate
2272
+ #endif`,Wp=`#ifndef saturate
2273
2273
  #define saturate( a ) clamp( a, 0.0, 1.0 )
2274
2274
  #endif
2275
2275
  uniform float toneMappingExposure;
@@ -2366,7 +2366,7 @@ vec3 NeutralToneMapping( vec3 color ) {
2366
2366
  float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2367
2367
  return mix( color, vec3( newPeak ), g );
2368
2368
  }
2369
- vec3 CustomToneMapping( vec3 color ) { return color; }`,bp=`#ifdef USE_TRANSMISSION
2369
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Xp=`#ifdef USE_TRANSMISSION
2370
2370
  material.transmission = transmission;
2371
2371
  material.transmissionAlpha = 1.0;
2372
2372
  material.thickness = thickness;
@@ -2387,7 +2387,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bp=`#ifdef USE_TRANSMISS
2387
2387
  material.attenuationColor, material.attenuationDistance );
2388
2388
  material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2389
2389
  totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2390
- #endif`,Sp=`#ifdef USE_TRANSMISSION
2390
+ #endif`,qp=`#ifdef USE_TRANSMISSION
2391
2391
  uniform float transmission;
2392
2392
  uniform float thickness;
2393
2393
  uniform float attenuationDistance;
@@ -2513,7 +2513,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bp=`#ifdef USE_TRANSMISS
2513
2513
  float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2514
2514
  return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2515
2515
  }
2516
- #endif`,Ep=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2516
+ #endif`,Yp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2517
2517
  varying vec2 vUv;
2518
2518
  #endif
2519
2519
  #ifdef USE_MAP
@@ -2586,7 +2586,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bp=`#ifdef USE_TRANSMISS
2586
2586
  #ifdef USE_THICKNESSMAP
2587
2587
  uniform mat3 thicknessMapTransform;
2588
2588
  varying vec2 vThicknessMapUv;
2589
- #endif`,wp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2589
+ #endif`,Zp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2590
2590
  varying vec2 vUv;
2591
2591
  #endif
2592
2592
  #ifdef USE_MAP
@@ -2684,7 +2684,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bp=`#ifdef USE_TRANSMISS
2684
2684
  #ifdef USE_THICKNESSMAP
2685
2685
  uniform mat3 thicknessMapTransform;
2686
2686
  varying vec2 vThicknessMapUv;
2687
- #endif`,Tp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2687
+ #endif`,$p=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2688
2688
  vUv = vec3( uv, 1 ).xy;
2689
2689
  #endif
2690
2690
  #ifdef USE_MAP
@@ -2758,7 +2758,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bp=`#ifdef USE_TRANSMISS
2758
2758
  #endif
2759
2759
  #ifdef USE_THICKNESSMAP
2760
2760
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2761
- #endif`,Ap=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2761
+ #endif`,Jp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2762
2762
  vec4 worldPosition = vec4( transformed, 1.0 );
2763
2763
  #ifdef USE_BATCHING
2764
2764
  worldPosition = batchingMatrix * worldPosition;
@@ -2767,12 +2767,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,bp=`#ifdef USE_TRANSMISS
2767
2767
  worldPosition = instanceMatrix * worldPosition;
2768
2768
  #endif
2769
2769
  worldPosition = modelMatrix * worldPosition;
2770
- #endif`,Rp=`varying vec2 vUv;
2770
+ #endif`,Kp=`varying vec2 vUv;
2771
2771
  uniform mat3 uvTransform;
2772
2772
  void main() {
2773
2773
  vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2774
2774
  gl_Position = vec4( position.xy, 1.0, 1.0 );
2775
- }`,Cp=`uniform sampler2D t2D;
2775
+ }`,jp=`uniform sampler2D t2D;
2776
2776
  uniform float backgroundIntensity;
2777
2777
  varying vec2 vUv;
2778
2778
  void main() {
@@ -2784,14 +2784,14 @@ void main() {
2784
2784
  gl_FragColor = texColor;
2785
2785
  #include <tonemapping_fragment>
2786
2786
  #include <colorspace_fragment>
2787
- }`,Pp=`varying vec3 vWorldDirection;
2787
+ }`,Qp=`varying vec3 vWorldDirection;
2788
2788
  #include <common>
2789
2789
  void main() {
2790
2790
  vWorldDirection = transformDirection( position, modelMatrix );
2791
2791
  #include <begin_vertex>
2792
2792
  #include <project_vertex>
2793
2793
  gl_Position.z = gl_Position.w;
2794
- }`,Ip=`uniform float backgroundBlurriness;
2794
+ }`,em=`uniform float backgroundBlurriness;
2795
2795
  uniform float backgroundIntensity;
2796
2796
  uniform mat3 backgroundRotation;
2797
2797
  varying vec3 vWorldDirection;
@@ -2806,14 +2806,14 @@ void main() {
2806
2806
  gl_FragColor = texColor;
2807
2807
  #include <tonemapping_fragment>
2808
2808
  #include <colorspace_fragment>
2809
- }`,Lp=`varying vec3 vWorldDirection;
2809
+ }`,tm=`varying vec3 vWorldDirection;
2810
2810
  #include <common>
2811
2811
  void main() {
2812
2812
  vWorldDirection = transformDirection( position, modelMatrix );
2813
2813
  #include <begin_vertex>
2814
2814
  #include <project_vertex>
2815
2815
  gl_Position.z = gl_Position.w;
2816
- }`,Dp=`uniform samplerCube tCube;
2816
+ }`,nm=`uniform samplerCube tCube;
2817
2817
  uniform float tFlip;
2818
2818
  uniform float opacity;
2819
2819
  varying vec3 vWorldDirection;
@@ -2823,7 +2823,7 @@ void main() {
2823
2823
  gl_FragColor.a *= opacity;
2824
2824
  #include <tonemapping_fragment>
2825
2825
  #include <colorspace_fragment>
2826
- }`,Np=`#include <common>
2826
+ }`,im=`#include <common>
2827
2827
  #include <batching_pars_vertex>
2828
2828
  #include <uv_pars_vertex>
2829
2829
  #include <displacementmap_pars_vertex>
@@ -2850,7 +2850,7 @@ void main() {
2850
2850
  #include <logdepthbuf_vertex>
2851
2851
  #include <clipping_planes_vertex>
2852
2852
  vHighPrecisionZW = gl_Position.zw;
2853
- }`,Up=`#if DEPTH_PACKING == 3200
2853
+ }`,sm=`#if DEPTH_PACKING == 3200
2854
2854
  uniform float opacity;
2855
2855
  #endif
2856
2856
  #include <common>
@@ -2888,7 +2888,7 @@ void main() {
2888
2888
  #elif DEPTH_PACKING == 3203
2889
2889
  gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2890
2890
  #endif
2891
- }`,Fp=`#define DISTANCE
2891
+ }`,rm=`#define DISTANCE
2892
2892
  varying vec3 vWorldPosition;
2893
2893
  #include <common>
2894
2894
  #include <batching_pars_vertex>
@@ -2915,7 +2915,7 @@ void main() {
2915
2915
  #include <worldpos_vertex>
2916
2916
  #include <clipping_planes_vertex>
2917
2917
  vWorldPosition = worldPosition.xyz;
2918
- }`,Op=`#define DISTANCE
2918
+ }`,om=`#define DISTANCE
2919
2919
  uniform vec3 referencePosition;
2920
2920
  uniform float nearDistance;
2921
2921
  uniform float farDistance;
@@ -2938,13 +2938,13 @@ void main() {
2938
2938
  dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2939
2939
  dist = saturate( dist );
2940
2940
  gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
2941
- }`,Bp=`varying vec3 vWorldDirection;
2941
+ }`,am=`varying vec3 vWorldDirection;
2942
2942
  #include <common>
2943
2943
  void main() {
2944
2944
  vWorldDirection = transformDirection( position, modelMatrix );
2945
2945
  #include <begin_vertex>
2946
2946
  #include <project_vertex>
2947
- }`,zp=`uniform sampler2D tEquirect;
2947
+ }`,lm=`uniform sampler2D tEquirect;
2948
2948
  varying vec3 vWorldDirection;
2949
2949
  #include <common>
2950
2950
  void main() {
@@ -2953,7 +2953,7 @@ void main() {
2953
2953
  gl_FragColor = texture2D( tEquirect, sampleUV );
2954
2954
  #include <tonemapping_fragment>
2955
2955
  #include <colorspace_fragment>
2956
- }`,kp=`uniform float scale;
2956
+ }`,cm=`uniform float scale;
2957
2957
  attribute float lineDistance;
2958
2958
  varying float vLineDistance;
2959
2959
  #include <common>
@@ -2975,7 +2975,7 @@ void main() {
2975
2975
  #include <logdepthbuf_vertex>
2976
2976
  #include <clipping_planes_vertex>
2977
2977
  #include <fog_vertex>
2978
- }`,Vp=`uniform vec3 diffuse;
2978
+ }`,hm=`uniform vec3 diffuse;
2979
2979
  uniform float opacity;
2980
2980
  uniform float dashSize;
2981
2981
  uniform float totalSize;
@@ -3003,7 +3003,7 @@ void main() {
3003
3003
  #include <colorspace_fragment>
3004
3004
  #include <fog_fragment>
3005
3005
  #include <premultiplied_alpha_fragment>
3006
- }`,Gp=`#include <common>
3006
+ }`,um=`#include <common>
3007
3007
  #include <batching_pars_vertex>
3008
3008
  #include <uv_pars_vertex>
3009
3009
  #include <envmap_pars_vertex>
@@ -3035,7 +3035,7 @@ void main() {
3035
3035
  #include <worldpos_vertex>
3036
3036
  #include <envmap_vertex>
3037
3037
  #include <fog_vertex>
3038
- }`,Hp=`uniform vec3 diffuse;
3038
+ }`,dm=`uniform vec3 diffuse;
3039
3039
  uniform float opacity;
3040
3040
  #ifndef FLAT_SHADED
3041
3041
  varying vec3 vNormal;
@@ -3083,7 +3083,7 @@ void main() {
3083
3083
  #include <fog_fragment>
3084
3084
  #include <premultiplied_alpha_fragment>
3085
3085
  #include <dithering_fragment>
3086
- }`,Wp=`#define LAMBERT
3086
+ }`,fm=`#define LAMBERT
3087
3087
  varying vec3 vViewPosition;
3088
3088
  #include <common>
3089
3089
  #include <batching_pars_vertex>
@@ -3122,7 +3122,7 @@ void main() {
3122
3122
  #include <envmap_vertex>
3123
3123
  #include <shadowmap_vertex>
3124
3124
  #include <fog_vertex>
3125
- }`,Xp=`#define LAMBERT
3125
+ }`,pm=`#define LAMBERT
3126
3126
  uniform vec3 diffuse;
3127
3127
  uniform vec3 emissive;
3128
3128
  uniform float opacity;
@@ -3179,7 +3179,7 @@ void main() {
3179
3179
  #include <fog_fragment>
3180
3180
  #include <premultiplied_alpha_fragment>
3181
3181
  #include <dithering_fragment>
3182
- }`,qp=`#define MATCAP
3182
+ }`,mm=`#define MATCAP
3183
3183
  varying vec3 vViewPosition;
3184
3184
  #include <common>
3185
3185
  #include <batching_pars_vertex>
@@ -3213,7 +3213,7 @@ void main() {
3213
3213
  #include <clipping_planes_vertex>
3214
3214
  #include <fog_vertex>
3215
3215
  vViewPosition = - mvPosition.xyz;
3216
- }`,Yp=`#define MATCAP
3216
+ }`,gm=`#define MATCAP
3217
3217
  uniform vec3 diffuse;
3218
3218
  uniform float opacity;
3219
3219
  uniform sampler2D matcap;
@@ -3259,7 +3259,7 @@ void main() {
3259
3259
  #include <fog_fragment>
3260
3260
  #include <premultiplied_alpha_fragment>
3261
3261
  #include <dithering_fragment>
3262
- }`,Zp=`#define NORMAL
3262
+ }`,_m=`#define NORMAL
3263
3263
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3264
3264
  varying vec3 vViewPosition;
3265
3265
  #endif
@@ -3292,7 +3292,7 @@ void main() {
3292
3292
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3293
3293
  vViewPosition = - mvPosition.xyz;
3294
3294
  #endif
3295
- }`,$p=`#define NORMAL
3295
+ }`,xm=`#define NORMAL
3296
3296
  uniform float opacity;
3297
3297
  #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3298
3298
  varying vec3 vViewPosition;
@@ -3313,7 +3313,7 @@ void main() {
3313
3313
  #ifdef OPAQUE
3314
3314
  gl_FragColor.a = 1.0;
3315
3315
  #endif
3316
- }`,Jp=`#define PHONG
3316
+ }`,ym=`#define PHONG
3317
3317
  varying vec3 vViewPosition;
3318
3318
  #include <common>
3319
3319
  #include <batching_pars_vertex>
@@ -3352,7 +3352,7 @@ void main() {
3352
3352
  #include <envmap_vertex>
3353
3353
  #include <shadowmap_vertex>
3354
3354
  #include <fog_vertex>
3355
- }`,Kp=`#define PHONG
3355
+ }`,vm=`#define PHONG
3356
3356
  uniform vec3 diffuse;
3357
3357
  uniform vec3 emissive;
3358
3358
  uniform vec3 specular;
@@ -3411,7 +3411,7 @@ void main() {
3411
3411
  #include <fog_fragment>
3412
3412
  #include <premultiplied_alpha_fragment>
3413
3413
  #include <dithering_fragment>
3414
- }`,jp=`#define STANDARD
3414
+ }`,bm=`#define STANDARD
3415
3415
  varying vec3 vViewPosition;
3416
3416
  #ifdef USE_TRANSMISSION
3417
3417
  varying vec3 vWorldPosition;
@@ -3454,7 +3454,7 @@ void main() {
3454
3454
  #ifdef USE_TRANSMISSION
3455
3455
  vWorldPosition = worldPosition.xyz;
3456
3456
  #endif
3457
- }`,Qp=`#define STANDARD
3457
+ }`,Mm=`#define STANDARD
3458
3458
  #ifdef PHYSICAL
3459
3459
  #define IOR
3460
3460
  #define USE_SPECULAR
@@ -3587,7 +3587,7 @@ void main() {
3587
3587
  #include <fog_fragment>
3588
3588
  #include <premultiplied_alpha_fragment>
3589
3589
  #include <dithering_fragment>
3590
- }`,em=`#define TOON
3590
+ }`,Sm=`#define TOON
3591
3591
  varying vec3 vViewPosition;
3592
3592
  #include <common>
3593
3593
  #include <batching_pars_vertex>
@@ -3624,7 +3624,7 @@ void main() {
3624
3624
  #include <worldpos_vertex>
3625
3625
  #include <shadowmap_vertex>
3626
3626
  #include <fog_vertex>
3627
- }`,tm=`#define TOON
3627
+ }`,wm=`#define TOON
3628
3628
  uniform vec3 diffuse;
3629
3629
  uniform vec3 emissive;
3630
3630
  uniform float opacity;
@@ -3676,7 +3676,7 @@ void main() {
3676
3676
  #include <fog_fragment>
3677
3677
  #include <premultiplied_alpha_fragment>
3678
3678
  #include <dithering_fragment>
3679
- }`,nm=`uniform float size;
3679
+ }`,Em=`uniform float size;
3680
3680
  uniform float scale;
3681
3681
  #include <common>
3682
3682
  #include <color_pars_vertex>
@@ -3707,7 +3707,7 @@ void main() {
3707
3707
  #include <clipping_planes_vertex>
3708
3708
  #include <worldpos_vertex>
3709
3709
  #include <fog_vertex>
3710
- }`,im=`uniform vec3 diffuse;
3710
+ }`,Tm=`uniform vec3 diffuse;
3711
3711
  uniform float opacity;
3712
3712
  #include <common>
3713
3713
  #include <color_pars_fragment>
@@ -3732,7 +3732,7 @@ void main() {
3732
3732
  #include <colorspace_fragment>
3733
3733
  #include <fog_fragment>
3734
3734
  #include <premultiplied_alpha_fragment>
3735
- }`,sm=`#include <common>
3735
+ }`,Am=`#include <common>
3736
3736
  #include <batching_pars_vertex>
3737
3737
  #include <fog_pars_vertex>
3738
3738
  #include <morphtarget_pars_vertex>
@@ -3755,7 +3755,7 @@ void main() {
3755
3755
  #include <worldpos_vertex>
3756
3756
  #include <shadowmap_vertex>
3757
3757
  #include <fog_vertex>
3758
- }`,rm=`uniform vec3 color;
3758
+ }`,Rm=`uniform vec3 color;
3759
3759
  uniform float opacity;
3760
3760
  #include <common>
3761
3761
  #include <fog_pars_fragment>
@@ -3771,7 +3771,7 @@ void main() {
3771
3771
  #include <colorspace_fragment>
3772
3772
  #include <fog_fragment>
3773
3773
  #include <premultiplied_alpha_fragment>
3774
- }`,am=`uniform float rotation;
3774
+ }`,Cm=`uniform float rotation;
3775
3775
  uniform vec2 center;
3776
3776
  #include <common>
3777
3777
  #include <uv_pars_vertex>
@@ -3795,7 +3795,7 @@ void main() {
3795
3795
  #include <logdepthbuf_vertex>
3796
3796
  #include <clipping_planes_vertex>
3797
3797
  #include <fog_vertex>
3798
- }`,om=`uniform vec3 diffuse;
3798
+ }`,Pm=`uniform vec3 diffuse;
3799
3799
  uniform float opacity;
3800
3800
  #include <common>
3801
3801
  #include <uv_pars_fragment>
@@ -3820,7 +3820,7 @@ void main() {
3820
3820
  #include <tonemapping_fragment>
3821
3821
  #include <colorspace_fragment>
3822
3822
  #include <fog_fragment>
3823
- }`,He={alphahash_fragment:Rd,alphahash_pars_fragment:Cd,alphamap_fragment:Pd,alphamap_pars_fragment:Id,alphatest_fragment:Ld,alphatest_pars_fragment:Dd,aomap_fragment:Nd,aomap_pars_fragment:Ud,batching_pars_vertex:Fd,batching_vertex:Od,begin_vertex:Bd,beginnormal_vertex:zd,bsdfs:kd,iridescence_fragment:Vd,bumpmap_pars_fragment:Gd,clipping_planes_fragment:Hd,clipping_planes_pars_fragment:Wd,clipping_planes_pars_vertex:Xd,clipping_planes_vertex:qd,color_fragment:Yd,color_pars_fragment:Zd,color_pars_vertex:$d,color_vertex:Jd,common:Kd,defaultnormal_vertex:jd,displacementmap_pars_vertex:Qd,displacementmap_vertex:ef,emissivemap_fragment:tf,emissivemap_pars_fragment:nf,colorspace_fragment:sf,colorspace_pars_fragment:rf,envmap_fragment:af,envmap_common_pars_fragment:of,envmap_pars_fragment:lf,envmap_pars_vertex:cf,envmap_physical_pars_fragment:vf,envmap_vertex:hf,fog_vertex:uf,fog_pars_vertex:df,fog_fragment:ff,fog_pars_fragment:pf,gradientmap_pars_fragment:mf,lightmap_pars_fragment:gf,lights_lambert_fragment:_f,lights_lambert_pars_fragment:xf,lights_pars_begin:yf,lights_toon_fragment:Mf,lights_toon_pars_fragment:bf,lights_phong_fragment:Sf,lights_phong_pars_fragment:Ef,lights_physical_fragment:wf,lights_physical_pars_fragment:Tf,lights_fragment_begin:Af,lights_fragment_maps:Rf,lights_fragment_end:Cf,lightprobes_pars_fragment:Pf,logdepthbuf_fragment:If,logdepthbuf_pars_fragment:Lf,logdepthbuf_pars_vertex:Df,logdepthbuf_vertex:Nf,map_fragment:Uf,map_pars_fragment:Ff,map_particle_fragment:Of,map_particle_pars_fragment:Bf,metalnessmap_fragment:zf,metalnessmap_pars_fragment:kf,morphinstance_vertex:Vf,morphcolor_vertex:Gf,morphnormal_vertex:Hf,morphtarget_pars_vertex:Wf,morphtarget_vertex:Xf,normal_fragment_begin:qf,normal_fragment_maps:Yf,normal_pars_fragment:Zf,normal_pars_vertex:$f,normal_vertex:Jf,normalmap_pars_fragment:Kf,clearcoat_normal_fragment_begin:jf,clearcoat_normal_fragment_maps:Qf,clearcoat_pars_fragment:ep,iridescence_pars_fragment:tp,opaque_fragment:np,packing:ip,premultiplied_alpha_fragment:sp,project_vertex:rp,dithering_fragment:ap,dithering_pars_fragment:op,roughnessmap_fragment:lp,roughnessmap_pars_fragment:cp,shadowmap_pars_fragment:hp,shadowmap_pars_vertex:up,shadowmap_vertex:dp,shadowmask_pars_fragment:fp,skinbase_vertex:pp,skinning_pars_vertex:mp,skinning_vertex:gp,skinnormal_vertex:_p,specularmap_fragment:xp,specularmap_pars_fragment:yp,tonemapping_fragment:vp,tonemapping_pars_fragment:Mp,transmission_fragment:bp,transmission_pars_fragment:Sp,uv_pars_fragment:Ep,uv_pars_vertex:wp,uv_vertex:Tp,worldpos_vertex:Ap,background_vert:Rp,background_frag:Cp,backgroundCube_vert:Pp,backgroundCube_frag:Ip,cube_vert:Lp,cube_frag:Dp,depth_vert:Np,depth_frag:Up,distance_vert:Fp,distance_frag:Op,equirect_vert:Bp,equirect_frag:zp,linedashed_vert:kp,linedashed_frag:Vp,meshbasic_vert:Gp,meshbasic_frag:Hp,meshlambert_vert:Wp,meshlambert_frag:Xp,meshmatcap_vert:qp,meshmatcap_frag:Yp,meshnormal_vert:Zp,meshnormal_frag:$p,meshphong_vert:Jp,meshphong_frag:Kp,meshphysical_vert:jp,meshphysical_frag:Qp,meshtoon_vert:em,meshtoon_frag:tm,points_vert:nm,points_frag:im,shadow_vert:sm,shadow_frag:rm,sprite_vert:am,sprite_frag:om},me={common:{diffuse:{value:new ze(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Oe}},envmap:{envMap:{value:null},envMapRotation:{value:new Oe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Oe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Oe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Oe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Oe},normalScale:{value:new Fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Oe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Oe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Oe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Oe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ze(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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:[]},probesMin:{value:[]},probesMax:{value:[]},probesResolution:{value:[]}},points:{diffuse:{value:new ze(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0},uvTransform:{value:new Oe}},sprite:{diffuse:{value:new ze(16777215)},opacity:{value:1},center:{value:new Fe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Oe},alphaMap:{value:null},alphaMapTransform:{value:new Oe},alphaTest:{value:0}}},En={basic:{uniforms:Ut([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.fog]),vertexShader:He.meshbasic_vert,fragmentShader:He.meshbasic_frag},lambert:{uniforms:Ut([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new ze(0)},envMapIntensity:{value:1}}]),vertexShader:He.meshlambert_vert,fragmentShader:He.meshlambert_frag},phong:{uniforms:Ut([me.common,me.specularmap,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.fog,me.lights,{emissive:{value:new ze(0)},specular:{value:new ze(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:He.meshphong_vert,fragmentShader:He.meshphong_frag},standard:{uniforms:Ut([me.common,me.envmap,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.roughnessmap,me.metalnessmap,me.fog,me.lights,{emissive:{value:new ze(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag},toon:{uniforms:Ut([me.common,me.aomap,me.lightmap,me.emissivemap,me.bumpmap,me.normalmap,me.displacementmap,me.gradientmap,me.fog,me.lights,{emissive:{value:new ze(0)}}]),vertexShader:He.meshtoon_vert,fragmentShader:He.meshtoon_frag},matcap:{uniforms:Ut([me.common,me.bumpmap,me.normalmap,me.displacementmap,me.fog,{matcap:{value:null}}]),vertexShader:He.meshmatcap_vert,fragmentShader:He.meshmatcap_frag},points:{uniforms:Ut([me.points,me.fog]),vertexShader:He.points_vert,fragmentShader:He.points_frag},dashed:{uniforms:Ut([me.common,me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:He.linedashed_vert,fragmentShader:He.linedashed_frag},depth:{uniforms:Ut([me.common,me.displacementmap]),vertexShader:He.depth_vert,fragmentShader:He.depth_frag},normal:{uniforms:Ut([me.common,me.bumpmap,me.normalmap,me.displacementmap,{opacity:{value:1}}]),vertexShader:He.meshnormal_vert,fragmentShader:He.meshnormal_frag},sprite:{uniforms:Ut([me.sprite,me.fog]),vertexShader:He.sprite_vert,fragmentShader:He.sprite_frag},background:{uniforms:{uvTransform:{value:new Oe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:He.background_vert,fragmentShader:He.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Oe}},vertexShader:He.backgroundCube_vert,fragmentShader:He.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:He.cube_vert,fragmentShader:He.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:He.equirect_vert,fragmentShader:He.equirect_frag},distance:{uniforms:Ut([me.common,me.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:He.distance_vert,fragmentShader:He.distance_frag},shadow:{uniforms:Ut([me.lights,me.fog,{color:{value:new ze(0)},opacity:{value:1}}]),vertexShader:He.shadow_vert,fragmentShader:He.shadow_frag}};En.physical={uniforms:Ut([En.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Oe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Oe},clearcoatNormalScale:{value:new Fe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Oe},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new Oe},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Oe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Oe},sheen:{value:0},sheenColor:{value:new ze(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Oe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Oe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Oe},transmissionSamplerSize:{value:new Fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Oe},attenuationDistance:{value:0},attenuationColor:{value:new ze(0)},specularColor:{value:new ze(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Oe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Oe},anisotropyVector:{value:new Fe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Oe}}]),vertexShader:He.meshphysical_vert,fragmentShader:He.meshphysical_frag};var Ka={r:0,b:0,g:0},lm=new ht,kh=new Oe;kh.set(-1,0,0,0,1,0,0,0,1);function cm(i,e,t,n,s,r){let a=new ze(0),o=s===!0?0:1,c,l,h=null,d=0,u=null;function m(S){let A=S.isScene===!0?S.background:null;if(A&&A.isTexture){let b=S.backgroundBlurriness>0;A=e.get(A,b)}return A}function _(S){let A=!1,b=m(S);b===null?p(a,o):b&&b.isColor&&(p(b,1),A=!0);let T=i.xr.getEnvironmentBlendMode();T==="additive"?t.buffers.color.setClear(0,0,0,1,r):T==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function y(S,A){let b=m(A);b&&b.isCubeTexture?(l===void 0&&(l=new en(new Zi(1,1,1),new vn({name:"BackgroundCubeMaterial",uniforms:Si(En.backgroundCube.uniforms),vertexShader:En.backgroundCube.vertexShader,fragmentShader:En.backgroundCube.fragmentShader,side:Vt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(T,E,g){this.matrixWorld.copyPosition(g.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=b,l.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(lm.makeRotationFromEuler(A.backgroundRotation)).transpose(),b.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(kh),l.material.toneMapped=Ze.getTransfer(b.colorSpace)!==nt,(h!==b||d!==b.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=b,d=b.version,u=i.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new en(new Cs(2,2),new vn({name:"BackgroundMaterial",uniforms:Si(En.background.uniforms),vertexShader:En.background.vertexShader,fragmentShader:En.background.fragmentShader,side:ii,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=b,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.toneMapped=Ze.getTransfer(b.colorSpace)!==nt,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(h!==b||d!==b.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=b,d=b.version,u=i.toneMapping),c.layers.enableAll(),S.unshift(c,c.geometry,c.material,0,0,null))}function p(S,A){S.getRGB(Ka,gl(i)),t.buffers.color.setClear(Ka.r,Ka.g,Ka.b,A,r)}function f(){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,A=1){a.set(S),o=A,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,p(a,o)},render:_,addToRenderList:y,dispose:f}}function hm(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,a=!1;function o(D,F,H,C,Y){let J=!1,z=d(D,C,H,F);r!==z&&(r=z,l(r.object)),J=m(D,C,H,Y),J&&_(D,C,H,Y),Y!==null&&e.update(Y,i.ELEMENT_ARRAY_BUFFER),(J||a)&&(a=!1,b(D,F,H,C),Y!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Y).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function d(D,F,H,C){let Y=C.wireframe===!0,J=n[F.id];J===void 0&&(J={},n[F.id]=J);let z=D.isInstancedMesh===!0?D.id:0,te=J[z];te===void 0&&(te={},J[z]=te);let W=te[H.id];W===void 0&&(W={},te[H.id]=W);let $=W[Y];return $===void 0&&($=u(c()),W[Y]=$),$}function u(D){let F=[],H=[],C=[];for(let Y=0;Y<t;Y++)F[Y]=0,H[Y]=0,C[Y]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:H,attributeDivisors:C,object:D,attributes:{},index:null}}function m(D,F,H,C){let Y=r.attributes,J=F.attributes,z=0,te=H.getAttributes();for(let W in te)if(te[W].location>=0){let ae=Y[W],_e=J[W];if(_e===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(_e=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(_e=D.instanceColor)),ae===void 0||ae.attribute!==_e||_e&&ae.data!==_e.data)return!0;z++}return r.attributesNum!==z||r.index!==C}function _(D,F,H,C){let Y={},J=F.attributes,z=0,te=H.getAttributes();for(let W in te)if(te[W].location>=0){let ae=J[W];ae===void 0&&(W==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),W==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor));let _e={};_e.attribute=ae,ae&&ae.data&&(_e.data=ae.data),Y[W]=_e,z++}r.attributes=Y,r.attributesNum=z,r.index=C}function y(){let D=r.newAttributes;for(let F=0,H=D.length;F<H;F++)D[F]=0}function p(D){f(D,0)}function f(D,F){let H=r.newAttributes,C=r.enabledAttributes,Y=r.attributeDivisors;H[D]=1,C[D]===0&&(i.enableVertexAttribArray(D),C[D]=1),Y[D]!==F&&(i.vertexAttribDivisor(D,F),Y[D]=F)}function S(){let D=r.newAttributes,F=r.enabledAttributes;for(let H=0,C=F.length;H<C;H++)F[H]!==D[H]&&(i.disableVertexAttribArray(H),F[H]=0)}function A(D,F,H,C,Y,J,z){z===!0?i.vertexAttribIPointer(D,F,H,Y,J):i.vertexAttribPointer(D,F,H,C,Y,J)}function b(D,F,H,C){y();let Y=C.attributes,J=H.getAttributes(),z=F.defaultAttributeValues;for(let te in J){let W=J[te];if(W.location>=0){let $=Y[te];if($===void 0&&(te==="instanceMatrix"&&D.instanceMatrix&&($=D.instanceMatrix),te==="instanceColor"&&D.instanceColor&&($=D.instanceColor)),$!==void 0){let ae=$.normalized,_e=$.itemSize,De=e.get($);if(De===void 0)continue;let j=De.buffer,pe=De.type,ye=De.bytesPerElement,Re=pe===i.INT||pe===i.UNSIGNED_INT||$.gpuType===pa;if($.isInterleavedBufferAttribute){let fe=$.data,Le=fe.isInterleavedBuffer===!0?fe.stride:fe.itemSize,pt=$.offset;if(fe.isInstancedInterleavedBuffer||fe.isInstancedBufferAttribute){for(let be=0;be<W.locationSize;be++)f(W.location+be,fe.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let be=0;be<W.locationSize;be++)p(W.location+be);i.bindBuffer(i.ARRAY_BUFFER,j);for(let be=0;be<W.locationSize;be++)A(W.location+be,_e/W.locationSize,pe,ae,Le*ye,(pt+_e/W.locationSize*be)*ye,Re)}else{if($.isInstancedBufferAttribute){for(let fe=0;fe<W.locationSize;fe++)f(W.location+fe,$.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let fe=0;fe<W.locationSize;fe++)p(W.location+fe);i.bindBuffer(i.ARRAY_BUFFER,j);for(let fe=0;fe<W.locationSize;fe++)A(W.location+fe,_e/W.locationSize,pe,ae,_e*ye,_e/W.locationSize*fe*ye,Re)}}else if(z!==void 0){let ae=z[te];if(ae!==void 0)switch(ae.length){case 2:i.vertexAttrib2fv(W.location,ae);break;case 3:i.vertexAttrib3fv(W.location,ae);break;case 4:i.vertexAttrib4fv(W.location,ae);break;default:i.vertexAttrib1fv(W.location,ae)}}}}S()}function T(){U();for(let D in n){let F=n[D];for(let H in F){let C=F[H];for(let Y in C){let J=C[Y];for(let z in J)h(J[z].object),delete J[z];delete C[Y]}}delete n[D]}}function E(D){if(n[D.id]===void 0)return;let F=n[D.id];for(let H in F){let C=F[H];for(let Y in C){let J=C[Y];for(let z in J)h(J[z].object),delete J[z];delete C[Y]}}delete n[D.id]}function g(D){for(let F in n){let H=n[F];for(let C in H){let Y=H[C];if(Y[D.id]===void 0)continue;let J=Y[D.id];for(let z in J)h(J[z].object),delete J[z];delete Y[D.id]}}}function M(D){for(let F in n){let H=n[F],C=D.isInstancedMesh===!0?D.id:0,Y=H[C];if(Y!==void 0){for(let J in Y){let z=Y[J];for(let te in z)h(z[te].object),delete z[te];delete Y[J]}delete H[C],Object.keys(H).length===0&&delete n[F]}}}function U(){I(),a=!0,r!==s&&(r=s,l(r.object))}function I(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:U,resetDefaultState:I,dispose:T,releaseStatesOfGeometry:E,releaseStatesOfObject:M,releaseStatesOfProgram:g,initAttributes:y,enableAttribute:p,disableUnusedAttributes:S}}function um(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function a(c,l,h){h!==0&&(i.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 u=0;for(let m=0;m<h;m++)u+=l[m];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function dm(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let g=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(g.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(g){return!(g!==gn&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(g){let M=g===mn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(g!==Xt&&g!==pn&&!M&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE))}function c(g){if(g==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";g="mediump"}return g==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",h=c(l);h!==l&&(Ie("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),u=t.logarithmicDepthBuffer===!0&&d===!1;t.reversedDepthBuffer===!0&&d===!1&&Ie("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&d===!0&&Ie("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),S=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),b=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),T=i.getParameter(i.MAX_SAMPLES),E=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:m,maxVertexTextures:_,maxTextureSize:y,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:S,maxVaryings:A,maxFragmentUniforms:b,maxSamples:T,samples:E}}function fm(i){let e=this,t=null,n=0,s=!1,r=!1,a=new Kt,o=new Oe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let m=d.length!==0||u||n!==0||s;return s=u,n=d.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,m){let _=d.clippingPlanes,y=d.clipIntersection,p=d.clipShadows,f=i.get(d);if(!s||_===null||_.length===0||r&&!p)r?h(null):l();else{let S=r?0:n,A=S*4,b=f.clippingState||null;c.value=b,b=h(_,u,A,m);for(let T=0;T!==A;++T)b[T]=t[T];f.clippingState=b,this.numIntersection=y?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(d,u,m,_){let y=d!==null?d.length:0,p=null;if(y!==0){if(p=c.value,_!==!0||p===null){let f=m+y*4,S=u.matrixWorldInverse;o.getNormalMatrix(S),(p===null||p.length<f)&&(p=new Float32Array(f));for(let A=0,b=m;A!==y;++A,b+=4)a.copy(d[A]).applyMatrix4(S,o),a.normal.toArray(p,b),p[b+3]=a.constant}c.value=p,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,p}}var qs=class extends Qt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new ws(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
3823
+ }`,Ye={alphahash_fragment:Kd,alphahash_pars_fragment:jd,alphamap_fragment:Qd,alphamap_pars_fragment:ef,alphatest_fragment:tf,alphatest_pars_fragment:nf,aomap_fragment:sf,aomap_pars_fragment:rf,batching_pars_vertex:of,batching_vertex:af,begin_vertex:lf,beginnormal_vertex:cf,bsdfs:hf,iridescence_fragment:uf,bumpmap_pars_fragment:df,clipping_planes_fragment:ff,clipping_planes_pars_fragment:pf,clipping_planes_pars_vertex:mf,clipping_planes_vertex:gf,color_fragment:_f,color_pars_fragment:xf,color_pars_vertex:yf,color_vertex:vf,common:bf,defaultnormal_vertex:Mf,displacementmap_pars_vertex:Sf,displacementmap_vertex:wf,emissivemap_fragment:Ef,emissivemap_pars_fragment:Tf,colorspace_fragment:Af,colorspace_pars_fragment:Rf,envmap_fragment:Cf,envmap_common_pars_fragment:Pf,envmap_pars_fragment:If,envmap_pars_vertex:Lf,envmap_physical_pars_fragment:Hf,envmap_vertex:Df,fog_vertex:Nf,fog_pars_vertex:Uf,fog_fragment:Ff,fog_pars_fragment:Of,gradientmap_pars_fragment:Bf,lightmap_pars_fragment:zf,lights_lambert_fragment:kf,lights_lambert_pars_fragment:Vf,lights_pars_begin:Gf,lights_toon_fragment:Wf,lights_toon_pars_fragment:Xf,lights_phong_fragment:qf,lights_phong_pars_fragment:Yf,lights_physical_fragment:Zf,lights_physical_pars_fragment:$f,lights_fragment_begin:Jf,lights_fragment_maps:Kf,lights_fragment_end:jf,lightprobes_pars_fragment:Qf,logdepthbuf_fragment:ep,logdepthbuf_pars_fragment:tp,logdepthbuf_pars_vertex:np,logdepthbuf_vertex:ip,map_fragment:sp,map_pars_fragment:rp,map_particle_fragment:op,map_particle_pars_fragment:ap,metalnessmap_fragment:lp,metalnessmap_pars_fragment:cp,morphinstance_vertex:hp,morphcolor_vertex:up,morphnormal_vertex:dp,morphtarget_pars_vertex:fp,morphtarget_vertex:pp,normal_fragment_begin:mp,normal_fragment_maps:gp,normal_pars_fragment:_p,normal_pars_vertex:xp,normal_vertex:yp,normalmap_pars_fragment:vp,clearcoat_normal_fragment_begin:bp,clearcoat_normal_fragment_maps:Mp,clearcoat_pars_fragment:Sp,iridescence_pars_fragment:wp,opaque_fragment:Ep,packing:Tp,premultiplied_alpha_fragment:Ap,project_vertex:Rp,dithering_fragment:Cp,dithering_pars_fragment:Pp,roughnessmap_fragment:Ip,roughnessmap_pars_fragment:Lp,shadowmap_pars_fragment:Dp,shadowmap_pars_vertex:Np,shadowmap_vertex:Up,shadowmask_pars_fragment:Fp,skinbase_vertex:Op,skinning_pars_vertex:Bp,skinning_vertex:zp,skinnormal_vertex:kp,specularmap_fragment:Vp,specularmap_pars_fragment:Gp,tonemapping_fragment:Hp,tonemapping_pars_fragment:Wp,transmission_fragment:Xp,transmission_pars_fragment:qp,uv_pars_fragment:Yp,uv_pars_vertex:Zp,uv_vertex:$p,worldpos_vertex:Jp,background_vert:Kp,background_frag:jp,backgroundCube_vert:Qp,backgroundCube_frag:em,cube_vert:tm,cube_frag:nm,depth_vert:im,depth_frag:sm,distance_vert:rm,distance_frag:om,equirect_vert:am,equirect_frag:lm,linedashed_vert:cm,linedashed_frag:hm,meshbasic_vert:um,meshbasic_frag:dm,meshlambert_vert:fm,meshlambert_frag:pm,meshmatcap_vert:mm,meshmatcap_frag:gm,meshnormal_vert:_m,meshnormal_frag:xm,meshphong_vert:ym,meshphong_frag:vm,meshphysical_vert:bm,meshphysical_frag:Mm,meshtoon_vert:Sm,meshtoon_frag:wm,points_vert:Em,points_frag:Tm,shadow_vert:Am,shadow_frag:Rm,sprite_vert:Cm,sprite_frag:Pm},be={common:{diffuse:{value:new We(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ge}},envmap:{envMap:{value:null},envMapRotation:{value:new Ge},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ge}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ge}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ge},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ge},normalScale:{value:new ke(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ge},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ge}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ge}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ge}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new We(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{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:[]},probesMin:{value:[]},probesMax:{value:[]},probesResolution:{value:[]}},points:{diffuse:{value:new We(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0},uvTransform:{value:new Ge}},sprite:{diffuse:{value:new We(16777215)},opacity:{value:1},center:{value:new ke(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}}},Ln={basic:{uniforms:Gt([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.fog]),vertexShader:Ye.meshbasic_vert,fragmentShader:Ye.meshbasic_frag},lambert:{uniforms:Gt([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new We(0)},envMapIntensity:{value:1}}]),vertexShader:Ye.meshlambert_vert,fragmentShader:Ye.meshlambert_frag},phong:{uniforms:Gt([be.common,be.specularmap,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.fog,be.lights,{emissive:{value:new We(0)},specular:{value:new We(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphong_vert,fragmentShader:Ye.meshphong_frag},standard:{uniforms:Gt([be.common,be.envmap,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.roughnessmap,be.metalnessmap,be.fog,be.lights,{emissive:{value:new We(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag},toon:{uniforms:Gt([be.common,be.aomap,be.lightmap,be.emissivemap,be.bumpmap,be.normalmap,be.displacementmap,be.gradientmap,be.fog,be.lights,{emissive:{value:new We(0)}}]),vertexShader:Ye.meshtoon_vert,fragmentShader:Ye.meshtoon_frag},matcap:{uniforms:Gt([be.common,be.bumpmap,be.normalmap,be.displacementmap,be.fog,{matcap:{value:null}}]),vertexShader:Ye.meshmatcap_vert,fragmentShader:Ye.meshmatcap_frag},points:{uniforms:Gt([be.points,be.fog]),vertexShader:Ye.points_vert,fragmentShader:Ye.points_frag},dashed:{uniforms:Gt([be.common,be.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ye.linedashed_vert,fragmentShader:Ye.linedashed_frag},depth:{uniforms:Gt([be.common,be.displacementmap]),vertexShader:Ye.depth_vert,fragmentShader:Ye.depth_frag},normal:{uniforms:Gt([be.common,be.bumpmap,be.normalmap,be.displacementmap,{opacity:{value:1}}]),vertexShader:Ye.meshnormal_vert,fragmentShader:Ye.meshnormal_frag},sprite:{uniforms:Gt([be.sprite,be.fog]),vertexShader:Ye.sprite_vert,fragmentShader:Ye.sprite_frag},background:{uniforms:{uvTransform:{value:new Ge},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ye.background_vert,fragmentShader:Ye.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ge}},vertexShader:Ye.backgroundCube_vert,fragmentShader:Ye.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ye.cube_vert,fragmentShader:Ye.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ye.equirect_vert,fragmentShader:Ye.equirect_frag},distance:{uniforms:Gt([be.common,be.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ye.distance_vert,fragmentShader:Ye.distance_frag},shadow:{uniforms:Gt([be.lights,be.fog,{color:{value:new We(0)},opacity:{value:1}}]),vertexShader:Ye.shadow_vert,fragmentShader:Ye.shadow_frag}};Ln.physical={uniforms:Gt([Ln.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ge},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ge},clearcoatNormalScale:{value:new ke(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ge},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new Ge},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ge},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ge},sheen:{value:0},sheenColor:{value:new We(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ge},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ge},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ge},transmissionSamplerSize:{value:new ke},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ge},attenuationDistance:{value:0},attenuationColor:{value:new We(0)},specularColor:{value:new We(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ge},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ge},anisotropyVector:{value:new ke},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ge}}]),vertexShader:Ye.meshphysical_vert,fragmentShader:Ye.meshphysical_frag};var ua={r:0,b:0,g:0},Im=new ft,su=new Ge;su.set(-1,0,0,0,1,0,0,0,1);function Lm(i,e,t,n,s,r){let o=new We(0),a=s===!0?0:1,c,l,h=null,d=0,u=null;function p(w){let A=w.isScene===!0?w.background:null;if(A&&A.isTexture){let S=w.backgroundBlurriness>0;A=e.get(A,S)}return A}function _(w){let A=!1,S=p(w);S===null?m(o,a):S&&S.isColor&&(m(S,1),A=!0);let M=i.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,r):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(w,A){let S=p(A);S&&S.isCubeTexture?(l===void 0&&(l=new Kt(new os(1,1,1),new Cn({name:"BackgroundCubeMaterial",uniforms:Ui(Ln.backgroundCube.uniforms),vertexShader:Ln.backgroundCube.vertexShader,fragmentShader:Ln.backgroundCube.fragmentShader,side:Zt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(M,E,g){this.matrixWorld.copyPosition(g.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=S,l.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Im.makeRotationFromEuler(A.backgroundRotation)).transpose(),S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(su),l.material.toneMapped=Qe.getTransfer(S.colorSpace)!==lt,(h!==S||d!==S.version||u!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new Kt(new Vs(2,2),new Cn({name:"BackgroundMaterial",uniforms:Ui(Ln.background.uniforms),vertexShader:Ln.background.vertexShader,fragmentShader:Ln.background.fragmentShader,side:gi,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=S,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.toneMapped=Qe.getTransfer(S.colorSpace)!==lt,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||d!==S.version||u!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,d=S.version,u=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function m(w,A){w.getRGB(ua,Dl(i)),t.buffers.color.setClear(ua.r,ua.g,ua.b,A,r)}function f(){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 o},setClearColor:function(w,A=1){o.set(w),a=A,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(w){a=w,m(o,a)},render:_,addToRenderList:x,dispose:f}}function Dm(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,o=!1;function a(D,U,z,I,q){let Z=!1,B=d(D,I,z,U);r!==B&&(r=B,l(r.object)),Z=p(D,I,z,q),Z&&_(D,I,z,q),q!==null&&e.update(q,i.ELEMENT_ARRAY_BUFFER),(Z||o)&&(o=!1,S(D,U,z,I),q!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(q).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function d(D,U,z,I){let q=I.wireframe===!0,Z=n[U.id];Z===void 0&&(Z={},n[U.id]=Z);let B=D.isInstancedMesh===!0?D.id:0,ee=Z[B];ee===void 0&&(ee={},Z[B]=ee);let C=ee[z.id];C===void 0&&(C={},ee[z.id]=C);let W=C[q];return W===void 0&&(W=u(c()),C[q]=W),W}function u(D){let U=[],z=[],I=[];for(let q=0;q<t;q++)U[q]=0,z[q]=0,I[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:U,enabledAttributes:z,attributeDivisors:I,object:D,attributes:{},index:null}}function p(D,U,z,I){let q=r.attributes,Z=U.attributes,B=0,ee=z.getAttributes();for(let C in ee)if(ee[C].location>=0){let K=q[C],ve=Z[C];if(ve===void 0&&(C==="instanceMatrix"&&D.instanceMatrix&&(ve=D.instanceMatrix),C==="instanceColor"&&D.instanceColor&&(ve=D.instanceColor)),K===void 0||K.attribute!==ve||ve&&K.data!==ve.data)return!0;B++}return r.attributesNum!==B||r.index!==I}function _(D,U,z,I){let q={},Z=U.attributes,B=0,ee=z.getAttributes();for(let C in ee)if(ee[C].location>=0){let K=Z[C];K===void 0&&(C==="instanceMatrix"&&D.instanceMatrix&&(K=D.instanceMatrix),C==="instanceColor"&&D.instanceColor&&(K=D.instanceColor));let ve={};ve.attribute=K,K&&K.data&&(ve.data=K.data),q[C]=ve,B++}r.attributes=q,r.attributesNum=B,r.index=I}function x(){let D=r.newAttributes;for(let U=0,z=D.length;U<z;U++)D[U]=0}function m(D){f(D,0)}function f(D,U){let z=r.newAttributes,I=r.enabledAttributes,q=r.attributeDivisors;z[D]=1,I[D]===0&&(i.enableVertexAttribArray(D),I[D]=1),q[D]!==U&&(i.vertexAttribDivisor(D,U),q[D]=U)}function w(){let D=r.newAttributes,U=r.enabledAttributes;for(let z=0,I=U.length;z<I;z++)U[z]!==D[z]&&(i.disableVertexAttribArray(z),U[z]=0)}function A(D,U,z,I,q,Z,B){B===!0?i.vertexAttribIPointer(D,U,z,q,Z):i.vertexAttribPointer(D,U,z,I,q,Z)}function S(D,U,z,I){x();let q=I.attributes,Z=z.getAttributes(),B=U.defaultAttributeValues;for(let ee in Z){let C=Z[ee];if(C.location>=0){let W=q[ee];if(W===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(W=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(W=D.instanceColor)),W!==void 0){let K=W.normalized,ve=W.itemSize,we=e.get(W);if(we===void 0)continue;let G=we.buffer,he=we.type,fe=we.bytesPerElement,Ee=he===i.INT||he===i.UNSIGNED_INT||W.gpuType===Ro;if(W.isInterleavedBufferAttribute){let le=W.data,ye=le.isInterleavedBuffer===!0?le.stride:le.itemSize,Ve=W.offset;if(le.isInstancedInterleavedBuffer||le.isInstancedBufferAttribute){for(let Me=0;Me<C.locationSize;Me++)f(C.location+Me,le.meshPerAttribute);D.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=le.meshPerAttribute*le.count)}else for(let Me=0;Me<C.locationSize;Me++)m(C.location+Me);i.bindBuffer(i.ARRAY_BUFFER,G);for(let Me=0;Me<C.locationSize;Me++)A(C.location+Me,ve/C.locationSize,he,K,ye*fe,(Ve+ve/C.locationSize*Me)*fe,Ee)}else{if(W.isInstancedBufferAttribute){for(let le=0;le<C.locationSize;le++)f(C.location+le,W.meshPerAttribute);D.isInstancedMesh!==!0&&I._maxInstanceCount===void 0&&(I._maxInstanceCount=W.meshPerAttribute*W.count)}else for(let le=0;le<C.locationSize;le++)m(C.location+le);i.bindBuffer(i.ARRAY_BUFFER,G);for(let le=0;le<C.locationSize;le++)A(C.location+le,ve/C.locationSize,he,K,ve*fe,ve/C.locationSize*le*fe,Ee)}}else if(B!==void 0){let K=B[ee];if(K!==void 0)switch(K.length){case 2:i.vertexAttrib2fv(C.location,K);break;case 3:i.vertexAttrib3fv(C.location,K);break;case 4:i.vertexAttrib4fv(C.location,K);break;default:i.vertexAttrib1fv(C.location,K)}}}}w()}function M(){N();for(let D in n){let U=n[D];for(let z in U){let I=U[z];for(let q in I){let Z=I[q];for(let B in Z)h(Z[B].object),delete Z[B];delete I[q]}}delete n[D]}}function E(D){if(n[D.id]===void 0)return;let U=n[D.id];for(let z in U){let I=U[z];for(let q in I){let Z=I[q];for(let B in Z)h(Z[B].object),delete Z[B];delete I[q]}}delete n[D.id]}function g(D){for(let U in n){let z=n[U];for(let I in z){let q=z[I];if(q[D.id]===void 0)continue;let Z=q[D.id];for(let B in Z)h(Z[B].object),delete Z[B];delete q[D.id]}}}function v(D){for(let U in n){let z=n[U],I=D.isInstancedMesh===!0?D.id:0,q=z[I];if(q!==void 0){for(let Z in q){let B=q[Z];for(let ee in B)h(B[ee].object),delete B[ee];delete q[Z]}delete z[I],Object.keys(z).length===0&&delete n[U]}}}function N(){R(),o=!0,r!==s&&(r=s,l(r.object))}function R(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:a,reset:N,resetDefaultState:R,dispose:M,releaseStatesOfGeometry:E,releaseStatesOfObject:v,releaseStatesOfProgram:g,initAttributes:x,enableAttribute:m,disableUnusedAttributes:w}}function Nm(i,e,t){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),t.update(l,n,1)}function o(c,l,h){h!==0&&(i.drawArraysInstanced(n,c,l,h),t.update(l,n,h))}function a(c,l,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let u=0;for(let p=0;p<h;p++)u+=l[p];t.update(u,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function Um(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){let g=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(g.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function o(g){return!(g!==En&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(g){let v=g===wn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(g!==jt&&g!==Sn&&!v&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE))}function c(g){if(g==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";g="mediump"}return g==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",h=c(l);h!==l&&(Ue("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),u=t.logarithmicDepthBuffer===!0&&d===!1;t.reversedDepthBuffer===!0&&d===!1&&Ue("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&d===!0&&Ue("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),M=i.getParameter(i.MAX_SAMPLES),E=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:_,maxTextureSize:x,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:w,maxVaryings:A,maxFragmentUniforms:S,maxSamples:M,samples:E}}function Fm(i){let e=this,t=null,n=0,s=!1,r=!1,o=new on,a=new Ge,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let p=d.length!==0||u||n!==0||s;return s=u,n=d.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){t=h(d,u,0)},this.setState=function(d,u,p){let _=d.clippingPlanes,x=d.clipIntersection,m=d.clipShadows,f=i.get(d);if(!s||_===null||_.length===0||r&&!m)r?h(null):l();else{let w=r?0:n,A=w*4,S=f.clippingState||null;c.value=S,S=h(_,u,A,p);for(let M=0;M!==A;++M)S[M]=t[M];f.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(d,u,p,_){let x=d!==null?d.length:0,m=null;if(x!==0){if(m=c.value,_!==!0||m===null){let f=p+x*4,w=u.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length<f)&&(m=new Float32Array(f));for(let A=0,S=p;A!==x;++A,S+=4)o.copy(d[A]).applyMatrix4(w,a),o.normal.toArray(m,S),m[S+3]=o.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}var sr=class extends ln{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},s=[n,n,n,n,n,n];this.texture=new Os(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
3824
3824
 
3825
3825
  varying vec3 vWorldDirection;
3826
3826
 
@@ -3855,9 +3855,9 @@ void main() {
3855
3855
  gl_FragColor = texture2D( tEquirect, sampleUV );
3856
3856
 
3857
3857
  }
3858
- `},s=new Zi(5,5,5),r=new vn({name:"CubemapFromEquirect",uniforms:Si(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Vt,blending:yi});r.uniforms.tEquirect.value=t;let a=new en(s,r),o=t.minFilter;return t.minFilter===kn&&(t.minFilter=kt),new Ki(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,s);e.setRenderTarget(r)}},xh=256,pm=3,mm=20,Vh=256,Gh=16,gm=3,_m=new B,xm=new ze,Qa=class i{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new Ki(1,10,null),this._boxMesh=new en(new Zi(5,5,5),null),this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null,this._integrationMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:a=256,position:o=_m}=r,c=this._renderer;this._setSize(a);let l=this._allocateTarget(),h=this._getSourceTarget(!0);t>0&&(h.texture.mipmapsAutoUpdate=!1);let d=c.autoClear,u=c.autoClearColor,m=c.autoClearDepth,_=c.autoClearStencil,y=e.background;c.autoClear=!0,c.autoClearColor=!0,c.autoClearDepth=!0,c.autoClearStencil=!0,y===null&&(e.background=c.getClearColor(xm));let p=new Ki(n,s,h);return p.position.copy(o),p.update(c,e),c.autoClear=d,c.autoClearColor=u,c.autoClearDepth=m,c.autoClearStencil=_,e.background=y,t>0&&(h.texture.mipmapsAutoUpdate=!0,this._blur(l,t)),this._applyPMREM(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Mh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=vh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._sourceTarget!==null&&this._sourceTarget.dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._integrationMaterial!==null&&this._integrationMaterial.dispose(),this._boxMesh.geometry.dispose()}static lodToRoughness(e,t){return t>0?1-Math.sqrt(1-e/t):0}_setSize(e){this._cubeSize=Math.max(xh,fl(e))}_fromTexture(e,t){e.mapping===Mi||e.mapping===ts?this._setSize(e.image.length===0?xh:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4);let n=t||this._allocateTarget();return this._textureToCubemap(e),this._applyPMREM(n),n}_allocateTarget(){let e=this._cubeSize,t=yh(e,!1,!1),n=Math.log2(e)-pm;for(let s=0;s<=n;s++)t.texture.mipmaps.push({width:e>>s,height:e>>s});return t.texture.name="PMREM",t.texture.isPMREMTexture=!0,t}_getSourceTarget(e=!1){let t=this._cubeSize,n=this._sourceTarget;return(n===null||n.width!==t||e&&n.depthBuffer===!1)&&(n!==null&&n.dispose(),this._sourceTarget=yh(t,!0,e)),this._sourceTarget}_compileMaterial(e){this._boxMesh.material=e,this._renderer.compile(this._boxMesh,this._cubeCamera.children[0])}_renderCube(e,t,n){let s=this._boxMesh,r=this._cubeCamera;s.material=n,r.renderTarget=e,r.activeMipmapLevel=t;let a=e.width>>t;e.viewport.set(0,0,a,a),r.update(this._renderer,s),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===Mi||e.mapping===ts?(this._cubemapMaterial===null&&(this._cubemapMaterial=Mh()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=vh()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=ym(),this._integrationMaterial=vm());let t=this._cubeSize,n=e.texture.mipmaps.length-1,s=this._ggxMaterial.uniforms;s.envMap.value=this._sourceTarget.texture;let r=this._integrationMaterial.uniforms;r.envMap.value=this._sourceTarget.texture,r.sourceLod.value=Math.log2(t/Gh);for(let a=0;a<=n;a++){let o=i.lodToRoughness(a,n);if(a>n-gm)r.roughness.value=o,this._renderCube(e,a,this._integrationMaterial);else{let c=o>0?Math.log2(t)+.5*Math.log2(6/(Vh*Math.pow(o,4)))+.5:0;s.roughness.value=o,s.lodBias.value=c,this._renderCube(e,a,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=Mm());let n=this._blurMaterial,s=n.uniforms,r=this._sourceTarget;s.sigma.value=Math.min(t,Math.PI)/Math.SQRT2,s.envMap.value=r.texture,this._renderCube(e,0,n),s.envMap.value=e.texture,this._renderCube(r,0,n)}};function yh(i,e,t){return new qs(i,{minFilter:kn,generateMipmaps:e,type:mn,colorSpace:_s,depthBuffer:t})}function Ys(i,e,t){return new vn({name:i,uniforms:e,vertexShader:He.cube_vert,fragmentShader:t,side:Vt,blending:yi,depthTest:!1,depthWrite:!1})}function ym(){return Ys("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},`
3858
+ `},s=new os(5,5,5),r=new Cn({name:"CubemapFromEquirect",uniforms:Ui(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Zt,blending:Ii});r.uniforms.tEquirect.value=t;let o=new Kt(s,r),a=t.minFilter;return t.minFilter===Kn&&(t.minFilter=qt),new cs(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,s=!0){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,s);e.setRenderTarget(r)}},Fh=256,Om=3,Bm=20,ru=256,ou=16,zm=3,km=new k,Vm=new We,fa=class i{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new cs(1,10,null),this._boxMesh=new Kt(new os(5,5,5),null),this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null,this._integrationMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){let{size:o=256,position:a=km}=r,c=this._renderer;this._setSize(o);let l=this._allocateTarget(),h=this._getSourceTarget(!0);t>0&&(h.texture.mipmapsAutoUpdate=!1);let d=c.autoClear,u=c.autoClearColor,p=c.autoClearDepth,_=c.autoClearStencil,x=e.background;c.autoClear=!0,c.autoClearColor=!0,c.autoClearDepth=!0,c.autoClearStencil=!0,x===null&&(e.background=c.getClearColor(Vm));let m=new cs(n,s,h);return m.position.copy(a),m.update(c,e),c.autoClear=d,c.autoClearColor=u,c.autoClearDepth=p,c.autoClearStencil=_,e.background=x,t>0&&(h.texture.mipmapsAutoUpdate=!0,this._blur(l,t)),this._applyPMREM(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=zh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Bh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._sourceTarget!==null&&this._sourceTarget.dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._integrationMaterial!==null&&this._integrationMaterial.dispose(),this._boxMesh.geometry.dispose()}static lodToRoughness(e,t){return t>0?1-Math.sqrt(1-e/t):0}_setSize(e){this._cubeSize=Math.max(Fh,Pl(e))}_fromTexture(e,t){e.mapping===Di||e.mapping===fs?this._setSize(e.image.length===0?Fh:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4);let n=t||this._allocateTarget();return this._textureToCubemap(e),this._applyPMREM(n),n}_allocateTarget(){let e=this._cubeSize,t=Oh(e,!1,!1),n=Math.log2(e)-Om;for(let s=0;s<=n;s++)t.texture.mipmaps.push({width:e>>s,height:e>>s});return t.texture.name="PMREM",t.texture.isPMREMTexture=!0,t}_getSourceTarget(e=!1){let t=this._cubeSize,n=this._sourceTarget;return(n===null||n.width!==t||e&&n.depthBuffer===!1)&&(n!==null&&n.dispose(),this._sourceTarget=Oh(t,!0,e)),this._sourceTarget}_compileMaterial(e){this._boxMesh.material=e,this._renderer.compile(this._boxMesh,this._cubeCamera.children[0])}_renderCube(e,t,n){let s=this._boxMesh,r=this._cubeCamera;s.material=n,r.renderTarget=e,r.activeMipmapLevel=t;let o=e.width>>t;e.viewport.set(0,0,o,o),r.update(this._renderer,s),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===Di||e.mapping===fs?(this._cubemapMaterial===null&&(this._cubemapMaterial=zh()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=Bh()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=Gm(),this._integrationMaterial=Hm());let t=this._cubeSize,n=e.texture.mipmaps.length-1,s=this._ggxMaterial.uniforms;s.envMap.value=this._sourceTarget.texture;let r=this._integrationMaterial.uniforms;r.envMap.value=this._sourceTarget.texture,r.sourceLod.value=Math.log2(t/ou);for(let o=0;o<=n;o++){let a=i.lodToRoughness(o,n);if(o>n-zm)r.roughness.value=a,this._renderCube(e,o,this._integrationMaterial);else{let c=a>0?Math.log2(t)+.5*Math.log2(6/(ru*Math.pow(a,4)))+.5:0;s.roughness.value=a,s.lodBias.value=c,this._renderCube(e,o,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=Wm());let n=this._blurMaterial,s=n.uniforms,r=this._sourceTarget;s.sigma.value=Math.min(t,Math.PI)/Math.SQRT2,s.envMap.value=r.texture,this._renderCube(e,0,n),s.envMap.value=e.texture,this._renderCube(r,0,n)}};function Oh(i,e,t){return new sr(i,{minFilter:Kn,generateMipmaps:e,type:wn,colorSpace:Cs,depthBuffer:t})}function rr(i,e,t){return new Cn({name:i,uniforms:e,vertexShader:Ye.cube_vert,fragmentShader:t,side:Zt,blending:Ii,depthTest:!1,depthWrite:!1})}function Gm(){return rr("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},`
3859
3859
 
3860
- #define GGX_SAMPLES ${Vh}u
3860
+ #define GGX_SAMPLES ${ru}u
3861
3861
 
3862
3862
  varying vec3 vWorldDirection;
3863
3863
 
@@ -3939,7 +3939,7 @@ void main() {
3939
3939
  gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );
3940
3940
 
3941
3941
  }
3942
- `)}function vm(){return Ys("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:Gh}},`
3942
+ `)}function Hm(){return rr("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:ou}},`
3943
3943
 
3944
3944
  varying vec3 vWorldDirection;
3945
3945
 
@@ -3992,9 +3992,9 @@ void main() {
3992
3992
  gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 );
3993
3993
 
3994
3994
  }
3995
- `)}function Mm(){return Ys("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},`
3995
+ `)}function Wm(){return rr("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},`
3996
3996
 
3997
- #define SAMPLES ${mm}
3997
+ #define SAMPLES ${Bm}
3998
3998
  #define GOLDEN_ANGLE 2.39996322973
3999
3999
 
4000
4000
  varying vec3 vWorldDirection;
@@ -4040,7 +4040,7 @@ void main() {
4040
4040
  gl_FragColor = vec4( accumColor / accumWeight, 1.0 );
4041
4041
 
4042
4042
  }
4043
- `)}function vh(){return Ys("PMREMEquirectangularToCubemap",{envMap:{value:null}},`
4043
+ `)}function Bh(){return rr("PMREMEquirectangularToCubemap",{envMap:{value:null}},`
4044
4044
 
4045
4045
  varying vec3 vWorldDirection;
4046
4046
 
@@ -4062,7 +4062,7 @@ void main() {
4062
4062
  gl_FragColor = vec4( color * 0.25, 1.0 );
4063
4063
 
4064
4064
  }
4065
- `)}function Mh(){return Ys("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},`
4065
+ `)}function zh(){return rr("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},`
4066
4066
 
4067
4067
  varying vec3 vWorldDirection;
4068
4068
 
@@ -4074,7 +4074,7 @@ void main() {
4074
4074
  gl_FragColor = vec4( textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ).rgb, 1.0 );
4075
4075
 
4076
4076
  }
4077
- `)}function bm(i){let e=new WeakMap,t=new WeakMap,n=null;function s(u,m=!1){return u==null?null:m?a(u):r(u)}function r(u){if(u&&u.isTexture){let m=u.mapping;if(m===ua||m===da)if(e.has(u)){let _=e.get(u).texture;return o(_,u.mapping)}else{let _=u.image;if(_&&_.height>0){let y=new qs(_.height);return y.fromEquirectangularTexture(i,u),e.set(u,y),u.addEventListener("dispose",l),o(y.texture,u.mapping)}else return null}}return u}function a(u){if(u&&u.isTexture&&u.isPMREMTexture!==!0){let m=u.mapping,_=m===ua||m===da,y=m===Mi||m===ts;if(_||y){let p=t.get(u),f=p!==void 0?p.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==f)return n===null&&(n=new Qa(i)),p=_?n.fromEquirectangular(u,p):n.fromCubemap(u,p),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),p.texture;if(p!==void 0)return p.texture;{let S=u.image;return _&&S&&S.height>0||y&&S&&c(S)?(n===null&&(n=new Qa(i)),p=_?n.fromEquirectangular(u):n.fromCubemap(u),p.texture.pmremVersion=u.pmremVersion,t.set(u,p),u.addEventListener("dispose",h),p.texture):null}}}return u}function o(u,m){return m===ua?u.mapping=Mi:m===da&&(u.mapping=ts),u}function c(u){let m=0,_=6;for(let y=0;y<_;y++)u[y]!==void 0&&m++;return m===_}function l(u){let m=u.target;m.removeEventListener("dispose",l);let _=e.get(m);_!==void 0&&(e.delete(m),_.dispose())}function h(u){let m=u.target;m.removeEventListener("dispose",h);let _=t.get(m);_!==void 0&&(t.delete(m),_.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function Sm(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&ps("WebGLRenderer: "+n+" extension not supported."),s}}}function Em(i,e,t,n){let s={},r=new WeakMap,a=new FinalizationRegistry(_=>delete s[_]);function o(_){c(_.target)}function c(_){_.index!==null&&e.remove(_.index);for(let p in _.attributes)e.remove(_.attributes[p]);_.removeEventListener("dispose",o),delete s[_.id],a.unregister(_);let y=r.get(_);y&&(e.remove(y),r.delete(_)),n.releaseStatesOfGeometry(_),_.isInstancedBufferGeometry===!0&&delete _._maxInstanceCount,t.memory.geometries--}function l(_,y){return s[y.id]!==void 0||(y.addEventListener("dispose",o),s[y.id]=new WeakRef(y),a.register(y,y.id,y),t.memory.geometries++),y}function h(_){let y=_.attributes;for(let p in y)e.update(y[p],i.ARRAY_BUFFER)}function d(_){let y=_.index,p=_.attributes.position,f=0;if(p===void 0)return;let S=y!==null?y.array.length:p.array.length/3-1,A=p.count>=65535?Es:Ss,b=new A(Math.ceil(S/3)*6,1),T=b.array;if(y!==null){let g=y.array;f=y.version;for(let M=0,U=0;M<S;M+=3){let I=g[M+0],D=g[M+1],F=g[M+2];T[U++]=I,T[U++]=D,T[U++]=D,T[U++]=F,T[U++]=F,T[U++]=I}}else{f=p.version;for(let g=0,M=0;g<S;g+=3){let U=g+0,I=g+1,D=g+2;T[M++]=U,T[M++]=I,T[M++]=I,T[M++]=D,T[M++]=D,T[M++]=U}}b.version=f;let E=r.get(_);E&&e.remove(E),r.set(_,b)}function u(_){let y=r.get(_);if(y){let p=_.index;p!==null&&y.version<p.version&&d(_)}else d(_);return r.get(_)}function m(){for(let _ in s){let y=s[_].deref();y!==void 0&&c(y)}}return{get:l,update:h,getWireframeAttribute:u,dispose:m}}function wm(i,e,t){let n;function s(d){n=d}let r,a;function o(d){r=d.type,a=d.bytesPerElement}function c(d,u){i.drawElements(n,u,r,d*a),t.update(u,n,1)}function l(d,u,m){m!==0&&(i.drawElementsInstanced(n,u,r,d*a,m),t.update(u,n,m))}function h(d,u,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,r,d,0,m);let y=0;for(let p=0;p<m;p++)y+=u[p];t.update(y,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Tm(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=o*(r/3);break;case i.LINES:t.lines+=o*(r/2);break;case i.LINE_STRIP:t.lines+=o*(r-1);break;case i.LINE_LOOP:t.lines+=o*r;break;case i.POINTS:t.points+=o*r;break;default:Ue("WebGLInfo: Unknown draw mode:",a);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Am(i,e,t){let n=new WeakMap,s=new dt;function r(a,o,c){let l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,d=h!==void 0?h.length:0,u=n.get(o);if(u===void 0||u.count!==d){let U=function(){g.dispose(),n.delete(o),o.removeEventListener("dispose",U)};u!==void 0&&u.texture.dispose();let m=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,y=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],f=o.morphAttributes.normal||[],S=o.morphAttributes.color||[],A=0;m===!0&&(A=1),_===!0&&(A=2),y===!0&&(A=3);let b=o.attributes.position.count*A,T=1;b>e.maxTextureSize&&(T=Math.ceil(b/e.maxTextureSize),b=e.maxTextureSize);let E=new Float32Array(b*T*4*d),g=new vs(E,b,T,d);g.type=pn,g.needsUpdate=!0;let M=A*4;for(let I=0;I<d;I++){let D=p[I],F=f[I],H=S[I],C=b*T*4*I;for(let Y=0;Y<D.count;Y++){let J=Y*M;m===!0&&(s.fromBufferAttribute(D,Y),E[C+J+0]=s.x,E[C+J+1]=s.y,E[C+J+2]=s.z,E[C+J+3]=0),_===!0&&(s.fromBufferAttribute(F,Y),E[C+J+4]=s.x,E[C+J+5]=s.y,E[C+J+6]=s.z,E[C+J+7]=0),y===!0&&(s.fromBufferAttribute(H,Y),E[C+J+8]=s.x,E[C+J+9]=s.y,E[C+J+10]=s.z,E[C+J+11]=H.itemSize===4?s.w:1)}}u={count:d,texture:g,size:new Fe(b,T)},n.set(o,u),o.addEventListener("dispose",U)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let m=0;for(let y=0;y<l.length;y++)m+=l[y];let _=o.morphTargetsRelative?1:1-m;c.getUniforms().setValue(i,"morphTargetBaseInfluence",_),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function Rm(i,e,t,n,s){let r=new WeakMap;function a(l){let h=s.render.frame,d=l.geometry,u=e.get(l,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){let m=l.skeleton;r.get(m)!==h&&(m.update(),r.set(m,h))}return u}function o(){r=new WeakMap}function c(l){let h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:a,dispose:o}}var Cm={[Yo]:"LINEAR_TONE_MAPPING",[Zo]:"REINHARD_TONE_MAPPING",[$o]:"CINEON_TONE_MAPPING",[Jo]:"ACES_FILMIC_TONE_MAPPING",[jo]:"AGX_TONE_MAPPING",[Fs]:"NEUTRAL_TONE_MAPPING",[Ko]:"CUSTOM_TONE_MAPPING"};function Pm(i,e,t,n,s,r){let a=new Qt(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),o=null,c=null,l=null,h=new Wt;h.setAttribute("position",new zt([-1,3,0,-1,-1,0,3,-1,0],3)),h.setAttribute("uv",new zt([0,2,0,0,2,0],2));let d=new Zr({uniforms:{tDiffuse:{value:null}},vertexShader:`
4077
+ `)}function Xm(i){let e=new WeakMap,t=new WeakMap,n=null;function s(u,p=!1){return u==null?null:p?o(u):r(u)}function r(u){if(u&&u.isTexture){let p=u.mapping;if(p===Eo||p===To)if(e.has(u)){let _=e.get(u).texture;return a(_,u.mapping)}else{let _=u.image;if(_&&_.height>0){let x=new sr(_.height);return x.fromEquirectangularTexture(i,u),e.set(u,x),u.addEventListener("dispose",l),a(x.texture,u.mapping)}else return null}}return u}function o(u){if(u&&u.isTexture&&u.isPMREMTexture!==!0){let p=u.mapping,_=p===Eo||p===To,x=p===Di||p===fs;if(_||x){let m=t.get(u),f=m!==void 0?m.texture.pmremVersion:0;if(u.isRenderTargetTexture&&u.pmremVersion!==f)return n===null&&(n=new fa(i)),m=_?n.fromEquirectangular(u,m):n.fromCubemap(u,m),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),m.texture;if(m!==void 0)return m.texture;{let w=u.image;return _&&w&&w.height>0||x&&w&&c(w)?(n===null&&(n=new fa(i)),m=_?n.fromEquirectangular(u):n.fromCubemap(u),m.texture.pmremVersion=u.pmremVersion,t.set(u,m),u.addEventListener("dispose",h),m.texture):null}}}return u}function a(u,p){return p===Eo?u.mapping=Di:p===To&&(u.mapping=fs),u}function c(u){let p=0,_=6;for(let x=0;x<_;x++)u[x]!==void 0&&p++;return p===_}function l(u){let p=u.target;p.removeEventListener("dispose",l);let _=e.get(p);_!==void 0&&(e.delete(p),_.dispose())}function h(u){let p=u.target;p.removeEventListener("dispose",h);let _=t.get(p);_!==void 0&&(t.delete(p),_.dispose())}function d(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:d}}function qm(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let s=i.getExtension(n);return e[n]=s,s}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let s=t(n);return s===null&&Ts("WebGLRenderer: "+n+" extension not supported."),s}}}function Ym(i,e,t,n){let s={},r=new WeakMap,o=new FinalizationRegistry(_=>delete s[_]);function a(_){c(_.target)}function c(_){_.index!==null&&e.remove(_.index);for(let m in _.attributes)e.remove(_.attributes[m]);_.removeEventListener("dispose",a),delete s[_.id],o.unregister(_);let x=r.get(_);x&&(e.remove(x),r.delete(_)),n.releaseStatesOfGeometry(_),_.isInstancedBufferGeometry===!0&&delete _._maxInstanceCount,t.memory.geometries--}function l(_,x){return s[x.id]!==void 0||(x.addEventListener("dispose",a),s[x.id]=new WeakRef(x),o.register(x,x.id,x),t.memory.geometries++),x}function h(_){let x=_.attributes;for(let m in x)e.update(x[m],i.ARRAY_BUFFER)}function d(_){let x=_.index,m=_.attributes.position,f=0;if(m===void 0)return;let w=x!==null?x.array.length:m.array.length/3-1,A=m.count>=65535?Fs:Us,S=new A(Math.ceil(w/3)*6,1),M=S.array;if(x!==null){let g=x.array;f=x.version;for(let v=0,N=0;v<w;v+=3){let R=g[v+0],D=g[v+1],U=g[v+2];M[N++]=R,M[N++]=D,M[N++]=D,M[N++]=U,M[N++]=U,M[N++]=R}}else{f=m.version;for(let g=0,v=0;g<w;g+=3){let N=g+0,R=g+1,D=g+2;M[v++]=N,M[v++]=R,M[v++]=R,M[v++]=D,M[v++]=D,M[v++]=N}}S.version=f;let E=r.get(_);E&&e.remove(E),r.set(_,S)}function u(_){let x=r.get(_);if(x){let m=_.index;m!==null&&x.version<m.version&&d(_)}else d(_);return r.get(_)}function p(){for(let _ in s){let x=s[_].deref();x!==void 0&&c(x)}}return{get:l,update:h,getWireframeAttribute:u,dispose:p}}function Zm(i,e,t){let n;function s(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function c(d,u){i.drawElements(n,u,r,d*o),t.update(u,n,1)}function l(d,u,p){p!==0&&(i.drawElementsInstanced(n,u,r,d*o,p),t.update(u,n,p))}function h(d,u,p){if(p===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,u,0,r,d,0,p);let x=0;for(let m=0;m<p;m++)x+=u[m];t.update(x,n,1)}this.setMode=s,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function $m(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(r/3);break;case i.LINES:t.lines+=a*(r/2);break;case i.LINE_STRIP:t.lines+=a*(r-1);break;case i.LINE_LOOP:t.lines+=a*r;break;case i.POINTS:t.points+=a*r;break;default:ze("WebGLInfo: Unknown draw mode:",o);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:n}}function Jm(i,e,t){let n=new WeakMap,s=new gt;function r(o,a,c){let l=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,d=h!==void 0?h.length:0,u=n.get(a);if(u===void 0||u.count!==d){let N=function(){g.dispose(),n.delete(a),a.removeEventListener("dispose",N)};u!==void 0&&u.texture.dispose();let p=a.morphAttributes.position!==void 0,_=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],f=a.morphAttributes.normal||[],w=a.morphAttributes.color||[],A=0;p===!0&&(A=1),_===!0&&(A=2),x===!0&&(A=3);let S=a.attributes.position.count*A,M=1;S>e.maxTextureSize&&(M=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let E=new Float32Array(S*M*4*d),g=new Ls(E,S,M,d);g.type=Sn,g.needsUpdate=!0;let v=A*4;for(let R=0;R<d;R++){let D=m[R],U=f[R],z=w[R],I=S*M*4*R;for(let q=0;q<D.count;q++){let Z=q*v;p===!0&&(s.fromBufferAttribute(D,q),E[I+Z+0]=s.x,E[I+Z+1]=s.y,E[I+Z+2]=s.z,E[I+Z+3]=0),_===!0&&(s.fromBufferAttribute(U,q),E[I+Z+4]=s.x,E[I+Z+5]=s.y,E[I+Z+6]=s.z,E[I+Z+7]=0),x===!0&&(s.fromBufferAttribute(z,q),E[I+Z+8]=s.x,E[I+Z+9]=s.y,E[I+Z+10]=s.z,E[I+Z+11]=z.itemSize===4?s.w:1)}}u={count:d,texture:g,size:new ke(S,M)},n.set(a,u),a.addEventListener("dispose",N)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let p=0;for(let x=0;x<l.length;x++)p+=l[x];let _=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(i,"morphTargetBaseInfluence",_),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",u.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function Km(i,e,t,n,s){let r=new WeakMap;function o(l){let h=s.render.frame,d=l.geometry,u=e.get(l,d);if(r.get(u)!==h&&(e.update(u),r.set(u,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(t.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&t.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){let p=l.skeleton;r.get(p)!==h&&(p.update(),r.set(p,h))}return u}function a(){r=new WeakMap}function c(l){let h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),t.remove(h.instanceMatrix),h.instanceColor!==null&&t.remove(h.instanceColor)}return{update:o,dispose:a}}var jm={[hl]:"LINEAR_TONE_MAPPING",[ul]:"REINHARD_TONE_MAPPING",[dl]:"CINEON_TONE_MAPPING",[fl]:"ACES_FILMIC_TONE_MAPPING",[ml]:"AGX_TONE_MAPPING",[Zs]:"NEUTRAL_TONE_MAPPING",[pl]:"CUSTOM_TONE_MAPPING"};function Qm(i,e,t,n,s,r){let o=new ln(e,t,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),a=null,c=null,l=null,h=new Yt;h.setAttribute("position",new Xt([-1,3,0,-1,-1,0,3,-1,0],3)),h.setAttribute("uv",new Xt([0,2,0,0,2,0],2));let d=new ao({uniforms:{tDiffuse:{value:null}},vertexShader:`
4078
4078
  precision highp float;
4079
4079
 
4080
4080
  uniform mat4 modelViewMatrix;
@@ -4120,17 +4120,17 @@ void main() {
4120
4120
  #ifdef SRGB_TRANSFER
4121
4121
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4122
4122
  #endif
4123
- }`,depthTest:!1,depthWrite:!1}),u=new en(h,d),m=new xi(-1,1,1,-1,0,1),_=null,y=null,p=!1,f,S=null,A=[],b=!1;this.setSize=function(T,E){a.setSize(T,E),o!==null&&o.setSize(T,E),c!==null&&c.setSize(T,E);for(let g=0;g<A.length;g++){let M=A[g];M.setSize&&M.setSize(T,E)}},this.setEffects=function(T){A=T,b=A.length>0&&A[0].isRenderPass===!0;let E=a.width,g=a.height;A.length>0&&o===null&&(o=new Qt(E,g,{type:mn,depthBuffer:!1,stencilBuffer:!1}),c=new Qt(E,g,{type:mn,depthBuffer:!1,stencilBuffer:!1}));let M=s===!0&&A.some(U=>U.needsDepthTexture===!0);M!==(a.depthTexture!==null)&&(M===!0&&l===null&&(l=new zn(E,g),r===!0&&(l.format=Vn,l.type=bi)),a.dispose(),a.depthTexture=M?l:null,a.resolveDepthBuffer=M,a.storeMultisampledDepthBuffer=M);for(let U=0;U<A.length;U++){let I=A[U];I.setSize&&I.setSize(E,g),M&&I.needsDepthTexture===!0&&I.setDepthTexture&&I.setDepthTexture(l)}},this.begin=function(T,E){if(p||T.toneMapping===bn&&A.length===0)return!1;if(S=E,E!==null){let g=E.width,M=E.height;(a.width!==g||a.height!==M)&&this.setSize(g,M)}return b===!1&&T.setRenderTarget(a),f=T.toneMapping,T.toneMapping=bn,!0},this.hasRenderPass=function(){return b},this.end=function(T,E){T.toneMapping=f,p=!0;let g=a,M=o;for(let U=0;U<A.length;U++){let I=A[U];I.enabled!==!1&&(I.render(T,M,g,E),I.needsSwap!==!1&&(g=M,M=M===o?c:o))}if(_!==T.outputColorSpace||y!==T.toneMapping){_=T.outputColorSpace,y=T.toneMapping,d.defines={},Ze.getTransfer(_)===nt&&(d.defines.SRGB_TRANSFER="");let U=Cm[y];U&&(d.defines[U]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=g.texture,T.setRenderTarget(S),T.render(u,m),S=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.dispose(),o!==null&&o.dispose(),c!==null&&c.dispose(),h.dispose(),d.dispose()}}var Hh=new Ht,Wh=new zn(1,1),Xh=new Ts(1),qh=new vs,Yh=new Vr,Zh=new ws,bh=[],Sh=[],Eh=new Float32Array(16),wh=new Float32Array(9),Th=new Float32Array(4);function rs(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=bh[s];if(r===void 0&&(r=new Float32Array(s),bh[s]=r),e!==0){n.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,i[a].toArray(r,o)}return r}function vt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Mt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function to(i,e){let t=Sh[e];t===void 0&&(t=new Int32Array(e),Sh[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function Im(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Lm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;i.uniform2fv(this.addr,e),Mt(t,e)}}function Dm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(vt(t,e))return;i.uniform3fv(this.addr,e),Mt(t,e)}}function Nm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(vt(t,e))return;i.uniform4fv(this.addr,e),Mt(t,e)}}function Um(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,n))return;Th.set(n),i.uniformMatrix2fv(this.addr,!1,Th),Mt(t,n)}}function Fm(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,n))return;wh.set(n),i.uniformMatrix3fv(this.addr,!1,wh),Mt(t,n)}}function Om(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(vt(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Mt(t,e)}else{if(vt(t,n))return;Eh.set(n),i.uniformMatrix4fv(this.addr,!1,Eh),Mt(t,n)}}function Bm(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function zm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;i.uniform2iv(this.addr,e),Mt(t,e)}}function km(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vt(t,e))return;i.uniform3iv(this.addr,e),Mt(t,e)}}function Vm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(vt(t,e))return;i.uniform4iv(this.addr,e),Mt(t,e)}}function Gm(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function Hm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(vt(t,e))return;i.uniform2uiv(this.addr,e),Mt(t,e)}}function Wm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(vt(t,e))return;i.uniform3uiv(this.addr,e),Mt(t,e)}}function Xm(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(vt(t,e))return;i.uniform4uiv(this.addr,e),Mt(t,e)}}function no(i){return i.version===0&&(i.compareFunction=cl,i.needsUpdate=!0),i}function qm(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?r=no(Wh):r=Hh,t.setTexture2D(e||r,s)}function Ym(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||Yh,s)}function Zm(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_CUBE_SHADOW?r=no(Xh):r=Zh,t.setTextureCube(e||r,s)}function $m(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||qh,s)}function Jm(i){switch(i){case 5126:return Im;case 35664:return Lm;case 35665:return Dm;case 35666:return Nm;case 35674:return Um;case 35675:return Fm;case 35676:return Om;case 5124:case 35670:return Bm;case 35667:case 35671:return zm;case 35668:case 35672:return km;case 35669:case 35673:return Vm;case 5125:return Gm;case 36294:return Hm;case 36295:return Wm;case 36296:return Xm;case 35678:case 36198:case 36298:case 36306:case 35682:return qm;case 35679:case 36299:case 36307:return Ym;case 35680:case 36300:case 36308:case 36293:return Zm;case 36289:case 36303:case 36311:case 36292:return $m}}function Km(i,e){i.uniform1fv(this.addr,e)}function jm(i,e){let t=rs(e,this.size,2);i.uniform2fv(this.addr,t)}function Qm(i,e){let t=rs(e,this.size,3);i.uniform3fv(this.addr,t)}function eg(i,e){let t=rs(e,this.size,4);i.uniform4fv(this.addr,t)}function tg(i,e){let t=rs(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function ng(i,e){let t=rs(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function ig(i,e){let t=rs(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function sg(i,e){i.uniform1iv(this.addr,e)}function rg(i,e){i.uniform2iv(this.addr,e)}function ag(i,e){i.uniform3iv(this.addr,e)}function og(i,e){i.uniform4iv(this.addr,e)}function lg(i,e){i.uniform1uiv(this.addr,e)}function cg(i,e){i.uniform2uiv(this.addr,e)}function hg(i,e){i.uniform3uiv(this.addr,e)}function ug(i,e){i.uniform4uiv(this.addr,e)}function dg(i,e,t){let n=this.cache,s=e.length,r=to(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=no(Wh):a=Hh;for(let o=0;o!==s;++o)t.setTexture2D(e[o]||a,r[o])}function fg(i,e,t){let n=this.cache,s=e.length,r=to(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));for(let a=0;a!==s;++a)t.setTexture3D(e[a]||Yh,r[a])}function pg(i,e,t){let n=this.cache,s=e.length,r=to(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));let a;this.type===i.SAMPLER_CUBE_SHADOW?a=no(Xh):a=Zh;for(let o=0;o!==s;++o)t.setTextureCube(e[o]||a,r[o])}function mg(i,e,t){let n=this.cache,s=e.length,r=to(t,s);vt(n,r)||(i.uniform1iv(this.addr,r),Mt(n,r));for(let a=0;a!==s;++a)t.setTexture2DArray(e[a]||qh,r[a])}function gg(i){switch(i){case 5126:return Km;case 35664:return jm;case 35665:return Qm;case 35666:return eg;case 35674:return tg;case 35675:return ng;case 35676:return ig;case 5124:case 35670:return sg;case 35667:case 35671:return rg;case 35668:case 35672:return ag;case 35669:case 35673:return og;case 5125:return lg;case 36294:return cg;case 36295:return hg;case 36296:return ug;case 35678:case 36198:case 36298:case 36306:case 35682:return dg;case 35679:case 36299:case 36307:return fg;case 35680:case 36300:case 36308:case 36293:return pg;case 36289:case 36303:case 36311:case 36292:return mg}}var Al=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Jm(t.type)}},Rl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=gg(t.type)}},Cl=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(e,t[o.id],n)}}},wl=/(\w+)(\])?(\[|\.)?/g;function Ah(i,e){i.seq.push(e),i.map[e.id]=e}function _g(i,e,t){let n=i.name,s=n.length;for(wl.lastIndex=0;;){let r=wl.exec(n),a=wl.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Ah(t,l===void 0?new Al(o,i,e):new Rl(o,i,e));break}else{let d=t.map[o];d===void 0&&(d=new Cl(o),Ah(t,d)),t=d}}}var ss=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){let o=e.getActiveUniform(t,a),c=e.getUniformLocation(t,o.name);_g(o,c,this)}let s=[],r=[];for(let a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,a=t.length;r!==a;++r){let o=t[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(e,c.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let a=e[s];a.id in t&&n.push(a)}return n}};function Rh(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var xg=37297,yg=0;function vg(i,e){let t=i.split(`
4124
- `),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a<r;a++){let o=a+1;n.push(`${o===e?">":" "} ${o}: ${t[a]}`)}return n.join(`
4125
- `)}var Ch=new Oe;function Mg(i){Ze._getMatrix(Ch,Ze.workingColorSpace,i);let e=`mat3( ${Ch.elements.map(t=>t.toFixed(4))} )`;switch(Ze.getTransfer(i)){case xs:return[e,"LinearTransferOETF"];case nt:return[e,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Ph(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return t.toUpperCase()+`
4123
+ }`,depthTest:!1,depthWrite:!1}),u=new Kt(h,d),p=new Pi(-1,1,1,-1,0,1),_=null,x=null,m=!1,f,w=null,A=[],S=!1;this.setSize=function(M,E){o.setSize(M,E),a!==null&&a.setSize(M,E),c!==null&&c.setSize(M,E);for(let g=0;g<A.length;g++){let v=A[g];v.setSize&&v.setSize(M,E)}},this.setEffects=function(M){A=M,S=A.length>0&&A[0].isRenderPass===!0;let E=o.width,g=o.height;A.length>0&&a===null&&(a=new ln(E,g,{type:wn,depthBuffer:!1,stencilBuffer:!1}),c=new ln(E,g,{type:wn,depthBuffer:!1,stencilBuffer:!1}));let v=s===!0&&A.some(N=>N.needsDepthTexture===!0);v!==(o.depthTexture!==null)&&(v===!0&&l===null&&(l=new Jn(E,g),r===!0&&(l.format=jn,l.type=Ni)),o.dispose(),o.depthTexture=v?l:null,o.resolveDepthBuffer=v,o.storeMultisampledDepthBuffer=v);for(let N=0;N<A.length;N++){let R=A[N];R.setSize&&R.setSize(E,g),v&&R.needsDepthTexture===!0&&R.setDepthTexture&&R.setDepthTexture(l)}},this.begin=function(M,E){if(m||M.toneMapping===Pn&&A.length===0)return!1;if(w=E,E!==null){let g=E.width,v=E.height;(o.width!==g||o.height!==v)&&this.setSize(g,v)}return S===!1&&M.setRenderTarget(o),f=M.toneMapping,M.toneMapping=Pn,!0},this.hasRenderPass=function(){return S},this.end=function(M,E){M.toneMapping=f,m=!0;let g=o,v=a;for(let N=0;N<A.length;N++){let R=A[N];R.enabled!==!1&&(R.render(M,v,g,E),R.needsSwap!==!1&&(g=v,v=v===a?c:a))}if(_!==M.outputColorSpace||x!==M.toneMapping){_=M.outputColorSpace,x=M.toneMapping,d.defines={},Qe.getTransfer(_)===lt&&(d.defines.SRGB_TRANSFER="");let N=jm[x];N&&(d.defines[N]=""),d.needsUpdate=!0}d.uniforms.tDiffuse.value=g.texture,M.setRenderTarget(w),M.render(u,p),w=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.dispose(),a!==null&&a.dispose(),c!==null&&c.dispose(),h.dispose(),d.dispose()}}var au=new Jt,lu=new Jn(1,1),cu=new Bs(1),hu=new Ls,uu=new to,du=new Os,kh=[],Vh=[],Gh=new Float32Array(16),Hh=new Float32Array(9),Wh=new Float32Array(4);function _s(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=kh[s];if(r===void 0&&(r=new Float32Array(s),kh[s]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(r,a)}return r}function Et(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Tt(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function ma(i,e){let t=Vh[e];t===void 0&&(t=new Int32Array(e),Vh[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function eg(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function tg(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;i.uniform2fv(this.addr,e),Tt(t,e)}}function ng(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.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)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Et(t,e))return;i.uniform3fv(this.addr,e),Tt(t,e)}}function ig(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(Et(t,e))return;i.uniform4fv(this.addr,e),Tt(t,e)}}function sg(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Et(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,n))return;Wh.set(n),i.uniformMatrix2fv(this.addr,!1,Wh),Tt(t,n)}}function rg(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Et(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,n))return;Hh.set(n),i.uniformMatrix3fv(this.addr,!1,Hh),Tt(t,n)}}function og(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(Et(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Tt(t,e)}else{if(Et(t,n))return;Gh.set(n),i.uniformMatrix4fv(this.addr,!1,Gh),Tt(t,n)}}function ag(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function lg(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;i.uniform2iv(this.addr,e),Tt(t,e)}}function cg(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Et(t,e))return;i.uniform3iv(this.addr,e),Tt(t,e)}}function hg(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(Et(t,e))return;i.uniform4iv(this.addr,e),Tt(t,e)}}function ug(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function dg(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Et(t,e))return;i.uniform2uiv(this.addr,e),Tt(t,e)}}function fg(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Et(t,e))return;i.uniform3uiv(this.addr,e),Tt(t,e)}}function pg(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.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(Et(t,e))return;i.uniform4uiv(this.addr,e),Tt(t,e)}}function ga(i){return i.version===0&&(i.compareFunction=Tl,i.needsUpdate=!0),i}function mg(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?r=ga(lu):r=au,t.setTexture2D(e||r,s)}function gg(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||uu,s)}function _g(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_CUBE_SHADOW?r=ga(cu):r=du,t.setTextureCube(e||r,s)}function xg(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||hu,s)}function yg(i){switch(i){case 5126:return eg;case 35664:return tg;case 35665:return ng;case 35666:return ig;case 35674:return sg;case 35675:return rg;case 35676:return og;case 5124:case 35670:return ag;case 35667:case 35671:return lg;case 35668:case 35672:return cg;case 35669:case 35673:return hg;case 5125:return ug;case 36294:return dg;case 36295:return fg;case 36296:return pg;case 35678:case 36198:case 36298:case 36306:case 35682:return mg;case 35679:case 36299:case 36307:return gg;case 35680:case 36300:case 36308:case 36293:return _g;case 36289:case 36303:case 36311:case 36292:return xg}}function vg(i,e){i.uniform1fv(this.addr,e)}function bg(i,e){let t=_s(e,this.size,2);i.uniform2fv(this.addr,t)}function Mg(i,e){let t=_s(e,this.size,3);i.uniform3fv(this.addr,t)}function Sg(i,e){let t=_s(e,this.size,4);i.uniform4fv(this.addr,t)}function wg(i,e){let t=_s(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Eg(i,e){let t=_s(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Tg(i,e){let t=_s(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Ag(i,e){i.uniform1iv(this.addr,e)}function Rg(i,e){i.uniform2iv(this.addr,e)}function Cg(i,e){i.uniform3iv(this.addr,e)}function Pg(i,e){i.uniform4iv(this.addr,e)}function Ig(i,e){i.uniform1uiv(this.addr,e)}function Lg(i,e){i.uniform2uiv(this.addr,e)}function Dg(i,e){i.uniform3uiv(this.addr,e)}function Ng(i,e){i.uniform4uiv(this.addr,e)}function Ug(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));let o;this.type===i.SAMPLER_2D_SHADOW?o=ga(lu):o=au;for(let a=0;a!==s;++a)t.setTexture2D(e[a]||o,r[a])}function Fg(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));for(let o=0;o!==s;++o)t.setTexture3D(e[o]||uu,r[o])}function Og(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));let o;this.type===i.SAMPLER_CUBE_SHADOW?o=ga(cu):o=du;for(let a=0;a!==s;++a)t.setTextureCube(e[a]||o,r[a])}function Bg(i,e,t){let n=this.cache,s=e.length,r=ma(t,s);Et(n,r)||(i.uniform1iv(this.addr,r),Tt(n,r));for(let o=0;o!==s;++o)t.setTexture2DArray(e[o]||hu,r[o])}function zg(i){switch(i){case 5126:return vg;case 35664:return bg;case 35665:return Mg;case 35666:return Sg;case 35674:return wg;case 35675:return Eg;case 35676:return Tg;case 5124:case 35670:return Ag;case 35667:case 35671:return Rg;case 35668:case 35672:return Cg;case 35669:case 35673:return Pg;case 5125:return Ig;case 36294:return Lg;case 36295:return Dg;case 36296:return Ng;case 35678:case 36198:case 36298:case 36306:case 35682:return Ug;case 35679:case 36299:case 36307:return Fg;case 35680:case 36300:case 36308:case 36293:return Og;case 36289:case 36303:case 36311:case 36292:return Bg}}var Wl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=yg(t.type)}},Xl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=zg(t.type)}},ql=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let s=this.seq;for(let r=0,o=s.length;r!==o;++r){let a=s[r];a.setValue(e,t[a.id],n)}}},Gl=/(\w+)(\])?(\[|\.)?/g;function Xh(i,e){i.seq.push(e),i.map[e.id]=e}function kg(i,e,t){let n=i.name,s=n.length;for(Gl.lastIndex=0;;){let r=Gl.exec(n),o=Gl.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===s){Xh(t,l===void 0?new Wl(a,i,e):new Xl(a,i,e));break}else{let d=t.map[a];d===void 0&&(d=new ql(a),Xh(t,d)),t=d}}}var gs=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let o=0;o<n;++o){let a=e.getActiveUniform(t,o),c=e.getUniformLocation(t,a.name);kg(a,c,this)}let s=[],r=[];for(let o of this.seq)o.type===e.SAMPLER_2D_SHADOW||o.type===e.SAMPLER_CUBE_SHADOW||o.type===e.SAMPLER_2D_ARRAY_SHADOW?s.push(o):r.push(o);s.length>0&&(this.seq=s.concat(r))}setValue(e,t,n,s){let r=this.map[t];r!==void 0&&r.setValue(e,n,s)}setOptional(e,t,n){let s=t[n];s!==void 0&&this.setValue(e,n,s)}static upload(e,t,n,s){for(let r=0,o=t.length;r!==o;++r){let a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,s)}}static seqWithValue(e,t){let n=[];for(let s=0,r=e.length;s!==r;++s){let o=e[s];o.id in t&&n.push(o)}return n}};function qh(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var Vg=37297,Gg=0;function Hg(i,e){let t=i.split(`
4124
+ `),n=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=s;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
4125
+ `)}var Yh=new Ge;function Wg(i){Qe._getMatrix(Yh,Qe.workingColorSpace,i);let e=`mat3( ${Yh.elements.map(t=>t.toFixed(4))} )`;switch(Qe.getTransfer(i)){case Ps:return[e,"LinearTransferOETF"];case lt:return[e,"sRGBTransferOETF"];default:return Ue("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Zh(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=(i.getShaderInfoLog(e)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return t.toUpperCase()+`
4126
4126
 
4127
4127
  `+r+`
4128
4128
 
4129
- `+vg(i.getShaderSource(e),o)}else return r}function bg(i,e){let t=Mg(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( ${t[0]} * value.rgb, value.a ) );`,"}"].join(`
4130
- `)}var Sg={[Yo]:"Linear",[Zo]:"Reinhard",[$o]:"Cineon",[Jo]:"ACESFilmic",[jo]:"AgX",[Fs]:"Neutral",[Ko]:"Custom"};function Eg(i,e){let t=Sg[e];return t===void 0?(Ie("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var ja=new B;function wg(){Ze.getLuminanceCoefficients(ja);let i=ja.x.toFixed(4),e=ja.y.toFixed(4),t=ja.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4131
- `)}function Tg(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Xs).join(`
4132
- `)}function Ag(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4133
- `)}function Rg(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),a=r.name,o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),t[a]={type:r.type,location:i.getAttribLocation(e,a),locationSize:o}}return t}function Xs(i){return i!==""}function Ih(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows).replace(/NUM_LIGHT_PROBE_GRIDS/g,e.numLightProbeGrids)}function Lh(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Cg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Pl(i){return i.replace(Cg,Pg)}function Pg(i,e){let t=He[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return Pl(t)}var Ig=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Dh(i){return i.replace(Ig,Lg)}function Lg(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Nh(i){let e=`precision ${i.precision} float;
4129
+ `+Hg(i.getShaderSource(e),a)}else return r}function Xg(i,e){let t=Wg(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( ${t[0]} * value.rgb, value.a ) );`,"}"].join(`
4130
+ `)}var qg={[hl]:"Linear",[ul]:"Reinhard",[dl]:"Cineon",[fl]:"ACESFilmic",[ml]:"AgX",[Zs]:"Neutral",[pl]:"Custom"};function Yg(i,e){let t=qg[e];return t===void 0?(Ue("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var da=new k;function Zg(){Qe.getLuminanceCoefficients(da);let i=da.x.toFixed(4),e=da.y.toFixed(4),t=da.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
4131
+ `)}function $g(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ir).join(`
4132
+ `)}function Jg(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4133
+ `)}function Kg(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(e,s),o=r.name,a=1;r.type===i.FLOAT_MAT2&&(a=2),r.type===i.FLOAT_MAT3&&(a=3),r.type===i.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function ir(i){return i!==""}function $h(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_SUN_LIGHTS/g,e.numSunLights).replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_SUN_LIGHT_SHADOWS/g,e.numSunLightShadows).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows).replace(/NUM_LIGHT_PROBE_GRIDS/g,e.numLightProbeGrids)}function Jh(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var jg=/^[ \t]*#include +<([\w\d./]+)>/gm;function Yl(i){return i.replace(jg,Qg)}function Qg(i,e){let t=Ye[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return Yl(t)}var e0=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Kh(i){return i.replace(e0,t0)}function t0(i,e,t,n){let s="";for(let r=parseInt(e);r<parseInt(t);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function jh(i){let e=`precision ${i.precision} float;
4134
4134
  precision ${i.precision} int;
4135
4135
  precision ${i.precision} sampler2D;
4136
4136
  precision ${i.precision} samplerCube;
@@ -4150,30 +4150,30 @@ void main() {
4150
4150
  `;return i.precision==="highp"?e+=`
4151
4151
  #define HIGH_PRECISION`:i.precision==="mediump"?e+=`
4152
4152
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
4153
- #define LOW_PRECISION`),e}var Dg={[Us]:"SHADOWMAP_TYPE_PCF",[Qi]:"SHADOWMAP_TYPE_VSM"};function Ng(i){return Dg[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var Ug={[ts]:"ENVMAP_MODE_REFRACTION"};function Fg(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":Ug[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var Og={[ha]:"ENVMAP_BLENDING_MULTIPLY",[Jc]:"ENVMAP_BLENDING_MIX",[Kc]:"ENVMAP_BLENDING_ADD"};function Bg(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":Og[i.combine]||"ENVMAP_BLENDING_NONE"}function zg(i,e,t,n){let s=i.getContext(),r=t.defines,a=t.vertexShader,o=t.fragmentShader,c=Ng(t),l=t.envMapPMREM===!0?"ENVMAP_TYPE_PMREM":"ENVMAP_TYPE_CUBE",h=Fg(t),d=Bg(t),u=Tg(t),m=Ag(r),_=s.createProgram(),y,p,f=t.glslVersion?"#version "+t.glslVersion+`
4154
- `:"";t.isRawShaderMaterial?(y=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Xs).join(`
4155
- `),y.length>0&&(y+=`
4156
- `),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m].filter(Xs).join(`
4157
- `),p.length>0&&(p+=`
4158
- `)):(y=[Nh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.diffuseRoughnessMapUv?"#define DIFFUSE_ROUGHNESSMAP_UV "+t.diffuseRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4159
- `].filter(Xs).join(`
4160
- `),p=[Nh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,m,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",t.envMapPMREM?"#define ENVMAP_MAX_LOD "+t.envMapMaxLod+".0":"",t.envMapPMREM?"#define ENVMAP_SIZE "+t.envMapSize+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughness?"#define USE_DIFFUSE_ROUGHNESS":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==bn?"#define TONE_MAPPING":"",t.toneMapping!==bn?He.tonemapping_pars_fragment:"",t.toneMapping!==bn?Eg("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",He.colorspace_pars_fragment,bg("linearToOutputTexel",t.outputColorSpace),wg(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4161
- `].filter(Xs).join(`
4162
- `)),a=Pl(a),a=Ih(a,t),a=Lh(a,t),o=Pl(o),o=Ih(o,t),o=Lh(o,t),a=Dh(a),o=Dh(o),t.isRawShaderMaterial!==!0&&(f=`#version 300 es
4163
- `,y=[u,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4153
+ #define LOW_PRECISION`),e}var n0={[Ys]:"SHADOWMAP_TYPE_PCF",[us]:"SHADOWMAP_TYPE_VSM"};function i0(i){return n0[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var s0={[fs]:"ENVMAP_MODE_REFRACTION"};function r0(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":s0[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var o0={[wo]:"ENVMAP_BLENDING_MULTIPLY",[ph]:"ENVMAP_BLENDING_MIX",[mh]:"ENVMAP_BLENDING_ADD"};function a0(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":o0[i.combine]||"ENVMAP_BLENDING_NONE"}function l0(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,c=i0(t),l=t.envMapPMREM===!0?"ENVMAP_TYPE_PMREM":"ENVMAP_TYPE_CUBE",h=r0(t),d=a0(t),u=$g(t),p=Jg(r),_=s.createProgram(),x,m,f=t.glslVersion?"#version "+t.glslVersion+`
4154
+ `:"";t.isRawShaderMaterial?(x=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(ir).join(`
4155
+ `),x.length>0&&(x+=`
4156
+ `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(ir).join(`
4157
+ `),m.length>0&&(m+=`
4158
+ `)):(x=[jh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.diffuseRoughnessMapUv?"#define DIFFUSE_ROUGHNESSMAP_UV "+t.diffuseRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4159
+ `].filter(ir).join(`
4160
+ `),m=[jh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+d:"",t.envMapPMREM?"#define ENVMAP_MAX_LOD "+t.envMapMaxLod+".0":"",t.envMapPMREM?"#define ENVMAP_SIZE "+t.envMapSize+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughness?"#define USE_DIFFUSE_ROUGHNESS":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Pn?"#define TONE_MAPPING":"",t.toneMapping!==Pn?Ye.tonemapping_pars_fragment:"",t.toneMapping!==Pn?Yg("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ye.colorspace_pars_fragment,Xg("linearToOutputTexel",t.outputColorSpace),Zg(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4161
+ `].filter(ir).join(`
4162
+ `)),o=Yl(o),o=$h(o,t),o=Jh(o,t),a=Yl(a),a=$h(a,t),a=Jh(a,t),o=Kh(o),a=Kh(a),t.isRawShaderMaterial!==!0&&(f=`#version 300 es
4163
+ `,x=[u,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4164
4164
  `)+`
4165
- `+y,p=["#define varying in",t.glslVersion===hl?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===hl?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
4165
+ `+x,m=["#define varying in",t.glslVersion===Al?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Al?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
4166
4166
  `)+`
4167
- `+p);let S=f+y+a,A=f+p+o,b=Rh(s,s.VERTEX_SHADER,S),T=Rh(s,s.FRAGMENT_SHADER,A);s.attachShader(_,b),s.attachShader(_,T),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function E(I){if(i.debug.checkShaderErrors){let D=s.getProgramInfoLog(_)||"",F=s.getShaderInfoLog(b)||"",H=s.getShaderInfoLog(T)||"",C=D.trim(),Y=F.trim(),J=H.trim(),z=!0,te=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,b,T);else{let W=Ph(s,b,"vertex"),$=Ph(s,T,"fragment");Ue("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
4167
+ `+m);let w=f+x+o,A=f+m+a,S=qh(s,s.VERTEX_SHADER,w),M=qh(s,s.FRAGMENT_SHADER,A);s.attachShader(_,S),s.attachShader(_,M),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function E(R){if(i.debug.checkShaderErrors){let D=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(S)||"",z=s.getShaderInfoLog(M)||"",I=D.trim(),q=U.trim(),Z=z.trim(),B=!0,ee=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(B=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,S,M);else{let C=Zh(s,S,"vertex"),W=Zh(s,M,"fragment");ze("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
4168
4168
 
4169
- Material Name: `+I.name+`
4170
- Material Type: `+I.type+`
4169
+ Material Name: `+R.name+`
4170
+ Material Type: `+R.type+`
4171
4171
 
4172
- Program Info Log: `+C+`
4173
- `+W+`
4174
- `+$)}else C!==""?Ie("WebGLProgram: Program Info Log:",C):(Y===""||J==="")&&(te=!1);te&&(I.diagnostics={runnable:z,programLog:C,vertexShader:{log:Y,prefix:y},fragmentShader:{log:J,prefix:p}})}s.deleteShader(b),s.deleteShader(T),g=new ss(s,_),M=Rg(s,_)}let g;this.getUniforms=function(){return g===void 0&&E(this),g};let M;this.getAttributes=function(){return M===void 0&&E(this),M};let U=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return U===!1&&(U=s.getProgramParameter(_,xg)),U},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=yg++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=b,this.fragmentShader=T,this}var kg=0,Il=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let 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){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Ll(e),t.set(e,n)),n}},Ll=class{constructor(e){this.id=kg++,this.code=e,this.usedTimes=0}};function Vg(i){return i===si||i===Gs||i===Hs}function Gg(i,e,t,n,s,r){let a=new Ms,o=new Il,c=new Set,l=[],h=new Map,d=n.logarithmicDepthBuffer,u={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 m(g){return c.add(g),g===0?"uv":`uv${g}`}function _(g,M,U,I,D,F){let H=I.fog,C=D.geometry,Y=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?I.environment:null,J=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,z=e.get(g.envMap||Y,J),te=u[g.type],W=n.precision;g.precision!==null&&(W=n.getMaxPrecision(g.precision),W!==g.precision&&Ie("WebGLProgram.getParameters:",g.precision,"not supported, using",W,"instead."));let $=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,ae=$!==void 0?$.length:0,_e=0;C.morphAttributes.position!==void 0&&(_e=1),C.morphAttributes.normal!==void 0&&(_e=2),C.morphAttributes.color!==void 0&&(_e=3);let De,j,pe,ye;if(te){let ie=En[te];De=ie.vertexShader,j=ie.fragmentShader}else{De=g.vertexShader,j=g.fragmentShader;let ie=o.getVertexShaderStage(g),Ne=o.getFragmentShaderStage(g);o.update(g,ie,Ne),pe=ie.id,ye=Ne.id}let Re=i.getRenderTarget(),fe=i.state.buffers.depth.getReversed(),Le=D.isInstancedMesh===!0,pt=D.isBatchedMesh===!0,be=!!g.map,$e=!!g.matcap,it=!!z,ke=it&&z.isPMREMTexture===!0,lt=!!g.aoMap,Ge=!!g.lightMap,mt=!!g.bumpMap&&g.wireframe===!1,at=!!g.normalMap,nn=!!g.displacementMap,gt=!!g.emissiveMap,Ft=!!g.metalnessMap,Tt=!!g.roughnessMap,Pt=g.anisotropy>0,N=g.clearcoat>0,At=g.diffuseRoughness>0,Qe=g.dispersion>0,st=g.retroreflectivity>0,ue=g.iridescence>0,ut=g.sheen>0,Te=g.transmission>0,Ce=Pt&&!!g.anisotropyMap,w=N&&!!g.clearcoatMap,x=N&&!!g.clearcoatNormalMap,k=N&&!!g.clearcoatRoughnessMap,oe=At&&!!g.diffuseRoughnessMap,ee=ue&&!!g.iridescenceMap,le=ue&&!!g.iridescenceThicknessMap,ce=ut&&!!g.sheenColorMap,K=ut&&!!g.sheenRoughnessMap,P=!!g.specularMap,Q=!!g.specularColorMap,R=!!g.specularIntensityMap,X=Te&&!!g.transmissionMap,O=Te&&!!g.thicknessMap,q=!!g.gradientMap,ne=!!g.alphaMap,se=g.alphaTest>0,xe=!!g.alphaHash,Pe=!!g.extensions,re=bn;g.toneMapped&&(Re===null||Re.isXRRenderTarget===!0)&&(re=i.toneMapping);let ve=ke?z.isCompressedCubeTexture?z.image[0].mipmaps:z.mipmaps:null,Ae={shaderID:te,shaderType:g.type,shaderName:g.name,vertexShader:De,fragmentShader:j,defines:g.defines,customVertexShaderID:pe,customFragmentShaderID:ye,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:W,batching:pt,batchingColor:pt&&D._colorsTexture!==null,instancing:Le,instancingColor:Le&&D.instanceColor!==null,instancingMorph:Le&&D.morphTexture!==null,outputColorSpace:Re===null?i.outputColorSpace:Re.isXRRenderTarget===!0?Re.texture.colorSpace:Ze.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:be,matcap:$e,envMap:it,envMapMode:it&&z.mapping,envMapPMREM:ke,envMapMaxLod:ke?ve.length-1:null,envMapSize:ke?ve[0].width:null,aoMap:lt,lightMap:Ge,bumpMap:mt,normalMap:at,displacementMap:nn,emissiveMap:gt,normalMapObjectSpace:at&&g.normalMapType===eh,normalMapTangentSpace:at&&g.normalMapType===Ja,packedNormalMap:at&&g.normalMapType===Ja&&Vg(g.normalMap.format),metalnessMap:Ft,roughnessMap:Tt,anisotropy:Pt,anisotropyMap:Ce,clearcoat:N,clearcoatMap:w,clearcoatNormalMap:x,clearcoatRoughnessMap:k,diffuseRoughness:At,diffuseRoughnessMap:oe,dispersion:Qe,retroreflection:st,iridescence:ue,iridescenceMap:ee,iridescenceThicknessMap:le,sheen:ut,sheenColorMap:ce,sheenRoughnessMap:K,specularMap:P,specularColorMap:Q,specularIntensityMap:R,transmission:Te,transmissionMap:X,thicknessMap:O,gradientMap:q,opaque:g.transparent===!1&&g.blending===es&&g.alphaToCoverage===!1,alphaMap:ne,alphaTest:se,alphaHash:xe,combine:g.combine,mapUv:be&&m(g.map.channel),aoMapUv:lt&&m(g.aoMap.channel),lightMapUv:Ge&&m(g.lightMap.channel),bumpMapUv:mt&&m(g.bumpMap.channel),normalMapUv:at&&m(g.normalMap.channel),displacementMapUv:nn&&m(g.displacementMap.channel),emissiveMapUv:gt&&m(g.emissiveMap.channel),metalnessMapUv:Ft&&m(g.metalnessMap.channel),roughnessMapUv:Tt&&m(g.roughnessMap.channel),anisotropyMapUv:Ce&&m(g.anisotropyMap.channel),clearcoatMapUv:w&&m(g.clearcoatMap.channel),clearcoatNormalMapUv:x&&m(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:k&&m(g.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:oe&&m(g.diffuseRoughnessMap.channel),iridescenceMapUv:ee&&m(g.iridescenceMap.channel),iridescenceThicknessMapUv:le&&m(g.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&m(g.sheenColorMap.channel),sheenRoughnessMapUv:K&&m(g.sheenRoughnessMap.channel),specularMapUv:P&&m(g.specularMap.channel),specularColorMapUv:Q&&m(g.specularColorMap.channel),specularIntensityMapUv:R&&m(g.specularIntensityMap.channel),transmissionMapUv:X&&m(g.transmissionMap.channel),thicknessMapUv:O&&m(g.thicknessMap.channel),alphaMapUv:ne&&m(g.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(at||Pt),vertexNormals:!!C.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!C.attributes.color&&C.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!C.attributes.uv&&(be||ne),fog:!!H,useFog:g.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||C.attributes.normal===void 0&&at===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:fe,skinning:D.isSkinnedMesh===!0,hasPositionAttribute:C.attributes.position!==void 0,morphTargets:C.morphAttributes.position!==void 0,morphNormals:C.morphAttributes.normal!==void 0,morphColors:C.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:_e,numSunLights:M.sun.length,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numSunLightShadows:M.sunShadowMap.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numLightProbeGrids:F.filter(ie=>ie.texture!==null).length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&U.length>0,shadowMapType:i.shadowMap.type,toneMapping:re,decodeVideoTexture:be&&g.map.isVideoTexture===!0&&Ze.getTransfer(g.map.colorSpace)===nt,decodeVideoTextureEmissive:gt&&g.emissiveMap.isVideoTexture===!0&&Ze.getTransfer(g.emissiveMap.colorSpace)===nt,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===Mn,flipSided:g.side===Vt,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:Pe&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Pe&&g.extensions.multiDraw===!0||pt)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Ae.vertexUv1s=c.has(1),Ae.vertexUv2s=c.has(2),Ae.vertexUv3s=c.has(3),c.clear(),Ae}function y(g){let M=[];if(g.shaderID?M.push(g.shaderID):(M.push(g.customVertexShaderID),M.push(g.customFragmentShaderID)),g.defines!==void 0)for(let U in g.defines)M.push(U),M.push(g.defines[U]);return g.isRawShaderMaterial===!1&&(p(M,g),f(M,g),M.push(i.outputColorSpace)),M.push(g.customProgramCacheKey),M.join()}function p(g,M){g.push(M.precision),g.push(M.outputColorSpace),g.push(M.envMapMode),g.push(M.envMapPMREM),g.push(M.envMapMaxLod),g.push(M.envMapSize),g.push(M.mapUv),g.push(M.alphaMapUv),g.push(M.lightMapUv),g.push(M.aoMapUv),g.push(M.bumpMapUv),g.push(M.normalMapUv),g.push(M.displacementMapUv),g.push(M.emissiveMapUv),g.push(M.metalnessMapUv),g.push(M.roughnessMapUv),g.push(M.anisotropyMapUv),g.push(M.clearcoatMapUv),g.push(M.clearcoatNormalMapUv),g.push(M.clearcoatRoughnessMapUv),g.push(M.diffuseRoughnessMapUv),g.push(M.iridescenceMapUv),g.push(M.iridescenceThicknessMapUv),g.push(M.sheenColorMapUv),g.push(M.sheenRoughnessMapUv),g.push(M.specularMapUv),g.push(M.specularColorMapUv),g.push(M.specularIntensityMapUv),g.push(M.transmissionMapUv),g.push(M.thicknessMapUv),g.push(M.combine),g.push(M.fogExp2),g.push(M.sizeAttenuation),g.push(M.morphTargetsCount),g.push(M.numSunLights),g.push(M.numDirLights),g.push(M.numPointLights),g.push(M.numSpotLights),g.push(M.numSpotLightMaps),g.push(M.numHemiLights),g.push(M.numRectAreaLights),g.push(M.numSunLightShadows),g.push(M.numDirLightShadows),g.push(M.numPointLightShadows),g.push(M.numSpotLightShadows),g.push(M.numSpotLightShadowsWithMaps),g.push(M.numLightProbes),g.push(M.numLightProbeGrids),g.push(M.shadowMapType),g.push(M.toneMapping),g.push(M.numClippingPlanes),g.push(M.numClipIntersection),g.push(M.depthPacking)}function f(g,M){a.disableAll(),M.instancing&&a.enable(0),M.instancingColor&&a.enable(1),M.instancingMorph&&a.enable(2),M.matcap&&a.enable(3),M.envMap&&a.enable(4),M.normalMapObjectSpace&&a.enable(5),M.normalMapTangentSpace&&a.enable(6),M.clearcoat&&a.enable(7),M.iridescence&&a.enable(8),M.alphaTest&&a.enable(9),M.vertexColors&&a.enable(10),M.vertexAlphas&&a.enable(11),M.vertexUv1s&&a.enable(12),M.vertexUv2s&&a.enable(13),M.vertexUv3s&&a.enable(14),M.vertexTangents&&a.enable(15),M.anisotropy&&a.enable(16),M.alphaHash&&a.enable(17),M.batching&&a.enable(18),M.dispersion&&a.enable(19),M.retroreflection&&a.enable(24),M.diffuseRoughness&&a.enable(25),M.batchingColor&&a.enable(20),M.gradientMap&&a.enable(21),M.packedNormalMap&&a.enable(22),M.vertexNormals&&a.enable(23),g.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.reversedDepthBuffer&&a.enable(4),M.skinning&&a.enable(5),M.morphTargets&&a.enable(6),M.morphNormals&&a.enable(7),M.morphColors&&a.enable(8),M.premultipliedAlpha&&a.enable(9),M.shadowMapEnabled&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.transmission&&a.enable(15),M.sheen&&a.enable(16),M.opaque&&a.enable(17),M.pointsUvs&&a.enable(18),M.decodeVideoTexture&&a.enable(19),M.decodeVideoTextureEmissive&&a.enable(20),M.alphaToCoverage&&a.enable(21),M.numLightProbeGrids>0&&a.enable(22),M.hasPositionAttribute&&a.enable(23),g.push(a.mask)}function S(g){let M=u[g.type],U;if(M){let I=En[M];U=mh.clone(I.uniforms)}else U=g.uniforms;return U}function A(g,M){let U=h.get(M);return U!==void 0?++U.usedTimes:(U=new zg(i,M,g,s),l.push(U),h.set(M,U)),U}function b(g){if(--g.usedTimes===0){let M=l.indexOf(g);l[M]=l[l.length-1],l.pop(),h.delete(g.cacheKey),g.destroy()}}function T(g){o.remove(g)}function E(){o.dispose()}return{getParameters:_,getProgramCacheKey:y,getUniforms:S,acquireProgram:A,releaseProgram:b,releaseShaderCache:T,programs:l,dispose:E}}function Hg(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function Wg(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Uh(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Fh(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(u){let m=0;return u.isInstancedMesh&&(m+=2),u.isSkinnedMesh&&(m+=1),m}function o(u,m,_,y,p,f){let S=i[e];return S===void 0?(S={id:u.id,object:u,geometry:m,material:_,materialVariant:a(u),groupOrder:y,renderOrder:u.renderOrder,z:p,group:f},i[e]=S):(S.id=u.id,S.object=u,S.geometry=m,S.material=_,S.materialVariant=a(u),S.groupOrder=y,S.renderOrder=u.renderOrder,S.z=p,S.group=f),e++,S}function c(u,m,_,y,p,f,S){S.reversedDepth===!0&&(p=-p);let A=o(u,m,_,y,p,f);_.transmission>0?n.push(A):_.transparent===!0?s.push(A):t.push(A)}function l(u,m,_,y,p,f){let S=o(u,m,_,y,p,f);_.transmission>0?n.unshift(S):_.transparent===!0?s.unshift(S):t.unshift(S)}function h(u,m){t.length>1&&t.sort(u||Wg),n.length>1&&n.sort(m||Uh),s.length>1&&s.sort(m||Uh)}function d(){for(let u=e,m=i.length;u<m;u++){let _=i[u];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:d,sort:h}}function Xg(){let i=new WeakMap;function e(n,s){let r=i.get(n),a;return r===void 0?(a=new Fh,i.set(n,[a])):s>=r.length?(a=new Fh,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function qg(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new B,color:new ze};break;case"SpotLight":t={position:new B,direction:new B,color:new ze,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new ze,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new ze,groundColor:new ze};break;case"RectAreaLight":t={color:new ze,position:new B,halfWidth:new B,halfHeight:new B};break}return i[e.id]=t,t}}}function Yg(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var Zg=0;function $g(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Jg(i){let e=new qg,t=Yg(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 B);let s=new B,r=new ht,a=new ht;function o(l){let h=0,d=0,u=0;for(let F=0;F<9;F++)n.probe[F].set(0,0,0);let m=0,_=0,y=0,p=0,f=0,S=0,A=0,b=0,T=0,E=0,g=0,M=0,U=0,I=0;l.sort($g);for(let F=0,H=l.length;F<H;F++){let C=l[F],Y=C.color,J=C.intensity,z=C.distance,te=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===si?te=C.shadow.map.texture:te=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=Y.r*J,d+=Y.g*J,u+=Y.b*J;else if(C.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(C.sh.coefficients[W],J);I++}else if(C.isSunLight){let W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let $=C.shadow,ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize.copy($.mapSize).multiply($.getFrameExtents()),n.sunShadow[_]=ae,n.sunShadowMap[_]=te;let _e=$.getViewportCount();for(let De=0;De<_e;De++)n.sunShadowMatrix[y+De]=$.getMatrix(De),n.sunShadowCascade[y+De]=$._cascadeData[De];y+=_e,_++}n.sun[m]=W,m++}else if(C.isDirectionalLight){let W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let $=C.shadow,ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize=$.mapSize,n.directionalShadow[p]=ae,n.directionalShadowMap[p]=te,n.directionalShadowMatrix[p]=C.shadow.matrix,T++}n.directional[p]=W,p++}else if(C.isSpotLight){let W=e.get(C);W.position.setFromMatrixPosition(C.matrixWorld),W.color.copy(Y).multiplyScalar(J),W.distance=z,W.coneCos=Math.cos(C.angle),W.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),W.decay=C.decay,n.spot[S]=W;let $=C.shadow;if(C.map&&(n.spotLightMap[M]=C.map,M++,$.updateMatrices(C),C.castShadow&&U++),n.spotLightMatrix[S]=$.matrix,C.castShadow){let ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize=$.mapSize,n.spotShadow[S]=ae,n.spotShadowMap[S]=te,g++}S++}else if(C.isRectAreaLight){let W=e.get(C);W.color.copy(Y).multiplyScalar(J),W.halfWidth.set(C.width*.5,0,0),W.halfHeight.set(0,C.height*.5,0),n.rectArea[A]=W,A++}else if(C.isPointLight){let W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),W.distance=C.distance,W.decay=C.decay,C.castShadow){let $=C.shadow,ae=t.get(C);ae.shadowIntensity=$.intensity,ae.shadowBias=$.bias,ae.shadowNormalBias=$.normalBias,ae.shadowRadius=$.radius,ae.shadowMapSize=$.mapSize,ae.shadowCameraNear=$.camera.near,ae.shadowCameraFar=$.camera.far,n.pointShadow[f]=ae,n.pointShadowMap[f]=te,n.pointShadowMatrix[f]=C.shadow.matrix,E++}n.point[f]=W,f++}else if(C.isHemisphereLight){let W=e.get(C);W.skyColor.copy(C.color).multiplyScalar(J),W.groundColor.copy(C.groundColor).multiplyScalar(J),n.hemi[b]=W,b++}}A>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=me.LTC_FLOAT_1,n.rectAreaLTC2=me.LTC_FLOAT_2):(n.rectAreaLTC1=me.LTC_HALF_1,n.rectAreaLTC2=me.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let D=n.hash;(D.sunLength!==m||D.directionalLength!==p||D.pointLength!==f||D.spotLength!==S||D.rectAreaLength!==A||D.hemiLength!==b||D.numSunShadows!==_||D.numDirectionalShadows!==T||D.numPointShadows!==E||D.numSpotShadows!==g||D.numSpotMaps!==M||D.numLightProbes!==I)&&(n.sun.length=m,n.directional.length=p,n.spot.length=S,n.rectArea.length=A,n.point.length=f,n.hemi.length=b,n.sunShadow.length=_,n.sunShadowMap.length=_,n.sunShadowMatrix.length=y,n.sunShadowCascade.length=y,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.directionalShadowMatrix.length=T,n.pointShadow.length=E,n.pointShadowMap.length=E,n.pointShadowMatrix.length=E,n.spotShadow.length=g,n.spotShadowMap.length=g,n.spotLightMatrix.length=g+M-U,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=U,n.numLightProbes=I,D.sunLength=m,D.directionalLength=p,D.pointLength=f,D.spotLength=S,D.rectAreaLength=A,D.hemiLength=b,D.numSunShadows=_,D.numDirectionalShadows=T,D.numPointShadows=E,D.numSpotShadows=g,D.numSpotMaps=M,D.numLightProbes=I,n.version=Zg++)}function c(l,h){let d=0,u=0,m=0,_=0,y=0,p=0,f=h.matrixWorldInverse;for(let S=0,A=l.length;S<A;S++){let b=l[S];if(b.isSunLight){let T=n.sun[d];T.direction.setFromMatrixPosition(b.matrixWorld),T.direction.transformDirection(f),d++}else if(b.isDirectionalLight){let T=n.directional[u];T.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(f),u++}else if(b.isSpotLight){let T=n.spot[_];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(f),T.direction.setFromMatrixPosition(b.matrixWorld),s.setFromMatrixPosition(b.target.matrixWorld),T.direction.sub(s),T.direction.transformDirection(f),_++}else if(b.isRectAreaLight){let T=n.rectArea[y];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(f),a.identity(),r.copy(b.matrixWorld),r.premultiply(f),a.extractRotation(r),T.halfWidth.set(b.width*.5,0,0),T.halfHeight.set(0,b.height*.5,0),T.halfWidth.applyMatrix4(a),T.halfHeight.applyMatrix4(a),y++}else if(b.isPointLight){let T=n.point[m];T.position.setFromMatrixPosition(b.matrixWorld),T.position.applyMatrix4(f),m++}else if(b.isHemisphereLight){let T=n.hemi[p];T.direction.setFromMatrixPosition(b.matrixWorld),T.direction.transformDirection(f),p++}}}return{setup:o,setupView:c,state:n}}function Oh(i){let e=new Jg(i),t=[],n=[],s=[];function r(d){h.camera=d,t.length=0,n.length=0,s.length=0}function a(d){d.isLightProbeGrid?s.push(d):t.push(d)}function o(d){n.push(d)}function c(){e.setup(t),s.sort((d,u)=>d.priority-u.priority||d.id-u.id)}function l(d){e.setupView(t,d)}let h={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function Kg(i){let e=new WeakMap;function t(s,r=0){let a=e.get(s),o;return a===void 0?(o=new Oh(i),e.set(s,[o])):r>=a.length?(o=new Oh(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}var jg=`void main() {
4172
+ Program Info Log: `+I+`
4173
+ `+C+`
4174
+ `+W)}else I!==""?Ue("WebGLProgram: Program Info Log:",I):(q===""||Z==="")&&(ee=!1);ee&&(R.diagnostics={runnable:B,programLog:I,vertexShader:{log:q,prefix:x},fragmentShader:{log:Z,prefix:m}})}s.deleteShader(S),s.deleteShader(M),g=new gs(s,_),v=Kg(s,_)}let g;this.getUniforms=function(){return g===void 0&&E(this),g};let v;this.getAttributes=function(){return v===void 0&&E(this),v};let N=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return N===!1&&(N=s.getProgramParameter(_,Vg)),N},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Gg++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=M,this}var c0=0,Zl=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let 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){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new $l(e),t.set(e,n)),n}},$l=class{constructor(e){this.id=c0++,this.code=e,this.usedTimes=0}};function h0(i){return i===_i||i===er||i===tr}function u0(i,e,t,n,s,r){let o=new Ds,a=new Zl,c=new Set,l=[],h=new Map,d=n.logarithmicDepthBuffer,u={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(g){return c.add(g),g===0?"uv":`uv${g}`}function _(g,v,N,R,D,U){let z=R.fog,I=D.geometry,q=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?R.environment:null,Z=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,B=e.get(g.envMap||q,Z),ee=u[g.type],C=n.precision;g.precision!==null&&(C=n.getMaxPrecision(g.precision),C!==g.precision&&Ue("WebGLProgram.getParameters:",g.precision,"not supported, using",C,"instead."));let W=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,K=W!==void 0?W.length:0,ve=0;I.morphAttributes.position!==void 0&&(ve=1),I.morphAttributes.normal!==void 0&&(ve=2),I.morphAttributes.color!==void 0&&(ve=3);let we,G,he,fe;if(ee){let ce=Ln[ee];we=ce.vertexShader,G=ce.fragmentShader}else{we=g.vertexShader,G=g.fragmentShader;let ce=a.getVertexShaderStage(g),Ne=a.getFragmentShaderStage(g);a.update(g,ce,Ne),he=ce.id,fe=Ne.id}let Ee=i.getRenderTarget(),le=i.state.buffers.depth.getReversed(),ye=D.isInstancedMesh===!0,Ve=D.isBatchedMesh===!0,Me=!!g.map,Fe=!!g.matcap,Te=!!B,De=Te&&B.isPMREMTexture===!0,Je=!!g.aoMap,ct=!!g.lightMap,yt=!!g.bumpMap&&g.wireframe===!1,et=!!g.normalMap,pt=!!g.displacementMap,Xe=!!g.emissiveMap,vt=!!g.metalnessMap,Lt=!!g.roughnessMap,Ft=g.anisotropy>0,O=g.clearcoat>0,Rt=g.diffuseRoughness>0,it=g.dispersion>0,st=g.retroreflectivity>0,_e=g.iridescence>0,mt=g.sheen>0,Le=g.transmission>0,Oe=Ft&&!!g.anisotropyMap,T=O&&!!g.clearcoatMap,y=O&&!!g.clearcoatNormalMap,V=O&&!!g.clearcoatRoughnessMap,ae=Rt&&!!g.diffuseRoughnessMap,se=_e&&!!g.iridescenceMap,ue=_e&&!!g.iridescenceThicknessMap,me=mt&&!!g.sheenColorMap,j=mt&&!!g.sheenRoughnessMap,Q=!!g.specularMap,pe=!!g.specularColorMap,L=!!g.specularIntensityMap,te=Le&&!!g.transmissionMap,P=Le&&!!g.thicknessMap,ne=!!g.gradientMap,$=!!g.alphaMap,ie=g.alphaTest>0,oe=!!g.alphaHash,re=!!g.extensions,J=Pn;g.toneMapped&&(Ee===null||Ee.isXRRenderTarget===!0)&&(J=i.toneMapping);let de=De?B.isCompressedCubeTexture?B.image[0].mipmaps:B.mipmaps:null,Ie={shaderID:ee,shaderType:g.type,shaderName:g.name,vertexShader:we,fragmentShader:G,defines:g.defines,customVertexShaderID:he,customFragmentShaderID:fe,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:C,batching:Ve,batchingColor:Ve&&D._colorsTexture!==null,instancing:ye,instancingColor:ye&&D.instanceColor!==null,instancingMorph:ye&&D.morphTexture!==null,outputColorSpace:Ee===null?i.outputColorSpace:Ee.isXRRenderTarget===!0?Ee.texture.colorSpace:Qe.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:Me,matcap:Fe,envMap:Te,envMapMode:Te&&B.mapping,envMapPMREM:De,envMapMaxLod:De?de.length-1:null,envMapSize:De?de[0].width:null,aoMap:Je,lightMap:ct,bumpMap:yt,normalMap:et,displacementMap:pt,emissiveMap:Xe,normalMapObjectSpace:et&&g.normalMapType===xh,normalMapTangentSpace:et&&g.normalMapType===ha,packedNormalMap:et&&g.normalMapType===ha&&h0(g.normalMap.format),metalnessMap:vt,roughnessMap:Lt,anisotropy:Ft,anisotropyMap:Oe,clearcoat:O,clearcoatMap:T,clearcoatNormalMap:y,clearcoatRoughnessMap:V,diffuseRoughness:Rt,diffuseRoughnessMap:ae,dispersion:it,retroreflection:st,iridescence:_e,iridescenceMap:se,iridescenceThicknessMap:ue,sheen:mt,sheenColorMap:me,sheenRoughnessMap:j,specularMap:Q,specularColorMap:pe,specularIntensityMap:L,transmission:Le,transmissionMap:te,thicknessMap:P,gradientMap:ne,opaque:g.transparent===!1&&g.blending===ds&&g.alphaToCoverage===!1,alphaMap:$,alphaTest:ie,alphaHash:oe,combine:g.combine,mapUv:Me&&p(g.map.channel),aoMapUv:Je&&p(g.aoMap.channel),lightMapUv:ct&&p(g.lightMap.channel),bumpMapUv:yt&&p(g.bumpMap.channel),normalMapUv:et&&p(g.normalMap.channel),displacementMapUv:pt&&p(g.displacementMap.channel),emissiveMapUv:Xe&&p(g.emissiveMap.channel),metalnessMapUv:vt&&p(g.metalnessMap.channel),roughnessMapUv:Lt&&p(g.roughnessMap.channel),anisotropyMapUv:Oe&&p(g.anisotropyMap.channel),clearcoatMapUv:T&&p(g.clearcoatMap.channel),clearcoatNormalMapUv:y&&p(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:V&&p(g.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:ae&&p(g.diffuseRoughnessMap.channel),iridescenceMapUv:se&&p(g.iridescenceMap.channel),iridescenceThicknessMapUv:ue&&p(g.iridescenceThicknessMap.channel),sheenColorMapUv:me&&p(g.sheenColorMap.channel),sheenRoughnessMapUv:j&&p(g.sheenRoughnessMap.channel),specularMapUv:Q&&p(g.specularMap.channel),specularColorMapUv:pe&&p(g.specularColorMap.channel),specularIntensityMapUv:L&&p(g.specularIntensityMap.channel),transmissionMapUv:te&&p(g.transmissionMap.channel),thicknessMapUv:P&&p(g.thicknessMap.channel),alphaMapUv:$&&p(g.alphaMap.channel),vertexTangents:!!I.attributes.tangent&&(et||Ft),vertexNormals:!!I.attributes.normal,vertexColors:g.vertexColors,vertexAlphas:g.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,pointsUvs:D.isPoints===!0&&!!I.attributes.uv&&(Me||$),fog:!!z,useFog:g.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||I.attributes.normal===void 0&&et===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:le,skinning:D.isSkinnedMesh===!0,hasPositionAttribute:I.attributes.position!==void 0,morphTargets:I.morphAttributes.position!==void 0,morphNormals:I.morphAttributes.normal!==void 0,morphColors:I.morphAttributes.color!==void 0,morphTargetsCount:K,morphTextureStride:ve,numSunLights:v.sun.length,numDirLights:v.directional.length,numPointLights:v.point.length,numSpotLights:v.spot.length,numSpotLightMaps:v.spotLightMap.length,numRectAreaLights:v.rectArea.length,numHemiLights:v.hemi.length,numSunLightShadows:v.sunShadowMap.length,numDirLightShadows:v.directionalShadowMap.length,numPointLightShadows:v.pointShadowMap.length,numSpotLightShadows:v.spotShadowMap.length,numSpotLightShadowsWithMaps:v.numSpotLightShadowsWithMaps,numLightProbes:v.numLightProbes,numLightProbeGrids:U.filter(ce=>ce.texture!==null).length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&N.length>0,shadowMapType:i.shadowMap.type,toneMapping:J,decodeVideoTexture:Me&&g.map.isVideoTexture===!0&&Qe.getTransfer(g.map.colorSpace)===lt,decodeVideoTextureEmissive:Xe&&g.emissiveMap.isVideoTexture===!0&&Qe.getTransfer(g.emissiveMap.colorSpace)===lt,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===pn,flipSided:g.side===Zt,useDepthPacking:g.depthPacking>=0,depthPacking:g.depthPacking||0,index0AttributeName:g.index0AttributeName,extensionClipCullDistance:re&&g.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(re&&g.extensions.multiDraw===!0||Ve)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Ie.vertexUv1s=c.has(1),Ie.vertexUv2s=c.has(2),Ie.vertexUv3s=c.has(3),c.clear(),Ie}function x(g){let v=[];if(g.shaderID?v.push(g.shaderID):(v.push(g.customVertexShaderID),v.push(g.customFragmentShaderID)),g.defines!==void 0)for(let N in g.defines)v.push(N),v.push(g.defines[N]);return g.isRawShaderMaterial===!1&&(m(v,g),f(v,g),v.push(i.outputColorSpace)),v.push(g.customProgramCacheKey),v.join()}function m(g,v){g.push(v.precision),g.push(v.outputColorSpace),g.push(v.envMapMode),g.push(v.envMapPMREM),g.push(v.envMapMaxLod),g.push(v.envMapSize),g.push(v.mapUv),g.push(v.alphaMapUv),g.push(v.lightMapUv),g.push(v.aoMapUv),g.push(v.bumpMapUv),g.push(v.normalMapUv),g.push(v.displacementMapUv),g.push(v.emissiveMapUv),g.push(v.metalnessMapUv),g.push(v.roughnessMapUv),g.push(v.anisotropyMapUv),g.push(v.clearcoatMapUv),g.push(v.clearcoatNormalMapUv),g.push(v.clearcoatRoughnessMapUv),g.push(v.diffuseRoughnessMapUv),g.push(v.iridescenceMapUv),g.push(v.iridescenceThicknessMapUv),g.push(v.sheenColorMapUv),g.push(v.sheenRoughnessMapUv),g.push(v.specularMapUv),g.push(v.specularColorMapUv),g.push(v.specularIntensityMapUv),g.push(v.transmissionMapUv),g.push(v.thicknessMapUv),g.push(v.combine),g.push(v.fogExp2),g.push(v.sizeAttenuation),g.push(v.morphTargetsCount),g.push(v.numSunLights),g.push(v.numDirLights),g.push(v.numPointLights),g.push(v.numSpotLights),g.push(v.numSpotLightMaps),g.push(v.numHemiLights),g.push(v.numRectAreaLights),g.push(v.numSunLightShadows),g.push(v.numDirLightShadows),g.push(v.numPointLightShadows),g.push(v.numSpotLightShadows),g.push(v.numSpotLightShadowsWithMaps),g.push(v.numLightProbes),g.push(v.numLightProbeGrids),g.push(v.shadowMapType),g.push(v.toneMapping),g.push(v.numClippingPlanes),g.push(v.numClipIntersection),g.push(v.depthPacking)}function f(g,v){o.disableAll(),v.instancing&&o.enable(0),v.instancingColor&&o.enable(1),v.instancingMorph&&o.enable(2),v.matcap&&o.enable(3),v.envMap&&o.enable(4),v.normalMapObjectSpace&&o.enable(5),v.normalMapTangentSpace&&o.enable(6),v.clearcoat&&o.enable(7),v.iridescence&&o.enable(8),v.alphaTest&&o.enable(9),v.vertexColors&&o.enable(10),v.vertexAlphas&&o.enable(11),v.vertexUv1s&&o.enable(12),v.vertexUv2s&&o.enable(13),v.vertexUv3s&&o.enable(14),v.vertexTangents&&o.enable(15),v.anisotropy&&o.enable(16),v.alphaHash&&o.enable(17),v.batching&&o.enable(18),v.dispersion&&o.enable(19),v.retroreflection&&o.enable(24),v.diffuseRoughness&&o.enable(25),v.batchingColor&&o.enable(20),v.gradientMap&&o.enable(21),v.packedNormalMap&&o.enable(22),v.vertexNormals&&o.enable(23),g.push(o.mask),o.disableAll(),v.fog&&o.enable(0),v.useFog&&o.enable(1),v.flatShading&&o.enable(2),v.logarithmicDepthBuffer&&o.enable(3),v.reversedDepthBuffer&&o.enable(4),v.skinning&&o.enable(5),v.morphTargets&&o.enable(6),v.morphNormals&&o.enable(7),v.morphColors&&o.enable(8),v.premultipliedAlpha&&o.enable(9),v.shadowMapEnabled&&o.enable(10),v.doubleSided&&o.enable(11),v.flipSided&&o.enable(12),v.useDepthPacking&&o.enable(13),v.dithering&&o.enable(14),v.transmission&&o.enable(15),v.sheen&&o.enable(16),v.opaque&&o.enable(17),v.pointsUvs&&o.enable(18),v.decodeVideoTexture&&o.enable(19),v.decodeVideoTextureEmissive&&o.enable(20),v.alphaToCoverage&&o.enable(21),v.numLightProbeGrids>0&&o.enable(22),v.hasPositionAttribute&&o.enable(23),g.push(o.mask)}function w(g){let v=u[g.type],N;if(v){let R=Ln[v];N=Dh.clone(R.uniforms)}else N=g.uniforms;return N}function A(g,v){let N=h.get(v);return N!==void 0?++N.usedTimes:(N=new l0(i,v,g,s),l.push(N),h.set(v,N)),N}function S(g){if(--g.usedTimes===0){let v=l.indexOf(g);l[v]=l[l.length-1],l.pop(),h.delete(g.cacheKey),g.destroy()}}function M(g){a.remove(g)}function E(){a.dispose()}return{getParameters:_,getProgramCacheKey:x,getUniforms:w,acquireProgram:A,releaseProgram:S,releaseShaderCache:M,programs:l,dispose:E}}function d0(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function s(o,a,c){i.get(o)[a]=c}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function f0(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function Qh(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function eu(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(u){let p=0;return u.isInstancedMesh&&(p+=2),u.isSkinnedMesh&&(p+=1),p}function a(u,p,_,x,m,f){let w=i[e];return w===void 0?(w={id:u.id,object:u,geometry:p,material:_,materialVariant:o(u),groupOrder:x,renderOrder:u.renderOrder,z:m,group:f},i[e]=w):(w.id=u.id,w.object=u,w.geometry=p,w.material=_,w.materialVariant=o(u),w.groupOrder=x,w.renderOrder=u.renderOrder,w.z=m,w.group=f),e++,w}function c(u,p,_,x,m,f,w){w.reversedDepth===!0&&(m=-m);let A=a(u,p,_,x,m,f);_.transmission>0?n.push(A):_.transparent===!0?s.push(A):t.push(A)}function l(u,p,_,x,m,f){let w=a(u,p,_,x,m,f);_.transmission>0?n.unshift(w):_.transparent===!0?s.unshift(w):t.unshift(w)}function h(u,p){t.length>1&&t.sort(u||f0),n.length>1&&n.sort(p||Qh),s.length>1&&s.sort(p||Qh)}function d(){for(let u=e,p=i.length;u<p;u++){let _=i[u];if(_.id===null)break;_.id=null,_.object=null,_.geometry=null,_.material=null,_.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:c,unshift:l,finish:d,sort:h}}function p0(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new eu,i.set(n,[o])):s>=r.length?(o=new eu,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function m0(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new k,color:new We};break;case"SpotLight":t={position:new k,direction:new k,color:new We,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new We,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new We,groundColor:new We};break;case"RectAreaLight":t={color:new We,position:new k,halfWidth:new k,halfHeight:new k};break}return i[e.id]=t,t}}}function g0(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var _0=0;function x0(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function y0(i){let e=new m0,t=g0(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],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 k);let s=new k,r=new ft,o=new ft;function a(l){let h=0,d=0,u=0;for(let U=0;U<9;U++)n.probe[U].set(0,0,0);let p=0,_=0,x=0,m=0,f=0,w=0,A=0,S=0,M=0,E=0,g=0,v=0,N=0,R=0;l.sort(x0);for(let U=0,z=l.length;U<z;U++){let I=l[U],q=I.color,Z=I.intensity,B=I.distance,ee=null;if(I.shadow&&I.shadow.map&&(I.shadow.map.texture.format===_i?ee=I.shadow.map.texture:ee=I.shadow.map.depthTexture||I.shadow.map.texture),I.isAmbientLight)h+=q.r*Z,d+=q.g*Z,u+=q.b*Z;else if(I.isLightProbe){for(let C=0;C<9;C++)n.probe[C].addScaledVector(I.sh.coefficients[C],Z);R++}else if(I.isSunLight){let C=e.get(I);if(C.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let W=I.shadow,K=t.get(I);K.shadowIntensity=W.intensity,K.shadowBias=W.bias,K.shadowNormalBias=W.normalBias,K.shadowRadius=W.radius,K.shadowMapSize.copy(W.mapSize).multiply(W.getFrameExtents()),n.sunShadow[_]=K,n.sunShadowMap[_]=ee;let ve=W.getViewportCount();for(let we=0;we<ve;we++)n.sunShadowMatrix[x+we]=W.getMatrix(we),n.sunShadowCascade[x+we]=W._cascadeData[we];x+=ve,_++}n.sun[p]=C,p++}else if(I.isDirectionalLight){let C=e.get(I);if(C.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){let W=I.shadow,K=t.get(I);K.shadowIntensity=W.intensity,K.shadowBias=W.bias,K.shadowNormalBias=W.normalBias,K.shadowRadius=W.radius,K.shadowMapSize=W.mapSize,n.directionalShadow[m]=K,n.directionalShadowMap[m]=ee,n.directionalShadowMatrix[m]=I.shadow.matrix,M++}n.directional[m]=C,m++}else if(I.isSpotLight){let C=e.get(I);C.position.setFromMatrixPosition(I.matrixWorld),C.color.copy(q).multiplyScalar(Z),C.distance=B,C.coneCos=Math.cos(I.angle),C.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),C.decay=I.decay,n.spot[w]=C;let W=I.shadow;if(I.map&&(n.spotLightMap[v]=I.map,v++,W.updateMatrices(I),I.castShadow&&N++),n.spotLightMatrix[w]=W.matrix,I.castShadow){let K=t.get(I);K.shadowIntensity=W.intensity,K.shadowBias=W.bias,K.shadowNormalBias=W.normalBias,K.shadowRadius=W.radius,K.shadowMapSize=W.mapSize,n.spotShadow[w]=K,n.spotShadowMap[w]=ee,g++}w++}else if(I.isRectAreaLight){let C=e.get(I);C.color.copy(q).multiplyScalar(Z),C.halfWidth.set(I.width*.5,0,0),C.halfHeight.set(0,I.height*.5,0),n.rectArea[A]=C,A++}else if(I.isPointLight){let C=e.get(I);if(C.color.copy(I.color).multiplyScalar(I.intensity),C.distance=I.distance,C.decay=I.decay,I.castShadow){let W=I.shadow,K=t.get(I);K.shadowIntensity=W.intensity,K.shadowBias=W.bias,K.shadowNormalBias=W.normalBias,K.shadowRadius=W.radius,K.shadowMapSize=W.mapSize,K.shadowCameraNear=W.camera.near,K.shadowCameraFar=W.camera.far,n.pointShadow[f]=K,n.pointShadowMap[f]=ee,n.pointShadowMatrix[f]=I.shadow.matrix,E++}n.point[f]=C,f++}else if(I.isHemisphereLight){let C=e.get(I);C.skyColor.copy(I.color).multiplyScalar(Z),C.groundColor.copy(I.groundColor).multiplyScalar(Z),n.hemi[S]=C,S++}}A>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=be.LTC_FLOAT_1,n.rectAreaLTC2=be.LTC_FLOAT_2):(n.rectAreaLTC1=be.LTC_HALF_1,n.rectAreaLTC2=be.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=d,n.ambient[2]=u;let D=n.hash;(D.sunLength!==p||D.directionalLength!==m||D.pointLength!==f||D.spotLength!==w||D.rectAreaLength!==A||D.hemiLength!==S||D.numSunShadows!==_||D.numDirectionalShadows!==M||D.numPointShadows!==E||D.numSpotShadows!==g||D.numSpotMaps!==v||D.numLightProbes!==R)&&(n.sun.length=p,n.directional.length=m,n.spot.length=w,n.rectArea.length=A,n.point.length=f,n.hemi.length=S,n.sunShadow.length=_,n.sunShadowMap.length=_,n.sunShadowMatrix.length=x,n.sunShadowCascade.length=x,n.directionalShadow.length=M,n.directionalShadowMap.length=M,n.directionalShadowMatrix.length=M,n.pointShadow.length=E,n.pointShadowMap.length=E,n.pointShadowMatrix.length=E,n.spotShadow.length=g,n.spotShadowMap.length=g,n.spotLightMatrix.length=g+v-N,n.spotLightMap.length=v,n.numSpotLightShadowsWithMaps=N,n.numLightProbes=R,D.sunLength=p,D.directionalLength=m,D.pointLength=f,D.spotLength=w,D.rectAreaLength=A,D.hemiLength=S,D.numSunShadows=_,D.numDirectionalShadows=M,D.numPointShadows=E,D.numSpotShadows=g,D.numSpotMaps=v,D.numLightProbes=R,n.version=_0++)}function c(l,h){let d=0,u=0,p=0,_=0,x=0,m=0,f=h.matrixWorldInverse;for(let w=0,A=l.length;w<A;w++){let S=l[w];if(S.isSunLight){let M=n.sun[d];M.direction.setFromMatrixPosition(S.matrixWorld),M.direction.transformDirection(f),d++}else if(S.isDirectionalLight){let M=n.directional[u];M.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(f),u++}else if(S.isSpotLight){let M=n.spot[_];M.position.setFromMatrixPosition(S.matrixWorld),M.position.applyMatrix4(f),M.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(f),_++}else if(S.isRectAreaLight){let M=n.rectArea[x];M.position.setFromMatrixPosition(S.matrixWorld),M.position.applyMatrix4(f),o.identity(),r.copy(S.matrixWorld),r.premultiply(f),o.extractRotation(r),M.halfWidth.set(S.width*.5,0,0),M.halfHeight.set(0,S.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let M=n.point[p];M.position.setFromMatrixPosition(S.matrixWorld),M.position.applyMatrix4(f),p++}else if(S.isHemisphereLight){let M=n.hemi[m];M.direction.setFromMatrixPosition(S.matrixWorld),M.direction.transformDirection(f),m++}}}return{setup:a,setupView:c,state:n}}function tu(i){let e=new y0(i),t=[],n=[],s=[];function r(d){h.camera=d,t.length=0,n.length=0,s.length=0}function o(d){d.isLightProbeGrid?s.push(d):t.push(d)}function a(d){n.push(d)}function c(){e.setup(t),s.sort((d,u)=>d.priority-u.priority||d.id-u.id)}function l(d){e.setupView(t,d)}let h={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:h,setupLights:c,setupLightsView:l,pushLight:o,pushShadow:a}}function v0(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new tu(i),e.set(s,[a])):r>=o.length?(a=new tu(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var b0=`void main() {
4175
4175
  gl_Position = vec4( position, 1.0 );
4176
- }`,Qg=`uniform sampler2D shadow_pass;
4176
+ }`,M0=`uniform sampler2D shadow_pass;
4177
4177
  uniform vec2 resolution;
4178
4178
  uniform float radius;
4179
4179
  void main() {
@@ -4198,12 +4198,12 @@ void main() {
4198
4198
  squared_mean = squared_mean / samples;
4199
4199
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4200
4200
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4201
- }`,e_=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],t_=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Bh=new ht,Ws=new B,Tl=new B;function n_(i,e,t){let n=new Kn,s=new Fe,r=new Fe,a=new dt,o=new $r,c=new Jr,l={},h=t.maxTextureSize,d={[ii]:Vt,[Vt]:ii,[Mn]:Mn},u=new vn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:jg,fragmentShader:Qg}),m=u.clone();m.defines.HORIZONTAL_PASS=1;let _=new Wt;_.setAttribute("position",new Gt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new en(_,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Us;let f=this.type;this.render=function(E,g,M){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||E.length===0)return;this.type===Ic&&(Ie("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Us);let U=i.getRenderTarget(),I=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),F=i.state;F.setBlending(yi),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);let H=f!==this.type;H&&g.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(Y=>Y.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,Y=E.length;C<Y;C++){let J=E[C],z=J.shadow;if(z===void 0){Ie("WebGLShadowMap:",J,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;s.copy(z.mapSize);let te=z.getFrameExtents();s.multiply(te),r.copy(z.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/te.x),s.x=r.x*te.x,z.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/te.y),s.y=r.y*te.y,z.mapSize.y=r.y));let W=i.state.buffers.depth.getReversed();if(z.camera._reversedDepth=W,z.map===null||H===!0){if(z.map!==null&&(z.map.depthTexture!==null&&(z.map.depthTexture.dispose(),z.map.depthTexture=null),z.map.dispose()),this.type===Qi){if(J.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new Qt(s.x,s.y,{format:si,type:mn,minFilter:kt,magFilter:kt,generateMipmaps:!1}),z.map.texture.name=J.name+".shadowMap",z.map.depthTexture=new zn(s.x,s.y,pn),z.map.depthTexture.name=J.name+".shadowMapDepth",z.map.depthTexture.format=Fn,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=wt,z.map.depthTexture.magFilter=wt}else J.isPointLight?(z.map=new qs(s.x),z.map.depthTexture=new Ts(s.x,fn)):(z.map=new Qt(s.x,s.y),z.map.depthTexture=new zn(s.x,s.y,fn)),z.map.depthTexture.name=J.name+".shadowMap",z.map.depthTexture.format=Fn,this.type===Us?(z.map.depthTexture.compareFunction=W?ll:ol,z.map.depthTexture.minFilter=kt,z.map.depthTexture.magFilter=kt):(z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=wt,z.map.depthTexture.magFilter=wt);z.camera.updateProjectionMatrix()}z.map.isWebGLCubeRenderTarget!==!0&&(z.map.width!==s.x||z.map.height!==s.y)&&z.map.setSize(s.x,s.y);let $=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();J.isPointLight!==!0&&z.updateMatrices(J,M);let ae=(z.camera.layers.mask&4294967294)!==0?z.camera.layers:M.layers;for(let _e=0;_e<$;_e++){let De=z.getCamera(_e);if(J.isPointLight){let j=z.camera,pe=z.matrix,ye=J.distance||j.far;ye!==j.far&&(j.far=ye,j.updateProjectionMatrix()),Ws.setFromMatrixPosition(J.matrixWorld),j.position.copy(Ws),Tl.copy(j.position),Tl.add(e_[_e]),j.up.copy(t_[_e]),j.lookAt(Tl),j.updateMatrixWorld(),pe.makeTranslation(-Ws.x,-Ws.y,-Ws.z),Bh.multiplyMatrices(j.projectionMatrix,j.matrixWorldInverse),z._frustum.setFromProjectionMatrix(Bh,j.coordinateSystem,j.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)i.setRenderTarget(z.map,_e),i.clear();else{_e===0&&(i.setRenderTarget(z.map),i.clear());let j=z.getViewport(_e);a.set(r.x*j.x,r.y*j.y,r.x*j.z,r.y*j.w),F.viewport(a)}n=z.getFrustum(_e),b(g,M,De,J,ae,this.type)}z.isPointLightShadow!==!0&&this.type===Qi&&S(z,M),z.needsUpdate=!1}f=this.type,p.needsUpdate=!1,i.setRenderTarget(U,I,D)};function S(E,g){let M=e.update(y);u.defines.VSM_SAMPLES!==E.blurSamples&&(u.defines.VSM_SAMPLES=E.blurSamples,m.defines.VSM_SAMPLES=E.blurSamples,u.needsUpdate=!0,m.needsUpdate=!0),E.mapPass===null?E.mapPass=new Qt(s.x,s.y,{format:si,type:mn}):(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)&&E.mapPass.setSize(E.map.width,E.map.height),u.uniforms.shadow_pass.value=E.map.depthTexture,u.uniforms.resolution.value.set(E.map.width,E.map.height),u.uniforms.radius.value=E.radius,i.setRenderTarget(E.mapPass),i.clear(),i.renderBufferDirect(g,null,M,u,y,null),m.uniforms.shadow_pass.value=E.mapPass.texture,m.uniforms.resolution.value.set(E.map.width,E.map.height),m.uniforms.radius.value=E.radius,i.setRenderTarget(E.map),i.clear(),i.renderBufferDirect(g,null,M,m,y,null)}function A(E,g,M,U){let I=null,D=M.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(D!==void 0)I=D;else if(I=M.isPointLight===!0?c:o,i.localClippingEnabled&&g.clipShadows===!0&&Array.isArray(g.clippingPlanes)&&g.clippingPlanes.length!==0||g.displacementMap&&g.displacementScale!==0||g.alphaMap&&g.alphaTest>0||g.map&&g.alphaTest>0||g.alphaToCoverage===!0){let F=I.uuid,H=g.uuid,C=l[F];C===void 0&&(C={},l[F]=C);let Y=C[H];Y===void 0&&(Y=I.clone(),C[H]=Y,g.addEventListener("dispose",T)),I=Y}if(I.visible=g.visible,I.wireframe=g.wireframe,U===Qi?I.side=g.shadowSide!==null?g.shadowSide:g.side:I.side=g.shadowSide!==null?g.shadowSide:d[g.side],I.alphaMap=g.alphaMap,I.alphaTest=g.alphaToCoverage===!0?.5:g.alphaTest,I.map=g.map,I.clipShadows=g.clipShadows,I.clippingPlanes=g.clippingPlanes,I.clipIntersection=g.clipIntersection,I.displacementMap=g.displacementMap,I.displacementScale=g.displacementScale,I.displacementBias=g.displacementBias,I.wireframeLinewidth=g.wireframeLinewidth,I.linewidth=g.linewidth,M.isPointLight===!0&&I.isMeshDistanceMaterial===!0){let F=i.properties.get(I);F.light=M}return I}function b(E,g,M,U,I,D){if(E.visible===!1)return;if(E.layers.test(I)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&D===Qi)&&(!E.frustumCulled||E.intersectsFrustum(n))){E.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,E.matrixWorld);let C=e.update(E),Y=E.material;if(Array.isArray(Y)){let J=C.groups;for(let z=0,te=J.length;z<te;z++){let W=J[z],$=Y[W.materialIndex];if($&&$.visible){let ae=A(E,$,U,D);E.onBeforeShadow(i,E,g,M,C,ae,W),i.renderBufferDirect(M,null,C,ae,E,W),E.onAfterShadow(i,E,g,M,C,ae,W)}}}else if(Y.visible){let J=A(E,Y,U,D);E.onBeforeShadow(i,E,g,M,C,J,null),i.renderBufferDirect(M,null,C,J,E,null),E.onAfterShadow(i,E,g,M,C,J,null)}}let H=E.children;for(let C=0,Y=H.length;C<Y;C++)b(H[C],g,M,U,I,D)}function T(E){E.target.removeEventListener("dispose",T);for(let M in l){let U=l[M],I=E.target.uuid;I in U&&(U[I].dispose(),delete U[I])}}}function i_(i,e){function t(){let R=!1,X=new dt,O=null,q=new dt(0,0,0,0);return{setMask:function(ne){O!==ne&&!R&&(i.colorMask(ne,ne,ne,ne),O=ne)},setLocked:function(ne){R=ne},setClear:function(ne,se,xe,Pe,re){re===!0&&(ne*=Pe,se*=Pe,xe*=Pe),X.set(ne,se,xe,Pe),q.equals(X)===!1&&(i.clearColor(ne,se,xe,Pe),q.copy(X))},reset:function(){R=!1,O=null,q.set(-1,0,0,0)}}}function n(){let R=!1,X=!1,O=null,q=null,ne=null;return{setReversed:function(se){if(X!==se){let xe=e.get("EXT_clip_control");se?xe.clipControlEXT(xe.LOWER_LEFT_EXT,xe.ZERO_TO_ONE_EXT):xe.clipControlEXT(xe.LOWER_LEFT_EXT,xe.NEGATIVE_ONE_TO_ONE_EXT),X=se;let Pe=ne;ne=null,this.setClear(Pe)}},getReversed:function(){return X},setTest:function(se){se?fe(i.DEPTH_TEST):Le(i.DEPTH_TEST)},setMask:function(se){O!==se&&!R&&(i.depthMask(se),O=se)},setFunc:function(se){if(X&&(se=uh[se]),q!==se){switch(se){case Cr:i.depthFunc(i.NEVER);break;case Pr:i.depthFunc(i.ALWAYS);break;case Ir:i.depthFunc(i.LESS);break;case Vi:i.depthFunc(i.LEQUAL);break;case Lr:i.depthFunc(i.EQUAL);break;case Dr:i.depthFunc(i.GEQUAL);break;case Nr:i.depthFunc(i.GREATER);break;case Ur:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}q=se}},setLocked:function(se){R=se},setClear:function(se){ne!==se&&(ne=se,X&&(se=1-se),i.clearDepth(se))},reset:function(){R=!1,O=null,q=null,ne=null,X=!1}}}function s(){let R=!1,X=null,O=null,q=null,ne=null,se=null,xe=null,Pe=null,re=null;return{setTest:function(ve){R||(ve?fe(i.STENCIL_TEST):Le(i.STENCIL_TEST))},setMask:function(ve){X!==ve&&!R&&(i.stencilMask(ve),X=ve)},setFunc:function(ve,Ae,ie){(O!==ve||q!==Ae||ne!==ie)&&(i.stencilFunc(ve,Ae,ie),O=ve,q=Ae,ne=ie)},setOp:function(ve,Ae,ie){(se!==ve||xe!==Ae||Pe!==ie)&&(i.stencilOp(ve,Ae,ie),se=ve,xe=Ae,Pe=ie)},setLocked:function(ve){R=ve},setClear:function(ve){re!==ve&&(i.clearStencil(ve),re=ve)},reset:function(){R=!1,X=null,O=null,q=null,ne=null,se=null,xe=null,Pe=null,re=null}}}let r=new t,a=new n,o=new s,c={},l=new WeakMap,h={},d={},u={},m=new WeakMap,_=[],y=null,p=!1,f=null,S=null,A=null,b=null,T=null,E=null,g=null,M=new ze(0,0,0),U=0,I=!1,D=null,F=null,H=null,C=null,Y=null,J=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,te=0,W=i.getParameter(i.VERSION);W.indexOf("WebGL")!==-1?(te=parseFloat(/^WebGL (\d)/.exec(W)[1]),z=te>=1):W.indexOf("OpenGL ES")!==-1&&(te=parseFloat(/^OpenGL ES (\d)/.exec(W)[1]),z=te>=2);let $=null,ae={},_e=i.getParameter(i.SCISSOR_BOX),De=i.getParameter(i.VIEWPORT),j=new dt().fromArray(_e),pe=new dt().fromArray(De);function ye(R,X,O,q){let ne=new Uint8Array(4),se=i.createTexture();i.bindTexture(R,se),i.texParameteri(R,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(R,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let xe=0;xe<O;xe++)R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY?i.texImage3D(X,0,i.RGBA,1,1,q,0,i.RGBA,i.UNSIGNED_BYTE,ne):i.texImage2D(X+xe,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,ne);return se}let Re={};Re[i.TEXTURE_2D]=ye(i.TEXTURE_2D,i.TEXTURE_2D,1),Re[i.TEXTURE_CUBE_MAP]=ye(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Re[i.TEXTURE_2D_ARRAY]=ye(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Re[i.TEXTURE_3D]=ye(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),fe(i.DEPTH_TEST),a.setFunc(Vi),mt(!1),at(Vo),fe(i.CULL_FACE),lt(yi);function fe(R){h[R]!==!0&&(i.enable(R),h[R]=!0)}function Le(R){h[R]!==!1&&(i.disable(R),h[R]=!1)}function pt(R,X){return u[R]!==X?(i.bindFramebuffer(R,X),u[R]=X,R===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=X),R===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=X),!0):!1}function be(R,X){let O=_,q=!1;if(R){O=m.get(X),O===void 0&&(O=[],m.set(X,O));let ne=R.textures;if(O.length!==ne.length||O[0]!==i.COLOR_ATTACHMENT0){for(let se=0,xe=ne.length;se<xe;se++)O[se]=i.COLOR_ATTACHMENT0+se;O.length=ne.length,q=!0}}else O[0]!==i.BACK&&(O[0]=i.BACK,q=!0);q&&i.drawBuffers(O)}function $e(R){return y!==R?(i.useProgram(R),y=R,!0):!1}let it={[vi]:i.FUNC_ADD,[Dc]:i.FUNC_SUBTRACT,[Nc]:i.FUNC_REVERSE_SUBTRACT};it[Uc]=i.MIN,it[Fc]=i.MAX;let ke={[Oc]:i.ZERO,[Bc]:i.ONE,[zc]:i.SRC_COLOR,[Xo]:i.SRC_ALPHA,[Xc]:i.SRC_ALPHA_SATURATE,[Hc]:i.DST_COLOR,[Vc]:i.DST_ALPHA,[kc]:i.ONE_MINUS_SRC_COLOR,[qo]:i.ONE_MINUS_SRC_ALPHA,[Wc]:i.ONE_MINUS_DST_COLOR,[Gc]:i.ONE_MINUS_DST_ALPHA,[qc]:i.CONSTANT_COLOR,[Yc]:i.ONE_MINUS_CONSTANT_COLOR,[Zc]:i.CONSTANT_ALPHA,[$c]:i.ONE_MINUS_CONSTANT_ALPHA};function lt(R,X,O,q,ne,se,xe,Pe,re,ve){if(R===yi){p===!0&&(Le(i.BLEND),p=!1);return}if(p===!1&&(fe(i.BLEND),p=!0),R!==Lc){if(R!==f||ve!==I){if((S!==vi||T!==vi)&&(i.blendEquation(i.FUNC_ADD),S=vi,T=vi),ve)switch(R){case es:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Go:i.blendFunc(i.ONE,i.ONE);break;case Ho:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Wo:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Ue("WebGLState: Invalid blending: ",R);break}else switch(R){case es:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Go:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Ho:Ue("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Wo:Ue("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ue("WebGLState: Invalid blending: ",R);break}A=null,b=null,E=null,g=null,M.set(0,0,0),U=0,f=R,I=ve}return}ne=ne||X,se=se||O,xe=xe||q,(X!==S||ne!==T)&&(i.blendEquationSeparate(it[X],it[ne]),S=X,T=ne),(O!==A||q!==b||se!==E||xe!==g)&&(i.blendFuncSeparate(ke[O],ke[q],ke[se],ke[xe]),A=O,b=q,E=se,g=xe),(Pe.equals(M)===!1||re!==U)&&(i.blendColor(Pe.r,Pe.g,Pe.b,re),M.copy(Pe),U=re),f=R,I=!1}function Ge(R,X){R.side===Mn?Le(i.CULL_FACE):fe(i.CULL_FACE);let O=R.side===Vt;X&&(O=!O),mt(O),R.blending===es&&R.transparent===!1?lt(yi):lt(R.blending,R.blendEquation,R.blendSrc,R.blendDst,R.blendEquationAlpha,R.blendSrcAlpha,R.blendDstAlpha,R.blendColor,R.blendAlpha,R.premultipliedAlpha),a.setFunc(R.depthFunc),a.setTest(R.depthTest),a.setMask(R.depthWrite),r.setMask(R.colorWrite);let q=R.stencilWrite;o.setTest(q),q&&(o.setMask(R.stencilWriteMask),o.setFunc(R.stencilFunc,R.stencilRef,R.stencilFuncMask),o.setOp(R.stencilFail,R.stencilZFail,R.stencilZPass)),gt(R.polygonOffset,R.polygonOffsetFactor,R.polygonOffsetUnits),R.alphaToCoverage===!0?fe(i.SAMPLE_ALPHA_TO_COVERAGE):Le(i.SAMPLE_ALPHA_TO_COVERAGE)}function mt(R){D!==R&&(R?i.frontFace(i.CW):i.frontFace(i.CCW),D=R)}function at(R){R!==Cc?(fe(i.CULL_FACE),R!==F&&(R===Vo?i.cullFace(i.BACK):R===Pc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Le(i.CULL_FACE),F=R}function nn(R){R!==H&&(z&&i.lineWidth(R),H=R)}function gt(R,X,O){R?(fe(i.POLYGON_OFFSET_FILL),(C!==X||Y!==O)&&(C=X,Y=O,a.getReversed()&&(X=-X,O=-O),i.polygonOffset(X,O))):Le(i.POLYGON_OFFSET_FILL)}function Ft(R){R?fe(i.SCISSOR_TEST):Le(i.SCISSOR_TEST)}function Tt(R){R===void 0&&(R=i.TEXTURE0+J-1),$!==R&&(i.activeTexture(R),$=R)}function Pt(R,X,O){O===void 0&&($===null?O=i.TEXTURE0+J-1:O=$);let q=ae[O];q===void 0&&(q={type:void 0,texture:void 0},ae[O]=q),(q.type!==R||q.texture!==X)&&($!==O&&(i.activeTexture(O),$=O),i.bindTexture(R,X||Re[R]),q.type=R,q.texture=X)}function N(){let R=ae[$];R!==void 0&&R.type!==void 0&&(i.bindTexture(R.type,null),R.type=void 0,R.texture=void 0)}function At(){try{i.compressedTexImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function Qe(){try{i.compressedTexImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function st(){try{i.texSubImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function ue(){try{i.texSubImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function ut(){try{i.compressedTexSubImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function Te(){try{i.compressedTexSubImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function Ce(){try{i.texStorage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function w(){try{i.texStorage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function x(){try{i.texImage2D(...arguments)}catch(R){Ue("WebGLState:",R)}}function k(){try{i.texImage3D(...arguments)}catch(R){Ue("WebGLState:",R)}}function oe(R){return d[R]!==void 0?d[R]:i.getParameter(R)}function ee(R,X){d[R]!==X&&(i.pixelStorei(R,X),d[R]=X)}function le(R){j.equals(R)===!1&&(i.scissor(R.x,R.y,R.z,R.w),j.copy(R))}function ce(R){pe.equals(R)===!1&&(i.viewport(R.x,R.y,R.z,R.w),pe.copy(R))}function K(R,X){let O=l.get(X);O===void 0&&(O=new WeakMap,l.set(X,O));let q=O.get(R);q===void 0&&(q=i.getUniformBlockIndex(X,R.name),i.uniformBlockBinding(X,q,q),O.set(R,q))}function P(R,X,O){let ne=l.get(X).get(R);c[ne]!==O&&(i.bindBufferBase(i.UNIFORM_BUFFER,ne,O),c[ne]=O)}function Q(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},$=null,ae={},u={},c={},m=new WeakMap,_=[],y=null,p=!1,f=null,S=null,A=null,b=null,T=null,E=null,g=null,M=new ze(0,0,0),U=0,I=!1,D=null,F=null,H=null,C=null,Y=null,j.set(0,0,i.canvas.width,i.canvas.height),pe.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:fe,disable:Le,bindFramebuffer:pt,drawBuffers:be,useProgram:$e,setBlending:lt,setMaterial:Ge,setFlipSided:mt,setCullFace:at,setLineWidth:nn,setPolygonOffset:gt,setScissorTest:Ft,activeTexture:Tt,bindTexture:Pt,unbindTexture:N,compressedTexImage2D:At,compressedTexImage3D:Qe,texImage2D:x,texImage3D:k,pixelStorei:ee,getParameter:oe,updateUBOMapping:K,uniformBlockBinding:P,texStorage2D:Ce,texStorage3D:w,texSubImage2D:st,texSubImage3D:ue,compressedTexSubImage2D:ut,compressedTexSubImage3D:Te,scissor:le,viewport:ce,reset:Q}}function s_(i,e,t,n,s,r,a){let 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 Fe,h=new WeakMap,d=new Set,u,m=new WeakMap,_=new Set,y=new FinalizationRegistry(w=>_.delete(w)),p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function f(w,x){return p?new OffscreenCanvas(w,x):ys("canvas")}function S(w,x,k){let oe=1,ee=Ce(w);if((ee.width>k||ee.height>k)&&(oe=k/Math.max(ee.width,ee.height)),oe<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let le=Math.floor(oe*ee.width),ce=Math.floor(oe*ee.height);u===void 0&&(u=f(le,ce));let K=x?f(le,ce):u;return K.width=le,K.height=ce,K.getContext("2d").drawImage(w,0,0,le,ce),Ie("WebGLRenderer: Texture has been resized from ("+ee.width+"x"+ee.height+") to ("+le+"x"+ce+")."),K}else return"data"in w&&Ie("WebGLRenderer: Image in DataTexture is too big ("+ee.width+"x"+ee.height+")."),w;return w}function A(w){return w.generateMipmaps}function b(w){i.generateMipmap(w)}function T(w){return w.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:w.isWebGL3DRenderTarget?i.TEXTURE_3D:w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function E(w,x,k,oe,ee,le=!1){if(w!==null){if(i[w]!==void 0)return i[w];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let ce;oe&&(ce=e.get("EXT_texture_norm16"),ce||Ie("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let K=x;if(x===i.RED&&(k===i.FLOAT&&(K=i.R32F),k===i.HALF_FLOAT&&(K=i.R16F),k===i.UNSIGNED_BYTE&&(K=i.R8),k===i.UNSIGNED_SHORT&&ce&&(K=ce.R16_EXT),k===i.SHORT&&ce&&(K=ce.R16_SNORM_EXT)),x===i.RED_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.R8UI),k===i.UNSIGNED_SHORT&&(K=i.R16UI),k===i.UNSIGNED_INT&&(K=i.R32UI),k===i.BYTE&&(K=i.R8I),k===i.SHORT&&(K=i.R16I),k===i.INT&&(K=i.R32I)),x===i.RG&&(k===i.FLOAT&&(K=i.RG32F),k===i.HALF_FLOAT&&(K=i.RG16F),k===i.UNSIGNED_BYTE&&(K=i.RG8),k===i.UNSIGNED_SHORT&&ce&&(K=ce.RG16_EXT),k===i.SHORT&&ce&&(K=ce.RG16_SNORM_EXT)),x===i.RG_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.RG8UI),k===i.UNSIGNED_SHORT&&(K=i.RG16UI),k===i.UNSIGNED_INT&&(K=i.RG32UI),k===i.BYTE&&(K=i.RG8I),k===i.SHORT&&(K=i.RG16I),k===i.INT&&(K=i.RG32I)),x===i.RGB_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.RGB8UI),k===i.UNSIGNED_SHORT&&(K=i.RGB16UI),k===i.UNSIGNED_INT&&(K=i.RGB32UI),k===i.BYTE&&(K=i.RGB8I),k===i.SHORT&&(K=i.RGB16I),k===i.INT&&(K=i.RGB32I)),x===i.RGBA_INTEGER&&(k===i.UNSIGNED_BYTE&&(K=i.RGBA8UI),k===i.UNSIGNED_SHORT&&(K=i.RGBA16UI),k===i.UNSIGNED_INT&&(K=i.RGBA32UI),k===i.BYTE&&(K=i.RGBA8I),k===i.SHORT&&(K=i.RGBA16I),k===i.INT&&(K=i.RGBA32I)),x===i.RGB&&(k===i.UNSIGNED_SHORT&&ce&&(K=ce.RGB16_EXT),k===i.SHORT&&ce&&(K=ce.RGB16_SNORM_EXT),k===i.UNSIGNED_INT_5_9_9_9_REV&&(K=i.RGB9_E5),k===i.UNSIGNED_INT_10F_11F_11F_REV&&(K=i.R11F_G11F_B10F)),x===i.RGBA){let P=le?xs:Ze.getTransfer(ee);k===i.FLOAT&&(K=i.RGBA32F),k===i.HALF_FLOAT&&(K=i.RGBA16F),k===i.UNSIGNED_BYTE&&(K=P===nt?i.SRGB8_ALPHA8:i.RGBA8),k===i.UNSIGNED_SHORT&&ce&&(K=ce.RGBA16_EXT),k===i.SHORT&&ce&&(K=ce.RGBA16_SNORM_EXT),k===i.UNSIGNED_SHORT_4_4_4_4&&(K=i.RGBA4),k===i.UNSIGNED_SHORT_5_5_5_1&&(K=i.RGB5_A1)}return(K===i.R16F||K===i.R32F||K===i.RG16F||K===i.RG32F||K===i.RGBA16F||K===i.RGBA32F)&&e.get("EXT_color_buffer_float"),K}function g(w,x){let k;return w?x===null||x===fn||x===bi?k=i.DEPTH24_STENCIL8:x===pn?k=i.DEPTH32F_STENCIL8:x===ns&&(k=i.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===fn||x===bi?k=i.DEPTH_COMPONENT24:x===pn?k=i.DEPTH_COMPONENT32F:x===ns&&(k=i.DEPTH_COMPONENT16),k}function M(w,x){return A(w)===!0||w.isFramebufferTexture&&w.minFilter!==wt&&w.minFilter!==kt?Math.log2(Math.max(x.width,x.height))+1:w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?x.mipmaps.length:1}function U(w){let x=new WeakRef(w);n.get(w).__ref=x,_.add(x),y.register(w,x,x)}function I(w){let x=n.get(w).__ref;x!==void 0&&(_.delete(x),y.unregister(x))}function D(w){H(w.target)}function F(w){C(w.target)}function H(w){w.removeEventListener("dispose",D),I(w),J(w),w.isVideoTexture&&h.delete(w),w.isHTMLTexture&&d.delete(w)}function C(w){w.removeEventListener("dispose",F),I(w),te(w)}function Y(){for(let w of _){let x=w.deref();x!==void 0&&(x.isRenderTarget===!0?C(x):H(x))}_.clear(),d.clear()}function J(w){let x=n.get(w);if(x.__webglInit===void 0)return;let k=w.source,oe=m.get(k);if(oe){let ee=oe[x.__cacheKey];ee.usedTimes--,ee.usedTimes===0&&z(w),Object.keys(oe).length===0&&m.delete(k)}n.remove(w)}function z(w){let x=n.get(w);i.deleteTexture(x.__webglTexture);let k=w.source,oe=m.get(k);delete oe[x.__cacheKey],a.memory.textures--}function te(w){let x=n.get(w);x.__depthDisposeCallback&&x.__depthDisposeCallback();let k=w.depthTexture;if(k&&k.renderTarget===w&&H(k),w.isWebGLCubeRenderTarget)for(let ee=0;ee<6;ee++){if(Array.isArray(x.__webglFramebuffer[ee]))for(let le=0;le<x.__webglFramebuffer[ee].length;le++)i.deleteFramebuffer(x.__webglFramebuffer[ee][le]);else i.deleteFramebuffer(x.__webglFramebuffer[ee]);x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer[ee])}else{if(Array.isArray(x.__webglFramebuffer))for(let ee=0;ee<x.__webglFramebuffer.length;ee++)i.deleteFramebuffer(x.__webglFramebuffer[ee]);else i.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&i.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let ee=0;ee<x.__webglColorRenderbuffer.length;ee++)x.__webglColorRenderbuffer[ee]&&i.deleteRenderbuffer(x.__webglColorRenderbuffer[ee]);x.__webglDepthRenderbuffer&&i.deleteRenderbuffer(x.__webglDepthRenderbuffer)}let oe=w.textures;for(let ee=0,le=oe.length;ee<le;ee++){let ce=n.get(oe[ee]);ce.__webglTexture&&(i.deleteTexture(ce.__webglTexture),a.memory.textures--),n.remove(oe[ee])}n.remove(w)}let W=0;function $(){W=0}function ae(){return W}function _e(w){W=w}function De(){let w=W;return w>=s.maxTextures&&Ie("WebGLTextures: Trying to use "+(w+1)+" texture units while this GPU supports only "+s.maxTextures),W+=1,w}function j(w){let x=[];return x.push(w.wrapS),x.push(w.wrapT),x.push(w.wrapR||0),x.push(w.magFilter),x.push(w.minFilter),x.push(w.anisotropy),x.push(w.internalFormat),x.push(w.format),x.push(w.type),x.push(w.generateMipmaps),x.push(w.mipmapsAutoUpdate),x.push(w.premultiplyAlpha),x.push(w.flipY),x.push(w.unpackAlignment),x.push(w.colorSpace),x.join()}function pe(w,x){let k=n.get(w);if(w.isVideoTexture&&ut(w),w.isRenderTargetTexture===!1&&w.isExternalTexture!==!0&&w.version>0&&k.__version!==w.version){let oe=w.image;if(oe===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(oe.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{Ge(k,w,x);return}}else w.isExternalTexture&&(k.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,k.__webglTexture,i.TEXTURE0+x)}function ye(w,x){let k=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&k.__version!==w.version){Ge(k,w,x);return}else w.isExternalTexture&&(k.__webglTexture=w.sourceTexture?w.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,k.__webglTexture,i.TEXTURE0+x)}function Re(w,x){let k=n.get(w);if(w.isRenderTargetTexture===!1&&w.version>0&&k.__version!==w.version){Ge(k,w,x);return}t.bindTexture(i.TEXTURE_3D,k.__webglTexture,i.TEXTURE0+x)}function fe(w,x){let k=n.get(w);if(w.version>0&&k.__version!==w.version){mt(k,w,x);return}t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture,i.TEXTURE0+x)}let Le={[Fr]:i.REPEAT,[yn]:i.CLAMP_TO_EDGE,[Or]:i.MIRRORED_REPEAT},pt={[wt]:i.NEAREST,[jc]:i.NEAREST_MIPMAP_NEAREST,[Os]:i.NEAREST_MIPMAP_LINEAR,[kt]:i.LINEAR,[fa]:i.LINEAR_MIPMAP_NEAREST,[kn]:i.LINEAR_MIPMAP_LINEAR},be={[nh]:i.NEVER,[cl]:i.ALWAYS,[ih]:i.LESS,[ol]:i.LEQUAL,[sh]:i.EQUAL,[ll]:i.GEQUAL,[rh]:i.GREATER,[ah]:i.NOTEQUAL};function $e(w,x){if(x.type===pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===kt||x.magFilter===fa||x.magFilter===Os||x.magFilter===kn||x.minFilter===kt||x.minFilter===fa||x.minFilter===Os||x.minFilter===kn)&&Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(w,i.TEXTURE_WRAP_S,Le[x.wrapS]),i.texParameteri(w,i.TEXTURE_WRAP_T,Le[x.wrapT]),(w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY)&&i.texParameteri(w,i.TEXTURE_WRAP_R,Le[x.wrapR]),i.texParameteri(w,i.TEXTURE_MAG_FILTER,pt[x.magFilter]),i.texParameteri(w,i.TEXTURE_MIN_FILTER,pt[x.minFilter]),x.compareFunction&&(i.texParameteri(w,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(w,i.TEXTURE_COMPARE_FUNC,be[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===wt||x.minFilter!==Os&&x.minFilter!==kn||x.type===pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){let k=e.get("EXT_texture_filter_anisotropic");i.texParameterf(w,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function it(w,x){let k=!1;w.__webglInit===void 0&&(w.__webglInit=!0,x.addEventListener("dispose",D),U(x));let oe=x.source,ee=m.get(oe);ee===void 0&&(ee={},m.set(oe,ee));let le=j(x);if(le!==w.__cacheKey){ee[le]===void 0&&(ee[le]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,k=!0),ee[le].usedTimes++;let ce=ee[w.__cacheKey];ce!==void 0&&(ee[w.__cacheKey].usedTimes--,ce.usedTimes===0&&z(x)),w.__cacheKey=le,w.__webglTexture=ee[le].texture}return k}function ke(w,x,k){return Math.floor(Math.floor(w/k)/x)}function lt(w,x,k,oe){let le=w.updateRanges;if(le.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,x.width,x.height,k,oe,x.data);else{le.sort((R,X)=>R.start-X.start);let ce=0;for(let R=1;R<le.length;R++){let X=le[ce],O=le[R],q=X.start+X.count,ne=ke(O.start,x.width,4),se=ke(X.start,x.width,4);O.start<=q+1&&ne===se&&ke(O.start+O.count-1,x.width,4)===ne?X.count=Math.max(X.count,O.start+O.count-X.start):(++ce,le[ce]=O)}le.length=ce+1;let K=t.getParameter(i.UNPACK_ROW_LENGTH),P=t.getParameter(i.UNPACK_SKIP_PIXELS),Q=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,x.width);for(let R=0,X=le.length;R<X;R++){let O=le[R],q=Math.floor(O.start/4),ne=Math.ceil(O.count/4),se=q%x.width,xe=Math.floor(q/x.width),Pe=ne,re=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,se),t.pixelStorei(i.UNPACK_SKIP_ROWS,xe),t.texSubImage2D(i.TEXTURE_2D,0,se,xe,Pe,re,k,oe,x.data)}w.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,K),t.pixelStorei(i.UNPACK_SKIP_PIXELS,P),t.pixelStorei(i.UNPACK_SKIP_ROWS,Q)}}function Ge(w,x,k){let oe=i.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(oe=i.TEXTURE_2D_ARRAY),x.isData3DTexture&&(oe=i.TEXTURE_3D);let ee=it(w,x),le=x.source;t.bindTexture(oe,w.__webglTexture,i.TEXTURE0+k);let ce=n.get(le);if(le.version!==ce.__version||ee===!0){if(t.activeTexture(i.TEXTURE0+k),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){let re=Ze.getPrimaries(Ze.workingColorSpace),ve=x.colorSpace===Gn?null:Ze.getPrimaries(x.colorSpace),Ae=x.colorSpace===Gn||re===ve?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ae)}t.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment);let P=S(x.image,!1,s.maxTextureSize);P=Te(x,P);let Q=r.convert(x.format,x.colorSpace),R=r.convert(x.type),X=E(x.internalFormat,Q,R,x.normalized,x.colorSpace,x.isVideoTexture);$e(oe,x);let O,q=x.mipmaps,ne=x.isVideoTexture!==!0,se=ce.__version===void 0||ee===!0,xe=le.dataReady,Pe=M(x,P);if(x.isDepthTexture)X=g(x.format===Vn,x.type),se&&(ne?t.texStorage2D(i.TEXTURE_2D,1,X,P.width,P.height):t.texImage2D(i.TEXTURE_2D,0,X,P.width,P.height,0,Q,R,null));else if(x.isDataTexture)if(q.length>0){ne&&se&&t.texStorage2D(i.TEXTURE_2D,Pe,X,q[0].width,q[0].height);for(let re=0,ve=q.length;re<ve;re++)O=q[re],ne?xe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,O.width,O.height,Q,R,O.data):t.texImage2D(i.TEXTURE_2D,re,X,O.width,O.height,0,Q,R,O.data);x.generateMipmaps=!1}else ne?(se&&t.texStorage2D(i.TEXTURE_2D,Pe,X,P.width,P.height),xe&&lt(x,P,Q,R)):t.texImage2D(i.TEXTURE_2D,0,X,P.width,P.height,0,Q,R,P.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){ne&&se&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Pe,X,q[0].width,q[0].height,P.depth);for(let re=0,ve=q.length;re<ve;re++)if(O=q[re],x.format!==gn)if(Q!==null)if(ne){if(xe)if(x.layerUpdates.size>0){let Ae=yl(O.width,O.height,x.format,x.type);for(let ie of x.layerUpdates){let Ne=O.data.subarray(ie*Ae/O.data.BYTES_PER_ELEMENT,(ie+1)*Ae/O.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,ie,O.width,O.height,1,Q,Ne)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,O.width,O.height,P.depth,Q,O.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,re,X,O.width,O.height,P.depth,0,O.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ne?xe&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,re,0,0,0,O.width,O.height,P.depth,Q,R,O.data):t.texImage3D(i.TEXTURE_2D_ARRAY,re,X,O.width,O.height,P.depth,0,Q,R,O.data);x.layerUpdates.size>0&&x.clearLayerUpdates()}else{ne&&se&&t.texStorage2D(i.TEXTURE_2D,Pe,X,q[0].width,q[0].height);for(let re=0,ve=q.length;re<ve;re++)O=q[re],x.format!==gn?Q!==null?ne?xe&&t.compressedTexSubImage2D(i.TEXTURE_2D,re,0,0,O.width,O.height,Q,O.data):t.compressedTexImage2D(i.TEXTURE_2D,re,X,O.width,O.height,0,O.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ne?xe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,O.width,O.height,Q,R,O.data):t.texImage2D(i.TEXTURE_2D,re,X,O.width,O.height,0,Q,R,O.data)}else if(x.isDataArrayTexture)if(ne){if(se&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Pe,X,P.width,P.height,P.depth),xe)if(x.layerUpdates.size>0){let re=yl(P.width,P.height,x.format,x.type);for(let ve of x.layerUpdates){let Ae=P.data.subarray(ve*re/P.data.BYTES_PER_ELEMENT,(ve+1)*re/P.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ve,P.width,P.height,1,Q,R,Ae)}x.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,P.width,P.height,P.depth,Q,R,P.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,X,P.width,P.height,P.depth,0,Q,R,P.data);else if(x.isData3DTexture)ne?(se&&t.texStorage3D(i.TEXTURE_3D,Pe,X,P.width,P.height,P.depth),xe&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,P.width,P.height,P.depth,Q,R,P.data)):t.texImage3D(i.TEXTURE_3D,0,X,P.width,P.height,P.depth,0,Q,R,P.data);else if(x.isFramebufferTexture){if(se)if(ne)t.texStorage2D(i.TEXTURE_2D,Pe,X,P.width,P.height);else{let re=P.width,ve=P.height;for(let Ae=0;Ae<Pe;Ae++)t.texImage2D(i.TEXTURE_2D,Ae,X,re,ve,0,Q,R,null),re>>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in i){let re=i.canvas;if(re.hasAttribute("layoutsubtree")||re.setAttribute("layoutsubtree","true"),P.parentNode!==re){re.appendChild(P),d.add(x),re.onpaint=ve=>{let Ae=ve.changedElements;for(let ie of d)Ae.includes(ie.image)&&(ie.needsUpdate=!0)},re.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,P);else{let Ae=i.RGBA,ie=i.RGBA,Ne=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Ae,ie,Ne,P)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(q.length>0){if(ne&&se){let re=Ce(q[0]);t.texStorage2D(i.TEXTURE_2D,Pe,X,re.width,re.height)}for(let re=0,ve=q.length;re<ve;re++)O=q[re],ne?xe&&t.texSubImage2D(i.TEXTURE_2D,re,0,0,Q,R,O):t.texImage2D(i.TEXTURE_2D,re,X,Q,R,O);x.generateMipmaps=!1}else if(ne){if(se){let re=Ce(P);t.texStorage2D(i.TEXTURE_2D,Pe,X,re.width,re.height)}xe&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Q,R,P)}else t.texImage2D(i.TEXTURE_2D,0,X,Q,R,P);A(x)&&x.mipmapsAutoUpdate===!0&&b(oe),ce.__version=le.version,x.onUpdate&&x.onUpdate(x)}w.__version=x.version}function mt(w,x,k){if(x.image.length!==6)return;let oe=it(w,x),ee=x.source;t.bindTexture(i.TEXTURE_CUBE_MAP,w.__webglTexture,i.TEXTURE0+k);let le=n.get(ee);if(ee.version!==le.__version||oe===!0){t.activeTexture(i.TEXTURE0+k);let ce=Ze.getPrimaries(Ze.workingColorSpace),K=x.colorSpace===Gn?null:Ze.getPrimaries(x.colorSpace),P=x.colorSpace===Gn||ce===K?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,P);let Q=x.isCompressedTexture||x.image[0].isCompressedTexture,R=x.image[0]&&x.image[0].isDataTexture,X=[];for(let ie=0;ie<6;ie++)!Q&&!R?X[ie]=S(x.image[ie],!0,s.maxCubemapSize):X[ie]=R?x.image[ie].image:x.image[ie],X[ie]=Te(x,X[ie]);let O=X[0],q=r.convert(x.format,x.colorSpace),ne=r.convert(x.type),se=E(x.internalFormat,q,ne,x.normalized,x.colorSpace),xe=x.isVideoTexture!==!0,Pe=le.__version===void 0||oe===!0,re=ee.dataReady,ve=M(x,O);$e(i.TEXTURE_CUBE_MAP,x);let Ae;if(x.isDepthTexture){if(se=g(x.format===Vn,x.type),Pe)if(xe)t.texStorage2D(i.TEXTURE_CUBE_MAP,1,se,O.width,O.height);else for(let ie=0;ie<6;ie++)t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,se,O.width,O.height,0,q,ne,null)}else if(Q){xe&&Pe&&t.texStorage2D(i.TEXTURE_CUBE_MAP,ve,se,O.width,O.height);for(let ie=0;ie<6;ie++){Ae=X[ie].mipmaps;for(let Ne=0;Ne<Ae.length;Ne++){let Je=Ae[Ne];x.format!==gn?q!==null?xe?re&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,0,0,Je.width,Je.height,q,Je.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,se,Je.width,Je.height,0,Je.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,0,0,Je.width,Je.height,q,ne,Je.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne,se,Je.width,Je.height,0,q,ne,Je.data)}}}else{if(Ae=x.mipmaps,xe&&Pe){Ae.length>0&&ve++;let ie=Ce(X[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ve,se,ie.width,ie.height)}for(let ie=0;ie<6;ie++)if(R){xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,X[ie].width,X[ie].height,q,ne,X[ie].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,se,X[ie].width,X[ie].height,0,q,ne,X[ie].data);for(let Ne=0;Ne<Ae.length;Ne++){let Xe=Ae[Ne].image[ie].image;xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,0,0,Xe.width,Xe.height,q,ne,Xe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,se,Xe.width,Xe.height,0,q,ne,Xe.data)}}else{xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,0,0,q,ne,X[ie]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0,se,q,ne,X[ie]);for(let Ne=0;Ne<Ae.length;Ne++){let Je=Ae[Ne];xe?re&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,0,0,q,ne,Je.image[ie]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,Ne+1,se,q,ne,Je.image[ie])}}}A(x)&&x.mipmapsAutoUpdate===!0&&b(i.TEXTURE_CUBE_MAP),le.__version=ee.version,x.onUpdate&&x.onUpdate(x)}w.__version=x.version}function at(w,x,k,oe,ee,le){let ce=r.convert(k.format,k.colorSpace),K=r.convert(k.type),P=E(k.internalFormat,ce,K,k.normalized,k.colorSpace),Q=n.get(x),R=n.get(k);if(R.__renderTarget=x,!Q.__hasExternalTextures){let X=Math.max(1,x.width>>le),O=Math.max(1,x.height>>le);ee===i.TEXTURE_3D||ee===i.TEXTURE_2D_ARRAY?t.texImage3D(ee,le,P,X,O,x.depth,0,ce,K,null):t.texImage2D(ee,le,P,X,O,0,ce,K,null)}t.bindFramebuffer(i.FRAMEBUFFER,w),ue(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,oe,ee,R.__webglTexture,0,st(x)):(ee===i.TEXTURE_2D||ee>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ee<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,oe,ee,R.__webglTexture,le),t.bindFramebuffer(i.FRAMEBUFFER,null)}function nn(w,x,k){if(i.bindRenderbuffer(i.RENDERBUFFER,w),x.depthBuffer){let oe=x.depthTexture,ee=oe&&oe.isDepthTexture?oe.type:null,le=g(x.stencilBuffer,ee),ce=x.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;ue(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(x),le,x.width,x.height):k?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(x),le,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,le,x.width,x.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ce,i.RENDERBUFFER,w)}else{let oe=x.textures;for(let ee=0;ee<oe.length;ee++){let le=oe[ee],ce=r.convert(le.format,le.colorSpace),K=r.convert(le.type),P=E(le.internalFormat,ce,K,le.normalized,le.colorSpace);ue(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(x),P,x.width,x.height):k?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(x),P,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,P,x.width,x.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function gt(w,x,k){let oe=x.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,w),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let ee=n.get(x.depthTexture);ee.__renderTarget=x;let le=oe?x.depthTexture.image[0]:x.depthTexture.image;(!ee.__webglTexture||le.width!==x.width||le.height!==x.height)&&(le.width=x.width,le.height=x.height,x.depthTexture.needsUpdate=!0),oe?fe(x.depthTexture,0):pe(x.depthTexture,0);let ce=ee.__webglTexture,K=st(x),P=oe?i.TEXTURE_CUBE_MAP_POSITIVE_X+k:i.TEXTURE_2D,Q=x.depthTexture.format===Vn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(x.depthTexture.format===Fn)ue(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,P,ce,0,K):i.framebufferTexture2D(i.FRAMEBUFFER,Q,P,ce,0);else if(x.depthTexture.format===Vn)ue(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,P,ce,0,K):i.framebufferTexture2D(i.FRAMEBUFFER,Q,P,ce,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ft(w){let x=n.get(w),k=w.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==w.depthTexture){let oe=w.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),oe){let ee=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,oe.removeEventListener("dispose",ee)};oe.addEventListener("dispose",ee),x.__depthDisposeCallback=ee}x.__boundDepthTexture=oe}if(w.depthTexture&&!x.__autoAllocateDepthBuffer)if(k)for(let oe=0;oe<6;oe++)gt(x.__webglFramebuffer[oe],w,oe);else w.texture.mipmaps.length>0?gt(x.__webglFramebuffer[0],w,0):gt(x.__webglFramebuffer,w,0);else if(k){x.__webglDepthbuffer=[];for(let oe=0;oe<6;oe++)if(t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[oe]),x.__webglDepthbuffer[oe]===void 0)x.__webglDepthbuffer[oe]=i.createRenderbuffer(),nn(x.__webglDepthbuffer[oe],w,!1);else{let ee=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=x.__webglDepthbuffer[oe];i.bindRenderbuffer(i.RENDERBUFFER,le),i.framebufferRenderbuffer(i.FRAMEBUFFER,ee,i.RENDERBUFFER,le)}}else if(w.texture.mipmaps.length>0?t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=i.createRenderbuffer(),nn(x.__webglDepthbuffer,w,!1);else{let ee=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,le=x.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,le),i.framebufferRenderbuffer(i.FRAMEBUFFER,ee,i.RENDERBUFFER,le)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(w,x,k){let oe=n.get(w);x!==void 0&&at(oe.__webglFramebuffer,w,w.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),k!==void 0&&Ft(w)}function Pt(w){let x=w.texture,k=n.get(w),oe=n.get(x);w.addEventListener("dispose",F),U(w);let ee=w.textures,le=w.isWebGLCubeRenderTarget===!0,ce=ee.length>1;if(ce||(oe.__webglTexture===void 0&&(oe.__webglTexture=i.createTexture()),oe.__version=x.version,a.memory.textures++),le){k.__webglFramebuffer=[];for(let K=0;K<6;K++)if(x.mipmaps.length>0){k.__webglFramebuffer[K]=[];for(let P=0;P<x.mipmaps.length;P++)k.__webglFramebuffer[K][P]=i.createFramebuffer()}else k.__webglFramebuffer[K]=i.createFramebuffer()}else{if(x.mipmaps.length>0){k.__webglFramebuffer=[];for(let K=0;K<x.mipmaps.length;K++)k.__webglFramebuffer[K]=i.createFramebuffer()}else k.__webglFramebuffer=i.createFramebuffer();if(ce)for(let K=0,P=ee.length;K<P;K++){let Q=n.get(ee[K]);Q.__webglTexture===void 0&&(Q.__webglTexture=i.createTexture(),a.memory.textures++)}if(w.samples>0&&ue(w)===!1){k.__webglMultisampledFramebuffer=i.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let K=0;K<ee.length;K++){let P=ee[K];k.__webglColorRenderbuffer[K]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,k.__webglColorRenderbuffer[K]);let Q=r.convert(P.format,P.colorSpace),R=r.convert(P.type),X=E(P.internalFormat,Q,R,P.normalized,P.colorSpace,w.isXRRenderTarget===!0),O=st(w);i.renderbufferStorageMultisample(i.RENDERBUFFER,O,X,w.width,w.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+K,i.RENDERBUFFER,k.__webglColorRenderbuffer[K])}i.bindRenderbuffer(i.RENDERBUFFER,null),w.depthBuffer&&(k.__webglDepthRenderbuffer=i.createRenderbuffer(),nn(k.__webglDepthRenderbuffer,w,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(le){t.bindTexture(i.TEXTURE_CUBE_MAP,oe.__webglTexture),$e(i.TEXTURE_CUBE_MAP,x);for(let K=0;K<6;K++)if(x.mipmaps.length>0)for(let P=0;P<x.mipmaps.length;P++)at(k.__webglFramebuffer[K][P],w,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,P);else at(k.__webglFramebuffer[K],w,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0);A(x)?b(i.TEXTURE_CUBE_MAP):x.mipmaps.length>0&&i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,x.mipmaps.length-1),t.unbindTexture()}else if(ce){for(let K=0,P=ee.length;K<P;K++){let Q=ee[K],R=n.get(Q),X=i.TEXTURE_2D;(w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(X=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(X,R.__webglTexture),$e(X,Q),at(k.__webglFramebuffer,w,Q,i.COLOR_ATTACHMENT0+K,X,0),A(Q)&&b(X)}t.unbindTexture()}else{let K=i.TEXTURE_2D;if((w.isWebGL3DRenderTarget||w.isWebGLArrayRenderTarget)&&(K=w.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(K,oe.__webglTexture),$e(K,x),x.mipmaps.length>0)for(let P=0;P<x.mipmaps.length;P++)at(k.__webglFramebuffer[P],w,x,i.COLOR_ATTACHMENT0,K,P);else at(k.__webglFramebuffer,w,x,i.COLOR_ATTACHMENT0,K,0);A(x)?b(K):x.mipmaps.length>0&&i.texParameteri(K,i.TEXTURE_MAX_LEVEL,x.mipmaps.length-1),t.unbindTexture()}w.depthBuffer&&Ft(w)}function N(w){let x=w.textures;for(let k=0,oe=x.length;k<oe;k++){let ee=x[k];if(A(ee)&&ee.mipmapsAutoUpdate===!0){let le=T(w),ce=n.get(ee).__webglTexture;t.bindTexture(le,ce),b(le),t.unbindTexture()}}}let At=[];function Qe(w){if(w.samples>0){if(ue(w)===!1){let x=w.textures,k=w.width,oe=w.height,ee=i.COLOR_BUFFER_BIT,le=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ce=n.get(w),K=x.length>1;if(K)for(let Q=0;Q<x.length;Q++)t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ce.__webglMultisampledFramebuffer),w.texture.mipmaps.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglFramebuffer);for(let Q=0;Q<x.length;Q++){if(w.resolveDepthBuffer&&(w.depthBuffer&&(ee|=i.DEPTH_BUFFER_BIT),w.stencilBuffer&&w.resolveStencilBuffer&&(ee|=i.STENCIL_BUFFER_BIT)),K){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ce.__webglColorRenderbuffer[Q]);let R=n.get(x[Q]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,R,0)}i.blitFramebuffer(0,0,k,oe,0,0,k,oe,ee,i.NEAREST),c===!0&&(At.length=0,At.push(i.COLOR_ATTACHMENT0+Q),w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&At.push(le),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,At))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),K)for(let Q=0;Q<x.length;Q++){t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.RENDERBUFFER,ce.__webglColorRenderbuffer[Q]);let R=n.get(x[Q]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ce.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+Q,i.TEXTURE_2D,R,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ce.__webglMultisampledFramebuffer)}else if(w.depthBuffer&&w.storeMultisampledDepthBuffer===!1&&c){let x=w.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[x])}}}function st(w){return Math.min(s.maxSamples,w.samples)}function ue(w){let x=n.get(w);return w.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function ut(w){let x=a.render.frame;h.get(w)!==x&&(h.set(w,x),w.update())}function Te(w,x){let k=w.colorSpace,oe=w.format,ee=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||k!==_s&&k!==Gn&&(Ze.getTransfer(k)===nt?(oe!==gn||ee!==Xt)&&Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ue("WebGLTextures: Unsupported texture color space:",k)),x}function Ce(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(l.width=w.displayWidth,l.height=w.displayHeight):(l.width=w.width,l.height=w.height),l}this.allocateTextureUnit=De,this.resetTextureUnits=$,this.getTextureUnits=ae,this.setTextureUnits=_e,this.setTexture2D=pe,this.setTexture2DArray=ye,this.setTexture3D=Re,this.setTextureCube=fe,this.rebindTextures=Tt,this.setupRenderTarget=Pt,this.updateRenderTargetMipmap=N,this.updateMultisampleRenderTarget=Qe,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=at,this.useMultisampledRTT=ue,this.dispose=Y}function r_(i,e){function t(n,s=Gn){let r,a=Ze.getTransfer(s);if(n===Xt)return i.UNSIGNED_BYTE;if(n===ma)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ga)return i.UNSIGNED_SHORT_5_5_5_1;if(n===nl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===il)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===el)return i.BYTE;if(n===tl)return i.SHORT;if(n===ns)return i.UNSIGNED_SHORT;if(n===pa)return i.INT;if(n===fn)return i.UNSIGNED_INT;if(n===pn)return i.FLOAT;if(n===mn)return i.HALF_FLOAT;if(n===sl)return i.ALPHA;if(n===rl)return i.RGB;if(n===gn)return i.RGBA;if(n===Fn)return i.DEPTH_COMPONENT;if(n===Vn)return i.DEPTH_STENCIL;if(n===al)return i.RED;if(n===_a)return i.RED_INTEGER;if(n===si)return i.RG;if(n===xa)return i.RG_INTEGER;if(n===ya)return i.RGBA_INTEGER;if(n===Bs||n===zs||n===ks||n===Vs)if(a===nt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Bs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===zs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ks)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Vs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Bs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===zs)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ks)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Vs)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===va||n===Ma||n===ba||n===Sa)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===va)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Ma)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ba)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Sa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ea||n===wa||n===Ta||n===Aa||n===Ra||n===Gs||n===Ca)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ea||n===wa)return a===nt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ta)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Aa)return r.COMPRESSED_R11_EAC;if(n===Ra)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Gs)return r.COMPRESSED_RG11_EAC;if(n===Ca)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Pa||n===Ia||n===La||n===Da||n===Na||n===Ua||n===Fa||n===Oa||n===Ba||n===za||n===ka||n===Va||n===Ga||n===Ha)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Pa)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ia)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===La)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Da)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Na)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ua)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Fa)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Oa)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ba)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===za)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ka)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Va)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ga)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ha)return a===nt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Wa||n===Xa||n===qa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===Wa)return a===nt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Xa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===qa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Ya||n===Za||n===Hs||n===$a)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Ya)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Za)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Hs)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===$a)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===bi?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var a_=`
4201
+ }`,S0=[new k(1,0,0),new k(-1,0,0),new k(0,1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1)],w0=[new k(0,-1,0),new k(0,-1,0),new k(0,0,1),new k(0,0,-1),new k(0,-1,0),new k(0,-1,0)],nu=new ft,nr=new k,Hl=new k;function E0(i,e,t){let n=new hi,s=new ke,r=new ke,o=new gt,a=new lo,c=new co,l={},h=t.maxTextureSize,d={[gi]:Zt,[Zt]:gi,[pn]:pn},u=new Cn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:b0,fragmentShader:M0}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let _=new Yt;_.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Kt(_,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ys;let f=this.type;this.render=function(E,g,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||E.length===0)return;this.type===$c&&(Ue("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Ys);let N=i.getRenderTarget(),R=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),U=i.state;U.setBlending(Ii),U.buffers.depth.getReversed()===!0?U.buffers.color.setClear(0,0,0,0):U.buffers.color.setClear(1,1,1,1),U.buffers.depth.setTest(!0),U.setScissorTest(!1);let z=f!==this.type;z&&g.traverse(function(I){I.material&&(Array.isArray(I.material)?I.material.forEach(q=>q.needsUpdate=!0):I.material.needsUpdate=!0)});for(let I=0,q=E.length;I<q;I++){let Z=E[I],B=Z.shadow;if(B===void 0){Ue("WebGLShadowMap:",Z,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;s.copy(B.mapSize);let ee=B.getFrameExtents();s.multiply(ee),r.copy(B.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ee.x),s.x=r.x*ee.x,B.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ee.y),s.y=r.y*ee.y,B.mapSize.y=r.y));let C=i.state.buffers.depth.getReversed();if(B.camera._reversedDepth=C,B.map===null||z===!0){if(B.map!==null&&(B.map.depthTexture!==null&&(B.map.depthTexture.dispose(),B.map.depthTexture=null),B.map.dispose()),this.type===us){if(Z.isPointLight){Ue("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}B.map=new ln(s.x,s.y,{format:_i,type:wn,minFilter:qt,magFilter:qt,generateMipmaps:!1}),B.map.texture.name=Z.name+".shadowMap",B.map.depthTexture=new Jn(s.x,s.y,Sn),B.map.depthTexture.name=Z.name+".shadowMapDepth",B.map.depthTexture.format=Yn,B.map.depthTexture.compareFunction=null,B.map.depthTexture.minFilter=It,B.map.depthTexture.magFilter=It}else Z.isPointLight?(B.map=new sr(s.x),B.map.depthTexture=new Bs(s.x,Mn)):(B.map=new ln(s.x,s.y),B.map.depthTexture=new Jn(s.x,s.y,Mn)),B.map.depthTexture.name=Z.name+".shadowMap",B.map.depthTexture.format=Yn,this.type===Ys?(B.map.depthTexture.compareFunction=C?El:wl,B.map.depthTexture.minFilter=qt,B.map.depthTexture.magFilter=qt):(B.map.depthTexture.compareFunction=null,B.map.depthTexture.minFilter=It,B.map.depthTexture.magFilter=It);B.camera.updateProjectionMatrix()}B.map.isWebGLCubeRenderTarget!==!0&&(B.map.width!==s.x||B.map.height!==s.y)&&B.map.setSize(s.x,s.y);let W=B.map.isWebGLCubeRenderTarget?6:B.getViewportCount();Z.isPointLight!==!0&&B.updateMatrices(Z,v);let K=(B.camera.layers.mask&4294967294)!==0?B.camera.layers:v.layers;for(let ve=0;ve<W;ve++){let we=B.getCamera(ve);if(Z.isPointLight){let G=B.camera,he=B.matrix,fe=Z.distance||G.far;fe!==G.far&&(G.far=fe,G.updateProjectionMatrix()),nr.setFromMatrixPosition(Z.matrixWorld),G.position.copy(nr),Hl.copy(G.position),Hl.add(S0[ve]),G.up.copy(w0[ve]),G.lookAt(Hl),G.updateMatrixWorld(),he.makeTranslation(-nr.x,-nr.y,-nr.z),nu.multiplyMatrices(G.projectionMatrix,G.matrixWorldInverse),B._frustum.setFromProjectionMatrix(nu,G.coordinateSystem,G.reversedDepth)}if(B.map.isWebGLCubeRenderTarget)i.setRenderTarget(B.map,ve),i.clear();else{ve===0&&(i.setRenderTarget(B.map),i.clear());let G=B.getViewport(ve);o.set(r.x*G.x,r.y*G.y,r.x*G.z,r.y*G.w),U.viewport(o)}n=B.getFrustum(ve),S(g,v,we,Z,K,this.type)}B.isPointLightShadow!==!0&&this.type===us&&w(B,v),B.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(N,R,D)};function w(E,g){let v=e.update(x);u.defines.VSM_SAMPLES!==E.blurSamples&&(u.defines.VSM_SAMPLES=E.blurSamples,p.defines.VSM_SAMPLES=E.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),E.mapPass===null?E.mapPass=new ln(s.x,s.y,{format:_i,type:wn}):(E.mapPass.width!==E.map.width||E.mapPass.height!==E.map.height)&&E.mapPass.setSize(E.map.width,E.map.height),u.uniforms.shadow_pass.value=E.map.depthTexture,u.uniforms.resolution.value.set(E.map.width,E.map.height),u.uniforms.radius.value=E.radius,i.setRenderTarget(E.mapPass),i.clear(),i.renderBufferDirect(g,null,v,u,x,null),p.uniforms.shadow_pass.value=E.mapPass.texture,p.uniforms.resolution.value.set(E.map.width,E.map.height),p.uniforms.radius.value=E.radius,i.setRenderTarget(E.map),i.clear(),i.renderBufferDirect(g,null,v,p,x,null)}function A(E,g,v,N){let R=null,D=v.isPointLight===!0?E.customDistanceMaterial:E.customDepthMaterial;if(D!==void 0)R=D;else if(R=v.isPointLight===!0?c:a,i.localClippingEnabled&&g.clipShadows===!0&&Array.isArray(g.clippingPlanes)&&g.clippingPlanes.length!==0||g.displacementMap&&g.displacementScale!==0||g.alphaMap&&g.alphaTest>0||g.map&&g.alphaTest>0||g.alphaToCoverage===!0){let U=R.uuid,z=g.uuid,I=l[U];I===void 0&&(I={},l[U]=I);let q=I[z];q===void 0&&(q=R.clone(),I[z]=q,g.addEventListener("dispose",M)),R=q}if(R.visible=g.visible,R.wireframe=g.wireframe,N===us?R.side=g.shadowSide!==null?g.shadowSide:g.side:R.side=g.shadowSide!==null?g.shadowSide:d[g.side],R.alphaMap=g.alphaMap,R.alphaTest=g.alphaToCoverage===!0?.5:g.alphaTest,R.map=g.map,R.clipShadows=g.clipShadows,R.clippingPlanes=g.clippingPlanes,R.clipIntersection=g.clipIntersection,R.displacementMap=g.displacementMap,R.displacementScale=g.displacementScale,R.displacementBias=g.displacementBias,R.wireframeLinewidth=g.wireframeLinewidth,R.linewidth=g.linewidth,v.isPointLight===!0&&R.isMeshDistanceMaterial===!0){let U=i.properties.get(R);U.light=v}return R}function S(E,g,v,N,R,D){if(E.visible===!1)return;if(E.layers.test(R)&&(E.isMesh||E.isLine||E.isPoints)&&(E.castShadow||E.receiveShadow&&D===us)&&(!E.frustumCulled||E.intersectsFrustum(n))){E.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,E.matrixWorld);let I=e.update(E),q=E.material;if(Array.isArray(q)){let Z=I.groups;for(let B=0,ee=Z.length;B<ee;B++){let C=Z[B],W=q[C.materialIndex];if(W&&W.visible){let K=A(E,W,N,D);E.onBeforeShadow(i,E,g,v,I,K,C),i.renderBufferDirect(v,null,I,K,E,C),E.onAfterShadow(i,E,g,v,I,K,C)}}}else if(q.visible){let Z=A(E,q,N,D);E.onBeforeShadow(i,E,g,v,I,Z,null),i.renderBufferDirect(v,null,I,Z,E,null),E.onAfterShadow(i,E,g,v,I,Z,null)}}let z=E.children;for(let I=0,q=z.length;I<q;I++)S(z[I],g,v,N,R,D)}function M(E){E.target.removeEventListener("dispose",M);for(let v in l){let N=l[v],R=E.target.uuid;R in N&&(N[R].dispose(),delete N[R])}}}function T0(i,e){function t(){let L=!1,te=new gt,P=null,ne=new gt(0,0,0,0);return{setMask:function($){P!==$&&!L&&(i.colorMask($,$,$,$),P=$)},setLocked:function($){L=$},setClear:function($,ie,oe,re,J){J===!0&&($*=re,ie*=re,oe*=re),te.set($,ie,oe,re),ne.equals(te)===!1&&(i.clearColor($,ie,oe,re),ne.copy(te))},reset:function(){L=!1,P=null,ne.set(-1,0,0,0)}}}function n(){let L=!1,te=!1,P=null,ne=null,$=null;return{setReversed:function(ie){if(te!==ie){let oe=e.get("EXT_clip_control");ie?oe.clipControlEXT(oe.LOWER_LEFT_EXT,oe.ZERO_TO_ONE_EXT):oe.clipControlEXT(oe.LOWER_LEFT_EXT,oe.NEGATIVE_ONE_TO_ONE_EXT),te=ie;let re=$;$=null,this.setClear(re)}},getReversed:function(){return te},setTest:function(ie){ie?le(i.DEPTH_TEST):ye(i.DEPTH_TEST)},setMask:function(ie){P!==ie&&!L&&(i.depthMask(ie),P=ie)},setFunc:function(ie){if(te&&(ie=Ch[ie]),ne!==ie){switch(ie){case Hr:i.depthFunc(i.NEVER);break;case Wr:i.depthFunc(i.ALWAYS);break;case Xr:i.depthFunc(i.LESS);break;case ji:i.depthFunc(i.LEQUAL);break;case qr:i.depthFunc(i.EQUAL);break;case Yr:i.depthFunc(i.GEQUAL);break;case Zr:i.depthFunc(i.GREATER);break;case $r:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ne=ie}},setLocked:function(ie){L=ie},setClear:function(ie){$!==ie&&($=ie,te&&(ie=1-ie),i.clearDepth(ie))},reset:function(){L=!1,P=null,ne=null,$=null,te=!1}}}function s(){let L=!1,te=null,P=null,ne=null,$=null,ie=null,oe=null,re=null,J=null;return{setTest:function(de){L||(de?le(i.STENCIL_TEST):ye(i.STENCIL_TEST))},setMask:function(de){te!==de&&!L&&(i.stencilMask(de),te=de)},setFunc:function(de,Ie,ce){(P!==de||ne!==Ie||$!==ce)&&(i.stencilFunc(de,Ie,ce),P=de,ne=Ie,$=ce)},setOp:function(de,Ie,ce){(ie!==de||oe!==Ie||re!==ce)&&(i.stencilOp(de,Ie,ce),ie=de,oe=Ie,re=ce)},setLocked:function(de){L=de},setClear:function(de){J!==de&&(i.clearStencil(de),J=de)},reset:function(){L=!1,te=null,P=null,ne=null,$=null,ie=null,oe=null,re=null,J=null}}}let r=new t,o=new n,a=new s,c={},l=new WeakMap,h={},d={},u={},p=new WeakMap,_=[],x=null,m=!1,f=null,w=null,A=null,S=null,M=null,E=null,g=null,v=new We(0,0,0),N=0,R=!1,D=null,U=null,z=null,I=null,q=null,Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),B=!1,ee=0,C=i.getParameter(i.VERSION);C.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(C)[1]),B=ee>=1):C.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(C)[1]),B=ee>=2);let W=null,K={},ve=i.getParameter(i.SCISSOR_BOX),we=i.getParameter(i.VIEWPORT),G=new gt().fromArray(ve),he=new gt().fromArray(we);function fe(L,te,P,ne){let $=new Uint8Array(4),ie=i.createTexture();i.bindTexture(L,ie),i.texParameteri(L,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(L,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let oe=0;oe<P;oe++)L===i.TEXTURE_3D||L===i.TEXTURE_2D_ARRAY?i.texImage3D(te,0,i.RGBA,1,1,ne,0,i.RGBA,i.UNSIGNED_BYTE,$):i.texImage2D(te+oe,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,$);return ie}let Ee={};Ee[i.TEXTURE_2D]=fe(i.TEXTURE_2D,i.TEXTURE_2D,1),Ee[i.TEXTURE_CUBE_MAP]=fe(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Ee[i.TEXTURE_2D_ARRAY]=fe(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Ee[i.TEXTURE_3D]=fe(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),le(i.DEPTH_TEST),o.setFunc(ji),yt(!1),et(sl),le(i.CULL_FACE),Je(Ii);function le(L){h[L]!==!0&&(i.enable(L),h[L]=!0)}function ye(L){h[L]!==!1&&(i.disable(L),h[L]=!1)}function Ve(L,te){return u[L]!==te?(i.bindFramebuffer(L,te),u[L]=te,L===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=te),L===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=te),!0):!1}function Me(L,te){let P=_,ne=!1;if(L){P=p.get(te),P===void 0&&(P=[],p.set(te,P));let $=L.textures;if(P.length!==$.length||P[0]!==i.COLOR_ATTACHMENT0){for(let ie=0,oe=$.length;ie<oe;ie++)P[ie]=i.COLOR_ATTACHMENT0+ie;P.length=$.length,ne=!0}}else P[0]!==i.BACK&&(P[0]=i.BACK,ne=!0);ne&&i.drawBuffers(P)}function Fe(L){return x!==L?(i.useProgram(L),x=L,!0):!1}let Te={[Li]:i.FUNC_ADD,[Kc]:i.FUNC_SUBTRACT,[jc]:i.FUNC_REVERSE_SUBTRACT};Te[Qc]=i.MIN,Te[eh]=i.MAX;let De={[th]:i.ZERO,[nh]:i.ONE,[ih]:i.SRC_COLOR,[ll]:i.SRC_ALPHA,[ch]:i.SRC_ALPHA_SATURATE,[ah]:i.DST_COLOR,[rh]:i.DST_ALPHA,[sh]:i.ONE_MINUS_SRC_COLOR,[cl]:i.ONE_MINUS_SRC_ALPHA,[lh]:i.ONE_MINUS_DST_COLOR,[oh]:i.ONE_MINUS_DST_ALPHA,[hh]:i.CONSTANT_COLOR,[uh]:i.ONE_MINUS_CONSTANT_COLOR,[dh]:i.CONSTANT_ALPHA,[fh]:i.ONE_MINUS_CONSTANT_ALPHA};function Je(L,te,P,ne,$,ie,oe,re,J,de){if(L===Ii){m===!0&&(ye(i.BLEND),m=!1);return}if(m===!1&&(le(i.BLEND),m=!0),L!==Jc){if(L!==f||de!==R){if((w!==Li||M!==Li)&&(i.blendEquation(i.FUNC_ADD),w=Li,M=Li),de)switch(L){case ds:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case rl:i.blendFunc(i.ONE,i.ONE);break;case ol:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case al:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:ze("WebGLState: Invalid blending: ",L);break}else switch(L){case ds:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case rl:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case ol:ze("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case al:ze("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ze("WebGLState: Invalid blending: ",L);break}A=null,S=null,E=null,g=null,v.set(0,0,0),N=0,f=L,R=de}return}$=$||te,ie=ie||P,oe=oe||ne,(te!==w||$!==M)&&(i.blendEquationSeparate(Te[te],Te[$]),w=te,M=$),(P!==A||ne!==S||ie!==E||oe!==g)&&(i.blendFuncSeparate(De[P],De[ne],De[ie],De[oe]),A=P,S=ne,E=ie,g=oe),(re.equals(v)===!1||J!==N)&&(i.blendColor(re.r,re.g,re.b,J),v.copy(re),N=J),f=L,R=!1}function ct(L,te){L.side===pn?ye(i.CULL_FACE):le(i.CULL_FACE);let P=L.side===Zt;te&&(P=!P),yt(P),L.blending===ds&&L.transparent===!1?Je(Ii):Je(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),o.setFunc(L.depthFunc),o.setTest(L.depthTest),o.setMask(L.depthWrite),r.setMask(L.colorWrite);let ne=L.stencilWrite;a.setTest(ne),ne&&(a.setMask(L.stencilWriteMask),a.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),a.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),Xe(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?le(i.SAMPLE_ALPHA_TO_COVERAGE):ye(i.SAMPLE_ALPHA_TO_COVERAGE)}function yt(L){D!==L&&(L?i.frontFace(i.CW):i.frontFace(i.CCW),D=L)}function et(L){L!==Yc?(le(i.CULL_FACE),L!==U&&(L===sl?i.cullFace(i.BACK):L===Zc?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):ye(i.CULL_FACE),U=L}function pt(L){L!==z&&(B&&i.lineWidth(L),z=L)}function Xe(L,te,P){L?(le(i.POLYGON_OFFSET_FILL),(I!==te||q!==P)&&(I=te,q=P,o.getReversed()&&(te=-te,P=-P),i.polygonOffset(te,P))):ye(i.POLYGON_OFFSET_FILL)}function vt(L){L?le(i.SCISSOR_TEST):ye(i.SCISSOR_TEST)}function Lt(L){L===void 0&&(L=i.TEXTURE0+Z-1),W!==L&&(i.activeTexture(L),W=L)}function Ft(L,te,P){P===void 0&&(W===null?P=i.TEXTURE0+Z-1:P=W);let ne=K[P];ne===void 0&&(ne={type:void 0,texture:void 0},K[P]=ne),(ne.type!==L||ne.texture!==te)&&(W!==P&&(i.activeTexture(P),W=P),i.bindTexture(L,te||Ee[L]),ne.type=L,ne.texture=te)}function O(){let L=K[W];L!==void 0&&L.type!==void 0&&(i.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function Rt(){try{i.compressedTexImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function it(){try{i.compressedTexImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function st(){try{i.texSubImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function _e(){try{i.texSubImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function mt(){try{i.compressedTexSubImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function Le(){try{i.compressedTexSubImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function Oe(){try{i.texStorage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function T(){try{i.texStorage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function y(){try{i.texImage2D(...arguments)}catch(L){ze("WebGLState:",L)}}function V(){try{i.texImage3D(...arguments)}catch(L){ze("WebGLState:",L)}}function ae(L){return d[L]!==void 0?d[L]:i.getParameter(L)}function se(L,te){d[L]!==te&&(i.pixelStorei(L,te),d[L]=te)}function ue(L){G.equals(L)===!1&&(i.scissor(L.x,L.y,L.z,L.w),G.copy(L))}function me(L){he.equals(L)===!1&&(i.viewport(L.x,L.y,L.z,L.w),he.copy(L))}function j(L,te){let P=l.get(te);P===void 0&&(P=new WeakMap,l.set(te,P));let ne=P.get(L);ne===void 0&&(ne=i.getUniformBlockIndex(te,L.name),i.uniformBlockBinding(te,ne,ne),P.set(L,ne))}function Q(L,te,P){let $=l.get(te).get(L);c[$]!==P&&(i.bindBufferBase(i.UNIFORM_BUFFER,$,P),c[$]=P)}function pe(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},d={},W=null,K={},u={},c={},p=new WeakMap,_=[],x=null,m=!1,f=null,w=null,A=null,S=null,M=null,E=null,g=null,v=new We(0,0,0),N=0,R=!1,D=null,U=null,z=null,I=null,q=null,G.set(0,0,i.canvas.width,i.canvas.height),he.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:le,disable:ye,bindFramebuffer:Ve,drawBuffers:Me,useProgram:Fe,setBlending:Je,setMaterial:ct,setFlipSided:yt,setCullFace:et,setLineWidth:pt,setPolygonOffset:Xe,setScissorTest:vt,activeTexture:Lt,bindTexture:Ft,unbindTexture:O,compressedTexImage2D:Rt,compressedTexImage3D:it,texImage2D:y,texImage3D:V,pixelStorei:se,getParameter:ae,updateUBOMapping:j,uniformBlockBinding:Q,texStorage2D:Oe,texStorage3D:T,texSubImage2D:st,texSubImage3D:_e,compressedTexSubImage2D:mt,compressedTexSubImage3D:Le,scissor:ue,viewport:me,reset:pe}}function A0(i,e,t,n,s,r,o){let a=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 ke,h=new WeakMap,d=new Set,u,p=new WeakMap,_=new Set,x=new FinalizationRegistry(T=>_.delete(T)),m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function f(T,y){return m?new OffscreenCanvas(T,y):Is("canvas")}function w(T,y,V){let ae=1,se=Oe(T);if((se.width>V||se.height>V)&&(ae=V/Math.max(se.width,se.height)),ae<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){let ue=Math.floor(ae*se.width),me=Math.floor(ae*se.height);u===void 0&&(u=f(ue,me));let j=y?f(ue,me):u;return j.width=ue,j.height=me,j.getContext("2d").drawImage(T,0,0,ue,me),Ue("WebGLRenderer: Texture has been resized from ("+se.width+"x"+se.height+") to ("+ue+"x"+me+")."),j}else return"data"in T&&Ue("WebGLRenderer: Image in DataTexture is too big ("+se.width+"x"+se.height+")."),T;return T}function A(T){return T.generateMipmaps}function S(T){i.generateMipmap(T)}function M(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function E(T,y,V,ae,se,ue=!1){if(T!==null){if(i[T]!==void 0)return i[T];Ue("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let me;ae&&(me=e.get("EXT_texture_norm16"),me||Ue("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let j=y;if(y===i.RED&&(V===i.FLOAT&&(j=i.R32F),V===i.HALF_FLOAT&&(j=i.R16F),V===i.UNSIGNED_BYTE&&(j=i.R8),V===i.UNSIGNED_SHORT&&me&&(j=me.R16_EXT),V===i.SHORT&&me&&(j=me.R16_SNORM_EXT)),y===i.RED_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.R8UI),V===i.UNSIGNED_SHORT&&(j=i.R16UI),V===i.UNSIGNED_INT&&(j=i.R32UI),V===i.BYTE&&(j=i.R8I),V===i.SHORT&&(j=i.R16I),V===i.INT&&(j=i.R32I)),y===i.RG&&(V===i.FLOAT&&(j=i.RG32F),V===i.HALF_FLOAT&&(j=i.RG16F),V===i.UNSIGNED_BYTE&&(j=i.RG8),V===i.UNSIGNED_SHORT&&me&&(j=me.RG16_EXT),V===i.SHORT&&me&&(j=me.RG16_SNORM_EXT)),y===i.RG_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.RG8UI),V===i.UNSIGNED_SHORT&&(j=i.RG16UI),V===i.UNSIGNED_INT&&(j=i.RG32UI),V===i.BYTE&&(j=i.RG8I),V===i.SHORT&&(j=i.RG16I),V===i.INT&&(j=i.RG32I)),y===i.RGB_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.RGB8UI),V===i.UNSIGNED_SHORT&&(j=i.RGB16UI),V===i.UNSIGNED_INT&&(j=i.RGB32UI),V===i.BYTE&&(j=i.RGB8I),V===i.SHORT&&(j=i.RGB16I),V===i.INT&&(j=i.RGB32I)),y===i.RGBA_INTEGER&&(V===i.UNSIGNED_BYTE&&(j=i.RGBA8UI),V===i.UNSIGNED_SHORT&&(j=i.RGBA16UI),V===i.UNSIGNED_INT&&(j=i.RGBA32UI),V===i.BYTE&&(j=i.RGBA8I),V===i.SHORT&&(j=i.RGBA16I),V===i.INT&&(j=i.RGBA32I)),y===i.RGB&&(V===i.UNSIGNED_SHORT&&me&&(j=me.RGB16_EXT),V===i.SHORT&&me&&(j=me.RGB16_SNORM_EXT),V===i.UNSIGNED_INT_5_9_9_9_REV&&(j=i.RGB9_E5),V===i.UNSIGNED_INT_10F_11F_11F_REV&&(j=i.R11F_G11F_B10F)),y===i.RGBA){let Q=ue?Ps:Qe.getTransfer(se);V===i.FLOAT&&(j=i.RGBA32F),V===i.HALF_FLOAT&&(j=i.RGBA16F),V===i.UNSIGNED_BYTE&&(j=Q===lt?i.SRGB8_ALPHA8:i.RGBA8),V===i.UNSIGNED_SHORT&&me&&(j=me.RGBA16_EXT),V===i.SHORT&&me&&(j=me.RGBA16_SNORM_EXT),V===i.UNSIGNED_SHORT_4_4_4_4&&(j=i.RGBA4),V===i.UNSIGNED_SHORT_5_5_5_1&&(j=i.RGB5_A1)}return(j===i.R16F||j===i.R32F||j===i.RG16F||j===i.RG32F||j===i.RGBA16F||j===i.RGBA32F)&&e.get("EXT_color_buffer_float"),j}function g(T,y){let V;return T?y===null||y===Mn||y===Ni?V=i.DEPTH24_STENCIL8:y===Sn?V=i.DEPTH32F_STENCIL8:y===ps&&(V=i.DEPTH24_STENCIL8,Ue("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===Mn||y===Ni?V=i.DEPTH_COMPONENT24:y===Sn?V=i.DEPTH_COMPONENT32F:y===ps&&(V=i.DEPTH_COMPONENT16),V}function v(T,y){return A(T)===!0||T.isFramebufferTexture&&T.minFilter!==It&&T.minFilter!==qt?Math.log2(Math.max(y.width,y.height))+1:T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?y.mipmaps.length:1}function N(T){let y=new WeakRef(T);n.get(T).__ref=y,_.add(y),x.register(T,y,y)}function R(T){let y=n.get(T).__ref;y!==void 0&&(_.delete(y),x.unregister(y))}function D(T){z(T.target)}function U(T){I(T.target)}function z(T){T.removeEventListener("dispose",D),R(T),Z(T),T.isVideoTexture&&h.delete(T),T.isHTMLTexture&&d.delete(T)}function I(T){T.removeEventListener("dispose",U),R(T),ee(T)}function q(){for(let T of _){let y=T.deref();y!==void 0&&(y.isRenderTarget===!0?I(y):z(y))}_.clear(),d.clear()}function Z(T){let y=n.get(T);if(y.__webglInit===void 0)return;let V=T.source,ae=p.get(V);if(ae){let se=ae[y.__cacheKey];se.usedTimes--,se.usedTimes===0&&B(T),Object.keys(ae).length===0&&p.delete(V)}n.remove(T)}function B(T){let y=n.get(T);i.deleteTexture(y.__webglTexture);let V=T.source,ae=p.get(V);delete ae[y.__cacheKey],o.memory.textures--}function ee(T){let y=n.get(T);y.__depthDisposeCallback&&y.__depthDisposeCallback();let V=T.depthTexture;if(V&&V.renderTarget===T&&z(V),T.isWebGLCubeRenderTarget)for(let se=0;se<6;se++){if(Array.isArray(y.__webglFramebuffer[se]))for(let ue=0;ue<y.__webglFramebuffer[se].length;ue++)i.deleteFramebuffer(y.__webglFramebuffer[se][ue]);else i.deleteFramebuffer(y.__webglFramebuffer[se]);y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer[se])}else{if(Array.isArray(y.__webglFramebuffer))for(let se=0;se<y.__webglFramebuffer.length;se++)i.deleteFramebuffer(y.__webglFramebuffer[se]);else i.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&i.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&i.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let se=0;se<y.__webglColorRenderbuffer.length;se++)y.__webglColorRenderbuffer[se]&&i.deleteRenderbuffer(y.__webglColorRenderbuffer[se]);y.__webglDepthRenderbuffer&&i.deleteRenderbuffer(y.__webglDepthRenderbuffer)}let ae=T.textures;for(let se=0,ue=ae.length;se<ue;se++){let me=n.get(ae[se]);me.__webglTexture&&(i.deleteTexture(me.__webglTexture),o.memory.textures--),n.remove(ae[se])}n.remove(T)}let C=0;function W(){C=0}function K(){return C}function ve(T){C=T}function we(){let T=C;return T>=s.maxTextures&&Ue("WebGLTextures: Trying to use "+(T+1)+" texture units while this GPU supports only "+s.maxTextures),C+=1,T}function G(T){let y=[];return y.push(T.wrapS),y.push(T.wrapT),y.push(T.wrapR||0),y.push(T.magFilter),y.push(T.minFilter),y.push(T.anisotropy),y.push(T.internalFormat),y.push(T.format),y.push(T.type),y.push(T.generateMipmaps),y.push(T.mipmapsAutoUpdate),y.push(T.premultiplyAlpha),y.push(T.flipY),y.push(T.unpackAlignment),y.push(T.colorSpace),y.join()}function he(T,y){let V=n.get(T);if(T.isVideoTexture&&mt(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&V.__version!==T.version){let ae=T.image;if(ae===null)Ue("WebGLRenderer: Texture marked for update but no image data found.");else if(ae.complete===!1)Ue("WebGLRenderer: Texture marked for update but image is incomplete");else{ct(V,T,y);return}}else T.isExternalTexture&&(V.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,V.__webglTexture,i.TEXTURE0+y)}function fe(T,y){let V=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&V.__version!==T.version){ct(V,T,y);return}else T.isExternalTexture&&(V.__webglTexture=T.sourceTexture?T.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,V.__webglTexture,i.TEXTURE0+y)}function Ee(T,y){let V=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&V.__version!==T.version){ct(V,T,y);return}t.bindTexture(i.TEXTURE_3D,V.__webglTexture,i.TEXTURE0+y)}function le(T,y){let V=n.get(T);if(T.version>0&&V.__version!==T.version){yt(V,T,y);return}t.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture,i.TEXTURE0+y)}let ye={[Jr]:i.REPEAT,[An]:i.CLAMP_TO_EDGE,[Kr]:i.MIRRORED_REPEAT},Ve={[It]:i.NEAREST,[gh]:i.NEAREST_MIPMAP_NEAREST,[$s]:i.NEAREST_MIPMAP_LINEAR,[qt]:i.LINEAR,[Ao]:i.LINEAR_MIPMAP_NEAREST,[Kn]:i.LINEAR_MIPMAP_LINEAR},Me={[vh]:i.NEVER,[Tl]:i.ALWAYS,[bh]:i.LESS,[wl]:i.LEQUAL,[Mh]:i.EQUAL,[El]:i.GEQUAL,[Sh]:i.GREATER,[wh]:i.NOTEQUAL};function Fe(T,y){if(y.type===Sn&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===qt||y.magFilter===Ao||y.magFilter===$s||y.magFilter===Kn||y.minFilter===qt||y.minFilter===Ao||y.minFilter===$s||y.minFilter===Kn)&&Ue("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,ye[y.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,ye[y.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,ye[y.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,Ve[y.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,Ve[y.minFilter]),y.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,Me[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===It||y.minFilter!==$s&&y.minFilter!==Kn||y.type===Sn&&e.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||n.get(y).__currentAnisotropy){let V=e.get("EXT_texture_filter_anisotropic");i.texParameterf(T,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,s.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function Te(T,y){let V=!1;T.__webglInit===void 0&&(T.__webglInit=!0,y.addEventListener("dispose",D),N(y));let ae=y.source,se=p.get(ae);se===void 0&&(se={},p.set(ae,se));let ue=G(y);if(ue!==T.__cacheKey){se[ue]===void 0&&(se[ue]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,V=!0),se[ue].usedTimes++;let me=se[T.__cacheKey];me!==void 0&&(se[T.__cacheKey].usedTimes--,me.usedTimes===0&&B(y)),T.__cacheKey=ue,T.__webglTexture=se[ue].texture}return V}function De(T,y,V){return Math.floor(Math.floor(T/V)/y)}function Je(T,y,V,ae){let ue=T.updateRanges;if(ue.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,y.width,y.height,V,ae,y.data);else{ue.sort((L,te)=>L.start-te.start);let me=0;for(let L=1;L<ue.length;L++){let te=ue[me],P=ue[L],ne=te.start+te.count,$=De(P.start,y.width,4),ie=De(te.start,y.width,4);P.start<=ne+1&&$===ie&&De(P.start+P.count-1,y.width,4)===$?te.count=Math.max(te.count,P.start+P.count-te.start):(++me,ue[me]=P)}ue.length=me+1;let j=t.getParameter(i.UNPACK_ROW_LENGTH),Q=t.getParameter(i.UNPACK_SKIP_PIXELS),pe=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,y.width);for(let L=0,te=ue.length;L<te;L++){let P=ue[L],ne=Math.floor(P.start/4),$=Math.ceil(P.count/4),ie=ne%y.width,oe=Math.floor(ne/y.width),re=$,J=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,ie),t.pixelStorei(i.UNPACK_SKIP_ROWS,oe),t.texSubImage2D(i.TEXTURE_2D,0,ie,oe,re,J,V,ae,y.data)}T.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,j),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(i.UNPACK_SKIP_ROWS,pe)}}function ct(T,y,V){let ae=i.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(ae=i.TEXTURE_2D_ARRAY),y.isData3DTexture&&(ae=i.TEXTURE_3D);let se=Te(T,y),ue=y.source;t.bindTexture(ae,T.__webglTexture,i.TEXTURE0+V);let me=n.get(ue);if(ue.version!==me.__version||se===!0){if(t.activeTexture(i.TEXTURE0+V),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let J=Qe.getPrimaries(Qe.workingColorSpace),de=y.colorSpace===Qn?null:Qe.getPrimaries(y.colorSpace),Ie=y.colorSpace===Qn||J===de?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ie)}t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment);let Q=w(y.image,!1,s.maxTextureSize);Q=Le(y,Q);let pe=r.convert(y.format,y.colorSpace),L=r.convert(y.type),te=E(y.internalFormat,pe,L,y.normalized,y.colorSpace,y.isVideoTexture);Fe(ae,y);let P,ne=y.mipmaps,$=y.isVideoTexture!==!0,ie=me.__version===void 0||se===!0,oe=ue.dataReady,re=v(y,Q);if(y.isDepthTexture)te=g(y.format===jn,y.type),ie&&($?t.texStorage2D(i.TEXTURE_2D,1,te,Q.width,Q.height):t.texImage2D(i.TEXTURE_2D,0,te,Q.width,Q.height,0,pe,L,null));else if(y.isDataTexture)if(ne.length>0){$&&ie&&t.texStorage2D(i.TEXTURE_2D,re,te,ne[0].width,ne[0].height);for(let J=0,de=ne.length;J<de;J++)P=ne[J],$?oe&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,P.width,P.height,pe,L,P.data):t.texImage2D(i.TEXTURE_2D,J,te,P.width,P.height,0,pe,L,P.data);y.generateMipmaps=!1}else $?(ie&&t.texStorage2D(i.TEXTURE_2D,re,te,Q.width,Q.height),oe&&Je(y,Q,pe,L)):t.texImage2D(i.TEXTURE_2D,0,te,Q.width,Q.height,0,pe,L,Q.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){$&&ie&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,te,ne[0].width,ne[0].height,Q.depth);for(let J=0,de=ne.length;J<de;J++)if(P=ne[J],y.format!==En)if(pe!==null)if($){if(oe)if(y.layerUpdates.size>0){let Ie=Fl(P.width,P.height,y.format,y.type);for(let ce of y.layerUpdates){let Ne=P.data.subarray(ce*Ie/P.data.BYTES_PER_ELEMENT,(ce+1)*Ie/P.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,ce,P.width,P.height,1,pe,Ne)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,P.width,P.height,Q.depth,pe,P.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,te,P.width,P.height,Q.depth,0,P.data,0,0);else Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else $?oe&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,P.width,P.height,Q.depth,pe,L,P.data):t.texImage3D(i.TEXTURE_2D_ARRAY,J,te,P.width,P.height,Q.depth,0,pe,L,P.data);y.layerUpdates.size>0&&y.clearLayerUpdates()}else{$&&ie&&t.texStorage2D(i.TEXTURE_2D,re,te,ne[0].width,ne[0].height);for(let J=0,de=ne.length;J<de;J++)P=ne[J],y.format!==En?pe!==null?$?oe&&t.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,P.width,P.height,pe,P.data):t.compressedTexImage2D(i.TEXTURE_2D,J,te,P.width,P.height,0,P.data):Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):$?oe&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,P.width,P.height,pe,L,P.data):t.texImage2D(i.TEXTURE_2D,J,te,P.width,P.height,0,pe,L,P.data)}else if(y.isDataArrayTexture)if($){if(ie&&t.texStorage3D(i.TEXTURE_2D_ARRAY,re,te,Q.width,Q.height,Q.depth),oe)if(y.layerUpdates.size>0){let J=Fl(Q.width,Q.height,y.format,y.type);for(let de of y.layerUpdates){let Ie=Q.data.subarray(de*J/Q.data.BYTES_PER_ELEMENT,(de+1)*J/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,de,Q.width,Q.height,1,pe,L,Ie)}y.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,pe,L,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,te,Q.width,Q.height,Q.depth,0,pe,L,Q.data);else if(y.isData3DTexture)$?(ie&&t.texStorage3D(i.TEXTURE_3D,re,te,Q.width,Q.height,Q.depth),oe&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,pe,L,Q.data)):t.texImage3D(i.TEXTURE_3D,0,te,Q.width,Q.height,Q.depth,0,pe,L,Q.data);else if(y.isFramebufferTexture){if(ie)if($)t.texStorage2D(i.TEXTURE_2D,re,te,Q.width,Q.height);else{let J=Q.width,de=Q.height;for(let Ie=0;Ie<re;Ie++)t.texImage2D(i.TEXTURE_2D,Ie,te,J,de,0,pe,L,null),J>>=1,de>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in i){let J=i.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),Q.parentNode!==J){J.appendChild(Q),d.add(y),J.onpaint=de=>{let Ie=de.changedElements;for(let ce of d)Ie.includes(ce.image)&&(ce.needsUpdate=!0)},J.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{let Ie=i.RGBA,ce=i.RGBA,Ne=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Ie,ce,Ne,Q)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(ne.length>0){if($&&ie){let J=Oe(ne[0]);t.texStorage2D(i.TEXTURE_2D,re,te,J.width,J.height)}for(let J=0,de=ne.length;J<de;J++)P=ne[J],$?oe&&t.texSubImage2D(i.TEXTURE_2D,J,0,0,pe,L,P):t.texImage2D(i.TEXTURE_2D,J,te,pe,L,P);y.generateMipmaps=!1}else if($){if(ie){let J=Oe(Q);t.texStorage2D(i.TEXTURE_2D,re,te,J.width,J.height)}oe&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,pe,L,Q)}else t.texImage2D(i.TEXTURE_2D,0,te,pe,L,Q);A(y)&&y.mipmapsAutoUpdate===!0&&S(ae),me.__version=ue.version,y.onUpdate&&y.onUpdate(y)}T.__version=y.version}function yt(T,y,V){if(y.image.length!==6)return;let ae=Te(T,y),se=y.source;t.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+V);let ue=n.get(se);if(se.version!==ue.__version||ae===!0){t.activeTexture(i.TEXTURE0+V);let me=Qe.getPrimaries(Qe.workingColorSpace),j=y.colorSpace===Qn?null:Qe.getPrimaries(y.colorSpace),Q=y.colorSpace===Qn||me===j?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,y.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);let pe=y.isCompressedTexture||y.image[0].isCompressedTexture,L=y.image[0]&&y.image[0].isDataTexture,te=[];for(let ce=0;ce<6;ce++)!pe&&!L?te[ce]=w(y.image[ce],!0,s.maxCubemapSize):te[ce]=L?y.image[ce].image:y.image[ce],te[ce]=Le(y,te[ce]);let P=te[0],ne=r.convert(y.format,y.colorSpace),$=r.convert(y.type),ie=E(y.internalFormat,ne,$,y.normalized,y.colorSpace),oe=y.isVideoTexture!==!0,re=ue.__version===void 0||ae===!0,J=se.dataReady,de=v(y,P);Fe(i.TEXTURE_CUBE_MAP,y);let Ie;if(y.isDepthTexture){if(ie=g(y.format===jn,y.type),re)if(oe)t.texStorage2D(i.TEXTURE_CUBE_MAP,1,ie,P.width,P.height);else for(let ce=0;ce<6;ce++)t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ie,P.width,P.height,0,ne,$,null)}else if(pe){oe&&re&&t.texStorage2D(i.TEXTURE_CUBE_MAP,de,ie,P.width,P.height);for(let ce=0;ce<6;ce++){Ie=te[ce].mipmaps;for(let Ne=0;Ne<Ie.length;Ne++){let tt=Ie[Ne];y.format!==En?ne!==null?oe?J&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne,0,0,tt.width,tt.height,ne,tt.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne,ie,tt.width,tt.height,0,tt.data):Ue("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):oe?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne,0,0,tt.width,tt.height,ne,$,tt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne,ie,tt.width,tt.height,0,ne,$,tt.data)}}}else{if(Ie=y.mipmaps,oe&&re){Ie.length>0&&de++;let ce=Oe(te[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,de,ie,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(L){oe?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,te[ce].width,te[ce].height,ne,$,te[ce].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ie,te[ce].width,te[ce].height,0,ne,$,te[ce].data);for(let Ne=0;Ne<Ie.length;Ne++){let _t=Ie[Ne].image[ce].image;oe?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne+1,0,0,_t.width,_t.height,ne,$,_t.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne+1,ie,_t.width,_t.height,0,ne,$,_t.data)}}else{oe?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,ne,$,te[ce]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ie,ne,$,te[ce]);for(let Ne=0;Ne<Ie.length;Ne++){let tt=Ie[Ne];oe?J&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne+1,0,0,ne,$,tt.image[ce]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ne+1,ie,ne,$,tt.image[ce])}}}A(y)&&y.mipmapsAutoUpdate===!0&&S(i.TEXTURE_CUBE_MAP),ue.__version=se.version,y.onUpdate&&y.onUpdate(y)}T.__version=y.version}function et(T,y,V,ae,se,ue){let me=r.convert(V.format,V.colorSpace),j=r.convert(V.type),Q=E(V.internalFormat,me,j,V.normalized,V.colorSpace),pe=n.get(y),L=n.get(V);if(L.__renderTarget=y,!pe.__hasExternalTextures){let te=Math.max(1,y.width>>ue),P=Math.max(1,y.height>>ue);se===i.TEXTURE_3D||se===i.TEXTURE_2D_ARRAY?t.texImage3D(se,ue,Q,te,P,y.depth,0,me,j,null):t.texImage2D(se,ue,Q,te,P,0,me,j,null)}t.bindFramebuffer(i.FRAMEBUFFER,T),_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ae,se,L.__webglTexture,0,st(y)):(se===i.TEXTURE_2D||se>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&se<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,ae,se,L.__webglTexture,ue),t.bindFramebuffer(i.FRAMEBUFFER,null)}function pt(T,y,V){if(i.bindRenderbuffer(i.RENDERBUFFER,T),y.depthBuffer){let ae=y.depthTexture,se=ae&&ae.isDepthTexture?ae.type:null,ue=g(y.stencilBuffer,se),me=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;_e(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(y),ue,y.width,y.height):V?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(y),ue,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,ue,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,me,i.RENDERBUFFER,T)}else{let ae=y.textures;for(let se=0;se<ae.length;se++){let ue=ae[se],me=r.convert(ue.format,ue.colorSpace),j=r.convert(ue.type),Q=E(ue.internalFormat,me,j,ue.normalized,ue.colorSpace);_e(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,st(y),Q,y.width,y.height):V?i.renderbufferStorageMultisample(i.RENDERBUFFER,st(y),Q,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,Q,y.width,y.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Xe(T,y,V){let ae=y.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,T),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");let se=n.get(y.depthTexture);se.__renderTarget=y;let ue=ae?y.depthTexture.image[0]:y.depthTexture.image;(!se.__webglTexture||ue.width!==y.width||ue.height!==y.height)&&(ue.width=y.width,ue.height=y.height,y.depthTexture.needsUpdate=!0),ae?le(y.depthTexture,0):he(y.depthTexture,0);let me=se.__webglTexture,j=st(y),Q=ae?i.TEXTURE_CUBE_MAP_POSITIVE_X+V:i.TEXTURE_2D,pe=y.depthTexture.format===jn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(y.depthTexture.format===Yn)_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,pe,Q,me,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,pe,Q,me,0);else if(y.depthTexture.format===jn)_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,pe,Q,me,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,pe,Q,me,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function vt(T){let y=n.get(T),V=T.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==T.depthTexture){let ae=T.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),ae){let se=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,ae.removeEventListener("dispose",se)};ae.addEventListener("dispose",se),y.__depthDisposeCallback=se}y.__boundDepthTexture=ae}if(T.depthTexture&&!y.__autoAllocateDepthBuffer)if(V)for(let ae=0;ae<6;ae++)Xe(y.__webglFramebuffer[ae],T,ae);else T.texture.mipmaps.length>0?Xe(y.__webglFramebuffer[0],T,0):Xe(y.__webglFramebuffer,T,0);else if(V){y.__webglDepthbuffer=[];for(let ae=0;ae<6;ae++)if(t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[ae]),y.__webglDepthbuffer[ae]===void 0)y.__webglDepthbuffer[ae]=i.createRenderbuffer(),pt(y.__webglDepthbuffer[ae],T,!1);else{let se=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ue=y.__webglDepthbuffer[ae];i.bindRenderbuffer(i.RENDERBUFFER,ue),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,ue)}}else if(T.texture.mipmaps.length>0?t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=i.createRenderbuffer(),pt(y.__webglDepthbuffer,T,!1);else{let se=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ue=y.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ue),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,ue)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Lt(T,y,V){let ae=n.get(T);y!==void 0&&et(ae.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),V!==void 0&&vt(T)}function Ft(T){let y=T.texture,V=n.get(T),ae=n.get(y);T.addEventListener("dispose",U),N(T);let se=T.textures,ue=T.isWebGLCubeRenderTarget===!0,me=se.length>1;if(me||(ae.__webglTexture===void 0&&(ae.__webglTexture=i.createTexture()),ae.__version=y.version,o.memory.textures++),ue){V.__webglFramebuffer=[];for(let j=0;j<6;j++)if(y.mipmaps.length>0){V.__webglFramebuffer[j]=[];for(let Q=0;Q<y.mipmaps.length;Q++)V.__webglFramebuffer[j][Q]=i.createFramebuffer()}else V.__webglFramebuffer[j]=i.createFramebuffer()}else{if(y.mipmaps.length>0){V.__webglFramebuffer=[];for(let j=0;j<y.mipmaps.length;j++)V.__webglFramebuffer[j]=i.createFramebuffer()}else V.__webglFramebuffer=i.createFramebuffer();if(me)for(let j=0,Q=se.length;j<Q;j++){let pe=n.get(se[j]);pe.__webglTexture===void 0&&(pe.__webglTexture=i.createTexture(),o.memory.textures++)}if(T.samples>0&&_e(T)===!1){V.__webglMultisampledFramebuffer=i.createFramebuffer(),V.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let j=0;j<se.length;j++){let Q=se[j];V.__webglColorRenderbuffer[j]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,V.__webglColorRenderbuffer[j]);let pe=r.convert(Q.format,Q.colorSpace),L=r.convert(Q.type),te=E(Q.internalFormat,pe,L,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),P=st(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,P,te,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+j,i.RENDERBUFFER,V.__webglColorRenderbuffer[j])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(V.__webglDepthRenderbuffer=i.createRenderbuffer(),pt(V.__webglDepthRenderbuffer,T,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ue){t.bindTexture(i.TEXTURE_CUBE_MAP,ae.__webglTexture),Fe(i.TEXTURE_CUBE_MAP,y);for(let j=0;j<6;j++)if(y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)et(V.__webglFramebuffer[j][Q],T,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Q);else et(V.__webglFramebuffer[j],T,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0);A(y)?S(i.TEXTURE_CUBE_MAP):y.mipmaps.length>0&&i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,y.mipmaps.length-1),t.unbindTexture()}else if(me){for(let j=0,Q=se.length;j<Q;j++){let pe=se[j],L=n.get(pe),te=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(te=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(te,L.__webglTexture),Fe(te,pe),et(V.__webglFramebuffer,T,pe,i.COLOR_ATTACHMENT0+j,te,0),A(pe)&&S(te)}t.unbindTexture()}else{let j=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(j=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(j,ae.__webglTexture),Fe(j,y),y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)et(V.__webglFramebuffer[Q],T,y,i.COLOR_ATTACHMENT0,j,Q);else et(V.__webglFramebuffer,T,y,i.COLOR_ATTACHMENT0,j,0);A(y)?S(j):y.mipmaps.length>0&&i.texParameteri(j,i.TEXTURE_MAX_LEVEL,y.mipmaps.length-1),t.unbindTexture()}T.depthBuffer&&vt(T)}function O(T){let y=T.textures;for(let V=0,ae=y.length;V<ae;V++){let se=y[V];if(A(se)&&se.mipmapsAutoUpdate===!0){let ue=M(T),me=n.get(se).__webglTexture;t.bindTexture(ue,me),S(ue),t.unbindTexture()}}}let Rt=[];function it(T){if(T.samples>0){if(_e(T)===!1){let y=T.textures,V=T.width,ae=T.height,se=i.COLOR_BUFFER_BIT,ue=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,me=n.get(T),j=y.length>1;if(j)for(let pe=0;pe<y.length;pe++)t.bindFramebuffer(i.FRAMEBUFFER,me.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,me.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,me.__webglMultisampledFramebuffer),T.texture.mipmaps.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,me.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,me.__webglFramebuffer);for(let pe=0;pe<y.length;pe++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(se|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(se|=i.STENCIL_BUFFER_BIT)),j){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,me.__webglColorRenderbuffer[pe]);let L=n.get(y[pe]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,L,0)}i.blitFramebuffer(0,0,V,ae,0,0,V,ae,se,i.NEAREST),c===!0&&(Rt.length=0,Rt.push(i.COLOR_ATTACHMENT0+pe),T.depthBuffer&&T.storeMultisampledDepthBuffer===!1&&Rt.push(ue),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Rt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),j)for(let pe=0;pe<y.length;pe++){t.bindFramebuffer(i.FRAMEBUFFER,me.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.RENDERBUFFER,me.__webglColorRenderbuffer[pe]);let L=n.get(y[pe]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,me.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+pe,i.TEXTURE_2D,L,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,me.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.storeMultisampledDepthBuffer===!1&&c){let y=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[y])}}}function st(T){return Math.min(s.maxSamples,T.samples)}function _e(T){let y=n.get(T);return T.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function mt(T){let y=o.render.frame;h.get(T)!==y&&(h.set(T,y),T.update())}function Le(T,y){let V=T.colorSpace,ae=T.format,se=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||V!==Cs&&V!==Qn&&(Qe.getTransfer(V)===lt?(ae!==En||se!==jt)&&Ue("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ze("WebGLTextures: Unsupported texture color space:",V)),y}function Oe(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=we,this.resetTextureUnits=W,this.getTextureUnits=K,this.setTextureUnits=ve,this.setTexture2D=he,this.setTexture2DArray=fe,this.setTexture3D=Ee,this.setTextureCube=le,this.rebindTextures=Lt,this.setupRenderTarget=Ft,this.updateRenderTargetMipmap=O,this.updateMultisampleRenderTarget=it,this.setupDepthRenderbuffer=vt,this.setupFrameBufferTexture=et,this.useMultisampledRTT=_e,this.dispose=q}function R0(i,e){function t(n,s=Qn){let r,o=Qe.getTransfer(s);if(n===jt)return i.UNSIGNED_BYTE;if(n===Co)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Po)return i.UNSIGNED_SHORT_5_5_5_1;if(n===yl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===vl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===_l)return i.BYTE;if(n===xl)return i.SHORT;if(n===ps)return i.UNSIGNED_SHORT;if(n===Ro)return i.INT;if(n===Mn)return i.UNSIGNED_INT;if(n===Sn)return i.FLOAT;if(n===wn)return i.HALF_FLOAT;if(n===bl)return i.ALPHA;if(n===Ml)return i.RGB;if(n===En)return i.RGBA;if(n===Yn)return i.DEPTH_COMPONENT;if(n===jn)return i.DEPTH_STENCIL;if(n===Sl)return i.RED;if(n===Io)return i.RED_INTEGER;if(n===_i)return i.RG;if(n===Lo)return i.RG_INTEGER;if(n===Do)return i.RGBA_INTEGER;if(n===Js||n===Ks||n===js||n===Qs)if(o===lt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Js)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ks)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Qs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Js)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ks)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Qs)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===No||n===Uo||n===Fo||n===Oo)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===No)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Uo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Fo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Oo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Bo||n===zo||n===ko||n===Vo||n===Go||n===er||n===Ho)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Bo||n===zo)return o===lt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ko)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Vo)return r.COMPRESSED_R11_EAC;if(n===Go)return r.COMPRESSED_SIGNED_R11_EAC;if(n===er)return r.COMPRESSED_RG11_EAC;if(n===Ho)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Wo||n===Xo||n===qo||n===Yo||n===Zo||n===$o||n===Jo||n===Ko||n===jo||n===Qo||n===ea||n===ta||n===na||n===ia)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Wo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Xo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Yo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Zo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===$o)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Jo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ko)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===jo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Qo)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ea)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ta)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===na)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ia)return o===lt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===sa||n===ra||n===oa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===sa)return o===lt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ra)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===oa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===aa||n===la||n===tr||n===ca)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===aa)return r.COMPRESSED_RED_RGTC1_EXT;if(n===la)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===tr)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===ca)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ni?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var C0=`
4202
4202
  void main() {
4203
4203
 
4204
4204
  gl_Position = vec4( position, 1.0 );
4205
4205
 
4206
- }`,o_=`
4206
+ }`,P0=`
4207
4207
  uniform sampler2DArray depthColor;
4208
4208
  uniform float depthWidth;
4209
4209
  uniform float depthHeight;
@@ -4222,4 +4222,4 @@ void main() {
4222
4222
 
4223
4223
  }
4224
4224
 
4225
- }`,Dl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new As(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){let t=e.cameras[0].viewport,n=new vn({vertexShader:a_,fragmentShader:o_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new en(new Cs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Nl=class extends dn{constructor(e,t){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,m=null,_=null,y=typeof XRWebGLBinding<"u",p=new Dl,f={},S=t.getContextAttributes(),A=null,b=null,T=[],E=[],g=new Fe,M=null,U=null,I=new Bt;I.viewport=new dt;let D=new Bt;D.viewport=new dt;let F=[I,D],H=new la,C=null,Y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(j){let pe=T[j];return pe===void 0&&(pe=new qi,T[j]=pe),pe.getTargetRaySpace()},this.getControllerGrip=function(j){let pe=T[j];return pe===void 0&&(pe=new qi,T[j]=pe),pe.getGripSpace()},this.getHand=function(j){let pe=T[j];return pe===void 0&&(pe=new qi,T[j]=pe),pe.getHandSpace()};function J(j){let pe=E.indexOf(j.inputSource);if(pe===-1)return;let ye=T[pe];ye!==void 0&&(ye.update(j.inputSource,j.frame,l||a),ye.dispatchEvent({type:j.type,data:j.inputSource}))}function z(){s.removeEventListener("select",J),s.removeEventListener("selectstart",J),s.removeEventListener("selectend",J),s.removeEventListener("squeeze",J),s.removeEventListener("squeezestart",J),s.removeEventListener("squeezeend",J),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",te);for(let j=0;j<T.length;j++){let pe=E[j];pe!==null&&(E[j]=null,T[j].disconnect(pe))}C=null,Y=null,p.reset();for(let j in f)delete f[j];if(e.setRenderTarget(A),m=null,u=null,d=null,s=null,b=null,De.stop(),n.isPresenting=!1,e.setPixelRatio(M),e.setSize(g.width,g.height,!1),U!==null){let j=U.camera;j.fov=U.fov,j.zoom=U.zoom,j.updateProjectionMatrix(),U=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(j){r=j,n.isPresenting===!0&&Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(j){o=j,n.isPresenting===!0&&Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(j){l=j},this.getBaseLayer=function(){return u!==null?u:m},this.getBinding=function(){return d===null&&y&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(j){if(s=j,s!==null){if(A=e.getRenderTarget(),s.addEventListener("select",J),s.addEventListener("selectstart",J),s.addEventListener("selectend",J),s.addEventListener("squeeze",J),s.addEventListener("squeezestart",J),s.addEventListener("squeezeend",J),s.addEventListener("end",z),s.addEventListener("inputsourceschange",te),S.xrCompatible!==!0&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(g),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let ye=null,Re=null,fe=null;S.depth&&(fe=S.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ye=S.stencil?Vn:Fn,Re=S.stencil?bi:fn);let Le={colorFormat:t.RGBA8,depthFormat:fe,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(Le),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),b=new Qt(u.textureWidth,u.textureHeight,{format:gn,type:Xt,depthTexture:new zn(u.textureWidth,u.textureHeight,Re,void 0,void 0,void 0,void 0,void 0,void 0,ye),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1,storeMultisampledDepthBuffer:u.ignoreDepthValues===!1,storeMultisampledStencilBuffer:u.ignoreDepthValues===!1})}else{let ye={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,t,ye),s.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new Qt(m.framebufferWidth,m.framebufferHeight,{format:gn,type:Xt,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1,storeMultisampledDepthBuffer:m.ignoreDepthValues===!1,storeMultisampledStencilBuffer:m.ignoreDepthValues===!1})}b.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),De.setContext(s),De.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function te(j){for(let pe=0;pe<j.removed.length;pe++){let ye=j.removed[pe],Re=E.indexOf(ye);Re>=0&&(E[Re]=null,T[Re].disconnect(ye))}for(let pe=0;pe<j.added.length;pe++){let ye=j.added[pe],Re=E.indexOf(ye);if(Re===-1){for(let Le=0;Le<T.length;Le++)if(Le>=E.length){E.push(ye),Re=Le;break}else if(E[Le]===null){E[Le]=ye,Re=Le;break}if(Re===-1)break}let fe=T[Re];fe&&fe.connect(ye)}}function W(j,pe){pe===null?j.matrixWorld.copy(j.matrix):j.matrixWorld.multiplyMatrices(pe.matrixWorld,j.matrix),j.matrixWorldInverse.copy(j.matrixWorld).invert()}this.updateCamera=function(j){if(s===null)return;let pe=j.near,ye=j.far;p.texture!==null&&(p.depthNear>0&&(pe=p.depthNear),p.depthFar>0&&(ye=p.depthFar)),H.near=D.near=I.near=pe,H.far=D.far=I.far=ye,(C!==H.near||Y!==H.far)&&(s.updateRenderState({depthNear:H.near,depthFar:H.far}),C=H.near,Y=H.far),H.layers.mask=j.layers.mask|6,I.layers.mask=H.layers.mask&-5,D.layers.mask=H.layers.mask&-3;let Re=j.parent,fe=H.cameras;W(H,Re);for(let Le=0;Le<fe.length;Le++)W(fe[Le],Re);H.projectionMatrix.copy(I.projectionMatrix),H.projectionMatrixInverse.copy(I.projectionMatrixInverse),U===null&&j.isPerspectiveCamera&&(U={camera:j,fov:j.fov,zoom:j.zoom}),$(j,H,Re)};function $(j,pe,ye){ye===null?j.matrix.copy(pe.matrixWorld):(j.matrix.copy(ye.matrixWorld),j.matrix.invert(),j.matrix.multiply(pe.matrixWorld)),j.matrix.decompose(j.position,j.quaternion,j.scale),j.updateMatrixWorld(!0),j.projectionMatrix.copy(pe.projectionMatrix),j.projectionMatrixInverse.copy(pe.projectionMatrixInverse),j.isPerspectiveCamera&&(j.fov=Wi*2*Math.atan(1/j.projectionMatrix.elements[5]),j.zoom=1)}this.getCamera=function(){return H},this.getFoveation=function(){if(!(u===null&&m===null))return c},this.setFoveation=function(j){c=j,u!==null&&(u.fixedFoveation=j),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=j)},this.hasDepthSensing=function(){return p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(H)},this.getCameraTexture=function(j){return f[j]};let ae=null;function _e(j,pe){if(h=pe.getViewerPose(l||a),_=pe,h!==null){let ye=h.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let Re=!1;ye.length!==H.cameras.length&&(H.cameras.length=0,Re=!0);for(let be=0;be<ye.length;be++){let $e=ye[be],it=null;if(m!==null)it=m.getViewport($e);else{let lt=d.getViewSubImage(u,$e);it=lt.viewport,be===0&&(e.setRenderTargetTextures(b,lt.colorTexture,lt.depthStencilTexture),e.setRenderTarget(b))}let ke=F[be];ke===void 0&&(ke=new Bt,ke.layers.enable(be),ke.viewport=new dt,F[be]=ke),ke.matrix.fromArray($e.transform.matrix),ke.matrix.decompose(ke.position,ke.quaternion,ke.scale),ke.projectionMatrix.fromArray($e.projectionMatrix),ke.projectionMatrixInverse.copy(ke.projectionMatrix).invert(),ke.viewport.set(it.x,it.y,it.width,it.height),be===0&&(H.matrix.copy(ke.matrix),H.matrix.decompose(H.position,H.quaternion,H.scale)),Re===!0&&H.cameras.push(ke)}let fe=s.enabledFeatures;if(fe&&fe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&y){d=n.getBinding();let be=d.getDepthInformation(ye[0]);be&&be.isValid&&be.texture&&p.init(be,s.renderState)}if(fe&&fe.includes("camera-access")&&y){e.state.unbindTexture(),d=n.getBinding();for(let be=0;be<ye.length;be++){let $e=ye[be].camera;if($e){let it=f[$e];it||(it=new As,f[$e]=it);let ke=d.getCameraImage($e);it.sourceTexture=ke}}}}for(let ye=0;ye<T.length;ye++){let Re=E[ye],fe=T[ye];Re!==null&&fe!==void 0&&fe.update(Re,pe,l||a)}ae&&ae(j,pe),pe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:pe}),_=null}let De=new zh;De.setAnimationLoop(_e),this.setAnimationLoop=function(j){ae=j},this.dispose=function(){}}},l_=new ht,$h=new Oe;$h.set(-1,0,0,0,1,0,0,0,1);function c_(i,e){function t(p,f){p.matrixAutoUpdate===!0&&p.updateMatrix(),f.value.copy(p.matrix)}function n(p,f){f.color.getRGB(p.fogColor.value,gl(i)),f.isFog?(p.fogNear.value=f.near,p.fogFar.value=f.far):f.isFogExp2&&(p.fogDensity.value=f.density)}function s(p,f,S,A,b){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(p,f):f.isMeshLambertMaterial?(r(p,f),f.envMap&&(p.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(p,f),d(p,f)):f.isMeshPhongMaterial?(r(p,f),h(p,f),f.envMap&&(p.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(p,f),u(p,f),f.isMeshPhysicalMaterial&&m(p,f,b)):f.isMeshMatcapMaterial?(r(p,f),_(p,f)):f.isMeshDepthMaterial?r(p,f):f.isMeshDistanceMaterial?(r(p,f),y(p,f)):f.isMeshNormalMaterial?r(p,f):f.isLineBasicMaterial?(a(p,f),f.isLineDashedMaterial&&o(p,f)):f.isPointsMaterial?c(p,f,S,A):f.isSpriteMaterial?l(p,f):f.isShadowMaterial?(p.color.value.copy(f.color),p.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(p,f){p.opacity.value=f.opacity,f.color&&p.diffuse.value.copy(f.color),f.emissive&&p.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(p.map.value=f.map,t(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,t(f.alphaMap,p.alphaMapTransform)),f.bumpMap&&(p.bumpMap.value=f.bumpMap,t(f.bumpMap,p.bumpMapTransform),p.bumpScale.value=f.bumpScale,f.side===Vt&&(p.bumpScale.value*=-1)),f.normalMap&&(p.normalMap.value=f.normalMap,t(f.normalMap,p.normalMapTransform),p.normalScale.value.copy(f.normalScale),f.side===Vt&&p.normalScale.value.negate()),f.displacementMap&&(p.displacementMap.value=f.displacementMap,t(f.displacementMap,p.displacementMapTransform),p.displacementScale.value=f.displacementScale,p.displacementBias.value=f.displacementBias),f.emissiveMap&&(p.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,p.emissiveMapTransform)),f.specularMap&&(p.specularMap.value=f.specularMap,t(f.specularMap,p.specularMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest);let S=e.get(f),A=S.envMap,b=S.envMapRotation;A&&(p.envMap.value=A,p.envMapRotation.value.setFromMatrix4(l_.makeRotationFromEuler(b)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply($h),p.reflectivity.value=f.reflectivity,p.ior.value=f.ior,p.refractionRatio.value=f.refractionRatio),f.lightMap&&(p.lightMap.value=f.lightMap,p.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,p.lightMapTransform)),f.aoMap&&(p.aoMap.value=f.aoMap,p.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,p.aoMapTransform))}function a(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,f.map&&(p.map.value=f.map,t(f.map,p.mapTransform))}function o(p,f){p.dashSize.value=f.dashSize,p.totalSize.value=f.dashSize+f.gapSize,p.scale.value=f.scale}function c(p,f,S,A){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.size.value=f.size*S,p.scale.value=A*.5,f.map&&(p.map.value=f.map,t(f.map,p.uvTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,t(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function l(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.rotation.value=f.rotation,f.map&&(p.map.value=f.map,t(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,t(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function h(p,f){p.specular.value.copy(f.specular),p.shininess.value=Math.max(f.shininess,1e-4)}function d(p,f){f.gradientMap&&(p.gradientMap.value=f.gradientMap)}function u(p,f){p.metalness.value=f.metalness,f.metalnessMap&&(p.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,p.metalnessMapTransform)),p.roughness.value=f.roughness,f.roughnessMap&&(p.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,p.roughnessMapTransform)),f.envMap&&(p.envMapIntensity.value=f.envMapIntensity)}function m(p,f,S){p.ior.value=f.ior,f.diffuseRoughness>0&&(p.diffuseRoughness.value=f.diffuseRoughness,f.diffuseRoughnessMap&&(p.diffuseRoughnessMap.value=f.diffuseRoughnessMap,t(f.diffuseRoughnessMap,p.diffuseRoughnessMapTransform))),f.sheen>0&&(p.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),p.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(p.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,p.sheenColorMapTransform)),f.sheenRoughnessMap&&(p.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,p.sheenRoughnessMapTransform))),f.clearcoat>0&&(p.clearcoat.value=f.clearcoat,p.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(p.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,p.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(p.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Vt&&p.clearcoatNormalScale.value.negate())),f.dispersion>0&&(p.dispersion.value=f.dispersion),f.retroreflectivity>0&&(p.retroreflectivity.value=f.retroreflectivity),f.iridescence>0&&(p.iridescence.value=f.iridescence,p.iridescenceIOR.value=f.iridescenceIOR,p.iridescenceThicknessMinimum.value=f.iridescenceThicknessMinimum,p.iridescenceThicknessMaximum.value=f.iridescenceThicknessMaximum,f.iridescenceMap&&(p.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,p.iridescenceMapTransform)),f.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),f.transmission>0&&(p.transmission.value=f.transmission,p.transmissionSamplerMap.value=S.texture,p.transmissionSamplerSize.value.set(S.width,S.height),f.transmissionMap&&(p.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,p.transmissionMapTransform)),p.thickness.value=f.thickness,f.thicknessMap&&(p.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=f.attenuationDistance,p.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(p.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(p.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=f.specularIntensity,p.specularColor.value.copy(f.specularColor),f.specularColorMap&&(p.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,p.specularColorMapTransform)),f.specularIntensityMap&&(p.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,p.specularIntensityMapTransform))}function _(p,f){f.matcap&&(p.matcap.value=f.matcap)}function y(p,f){let S=e.get(f).light;p.referencePosition.value.setFromMatrixPosition(S.matrixWorld),p.nearDistance.value=S.shadow.camera.near,p.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function h_(i,e,t,n){let s={},r={};function a(S,A){let b=A.program;n.uniformBlockBinding(S,b,s[S.id])}function o(S,A){let b=s[S.id];b===void 0&&(_(S),b=c(S),s[S.id]=b,S.addEventListener("dispose",p));let T=A.program;n.updateUBOMapping(S,T);let E=e.render.frame;r[S.id]!==E&&(l(S),r[S.id]=E)}function c(S){let A=i.createBuffer(),b=S.__size,T=S.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,b,T),i.bindBuffer(i.UNIFORM_BUFFER,null),A}function l(S){let A=s[S.id],b=S.uniforms,T=S.__cache;i.bindBuffer(i.UNIFORM_BUFFER,A);for(let E=0,g=b.length;E<g;E++){let M=b[E];if(Array.isArray(M))for(let U=0,I=M.length;U<I;U++)h(M[U],E,U,T);else h(M,E,0,T)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function h(S,A,b,T){if(u(S,A,b,T)===!0){let E=S.__offset,g=S.value;if(Array.isArray(g)){let M=0;for(let U=0;U<g.length;U++){let I=g[U],D=y(I,!0);d(I,S.__data,M),M+=D.storage/Float32Array.BYTES_PER_ELEMENT}}else d(g,S.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,E,S.__data)}}function d(S,A,b){typeof S=="number"||typeof S=="boolean"?A[b]=S:S.isMatrix3?(A[b]=S.elements[0],A[b+1]=S.elements[1],A[b+2]=S.elements[2],A[b+3]=0,A[b+4]=S.elements[3],A[b+5]=S.elements[4],A[b+6]=S.elements[5],A[b+7]=0,A[b+8]=S.elements[6],A[b+9]=S.elements[7],A[b+10]=S.elements[8],A[b+11]=0):ArrayBuffer.isView(S)?A.set(S.subarray(0,A.length-b),b):S.toArray(A,b)}function u(S,A,b,T){let E=S.value,g=A+"_"+b;if(Array.isArray(E)){T[g]===void 0&&(T[g]=[]);let M=T[g],U=!1;for(let I=0;I<E.length;I++)m(E[I],M,I)===!0&&(U=!0);return U}return m(E,T,g)}function m(S,A,b){if(A[b]===void 0)return typeof S=="number"||typeof S=="boolean"?A[b]=S:ArrayBuffer.isView(S)?A[b]=S.slice():A[b]=S.clone(),!0;{let T=A[b];if(typeof S=="number"||typeof S=="boolean"){if(T!==S)return A[b]=S,!0}else{if(ArrayBuffer.isView(S))return!0;if(T.equals(S)===!1)return T.copy(S),!0}}return!1}function _(S){let A=S.uniforms,b=0,T=16;for(let g=0,M=A.length;g<M;g++){let U=Array.isArray(A[g])?A[g]:[A[g]];for(let I=0,D=U.length;I<D;I++){let F=U[I],H=Array.isArray(F.value)?F.value:[F.value],C=Array.isArray(A[g])||Array.isArray(F.value),Y=b;for(let z=0,te=H.length;z<te;z++){let W=H[z],$=y(W,C),ae=b%T,_e=ae%$.boundary,De=ae+_e;b+=_e,De!==0&&T-De<$.storage&&(b+=T-De),z===0&&(Y=b),b+=$.storage}let J=F.type==="int"?Int32Array:F.type==="uint"?Uint32Array:Float32Array;F.__data=new J((b-Y)/Float32Array.BYTES_PER_ELEMENT),F.__offset=Y}}let E=b%T;return E>0&&(b+=T-E),S.__size=b,S.__cache={},this}function y(S,A){let b={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(b.boundary=4,b.storage=4):S.isVector2?(b.boundary=8,b.storage=8):S.isVector3||S.isColor?(b.boundary=16,b.storage=12):S.isVector4?(b.boundary=16,b.storage=16):S.isMatrix3?(b.boundary=16,b.storage=48):S.isMatrix4?(b.boundary=16,b.storage=64):S.isTexture?Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(S)?(b.boundary=16,b.storage=S.byteLength):Ie("WebGLRenderer: Unsupported uniform value type.",S),A===!0&&(b.boundary=16,b.storage=Math.ceil(b.storage/16)*16),b}function p(S){let A=S.target;A.removeEventListener("dispose",p),i.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function f(){for(let S in s)i.deleteBuffer(s[S]);s={},r={}}return{bind:a,update:o,dispose:f}}var u_=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]),Sn=null;function d_(){return Sn===null&&(Sn=new Hr(u_,16,16,si,mn),Sn.name="DFG_LUT",Sn.minFilter=kt,Sn.magFilter=kt,Sn.wrapS=yn,Sn.wrapT=yn,Sn.generateMipmaps=!1,Sn.needsUpdate=!0),Sn}var eo=class{constructor(e={}){let{canvas:t=lh(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:m=Xt}=e;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=a;let y=m,p=new Set([ya,xa,_a]),f=new Set([Xt,fn,ns,bi,ma,ga]),S=new Uint32Array(4),A=new Int32Array(4),b={textures:[],min:[],max:[],resolution:[]},T=null,E=null,g=[],M=[],U=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=bn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let I=this,D=!1,F=null,H=null,C=null,Y=null;this._outputColorSpace=Jt;let J=0,z=0,te=null,W=-1,$=null,ae=new dt,_e=new dt,De=null,j=new ze(0),pe=0,ye=t.width,Re=t.height,fe=1,Le=null,pt=null,be=new dt(0,0,ye,Re),$e=new dt(0,0,ye,Re),it=!1,ke=new Kn,lt=new Wr,Ge=!1,mt=!1,at=new ht,nn=new B,gt=new dt,Ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Tt=!1;function Pt(){return te===null?fe:1}let N=n;function At(v,L){return t.getContext(v,L)}let Qe,st,ue,ut,Te,Ce,w,x,k,oe,ee,le,ce,K,P,Q,R,X,O,q,ne,se,xe;try{let v={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",ve,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",ie,!1),N===null){let L="webgl2";if(N=At(L,v),N===null)throw At(L)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Pe()}catch(v){throw t.removeEventListener("webglcontextlost",ve,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",ie,!1),Ue("WebGLRenderer: "+v.message),v}function Pe(){Qe=new Sm(N),Qe.init(),ne=new r_(N,Qe),st=new dm(N,Qe,e,ne),ue=new i_(N,Qe),st.reversedDepthBuffer&&u&&ue.buffers.depth.setReversed(!0),H=N.createFramebuffer(),C=N.createFramebuffer(),Y=N.createFramebuffer(),ut=new Tm(N),Te=new Hg,Ce=new s_(N,Qe,ue,Te,st,ne,ut),w=new bm(I),x=new Ad(N),se=new hm(N,x),k=new Em(N,x,ut,se),oe=new Rm(N,k,x,se,ut),X=new Am(N,st,Ce),P=new fm(Te),ee=new Gg(I,w,Qe,st,se,P),le=new c_(I,Te),ce=new Xg,K=new Kg(Qe),R=new cm(I,w,ue,oe,_,c),Q=new n_(I,oe,st),xe=new h_(N,ut,st,ue),O=new um(N,Qe,ut),q=new wm(N,Qe,ut),ut.programs=ee.programs,I.capabilities=st,I.extensions=Qe,I.properties=Te,I.renderLists=ce,I.shadowMap=Q,I.state=ue,I.info=ut}y!==Xt&&(U=new Pm(y,t.width,t.height,o,s,r));let re=new Nl(I,N);this.xr=re,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let v=Qe.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){let v=Qe.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return fe},this.setPixelRatio=function(v){v!==void 0&&(fe=v,this.setSize(ye,Re,!1))},this.getSize=function(v){return v.set(ye,Re)},this.setSize=function(v,L,Z=!0){if(re.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}ye=v,Re=L,t.width=Math.floor(v*fe),t.height=Math.floor(L*fe),Z===!0&&(t.style.width=v+"px",t.style.height=L+"px"),U!==null&&U.setSize(t.width,t.height),this.setViewport(0,0,v,L)},this.getDrawingBufferSize=function(v){return v.set(ye*fe,Re*fe).floor()},this.setDrawingBufferSize=function(v,L,Z){ye=v,Re=L,fe=Z,t.width=Math.floor(v*Z),t.height=Math.floor(L*Z),this.setViewport(0,0,v,L)},this.setEffects=function(v){if(y===Xt){Ue("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(v){for(let L=0;L<v.length;L++)if(v[L].isOutputPass===!0){Ie("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}U.setEffects(v||[])},this.getCurrentViewport=function(v){return v.copy(ae)},this.getViewport=function(v){return v.copy(be)},this.setViewport=function(v,L,Z,V){v.isVector4?be.set(v.x,v.y,v.z,v.w):be.set(v,L,Z,V),ue.viewport(ae.copy(be).multiplyScalar(Pt()).round())},this.getScissor=function(v){return v.copy($e)},this.setScissor=function(v,L,Z,V){v.isVector4?$e.set(v.x,v.y,v.z,v.w):$e.set(v,L,Z,V),ue.scissor(_e.copy($e).multiplyScalar(Pt()).round())},this.getScissorTest=function(){return it},this.setScissorTest=function(v){ue.setScissorTest(it=v)},this.setOpaqueSort=function(v){Le=v},this.setTransparentSort=function(v){pt=v},this.getClearColor=function(v){return v.copy(R.getClearColor())},this.setClearColor=function(){R.setClearColor(...arguments)},this.getClearAlpha=function(){return R.getClearAlpha()},this.setClearAlpha=function(){R.setClearAlpha(...arguments)},this.clear=function(v=!0,L=!0,Z=!0){let V=0;if(v){let G=!1;if(te!==null){let de=te.texture.format;G=p.has(de)}if(G){let de=te.texture.type,Me=f.has(de),he=R.getClearColor(),ge=R.getClearAlpha(),we=he.r,Be=he.g,qe=he.b;Me?(S[0]=we,S[1]=Be,S[2]=qe,S[3]=ge,N.clearBufferuiv(N.COLOR,0,S)):(A[0]=we,A[1]=Be,A[2]=qe,A[3]=ge,N.clearBufferiv(N.COLOR,0,A))}else V|=N.COLOR_BUFFER_BIT}L&&(V|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Z&&(V|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),V!==0&&N.clear(V)},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(v){v.setRenderer(this),F=v},this.dispose=function(){t.removeEventListener("webglcontextlost",ve,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",ie,!1),R.dispose(),ce.dispose(),K.dispose(),Ce.dispose(),Te.dispose(),w.dispose(),oe.dispose(),k.dispose(),se.dispose(),xe.dispose(),ee.dispose(),re.dispose(),re.removeEventListener("sessionstart",sn),re.removeEventListener("sessionend",Tn),rn.stop()};function ve(v){v.preventDefault(),ul("WebGLRenderer: Context Lost."),D=!0}function Ae(){ul("WebGLRenderer: Context Restored."),D=!1;let v=ut.autoReset,L=Q.enabled,Z=Q.autoUpdate,V=Q.needsUpdate,G=Q.type;Pe(),ut.autoReset=v,Q.enabled=L,Q.autoUpdate=Z,Q.needsUpdate=V,Q.type=G}function ie(v){Ue("WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function Ne(v){let L=v.target;L.removeEventListener("dispose",Ne),Je(L)}function Je(v){Xe(v),Te.remove(v)}function Xe(v){let L=Te.get(v).programs;L!==void 0&&(L.forEach(function(Z){ee.releaseProgram(Z)}),v.isShaderMaterial&&ee.releaseShaderCache(v))}this.renderBufferDirect=function(v,L,Z,V,G,de){L===null&&(L=Ft);let Me=G.isMesh&&G.matrixWorld.determinantAffine()<0,he=Ru(v,L,Z,V,G);ue.setMaterial(V,Me);let ge=Z.index,we=1;if(V.wireframe===!0){if(ge=k.getWireframeAttribute(Z),ge===void 0)return;we=2}let Be=Z.drawRange,qe=Z.attributes.position,Se=Be.start*we,Ye=(Be.start+Be.count)*we;de!==null&&(Se=Math.max(Se,de.start*we),Ye=Math.min(Ye,(de.start+de.count)*we)),ge!==null?(Se=Math.max(Se,0),Ye=Math.min(Ye,ge.count)):qe!=null&&(Se=Math.max(Se,0),Ye=Math.min(Ye,qe.count));let _t=Ye-Se;if(_t<0||_t===1/0)return;se.setup(G,V,he,Z,ge);let ot,rt=O;if(ge!==null&&(ot=x.get(ge),rt=q,rt.setIndex(ot)),G.isMesh)V.wireframe===!0?(ue.setLineWidth(V.wireframeLinewidth*Pt()),rt.setMode(N.LINES)):rt.setMode(N.TRIANGLES);else if(G.isLine){let It=V.linewidth;It===void 0&&(It=1),ue.setLineWidth(It*Pt()),G.isLineSegments?rt.setMode(N.LINES):G.isLineLoop?rt.setMode(N.LINE_LOOP):rt.setMode(N.LINE_STRIP)}else G.isPoints?rt.setMode(N.POINTS):G.isSprite&&rt.setMode(N.TRIANGLES);if(G.isBatchedMesh)if(Qe.get("WEBGL_multi_draw"))rt.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{let It=G._multiDrawStarts,Ee=G._multiDrawCounts,Ot=G._multiDrawCount,et=ge?x.get(ge).bytesPerElement:1,ci=Te.get(V).currentProgram.getUniforms();for(let Lt=0;Lt<Ot;Lt++)ci.setValue(N,"_gl_DrawID",Lt),rt.render(It[Lt]/et,Ee[Lt])}else if(G.isInstancedMesh)rt.renderInstances(Se,_t,G.count);else if(Z.isInstancedBufferGeometry){let It=Z._maxInstanceCount!==void 0?Z._maxInstanceCount:1/0,Ee=Math.min(Z.instanceCount,It);rt.renderInstances(Se,_t,Ee)}else rt.render(Se,_t)};function Yt(v,L,Z,V){F!==null&&v.isNodeMaterial&&F.setObject(V,v),Ge===!0&&P.setState(v,Z,!1),v.transparent===!0&&v.side===Mn&&v.forceSinglePass===!1?(v.side=Vt,v.needsUpdate=!0,ls(v,L,V),v.side=ii,v.needsUpdate=!0,ls(v,L,V),v.side=Mn):ls(v,L,V)}this.compile=function(v,L,Z=null){Z===null&&(Z=v),F!==null&&F.renderStart(v,L,Z),E=K.get(Z),E.init(L),M.push(E),Z.traverseVisible(function(G){G.isLight&&G.layers.test(L.layers)&&(E.pushLight(G),G.castShadow&&E.pushShadow(G))}),v!==Z&&v.traverseVisible(function(G){G.isLight&&G.layers.test(L.layers)&&(E.pushLight(G),G.castShadow&&E.pushShadow(G))}),E.setupLights(),F!==null&&F.updateLights(E.state.lightsArray),mt=this.localClippingEnabled,Ge=P.init(this.clippingPlanes,mt),Ge===!0&&P.setGlobalState(this.clippingPlanes,L),F!==null&&Q.render(E.state.shadowsArray,Z,L);let V=new Set;return v.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let de=G.material;if(de)if(Array.isArray(de))for(let Me=0;Me<de.length;Me++){let he=de[Me];Yt(he,Z,L,G),V.add(he)}else Yt(de,Z,L,G),V.add(de)}),E=M.pop(),F!==null&&F.renderEnd(),V},this.compileAsync=function(v,L,Z=null){let V=this.compile(v,L,Z);return new Promise(G=>{function de(){if(V.forEach(function(Me){let ge=Te.get(Me).currentProgram;(ge===void 0||ge.isReady())&&V.delete(Me)}),V.size===0){G(v);return}setTimeout(de,10)}Qe.get("KHR_parallel_shader_compile")!==null?de():setTimeout(de,10)})};let Ve=null;function _n(v){Ve&&Ve(v)}function sn(){rn.stop()}function Tn(){rn.start()}let rn=new zh;rn.setAnimationLoop(_n),typeof self<"u"&&rn.setContext(self),this.setAnimationLoop=function(v){Ve=v,re.setAnimationLoop(v),v===null?rn.stop():rn.start()},re.addEventListener("sessionstart",sn),re.addEventListener("sessionend",Tn),this.render=function(v,L){if(L!==void 0&&L.isCamera!==!0){Ue("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;F!==null&&F.renderStart(v,L);let Z=re.enabled===!0&&re.isPresenting===!0,V=U!==null&&(te===null||Z)&&U.begin(I,te);if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),re.enabled===!0&&re.isPresenting===!0&&(U===null||U.isCompositing()===!1)&&(re.cameraAutoUpdate===!0&&re.updateCamera(L),L=re.getCamera()),v.isScene===!0&&v.onBeforeRender(I,v,L,te),E=K.get(v,M.length),E.init(L),E.state.textureUnits=Ce.getTextureUnits(),M.push(E),at.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),L.isArrayCamera?lt.setFromArrayCamera(L):ke.setFromProjectionMatrix(at,on,L.reversedDepth),mt=this.localClippingEnabled,Ge=P.init(this.clippingPlanes,mt),T=ce.get(v,g.length),T.init(),g.push(T),this.info.render.frame++,re.enabled===!0&&re.isPresenting===!0){let Me=I.xr.getDepthSensingMesh();Me!==null&&wi(Me,L,-1/0,I.sortObjects)}wi(v,L,0,I.sortObjects),T.finish(),F!==null&&F.updateLights(E.state.lightsArray),I.sortObjects===!0&&T.sort(Le,pt),Tt=re.enabled===!1||re.isPresenting===!1||re.hasDepthSensing()===!1,Tt&&R.addToRenderList(T,v),this.info.autoReset===!0&&this.info.reset(),Ge===!0&&P.beginShadows();let G=E.state.shadowsArray;if(Q.render(G,v,L),Ge===!0&&P.endShadows(),(V&&U.hasRenderPass())===!1){let Me=T.opaque,he=T.transmissive;if(E.setupLights(),L.isArrayCamera){let ge=L.cameras;if(he.length>0)for(let we=0,Be=ge.length;we<Be;we++){let qe=ge[we];os(Me,he,v,qe)}Tt&&R.render(v);for(let we=0,Be=ge.length;we<Be;we++){let qe=ge[we];as(T,v,qe,qe.viewport)}}else he.length>0&&os(Me,he,v,L),Tt&&R.render(v),as(T,v,L)}te!==null&&z===0&&(Ce.updateMultisampleRenderTarget(te),Ce.updateRenderTargetMipmap(te)),V&&U.end(I),v.isScene===!0&&v.onAfterRender(I,v,L),se.resetDefaultState(),W=-1,$=null,M.pop(),M.length>0?(E=M[M.length-1],Ce.setTextureUnits(E.state.textureUnits),Ge===!0&&P.setGlobalState(I.clippingPlanes,E.state.camera)):E=null,g.pop(),g.length>0?T=g[g.length-1]:T=null,F!==null&&F.renderEnd()};function wi(v,L,Z,V){if(v.visible===!1)return;if(v.layers.test(L.layers)){if(v.isGroup)Z=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(L);else if(v.isLight)E.pushLight(v),v.castShadow&&E.pushShadow(v);else if(v.isSprite){let Me=L.isArrayCamera?lt:ke;if(!v.frustumCulled||v.intersectsFrustum(Me)){V&&gt.setFromMatrixPosition(v.matrixWorld).applyMatrix4(at);let he=oe.update(v),ge=v.material;ge.visible&&T.push(v,he,ge,Z,gt.z,null,L)}}else if(v.isMesh||v.isLine||v.isPoints){let Me=L.isArrayCamera?lt:ke;if(!v.frustumCulled||v.intersectsFrustum(Me)){let he=oe.update(v),ge=v.material;if(V&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),gt.copy(v.boundingSphere.center)):(he.boundingSphere===null&&he.computeBoundingSphere(),gt.copy(he.boundingSphere.center)),gt.applyMatrix4(v.matrixWorld).applyMatrix4(at)),Array.isArray(ge)){let we=he.groups;for(let Be=0,qe=we.length;Be<qe;Be++){let Se=we[Be],Ye=ge[Se.materialIndex];Ye&&Ye.visible&&T.push(v,he,Ye,Z,gt.z,Se,L)}}else ge.visible&&T.push(v,he,ge,Z,gt.z,null,L)}}}let de=v.children;for(let Me=0,he=de.length;Me<he;Me++)wi(de[Me],L,Z,V)}function as(v,L,Z,V){let{opaque:G,transmissive:de,transparent:Me}=v;E.setupLightsView(Z),Ge===!0&&P.setGlobalState(I.clippingPlanes,Z),V&&ue.viewport(ae.copy(V)),G.length>0&&li(G,L,Z),de.length>0&&li(de,L,Z),Me.length>0&&li(Me,L,Z),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function os(v,L,Z,V){if((Z.isScene===!0?Z.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[V.id]===void 0){let Se=Qe.has("EXT_color_buffer_half_float")||Qe.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[V.id]=new Qt(1,1,{generateMipmaps:!0,type:Se?mn:Xt,minFilter:kn,samples:Math.max(4,st.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Ze.workingColorSpace})}let de=E.state.transmissionRenderTarget[V.id],Me=V.viewport||ae;de.setSize(Me.z*I.transmissionResolutionScale,Me.w*I.transmissionResolutionScale);let he=I.getRenderTarget(),ge=I.getActiveCubeFace(),we=I.getActiveMipmapLevel();I.setRenderTarget(de),I.getClearColor(j),pe=I.getClearAlpha(),pe<1&&I.setClearColor(16777215,.5),I.clear(),Tt&&R.render(Z);let Be=I.toneMapping;I.toneMapping=bn;let qe=V.viewport;if(V.viewport!==void 0&&(V.viewport=void 0),E.setupLightsView(V),Ge===!0&&P.setGlobalState(I.clippingPlanes,V),li(v,Z,V),Ce.updateMultisampleRenderTarget(de),Ce.updateRenderTargetMipmap(de),Qe.has("WEBGL_multisampled_render_to_texture")===!1){let Se=!1;for(let Ye=0,_t=L.length;Ye<_t;Ye++){let ot=L[Ye],{object:rt,geometry:It,material:Ee,group:Ot}=ot;if(Ee.side===Mn&&rt.layers.test(V.layers)){let et=Ee.side;Ee.side=Vt,Ee.needsUpdate=!0,$l(rt,Z,V,It,Ee,Ot),Ee.side=et,Ee.needsUpdate=!0,Se=!0}}Se===!0&&(Ce.updateMultisampleRenderTarget(de),Ce.updateRenderTargetMipmap(de))}I.setRenderTarget(he,ge,we),I.setClearColor(j,pe),qe!==void 0&&(V.viewport=qe),I.toneMapping=Be}function li(v,L,Z){let V=L.isScene===!0?L.overrideMaterial:null;for(let G=0,de=v.length;G<de;G++){let Me=v[G],{object:he,geometry:ge,group:we}=Me,Be=Me.material;Be.allowOverride===!0&&V!==null&&(Be=V),he.layers.test(Z.layers)&&$l(he,L,Z,ge,Be,we)}}function $l(v,L,Z,V,G,de){F!==null&&G.isNodeMaterial&&F.setObject(v,G),v.onBeforeRender(I,L,Z,V,G,de),v.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),G.onBeforeRender(I,L,Z,V,v,de),G.transparent===!0&&G.side===Mn&&G.forceSinglePass===!1?(G.side=Vt,G.needsUpdate=!0,I.renderBufferDirect(Z,L,V,G,v,de),G.side=ii,G.needsUpdate=!0,I.renderBufferDirect(Z,L,V,G,v,de),G.side=Mn):I.renderBufferDirect(Z,L,V,G,v,de),v.onAfterRender(I,L,Z,V,G,de)}function Jl(v){let L=0;for(let Z of v)Z.texture!==null&&L++;return L}function ls(v,L,Z){L.isScene!==!0&&(L=Ft);let V=Te.get(v),G=E.state.lights,de=E.state.shadowsArray,Me=G.state.version,he=ee.getParameters(v,G.state,de,L,Z,E.state.lightProbeGridArray),ge=ee.getProgramCacheKey(he),we=V.programs;V.environment=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,V.fog=L.fog;let Be=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap;V.envMap=w.get(v.envMap||V.environment,Be),V.envMapRotation=V.environment!==null&&v.envMap===null?L.environmentRotation:v.envMapRotation,we===void 0&&(v.addEventListener("dispose",Ne),we=new Map,V.programs=we,V.programVariants=new Map);let qe=we.get(ge);if(qe!==void 0){if(V.currentProgram===qe&&V.lightsStateVersion===Me)return jl(v,he),qe}else he.uniforms=ee.getUniforms(v),F!==null&&v.isNodeMaterial&&F.build(v,Z,he),v.onBeforeCompile(he,I),qe=ee.acquireProgram(he,ge),we.set(ge,qe),V.uniforms=he.uniforms;let Se=V.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(Se.clippingPlanes=P.uniform),jl(v,he),V.needsLights=Pu(v),V.lightsStateVersion=Me,V.needsLights&&(Se.ambientLightColor.value=G.state.ambient,Se.lightProbe.value=G.state.probe,Se.sunLights.value=G.state.sun,Se.sunLightShadows.value=G.state.sunShadow,Se.directionalLights.value=G.state.directional,Se.directionalLightShadows.value=G.state.directionalShadow,Se.spotLights.value=G.state.spot,Se.spotLightShadows.value=G.state.spotShadow,Se.rectAreaLights.value=G.state.rectArea,Se.ltc_1.value=G.state.rectAreaLTC1,Se.ltc_2.value=G.state.rectAreaLTC2,Se.pointLights.value=G.state.point,Se.pointLightShadows.value=G.state.pointShadow,Se.hemisphereLights.value=G.state.hemi,Se.sunShadowMatrix.value=G.state.sunShadowMatrix,Se.sunShadowCascade.value=G.state.sunShadowCascade,Se.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Se.spotLightMatrix.value=G.state.spotLightMatrix,Se.spotLightMap.value=G.state.spotLightMap,Se.pointShadowMatrix.value=G.state.pointShadowMatrix),V.numLightProbeGrids=Jl(E.state.lightProbeGridArray),V.currentProgram=qe,V.uniformsList=null,qe}function Au(v,L,Z,V,G){let de=Te.get(v),Me=de.currentProgram.id+","+V+","+G,he=de.programVariants.get(Me);return he===void 0?(he=ls(v,L,Z),de.programVariants.set(Me,he)):(de.currentProgram=he,de.uniformsList=null,de.outputColorSpace=V,de.toneMapping=G),he}function Kl(v){if(v.uniformsList===null){let L=v.currentProgram.getUniforms();v.uniformsList=ss.seqWithValue(L.seq,v.uniforms)}return v.uniformsList}function jl(v,L){let Z=Te.get(v);Z.outputColorSpace=L.outputColorSpace,Z.batching=L.batching,Z.batchingColor=L.batchingColor,Z.instancing=L.instancing,Z.instancingColor=L.instancingColor,Z.instancingMorph=L.instancingMorph,Z.skinning=L.skinning,Z.morphTargets=L.morphTargets,Z.morphNormals=L.morphNormals,Z.morphColors=L.morphColors,Z.morphTargetsCount=L.morphTargetsCount,Z.numClippingPlanes=L.numClippingPlanes,Z.numIntersection=L.numClipIntersection,Z.vertexAlphas=L.vertexAlphas,Z.vertexTangents=L.vertexTangents,Z.toneMapping=L.toneMapping}function Ru(v,L,Z,V,G){L.isScene!==!0&&(L=Ft),Ce.resetTextureUnits();let de=L.fog,Me=V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial?L.environment:null,he=te===null?I.outputColorSpace:te.isXRRenderTarget===!0?te.texture.colorSpace:Ze.workingColorSpace,ge=V.isMeshStandardMaterial||V.isMeshLambertMaterial&&!V.envMap||V.isMeshPhongMaterial&&!V.envMap,we=w.get(V.envMap||Me,ge),Be=V.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,qe=!!Z.attributes.tangent&&(!!V.normalMap||V.anisotropy>0),Se=!!Z.morphAttributes.position,Ye=!!Z.morphAttributes.normal,_t=!!Z.morphAttributes.color,ot=bn;V.toneMapped&&(te===null||te.isXRRenderTarget===!0)&&(ot=I.toneMapping);let rt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,It=rt!==void 0?rt.length:0,Ee=Te.get(V),Ot=E.state.lights;if(Ge===!0&&(mt===!0||v!==$)){let ft=v===$&&V.id===W;P.setState(V,v,ft)}let et=!1,ci=!1;V.version===Ee.__version?Ee.needsLights&&Ee.lightsStateVersion!==Ot.state.version||G.isBatchedMesh&&Ee.batching===!1||!G.isBatchedMesh&&Ee.batching===!0||G.isBatchedMesh&&Ee.batchingColor===!0&&G._colorsTexture===null||G.isBatchedMesh&&Ee.batchingColor===!1&&G._colorsTexture!==null||G.isInstancedMesh&&Ee.instancing===!1||!G.isInstancedMesh&&Ee.instancing===!0||G.isSkinnedMesh&&Ee.skinning===!1||!G.isSkinnedMesh&&Ee.skinning===!0||G.isInstancedMesh&&Ee.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Ee.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Ee.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Ee.instancingMorph===!1&&G.morphTexture!==null||Ee.envMap!==we||V.fog===!0&&Ee.fog!==de||Ee.numClippingPlanes!==void 0&&(Ee.numClippingPlanes!==P.numPlanes||Ee.numIntersection!==P.numIntersection)||Ee.vertexAlphas!==Be||Ee.vertexTangents!==qe||Ee.morphTargets!==Se||Ee.morphNormals!==Ye||Ee.morphColors!==_t||Ee.morphTargetsCount!==It||Ee.numLightProbeGrids!==Jl(E.state.lightProbeGridArray)?et=!0:(Ee.outputColorSpace!==he||Ee.toneMapping!==ot)&&(ci=!0):(et=!0,Ee.__version=V.version);let Lt=Ee.currentProgram;(et===!0||ci===!0)&&(Lt=ci===!0?Au(V,L,G,he,ot):ls(V,L,G),F&&V.isNodeMaterial&&F.onUpdateProgram(V,Lt,Ee));let tr=!1,Wn=!1,hi=!1,je=Lt.getUniforms(),Rt=Ee.uniforms;if(ue.useProgram(Lt.program)&&(tr=!0,Wn=!0,hi=!0),V.id!==W&&(W=V.id,Wn=!0),tr||$!==v){ue.buffers.depth.getReversed()&&v.reversedDepth!==!0&&(v._reversedDepth=!0,v.updateProjectionMatrix()),je.setValue(N,"projectionMatrix",v.projectionMatrix),je.setValue(N,"viewMatrix",v.matrixWorldInverse);let St=je.map.cameraPosition;St!==void 0&&St.setValue(N,nn.setFromMatrixPosition(v.matrixWorld)),st.logarithmicDepthBuffer&&je.setValue(N,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(V.isMeshPhongMaterial||V.isMeshToonMaterial||V.isMeshLambertMaterial||V.isMeshBasicMaterial||V.isMeshStandardMaterial||V.isShaderMaterial)&&je.setValue(N,"isOrthographic",v.isOrthographicCamera===!0),$!==v&&($=v,Wn=!0,hi=!0)}if(Ee.needsLights&&(Ot.state.sunShadowMap.length>0&&je.setValue(N,"sunShadowMap",Ot.state.sunShadowMap,Ce),Ot.state.directionalShadowMap.length>0&&je.setValue(N,"directionalShadowMap",Ot.state.directionalShadowMap,Ce),Ot.state.spotShadowMap.length>0&&je.setValue(N,"spotShadowMap",Ot.state.spotShadowMap,Ce),Ot.state.pointShadowMap.length>0&&je.setValue(N,"pointShadowMap",Ot.state.pointShadowMap,Ce)),G.isSkinnedMesh){je.setOptional(N,G,"bindMatrix"),je.setOptional(N,G,"bindMatrixInverse");let ft=G.skeleton;ft&&(ft.boneTexture===null&&ft.computeBoneTexture(),je.setValue(N,"boneTexture",ft.boneTexture,Ce))}G.isBatchedMesh&&(je.setOptional(N,G,"batchingTexture"),je.setValue(N,"batchingTexture",G._matricesTexture,Ce),je.setOptional(N,G,"batchingIdTexture"),je.setValue(N,"batchingIdTexture",G._indirectTexture,Ce),je.setOptional(N,G,"batchingColorTexture"),G._colorsTexture!==null&&je.setValue(N,"batchingColorTexture",G._colorsTexture,Ce));let ln=Z.morphAttributes;if((ln.position!==void 0||ln.normal!==void 0||ln.color!==void 0)&&X.update(G,Z,Lt),(Wn||Ee.receiveShadow!==G.receiveShadow)&&(Ee.receiveShadow=G.receiveShadow,je.setValue(N,"receiveShadow",G.receiveShadow)),(V.isMeshStandardMaterial||V.isMeshLambertMaterial||V.isMeshPhongMaterial)&&V.envMap===null&&L.environment!==null&&(Rt.envMapIntensity.value=L.environmentIntensity),Rt.dfgLUT!==void 0&&(Rt.dfgLUT.value=d_()),Wn){if(je.setValue(N,"toneMappingExposure",I.toneMappingExposure),Ee.needsLights&&Cu(Rt,hi),de&&V.fog===!0&&le.refreshFogUniforms(Rt,de),le.refreshMaterialUniforms(Rt,V,fe,Re,E.state.transmissionRenderTarget[v.id]),Ee.needsLights&&Ee.numLightProbeGrids>0){let ft=b,St=0;for(let An of E.state.lightProbeGridArray)An.texture!==null&&(ft.textures[St]=An.texture,ft.min[St]=An.boundingBox.min,ft.max[St]=An.boundingBox.max,ft.resolution[St]=An.resolution,St++);for(let An in ft)ft[An].length=St;Rt.probesSH.value=ft.textures,Rt.probesMin.value=ft.min,Rt.probesMax.value=ft.max,Rt.probesResolution.value=ft.resolution}ss.upload(N,Kl(Ee),Rt,Ce)}if(V.isShaderMaterial&&V.uniformsNeedUpdate===!0&&(ss.upload(N,Kl(Ee),Rt,Ce),V.uniformsNeedUpdate=!1),V.isSpriteMaterial&&je.setValue(N,"center",G.center),je.setValue(N,"modelViewMatrix",G.modelViewMatrix),je.setValue(N,"normalMatrix",G.normalMatrix),je.setValue(N,"modelMatrix",G.matrixWorld),V.uniformsGroups!==void 0){let ft=V.uniformsGroups;for(let St=0,An=ft.length;St<An;St++){let ec=ft[St];xe.update(ec,Lt),xe.bind(ec,Lt)}}return Lt}function Cu(v,L){v.ambientLightColor.needsUpdate=L,v.lightProbe.needsUpdate=L,v.sunLights.needsUpdate=L,v.sunLightShadows.needsUpdate=L,v.directionalLights.needsUpdate=L,v.directionalLightShadows.needsUpdate=L,v.pointLights.needsUpdate=L,v.pointLightShadows.needsUpdate=L,v.spotLights.needsUpdate=L,v.spotLightShadows.needsUpdate=L,v.rectAreaLights.needsUpdate=L,v.hemisphereLights.needsUpdate=L}function Pu(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return J},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return te},this.setRenderTargetTextures=function(v,L,Z){let V=Te.get(v);V.__autoAllocateDepthBuffer=v.resolveDepthBuffer===!1,V.__autoAllocateDepthBuffer===!1&&(V.__useRenderToTexture=!1),Te.get(v.texture).__webglTexture=L,Te.get(v.depthTexture).__webglTexture=V.__autoAllocateDepthBuffer?void 0:Z,V.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(v,L){let Z=Te.get(v);Z.__webglFramebuffer=L,Z.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(v,L=0,Z=0){te=v,J=L,z=Z;let V=null,G=!1,de=!1;if(v){let he=Te.get(v);if(he.__useDefaultFramebuffer!==void 0){ue.bindFramebuffer(N.FRAMEBUFFER,he.__webglFramebuffer),ae.copy(v.viewport),_e.copy(v.scissor),De=v.scissorTest,ue.viewport(ae),ue.scissor(_e),ue.setScissorTest(De),W=-1;return}else if(he.__webglFramebuffer===void 0)Ce.setupRenderTarget(v);else if(he.__hasExternalTextures)Ce.rebindTextures(v,Te.get(v.texture).__webglTexture,Te.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){let Be=v.depthTexture;if(he.__boundDepthTexture!==Be){if(Be!==null&&Te.has(Be)&&(v.width!==Be.image.width||v.height!==Be.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Ce.setupDepthRenderbuffer(v)}}let ge=v.texture;(ge.isData3DTexture||ge.isDataArrayTexture||ge.isCompressedArrayTexture)&&(de=!0);let we=Te.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(we[L])?V=we[L][Z]:V=we[L],G=!0):v.samples>0&&Ce.useMultisampledRTT(v)===!1?V=Te.get(v).__webglMultisampledFramebuffer:Array.isArray(we)?V=we[Z]:V=we,ae.copy(v.viewport),_e.copy(v.scissor),De=v.scissorTest}else ae.copy(be).multiplyScalar(fe).floor(),_e.copy($e).multiplyScalar(fe).floor(),De=it;if(Z!==0&&(V=H),ue.bindFramebuffer(N.FRAMEBUFFER,V)&&ue.drawBuffers(v,V),ue.viewport(ae),ue.scissor(_e),ue.setScissorTest(De),G){let he=Te.get(v.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+L,he.__webglTexture,Z)}else if(de){let he=L;for(let ge=0;ge<v.textures.length;ge++){let we=Te.get(v.textures[ge]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+ge,we.__webglTexture,Z,he)}}else if(v!==null&&Z!==0){let he=Te.get(v.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,he.__webglTexture,Z)}W=-1};function Ql(v){let L=Te.get(v);return(L.__readFormat!==v.format||L.__readType!==v.type)&&(L.__readFormat=v.format,L.__readType=v.type,L.__formatReadable=st.textureFormatReadable(v.format),L.__typeReadable=st.textureTypeReadable(v.type)),L}this.readRenderTargetPixels=function(v,L,Z,V,G,de,Me,he=0){if(!(v&&v.isWebGLRenderTarget)){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ge=Te.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&Me!==void 0&&(ge=ge[Me],Array.isArray(ge)&&(ge=ge[0])),ge){ue.bindFramebuffer(N.FRAMEBUFFER,ge);try{let we=v.textures[he],Be=we.format,qe=we.type;v.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+he);let Se=Ql(we);if(Se.__formatReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Se.__typeReadable===!1){Ue("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=v.width-V&&Z>=0&&Z<=v.height-G&&N.readPixels(L,Z,V,G,ne.convert(Be),ne.convert(qe),de)}finally{let we=te!==null?Te.get(te).__webglFramebuffer:null;ue.bindFramebuffer(N.FRAMEBUFFER,we)}}},this.readRenderTargetPixelsAsync=async function(v,L,Z,V,G,de,Me,he=0){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ge=Te.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&Me!==void 0&&(ge=ge[Me],Array.isArray(ge)&&(ge=ge[0])),ge)if(L>=0&&L<=v.width-V&&Z>=0&&Z<=v.height-G){ue.bindFramebuffer(N.FRAMEBUFFER,ge);let we=v.textures[he],Be=we.format,qe=we.type;v.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+he);let Se=Ql(we);if(Se.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Se.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Ye=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ye),N.bufferData(N.PIXEL_PACK_BUFFER,de.byteLength,N.STREAM_READ),N.readPixels(L,Z,V,G,ne.convert(Be),ne.convert(qe),0),N.bindBuffer(N.PIXEL_PACK_BUFFER,null);let _t=te!==null?Te.get(te).__webglFramebuffer:null;ue.bindFramebuffer(N.FRAMEBUFFER,_t);let ot=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await hh(N,ot,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ye),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,de),N.bindBuffer(N.PIXEL_PACK_BUFFER,null),N.deleteBuffer(Ye),N.deleteSync(ot),de}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(v,L=null,Z=0){let V=Math.pow(2,-Z),G=Math.floor(v.image.width*V),de=Math.floor(v.image.height*V),Me=L!==null?L.x:0,he=L!==null?L.y:0;Ce.setTexture2D(v,0),N.copyTexSubImage2D(N.TEXTURE_2D,Z,0,0,Me,he,G,de),ue.unbindTexture()},this.copyTextureToTexture=function(v,L,Z=null,V=null,G=0,de=0){let Me,he,ge,we,Be,qe,Se,Ye,_t,ot=v.isCompressedTexture?v.mipmaps[de]:v.image;if(Z!==null)Me=Z.max.x-Z.min.x,he=Z.max.y-Z.min.y,ge=Z.isBox3?Z.max.z-Z.min.z:1,we=Z.min.x,Be=Z.min.y,qe=Z.isBox3?Z.min.z:0;else{let je=Math.pow(2,-G);Me=Math.floor(ot.width*je),he=Math.floor(ot.height*je),v.isDataArrayTexture?ge=ot.depth:v.isData3DTexture?ge=Math.floor(ot.depth*je):ge=1,we=0,Be=0,qe=0}V!==null?(Se=V.x,Ye=V.y,_t=V.z):(Se=0,Ye=0,_t=0);let rt=ne.convert(L.format),It=ne.convert(L.type),Ee;L.isData3DTexture?(Ce.setTexture3D(L,0),Ee=N.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(Ce.setTexture2DArray(L,0),Ee=N.TEXTURE_2D_ARRAY):(Ce.setTexture2D(L,0),Ee=N.TEXTURE_2D),ue.activeTexture(N.TEXTURE0),ue.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,L.flipY),ue.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),ue.pixelStorei(N.UNPACK_ALIGNMENT,L.unpackAlignment);let Ot=ue.getParameter(N.UNPACK_ROW_LENGTH),et=ue.getParameter(N.UNPACK_IMAGE_HEIGHT),ci=ue.getParameter(N.UNPACK_SKIP_PIXELS),Lt=ue.getParameter(N.UNPACK_SKIP_ROWS),tr=ue.getParameter(N.UNPACK_SKIP_IMAGES);ue.pixelStorei(N.UNPACK_ROW_LENGTH,ot.width),ue.pixelStorei(N.UNPACK_IMAGE_HEIGHT,ot.height),ue.pixelStorei(N.UNPACK_SKIP_PIXELS,we),ue.pixelStorei(N.UNPACK_SKIP_ROWS,Be),ue.pixelStorei(N.UNPACK_SKIP_IMAGES,qe);let Wn=v.isDataArrayTexture||v.isData3DTexture,hi=L.isDataArrayTexture||L.isData3DTexture;if(v.isDepthTexture){let je=Te.get(v),Rt=Te.get(L),ln=Te.get(je.__renderTarget),ft=Te.get(Rt.__renderTarget);ue.bindFramebuffer(N.READ_FRAMEBUFFER,ln.__webglFramebuffer),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,ft.__webglFramebuffer);for(let St=0;St<ge;St++)Wn&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Te.get(v).__webglTexture,G,qe+St),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Te.get(L).__webglTexture,de,_t+St)),N.blitFramebuffer(we,Be,we+Me,Be+he,Se,Ye,Se+Me,Ye+he,N.DEPTH_BUFFER_BIT,N.NEAREST);ue.bindFramebuffer(N.READ_FRAMEBUFFER,null),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(G!==0||v.isRenderTargetTexture||Te.has(v)){let je=Te.get(v),Rt=Te.get(L);ue.bindFramebuffer(N.READ_FRAMEBUFFER,C),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,Y);for(let ln=0;ln<ge;ln++)Wn?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,je.__webglTexture,G,qe+ln):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,je.__webglTexture,G),hi?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Rt.__webglTexture,de,_t+ln):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Rt.__webglTexture,de),G!==0?N.blitFramebuffer(we,Be,we+Me,Be+he,Se,Ye,Se+Me,Ye+he,N.COLOR_BUFFER_BIT,N.NEAREST):hi?N.copyTexSubImage3D(Ee,de,Se,Ye,_t+ln,we,Be,Me,he):N.copyTexSubImage2D(Ee,de,Se,Ye,we,Be,Me,he);ue.bindFramebuffer(N.READ_FRAMEBUFFER,null),ue.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else hi?v.isDataTexture||v.isData3DTexture?N.texSubImage3D(Ee,de,Se,Ye,_t,Me,he,ge,rt,It,ot.data):L.isCompressedArrayTexture?N.compressedTexSubImage3D(Ee,de,Se,Ye,_t,Me,he,ge,rt,ot.data):N.texSubImage3D(Ee,de,Se,Ye,_t,Me,he,ge,rt,It,ot):v.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,de,Se,Ye,Me,he,rt,It,ot.data):v.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,de,Se,Ye,ot.width,ot.height,rt,ot.data):N.texSubImage2D(N.TEXTURE_2D,de,Se,Ye,Me,he,rt,It,ot);ue.pixelStorei(N.UNPACK_ROW_LENGTH,Ot),ue.pixelStorei(N.UNPACK_IMAGE_HEIGHT,et),ue.pixelStorei(N.UNPACK_SKIP_PIXELS,ci),ue.pixelStorei(N.UNPACK_SKIP_ROWS,Lt),ue.pixelStorei(N.UNPACK_SKIP_IMAGES,tr),de===0&&L.generateMipmaps===!0&&L.mipmapsAutoUpdate===!0&&N.generateMipmap(Ee),ue.unbindTexture()},this.initRenderTarget=function(v){Te.get(v).__webglFramebuffer===void 0&&Ce.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?Ce.setTextureCube(v,0):v.isData3DTexture?Ce.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?Ce.setTexture2DArray(v,0):Ce.setTexture2D(v,0),ue.unbindTexture()},this.resetState=function(){J=0,z=0,te=null,ue.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return on}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Ze._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ze._getUnpackColorSpace()}};var Jh={type:"change"},Fl={type:"start"},jh={type:"end"},io=new gi,Kh=new Kt,f_=Math.cos(70*ml.DEG2RAD),bt=new B,qt=2*Math.PI,tt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ul=1e-6,so=class extends Ns{constructor(e,t=null){super(e,t),this.state=tt.NONE,this.target=new B,this.cursor=new B,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:ti.ROTATE,MIDDLE:ti.DOLLY,RIGHT:ti.PAN},this.touches={ONE:ni.ROTATE,TWO:ni.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new B,this._lastQuaternion=new jt,this._lastTargetPosition=new B,this._quat=new jt().setFromUnitVectors(e.up,new B(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new ji,this._sphericalDelta=new ji,this._scale=1,this._panOffset=new B,this._rotateStart=new Fe,this._rotateEnd=new Fe,this._rotateDelta=new Fe,this._panStart=new Fe,this._panEnd=new Fe,this._panDelta=new Fe,this._dollyStart=new Fe,this._dollyEnd=new Fe,this._dollyDelta=new Fe,this._dollyDirection=new B,this._mouse=new Fe,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=m_.bind(this),this._onPointerDown=p_.bind(this),this._onPointerUp=g_.bind(this),this._onContextMenu=S_.bind(this),this._onMouseWheel=y_.bind(this),this._onKeyDown=v_.bind(this),this._onTouchStart=M_.bind(this),this._onTouchMove=b_.bind(this),this._onMouseDown=__.bind(this),this._onMouseMove=x_.bind(this),this._interceptControlDown=E_.bind(this),this._interceptControlUp=w_.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.ownerDocument.addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=tt.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.ownerDocument.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Jh),this.update(),this.state=tt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;bt.copy(t).sub(this.target),bt.applyQuaternion(this._quat),this._spherical.setFromVector3(bt),this.autoRotate&&this.state===tt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=qt:n>Math.PI&&(n-=qt),s<-Math.PI?s+=qt:s>Math.PI&&(s-=qt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(bt.setFromSpherical(this._spherical),bt.applyQuaternion(this._quatInverse),t.copy(this.target).add(bt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){let o=bt.length();a=this._clampDistance(o*this._scale);let c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;let l=new B(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=bt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(io.origin.copy(this.object.position),io.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(io.direction))<f_?this.object.lookAt(this.target):(Kh.setFromNormalAndCoplanarPoint(this.object.up,this.target),io.intersectPlane(Kh,this.target))))}else if(this.object.isOrthographicCamera){let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>Ul||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ul||this._lastTargetPosition.distanceToSquared(this.target)>Ul?(this.dispatchEvent(Jh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?qt/60*this.autoRotateSpeed*e:qt/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){bt.setFromMatrixColumn(t,0),bt.multiplyScalar(-e),this._panOffset.add(bt)}_panUp(e,t){this.screenSpacePanning===!0?bt.setFromMatrixColumn(t,1):(bt.setFromMatrixColumn(t,0),bt.crossVectors(this.object.up,bt)),bt.multiplyScalar(e),this._panOffset.add(bt)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;bt.copy(s).sub(this.target);let r=bt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientY),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(qt*this._rotateDelta.x/t.clientHeight),this._rotateUp(qt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.zoomToCursor&&(this._performCursorZoom=!0,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(qt*this._rotateDelta.x/t.clientHeight),this._rotateUp(qt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Fe,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function p_(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function m_(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function g_(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(jh),this.state=tt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function __(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case ti.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=tt.DOLLY;break;case ti.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=tt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=tt.ROTATE}break;case ti.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=tt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=tt.PAN}break;default:this.state=tt.NONE}this.state!==tt.NONE&&this.dispatchEvent(Fl)}function x_(i){switch(this.state){case tt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case tt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case tt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function y_(i){this.enabled===!1||this.enableZoom===!1||this.state!==tt.NONE||(i.preventDefault(),this.dispatchEvent(Fl),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(jh))}function v_(i){this.enabled!==!1&&this._handleKeyDown(i)}function M_(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case ni.ROTATE:if(this.enableRotate===!1){this.state=tt.NONE;break}this._handleTouchStartRotate(i),this.state=tt.TOUCH_ROTATE;break;case ni.PAN:if(this.enablePan===!1){this.state=tt.NONE;break}this._handleTouchStartPan(i),this.state=tt.TOUCH_PAN;break;default:this.state=tt.NONE}break;case 2:switch(this.touches.TWO){case ni.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=tt.TOUCH_DOLLY_PAN;break;case ni.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=tt.TOUCH_DOLLY_ROTATE;break;default:this.state=tt.NONE}break;default:this.state=tt.NONE}this.state!==tt.NONE&&this.dispatchEvent(Fl)}function b_(i){switch(this._trackPointer(i),this.state){case tt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case tt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case tt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case tt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=tt.NONE}}function S_(i){this.enabled!==!1&&i.preventDefault()}function E_(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function w_(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var yt={drawn:.4,svgIn:.5,rise:.55,svgOut:.62,tilted:.78,wallsUp:.84,done:.96};var Qh=i=>i<0?0:i>1?1:i,Ei=i=>{let e=Qh(i);return e*e*(3-2*e)};function Zs(i,e){let t=Qh(e),n=t<yt.drawn?0:t<yt.svgIn?Ei((t-yt.drawn)/(yt.svgIn-yt.drawn)):t<yt.rise?1:1-Ei((t-yt.rise)/(yt.svgOut-yt.rise)),s=new Map;for(let h of i){let d=!h.hidden&&t>=h.appear,u=h.riseTo<=h.riseFrom?t>=h.riseFrom?1:0:Ei((t-h.riseFrom)/(h.riseTo-h.riseFrom));s.set(h.key,{visible:d,rise:u})}let r=[],a=[];for(let h of i)h.storey===void 0||h.hidden||(r[h.storey]=Math.max(r[h.storey]??0,h.riseTo),a[h.storey]=Math.min(a[h.storey]??1,h.appear));let o=r[0]??1,c=0;for(let h=1;h<r.length;h++){let d=r[h-1],u=a[h];t>d&&(c=h-1+(u>d?Ei((t-d)/(u-d)):1))}let l=0;if(r.length>1){let h=T_(r);l=h<1?Ei((t-h)/(1-h)):t>=1?1:0,l>0&&(c=r.length-1+l)}return{tilt:Ei((t-yt.rise)/(Math.min(yt.tilted,o)-yt.rise)),dolly:Ei((t-yt.rise)/(o-yt.rise)),stop:c,settle:l,svg:n,ground:t>=yt.rise?1-n:0,nodes:s}}var T_=i=>Math.max(yt.done,...i);var eu=.88,ri=i=>i*Math.PI/180;function Bl(i){let e=ri(i.elevation),t=ri(i.azimuth);return[Math.cos(e)*Math.sin(t),Math.sin(e),Math.cos(e)*Math.cos(t)]}function zl(i,e,t){let n=Bl(t);return[i[0]+e*n[0],i[1]+e*n[1],i[2]+e*n[2]]}function iu(i){let e=i[2],t=-i[0],n=Math.hypot(e,t),s=[e/n,0,t/n],r=[i[1]*s[2]-i[2]*s[1],i[2]*s[0]-i[0]*s[2],i[0]*s[1]-i[1]*s[0]];return{right:s,up:r}}function su(i){let e=[];for(let t of[i.lo[0],i.hi[0]])for(let n of[i.lo[1],i.hi[1]])for(let s of[i.lo[2],i.hi[2]])e.push([t,n,s]);return e}function A_(i,e,t){let n=Bl(t),{right:s,up:r}=iu(n),a=Math.tan(ri(t.fov)/2),o=1/0,c=-1/0,l=1/0,h=-1/0;for(let d of su(i)){let u=[d[0]-e.target[0],d[1]-e.target[1],d[2]-e.target[2]],m=e.dist-(u[0]*n[0]+u[1]*n[1]+u[2]*n[2]),_=(u[0]*s[0]+u[2]*s[2])/(m*a*t.aspect),y=(u[0]*r[0]+u[1]*r[1]+u[2]*r[2])/(m*a);o=Math.min(o,_),c=Math.max(c,_),l=Math.min(l,y),h=Math.max(h,y)}return{x:[o,c],y:[l,h]}}function Ol(i,e){let t=Bl(e),{right:n,up:s}=iu(t),r=Math.tan(ri(e.fov)/2),a=[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],o=1e3;for(let c=0;c<4;c++){o=0;for(let u of su(i)){let m=[u[0]-a[0],u[1]-a[1],u[2]-a[2]],_=m[0]*t[0]+m[1]*t[1]+m[2]*t[2],y=Math.abs(m[0]*n[0]+m[2]*n[2]),p=Math.abs(m[0]*s[0]+m[1]*s[1]+m[2]*s[2]);o=Math.max(o,_+y/(eu*r*e.aspect),_+p/(eu*r))}if(c===3)break;let l=A_(i,{target:a,dist:o},e),h=(l.x[0]+l.x[1])/2*o*r*e.aspect,d=(l.y[0]+l.y[1])/2*o*r;a=[a[0]+h*n[0]+d*s[0],a[1]+h*n[1]+d*s[1],a[2]+h*n[2]+d*s[2]]}return{target:a,dist:o}}var wn=30,kl=-32;function $s(i,e={}){let t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],s=e.ghosts?i:i.filter(r=>r.part!=="demolish");for(let r of s.length>0?s:i){let a=e.settle===void 0?r.lift??0:Vl(r.lift,e.settle);for(let o=0;o<r.positions.length;o+=3){let c=[r.positions[o]/1e3,r.positions[o+1]/1e3+a,r.positions[o+2]/1e3];for(let l=0;l<3;l++)t[l]=Math.min(t[l],c[l]),n[l]=Math.max(n[l],c[l])}}return{lo:t,hi:n}}var Vl=(i,e)=>(i??0)*(1-e),ao=i=>Math.max(1,...i.map(e=>(e.storey??0)+1)),ro=1.5;function ru(i,e,t){let n=new Map(e.map(a=>[a.key,a.storey??0])),s=ao(e),r=[];for(let a=0;a<s;a++)r.push(Ol($s(i.filter(o=>(n.get(o.key)??0)<=a)),t));return s>1&&r.push(Ol($s(i,{settle:1}),t)),r}function R_(i,e){let t=Math.min(i.length-1,Math.floor(e)),n=i[t],s=i[Math.min(i.length-1,t+1)],r=e-t;return r<=0||n===s?n:{target:[0,1,2].map(a=>n.target[a]*(1-r)+s.target[a]*r),dist:n.dist*(1-r)+s.dist*r}}function oo(i,e,t){let n=h=>h*Math.PI/180,s=R_(e,i.stop),r=2*s.dist*Math.tan(n(wn)/2),a=ro+(wn-ro)*i.dolly,c=(t.oh+(r-t.oh)*i.dolly)/(2*Math.tan(n(a)/2));return{target:[t.cx+(s.target[0]-t.cx)*i.dolly,s.target[1]*i.tilt,t.cz+(s.target[2]-t.cz)*i.dolly],dist:c,fov:a,elevation:90-(90-t.elevation)*i.tilt,azimuth:kl*i.tilt}}function Gl(i,e){let[t,n,s,r]=i,a=Math.max(s,r*e);return{cx:t+s/2,cz:n+r/2,ow:a,oh:a/e}}var tu={north:180,east:90,south:0,west:-90},Js={min:0,max:90};function au(i,e,t){if(e[1]>=t||i[1]<=t)return e;let n=(i[1]-t)/(i[1]-e[1]);return[i[0]+(e[0]-i[0])*n,t,i[2]+(e[2]-i[2])*n]}function ou(i,e){if(i==="iso")return oo(Zs(e.events,1),e.fits,e.frame);let t=i==="top"?{elevation:Js.max,azimuth:tu.south}:{elevation:Js.min,azimuth:tu[i]},n=Ol(e.box,{...t,fov:wn,aspect:e.aspect});return{target:n.target,dist:n.dist,fov:wn,...t}}function lu(i){return i.fov===wn?i:{...i,fov:wn,dist:i.dist*Math.tan(ri(i.fov)/2)/Math.tan(ri(wn)/2)}}var nu={in:8,out:3};function cu(i,e){let t=i[i.length-1].dist,n=Math.tan(ri(wn)/2)/Math.tan(ri(e)/2);return{min:t*n/nu.in,max:t*n*nu.out}}function hu(i){let e=[i.hi[0]-i.lo[0],i.hi[1]-i.lo[1],i.hi[2]-i.lo[2]];return{centre:[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],radius:Math.hypot(e[0],e[1],e[2])/2}}var Ke=(i,e,t=0,n=1)=>({srgb:i,alpha:n,metallic:t,roughness:e}),ai={wood:Ke("#c6a785",.75),wood_dark:Ke("#7b5b44",.7),fabric:Ke("#968f85",.95),cushion:Ke("#bfb7ab",.95),linen:Ke("#f3efe7",.9),wool:Ke("#a7ac98",1),ceramic:Ke("#f6f4f0",.25),stone:Ke("#d8d4cc",.45),metal:Ke("#aeb2b4",.35,1),glass:Ke("#c9dee6",.05,0,.35),appliance:Ke("#dcdcd8",.35),screen:Ke("#2e3033",.2),paint:Ke("#a9b1a2",.6),rubber:Ke("#3b3b3b",.9),foliage:Ke("#8c9b78",.9),bark:Ke("#6f5b49",.9),soil:Ke("#5f4b3b",1),water:Ke("#a3c6d0",.1,0,.7)},C_="wood",Hl={slab:Ke("#bdb6ab",.9),column:Ke("#e6e1d8",.85),wall:Ke("#f2f0eb",.9),door:Ke("#c2a27e",.7),"window:frame":Ke("#55534f",.5),"window:glass":Ke("#bcd6e0",.05,0,.4),opening:Ke("#e6e1d8",.85),furniture:Ke("#d6cec1",.9),roof:Ke("#9c958a",.9),"wall:demolish":Ke("#c8553d",.9,0,.3),stair:ai[C_]},du="#8f877d";var P_={timber:Ke("#cdb596",.6),tile:Ke("#e3e1db",.35),neutral:Ke("#e8e2d7",.9)};var uu={gravel:Ke("#cbc3b4",.95),tarmac:Ke("#8c8984",.85)},Rv={planting:ai.foliage,deck:ai.wood,gravel:uu.gravel,driveway:uu.tarmac};var Cv={picket:Ke("#eeebe4",.8),panel:ai.wood,post:ai.wood_dark},lo={light:"#e2ddd3",dark:"#16293d",marginMm:6e3};function fu(i,e,t){if(e==="light")return i;let n=s=>{let r=Number.parseInt(i.slice(s,s+2),16),a=Number.parseInt(t.slice(s,s+2),16);return Math.round(r*.4+a*.6).toString(16).padStart(2,"0")};return`#${n(1)}${n(3)}${n(5)}`}function pu(i,e,t){let n=ai[i].srgb;if(e==="light")return n;let s=r=>{let a=Number.parseInt(n.slice(r,r+2),16),o=Number.parseInt(t.slice(r,r+2),16);return Math.round(a*.4+o*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}function mu(i,e,t){let n=P_[i].srgb;if(e==="light")return n;let s=r=>{let a=Number.parseInt(n.slice(r,r+2),16),o=Number.parseInt(t.slice(r,r+2),16);return Math.round(a*.4+o*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}var Ks=(i,e,t)=>`${i} ${i===1?e:t}`,gu=i=>`${Number(i.toFixed(2))} m\xB2`;function Wl(i,e,t){let n;for(let s of i)s.stage===e&&!s.hidden&&(n===void 0||s.appear<n)&&(n=s.appear);return n??t}function _u(i,e,t){let n=Wl(e,"rooms",yt.drawn),s=Wl(e,"openings",yt.drawn),r=[],a=(o,c)=>{t>=o&&r.push(c)};return i.storeys!==void 0&&a(Wl(e,"brief",0),{id:"storeys",text:Ks(i.storeys,"storey","storeys")}),a(n,{id:"rooms",text:Ks(i.rooms,"room","rooms")}),i.areaNet!==void 0&&a(n,{id:"area-net",text:`floor area ${gu(i.areaNet)} (net)`}),a(n,{id:"area-centre",text:`floor area ${gu(i.areaCentre)} (to wall centre lines)`}),a(s,{id:"doors",text:Ks(i.doors,"door","doors")}),a(s,{id:"windows",text:Ks(i.windows,"window","windows")}),a(yt.svgIn,{id:"warnings",text:i.warnings===0?"no warnings":Ks(i.warnings,"warning","warnings")}),r}function xu(i,e){let t=e.map(s=>`${s.id}=${s.text}`).join("|");if(i.dataset.stripKey===t)return;i.dataset.stripKey=t,i.hidden=e.length===0;let n=[];for(let s of e){let r=i.ownerDocument.createElement("span");r.dataset.fact=s.id,r.textContent=s.text,n.length>0&&n.push(i.ownerDocument.createTextNode(" ")),n.push(r)}i.replaceChildren(...n)}function co(i){return i.kind==="wall"&&i.part===void 0||i.kind==="column"}var oi=2**26;function js(i,e,t,n){if(Math.abs(i)<oi&&Math.abs(e)<oi&&Math.abs(t)<oi&&Math.abs(n)<oi)return i*n-e*t;let s=BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t);return s>0n?1:s<0n?-1:0}function I_(i,e,t,n){return Math.abs(i)<oi&&Math.abs(e)<oi&&Math.abs(t)<oi&&Math.abs(n)<oi?String(i*n-e*t):(BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t)).toString()}function L_(i,e){let t=Math.abs(i),n=Math.abs(e);for(;n!==0;)[t,n]=[n,t%n];return t}function D_(i,e,t,n){let s=BigInt(i[0])*BigInt(e[0])+BigInt(i[1])*BigInt(e[1]),r=BigInt(i[0])*BigInt(e[1])-BigInt(i[1])*BigInt(e[0]),a=t*n>0?s:-s;return a>0n&&a*a>3n*r*r}function Xl(i,e,t,n){let s=t-i,r=n-e,a=L_(s,r);return s/=a,r/=a,(s<0||s===0&&r<0)&&(s=0-s,r=0-r),{dx:s,dz:r,key:`${s},${r},${I_(s,r,i,e)}`}}var ql=(i,e)=>{for(let t=0;t<i.length;t++){let n=i[t]-e[t];if(n!==0)return n}return 0},Qs=i=>[...i.keys()].sort((e,t)=>e<t?-1:e>t?1:0),er=i=>{let e=[...i].sort((n,s)=>n-s),t=0;for(let n=0;n<e.length;n++)(n===0||e[n]!==e[t-1])&&(e[t++]=e[n]);return e.length=t,e};function yu(i){let e=1/0,t=-1/0;for(let n of i)n<e&&(e=n),n>t&&(t=n);return[e,t]}function vu(i,e){let t=-1;for(let n of i)if(t<0)t=n;else{let s=e?.[n]??0,r=e?.[t]??0;(s>r||s===r&&n<t)&&(t=n)}return t}function bu(i){let e=new Map;return i.forEach((t,n)=>{if(!co(t))return;let s=/^L(-?\d+)\//.exec(t.key)?.[1]??"",r=e.get(s);r?r.push(n):e.set(s,[n])}),Qs(e).map(t=>e.get(t)??[])}function Su(i,e){let t=F_(i),n=i.map((s,r)=>co(s)?{...s,...O_(s,t[r])}:s);return{faces:t,lines:N_(n,e)}}function N_(i,e){let t=i.map(s=>co(s)?[]:void 0),n=i.map(()=>[]);for(let s of bu(i))U_(i,s,n,e);return n.forEach((s,r)=>{if(!t[r])return;let a=s.map(o=>ql(o.slice(0,3),o.slice(3))<=0?o:[o[3],o[4],o[5],o[0],o[1],o[2]]).sort(ql);t[r]=a.flat()}),t}function Mu(i,e){let t=i.map((a,o)=>[a,o]).sort((a,o)=>a[0].t0-o[0].t0||a[1]-o[1]),n=er(i.flatMap(a=>[a.t0,a.t1])),s=0,r=[];for(let a=0;a+1<n.length;a++){let o=n[a],c=n[a+1];for(r.some(l=>l.t1<=o)&&(r=r.filter(l=>l.t1>o));s<t.length&&t[s]?.[0].t0<=o;)r.push(t[s++]?.[0]);r.length>0&&e(o,c,r)}}function U_(i,e,t,n){let s=new Map,r=new Map,a=new Map,o=new Map,c=(_,y,p)=>{let f=`${_}|${y}`,S=s.get(f);S?S.edges.push(p):s.set(f,{line:y,plane:_,edges:[p]})},l=(_,y,p,f)=>{let S=ql(y,p)<0,[A,b]=S?[y,p]:[p,y],T=`${_}|${A[0]},${A[1]},${A[2]}|${b[0]},${b[1]},${b[2]}`,E=o.get(T);E?(E.net+=S?1:-1,E.nodes.push(f)):o.set(T,{a:A,b,net:S?1:-1,nodes:[f]})},h=(_,y,p,f)=>{let S=`h${_}:${y.key}`,A=r.get(S);if(A||(A={kind:"horizontal",y:_,alongX:y.dx!==0,other:new Map},r.set(S,A)),A.kind==="horizontal")for(let b of[p,f]){let[T,,E]=b;A.alongX?A.other.set(T,E):A.other.set(E,T)}return S},d=(_,y)=>_.dx!==0?y[0]:y[2],u=(_,y,p,f)=>_<y?{t0:_,t1:y,k:1,node:p,f}:{t0:y,t1:_,k:-1,node:p,f};for(let _ of e){let y=i[_],p=f=>[Math.round(y.positions[f*3]),Math.round(y.positions[f*3+1]),Math.round(y.positions[f*3+2])];for(let f=0;f+2<y.indices.length;f+=3){let S=[p(y.indices[f]),p(y.indices[f+1]),p(y.indices[f+2])],[A,b,T]=S,E=A[0],g=A[1],M=A[2],U=[[A,b],[b,T],[T,A]];if(g===b[1]&&g===T[1]){if(js(b[0]-E,b[2]-M,T[0]-E,T[2]-M)===0)continue;let z=`H${g}`;for(let[te,W]of U){if(te[0]===W[0]&&te[2]===W[2])continue;let $=Xl(te[0],te[2],W[0],W[2]);c(z,h(g,$,te,W),u(d($,te),d($,W),_,0))}continue}if(!(js(b[0]-E,b[2]-M,T[0]-E,T[2]-M)===0)){for(let[z,te]of U)t[_].push([...z,...te]);continue}let D=A[0]!==b[0]||A[2]!==b[2]?b:T;if(D[0]===E&&D[2]===M)continue;let F=Xl(E,M,D[0],D[2]),H=`V${F.key}`;a.has(H)||a.set(H,[F.dx,F.dz]);let C=z=>d(F,z),Y=js(C(b)-C(A),b[1]-g,C(T)-C(A),T[1]-g);if(Y===0)continue;let J=Y>0?1:-1;for(let[z,te]of U)if(z[0]===te[0]&&z[2]===te[2]){if(z[1]===te[1])continue;let W=`v${z[0]},${z[2]}`;r.has(W)||r.set(W,{kind:"vertical",x:z[0],z:z[2]}),c(H,W,u(z[1],te[1],_,J))}else z[1]===te[1]?c(H,h(z[1],F,z,te),u(d(F,z),d(F,te),_,J)):l(H,z,te,_)}}let m=new Map;for(let _ of Qs(s)){let{line:y,plane:p,edges:f}=s.get(_),[S,A]=f;f.length===2&&A&&S.t0===A.t0&&S.t1===A.t1&&S.k!==A.k||Mu(f,(b,T,E)=>{let g=0;for(let H of E)g+=H.k;if(g===0)return;let M=new Map;for(let H of E)M.set(H.node,(M.get(H.node)??0)+H.k);let U=er(E.filter(H=>M.get(H.node)!==0).map(H=>H.node)),I=er(E.filter(H=>H.k===Math.sign(g)).map(H=>H.f)),D={t0:b,t1:T,nodes:U,plane:p,f:I.length===1?I[0]:0},F=m.get(y);F?F.push(D):m.set(y,[D])})}for(let _ of Qs(m)){let y=m.get(_),p=r.get(_),f=[];Mu(y,(S,A,b)=>{if(p.kind==="vertical"&&b.length===2){let[g,M]=b,U=a.get(g.plane),I=a.get(M.plane);if(U&&I&&g.f!==0&&M.f!==0&&D_(U,I,g.f,M.f))return}let T=vu(b.flatMap(g=>g.nodes),n),E=f[f.length-1];E&&E.t1===S&&E.node===T?E.t1=A:f.push({t0:S,t1:A,node:T})});for(let S of f){let A=b=>{if(p.kind==="vertical")return[p.x,b,p.z];let T=p.other.get(b);return p.alongX?[b,p.y,T]:[T,p.y,b]};t[S.node].push([...A(S.t0),...A(S.t1)])}}for(let _ of Qs(o)){let{a:y,b:p,net:f,nodes:S}=o.get(_);f!==0&&t[vu(S,n)].push([...y,...p])}}function Eu(i,e){let t=new Map;i.forEach((s,r)=>{s&&s.group>=0&&t.set(s.group,(t.get(s.group)??!0)&&e(r))});let n=new Set;for(let[s,r]of t)r&&n.add(s);return n}function F_(i){let e=i.map(a=>co(a)?{hide:[],add:[],alone:[],joined:[],group:-1}:void 0),t=i.map((a,o)=>o),n=a=>{let o=a;for(;t[o]!==o;)o=t[o];for(;t[a]!==o;)[a,t[a]]=[t[a],o];return o},s=(a,o)=>{let c=n(a),l=n(o);c<l?t[l]=c:l<c&&(t[c]=l)},r=new Set;for(let a of bu(i))z_(i,a,e,s,r);return e.forEach((a,o)=>{a&&(a.hide.sort((c,l)=>c-l),r.has(o)&&(a.group=n(o)))}),e}function Yl(i,e){if(!e)return{positions:i.positions,base:[...i.indices],alone:[],joined:[]};let t=new Set(e.hide),n=[];for(let c=0;c+2<i.indices.length;c+=3)t.has(c/3)||n.push(i.indices[c],i.indices[c+1],i.indices[c+2]);let s=i.positions.length/3,r=(c,l=[])=>{for(let h=0;h<c.length/3;h++)l.push(s++);return l};r(e.add,n);let a=r(e.alone),o=r(e.joined);return{positions:i.positions.concat(e.add,e.alone,e.joined),base:n,alone:a,joined:o}}function O_(i,e,t="joined"){if(!e)return{positions:i.positions,indices:i.indices};let n=Yl(i,e);return{positions:n.positions,indices:n.base.concat(t==="joined"?n.joined:n.alone)}}function B_(i){let e=i.map(s=>{let[r,a]=yu(s.s),[o,c]=yu(s.p.map(l=>l[1]));return{s0:r,s1:a,y0:o,y1:c,f:s.f}});e.sort((s,r)=>s.s0-r.s0);let t=[],n=[];for(let s of e){if(t.some(a=>a.s1<=s.s0)&&(t=t.filter(a=>a.s1>s.s0)),n.some(a=>a.s1<=s.s0)&&(n=n.filter(a=>a.s1>s.s0)),(s.f>0?n:t).some(a=>Math.min(a.y1,s.y1)>Math.max(a.y0,s.y0)))return!0;(s.f>0?t:n).push(s)}return!1}function z_(i,e,t,n,s){let r=new Map;for(let a of e){let o=i[a],c=l=>[Math.round(o.positions[l*3]),Math.round(o.positions[l*3+1]),Math.round(o.positions[l*3+2])];for(let l=0;l+2<o.indices.length;l+=3){let h=c(o.indices[l]),d=c(o.indices[l+1]),u=c(o.indices[l+2]),m=h[0],_=h[1],y=h[2];if(_===d[1]&&_===u[1]||js(d[0]-m,d[2]-y,u[0]-m,u[2]-y)!==0)continue;let p=h[0]!==d[0]||h[2]!==d[2]?d:u;if(p[0]===m&&p[2]===y)continue;let f=Xl(m,y,p[0],p[2]),S=M=>f.dx!==0?M[0]:M[2],A=[S(h),S(d),S(u)],b=js(A[1]-A[0],d[1]-_,A[2]-A[0],u[1]-_);if(b===0)continue;let T=`V${f.key}`,E={node:a,tri:l/3,p:[h,d,u],f:b>0?1:-1,s:A},g=r.get(T);g?g.tris.push(E):r.set(T,{pl:f,tris:[E]})}}for(let a of Qs(r)){let{tris:o}=r.get(a);if(!B_(o))continue;let c=er(o.flatMap(b=>b.s)),l=er(o.flatMap(b=>b.p.map(T=>T[1]))),h=new Map;for(let b of o)for(let T=0;T<3;T++)h.set(b.s[T],b.p[T]);let d=new Map(c.map((b,T)=>[b,T])),u=new Map(l.map((b,T)=>[b,T])),m=l.length-1,_=c.map(()=>[]);for(let b of o)for(let T=0;T<3;T++){let E=b.p[T],g=b.p[(T+1)%3];if(E[0]!==g[0]||E[2]!==g[2]||E[1]===g[1])continue;let M=d.get(b.s[T]),U=Math.min(E[1],g[1]),I=Math.max(E[1],g[1]);_[M].push([b.node,u.get(U),u.get(I),g[1]>E[1]?1:-1])}let y=new Map,p=new Map,f=[],S=new Int32Array(m),A=(b,T,E,g,M)=>{let U=l[g],I=l[g+1],D=(J,z)=>{let te=h.get(J);return[te[0],z,te[2]]},[F,H,C,Y]=[D(T,U),D(E,U),D(E,I),D(T,I)];M>0?b.push(...F,...H,...C,...F,...C,...Y):b.push(...F,...C,...H,...F,...Y,...C)};for(let b=0;b+1<c.length;b++){let T=_[b];for(let[M,U,I,D]of T){let F=y.get(M);F||(F=new Int32Array(m),y.set(M,F));let H=p.get(M)??0;for(let C=U;C<I;C++){let Y=F[C],J=Y-D;F[C]=J,S[C]=S[C]-D,Y===0?H++:J===0&&H--}p.set(M,H)}if(T.length>0){for(let M of[...y.keys()])p.get(M)===0&&(y.delete(M),p.delete(M));f=[...y.keys()].sort((M,U)=>M-U)}let E=c[b],g=c[b+1];for(let M=0;M<m;M++){let U=f.filter(F=>y.get(F)[M]!==0);if(U.length===0)continue;if(U.length===1){let F=U[0];A(t[F].add,E,g,M,y.get(F)[M]);continue}for(let F of U)A(t[F].alone,E,g,M,y.get(F)[M]),s.add(F),n(F,U[0]);let I=S[M];if(I===0)continue;let D=U.find(F=>Math.sign(y.get(F)[M])===Math.sign(I));A(t[D].joined,E,g,M,I)}}for(let b of o)t[b.node].hide.push(b.tri)}}var k_=5,ho=.9,Zl={light:{background:"#f7f5f0",edge:"#8f877c",cap:du,colors:Object.fromEntries(Object.entries(Hl).map(([i,e])=>[i,e.srgb]))},dark:{background:"#0f2235",edge:"#cfe3f5",cap:"#cfe3f5",colors:{slab:"#20384f",floor:"#1b3248",column:"#3b5b78",wall:"#2e4d6a",roof:"#14283c",door:"#7aa6c9","window:frame":"#5d86a8","window:glass":"#86c5ee","wall:demolish":"#e07a5f",furniture:"#3f6a8f",stair:"#5d86a8"}}},Hn={sky:16317439,ground:14275271,hemi:2.4,keyColour:16775922,key:2.7,keyFrom:[-1,1.25,.3],fillColour:15002869,fill:.5,fillFrom:[.7,.5,-.6]},V_=12;function wu(i,e,t,n={}){let s=Zl[e.theme],r=s.colors.furniture,a=e.width,o=e.height,c=document.createElement("canvas");c.width=a,c.height=o,i.width=a,i.height=o;let l=i.getContext("2d",{willReadFrequently:!0}),h=new eo({canvas:c,antialias:!1,preserveDrawingBuffer:!0});h.setPixelRatio(1),h.setSize(a,o,!1),h.toneMapping=Fs;let d=new bs;d.background=new ze(s.background),d.add(new Ls(Hn.sky,Hn.ground,Hn.hemi));let u=new Ji(Hn.keyColour,Hn.key);u.position.set(...Hn.keyFrom),d.add(u);let m=new Ji(Hn.fillColour,Hn.fill);m.position.set(...Hn.fillFrom),d.add(m);let _=new Map,y=[],p=new Map(e.events.map(P=>[P.key,P.rank])),{faces:f,lines:S}=Su(e.nodes,e.nodes.map(P=>p.get(P.key)??0)),A=[];for(let[P,Q]of e.nodes.entries()){let R=S[P],X=f[P],O=Yl(Q,X),q={...Q,positions:O.positions,indices:O.base},ne=new Float32Array(q.positions.length),se=1/0,xe=-1/0;for(let ie=1;ie<q.positions.length;ie+=3)se=Math.min(se,q.positions[ie]/1e3),xe=Math.max(xe,q.positions[ie]/1e3);for(let ie=0;ie<q.positions.length;ie+=3){let Ne=q.positions[ie]/1e3,Je=q.positions[ie+1]/1e3,Xe=q.positions[ie+2]/1e3;ne[ie]=Ne,ne[ie+1]=Je-se,ne[ie+2]=Xe}let Pe=q.part?`${q.kind}:${q.part}`:q.kind,re=new Nn;re.position.y=se+(q.lift??0);let ve=(ie,Ne,Je,Xe,Yt,Ve,_n=!0)=>{let sn=new Wt;sn.setAttribute("position",ie),sn.setIndex(Ne),Ve&&sn.computeVertexNormals();let Tn=Pe==="wall:demolish",rn=q.kind==="floor"||q.kind==="slab",wi=new $i({color:new ze(Je),transparent:Xe||Tn,opacity:Xe?Yt:Tn?.3:1,depthWrite:!Tn,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:q.kind==="outdoor"?8:rn?4:1});y.push(sn,wi);let as=new en(sn,wi);if(re.add(as),q.kind!=="slab"&&!Xe&&_n){let os=new Rs(sn,30),li=new _i({color:new ze(s.edge)});y.push(os,li),re.add(new Yi(os,li))}return as},Ae=new Gt(ne,3);if(q.groups){let ie=0;for(let{slot:Ne,count:Je}of q.groups){let Xe=q.indices.slice(ie,ie+Je);if(ie+=Je,Ne==="body")ve(Ae,Xe,s.colors[Pe]??r,!1,1,!1);else{let{alpha:Yt}=ai[Ne];ve(Ae,Xe,pu(Ne,e.theme,r),Yt<1,Yt,!1)}}}else if(q.colour)ve(Ae,q.indices,fu(q.colour,e.theme,Zl.dark.colors.floor),!1,1,!0,q.kind!=="fence");else if(q.finish)ve(Ae,q.indices,mu(q.finish,e.theme,Zl.dark.colors.floor),!1,1,!0);else if(Pe==="wall"){let ie=Xe=>q.positions[Xe*3+1]/1e3===xe,Ne=[],Je=[];for(let Xe=0;Xe<q.indices.length;Xe+=3){let Yt=q.indices.slice(Xe,Xe+3);(Yt.every(ie)?Ne:Je).push(...Yt)}ve(Ae,Je,s.colors.wall??r,!1,1,!0,R===void 0),Ne.length&&ve(Ae,Ne,s.cap,!1,1,!0,!1)}else{let ie=Pe==="window:glass";ve(Ae,q.indices,s.colors[Pe]??r,ie,ie?Hl["window:glass"].alpha:1,!0,R===void 0)}if(X&&X.group>=0){let ie=s.colors[Pe]??r;A.push({key:q.key,...O.alone.length>0?{alone:ve(Ae,O.alone,ie,!1,1,!0,!1)}:{},...O.joined.length>0?{joined:ve(Ae,O.joined,ie,!1,1,!0,!1)}:{},group:X.group})}if(R&&R.length>0){let ie=new Float32Array(R.length);for(let Xe=0;Xe<R.length;Xe+=3)ie[Xe]=R[Xe]/1e3,ie[Xe+1]=R[Xe+1]/1e3-se,ie[Xe+2]=R[Xe+2]/1e3;let Ne=new Wt;Ne.setAttribute("position",new Gt(ie,3));let Je=new _i({color:new ze(s.edge)});y.push(Ne,Je),re.add(new Yi(Ne,Je))}re.visible=!1,d.add(re),_.set(q.key,{g:re,flat:Math.min(1,V_/Math.max(1e-6,xe-se)),base:se,lift:q.lift??0})}let[b,T,E,g]=e.viewBox,M=a/o,{cx:U,cz:I,ow:D,oh:F}=Gl(e.viewBox,M),H=$s(e.nodes,{ghosts:!0}),C=new B(...H.lo),Y=new B(...H.hi),J=Y.y+1e3,z,te;if(e.ground){let P=e.ground.y/1e3,Q=lo.marginMm,[R,X,O,q]=[C.x-Q,C.z-Q,Y.x+Q,Y.z+Q],ne=new Wt;ne.setAttribute("position",new Gt(new Float32Array([R,P,X,R,P,q,O,P,q,O,P,X]),3)),ne.setIndex([0,1,2,0,2,3]);let se=new $i({color:new ze(e.theme==="light"?lo.light:lo.dark),transparent:!0,opacity:0,depthWrite:!0,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:16});y.push(ne,se),z=new en(ne,se),te=se,z.renderOrder=-1,z.visible=!1,d.add(z)}let W=new xi(-D/2,D/2,F/2,-F/2,1,J+1e5);W.up.set(0,0,-1),W.position.set(U,J+5e4,I),W.lookAt(U,0,I);let $=new Bt(ro,M,10,1e9),ae=P=>ru(e.nodes,e.events,{elevation:e.elevation,azimuth:kl,fov:wn,aspect:P}),_e=ae(M),De=Y.clone().sub(C),j=C.clone().add(Y).multiplyScalar(.5),pe=P=>{let Q=Math.max(...P.map(R=>j.distanceTo(new B(...R.target))));return Math.max(De.length()*.75+Q+Math.hypot(j.x-(b+E/2),j.z-(T+g/2)),1e3)},ye=pe(_e.slice(0,ao(e.events))),Re=pe(_e),fe=P=>P*Math.PI/180,Le=new Image,pt=new Promise(P=>{Le.onload=()=>P(),Le.onerror=()=>P()});Le.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e.svg)))}`;let be=!1,$e={cx:U,cz:I,oh:F,elevation:e.elevation},it=new Map(e.events.map(P=>[P.key,P.storey??0])),ke=Math.max(1,...e.events.filter(P=>!P.hidden).map(P=>(P.storey??0)+1)),lt=ke,Ge="replay",mt=0,at=!1,nn=De.length()/2,gt=P=>Math.max(Re,j.distanceTo(P)+nn);function Ft(P,Q){let{fov:R,dist:X,elevation:O,azimuth:q}=P,ne=new B(...P.target),se=fe(O);$.fov=R,$.near=Math.max(10,X-Q),$.far=X+Q,$.updateProjectionMatrix(),$.up.set(0,0,-1),se<fe(89.99)&&$.up.set(0,1,0),$.position.set(...zl([ne.x,ne.y,ne.z],X,{elevation:O,azimuth:q})),$.lookAt(ne)}let Tt={events:e.events,fits:_e,frame:$e,box:$s(e.nodes,{settle:1}),aspect:M},Pt=new Map,N=P=>{let Q=Pt.get(P);if(Q)return Q;let R=ou(P,Tt);return Pt.set(P,R),R},At,Qe=()=>{},st=()=>{},ue=()=>{},ut=new Set,Te=()=>{for(let P of ut)P()},Ce=Math.max(1,Math.min(4,Math.floor(e.supersample??1)));function w(P){let Q=Ce*Ce,R=new Uint32Array(a*o*4);l.globalAlpha=1;for(let O=0;O<Ce;O++)for(let q=0;q<Ce;q++){P.setViewOffset(a,o,(q+.5)/Ce-.5,(O+.5)/Ce-.5,a,o),h.render(d,P),l.drawImage(c,0,0);let ne=l.getImageData(0,0,a,o).data;for(let se=0;se<ne.length;se++)R[se]=R[se]+ne[se]}P.clearViewOffset();let X=l.createImageData(a,o);for(let O=0;O<R.length;O++)X.data[O]=Math.floor((R[O]+(Q>>1))/Q);l.putImageData(X,0,0)}function x(P){mt=P,at=!0,t&&e.facts&&xu(t,_u(e.facts,e.events,Math.min(1,Math.max(0,P))));let Q=Zs(e.events,P);z&&te&&(z.visible=Q.ground>0,te.opacity=Q.ground);for(let[O,{g:q,flat:ne,base:se,lift:xe}]of _){let Pe=Q.nodes.get(O);q.visible=Pe?.visible===!0&&(it.get(O)??0)<lt,q.scale.y=Math.max(ne,Pe?.rise??0),xe!==0&&(q.position.y=se+Vl(xe,Q.settle))}let R=Eu(f,O=>{let q=e.nodes[O]?.key??"";return _.get(q)?.g.visible===!0&&(Q.nodes.get(q)?.rise??0)>=1});for(let{group:O,alone:q,joined:ne}of A){let se=R.has(O);q&&(q.visible=!se),ne&&(ne.visible=se)}let X=W;if(Ge==="free"&&At){let O=$.position.distanceTo(At.target),q=gt(At.target);$.near=Math.max(10,O-q),$.far=O+q,$.updateProjectionMatrix(),X=$}else if(Ge!=="replay"&&Ge!=="free"){let O=N(Ge);Ft(O,gt(new B(...O.target))),X=$}else(Q.tilt>0||Q.dolly>0)&&(Ft(oo(Q,_e,$e),Q.settle>0?Re:ye),X=$);if(Ce===1?(h.render(d,X),l.globalAlpha=1,l.drawImage(c,0,0)):w(X),Ge==="replay"&&Q.svg>0&&Le.complete&&Le.naturalWidth>0){let O=Math.min(a/E,o/g),q=E*O,ne=g*O;l.globalAlpha=Q.svg,l.drawImage(Le,(a-q)/2,(o-ne)/2,q,ne),l.globalAlpha=1}}function k(P){be||(Ge!=="replay"&&(Qe(),Ge="replay",Te()),x(P),ue())}async function oe(){let P=l.getImageData(0,0,a,o).data,Q=await crypto.subtle.digest("SHA-256",P);return[...new Uint8Array(Q)].map(R=>R.toString(16).padStart(2,"0")).join("")}let ee=n.interactive?le():void 0;function le(){let P=new so($,i);At=P,P.enableDamping=!1,P.screenSpacePanning=!1,P.minPolarAngle=fe(90-Js.max),P.maxPolarAngle=fe(90-Js.min);let Q=hu(H);P.cursor.set(...Q.centre);let R=i.getAttribute("tabindex");i.tabIndex=0;let X=0,O=!1,q=!1,ne=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,se=()=>{X=0,!(be||Ge!=="free")&&(P.update()||O)&&(X=requestAnimationFrame(se))},xe=()=>{P.enableDamping&&!X&&(X=requestAnimationFrame(se))};Qe=()=>{X&&cancelAnimationFrame(X),X=0,O=!1,P.enableDamping&&(q=!0,P.enableDamping=!1,P.update(),q=!1)};let Pe=(Ve,_n,sn)=>{$.fov=sn,$.up.set(0,1,0),$.position.set(...Ve),P.target.set(...au(Ve,_n,Tt.box.lo[1])),$.lookAt(P.target);let Tn=$.position.distanceTo(P.target),rn=cu(_e,sn);P.minDistance=Math.min(rn.min,Tn),P.maxDistance=Math.max(rn.max,Tn),P.maxTargetRadius=Math.max(Q.radius,P.target.distanceTo(P.cursor)),P.enableDamping=!ne()},re=()=>{if(Ge==="free")return;let Ve=Ge==="replay"?lu(oo(Zs(e.events,mt),_e,$e)):N(Ge);Pe(zl(Ve.target,Ve.dist,Ve),Ve.target,Ve.fov)},ve=()=>{Ge!=="free"&&(Ge="free",n.onTake?.(),Te(),xe())},Ae=!1;ue=()=>{Ae&&re()},P.addEventListener("start",()=>{re(),Ae=!0,O=!0}),P.addEventListener("end",()=>{Ae=!1,O=!1}),P.addEventListener("change",()=>{q||be||(Ae=!1,ve(),x(mt))});let ie=fe(k_),Ne=new Map([["ArrowLeft",()=>P.rotateLeft(ie)],["ArrowRight",()=>P.rotateLeft(-ie)],["ArrowUp",()=>P.rotateUp(ie)],["ArrowDown",()=>P.rotateUp(-ie)],["+",()=>P.dollyIn(ho)],["=",()=>P.dollyIn(ho)],["-",()=>P.dollyOut(ho)],["_",()=>P.dollyOut(ho)]]),Je=Ve=>{let _n=Ne.get(Ve.key);!_n||be||Ve.ctrlKey||Ve.metaKey||Ve.altKey||(Ve.preventDefault(),re(),_n(),xe())};i.addEventListener("keydown",Je),st=()=>{i.removeEventListener("keydown",Je),P.dispose(),R===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",R),ut.clear()};let Xe=Ve=>Math.min(ke,Math.max(1,Math.round(Ve))),Yt=()=>lt===ke?"all":lt;return{at:Ve=>{be||x(Ve)},preset:Ve=>{be||(Qe(),Ge=Ve,n.onTake?.(),Te(),x(mt))},reset:()=>{be||(Qe(),Ge="replay",lt=ke,Te(),x(mt))},storeys:ke,showStoreys:Ve=>{be||(lt=Xe(Ve),Te(),x(mt))},onChange:Ve=>(ut.add(Ve),()=>ut.delete(Ve)),spin:Ve=>{if(be||O||!Number.isFinite(Ve)||Ve===0)return;re();let _n=P.enableDamping;P.enableDamping=!1,P.rotateLeft(fe(Ve)),P.update(),P.enableDamping=_n},get shown(){return lt},get camera(){return Ge},state:()=>Ge==="free"?{camera:"free",position:$.position.toArray(),target:P.target.toArray(),fov:$.fov,storeys:Yt()}:{camera:Ge,storeys:Yt()},restore:Ve=>{be||(Qe(),lt=Ve.storeys==="all"?ke:Xe(Ve.storeys),Ve.camera==="free"&&Pe(Ve.position,Ve.target,Ve.fov),Ge=Ve.camera,Ge!=="replay"&&n.onTake?.(),Te())}}}function ce(P,Q){if(be)return;let R=Math.max(1,Math.round(P)),X=Math.max(1,Math.round(Q));R===a&&X===o||(a=R,o=X,c.width=a,c.height=o,i.width=a,i.height=o,h.setSize(a,o,!1),M=a/o,{cx:U,cz:I,ow:D,oh:F}=Gl(e.viewBox,M),W.left=-D/2,W.right=D/2,W.top=F/2,W.bottom=-F/2,W.position.set(U,J+5e4,I),W.lookAt(U,0,I),W.updateProjectionMatrix(),$.aspect=M,$.updateProjectionMatrix(),_e=ae(M),ye=pe(_e.slice(0,ao(e.events))),Re=pe(_e),$e={cx:U,cz:I,oh:F,elevation:e.elevation},Tt={...Tt,fits:_e,frame:$e,aspect:M},Pt.clear(),at&&x(mt))}function K(){if(!be){Qe(),be=!0,st();for(let P of y)P.dispose();h.dispose(),h.forceContextLoss()}}return{seek:k,frameHash:oe,ready:pt,dispose:K,resize:ce,...ee?{view:ee}:{}}}var G_=[["iso","Iso","Iso view: the replay's end view"],["top","Top","Top view, the plan's top edge up"],["north","N","View from north: level, from the plan's top edge"],["east","E","View from east: level, from the plan's right edge"],["south","S","View from south: level, from the plan's bottom edge"],["west","W","View from west: level, from the plan's left edge"]],H_="Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";function Tu(i,e={}){let t=document.createElement("div");t.className="archlang-views",t.setAttribute("role","toolbar"),t.setAttribute("aria-label","3D view");let n=(h,d,u)=>{let m=document.createElement("button");return m.type="button",e.buttonClass&&(m.className=e.buttonClass),m.textContent=h,m.setAttribute("aria-label",d),m.addEventListener("click",u),m},s=[],r=[],a=()=>{for(let[h,d]of s)d.setAttribute("aria-pressed",String(i.camera===h));for(let[h,d]of r.entries())d.setAttribute("aria-pressed",String(h+1===i.shown))},o=h=>{};for(let[h,d,u]of G_){let m=n(d,u,()=>{i.preset(h),o(!0)});m.dataset.preset=h,s.push([h,m])}let c="Reset the view: the replay's own camera, every storey shown";if(e.compact){t.classList.add("archlang-views-compact"),t.append(n("\u27F2 Reset",c,()=>i.reset()));let h=document.createElement("span");h.className="archlang-views-menu";let d=document.createElement("span");d.className="archlang-views-presets",d.id=`${e.hintId??"archlang-views"}-presets`,d.setAttribute("role","group"),d.setAttribute("aria-label","Preset views"),d.hidden=!0,d.append(...s.map(([,y])=>y));let u=n("View \u25BE","View presets: iso, top, and from north, east, south and west",()=>d.hidden?_():o(!1));u.setAttribute("aria-expanded","false"),u.setAttribute("aria-controls",d.id);let m=y=>{h.contains(y.target)||o(!1)},_=()=>{d.hidden=!1,u.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",m,!0),(s.find(([y])=>i.camera===y)?.[1]??s[0]?.[1])?.focus()};o=y=>{d.hidden||(d.hidden=!0,u.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",m,!0),y&&u.focus())},h.addEventListener("keydown",y=>{y.key!=="Escape"||d.hidden||(y.preventDefault(),y.stopPropagation(),o(!0))}),h.addEventListener("focusout",y=>{h.contains(y.relatedTarget)||o(!1)}),h.append(u,d),t.append(h)}else t.append(...s.map(([,h])=>h)),t.append(n("Reset",c,()=>i.reset()));if(i.storeys>1&&e.storeys!==!1){let h=document.createElement("span");h.className="archlang-views-storeys",h.setAttribute("role","group"),h.setAttribute("aria-label","Storeys shown"),h.append("Storeys ");for(let d=1;d<=i.storeys;d++){let u=d===i.storeys,m=n(u?"All":d===1?"1":`1\u2013${d}`,u?"Show every storey":`Show storeys 1 to ${d}, hide the ones above`,()=>i.showStoreys(d));m.dataset.storeys=String(d),r.push(m),h.append(m)}t.append(h)}i.onChange(a),a();let l=document.createElement("span");return l.className="archlang-views-hint",e.hintId&&(l.id=e.hintId),l.textContent=H_,t.append(l),t}function W_(){let i=document.getElementById("archlang-replay-payload");return JSON.parse(i?.textContent??"{}")}function X_(){let i=W_(),e=document.getElementById("archlang-replay"),t=document.getElementById("archlang-replay-strip")??void 0,n=0,s=()=>{n&&cancelAnimationFrame(n),n=0},{seek:r,frameHash:a,ready:o,view:c}=wu(e,i,t,{interactive:!0,onTake:s});window.__seek=r,window.__frameHash=a,window.__ready=o.then(()=>r(0));let l=document.getElementById("archlang-replay-views");c&&l&&(l.replaceWith(Tu(c,{hintId:"archlang-replay-hint"})),e.setAttribute("aria-describedby","archlang-replay-hint"));let h=document.getElementById("archlang-replay-t"),d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;window.__ready.then(()=>{if(window.__replayAutoplay===!1)return;if(d){r(1),h&&(h.value="1");return}let u,m=_=>{u??(u=_);let y=Math.min(1,(_-u)/(i.seconds*1e3));r(y),h&&(h.value=String(y)),n=y<1?requestAnimationFrame(m):0};n=requestAnimationFrame(m)}),h?.addEventListener("input",()=>{s(),r(Number(h.value))})}X_();})();
4225
+ }`,Jl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new zs(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){let t=e.cameras[0].viewport,n=new Cn({vertexShader:C0,fragmentShader:P0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kt(new Vs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Kl=class extends bn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",c=1,l=null,h=null,d=null,u=null,p=null,_=null,x=typeof XRWebGLBinding<"u",m=new Jl,f={},w=t.getContextAttributes(),A=null,S=null,M=[],E=[],g=new ke,v=null,N=null,R=new Wt;R.viewport=new gt;let D=new Wt;D.viewport=new gt;let U=[R,D],z=new Mo,I=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let he=M[G];return he===void 0&&(he=new is,M[G]=he),he.getTargetRaySpace()},this.getControllerGrip=function(G){let he=M[G];return he===void 0&&(he=new is,M[G]=he),he.getGripSpace()},this.getHand=function(G){let he=M[G];return he===void 0&&(he=new is,M[G]=he),he.getHandSpace()};function Z(G){let he=E.indexOf(G.inputSource);if(he===-1)return;let fe=M[he];fe!==void 0&&(fe.update(G.inputSource,G.frame,l||o),fe.dispatchEvent({type:G.type,data:G.inputSource}))}function B(){s.removeEventListener("select",Z),s.removeEventListener("selectstart",Z),s.removeEventListener("selectend",Z),s.removeEventListener("squeeze",Z),s.removeEventListener("squeezestart",Z),s.removeEventListener("squeezeend",Z),s.removeEventListener("end",B),s.removeEventListener("inputsourceschange",ee);for(let G=0;G<M.length;G++){let he=E[G];he!==null&&(E[G]=null,M[G].disconnect(he))}I=null,q=null,m.reset();for(let G in f)delete f[G];if(e.setRenderTarget(A),p=null,u=null,d=null,s=null,S=null,we.stop(),n.isPresenting=!1,e.setPixelRatio(v),e.setSize(g.width,g.height,!1),N!==null){let G=N.camera;G.fov=N.fov,G.zoom=N.zoom,G.updateProjectionMatrix(),N=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(G){r=G,n.isPresenting===!0&&Ue("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(G){a=G,n.isPresenting===!0&&Ue("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(G){l=G},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return d===null&&x&&(d=new XRWebGLBinding(s,t)),d},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(G){if(s=G,s!==null){if(A=e.getRenderTarget(),s.addEventListener("select",Z),s.addEventListener("selectstart",Z),s.addEventListener("selectend",Z),s.addEventListener("squeeze",Z),s.addEventListener("squeezestart",Z),s.addEventListener("squeezeend",Z),s.addEventListener("end",B),s.addEventListener("inputsourceschange",ee),w.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(g),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let fe=null,Ee=null,le=null;w.depth&&(le=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,fe=w.stencil?jn:Yn,Ee=w.stencil?Ni:Mn);let ye={colorFormat:t.RGBA8,depthFormat:le,scaleFactor:r};d=this.getBinding(),u=d.createProjectionLayer(ye),s.updateRenderState({layers:[u]}),e.setPixelRatio(1),e.setSize(u.textureWidth,u.textureHeight,!1),S=new ln(u.textureWidth,u.textureHeight,{format:En,type:jt,depthTexture:new Jn(u.textureWidth,u.textureHeight,Ee,void 0,void 0,void 0,void 0,void 0,void 0,fe),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1,storeMultisampledDepthBuffer:u.ignoreDepthValues===!1,storeMultisampledStencilBuffer:u.ignoreDepthValues===!1})}else{let fe={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,t,fe),s.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),S=new ln(p.framebufferWidth,p.framebufferHeight,{format:En,type:jt,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1,storeMultisampledDepthBuffer:p.ignoreDepthValues===!1,storeMultisampledStencilBuffer:p.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await s.requestReferenceSpace(a),we.setContext(s),we.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function ee(G){for(let he=0;he<G.removed.length;he++){let fe=G.removed[he],Ee=E.indexOf(fe);Ee>=0&&(E[Ee]=null,M[Ee].disconnect(fe))}for(let he=0;he<G.added.length;he++){let fe=G.added[he],Ee=E.indexOf(fe);if(Ee===-1){for(let ye=0;ye<M.length;ye++)if(ye>=E.length){E.push(fe),Ee=ye;break}else if(E[ye]===null){E[ye]=fe,Ee=ye;break}if(Ee===-1)break}let le=M[Ee];le&&le.connect(fe)}}function C(G,he){he===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(he.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(s===null)return;let he=G.near,fe=G.far;m.texture!==null&&(m.depthNear>0&&(he=m.depthNear),m.depthFar>0&&(fe=m.depthFar)),z.near=D.near=R.near=he,z.far=D.far=R.far=fe,(I!==z.near||q!==z.far)&&(s.updateRenderState({depthNear:z.near,depthFar:z.far}),I=z.near,q=z.far),z.layers.mask=G.layers.mask|6,R.layers.mask=z.layers.mask&-5,D.layers.mask=z.layers.mask&-3;let Ee=G.parent,le=z.cameras;C(z,Ee);for(let ye=0;ye<le.length;ye++)C(le[ye],Ee);z.projectionMatrix.copy(R.projectionMatrix),z.projectionMatrixInverse.copy(R.projectionMatrixInverse),N===null&&G.isPerspectiveCamera&&(N={camera:G,fov:G.fov,zoom:G.zoom}),W(G,z,Ee)};function W(G,he,fe){fe===null?G.matrix.copy(he.matrixWorld):(G.matrix.copy(fe.matrixWorld),G.matrix.invert(),G.matrix.multiply(he.matrixWorld)),G.matrix.decompose(G.position,G.quaternion,G.scale),G.updateMatrixWorld(!0),G.projectionMatrix.copy(he.projectionMatrix),G.projectionMatrixInverse.copy(he.projectionMatrixInverse),G.isPerspectiveCamera&&(G.fov=ts*2*Math.atan(1/G.projectionMatrix.elements[5]),G.zoom=1)}this.getCamera=function(){return z},this.getFoveation=function(){if(!(u===null&&p===null))return c},this.setFoveation=function(G){c=G,u!==null&&(u.fixedFoveation=G),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=G)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(z)},this.getCameraTexture=function(G){return f[G]};let K=null;function ve(G,he){if(h=he.getViewerPose(l||o),_=he,h!==null){let fe=h.views;p!==null&&(e.setRenderTargetFramebuffer(S,p.framebuffer),e.setRenderTarget(S));let Ee=!1;fe.length!==z.cameras.length&&(z.cameras.length=0,Ee=!0);for(let Me=0;Me<fe.length;Me++){let Fe=fe[Me],Te=null;if(p!==null)Te=p.getViewport(Fe);else{let Je=d.getViewSubImage(u,Fe);Te=Je.viewport,Me===0&&(e.setRenderTargetTextures(S,Je.colorTexture,Je.depthStencilTexture),e.setRenderTarget(S))}let De=U[Me];De===void 0&&(De=new Wt,De.layers.enable(Me),De.viewport=new gt,U[Me]=De),De.matrix.fromArray(Fe.transform.matrix),De.matrix.decompose(De.position,De.quaternion,De.scale),De.projectionMatrix.fromArray(Fe.projectionMatrix),De.projectionMatrixInverse.copy(De.projectionMatrix).invert(),De.viewport.set(Te.x,Te.y,Te.width,Te.height),Me===0&&(z.matrix.copy(De.matrix),z.matrix.decompose(z.position,z.quaternion,z.scale)),Ee===!0&&z.cameras.push(De)}let le=s.enabledFeatures;if(le&&le.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){d=n.getBinding();let Me=d.getDepthInformation(fe[0]);Me&&Me.isValid&&Me.texture&&m.init(Me,s.renderState)}if(le&&le.includes("camera-access")&&x){e.state.unbindTexture(),d=n.getBinding();for(let Me=0;Me<fe.length;Me++){let Fe=fe[Me].camera;if(Fe){let Te=f[Fe];Te||(Te=new zs,f[Fe]=Te);let De=d.getCameraImage(Fe);Te.sourceTexture=De}}}}for(let fe=0;fe<M.length;fe++){let Ee=E[fe],le=M[fe];Ee!==null&&le!==void 0&&le.update(Ee,he,l||o)}K&&K(G,he),he.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:he}),_=null}let we=new iu;we.setAnimationLoop(ve),this.setAnimationLoop=function(G){K=G},this.dispose=function(){}}},I0=new ft,fu=new Ge;fu.set(-1,0,0,0,1,0,0,0,1);function L0(i,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,Dl(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function s(m,f,w,A,S){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(m,f):f.isMeshLambertMaterial?(r(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(m,f),d(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),u(m,f),f.isMeshPhysicalMaterial&&p(m,f,S)):f.isMeshMatcapMaterial?(r(m,f),_(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),x(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(o(m,f),f.isLineDashedMaterial&&a(m,f)):f.isPointsMaterial?c(m,f,w,A):f.isSpriteMaterial?l(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Zt&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Zt&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);let w=e.get(f),A=w.envMap,S=w.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(I0.makeRotationFromEuler(S)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(fu),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function o(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function a(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function c(m,f,w,A){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*w,m.scale.value=A*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function l(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function d(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function u(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,w){m.ior.value=f.ior,f.diffuseRoughness>0&&(m.diffuseRoughness.value=f.diffuseRoughness,f.diffuseRoughnessMap&&(m.diffuseRoughnessMap.value=f.diffuseRoughnessMap,t(f.diffuseRoughnessMap,m.diffuseRoughnessMapTransform))),f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Zt&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.retroreflectivity>0&&(m.retroreflectivity.value=f.retroreflectivity),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessMinimum,m.iridescenceThicknessMaximum.value=f.iridescenceThicknessMaximum,f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,f){f.matcap&&(m.matcap.value=f.matcap)}function x(m,f){let w=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function D0(i,e,t,n){let s={},r={};function o(w,A){let S=A.program;n.uniformBlockBinding(w,S,s[w.id])}function a(w,A){let S=s[w.id];S===void 0&&(_(w),S=c(w),s[w.id]=S,w.addEventListener("dispose",m));let M=A.program;n.updateUBOMapping(w,M);let E=e.render.frame;r[w.id]!==E&&(l(w),r[w.id]=E)}function c(w){let A=i.createBuffer(),S=w.__size,M=w.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,S,M),i.bindBuffer(i.UNIFORM_BUFFER,null),A}function l(w){let A=s[w.id],S=w.uniforms,M=w.__cache;i.bindBuffer(i.UNIFORM_BUFFER,A);for(let E=0,g=S.length;E<g;E++){let v=S[E];if(Array.isArray(v))for(let N=0,R=v.length;N<R;N++)h(v[N],E,N,M);else h(v,E,0,M)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function h(w,A,S,M){if(u(w,A,S,M)===!0){let E=w.__offset,g=w.value;if(Array.isArray(g)){let v=0;for(let N=0;N<g.length;N++){let R=g[N],D=x(R,!0);d(R,w.__data,v),v+=D.storage/Float32Array.BYTES_PER_ELEMENT}}else d(g,w.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,E,w.__data)}}function d(w,A,S){typeof w=="number"||typeof w=="boolean"?A[S]=w:w.isMatrix3?(A[S]=w.elements[0],A[S+1]=w.elements[1],A[S+2]=w.elements[2],A[S+3]=0,A[S+4]=w.elements[3],A[S+5]=w.elements[4],A[S+6]=w.elements[5],A[S+7]=0,A[S+8]=w.elements[6],A[S+9]=w.elements[7],A[S+10]=w.elements[8],A[S+11]=0):ArrayBuffer.isView(w)?A.set(w.subarray(0,A.length-S),S):w.toArray(A,S)}function u(w,A,S,M){let E=w.value,g=A+"_"+S;if(Array.isArray(E)){M[g]===void 0&&(M[g]=[]);let v=M[g],N=!1;for(let R=0;R<E.length;R++)p(E[R],v,R)===!0&&(N=!0);return N}return p(E,M,g)}function p(w,A,S){if(A[S]===void 0)return typeof w=="number"||typeof w=="boolean"?A[S]=w:ArrayBuffer.isView(w)?A[S]=w.slice():A[S]=w.clone(),!0;{let M=A[S];if(typeof w=="number"||typeof w=="boolean"){if(M!==w)return A[S]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(M.equals(w)===!1)return M.copy(w),!0}}return!1}function _(w){let A=w.uniforms,S=0,M=16;for(let g=0,v=A.length;g<v;g++){let N=Array.isArray(A[g])?A[g]:[A[g]];for(let R=0,D=N.length;R<D;R++){let U=N[R],z=Array.isArray(U.value)?U.value:[U.value],I=Array.isArray(A[g])||Array.isArray(U.value),q=S;for(let B=0,ee=z.length;B<ee;B++){let C=z[B],W=x(C,I),K=S%M,ve=K%W.boundary,we=K+ve;S+=ve,we!==0&&M-we<W.storage&&(S+=M-we),B===0&&(q=S),S+=W.storage}let Z=U.type==="int"?Int32Array:U.type==="uint"?Uint32Array:Float32Array;U.__data=new Z((S-q)/Float32Array.BYTES_PER_ELEMENT),U.__offset=q}}let E=S%M;return E>0&&(S+=M-E),w.__size=S,w.__cache={},this}function x(w,A){let S={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(S.boundary=4,S.storage=4):w.isVector2?(S.boundary=8,S.storage=8):w.isVector3||w.isColor?(S.boundary=16,S.storage=12):w.isVector4?(S.boundary=16,S.storage=16):w.isMatrix3?(S.boundary=16,S.storage=48):w.isMatrix4?(S.boundary=16,S.storage=64):w.isTexture?Ue("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(w)?(S.boundary=16,S.storage=w.byteLength):Ue("WebGLRenderer: Unsupported uniform value type.",w),A===!0&&(S.boundary=16,S.storage=Math.ceil(S.storage/16)*16),S}function m(w){let A=w.target;A.removeEventListener("dispose",m),i.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function f(){for(let w in s)i.deleteBuffer(s[w]);s={},r={}}return{bind:o,update:a,dispose:f}}var N0=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]),In=null;function U0(){return In===null&&(In=new no(N0,16,16,_i,wn),In.name="DFG_LUT",In.minFilter=qt,In.magFilter=qt,In.wrapS=An,In.wrapT=An,In.generateMipmaps=!1,In.needsUpdate=!0),In}var pa=class{constructor(e={}){let{canvas:t=Th(),context:n=null,depth:s=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:u=!1,outputBufferType:p=jt}=e;this.isWebGLRenderer=!0;let _;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");_=n.getContextAttributes().alpha}else _=o;let x=p,m=new Set([Do,Lo,Io]),f=new Set([jt,Mn,ps,Ni,Co,Po]),w=new Uint32Array(4),A=new Int32Array(4),S={textures:[],min:[],max:[],resolution:[]},M=null,E=null,g=[],v=[],N=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Pn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let R=this,D=!1,U=null,z=null,I=null,q=null;this._outputColorSpace=rn;let Z=0,B=0,ee=null,C=-1,W=null,K=new gt,ve=new gt,we=null,G=new We(0),he=0,fe=t.width,Ee=t.height,le=1,ye=null,Ve=null,Me=new gt(0,0,fe,Ee),Fe=new gt(0,0,fe,Ee),Te=!1,De=new hi,Je=new io,ct=!1,yt=!1,et=new ft,pt=new k,Xe=new gt,vt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Lt=!1;function Ft(){return ee===null?le:1}let O=n;function Rt(b,F){return t.getContext(b,F)}let it,st,_e,mt,Le,Oe,T,y,V,ae,se,ue,me,j,Q,pe,L,te,P,ne,$,ie,oe;try{let b={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",de,!1),t.addEventListener("webglcontextrestored",Ie,!1),t.addEventListener("webglcontextcreationerror",ce,!1),O===null){let F="webgl2";if(O=Rt(F,b),O===null)throw Rt(F)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}re()}catch(b){throw t.removeEventListener("webglcontextlost",de,!1),t.removeEventListener("webglcontextrestored",Ie,!1),t.removeEventListener("webglcontextcreationerror",ce,!1),ze("WebGLRenderer: "+b.message),b}function re(){it=new qm(O),it.init(),$=new R0(O,it),st=new Um(O,it,e,$),_e=new T0(O,it),st.reversedDepthBuffer&&u&&_e.buffers.depth.setReversed(!0),z=O.createFramebuffer(),I=O.createFramebuffer(),q=O.createFramebuffer(),mt=new $m(O),Le=new d0,Oe=new A0(O,it,_e,Le,st,$,mt),T=new Xm(R),y=new Jd(O),ie=new Dm(O,y),V=new Ym(O,y,mt,ie),ae=new Km(O,V,y,ie,mt),te=new Jm(O,st,Oe),Q=new Fm(Le),se=new u0(R,T,it,st,ie,Q),ue=new L0(R,Le),me=new p0,j=new v0(it),L=new Lm(R,T,_e,ae,_,c),pe=new E0(R,ae,st),oe=new D0(O,mt,st,_e),P=new Nm(O,it,mt),ne=new Zm(O,it,mt),mt.programs=se.programs,R.capabilities=st,R.extensions=it,R.properties=Le,R.renderLists=me,R.shadowMap=pe,R.state=_e,R.info=mt}x!==jt&&(N=new Qm(x,t.width,t.height,a,s,r));let J=new Kl(R,O);this.xr=J,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){let b=it.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){let b=it.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return le},this.setPixelRatio=function(b){b!==void 0&&(le=b,this.setSize(fe,Ee,!1))},this.getSize=function(b){return b.set(fe,Ee)},this.setSize=function(b,F,Y=!0){if(J.isPresenting){Ue("WebGLRenderer: Can't change size while VR device is presenting.");return}fe=b,Ee=F,t.width=Math.floor(b*le),t.height=Math.floor(F*le),Y===!0&&(t.style.width=b+"px",t.style.height=F+"px"),N!==null&&N.setSize(t.width,t.height),this.setViewport(0,0,b,F)},this.getDrawingBufferSize=function(b){return b.set(fe*le,Ee*le).floor()},this.setDrawingBufferSize=function(b,F,Y){fe=b,Ee=F,le=Y,t.width=Math.floor(b*Y),t.height=Math.floor(F*Y),this.setViewport(0,0,b,F)},this.setEffects=function(b){if(x===jt){ze("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let F=0;F<b.length;F++)if(b[F].isOutputPass===!0){Ue("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}N.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(K)},this.getViewport=function(b){return b.copy(Me)},this.setViewport=function(b,F,Y,H){b.isVector4?Me.set(b.x,b.y,b.z,b.w):Me.set(b,F,Y,H),_e.viewport(K.copy(Me).multiplyScalar(Ft()).round())},this.getScissor=function(b){return b.copy(Fe)},this.setScissor=function(b,F,Y,H){b.isVector4?Fe.set(b.x,b.y,b.z,b.w):Fe.set(b,F,Y,H),_e.scissor(ve.copy(Fe).multiplyScalar(Ft()).round())},this.getScissorTest=function(){return Te},this.setScissorTest=function(b){_e.setScissorTest(Te=b)},this.setOpaqueSort=function(b){ye=b},this.setTransparentSort=function(b){Ve=b},this.getClearColor=function(b){return b.copy(L.getClearColor())},this.setClearColor=function(){L.setClearColor(...arguments)},this.getClearAlpha=function(){return L.getClearAlpha()},this.setClearAlpha=function(){L.setClearAlpha(...arguments)},this.clear=function(b=!0,F=!0,Y=!0){let H=0;if(b){let X=!1;if(ee!==null){let xe=ee.texture.format;X=m.has(xe)}if(X){let xe=ee.texture.type,Ae=f.has(xe),ge=L.getClearColor(),Se=L.getClearAlpha(),Pe=ge.r,He=ge.g,Ke=ge.b;Ae?(w[0]=Pe,w[1]=He,w[2]=Ke,w[3]=Se,O.clearBufferuiv(O.COLOR,0,w)):(A[0]=Pe,A[1]=He,A[2]=Ke,A[3]=Se,O.clearBufferiv(O.COLOR,0,A))}else H|=O.COLOR_BUFFER_BIT}F&&(H|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(H|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H!==0&&O.clear(H)},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(b){b.setRenderer(this),U=b},this.dispose=function(){t.removeEventListener("webglcontextlost",de,!1),t.removeEventListener("webglcontextrestored",Ie,!1),t.removeEventListener("webglcontextcreationerror",ce,!1),L.dispose(),me.dispose(),j.dispose(),Oe.dispose(),Le.dispose(),T.dispose(),ae.dispose(),V.dispose(),ie.dispose(),oe.dispose(),se.dispose(),J.dispose(),J.removeEventListener("sessionstart",at),J.removeEventListener("sessionend",tn),Be.stop()};function de(b){b.preventDefault(),Rl("WebGLRenderer: Context Lost."),D=!0}function Ie(){Rl("WebGLRenderer: Context Restored."),D=!1;let b=mt.autoReset,F=pe.enabled,Y=pe.autoUpdate,H=pe.needsUpdate,X=pe.type;re(),mt.autoReset=b,pe.enabled=F,pe.autoUpdate=Y,pe.needsUpdate=H,pe.type=X}function ce(b){ze("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Ne(b){let F=b.target;F.removeEventListener("dispose",Ne),tt(F)}function tt(b){_t(b),Le.remove(b)}function _t(b){let F=Le.get(b).programs;F!==void 0&&(F.forEach(function(Y){se.releaseProgram(Y)}),b.isShaderMaterial&&se.releaseShaderCache(b))}this.renderBufferDirect=function(b,F,Y,H,X,xe){F===null&&(F=vt);let Ae=X.isMesh&&X.matrixWorld.determinantAffine()<0,ge=$u(b,F,Y,H,X);_e.setMaterial(H,Ae);let Se=Y.index,Pe=1;if(H.wireframe===!0){if(Se=V.getWireframeAttribute(Y),Se===void 0)return;Pe=2}let He=Y.drawRange,Ke=Y.attributes.position,Re=He.start*Pe,je=(He.start+He.count)*Pe;xe!==null&&(Re=Math.max(Re,xe.start*Pe),je=Math.min(je,(xe.start+xe.count)*Pe)),Se!==null?(Re=Math.max(Re,0),je=Math.min(je,Se.count)):Ke!=null&&(Re=Math.max(Re,0),je=Math.min(je,Ke.count));let Mt=je-Re;if(Mt<0||Mt===1/0)return;ie.setup(X,H,ge,Y,Se);let ut,ht=P;if(Se!==null&&(ut=y.get(Se),ht=ne,ht.setIndex(ut)),X.isMesh)H.wireframe===!0?(_e.setLineWidth(H.wireframeLinewidth*Ft()),ht.setMode(O.LINES)):ht.setMode(O.TRIANGLES);else if(X.isLine){let Ot=H.linewidth;Ot===void 0&&(Ot=1),_e.setLineWidth(Ot*Ft()),X.isLineSegments?ht.setMode(O.LINES):X.isLineLoop?ht.setMode(O.LINE_LOOP):ht.setMode(O.LINE_STRIP)}else X.isPoints?ht.setMode(O.POINTS):X.isSprite&&ht.setMode(O.TRIANGLES);if(X.isBatchedMesh)if(it.get("WEBGL_multi_draw"))ht.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{let Ot=X._multiDrawStarts,Ce=X._multiDrawCounts,Ht=X._multiDrawCount,rt=Se?y.get(Se).bytesPerElement:1,bi=Le.get(H).currentProgram.getUniforms();for(let Bt=0;Bt<Ht;Bt++)bi.setValue(O,"_gl_DrawID",Bt),ht.render(Ot[Bt]/rt,Ce[Bt])}else if(X.isInstancedMesh)ht.renderInstances(Re,Mt,X.count);else if(Y.isInstancedBufferGeometry){let Ot=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,Ce=Math.min(Y.instanceCount,Ot);ht.renderInstances(Re,Mt,Ce)}else ht.render(Re,Mt)};function qe(b,F,Y,H){U!==null&&b.isNodeMaterial&&U.setObject(H,b),ct===!0&&Q.setState(b,Y,!1),b.transparent===!0&&b.side===pn&&b.forceSinglePass===!1?(b.side=Zt,b.needsUpdate=!0,ni(b,F,H),b.side=gi,b.needsUpdate=!0,ni(b,F,H),b.side=pn):ni(b,F,H)}this.compile=function(b,F,Y=null){Y===null&&(Y=b),U!==null&&U.renderStart(b,F,Y),E=j.get(Y),E.init(F),v.push(E),Y.traverseVisible(function(X){X.isLight&&X.layers.test(F.layers)&&(E.pushLight(X),X.castShadow&&E.pushShadow(X))}),b!==Y&&b.traverseVisible(function(X){X.isLight&&X.layers.test(F.layers)&&(E.pushLight(X),X.castShadow&&E.pushShadow(X))}),E.setupLights(),U!==null&&U.updateLights(E.state.lightsArray),yt=this.localClippingEnabled,ct=Q.init(this.clippingPlanes,yt),ct===!0&&Q.setGlobalState(this.clippingPlanes,F),U!==null&&pe.render(E.state.shadowsArray,Y,F);let H=new Set;return b.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;let xe=X.material;if(xe)if(Array.isArray(xe))for(let Ae=0;Ae<xe.length;Ae++){let ge=xe[Ae];qe(ge,Y,F,X),H.add(ge)}else qe(xe,Y,F,X),H.add(xe)}),E=v.pop(),U!==null&&U.renderEnd(),H},this.compileAsync=function(b,F,Y=null){let H=this.compile(b,F,Y);return new Promise(X=>{function xe(){if(H.forEach(function(Ae){let Se=Le.get(Ae).currentProgram;(Se===void 0||Se.isReady())&&H.delete(Ae)}),H.size===0){X(b);return}setTimeout(xe,10)}it.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let bt=null;function Dt(b){bt&&bt(b)}function at(){Be.stop()}function tn(){Be.start()}let Be=new iu;Be.setAnimationLoop(Dt),typeof self<"u"&&Be.setContext(self),this.setAnimationLoop=function(b){bt=b,J.setAnimationLoop(b),b===null?Be.stop():Be.start()},J.addEventListener("sessionstart",at),J.addEventListener("sessionend",tn),this.render=function(b,F){if(F!==void 0&&F.isCamera!==!0){ze("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;U!==null&&U.renderStart(b,F);let Y=J.enabled===!0&&J.isPresenting===!0,H=N!==null&&(ee===null||Y)&&N.begin(R,ee);if(b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),F.parent===null&&F.matrixWorldAutoUpdate===!0&&F.updateMatrixWorld(),J.enabled===!0&&J.isPresenting===!0&&(N===null||N.isCompositing()===!1)&&(J.cameraAutoUpdate===!0&&J.updateCamera(F),F=J.getCamera()),b.isScene===!0&&b.onBeforeRender(R,b,F,ee),E=j.get(b,v.length),E.init(F),E.state.textureUnits=Oe.getTextureUnits(),v.push(E),et.multiplyMatrices(F.projectionMatrix,F.matrixWorldInverse),F.isArrayCamera?Je.setFromArrayCamera(F):De.setFromProjectionMatrix(et,fn,F.reversedDepth),yt=this.localClippingEnabled,ct=Q.init(this.clippingPlanes,yt),M=me.get(b,g.length),M.init(),g.push(M),this.info.render.frame++,J.enabled===!0&&J.isPresenting===!0){let Ae=R.xr.getDepthSensingMesh();Ae!==null&&hn(Ae,F,-1/0,R.sortObjects)}hn(b,F,0,R.sortObjects),M.finish(),U!==null&&U.updateLights(E.state.lightsArray),R.sortObjects===!0&&M.sort(ye,Ve),Lt=J.enabled===!1||J.isPresenting===!1||J.hasDepthSensing()===!1,Lt&&L.addToRenderList(M,b),this.info.autoReset===!0&&this.info.reset(),ct===!0&&Q.beginShadows();let X=E.state.shadowsArray;if(pe.render(X,b,F),ct===!0&&Q.endShadows(),(H&&N.hasRenderPass())===!1){let Ae=M.opaque,ge=M.transmissive;if(E.setupLights(),F.isArrayCamera){let Se=F.cameras;if(ge.length>0)for(let Pe=0,He=Se.length;Pe<He;Pe++){let Ke=Se[Pe];On(Ae,ge,b,Ke)}Lt&&L.render(b);for(let Pe=0,He=Se.length;Pe<He;Pe++){let Ke=Se[Pe];un(M,b,Ke,Ke.viewport)}}else ge.length>0&&On(Ae,ge,b,F),Lt&&L.render(b),un(M,b,F)}ee!==null&&B===0&&(Oe.updateMultisampleRenderTarget(ee),Oe.updateRenderTargetMipmap(ee)),H&&N.end(R),b.isScene===!0&&b.onAfterRender(R,b,F),ie.resetDefaultState(),C=-1,W=null,v.pop(),v.length>0?(E=v[v.length-1],Oe.setTextureUnits(E.state.textureUnits),ct===!0&&Q.setGlobalState(R.clippingPlanes,E.state.camera)):E=null,g.pop(),g.length>0?M=g[g.length-1]:M=null,U!==null&&U.renderEnd()};function hn(b,F,Y,H){if(b.visible===!1)return;if(b.layers.test(F.layers)){if(b.isGroup)Y=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(F);else if(b.isLight)E.pushLight(b),b.castShadow&&E.pushShadow(b);else if(b.isSprite){let Ae=F.isArrayCamera?Je:De;if(!b.frustumCulled||b.intersectsFrustum(Ae)){H&&Xe.setFromMatrixPosition(b.matrixWorld).applyMatrix4(et);let ge=ae.update(b),Se=b.material;Se.visible&&M.push(b,ge,Se,Y,Xe.z,null,F)}}else if(b.isMesh||b.isLine||b.isPoints){let Ae=F.isArrayCamera?Je:De;if(!b.frustumCulled||b.intersectsFrustum(Ae)){let ge=ae.update(b),Se=b.material;if(H&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),Xe.copy(b.boundingSphere.center)):(ge.boundingSphere===null&&ge.computeBoundingSphere(),Xe.copy(ge.boundingSphere.center)),Xe.applyMatrix4(b.matrixWorld).applyMatrix4(et)),Array.isArray(Se)){let Pe=ge.groups;for(let He=0,Ke=Pe.length;He<Ke;He++){let Re=Pe[He],je=Se[Re.materialIndex];je&&je.visible&&M.push(b,ge,je,Y,Xe.z,Re,F)}}else Se.visible&&M.push(b,ge,Se,Y,Xe.z,null,F)}}}let xe=b.children;for(let Ae=0,ge=xe.length;Ae<ge;Ae++)hn(xe[Ae],F,Y,H)}function un(b,F,Y,H){let{opaque:X,transmissive:xe,transparent:Ae}=b;E.setupLightsView(Y),ct===!0&&Q.setGlobalState(R.clippingPlanes,Y),H&&_e.viewport(K.copy(H)),X.length>0&&Bn(X,F,Y),xe.length>0&&Bn(xe,F,Y),Ae.length>0&&Bn(Ae,F,Y),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function On(b,F,Y,H){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(E.state.transmissionRenderTarget[H.id]===void 0){let Re=it.has("EXT_color_buffer_half_float")||it.has("EXT_color_buffer_float");E.state.transmissionRenderTarget[H.id]=new ln(1,1,{generateMipmaps:!0,type:Re?wn:jt,minFilter:Kn,samples:Math.max(4,st.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:Qe.workingColorSpace})}let xe=E.state.transmissionRenderTarget[H.id],Ae=H.viewport||K;xe.setSize(Ae.z*R.transmissionResolutionScale,Ae.w*R.transmissionResolutionScale);let ge=R.getRenderTarget(),Se=R.getActiveCubeFace(),Pe=R.getActiveMipmapLevel();R.setRenderTarget(xe),R.getClearColor(G),he=R.getClearAlpha(),he<1&&R.setClearColor(16777215,.5),R.clear(),Lt&&L.render(Y);let He=R.toneMapping;R.toneMapping=Pn;let Ke=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),E.setupLightsView(H),ct===!0&&Q.setGlobalState(R.clippingPlanes,H),Bn(b,Y,H),Oe.updateMultisampleRenderTarget(xe),Oe.updateRenderTargetMipmap(xe),it.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let je=0,Mt=F.length;je<Mt;je++){let ut=F[je],{object:ht,geometry:Ot,material:Ce,group:Ht}=ut;if(Ce.side===pn&&ht.layers.test(H.layers)){let rt=Ce.side;Ce.side=Zt,Ce.needsUpdate=!0,ys(ht,Y,H,Ot,Ce,Ht),Ce.side=rt,Ce.needsUpdate=!0,Re=!0}}Re===!0&&(Oe.updateMultisampleRenderTarget(xe),Oe.updateRenderTargetMipmap(xe))}R.setRenderTarget(ge,Se,Pe),R.setClearColor(G,he),Ke!==void 0&&(H.viewport=Ke),R.toneMapping=He}function Bn(b,F,Y){let H=F.isScene===!0?F.overrideMaterial:null;for(let X=0,xe=b.length;X<xe;X++){let Ae=b[X],{object:ge,geometry:Se,group:Pe}=Ae,He=Ae.material;He.allowOverride===!0&&H!==null&&(He=H),ge.layers.test(Y.layers)&&ys(ge,F,Y,Se,He,Pe)}}function ys(b,F,Y,H,X,xe){U!==null&&X.isNodeMaterial&&U.setObject(b,X),b.onBeforeRender(R,F,Y,H,X,xe),b.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),X.onBeforeRender(R,F,Y,H,b,xe),X.transparent===!0&&X.side===pn&&X.forceSinglePass===!1?(X.side=Zt,X.needsUpdate=!0,R.renderBufferDirect(Y,F,H,X,b,xe),X.side=gi,X.needsUpdate=!0,R.renderBufferDirect(Y,F,H,X,b,xe),X.side=pn):R.renderBufferDirect(Y,F,H,X,b,xe),b.onAfterRender(R,F,Y,H,X,xe)}function vs(b){let F=0;for(let Y of b)Y.texture!==null&&F++;return F}function ni(b,F,Y){F.isScene!==!0&&(F=vt);let H=Le.get(b),X=E.state.lights,xe=E.state.shadowsArray,Ae=X.state.version,ge=se.getParameters(b,X.state,xe,F,Y,E.state.lightProbeGridArray),Se=se.getProgramCacheKey(ge),Pe=H.programs;H.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?F.environment:null,H.fog=F.fog;let He=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;H.envMap=T.get(b.envMap||H.environment,He),H.envMapRotation=H.environment!==null&&b.envMap===null?F.environmentRotation:b.envMapRotation,Pe===void 0&&(b.addEventListener("dispose",Ne),Pe=new Map,H.programs=Pe,H.programVariants=new Map);let Ke=Pe.get(Se);if(Ke!==void 0){if(H.currentProgram===Ke&&H.lightsStateVersion===Ae)return gc(b,ge),Ke}else ge.uniforms=se.getUniforms(b),U!==null&&b.isNodeMaterial&&U.build(b,Y,ge),b.onBeforeCompile(ge,R),Ke=se.acquireProgram(ge,Se),Pe.set(Se,Ke),H.uniforms=ge.uniforms;let Re=H.uniforms;return(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(Re.clippingPlanes=Q.uniform),gc(b,ge),H.needsLights=Ku(b),H.lightsStateVersion=Ae,H.needsLights&&(Re.ambientLightColor.value=X.state.ambient,Re.lightProbe.value=X.state.probe,Re.sunLights.value=X.state.sun,Re.sunLightShadows.value=X.state.sunShadow,Re.directionalLights.value=X.state.directional,Re.directionalLightShadows.value=X.state.directionalShadow,Re.spotLights.value=X.state.spot,Re.spotLightShadows.value=X.state.spotShadow,Re.rectAreaLights.value=X.state.rectArea,Re.ltc_1.value=X.state.rectAreaLTC1,Re.ltc_2.value=X.state.rectAreaLTC2,Re.pointLights.value=X.state.point,Re.pointLightShadows.value=X.state.pointShadow,Re.hemisphereLights.value=X.state.hemi,Re.sunShadowMatrix.value=X.state.sunShadowMatrix,Re.sunShadowCascade.value=X.state.sunShadowCascade,Re.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Re.spotLightMatrix.value=X.state.spotLightMatrix,Re.spotLightMap.value=X.state.spotLightMap,Re.pointShadowMatrix.value=X.state.pointShadowMatrix),H.numLightProbeGrids=vs(E.state.lightProbeGridArray),H.currentProgram=Ke,H.uniformsList=null,Ke}function pr(b,F,Y,H,X){let xe=Le.get(b),Ae=xe.currentProgram.id+","+H+","+X,ge=xe.programVariants.get(Ae);return ge===void 0?(ge=ni(b,F,Y),xe.programVariants.set(Ae,ge)):(xe.currentProgram=ge,xe.uniformsList=null,xe.outputColorSpace=H,xe.toneMapping=X),ge}function mc(b){if(b.uniformsList===null){let F=b.currentProgram.getUniforms();b.uniformsList=gs.seqWithValue(F.seq,b.uniforms)}return b.uniformsList}function gc(b,F){let Y=Le.get(b);Y.outputColorSpace=F.outputColorSpace,Y.batching=F.batching,Y.batchingColor=F.batchingColor,Y.instancing=F.instancing,Y.instancingColor=F.instancingColor,Y.instancingMorph=F.instancingMorph,Y.skinning=F.skinning,Y.morphTargets=F.morphTargets,Y.morphNormals=F.morphNormals,Y.morphColors=F.morphColors,Y.morphTargetsCount=F.morphTargetsCount,Y.numClippingPlanes=F.numClippingPlanes,Y.numIntersection=F.numClipIntersection,Y.vertexAlphas=F.vertexAlphas,Y.vertexTangents=F.vertexTangents,Y.toneMapping=F.toneMapping}function $u(b,F,Y,H,X){F.isScene!==!0&&(F=vt),Oe.resetTextureUnits();let xe=F.fog,Ae=H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial?F.environment:null,ge=ee===null?R.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:Qe.workingColorSpace,Se=H.isMeshStandardMaterial||H.isMeshLambertMaterial&&!H.envMap||H.isMeshPhongMaterial&&!H.envMap,Pe=T.get(H.envMap||Ae,Se),He=H.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,Ke=!!Y.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Re=!!Y.morphAttributes.position,je=!!Y.morphAttributes.normal,Mt=!!Y.morphAttributes.color,ut=Pn;H.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(ut=R.toneMapping);let ht=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Ot=ht!==void 0?ht.length:0,Ce=Le.get(H),Ht=E.state.lights;if(ct===!0&&(yt===!0||b!==W)){let xt=b===W&&H.id===C;Q.setState(H,b,xt)}let rt=!1,bi=!1;H.version===Ce.__version?Ce.needsLights&&Ce.lightsStateVersion!==Ht.state.version||X.isBatchedMesh&&Ce.batching===!1||!X.isBatchedMesh&&Ce.batching===!0||X.isBatchedMesh&&Ce.batchingColor===!0&&X._colorsTexture===null||X.isBatchedMesh&&Ce.batchingColor===!1&&X._colorsTexture!==null||X.isInstancedMesh&&Ce.instancing===!1||!X.isInstancedMesh&&Ce.instancing===!0||X.isSkinnedMesh&&Ce.skinning===!1||!X.isSkinnedMesh&&Ce.skinning===!0||X.isInstancedMesh&&Ce.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&Ce.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&Ce.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&Ce.instancingMorph===!1&&X.morphTexture!==null||Ce.envMap!==Pe||H.fog===!0&&Ce.fog!==xe||Ce.numClippingPlanes!==void 0&&(Ce.numClippingPlanes!==Q.numPlanes||Ce.numIntersection!==Q.numIntersection)||Ce.vertexAlphas!==He||Ce.vertexTangents!==Ke||Ce.morphTargets!==Re||Ce.morphNormals!==je||Ce.morphColors!==Mt||Ce.morphTargetsCount!==Ot||Ce.numLightProbeGrids!==vs(E.state.lightProbeGridArray)?rt=!0:(Ce.outputColorSpace!==ge||Ce.toneMapping!==ut)&&(bi=!0):(rt=!0,Ce.__version=H.version);let Bt=Ce.currentProgram;(rt===!0||bi===!0)&&(Bt=bi===!0?pr(H,F,X,ge,ut):ni(H,F,X),U&&H.isNodeMaterial&&U.onUpdateProgram(H,Bt,Ce));let mr=!1,ii=!1,Mi=!1,nt=Bt.getUniforms(),Nt=Ce.uniforms;if(_e.useProgram(Bt.program)&&(mr=!0,ii=!0,Mi=!0),H.id!==C&&(C=H.id,ii=!0),mr||W!==b){_e.buffers.depth.getReversed()&&b.reversedDepth!==!0&&(b._reversedDepth=!0,b.updateProjectionMatrix()),nt.setValue(O,"projectionMatrix",b.projectionMatrix),nt.setValue(O,"viewMatrix",b.matrixWorldInverse);let Ct=nt.map.cameraPosition;Ct!==void 0&&Ct.setValue(O,pt.setFromMatrixPosition(b.matrixWorld)),st.logarithmicDepthBuffer&&nt.setValue(O,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&nt.setValue(O,"isOrthographic",b.isOrthographicCamera===!0),W!==b&&(W=b,ii=!0,Mi=!0)}if(Ce.needsLights&&(Ht.state.sunShadowMap.length>0&&nt.setValue(O,"sunShadowMap",Ht.state.sunShadowMap,Oe),Ht.state.directionalShadowMap.length>0&&nt.setValue(O,"directionalShadowMap",Ht.state.directionalShadowMap,Oe),Ht.state.spotShadowMap.length>0&&nt.setValue(O,"spotShadowMap",Ht.state.spotShadowMap,Oe),Ht.state.pointShadowMap.length>0&&nt.setValue(O,"pointShadowMap",Ht.state.pointShadowMap,Oe)),X.isSkinnedMesh){nt.setOptional(O,X,"bindMatrix"),nt.setOptional(O,X,"bindMatrixInverse");let xt=X.skeleton;xt&&(xt.boneTexture===null&&xt.computeBoneTexture(),nt.setValue(O,"boneTexture",xt.boneTexture,Oe))}X.isBatchedMesh&&(nt.setOptional(O,X,"batchingTexture"),nt.setValue(O,"batchingTexture",X._matricesTexture,Oe),nt.setOptional(O,X,"batchingIdTexture"),nt.setValue(O,"batchingIdTexture",X._indirectTexture,Oe),nt.setOptional(O,X,"batchingColorTexture"),X._colorsTexture!==null&&nt.setValue(O,"batchingColorTexture",X._colorsTexture,Oe));let gn=Y.morphAttributes;if((gn.position!==void 0||gn.normal!==void 0||gn.color!==void 0)&&te.update(X,Y,Bt),(ii||Ce.receiveShadow!==X.receiveShadow)&&(Ce.receiveShadow=X.receiveShadow,nt.setValue(O,"receiveShadow",X.receiveShadow)),(H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial)&&H.envMap===null&&F.environment!==null&&(Nt.envMapIntensity.value=F.environmentIntensity),Nt.dfgLUT!==void 0&&(Nt.dfgLUT.value=U0()),ii){if(nt.setValue(O,"toneMappingExposure",R.toneMappingExposure),Ce.needsLights&&Ju(Nt,Mi),xe&&H.fog===!0&&ue.refreshFogUniforms(Nt,xe),ue.refreshMaterialUniforms(Nt,H,le,Ee,E.state.transmissionRenderTarget[b.id]),Ce.needsLights&&Ce.numLightProbeGrids>0){let xt=S,Ct=0;for(let zn of E.state.lightProbeGridArray)zn.texture!==null&&(xt.textures[Ct]=zn.texture,xt.min[Ct]=zn.boundingBox.min,xt.max[Ct]=zn.boundingBox.max,xt.resolution[Ct]=zn.resolution,Ct++);for(let zn in xt)xt[zn].length=Ct;Nt.probesSH.value=xt.textures,Nt.probesMin.value=xt.min,Nt.probesMax.value=xt.max,Nt.probesResolution.value=xt.resolution}gs.upload(O,mc(Ce),Nt,Oe)}if(H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(gs.upload(O,mc(Ce),Nt,Oe),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&nt.setValue(O,"center",X.center),nt.setValue(O,"modelViewMatrix",X.modelViewMatrix),nt.setValue(O,"normalMatrix",X.normalMatrix),nt.setValue(O,"modelMatrix",X.matrixWorld),H.uniformsGroups!==void 0){let xt=H.uniformsGroups;for(let Ct=0,zn=xt.length;Ct<zn;Ct++){let xc=xt[Ct];oe.update(xc,Bt),oe.bind(xc,Bt)}}return Bt}function Ju(b,F){b.ambientLightColor.needsUpdate=F,b.lightProbe.needsUpdate=F,b.sunLights.needsUpdate=F,b.sunLightShadows.needsUpdate=F,b.directionalLights.needsUpdate=F,b.directionalLightShadows.needsUpdate=F,b.pointLights.needsUpdate=F,b.pointLightShadows.needsUpdate=F,b.spotLights.needsUpdate=F,b.spotLightShadows.needsUpdate=F,b.rectAreaLights.needsUpdate=F,b.hemisphereLights.needsUpdate=F}function Ku(b){return b.isMeshLambertMaterial||b.isMeshToonMaterial||b.isMeshPhongMaterial||b.isMeshStandardMaterial||b.isShadowMaterial||b.isShaderMaterial&&b.lights===!0}this.getActiveCubeFace=function(){return Z},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return ee},this.setRenderTargetTextures=function(b,F,Y){let H=Le.get(b);H.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),Le.get(b.texture).__webglTexture=F,Le.get(b.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:Y,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,F){let Y=Le.get(b);Y.__webglFramebuffer=F,Y.__useDefaultFramebuffer=F===void 0},this.setRenderTarget=function(b,F=0,Y=0){ee=b,Z=F,B=Y;let H=null,X=!1,xe=!1;if(b){let ge=Le.get(b);if(ge.__useDefaultFramebuffer!==void 0){_e.bindFramebuffer(O.FRAMEBUFFER,ge.__webglFramebuffer),K.copy(b.viewport),ve.copy(b.scissor),we=b.scissorTest,_e.viewport(K),_e.scissor(ve),_e.setScissorTest(we),C=-1;return}else if(ge.__webglFramebuffer===void 0)Oe.setupRenderTarget(b);else if(ge.__hasExternalTextures)Oe.rebindTextures(b,Le.get(b.texture).__webglTexture,Le.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let He=b.depthTexture;if(ge.__boundDepthTexture!==He){if(He!==null&&Le.has(He)&&(b.width!==He.image.width||b.height!==He.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Oe.setupDepthRenderbuffer(b)}}let Se=b.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(xe=!0);let Pe=Le.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(Array.isArray(Pe[F])?H=Pe[F][Y]:H=Pe[F],X=!0):b.samples>0&&Oe.useMultisampledRTT(b)===!1?H=Le.get(b).__webglMultisampledFramebuffer:Array.isArray(Pe)?H=Pe[Y]:H=Pe,K.copy(b.viewport),ve.copy(b.scissor),we=b.scissorTest}else K.copy(Me).multiplyScalar(le).floor(),ve.copy(Fe).multiplyScalar(le).floor(),we=Te;if(Y!==0&&(H=z),_e.bindFramebuffer(O.FRAMEBUFFER,H)&&_e.drawBuffers(b,H),_e.viewport(K),_e.scissor(ve),_e.setScissorTest(we),X){let ge=Le.get(b.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+F,ge.__webglTexture,Y)}else if(xe){let ge=F;for(let Se=0;Se<b.textures.length;Se++){let Pe=Le.get(b.textures[Se]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+Se,Pe.__webglTexture,Y,ge)}}else if(b!==null&&Y!==0){let ge=Le.get(b.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,ge.__webglTexture,Y)}C=-1};function _c(b){let F=Le.get(b);return(F.__readFormat!==b.format||F.__readType!==b.type)&&(F.__readFormat=b.format,F.__readType=b.type,F.__formatReadable=st.textureFormatReadable(b.format),F.__typeReadable=st.textureTypeReadable(b.type)),F}this.readRenderTargetPixels=function(b,F,Y,H,X,xe,Ae,ge=0){if(!(b&&b.isWebGLRenderTarget)){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=Le.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ae!==void 0&&(Se=Se[Ae],Array.isArray(Se)&&(Se=Se[0])),Se){_e.bindFramebuffer(O.FRAMEBUFFER,Se);try{let Pe=b.textures[ge],He=Pe.format,Ke=Pe.type;b.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+ge);let Re=_c(Pe);if(Re.__formatReadable===!1){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){ze("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}F>=0&&F<=b.width-H&&Y>=0&&Y<=b.height-X&&O.readPixels(F,Y,H,X,$.convert(He),$.convert(Ke),xe)}finally{let Pe=ee!==null?Le.get(ee).__webglFramebuffer:null;_e.bindFramebuffer(O.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,F,Y,H,X,xe,Ae,ge=0){if(!(b&&b.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=Le.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ae!==void 0&&(Se=Se[Ae],Array.isArray(Se)&&(Se=Se[0])),Se)if(F>=0&&F<=b.width-H&&Y>=0&&Y<=b.height-X){_e.bindFramebuffer(O.FRAMEBUFFER,Se);let Pe=b.textures[ge],He=Pe.format,Ke=Pe.type;b.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+ge);let Re=_c(Pe);if(Re.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let je=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,je),O.bufferData(O.PIXEL_PACK_BUFFER,xe.byteLength,O.STREAM_READ),O.readPixels(F,Y,H,X,$.convert(He),$.convert(Ke),0),O.bindBuffer(O.PIXEL_PACK_BUFFER,null);let Mt=ee!==null?Le.get(ee).__webglFramebuffer:null;_e.bindFramebuffer(O.FRAMEBUFFER,Mt);let ut=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await Rh(O,ut,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,je),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,xe),O.bindBuffer(O.PIXEL_PACK_BUFFER,null),O.deleteBuffer(je),O.deleteSync(ut),xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,F=null,Y=0){let H=Math.pow(2,-Y),X=Math.floor(b.image.width*H),xe=Math.floor(b.image.height*H),Ae=F!==null?F.x:0,ge=F!==null?F.y:0;Oe.setTexture2D(b,0),O.copyTexSubImage2D(O.TEXTURE_2D,Y,0,0,Ae,ge,X,xe),_e.unbindTexture()},this.copyTextureToTexture=function(b,F,Y=null,H=null,X=0,xe=0){let Ae,ge,Se,Pe,He,Ke,Re,je,Mt,ut=b.isCompressedTexture?b.mipmaps[xe]:b.image;if(Y!==null)Ae=Y.max.x-Y.min.x,ge=Y.max.y-Y.min.y,Se=Y.isBox3?Y.max.z-Y.min.z:1,Pe=Y.min.x,He=Y.min.y,Ke=Y.isBox3?Y.min.z:0;else{let nt=Math.pow(2,-X);Ae=Math.floor(ut.width*nt),ge=Math.floor(ut.height*nt),b.isDataArrayTexture?Se=ut.depth:b.isData3DTexture?Se=Math.floor(ut.depth*nt):Se=1,Pe=0,He=0,Ke=0}H!==null?(Re=H.x,je=H.y,Mt=H.z):(Re=0,je=0,Mt=0);let ht=$.convert(F.format),Ot=$.convert(F.type),Ce;F.isData3DTexture?(Oe.setTexture3D(F,0),Ce=O.TEXTURE_3D):F.isDataArrayTexture||F.isCompressedArrayTexture?(Oe.setTexture2DArray(F,0),Ce=O.TEXTURE_2D_ARRAY):(Oe.setTexture2D(F,0),Ce=O.TEXTURE_2D),_e.activeTexture(O.TEXTURE0),_e.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,F.flipY),_e.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,F.premultiplyAlpha),_e.pixelStorei(O.UNPACK_ALIGNMENT,F.unpackAlignment);let Ht=_e.getParameter(O.UNPACK_ROW_LENGTH),rt=_e.getParameter(O.UNPACK_IMAGE_HEIGHT),bi=_e.getParameter(O.UNPACK_SKIP_PIXELS),Bt=_e.getParameter(O.UNPACK_SKIP_ROWS),mr=_e.getParameter(O.UNPACK_SKIP_IMAGES);_e.pixelStorei(O.UNPACK_ROW_LENGTH,ut.width),_e.pixelStorei(O.UNPACK_IMAGE_HEIGHT,ut.height),_e.pixelStorei(O.UNPACK_SKIP_PIXELS,Pe),_e.pixelStorei(O.UNPACK_SKIP_ROWS,He),_e.pixelStorei(O.UNPACK_SKIP_IMAGES,Ke);let ii=b.isDataArrayTexture||b.isData3DTexture,Mi=F.isDataArrayTexture||F.isData3DTexture;if(b.isDepthTexture){let nt=Le.get(b),Nt=Le.get(F),gn=Le.get(nt.__renderTarget),xt=Le.get(Nt.__renderTarget);_e.bindFramebuffer(O.READ_FRAMEBUFFER,gn.__webglFramebuffer),_e.bindFramebuffer(O.DRAW_FRAMEBUFFER,xt.__webglFramebuffer);for(let Ct=0;Ct<Se;Ct++)ii&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Le.get(b).__webglTexture,X,Ke+Ct),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Le.get(F).__webglTexture,xe,Mt+Ct)),O.blitFramebuffer(Pe,He,Pe+Ae,He+ge,Re,je,Re+Ae,je+ge,O.DEPTH_BUFFER_BIT,O.NEAREST);_e.bindFramebuffer(O.READ_FRAMEBUFFER,null),_e.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(X!==0||b.isRenderTargetTexture||Le.has(b)){let nt=Le.get(b),Nt=Le.get(F);_e.bindFramebuffer(O.READ_FRAMEBUFFER,I),_e.bindFramebuffer(O.DRAW_FRAMEBUFFER,q);for(let gn=0;gn<Se;gn++)ii?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,nt.__webglTexture,X,Ke+gn):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,nt.__webglTexture,X),Mi?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Nt.__webglTexture,xe,Mt+gn):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Nt.__webglTexture,xe),X!==0?O.blitFramebuffer(Pe,He,Pe+Ae,He+ge,Re,je,Re+Ae,je+ge,O.COLOR_BUFFER_BIT,O.NEAREST):Mi?O.copyTexSubImage3D(Ce,xe,Re,je,Mt+gn,Pe,He,Ae,ge):O.copyTexSubImage2D(Ce,xe,Re,je,Pe,He,Ae,ge);_e.bindFramebuffer(O.READ_FRAMEBUFFER,null),_e.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else Mi?b.isDataTexture||b.isData3DTexture?O.texSubImage3D(Ce,xe,Re,je,Mt,Ae,ge,Se,ht,Ot,ut.data):F.isCompressedArrayTexture?O.compressedTexSubImage3D(Ce,xe,Re,je,Mt,Ae,ge,Se,ht,ut.data):O.texSubImage3D(Ce,xe,Re,je,Mt,Ae,ge,Se,ht,Ot,ut):b.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,xe,Re,je,Ae,ge,ht,Ot,ut.data):b.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,xe,Re,je,ut.width,ut.height,ht,ut.data):O.texSubImage2D(O.TEXTURE_2D,xe,Re,je,Ae,ge,ht,Ot,ut);_e.pixelStorei(O.UNPACK_ROW_LENGTH,Ht),_e.pixelStorei(O.UNPACK_IMAGE_HEIGHT,rt),_e.pixelStorei(O.UNPACK_SKIP_PIXELS,bi),_e.pixelStorei(O.UNPACK_SKIP_ROWS,Bt),_e.pixelStorei(O.UNPACK_SKIP_IMAGES,mr),xe===0&&F.generateMipmaps===!0&&F.mipmapsAutoUpdate===!0&&O.generateMipmap(Ce),_e.unbindTexture()},this.initRenderTarget=function(b){Le.get(b).__webglFramebuffer===void 0&&Oe.setupRenderTarget(b)},this.initTexture=function(b){b.isCubeTexture?Oe.setTextureCube(b,0):b.isData3DTexture?Oe.setTexture3D(b,0):b.isDataArrayTexture||b.isCompressedArrayTexture?Oe.setTexture2DArray(b,0):Oe.setTexture2D(b,0),_e.unbindTexture()},this.resetState=function(){Z=0,B=0,ee=null,_e.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=Qe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Qe._getUnpackColorSpace()}};var pu={type:"change"},Ql={type:"start"},gu={type:"end"},_a=new Ri,mu=new on,F0=Math.cos(70*Ll.DEG2RAD),At=new k,Qt=2*Math.PI,ot={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},jl=1e-6,xa=class extends qs{constructor(e,t=null){super(e,t),this.state=ot.NONE,this.target=new k,this.cursor=new k,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:pi.ROTATE,MIDDLE:pi.DOLLY,RIGHT:pi.PAN},this.touches={ONE:mi.ROTATE,TWO:mi.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new k,this._lastQuaternion=new an,this._lastTargetPosition=new k,this._quat=new an().setFromUnitVectors(e.up,new k(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new hs,this._sphericalDelta=new hs,this._scale=1,this._panOffset=new k,this._rotateStart=new ke,this._rotateEnd=new ke,this._rotateDelta=new ke,this._panStart=new ke,this._panEnd=new ke,this._panDelta=new ke,this._dollyStart=new ke,this._dollyEnd=new ke,this._dollyDelta=new ke,this._dollyDirection=new k,this._mouse=new ke,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=B0.bind(this),this._onPointerDown=O0.bind(this),this._onPointerUp=z0.bind(this),this._onContextMenu=q0.bind(this),this._onMouseWheel=G0.bind(this),this._onKeyDown=H0.bind(this),this._onTouchStart=W0.bind(this),this._onTouchMove=X0.bind(this),this._onMouseDown=k0.bind(this),this._onMouseMove=V0.bind(this),this._interceptControlDown=Y0.bind(this),this._interceptControlUp=Z0.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.ownerDocument.addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.state=ot.NONE,this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.ownerDocument.removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{capture:!0}),this._controlActive=!1,this._pointers.length=0,this._pointerPositions={},this.domElement.style.touchAction="",this.domElement.style.cursor="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(pu),this.update(),this.state=ot.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){let t=this.object.position;At.copy(t).sub(this.target),At.applyQuaternion(this._quat),this._spherical.setFromVector3(At),this.autoRotate&&this.state===ot.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Qt:n>Math.PI&&(n-=Qt),s<-Math.PI?s+=Qt:s>Math.PI&&(s-=Qt),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(At.setFromSpherical(this._spherical),At.applyQuaternion(this._quatInverse),t.copy(this.target).add(At),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=At.length();o=this._clampDistance(a*this._scale);let c=a-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let a=new k(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;let l=new k(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=At.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(_a.origin.copy(this.object.position),_a.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_a.direction))<F0?this.object.lookAt(this.target):(mu.setFromNormalAndCoplanarPoint(this.object.up,this.target),_a.intersectPlane(mu,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>jl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>jl||this._lastTargetPosition.distanceToSquared(this.target)>jl?(this.dispatchEvent(pu),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Qt/60*this.autoRotateSpeed*e:Qt/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){At.setFromMatrixColumn(t,0),At.multiplyScalar(-e),this._panOffset.add(At)}_panUp(e,t){this.screenSpacePanning===!0?At.setFromMatrixColumn(t,1):(At.setFromMatrixColumn(t,0),At.crossVectors(this.object.up,At)),At.multiplyScalar(e),this._panOffset.add(At)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;At.copy(s).sub(this.target);let r=At.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientY),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Qt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.zoomToCursor&&(this._performCursorZoom=!0,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Qt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Qt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new ke,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function O0(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function B0(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function z0(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(gu),this.state=ot.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function k0(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case pi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=ot.DOLLY;break;case pi.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ot.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ot.ROTATE}break;case pi.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=ot.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=ot.PAN}break;default:this.state=ot.NONE}this.state!==ot.NONE&&this.dispatchEvent(Ql)}function V0(i){switch(this.state){case ot.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case ot.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case ot.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function G0(i){this.enabled===!1||this.enableZoom===!1||this.state!==ot.NONE||(i.preventDefault(),this.dispatchEvent(Ql),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(gu))}function H0(i){this.enabled!==!1&&this._handleKeyDown(i)}function W0(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case mi.ROTATE:if(this.enableRotate===!1){this.state=ot.NONE;break}this._handleTouchStartRotate(i),this.state=ot.TOUCH_ROTATE;break;case mi.PAN:if(this.enablePan===!1){this.state=ot.NONE;break}this._handleTouchStartPan(i),this.state=ot.TOUCH_PAN;break;default:this.state=ot.NONE}break;case 2:switch(this.touches.TWO){case mi.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=ot.TOUCH_DOLLY_PAN;break;case mi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=ot.TOUCH_DOLLY_ROTATE;break;default:this.state=ot.NONE}break;default:this.state=ot.NONE}this.state!==ot.NONE&&this.dispatchEvent(Ql)}function X0(i){switch(this._trackPointer(i),this.state){case ot.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case ot.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case ot.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case ot.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=ot.NONE}}function q0(i){this.enabled!==!1&&i.preventDefault()}function Y0(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Z0(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.ownerDocument.removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var wt={drawn:.4,svgIn:.5,rise:.55,svgOut:.62,tilted:.78,wallsUp:.84,done:.96};var _u=i=>i<0?0:i>1?1:i,ei=i=>{let e=_u(i);return e*e*(3-2*e)};function or(i,e){let t=_u(e),n=t<wt.drawn?0:t<wt.svgIn?ei((t-wt.drawn)/(wt.svgIn-wt.drawn)):t<wt.rise?1:1-ei((t-wt.rise)/(wt.svgOut-wt.rise)),s=new Map;for(let h of i){let d=!h.hidden&&t>=h.appear,u=h.riseTo<=h.riseFrom?t>=h.riseFrom?1:0:ei((t-h.riseFrom)/(h.riseTo-h.riseFrom));s.set(h.key,{visible:d,rise:u})}let r=[],o=[];for(let h of i)h.storey===void 0||h.hidden||(r[h.storey]=Math.max(r[h.storey]??0,h.riseTo),o[h.storey]=Math.min(o[h.storey]??1,h.appear));let a=r[0]??1,c=0;for(let h=1;h<r.length;h++){let d=r[h-1],u=o[h];t>d&&(c=h-1+(u>d?ei((t-d)/(u-d)):1))}let l=0;if(r.length>1){let h=$0(r);l=h<1?ei((t-h)/(1-h)):t>=1?1:0,l>0&&(c=r.length-1+l)}return{tilt:ei((t-wt.rise)/(Math.min(wt.tilted,a)-wt.rise)),dolly:ei((t-wt.rise)/(a-wt.rise)),stop:c,settle:l,svg:n,ground:t>=wt.rise?1-n:0,nodes:s}}var $0=i=>Math.max(wt.done,...i);var xu=.88,xi=i=>i*Math.PI/180;function tc(i){let e=xi(i.elevation),t=xi(i.azimuth);return[Math.cos(e)*Math.sin(t),Math.sin(e),Math.cos(e)*Math.cos(t)]}function nc(i,e,t){let n=tc(t);return[i[0]+e*n[0],i[1]+e*n[1],i[2]+e*n[2]]}function bu(i){let e=i[2],t=-i[0],n=Math.hypot(e,t),s=[e/n,0,t/n],r=[i[1]*s[2]-i[2]*s[1],i[2]*s[0]-i[0]*s[2],i[0]*s[1]-i[1]*s[0]];return{right:s,up:r}}function Mu(i){let e=[];for(let t of[i.lo[0],i.hi[0]])for(let n of[i.lo[1],i.hi[1]])for(let s of[i.lo[2],i.hi[2]])e.push([t,n,s]);return e}function J0(i,e,t){let n=tc(t),{right:s,up:r}=bu(n),o=Math.tan(xi(t.fov)/2),a=1/0,c=-1/0,l=1/0,h=-1/0;for(let d of Mu(i)){let u=[d[0]-e.target[0],d[1]-e.target[1],d[2]-e.target[2]],p=e.dist-(u[0]*n[0]+u[1]*n[1]+u[2]*n[2]),_=(u[0]*s[0]+u[2]*s[2])/(p*o*t.aspect),x=(u[0]*r[0]+u[1]*r[1]+u[2]*r[2])/(p*o);a=Math.min(a,_),c=Math.max(c,_),l=Math.min(l,x),h=Math.max(h,x)}return{x:[a,c],y:[l,h]}}function ec(i,e){let t=tc(e),{right:n,up:s}=bu(t),r=Math.tan(xi(e.fov)/2),o=[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],a=1e3;for(let c=0;c<4;c++){a=0;for(let u of Mu(i)){let p=[u[0]-o[0],u[1]-o[1],u[2]-o[2]],_=p[0]*t[0]+p[1]*t[1]+p[2]*t[2],x=Math.abs(p[0]*n[0]+p[2]*n[2]),m=Math.abs(p[0]*s[0]+p[1]*s[1]+p[2]*s[2]);a=Math.max(a,_+x/(xu*r*e.aspect),_+m/(xu*r))}if(c===3)break;let l=J0(i,{target:o,dist:a},e),h=(l.x[0]+l.x[1])/2*a*r*e.aspect,d=(l.y[0]+l.y[1])/2*a*r;o=[o[0]+h*n[0]+d*s[0],o[1]+h*n[1]+d*s[1],o[2]+h*n[2]+d*s[2]]}return{target:o,dist:a}}var Dn=30,ic=-32;function ar(i,e={}){let t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],s=e.ghosts?i:i.filter(r=>r.part!=="demolish");for(let r of s.length>0?s:i){let o=e.settle===void 0?r.lift??0:va(r.lift,e.settle);for(let a=0;a<r.positions.length;a+=3){let c=[r.positions[a]/1e3,r.positions[a+1]/1e3+o,r.positions[a+2]/1e3];for(let l=0;l<3;l++)t[l]=Math.min(t[l],c[l]),n[l]=Math.max(n[l],c[l])}}return{lo:t,hi:n}}var va=(i,e)=>(i??0)*(1-e),ba=i=>Math.max(1,...i.map(e=>(e.storey??0)+1)),ya=1.5;function Su(i,e,t){let n=new Map(e.map(o=>[o.key,o.storey??0])),s=ba(e),r=[];for(let o=0;o<s;o++)r.push(ec(ar(i.filter(a=>(n.get(a.key)??0)<=o)),t));return s>1&&r.push(ec(ar(i,{settle:1}),t)),r}function K0(i,e){let t=Math.min(i.length-1,Math.floor(e)),n=i[t],s=i[Math.min(i.length-1,t+1)],r=e-t;return r<=0||n===s?n:{target:[0,1,2].map(o=>n.target[o]*(1-r)+s.target[o]*r),dist:n.dist*(1-r)+s.dist*r}}function Ma(i,e,t){let n=h=>h*Math.PI/180,s=K0(e,i.stop),r=2*s.dist*Math.tan(n(Dn)/2),o=ya+(Dn-ya)*i.dolly,c=(t.oh+(r-t.oh)*i.dolly)/(2*Math.tan(n(o)/2));return{target:[t.cx+(s.target[0]-t.cx)*i.dolly,s.target[1]*i.tilt,t.cz+(s.target[2]-t.cz)*i.dolly],dist:c,fov:o,elevation:90-(90-t.elevation)*i.tilt,azimuth:ic*i.tilt}}function sc(i,e){let[t,n,s,r]=i,o=Math.max(s,r*e);return{cx:t+s/2,cz:n+r/2,ow:o,oh:o/e}}var yu={north:180,east:90,south:0,west:-90},lr={min:0,max:90};function wu(i,e,t){if(e[1]>=t||i[1]<=t)return e;let n=(i[1]-t)/(i[1]-e[1]);return[i[0]+(e[0]-i[0])*n,t,i[2]+(e[2]-i[2])*n]}function Eu(i,e){if(i==="iso")return Ma(or(e.events,1),e.fits,e.frame);let t=i==="top"?{elevation:lr.max,azimuth:yu.south}:{elevation:lr.min,azimuth:yu[i]},n=ec(e.box,{...t,fov:Dn,aspect:e.aspect});return{target:n.target,dist:n.dist,fov:Dn,...t}}function Tu(i){return i.fov===Dn?i:{...i,fov:Dn,dist:i.dist*Math.tan(xi(i.fov)/2)/Math.tan(xi(Dn)/2)}}var vu={in:8,out:3};function Au(i,e){let t=i[i.length-1].dist,n=Math.tan(xi(Dn)/2)/Math.tan(xi(e)/2);return{min:t*n/vu.in,max:t*n*vu.out}}function Ru(i){let e=[i.hi[0]-i.lo[0],i.hi[1]-i.lo[1],i.hi[2]-i.lo[2]];return{centre:[(i.lo[0]+i.hi[0])/2,(i.lo[1]+i.hi[1])/2,(i.lo[2]+i.hi[2])/2],radius:Math.hypot(e[0],e[1],e[2])/2}}var $e=(i,e,t=0,n=1)=>({srgb:i,alpha:n,metallic:t,roughness:e}),$t={wood:$e("#c6a785",.75),wood_dark:$e("#7b5b44",.7),fabric:$e("#968f85",.95),cushion:$e("#bfb7ab",.95),linen:$e("#f3efe7",.9),wool:$e("#a7ac98",1),ceramic:$e("#f6f4f0",.25),stone:$e("#d8d4cc",.45),metal:$e("#aeb2b4",.35,1),glass:$e("#c9dee6",.05,0,.35),appliance:$e("#dcdcd8",.35),screen:$e("#2e3033",.2),paint:$e("#a9b1a2",.6),rubber:$e("#3b3b3b",.9),foliage:$e("#8c9b78",.9),bark:$e("#6f5b49",.9),soil:$e("#5f4b3b",1),water:$e("#a3c6d0",.1,0,.7)},j0="wood",Q0="wood_dark",rc=$e("#c2a27e",.7),Cu=$e("#55534f",.5),Nn={slab:$e("#bdb6ab",.9),column:$e("#e6e1d8",.85),wall:$e("#f2f0eb",.9),door:rc,"window:frame":Cu,"window:glass":$e("#bcd6e0",.05,0,.4),"window:reveal":Cu,"window:sill":$t.stone,"window:board":$t.wood,"opening:lining":rc,"opening:casing":rc,opening:$e("#e6e1d8",.85),furniture:$e("#d6cec1",.9),roof:$e("#9c958a",.9),"wall:demolish":$e("#c8553d",.9,0,.3),stair:$t[j0],"stair:rail":$t[Q0]},nb={"door:lining":{material:"door",srgb:Nn.door.srgb},"door:casing":{material:"door",srgb:Nn.door.srgb},"opening:lining":{material:"opening:lining",srgb:Nn["opening:lining"].srgb},"opening:casing":{material:"opening:casing",srgb:Nn["opening:casing"].srgb},"window:reveal":{material:"window:reveal",srgb:Nn["window:reveal"].srgb},"window:sill":{material:"window:sill",srgb:Nn["window:sill"].srgb},"window:board":{material:"window:board",srgb:Nn["window:board"].srgb}},Pu="#8f877d";var e_={timber:$e("#cdb596",.6),tile:$e("#e3e1db",.35),neutral:$e("#e8e2d7",.9),carpeting:$t.wool,stone:$t.stone,deck:$t.wood,paving:$e("#ab9f87",.85),concrete:$e("#c9c5be",.6)};var oc={gravel:$e("#cbc3b4",.95),tarmac:$e("#8c8984",.85),sand:$e("#dcc9a3",.95)},ib={planting:$t.foliage,deck:$t.wood,gravel:oc.gravel,driveway:oc.tarmac,sand:oc.sand,soil:$t.soil};var sb={picket:$e("#eeebe4",.8),panel:$t.wood,post:$t.wood_dark},Sa={light:"#e2ddd3",dark:"#16293d",marginMm:6e3},xs={wall:{of:.75,minMm:80,maxMm:200},furniture:{of:.12,minMm:30,maxMm:120},fence:{of:1.5,minMm:40,maxMm:120},stairThicknessMm:100,alpha:{floor:.2,corner:.12,furniture:.18},alphaDark:{floor:.3,corner:.18,furniture:.27},liftMm:1};function Iu(i,e,t){if(e==="light")return i;let n=s=>{let r=Number.parseInt(i.slice(s,s+2),16),o=Number.parseInt(t.slice(s,s+2),16);return Math.round(r*.4+o*.6).toString(16).padStart(2,"0")};return`#${n(1)}${n(3)}${n(5)}`}function Lu(i,e,t){let n=$t[i].srgb;if(e==="light")return n;let s=r=>{let o=Number.parseInt(n.slice(r,r+2),16),a=Number.parseInt(t.slice(r,r+2),16);return Math.round(o*.4+a*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}function Du(i,e,t){let n=e_[i].srgb;if(e==="light")return n;let s=r=>{let o=Number.parseInt(n.slice(r,r+2),16),a=Number.parseInt(t.slice(r,r+2),16);return Math.round(o*.4+a*.6).toString(16).padStart(2,"0")};return`#${s(1)}${s(3)}${s(5)}`}var wa=[1,.9238795325112867,Math.SQRT1_2,.3826834323650898,0,-.3826834323650898,-Math.SQRT1_2,-.9238795325112867,-1,-.9238795325112867,-Math.SQRT1_2,-.3826834323650898,0,.3826834323650898,Math.SQRT1_2,.9238795325112867],Nu=wa.map((i,e)=>wa[(e+12)%16]);function Ta(i){return i.kind==="wall"&&i.part===void 0||i.kind==="column"}var yi=2**26;function Fi(i,e,t,n){if(Math.abs(i)<yi&&Math.abs(e)<yi&&Math.abs(t)<yi&&Math.abs(n)<yi)return i*n-e*t;let s=BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t);return s>0n?1:s<0n?-1:0}function t_(i,e,t,n){return Math.abs(i)<yi&&Math.abs(e)<yi&&Math.abs(t)<yi&&Math.abs(n)<yi?String(i*n-e*t):(BigInt(i)*BigInt(n)-BigInt(e)*BigInt(t)).toString()}function n_(i,e){let t=Math.abs(i),n=Math.abs(e);for(;n!==0;)[t,n]=[n,t%n];return t}function lc(i,e,t,n){let s=BigInt(i[0])*BigInt(e[0])+BigInt(i[1])*BigInt(e[1]),r=BigInt(i[0])*BigInt(e[1])-BigInt(i[1])*BigInt(e[0]),o=t*n>0?s:-s;return o>0n&&o*o>3n*r*r}function hr(i,e,t,n){let s=t-i,r=n-e,o=n_(s,r);return s/=o,r/=o,(s<0||s===0&&r<0)&&(s=0-s,r=0-r),{dx:s,dz:r,key:`${s},${r},${t_(s,r,i,e)}`}}var ac=(i,e)=>{for(let t=0;t<i.length;t++){let n=i[t]-e[t];if(n!==0)return n}return 0},cr=i=>[...i.keys()].sort((e,t)=>e<t?-1:e>t?1:0),ur=i=>{let e=[...i].sort((n,s)=>n-s),t=0;for(let n=0;n<e.length;n++)(n===0||e[n]!==e[t-1])&&(e[t++]=e[n]);return e.length=t,e};function Uu(i){let e=1/0,t=-1/0;for(let n of i)n<e&&(e=n),n>t&&(t=n);return[e,t]}function Fu(i,e){let t=-1;for(let n of i)if(t<0)t=n;else{let s=e?.[n]??0,r=e?.[t]??0;(s>r||s===r&&n<t)&&(t=n)}return t}function Ou(i){let e=new Map;return i.forEach((t,n)=>{if(!Ta(t))return;let s=/^L(-?\d+)\//.exec(t.key)?.[1]??"",r=e.get(s);r?r.push(n):e.set(s,[n])}),cr(e).map(t=>e.get(t)??[])}function Bu(i,e){let t=r_(i),n=i.map((s,r)=>Ta(s)?{...s,...o_(s,t[r])}:s);return{faces:t,lines:i_(n,e)}}function i_(i,e){let t=i.map(s=>Ta(s)?[]:void 0),n=i.map(()=>[]);for(let s of Ou(i))s_(i,s,n,e);return n.forEach((s,r)=>{if(!t[r])return;let o=s.map(a=>ac(a.slice(0,3),a.slice(3))<=0?a:[a[3],a[4],a[5],a[0],a[1],a[2]]).sort(ac);t[r]=o.flat()}),t}function Ea(i,e){let t=i.map((o,a)=>[o,a]).sort((o,a)=>o[0].t0-a[0].t0||o[1]-a[1]),n=ur(i.flatMap(o=>[o.t0,o.t1])),s=0,r=[];for(let o=0;o+1<n.length;o++){let a=n[o],c=n[o+1];for(r.some(l=>l.t1<=a)&&(r=r.filter(l=>l.t1>a));s<t.length&&t[s]?.[0].t0<=a;)r.push(t[s++]?.[0]);r.length>0&&e(a,c,r)}}function s_(i,e,t,n){let s=new Map,r=new Map,o=new Map,a=new Map,c=(_,x,m)=>{let f=`${_}|${x}`,w=s.get(f);w?w.edges.push(m):s.set(f,{line:x,plane:_,edges:[m]})},l=(_,x,m,f)=>{let w=ac(x,m)<0,[A,S]=w?[x,m]:[m,x],M=`${_}|${A[0]},${A[1]},${A[2]}|${S[0]},${S[1]},${S[2]}`,E=a.get(M);E?(E.net+=w?1:-1,E.nodes.push(f)):a.set(M,{a:A,b:S,net:w?1:-1,nodes:[f]})},h=(_,x,m,f)=>{let w=`h${_}:${x.key}`,A=r.get(w);if(A||(A={kind:"horizontal",y:_,alongX:x.dx!==0,other:new Map},r.set(w,A)),A.kind==="horizontal")for(let S of[m,f]){let[M,,E]=S;A.alongX?A.other.set(M,E):A.other.set(E,M)}return w},d=(_,x)=>_.dx!==0?x[0]:x[2],u=(_,x,m,f)=>_<x?{t0:_,t1:x,k:1,node:m,f}:{t0:x,t1:_,k:-1,node:m,f};for(let _ of e){let x=i[_],m=f=>[Math.round(x.positions[f*3]),Math.round(x.positions[f*3+1]),Math.round(x.positions[f*3+2])];for(let f=0;f+2<x.indices.length;f+=3){let w=[m(x.indices[f]),m(x.indices[f+1]),m(x.indices[f+2])],[A,S,M]=w,E=A[0],g=A[1],v=A[2],N=[[A,S],[S,M],[M,A]];if(g===S[1]&&g===M[1]){if(Fi(S[0]-E,S[2]-v,M[0]-E,M[2]-v)===0)continue;let B=`H${g}`;for(let[ee,C]of N){if(ee[0]===C[0]&&ee[2]===C[2])continue;let W=hr(ee[0],ee[2],C[0],C[2]);c(B,h(g,W,ee,C),u(d(W,ee),d(W,C),_,0))}continue}if(!(Fi(S[0]-E,S[2]-v,M[0]-E,M[2]-v)===0)){for(let[B,ee]of N)t[_].push([...B,...ee]);continue}let D=A[0]!==S[0]||A[2]!==S[2]?S:M;if(D[0]===E&&D[2]===v)continue;let U=hr(E,v,D[0],D[2]),z=`V${U.key}`;o.has(z)||o.set(z,[U.dx,U.dz]);let I=B=>d(U,B),q=Fi(I(S)-I(A),S[1]-g,I(M)-I(A),M[1]-g);if(q===0)continue;let Z=q>0?1:-1;for(let[B,ee]of N)if(B[0]===ee[0]&&B[2]===ee[2]){if(B[1]===ee[1])continue;let C=`v${B[0]},${B[2]}`;r.has(C)||r.set(C,{kind:"vertical",x:B[0],z:B[2]}),c(z,C,u(B[1],ee[1],_,Z))}else B[1]===ee[1]?c(z,h(B[1],U,B,ee),u(d(U,B),d(U,ee),_,Z)):l(z,B,ee,_)}}let p=new Map;for(let _ of cr(s)){let{line:x,plane:m,edges:f}=s.get(_),[w,A]=f;f.length===2&&A&&w.t0===A.t0&&w.t1===A.t1&&w.k!==A.k||Ea(f,(S,M,E)=>{let g=0;for(let z of E)g+=z.k;if(g===0)return;let v=new Map;for(let z of E)v.set(z.node,(v.get(z.node)??0)+z.k);let N=ur(E.filter(z=>v.get(z.node)!==0).map(z=>z.node)),R=ur(E.filter(z=>z.k===Math.sign(g)).map(z=>z.f)),D={t0:S,t1:M,nodes:N,plane:m,f:R.length===1?R[0]:0},U=p.get(x);U?U.push(D):p.set(x,[D])})}for(let _ of cr(p)){let x=p.get(_),m=r.get(_),f=[];Ea(x,(w,A,S)=>{if(m.kind==="vertical"&&S.length===2){let[g,v]=S,N=o.get(g.plane),R=o.get(v.plane);if(N&&R&&g.f!==0&&v.f!==0&&lc(N,R,g.f,v.f))return}let M=Fu(S.flatMap(g=>g.nodes),n),E=f[f.length-1];E&&E.t1===w&&E.node===M?E.t1=A:f.push({t0:w,t1:A,node:M})});for(let w of f){let A=S=>{if(m.kind==="vertical")return[m.x,S,m.z];let M=m.other.get(S);return m.alongX?[S,m.y,M]:[M,m.y,S]};t[w.node].push([...A(w.t0),...A(w.t1)])}}for(let _ of cr(a)){let{a:x,b:m,net:f,nodes:w}=a.get(_);f!==0&&t[Fu(w,n)].push([...x,...m])}}function zu(i,e){let t=new Map;i.forEach((s,r)=>{s&&s.group>=0&&t.set(s.group,(t.get(s.group)??!0)&&e(r))});let n=new Set;for(let[s,r]of t)r&&n.add(s);return n}function r_(i){let e=i.map(o=>Ta(o)?{hide:[],add:[],alone:[],joined:[],group:-1}:void 0),t=i.map((o,a)=>a),n=o=>{let a=o;for(;t[a]!==a;)a=t[a];for(;t[o]!==a;)[o,t[o]]=[t[o],a];return a},s=(o,a)=>{let c=n(o),l=n(a);c<l?t[l]=c:l<c&&(t[c]=l)},r=new Set;for(let o of Ou(i))l_(i,o,e,s,r);return e.forEach((o,a)=>{o&&(o.hide.sort((c,l)=>c-l),r.has(a)&&(o.group=n(a)))}),e}function cc(i,e){if(!e)return{positions:i.positions,base:[...i.indices],alone:[],joined:[]};let t=new Set(e.hide),n=[];for(let c=0;c+2<i.indices.length;c+=3)t.has(c/3)||n.push(i.indices[c],i.indices[c+1],i.indices[c+2]);let s=i.positions.length/3,r=(c,l=[])=>{for(let h=0;h<c.length/3;h++)l.push(s++);return l};r(e.add,n);let o=r(e.alone),a=r(e.joined);return{positions:i.positions.concat(e.add,e.alone,e.joined),base:n,alone:o,joined:a}}function o_(i,e,t="joined"){if(!e)return{positions:i.positions,indices:i.indices};let n=cc(i,e);return{positions:n.positions,indices:n.base.concat(t==="joined"?n.joined:n.alone)}}function a_(i){let e=i.map(s=>{let[r,o]=Uu(s.s),[a,c]=Uu(s.p.map(l=>l[1]));return{s0:r,s1:o,y0:a,y1:c,f:s.f}});e.sort((s,r)=>s.s0-r.s0);let t=[],n=[];for(let s of e){if(t.some(o=>o.s1<=s.s0)&&(t=t.filter(o=>o.s1>s.s0)),n.some(o=>o.s1<=s.s0)&&(n=n.filter(o=>o.s1>s.s0)),(s.f>0?n:t).some(o=>Math.min(o.y1,s.y1)>Math.max(o.y0,s.y0)))return!0;(s.f>0?t:n).push(s)}return!1}function l_(i,e,t,n,s){let r=new Map;for(let o of e){let a=i[o],c=l=>[Math.round(a.positions[l*3]),Math.round(a.positions[l*3+1]),Math.round(a.positions[l*3+2])];for(let l=0;l+2<a.indices.length;l+=3){let h=c(a.indices[l]),d=c(a.indices[l+1]),u=c(a.indices[l+2]),p=h[0],_=h[1],x=h[2];if(_===d[1]&&_===u[1]||Fi(d[0]-p,d[2]-x,u[0]-p,u[2]-x)!==0)continue;let m=h[0]!==d[0]||h[2]!==d[2]?d:u;if(m[0]===p&&m[2]===x)continue;let f=hr(p,x,m[0],m[2]),w=v=>f.dx!==0?v[0]:v[2],A=[w(h),w(d),w(u)],S=Fi(A[1]-A[0],d[1]-_,A[2]-A[0],u[1]-_);if(S===0)continue;let M=`V${f.key}`,E={node:o,tri:l/3,p:[h,d,u],f:S>0?1:-1,s:A},g=r.get(M);g?g.tris.push(E):r.set(M,{pl:f,tris:[E]})}}for(let o of cr(r)){let{tris:a}=r.get(o);if(!a_(a))continue;let c=ur(a.flatMap(S=>S.s)),l=ur(a.flatMap(S=>S.p.map(M=>M[1]))),h=new Map;for(let S of a)for(let M=0;M<3;M++)h.set(S.s[M],S.p[M]);let d=new Map(c.map((S,M)=>[S,M])),u=new Map(l.map((S,M)=>[S,M])),p=l.length-1,_=c.map(()=>[]);for(let S of a)for(let M=0;M<3;M++){let E=S.p[M],g=S.p[(M+1)%3];if(E[0]!==g[0]||E[2]!==g[2]||E[1]===g[1])continue;let v=d.get(S.s[M]),N=Math.min(E[1],g[1]),R=Math.max(E[1],g[1]);_[v].push([S.node,u.get(N),u.get(R),g[1]>E[1]?1:-1])}let x=new Map,m=new Map,f=[],w=new Int32Array(p),A=(S,M,E,g,v)=>{let N=l[g],R=l[g+1],D=(Z,B)=>{let ee=h.get(Z);return[ee[0],B,ee[2]]},[U,z,I,q]=[D(M,N),D(E,N),D(E,R),D(M,R)];v>0?S.push(...U,...z,...I,...U,...I,...q):S.push(...U,...I,...z,...U,...q,...I)};for(let S=0;S+1<c.length;S++){let M=_[S];for(let[v,N,R,D]of M){let U=x.get(v);U||(U=new Int32Array(p),x.set(v,U));let z=m.get(v)??0;for(let I=N;I<R;I++){let q=U[I],Z=q-D;U[I]=Z,w[I]=w[I]-D,q===0?z++:Z===0&&z--}m.set(v,z)}if(M.length>0){for(let v of[...x.keys()])m.get(v)===0&&(x.delete(v),m.delete(v));f=[...x.keys()].sort((v,N)=>v-N)}let E=c[S],g=c[S+1];for(let v=0;v<p;v++){let N=f.filter(U=>x.get(U)[v]!==0);if(N.length===0)continue;if(N.length===1){let U=N[0];A(t[U].add,E,g,v,x.get(U)[v]);continue}for(let U of N)A(t[U].alone,E,g,v,x.get(U)[v]),s.add(U),n(U,N[0]);let R=w[v];if(R===0)continue;let D=N.find(U=>Math.sign(x.get(U)[v])===Math.sign(R));A(t[D].joined,E,g,v,R)}}for(let S of a)t[S.node].hide.push(S.tri)}}var Fn=(i,e,t,n)=>Fi(i,e,t,n),ku=i=>Number(/^L(-?\d+)\//.exec(i)?.[1]??0),en=i=>Math.round(i)+0,c_=(i,e)=>Math.sqrt(Number(BigInt(i)*BigInt(i)+BigInt(e)*BigInt(e)));function Gu(i,e){if(!i||i.hidden)return 0;let t=i.riseTo-i.riseFrom;if(t<=0)return e>=i.riseTo?1:0;let n=t/4;return ei((e-(i.riseTo-n))/n)}function Vu(i,e){let t=Fn(i.b[0]-i.a[0],i.b[1]-i.a[1],e[0]-i.a[0],e[1]-i.a[1]),n=Fn(i.c[0]-i.b[0],i.c[1]-i.b[1],e[0]-i.b[0],e[1]-i.b[1]),s=Fn(i.a[0]-i.c[0],i.a[1]-i.c[1],e[0]-i.c[0],e[1]-i.c[1]);return t>=0&&n>=0&&s>=0||t<=0&&n<=0&&s<=0}var h_=64,Aa=class{constructor(e){_n(this,"x0");_n(this,"z0");_n(this,"w");_n(this,"h");_n(this,"k");_n(this,"cells");let[t,n,s,r]=[1/0,1/0,-1/0,-1/0];for(let o of e)for(let a of[o.a,o.b,o.c])a[0]<t&&(t=a[0]),a[0]>s&&(s=a[0]),a[1]<n&&(n=a[1]),a[1]>r&&(r=a[1]);this.k=e.length===0?0:Math.max(1,Math.min(h_,Math.ceil(Math.sqrt(e.length)))),this.x0=t,this.z0=n,this.w=this.k===0?1:Math.max(1,Math.ceil((s-t+1)/this.k)),this.h=this.k===0?1:Math.max(1,Math.ceil((r-n+1)/this.k)),this.cells=Array.from({length:this.k*this.k},()=>[]);for(let o of e){let a=[o.a[0],o.b[0],o.c[0]],c=[o.a[1],o.b[1],o.c[1]],[l,h]=[this.col(Math.min(...a)),this.col(Math.max(...a))],[d,u]=[this.row(Math.min(...c)),this.row(Math.max(...c))];for(let p=d;p<=u;p++)for(let _=l;_<=h;_++)this.cells[p*this.k+_]?.push(o)}}col(e){return Math.floor((e-this.x0)/this.w)}row(e){return Math.floor((e-this.z0)/this.h)}at(e){if(this.k===0)return[];let t=this.col(e[0]),n=this.row(e[1]);return t<0||n<0||t>=this.k||n>=this.k?[]:this.cells[n*this.k+t]??[]}near(e,t,n,s){if(this.k===0)return[];let r=a=>Math.max(0,Math.min(this.k-1,a)),o=new Set;for(let a=r(this.row(t));a<=r(this.row(s));a++)for(let c=r(this.col(e));c<=r(this.col(n));c++)for(let l of this.cells[a*this.k+c]??[])o.add(l);return[...o]}};function u_(i,e,t,n){let s=i.positions;for(let r=0;r<i.indices.length;r+=3){let[o,a,c]=[i.indices[r],i.indices[r+1],i.indices[r+2]],l=s[o*3+1];if(s[a*3+1]!==l||s[c*3+1]!==l||t!==void 0&&l!==t)continue;let h=[s[o*3],s[o*3+2]],d=[s[a*3],s[a*3+2]],u=[s[c*3],s[c*3+2]],p=Fn(d[0]-h[0],d[1]-h[1],u[0]-h[0],u[1]-h[1]);(e?p<0:p>0)&&n.push({a:h,b:d,c:u,y:l})}}function hc(i){let e=new Map;for(let{node:n,p:s}of i)for(let r=0;r<3;r++){let o=s[r],a=s[(r+1)%3];if(o[0]===a[0]&&o[1]===a[1])continue;let c=hr(o[0],o[1],a[0],a[1]),l=c.dx!==0,h=l?o[0]:o[1],d=l?a[0]:a[1],u=e.get(c.key);u||(u={edges:[],at:new Map},e.set(c.key,u)),u.at.set(h,o),u.at.set(d,a),u.edges.push(h<d?{t0:h,t1:d,k:1,node:n}:{t0:d,t1:h,k:-1,node:n})}let t=[];for(let n of[...e.keys()].sort()){let s=e.get(n);if(!s)continue;let r=[];Ea(s.edges,(o,a,c)=>{let l=0,h=1/0;for(let p of c)l+=p.k,p.node<h&&(h=p.node);if(l===0)return;let d=l>0?1:-1,u=r[r.length-1];u&&u.t1===o&&u.s===d&&u.node===h?u.t1=a:r.push({t0:o,t1:a,s:d,node:h})});for(let o of r){let a=s.at.get(o.t0),c=s.at.get(o.t1);t.push(o.s>0?{a,b:c,node:o.node}:{a:c,b:a,node:o.node})}}return t}function uc(i,e,t,n){let s=i.positions;for(let r=0;r<i.indices.length;r+=3){let[o,a,c]=[i.indices[r],i.indices[r+1],i.indices[r+2]];if(t!==void 0&&(s[o*3+1]!==t||s[a*3+1]!==t||s[c*3+1]!==t))continue;let l=[s[o*3],s[o*3+2]],h=[s[a*3],s[a*3+2]],d=[s[c*3],s[c*3+2]];Fn(h[0]-l[0],h[1]-l[1],d[0]-l[0],d[1]-l[1])>0&&n.push({node:e,p:[l,h,d]})}}var dc=i=>{let e=1/0,t=-1/0;for(let n=1;n<i.positions.length;n+=3){let s=i.positions[n];s<e&&(e=s),s>t&&(t=s)}return[e,t]},dr=class{constructor(){_n(this,"positions",[]);_n(this,"weight",[]);_n(this,"caster",[]);_n(this,"indices",[])}vertex(e,t,n,s,r){return this.positions.push(e,t,n),this.weight.push(s),this.caster.push(r),this.weight.length-1}tri(e,t,n){this.indices.push(e,t,n)}quad(e,t,n,s){this.indices.push(e,t,n,e,n,s)}};function Un(i){let e=i.b[0]-i.a[0],t=i.b[1]-i.a[1],n=c_(e,t);return{d:[e,t],len:n,u:[e/n,t/n],n:[t/n,-e/n]}}var mn=(i,e)=>[en(i[0]*e*1e3),en(i[1]*e*1e3)],vi=(i,e)=>[i[0]+e[0],i[1]+e[1]],d_=8;function Hu(i,e,t){let n={edges:0,convex:0,concave:0,flatJoints:0,dropped:0,furniture:0,fenceSides:0,stairEdges:0,triangles:0,probes:0,tests:0},s=[],r=[],o=[...new Set(i.map(l=>ku(l.key)))].sort((l,h)=>l-h),a=o[0],c=xs.liftMm*1e3;for(let l of o){let h=i.map((M,E)=>[M,E]).filter(([M])=>ku(M.key)===l),d=[];for(let[M]of h)(M.kind==="floor"||M.kind==="slab"||M.kind==="outdoor"||M.flat===!0)&&u_(M,!0,void 0,d);let u=new Aa(d),p=l===a?e?.y:void 0,_=M=>{let E;for(let g of M){n.probes++;let v=p;for(let N of u.at(g))n.tests++,!(v!==void 0&&N.y<=v)&&Vu(N,g)&&(v=N.y);v!==void 0&&(E===void 0||v>E)&&(E=v)}return E===void 0?void 0:E+c},x=new dr,m=new dr,f=new dr,w=(M,E,g,v,N)=>{let R=x.vertex(M.a[0],v,M.a[1],1,N),D=x.vertex(M.b[0],v,M.b[1],1,N),U=x.vertex(M.b[0]+g[0],v,M.b[1]+g[1],0,N),z=x.vertex(M.a[0]+E[0],v,M.a[1]+E[1],0,N);x.quad(R,D,U,z)},A=(M,E,g)=>{let v=Un(M),N=[en((M.a[0]+M.b[0])/2),en((M.a[1]+M.b[1])/2)],R=z=>[en(z[0]/2),en(z[1]/2)],D=[en((E[0]+g[0])/4),en((E[1]+g[1])/4)],U=[vi(N,D)];return v.len>2e3&&U.push(vi(vi(M.a,mn(v.u,1)),R(E)),vi(vi(M.b,mn(v.u,-1)),R(g))),U},S=h.filter(([M])=>M.band!==void 0&&(M.kind==="wall"||M.kind==="column"));if(S.length>0){let M=s.push(S.map(([C])=>C.key))-1,E=1/0;for(let[C]of S)E=Math.min(E,dc(C)[0]);let g=[];for(let[C,W]of S)uc(C,W,E,g);let v=new Aa(g.map(C=>({a:C.p[0],b:C.p[1],c:C.p[2],y:E,node:C.node}))),N=C=>{n.probes++;for(let W of v.at(C))if(n.tests++,Vu(W,C))return!0;return!1},R=hc(g).flatMap(C=>{let W=Un(C),K=[0,1],[ve,we]=[Math.min(C.a[0],C.b[0]),Math.max(C.a[0],C.b[0])],[G,he]=[Math.min(C.a[1],C.b[1]),Math.max(C.a[1],C.b[1])];for(let ye of v.near(ve,G,we,he))if(ye.node!==C.node){n.tests++;for(let[Ve,Me]of[[ye.a,ye.b],[ye.b,ye.c],[ye.c,ye.a]]){let Fe=W.d[0]*(Me[1]-Ve[1])-W.d[1]*(Me[0]-Ve[0]);if(Fe===0)continue;let Te=((Ve[0]-C.a[0])*(Me[1]-Ve[1])-(Ve[1]-C.a[1])*(Me[0]-Ve[0]))/Fe,De=((Ve[0]-C.a[0])*W.d[1]-(Ve[1]-C.a[1])*W.d[0])/Fe;Te>0&&Te<1&&De>=0&&De<=1&&K.push(Te)}}K.sort((ye,Ve)=>ye-Ve);let fe=ye=>ye===0?C.a:ye===1?C.b:[en(C.a[0]+W.d[0]*ye),en(C.a[1]+W.d[1]*ye)],Ee=[],le;for(let ye=0;ye+1<K.length;ye++){let Ve=K[ye],Me=K[ye+1];if(Me-Ve<=0)continue;let Fe=fe((Ve+Me)/2),Te=!N(vi(Fe,mn(W.n,1)));Te&&le===void 0&&(le=Ve),Te||(n.dropped++,le!==void 0&&Ee.push({a:fe(le),b:fe(Ve),node:C.node}),le=void 0)}return le!==void 0&&Ee.push({a:fe(le),b:C.b,node:C.node}),Ee.filter(ye=>ye.a[0]!==ye.b[0]||ye.a[1]!==ye.b[1])}),D=C=>i[C.node]?.band??0,U=C=>`${C[0]},${C[1]}`,z=new Map,I=new Map;for(let C of R)z.set(U(C.b),[...z.get(U(C.b))??[],C]),I.set(U(C.a),[...I.get(U(C.a))??[],C]);let q=new Map,Z=new Map;for(let C of R){let W=mn(Un(C).n,D(C));q.set(C,W),Z.set(C,W)}let B=[];for(let C of[...z.keys()].sort()){let W=z.get(C)??[],K=I.get(C)??[];if(W.length!==1||K.length!==1)continue;let ve=W[0],we=K[0],G=Un(ve),he=Un(we),fe=Fn(G.d[0],G.d[1],he.d[0],he.d[1]);if(lc(G.d,he.d,1,1)){let Ee=[G.n[0]+he.n[0],G.n[1]+he.n[1]],le=1+G.n[0]*he.n[0]+G.n[1]*he.n[1];Z.set(ve,mn([Ee[0]/le,Ee[1]/le],D(ve))),q.set(we,mn([Ee[0]/le,Ee[1]/le],D(we))),fe!==0&&n.flatJoints++;continue}fe!==0&&B.push({v:ve.b,si:ve,so:we,turn:fe})}for(let C of R){let W=q.get(C),K=Z.get(C),ve=_(A(C,W,K));ve!==void 0&&(w(C,W,K,ve,M),n.edges++)}let ee=[];for(let[,C]of S){let W=t?.[C]??[];for(let K=0;K+5<W.length;K+=6)W[K]===W[K+3]&&W[K+2]===W[K+5]&&W[K+1]!==W[K+4]&&ee.push([W[K],W[K+2]])}for(let{v:C,si:W,so:K,turn:ve}of B){let we=Un(W),G=Un(K),he=D(W),fe=D(K);if(ve>0){let Ee=[];for(let Te=0;Te<16;Te++){let De=[wa[Te],Nu[Te]];Fn(we.n[0],we.n[1],De[0],De[1])>0&&Fn(De[0],De[1],G.n[0],G.n[1])>0&&Ee.push(De)}Ee.sort((Te,De)=>-Math.sign(Fn(Te[0],Te[1],De[0],De[1])));let le=[we.n,...Ee.slice(0,d_-1),G.n],ye=le.map((Te,De)=>mn(Te,he+(fe-he)*De/(le.length-1))),Ve=_(ye.map(Te=>vi(C,[en(Te[0]/2),en(Te[1]/2)])));if(Ve===void 0)continue;let Me=x.vertex(C[0],Ve,C[1],1,M),Fe=ye.map(Te=>x.vertex(C[0]+Te[0],Ve,C[1]+Te[1],0,M));for(let Te=0;Te+1<Fe.length;Te++)x.tri(Me,Fe[Te],Fe[Te+1]);n.convex++}else{let Ee=Math.max(he,fe),le=_([vi(C,mn([we.n[0]+G.n[0],we.n[1]+G.n[1]],Ee/2))]);if(le===void 0)continue;let ye=Math.min(dc(i[W.node])[1],dc(i[K.node])[1]);if(ye<=le)continue;let Ve=(Me,Fe,Te)=>{let De=Te?[-Me.d[0],-Me.d[1]]:Me.d,Je=Math.min(Fe*1e3,Me.len);for(let O of ee){let Rt=O[0]-C[0],it=O[1]-C[1];if(Fn(De[0],De[1],Rt,it)!==0)continue;let st=(De[0]*Rt+De[1]*it)/Me.len;st>0&&st<Je&&(Je=st)}if(Je<=0)return;let ct=mn(Me.n,xs.liftMm),yt=mn(Te?[-Me.u[0],-Me.u[1]]:Me.u,Je/1e3),et=C[0]+ct[0],pt=C[1]+ct[1],Xe=m.vertex(et,le,pt,1,M),vt=m.vertex(et,ye,pt,1,M),Lt=m.vertex(et+yt[0],ye,pt+yt[1],0,M),Ft=m.vertex(et+yt[0],le,pt+yt[1],0,M);m.quad(Xe,vt,Lt,Ft)};Ve(we,he,!0),Ve(G,fe,!1),n.concave++}}}for(let[M,E]of h){if(M.kind!=="fence"||M.band===void 0)continue;let g=s.push([M.key])-1,v=[...new Set(M.positions.filter((R,D)=>D%3===1))].sort((R,D)=>R-D),N=new Set;for(let R of v){let D=[];uc(M,E,R,D);for(let U of hc(D)){if(Un(U).len<=2*M.band*1e3)continue;let z=`${U.a[0]},${U.a[1]},${U.b[0]},${U.b[1]}`;if(N.has(z))continue;N.add(z);let I=mn(Un(U).n,M.band),q=_(A(U,I,I));q!==void 0&&(w(U,I,I,q,g),n.fenceSides++)}}}for(let[M,E]of h){if(M.kind!=="stair"||M.band===void 0)continue;let g=s.push([M.key])-1,v=[];uc(M,E,void 0,v);for(let N of hc(v)){let R=mn(Un(N).n,M.band),D=_(A(N,R,R));D!==void 0&&(w(N,R,R,D,g),n.stairEdges++)}}for(let[M]of h){if(M.kind!=="furniture"||M.band===void 0||M.positions.length===0)continue;let E=1/0,g=-1/0,v=1/0,N=-1/0;for(let C=0;C<M.positions.length;C+=3){let W=M.positions[C],K=M.positions[C+2];W<E&&(E=W),W>g&&(g=W),K<v&&(v=K),K>N&&(N=K)}let R=M.band*1e3,D=en((E+g)/2),U=en((v+N)/2),z=_([[D,U],[D,v-R/2],[g+R/2,U],[D,N+R/2],[E-R/2,U]]);if(z===void 0)continue;let I=s.push([M.key])-1,q=[[E,v],[g,v],[g,N],[E,N]],Z=[[E-R,v-R],[g+R,v-R],[g+R,N+R],[E-R,N+R]],B=q.map(C=>f.vertex(C[0],z,C[1],1,I)),ee=Z.map(C=>f.vertex(C[0],z,C[1],0,I));for(let C=0;C<4;C++){let W=(C+1)%4;f.quad(B[C],B[W],ee[W],ee[C])}n.furniture++}for(let[M,E]of[["foot",x],["corner",m],["halo",f]])E.indices.length!==0&&(n.triangles+=E.indices.length/3,r.push({level:l,cls:M,...E}))}return{layers:r,casters:s,counts:n}}var fr=(i,e,t)=>`${i} ${i===1?e:t}`,Wu=i=>`${Number(i.toFixed(2))} m\xB2`;function fc(i,e,t){let n;for(let s of i)s.stage===e&&!s.hidden&&(n===void 0||s.appear<n)&&(n=s.appear);return n??t}function Xu(i,e,t){let n=fc(e,"rooms",wt.drawn),s=fc(e,"openings",wt.drawn),r=[],o=(a,c)=>{t>=a&&r.push(c)};return i.storeys!==void 0&&o(fc(e,"brief",0),{id:"storeys",text:fr(i.storeys,"storey","storeys")}),o(n,{id:"rooms",text:fr(i.rooms,"room","rooms")}),i.areaNet!==void 0&&o(n,{id:"area-net",text:`floor area ${Wu(i.areaNet)} (net)`}),o(n,{id:"area-centre",text:`floor area ${Wu(i.areaCentre)} (to wall centre lines)`}),o(s,{id:"doors",text:fr(i.doors,"door","doors")}),o(s,{id:"windows",text:fr(i.windows,"window","windows")}),o(wt.svgIn,{id:"warnings",text:i.warnings===0?"no warnings":fr(i.warnings,"warning","warnings")}),r}function qu(i,e){let t=e.map(s=>`${s.id}=${s.text}`).join("|");if(i.dataset.stripKey===t)return;i.dataset.stripKey=t,i.hidden=e.length===0;let n=[];for(let s of e){let r=i.ownerDocument.createElement("span");r.dataset.fact=s.id,r.textContent=s.text,n.length>0&&n.push(i.ownerDocument.createTextNode(" ")),n.push(r)}i.replaceChildren(...n)}var f_=5,Ra=.9,pc={light:{background:"#f7f5f0",edge:"#8f877c",cap:Pu,colors:Object.fromEntries(Object.entries(Nn).map(([i,e])=>[i,e.srgb]))},dark:{background:"#0f2235",edge:"#cfe3f5",cap:"#cfe3f5",colors:{slab:"#20384f",floor:"#1b3248",column:"#3b5b78",wall:"#2e4d6a",roof:"#14283c",door:"#7aa6c9","window:frame":"#5d86a8","window:glass":"#86c5ee","window:reveal":"#5d86a8","window:sill":"#7aa6c9","window:board":"#7aa6c9","opening:lining":"#7aa6c9","opening:casing":"#7aa6c9","stair:rail":"#3b5b78","wall:demolish":"#e07a5f",furniture:"#3f6a8f",stair:"#5d86a8"}}},ti={sky:16317439,ground:14275271,hemi:2.4,keyColour:16775922,key:2.7,keyFrom:[-1,1.25,.3],fillColour:15002869,fill:.5,fillFrom:[.7,.5,-.6]},p_=12;function Yu(i,e,t,n={}){let s=pc[e.theme],r=s.colors.furniture,o=e.width,a=e.height,c=document.createElement("canvas");c.width=o,c.height=a,i.width=o,i.height=a;let l=i.getContext("2d",{willReadFrequently:!0}),h=new pa({canvas:c,antialias:!1,preserveDrawingBuffer:!0});h.setPixelRatio(1),h.setSize(o,a,!1),h.toneMapping=Zs;let d=new Ns;d.background=new We(s.background),d.add(new Ws(ti.sky,ti.ground,ti.hemi));let u=new ls(ti.keyColour,ti.key);u.position.set(...ti.keyFrom),d.add(u);let p=new ls(ti.fillColour,ti.fill);p.position.set(...ti.fillFrom),d.add(p);let _=new Map,x=[],m=new Map(e.events.map(P=>[P.key,P.rank])),{faces:f,lines:w}=Bu(e.nodes,e.nodes.map(P=>m.get(P.key)??0)),A=[];for(let[P,ne]of e.nodes.entries()){let $=w[P],ie=f[P],oe=cc(ne,ie),re={...ne,positions:oe.positions,indices:oe.base},J=new Float32Array(re.positions.length),de=1/0,Ie=-1/0;for(let qe=1;qe<re.positions.length;qe+=3)de=Math.min(de,re.positions[qe]/1e3),Ie=Math.max(Ie,re.positions[qe]/1e3);for(let qe=0;qe<re.positions.length;qe+=3){let bt=re.positions[qe]/1e3,Dt=re.positions[qe+1]/1e3,at=re.positions[qe+2]/1e3;J[qe]=bt,J[qe+1]=Dt-de,J[qe+2]=at}let ce=re.part?`${re.kind}:${re.part}`:re.kind,Ne=new Rn;Ne.position.y=de+(re.lift??0);let tt=(qe,bt,Dt,at,tn,Be,hn=!0)=>{let un=new Yt;un.setAttribute("position",qe),un.setIndex(bt),Be&&un.computeVertexNormals();let On=ce==="wall:demolish",Bn=re.kind==="floor"||re.kind==="slab",ys=new as({color:new We(Dt),transparent:at||On,opacity:at?tn:On?.3:1,depthWrite:!On,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:re.kind==="outdoor"?8:Bn?4:1});x.push(un,ys);let vs=new Kt(un,ys);if(Ne.add(vs),re.kind!=="slab"&&!at&&hn){let ni=new ks(un,30),pr=new Ci({color:new We(s.edge)});x.push(ni,pr),Ne.add(new rs(ni,pr))}return vs},_t=new Vt(J,3);if(re.groups){let qe=0;for(let{slot:bt,count:Dt}of re.groups){let at=re.indices.slice(qe,qe+Dt);if(qe+=Dt,bt==="body")tt(_t,at,s.colors[ce]??s.colors[re.kind]??r,!1,1,!1);else{let{alpha:tn}=$t[bt];tt(_t,at,Lu(bt,e.theme,r),tn<1,tn,!1)}}}else if(re.colour)tt(_t,re.indices,Iu(re.colour,e.theme,pc.dark.colors.floor),!1,1,!0,re.kind!=="fence");else if(re.finish)tt(_t,re.indices,Du(re.finish,e.theme,pc.dark.colors.floor),!1,1,!0);else if(ce==="wall"){let qe=at=>re.positions[at*3+1]/1e3===Ie,bt=[],Dt=[];for(let at=0;at<re.indices.length;at+=3){let tn=re.indices.slice(at,at+3);(tn.every(qe)?bt:Dt).push(...tn)}tt(_t,Dt,s.colors.wall??r,!1,1,!0,$===void 0),bt.length&&tt(_t,bt,s.cap,!1,1,!0,!1)}else{let qe=ce==="window:glass";tt(_t,re.indices,s.colors[ce]??s.colors[re.kind]??r,qe,qe?Nn["window:glass"].alpha:1,!0,$===void 0)}if(ie&&ie.group>=0){let qe=s.colors[ce]??s.colors[re.kind]??r;A.push({key:re.key,...oe.alone.length>0?{alone:tt(_t,oe.alone,qe,!1,1,!0,!1)}:{},...oe.joined.length>0?{joined:tt(_t,oe.joined,qe,!1,1,!0,!1)}:{},group:ie.group})}if($&&$.length>0){let qe=new Float32Array($.length);for(let at=0;at<$.length;at+=3)qe[at]=$[at]/1e3,qe[at+1]=$[at+1]/1e3-de,qe[at+2]=$[at+2]/1e3;let bt=new Yt;bt.setAttribute("position",new Vt(qe,3));let Dt=new Ci({color:new We(s.edge)});x.push(bt,Dt),Ne.add(new rs(bt,Dt))}Ne.visible=!1,d.add(Ne),_.set(re.key,{g:Ne,flat:Math.min(1,p_/Math.max(1e-6,Ie-de)),base:de,lift:re.lift??0})}let[S,M,E,g]=e.viewBox,v=o/a,{cx:N,cz:R,ow:D,oh:U}=sc(e.viewBox,v),z=ar(e.nodes,{ghosts:!0}),I=new k(...z.lo),q=new k(...z.hi),Z=q.y+1e3,B,ee;if(e.ground){let P=e.ground.y/1e3,ne=Sa.marginMm,[$,ie,oe,re]=[I.x-ne,I.z-ne,q.x+ne,q.z+ne],J=new Yt;J.setAttribute("position",new Vt(new Float32Array([$,P,ie,$,P,re,oe,P,re,oe,P,ie]),3)),J.setIndex([0,1,2,0,2,3]);let de=new as({color:new We(e.theme==="light"?Sa.light:Sa.dark),transparent:!0,opacity:0,depthWrite:!0,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:16});x.push(J,de),B=new Kt(J,de),ee=de,B.renderOrder=-1,B.visible=!1,d.add(B)}let C=e.theme==="light"?xs.alpha:xs.alphaDark,W=[],K=new Map(e.events.map(P=>[P.key,P])),ve=[];if(e.shadows!==!1){let P=Hu(e.nodes,e.ground,w);ve=P.casters.map($=>{let ie;for(let oe of $){let re=K.get(oe);re&&(!ie||re.riseTo>ie.riseTo)&&(ie=re)}return ie});let ne=new Map(e.nodes.map($=>[$.key,$.lift??0]));for(let $ of P.layers){let ie=new Float32Array($.positions.length);for(let Ne=0;Ne<$.positions.length;Ne++)ie[Ne]=$.positions[Ne]/1e3;let oe=new Vt(new Float32Array($.weight.length*4),4),re=new Yt;re.setAttribute("position",new Vt(ie,3)),re.setAttribute("color",oe),re.setIndex($.indices);let J=new ss({color:16777215,vertexColors:!0,transparent:!0,depthWrite:!1,side:pn,polygonOffset:!0,polygonOffsetFactor:0,polygonOffsetUnits:-2});x.push(re,J);let de=new Kt(re,J);de.renderOrder=-.5,de.visible=!1;let Ie=new Rn;Ie.add(de),d.add(Ie);let ce=P.casters[$.caster[0]]?.[0]??"";W.push({mesh:de,group:Ie,alpha:oe,weight:$.weight,caster:$.caster,scale:$.cls==="corner"?C.corner:$.cls==="halo"?C.furniture:C.floor,key:ce,lift:ne.get(ce)??0})}}let we=new Pi(-D/2,D/2,U/2,-U/2,1,Z+1e5);we.up.set(0,0,-1),we.position.set(N,Z+5e4,R),we.lookAt(N,0,R);let G=new Wt(ya,v,10,1e9),he=P=>Su(e.nodes,e.events,{elevation:e.elevation,azimuth:ic,fov:Dn,aspect:P}),fe=he(v),Ee=q.clone().sub(I),le=I.clone().add(q).multiplyScalar(.5),ye=P=>{let ne=Math.max(...P.map($=>le.distanceTo(new k(...$.target))));return Math.max(Ee.length()*.75+ne+Math.hypot(le.x-(S+E/2),le.z-(M+g/2)),1e3)},Ve=ye(fe.slice(0,ba(e.events))),Me=ye(fe),Fe=P=>P*Math.PI/180,Te=new Image,De=new Promise(P=>{Te.onload=()=>P(),Te.onerror=()=>P()});Te.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e.svg)))}`;let Je=!1,ct={cx:N,cz:R,oh:U,elevation:e.elevation},yt=new Map(e.events.map(P=>[P.key,P.storey??0])),et=Math.max(1,...e.events.filter(P=>!P.hidden).map(P=>(P.storey??0)+1)),pt=et,Xe="replay",vt=0,Lt=!1,Ft=Ee.length()/2,O=P=>Math.max(Me,le.distanceTo(P)+Ft);function Rt(P,ne){let{fov:$,dist:ie,elevation:oe,azimuth:re}=P,J=new k(...P.target),de=Fe(oe);G.fov=$,G.near=Math.max(10,ie-ne),G.far=ie+ne,G.updateProjectionMatrix(),G.up.set(0,0,-1),de<Fe(89.99)&&G.up.set(0,1,0),G.position.set(...nc([J.x,J.y,J.z],ie,{elevation:oe,azimuth:re})),G.lookAt(J)}let it={events:e.events,fits:fe,frame:ct,box:ar(e.nodes,{settle:1}),aspect:v},st=new Map,_e=P=>{let ne=st.get(P);if(ne)return ne;let $=Eu(P,it);return st.set(P,$),$},mt,Le=()=>{},Oe=()=>{},T=()=>{},y=new Set,V=()=>{for(let P of y)P()},ae=Math.max(1,Math.min(4,Math.floor(e.supersample??1)));function se(P){let ne=ae*ae,$=new Uint32Array(o*a*4);l.globalAlpha=1;for(let oe=0;oe<ae;oe++)for(let re=0;re<ae;re++){P.setViewOffset(o,a,(re+.5)/ae-.5,(oe+.5)/ae-.5,o,a),h.render(d,P),l.drawImage(c,0,0);let J=l.getImageData(0,0,o,a).data;for(let de=0;de<J.length;de++)$[de]=$[de]+J[de]}P.clearViewOffset();let ie=l.createImageData(o,a);for(let oe=0;oe<$.length;oe++)ie.data[oe]=Math.floor(($[oe]+(ne>>1))/ne);l.putImageData(ie,0,0)}function ue(P){vt=P,Lt=!0,t&&e.facts&&qu(t,Xu(e.facts,e.events,Math.min(1,Math.max(0,P))));let ne=or(e.events,P);B&&ee&&(B.visible=ne.ground>0,ee.opacity=ne.ground);for(let[oe,{g:re,flat:J,base:de,lift:Ie}]of _){let ce=ne.nodes.get(oe);re.visible=ce?.visible===!0&&(yt.get(oe)??0)<pt,re.scale.y=Math.max(J,ce?.rise??0),Ie!==0&&(re.position.y=de+va(Ie,ne.settle))}let $=zu(f,oe=>{let re=e.nodes[oe]?.key??"";return _.get(re)?.g.visible===!0&&(ne.nodes.get(re)?.rise??0)>=1});for(let{group:oe,alone:re,joined:J}of A){let de=$.has(oe);re&&(re.visible=!de),J&&(J.visible=de)}if(W.length>0){let oe=Math.min(1,Math.max(0,P)),re=ve.map(J=>Gu(J,oe));for(let J of W){let de=J.alpha.array,Ie=!1,ce=!1;for(let Ne=0;Ne<J.weight.length;Ne++){let tt=Math.fround(J.weight[Ne]*J.scale*re[J.caster[Ne]]);de[Ne*4+3]!==tt&&(de[Ne*4+3]=tt,Ie=!0),tt>0&&(ce=!0)}Ie&&(J.alpha.needsUpdate=!0),J.mesh.visible=ce&&(yt.get(J.key)??0)<pt,J.group.position.y=va(J.lift,ne.settle)}}let ie=we;if(Xe==="free"&&mt){let oe=G.position.distanceTo(mt.target),re=O(mt.target);G.near=Math.max(10,oe-re),G.far=oe+re,G.updateProjectionMatrix(),ie=G}else if(Xe!=="replay"&&Xe!=="free"){let oe=_e(Xe);Rt(oe,O(new k(...oe.target))),ie=G}else(ne.tilt>0||ne.dolly>0)&&(Rt(Ma(ne,fe,ct),ne.settle>0?Me:Ve),ie=G);if(ae===1?(h.render(d,ie),l.globalAlpha=1,l.drawImage(c,0,0)):se(ie),Xe==="replay"&&ne.svg>0&&Te.complete&&Te.naturalWidth>0){let oe=Math.min(o/E,a/g),re=E*oe,J=g*oe;l.globalAlpha=ne.svg,l.drawImage(Te,(o-re)/2,(a-J)/2,re,J),l.globalAlpha=1}}function me(P){Je||(Xe!=="replay"&&(Le(),Xe="replay",V()),ue(P),T())}async function j(){let P=l.getImageData(0,0,o,a).data,ne=await crypto.subtle.digest("SHA-256",P);return[...new Uint8Array(ne)].map($=>$.toString(16).padStart(2,"0")).join("")}let Q=n.interactive?pe():void 0;function pe(){let P=new xa(G,i);mt=P,P.enableDamping=!1,P.screenSpacePanning=!1,P.minPolarAngle=Fe(90-lr.max),P.maxPolarAngle=Fe(90-lr.min);let ne=Ru(z);P.cursor.set(...ne.centre);let $=i.getAttribute("tabindex");i.tabIndex=0;let ie=0,oe=!1,re=!1,J=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,de=()=>{ie=0,!(Je||Xe!=="free")&&(P.update()||oe)&&(ie=requestAnimationFrame(de))},Ie=()=>{P.enableDamping&&!ie&&(ie=requestAnimationFrame(de))};Le=()=>{ie&&cancelAnimationFrame(ie),ie=0,oe=!1,P.enableDamping&&(re=!0,P.enableDamping=!1,P.update(),re=!1)};let ce=(Be,hn,un)=>{G.fov=un,G.up.set(0,1,0),G.position.set(...Be),P.target.set(...wu(Be,hn,it.box.lo[1])),G.lookAt(P.target);let On=G.position.distanceTo(P.target),Bn=Au(fe,un);P.minDistance=Math.min(Bn.min,On),P.maxDistance=Math.max(Bn.max,On),P.maxTargetRadius=Math.max(ne.radius,P.target.distanceTo(P.cursor)),P.enableDamping=!J()},Ne=()=>{if(Xe==="free")return;let Be=Xe==="replay"?Tu(Ma(or(e.events,vt),fe,ct)):_e(Xe);ce(nc(Be.target,Be.dist,Be),Be.target,Be.fov)},tt=()=>{Xe!=="free"&&(Xe="free",n.onTake?.(),V(),Ie())},_t=!1;T=()=>{_t&&Ne()},P.addEventListener("start",()=>{Ne(),_t=!0,oe=!0}),P.addEventListener("end",()=>{_t=!1,oe=!1}),P.addEventListener("change",()=>{re||Je||(_t=!1,tt(),ue(vt))});let qe=Fe(f_),bt=new Map([["ArrowLeft",()=>P.rotateLeft(qe)],["ArrowRight",()=>P.rotateLeft(-qe)],["ArrowUp",()=>P.rotateUp(qe)],["ArrowDown",()=>P.rotateUp(-qe)],["+",()=>P.dollyIn(Ra)],["=",()=>P.dollyIn(Ra)],["-",()=>P.dollyOut(Ra)],["_",()=>P.dollyOut(Ra)]]),Dt=Be=>{let hn=bt.get(Be.key);!hn||Je||Be.ctrlKey||Be.metaKey||Be.altKey||(Be.preventDefault(),Ne(),hn(),Ie())};i.addEventListener("keydown",Dt),Oe=()=>{i.removeEventListener("keydown",Dt),P.dispose(),$===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",$),y.clear()};let at=Be=>Math.min(et,Math.max(1,Math.round(Be))),tn=()=>pt===et?"all":pt;return{at:Be=>{Je||ue(Be)},preset:Be=>{Je||(Le(),Xe=Be,n.onTake?.(),V(),ue(vt))},reset:()=>{Je||(Le(),Xe="replay",pt=et,V(),ue(vt))},storeys:et,showStoreys:Be=>{Je||(pt=at(Be),V(),ue(vt))},onChange:Be=>(y.add(Be),()=>y.delete(Be)),spin:Be=>{if(Je||oe||!Number.isFinite(Be)||Be===0)return;Ne();let hn=P.enableDamping;P.enableDamping=!1,P.rotateLeft(Fe(Be)),P.update(),P.enableDamping=hn},get shown(){return pt},get camera(){return Xe},state:()=>Xe==="free"?{camera:"free",position:G.position.toArray(),target:P.target.toArray(),fov:G.fov,storeys:tn()}:{camera:Xe,storeys:tn()},restore:Be=>{Je||(Le(),pt=Be.storeys==="all"?et:at(Be.storeys),Be.camera==="free"&&ce(Be.position,Be.target,Be.fov),Xe=Be.camera,Xe!=="replay"&&n.onTake?.(),V())}}}function L(P,ne){if(Je)return;let $=Math.max(1,Math.round(P)),ie=Math.max(1,Math.round(ne));$===o&&ie===a||(o=$,a=ie,c.width=o,c.height=a,i.width=o,i.height=a,h.setSize(o,a,!1),v=o/a,{cx:N,cz:R,ow:D,oh:U}=sc(e.viewBox,v),we.left=-D/2,we.right=D/2,we.top=U/2,we.bottom=-U/2,we.position.set(N,Z+5e4,R),we.lookAt(N,0,R),we.updateProjectionMatrix(),G.aspect=v,G.updateProjectionMatrix(),fe=he(v),Ve=ye(fe.slice(0,ba(e.events))),Me=ye(fe),ct={cx:N,cz:R,oh:U,elevation:e.elevation},it={...it,fits:fe,frame:ct,aspect:v},st.clear(),Lt&&ue(vt))}function te(){if(!Je){Le(),Je=!0,Oe();for(let P of x)P.dispose();h.dispose(),h.forceContextLoss()}}return{seek:me,frameHash:j,ready:De,dispose:te,resize:L,...Q?{view:Q}:{}}}var m_=[["iso","Iso","Iso view: the replay's end view"],["top","Top","Top view, the plan's top edge up"],["north","N","View from north: level, from the plan's top edge"],["east","E","View from east: level, from the plan's right edge"],["south","S","View from south: level, from the plan's bottom edge"],["west","W","View from west: level, from the plan's left edge"]],g_="Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";function Zu(i,e={}){let t=document.createElement("div");t.className="archlang-views",t.setAttribute("role","toolbar"),t.setAttribute("aria-label","3D view");let n=(h,d,u)=>{let p=document.createElement("button");return p.type="button",e.buttonClass&&(p.className=e.buttonClass),p.textContent=h,p.setAttribute("aria-label",d),p.addEventListener("click",u),p},s=[],r=[],o=()=>{for(let[h,d]of s)d.setAttribute("aria-pressed",String(i.camera===h));for(let[h,d]of r.entries())d.setAttribute("aria-pressed",String(h+1===i.shown))},a=h=>{};for(let[h,d,u]of m_){let p=n(d,u,()=>{i.preset(h),a(!0)});p.dataset.preset=h,s.push([h,p])}let c="Reset the view: the replay's own camera, every storey shown";if(e.compact){t.classList.add("archlang-views-compact"),t.append(n("\u27F2 Reset",c,()=>i.reset()));let h=document.createElement("span");h.className="archlang-views-menu";let d=document.createElement("span");d.className="archlang-views-presets",d.id=`${e.hintId??"archlang-views"}-presets`,d.setAttribute("role","group"),d.setAttribute("aria-label","Preset views"),d.hidden=!0,d.append(...s.map(([,x])=>x));let u=n("View \u25BE","View presets: iso, top, and from north, east, south and west",()=>d.hidden?_():a(!1));u.setAttribute("aria-expanded","false"),u.setAttribute("aria-controls",d.id);let p=x=>{h.contains(x.target)||a(!1)},_=()=>{d.hidden=!1,u.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",p,!0),(s.find(([x])=>i.camera===x)?.[1]??s[0]?.[1])?.focus()};a=x=>{d.hidden||(d.hidden=!0,u.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",p,!0),x&&u.focus())},h.addEventListener("keydown",x=>{x.key!=="Escape"||d.hidden||(x.preventDefault(),x.stopPropagation(),a(!0))}),h.addEventListener("focusout",x=>{h.contains(x.relatedTarget)||a(!1)}),h.append(u,d),t.append(h)}else t.append(...s.map(([,h])=>h)),t.append(n("Reset",c,()=>i.reset()));if(i.storeys>1&&e.storeys!==!1){let h=document.createElement("span");h.className="archlang-views-storeys",h.setAttribute("role","group"),h.setAttribute("aria-label","Storeys shown"),h.append("Storeys ");for(let d=1;d<=i.storeys;d++){let u=d===i.storeys,p=n(u?"All":d===1?"1":`1\u2013${d}`,u?"Show every storey":`Show storeys 1 to ${d}, hide the ones above`,()=>i.showStoreys(d));p.dataset.storeys=String(d),r.push(p),h.append(p)}t.append(h)}i.onChange(o),o();let l=document.createElement("span");return l.className="archlang-views-hint",e.hintId&&(l.id=e.hintId),l.textContent=g_,t.append(l),t}function __(){let i=document.getElementById("archlang-replay-payload");return JSON.parse(i?.textContent??"{}")}function x_(){let i=__(),e=document.getElementById("archlang-replay"),t=document.getElementById("archlang-replay-strip")??void 0,n=0,s=()=>{n&&cancelAnimationFrame(n),n=0},{seek:r,frameHash:o,ready:a,view:c}=Yu(e,i,t,{interactive:!0,onTake:s});window.__seek=r,window.__frameHash=o,window.__ready=a.then(()=>r(0));let l=document.getElementById("archlang-replay-views");c&&l&&(l.replaceWith(Zu(c,{hintId:"archlang-replay-hint"})),e.setAttribute("aria-describedby","archlang-replay-hint"));let h=document.getElementById("archlang-replay-t"),d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;window.__ready.then(()=>{if(window.__replayAutoplay===!1)return;if(d){r(1),h&&(h.value="1");return}let u,p=_=>{u??(u=_);let x=Math.min(1,(_-u)/(i.seconds*1e3));r(x),h&&(h.value=String(x)),n=x<1?requestAnimationFrame(p):0};n=requestAnimationFrame(p)}),h?.addEventListener("input",()=>{s(),r(Number(h.value))})}x_();})();