@chanmeng666/archlang-3d 0.8.0 → 0.9.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 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() {
1
+ "use strict";(()=>{var td=Object.defineProperty;var nd=(i,e,t)=>e in i?td(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var pn=(i,e,t)=>nd(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},Zc=0,il=1,$c=2;var Zs=1,Jc=2,us=3,gi=0,Jt=1,_n=2,Ii=0,ds=1,sl=2,rl=3,ol=4,Kc=5;var Li=100,jc=101,Qc=102,eh=103,th=104,nh=200,ih=201,sh=202,rh=203,al=204,ll=205,oh=206,ah=207,lh=208,ch=209,hh=210,uh=211,dh=212,fh=213,ph=214,Hr=0,Wr=1,Xr=2,ji=3,qr=4,Yr=5,Zr=6,$r=7,wo=0,mh=1,gh=2,Ln=0,cl=1,hl=2,ul=3,dl=4,fl=5,pl=6,$s=7;var ml=300,Di=301,fs=302,Eo=303,To=304,Jr=1e3,Cn=1001,Kr=1002,Pt=1003,_h=1004;var Js=1005;var Zt=1006,Ao=1007;var Kn=1008;var en=1009,gl=1010,_l=1011,ps=1012,Ro=1013,wn=1014,En=1015,Tn=1016,Co=1017,Po=1018,Ni=1020,xl=35902,yl=35899,vl=1021,bl=1022,An=1023,Yn=1026,jn=1027,Ml=1028,Io=1029,_i=1030,Lo=1031;var Do=1033,Ks=33776,js=33777,Qs=33778,er=33779,No=35840,Uo=35841,Fo=35842,Oo=35843,Bo=36196,zo=37492,ko=37496,Vo=37488,Go=37489,tr=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,nr=36285,ca=36286;var Cs=2300,jr=2301,Vr=2302,Ja=2303,Ka=2400,ja=2401,Qa=2402;var xh=3200;var ha=0,yh=1,Qn="",on="srgb",Ps="srgb-linear",Is="linear",ct="srgb";var Gr=7680;var vh=519,bh=512,Mh=513,Sh=514,Sl=515,wh=516,Eh=517,wl=518,El=519,Th=35044;var Tl="300 es",gn=2e3,Qi=2001;function id(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function sd(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function Ls(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Ah(){let i=Ls("canvas");return i.style.display="block",i}var vc={},es=null;function Al(...i){let e="THREE."+i.shift();es?es("log",e,...i):console.log(e,...i)}function Rh(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 Fe(...i){i=Rh(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 ke(...i){i=Rh(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 As(...i){let e=i.join(" ");e in vc||(vc[e]=!0,Fe(...i))}function Ch(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 Ph={[Hr]:Hr,[Xr]:Zr,[qr]:qr,[ji]:Yr,[Wr]:Wr,[Zr]:Xr,[$r]:$r,[Yr]:ji},Sn=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"],bc=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 Je(i,e,t){return Math.max(e,Math.min(t,i))}function Rl(i,e){return(i%e+e)%e}function rd(i,e,t,n,s){return n+(i-e)*(s-n)/(t-e)}function od(i,e,t){return i!==e?(t-i)/(e-i):0}function Rs(i,e,t){return(1-t)*i+t*e}function ad(i,e,t,n){return Rs(i,e,1-Math.exp(-t*n))}function ld(i,e=1){return e-Math.abs(Rl(i,e*2)-e)}function cd(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function hd(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function ud(i,e){return i+Math.floor(Math.random()*(e-i+1))}function dd(i,e){return i+Math.random()*(e-i)}function fd(i){return i*(.5-Math.random())}function pd(i){i!==void 0&&(bc=i);let e=bc+=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 md(i){return i*Ji}function gd(i){return i*ts}function _d(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function xd(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Cl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function yd(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),u=r((e-n)/2),d=o((e-n)/2),f=r((n-e)/2),_=o((n-e)/2);switch(s){case"XYX":i.set(a*h,c*u,c*d,a*l);break;case"YZY":i.set(c*d,a*h,c*u,a*l);break;case"ZXZ":i.set(c*u,c*d,a*h,a*l);break;case"XZX":i.set(a*h,c*_,c*f,a*l);break;case"YXY":i.set(c*f,a*h,c*_,a*l);break;case"ZYZ":i.set(c*_,c*f,a*h,a*l);break;default:Fe("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 Ih(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 Lh(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 Il={DEG2RAD:Ji,RAD2DEG:ts,generateUUID:ms,clamp:Je,euclideanModulo:Rl,mapLinear:rd,inverseLerp:od,lerp:Rs,damp:ad,pingpong:ld,smoothstep:cd,smootherstep:hd,randInt:ud,randFloat:dd,randFloatSpread:fd,seededRandom:pd,degToRad:md,radToDeg:gd,isPowerOfTwo:_d,ceilPowerOfTwo:xd,floorPowerOfTwo:Cl,setQuaternionFromProperEuler:yd,normalize:Lh,denormalize:Ih},Fl=class Fl{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=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Je(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}};Fl.prototype.isVector2=!0;var Ve=Fl,ln=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],u=n[s+3],d=r[o+0],f=r[o+1],_=r[o+2],x=r[o+3];if(u!==x||c!==d||l!==f||h!==_){let m=c*d+l*f+h*_+u*x;m<0&&(d=-d,f=-f,_=-_,x=-x,m=-m);let p=1-a;if(m<.9995){let w=Math.acos(m),T=Math.sin(w);p=Math.sin(p*w)/T,a=Math.sin(a*w)/T,c=c*p+d*a,l=l*p+f*a,h=h*p+_*a,u=u*p+x*a}else{c=c*p+d*a,l=l*p+f*a,h=h*p+_*a,u=u*p+x*a;let w=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=w,l*=w,h*=w,u*=w}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,o){let a=n[s],c=n[s+1],l=n[s+2],h=n[s+3],u=r[o],d=r[o+1],f=r[o+2],_=r[o+3];return e[t]=a*_+h*u+c*f-l*d,e[t+1]=c*_+h*d+l*u-a*f,e[t+2]=l*_+h*f+a*d-c*u,e[t+3]=h*_-a*u-c*d-l*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,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),u=a(r/2),d=c(n/2),f=c(s/2),_=c(r/2);switch(o){case"XYZ":this._x=d*h*u+l*f*_,this._y=l*f*u-d*h*_,this._z=l*h*_+d*f*u,this._w=l*h*u-d*f*_;break;case"YXZ":this._x=d*h*u+l*f*_,this._y=l*f*u-d*h*_,this._z=l*h*_-d*f*u,this._w=l*h*u+d*f*_;break;case"ZXY":this._x=d*h*u-l*f*_,this._y=l*f*u+d*h*_,this._z=l*h*_+d*f*u,this._w=l*h*u-d*f*_;break;case"ZYX":this._x=d*h*u-l*f*_,this._y=l*f*u+d*h*_,this._z=l*h*_-d*f*u,this._w=l*h*u+d*f*_;break;case"YZX":this._x=d*h*u+l*f*_,this._y=l*f*u+d*h*_,this._z=l*h*_-d*f*u,this._w=l*h*u-d*f*_;break;case"XZY":this._x=d*h*u-l*f*_,this._y=l*f*u-d*h*_,this._z=l*h*_+d*f*u,this._w=l*h*u+d*f*_;break;default:Fe("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],u=t[10],d=n+a+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(o-s)*f}else if(n>a&&n>u){let f=2*Math.sqrt(1+n-a-u);this._w=(h-c)/f,this._x=.25*f,this._y=(s+o)/f,this._z=(r+l)/f}else if(a>u){let f=2*Math.sqrt(1+a-n-u);this._w=(r-l)/f,this._x=(s+o)/f,this._y=.25*f,this._z=(c+h)/f}else{let f=2*Math.sqrt(1+u-n-a);this._w=(o-s)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Je(this.dot(e),-1,1)))}rotateTowards(e,t){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}},Ol=class Ol{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(Mc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mc.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),u=2*(r*n-o*t);return this.x=t+c*l+o*u-a*h,this.y=n+c*h+a*l-r*u,this.z=s+c*u+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=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){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 Ra.copy(this).projectOnVector(e),this.sub(Ra)}reflect(e){return this.sub(Ra.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(Je(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}};Ol.prototype.isVector3=!0;var k=Ol,Ra=new k,Mc=new ln,Bl=class Bl{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],u=n[7],d=n[2],f=n[5],_=n[8],x=s[0],m=s[3],p=s[6],w=s[1],T=s[4],S=s[7],E=s[2],M=s[5],g=s[8];return r[0]=o*x+a*w+c*E,r[3]=o*m+a*T+c*M,r[6]=o*p+a*S+c*g,r[1]=l*x+h*w+u*E,r[4]=l*m+h*T+u*M,r[7]=l*p+h*S+u*g,r[2]=d*x+f*w+_*E,r[5]=d*m+f*T+_*M,r[8]=d*p+f*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],u=h*o-a*l,d=a*c-h*r,f=l*r-o*c,_=t*u+n*d+s*f;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/_;return e[0]=u*x,e[1]=(s*l-h*n)*x,e[2]=(a*n-s*o)*x,e[3]=d*x,e[4]=(h*t-s*c)*x,e[5]=(s*r-a*t)*x,e[6]=f*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 As("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ca.makeScale(e,t)),this}rotate(e){return As("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ca.makeRotation(-e)),this}translate(e,t){return As("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ca.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 Ge=Bl,Ca=new Ge,Sc=new Ge().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),wc=new Ge().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function vd(){let i={enabled:!0,workingColorSpace:Ps,spaces:{},convert:function(s,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===ct&&(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===ct&&(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?Is: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({[Ps]:{primaries:e,whitePoint:n,transfer:Is,toXYZ:Sc,fromXYZ:wc,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:on},outputColorSpaceConfig:{drawingBufferColorSpace:on}},[on]:{primaries:e,whitePoint:n,transfer:ct,toXYZ:Sc,fromXYZ:wc,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:on}}}),i}var et=vd();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=Ls("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=Ls("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 Fe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},bd=0,ns=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:bd++}),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(Pa(s[o].image)):r.push(Pa(s[o]))}else r=Pa(s);n.url=r}return t||(e.images[this.uuid]=n),n}};function Pa(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}:(Fe("Texture: Unable to serialize Texture."),{})}var Md=0,Ia=new k,jt=class i extends Sn{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=Cn,s=Cn,r=Zt,o=Kn,a=An,c=en,l=i.DEFAULT_ANISOTROPY,h=Qn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Md++}),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 Ve(0,0),this.repeat=new Ve(1,1),this.center=new Ve(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(Ia).x}get height(){return this.source.getSize(Ia).y}get depth(){return this.source.getSize(Ia).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){Fe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Fe(`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!==ml)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 Cn: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 Cn: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=ml;jt.DEFAULT_ANISOTROPY=1;var zl=class zl{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],u=c[8],d=c[1],f=c[5],_=c[9],x=c[2],m=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(_-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(_+m)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let T=(l+1)/2,S=(f+1)/2,E=(p+1)/2,M=(h+d)/4,g=(u+x)/4,v=(_+m)/4;return T>S&&T>E?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=M/n,r=g/n):S>E?S<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(S),n=M/s,r=v/s):E<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),n=g/r,s=v/r),this.set(n,s,r,t),this}let w=Math.sqrt((m-_)*(m-_)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(w)<.001&&(w=1),this.x=(m-_)/w,this.y=(u-x)/w,this.z=(d-h)/w,this.w=Math.acos((l+f+p-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=Je(this.x,e.x,t.x),this.y=Je(this.y,e.y,t.y),this.z=Je(this.z,e.z,t.z),this.w=Je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Je(this.x,e,t),this.y=Je(this.y,e,t),this.z=Je(this.z,e,t),this.w=Je(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Je(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};zl.prototype.isVector4=!0;var _t=zl,eo=class extends Sn{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zt,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 _t(0,0,e,t),this.scissorTest=!1,this.viewport=new _t(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:Zt,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"})}},cn=class extends eo{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Ds=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=Pt,this.minFilter=Pt,this.wrapR=Cn,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=Pt,this.minFilter=Pt,this.wrapR=Cn,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,u,d,f,_,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,u,d,f,_,x,m)}set(e,t,n,s,r,o,a,c,l,h,u,d,f,_,x,m){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=s,p[1]=r,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=_,p[11]=x,p[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),u=Math.sin(r);if(e.order==="XYZ"){let d=o*h,f=o*u,_=a*h,x=a*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=f+_*l,t[5]=d-x*l,t[9]=-a*c,t[2]=x-d*l,t[6]=_+f*l,t[10]=o*c}else if(e.order==="YXZ"){let d=c*h,f=c*u,_=l*h,x=l*u;t[0]=d+x*a,t[4]=_*a-f,t[8]=o*l,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=f*a-_,t[6]=x+d*a,t[10]=o*c}else if(e.order==="ZXY"){let d=c*h,f=c*u,_=l*h,x=l*u;t[0]=d-x*a,t[4]=-o*u,t[8]=_+f*a,t[1]=f+_*a,t[5]=o*h,t[9]=x-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let d=o*h,f=o*u,_=a*h,x=a*u;t[0]=c*h,t[4]=_*l-f,t[8]=d*l+x,t[1]=c*u,t[5]=x*l+d,t[9]=f*l-_,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let d=o*c,f=o*l,_=a*c,x=a*l;t[0]=c*h,t[4]=x-d*u,t[8]=_*u+f,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=f*u+_,t[10]=d-x*u}else if(e.order==="XZY"){let d=o*c,f=o*l,_=a*c,x=a*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+x,t[5]=o*h,t[9]=f*u-_,t[2]=_*u-f,t[6]=a*h,t[10]=x*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Sd,e,wd)}lookAt(e,t,n){let s=this.elements;return sn.subVectors(e,t),sn.lengthSq()===0&&(sn.z=1),sn.normalize(),si.crossVectors(n,sn),si.lengthSq()===0&&(Math.abs(n.z)===1?sn.x+=1e-4:sn.z+=1e-4,sn.normalize(),si.crossVectors(n,sn)),si.normalize(),gr.crossVectors(sn,si),s[0]=si.x,s[4]=gr.x,s[8]=sn.x,s[1]=si.y,s[5]=gr.y,s[9]=sn.y,s[2]=si.z,s[6]=gr.z,s[10]=sn.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],u=n[5],d=n[9],f=n[13],_=n[2],x=n[6],m=n[10],p=n[14],w=n[3],T=n[7],S=n[11],E=n[15],M=s[0],g=s[4],v=s[8],L=s[12],R=s[1],D=s[5],N=s[9],B=s[13],C=s[2],W=s[6],Z=s[10],z=s[14],ee=s[3],q=s[7],J=s[11],O=s[15];return r[0]=o*M+a*R+c*C+l*ee,r[4]=o*g+a*D+c*W+l*q,r[8]=o*v+a*N+c*Z+l*J,r[12]=o*L+a*B+c*z+l*O,r[1]=h*M+u*R+d*C+f*ee,r[5]=h*g+u*D+d*W+f*q,r[9]=h*v+u*N+d*Z+f*J,r[13]=h*L+u*B+d*z+f*O,r[2]=_*M+x*R+m*C+p*ee,r[6]=_*g+x*D+m*W+p*q,r[10]=_*v+x*N+m*Z+p*J,r[14]=_*L+x*B+m*z+p*O,r[3]=w*M+T*R+S*C+E*ee,r[7]=w*g+T*D+S*W+E*q,r[11]=w*v+T*N+S*Z+E*J,r[15]=w*L+T*B+S*z+E*O,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],u=e[6],d=e[10],f=e[14],_=e[3],x=e[7],m=e[11],p=e[15],w=c*f-l*d,T=a*f-l*u,S=a*d-c*u,E=o*f-l*h,M=o*d-c*h,g=o*u-a*h;return t*(x*w-m*T+p*S)-n*(_*w-m*E+p*M)+s*(_*T-x*E+p*g)-r*(_*S-x*M+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],u=e[9],d=e[10],f=e[11],_=e[12],x=e[13],m=e[14],p=e[15],w=t*a-n*o,T=t*c-s*o,S=t*l-r*o,E=n*c-s*a,M=n*l-r*a,g=s*l-r*c,v=h*x-u*_,L=h*m-d*_,R=h*p-f*_,D=u*m-d*x,N=u*p-f*x,B=d*p-f*m,C=w*B-T*N+S*D+E*R-M*L+g*v;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let W=1/C;return e[0]=(a*B-c*N+l*D)*W,e[1]=(s*N-n*B-r*D)*W,e[2]=(x*g-m*M+p*E)*W,e[3]=(d*M-u*g-f*E)*W,e[4]=(c*R-o*B-l*L)*W,e[5]=(t*B-s*R+r*L)*W,e[6]=(m*S-_*g-p*T)*W,e[7]=(h*g-d*S+f*T)*W,e[8]=(o*N-a*R+l*v)*W,e[9]=(n*R-t*N-r*v)*W,e[10]=(_*M-x*S+p*w)*W,e[11]=(u*S-h*M-f*w)*W,e[12]=(a*L-o*D-c*v)*W,e[13]=(t*D-n*L+s*v)*W,e[14]=(x*T-_*E-m*w)*W,e[15]=(h*E-u*T+d*w)*W,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,u=a+a,d=r*l,f=r*h,_=r*u,x=o*h,m=o*u,p=a*u,w=c*l,T=c*h,S=c*u,E=n.x,M=n.y,g=n.z;return s[0]=(1-(x+p))*E,s[1]=(f+S)*E,s[2]=(_-T)*E,s[3]=0,s[4]=(f-S)*M,s[5]=(1-(d+p))*M,s[6]=(m+w)*M,s[7]=0,s[8]=(_+T)*g,s[9]=(m-w)*g,s[10]=(1-(d+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),vn.copy(this);let l=1/o,h=1/a,u=1/c;return vn.elements[0]*=l,vn.elements[1]*=l,vn.elements[2]*=l,vn.elements[4]*=h,vn.elements[5]*=h,vn.elements[6]*=h,vn.elements[8]*=u,vn.elements[9]*=u,vn.elements[10]*=u,t.setFromRotationMatrix(vn),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,s,r,o,a=gn,c=!1){let l=this.elements,h=2*r/(t-e),u=2*r/(n-s),d=(t+e)/(t-e),f=(n+s)/(n-s),_,x;if(c)_=r/(o-r),x=o*r/(o-r);else if(a===gn)_=-(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]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,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=gn,c=!1){let l=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),f=-(n+s)/(n-s),_,x;if(c)_=1/(o-r),x=o/(o-r);else if(a===gn)_=-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]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,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 mt=So,Bi=new k,vn=new mt,Sd=new k(0,0,0),wd=new k(1,1,1),si=new k,gr=new k,sn=new k,Ec=new mt,Tc=new ln,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],u=s[2],d=s[6],f=s[10];switch(t){case"XYZ":this._y=Math.asin(Je(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Je(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Je(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Je(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Je(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,f));break;case"XZY":this._z=Math.asin(-Je(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Fe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ec.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ec,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Tc.setFromEuler(this),this.setFromQuaternion(Tc,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 Ns=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}},Ed=0,Ac=new k,zi=new ln,kn=new mt,_r=new k,Ms=new k,Td=new k,Ad=new ln,Rc=new k(1,0,0),Cc=new k(0,1,0),Pc=new k(0,0,1),Ic={type:"added"},Rd={type:"removed"},ki={type:"childadded",child:null},La={type:"childremoved",child:null},Ut=class i extends Sn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ed++}),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 ln,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 mt},normalMatrix:{value:new Ge}}),this.matrix=new mt,this.matrixWorld=new mt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ns,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(Rc,e)}rotateY(e){return this.rotateOnAxis(Cc,e)}rotateZ(e){return this.rotateOnAxis(Pc,e)}translateOnAxis(e,t){return Ac.copy(e).applyQuaternion(this.quaternion),this.position.add(Ac.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Rc,e)}translateY(e){return this.translateOnAxis(Cc,e)}translateZ(e){return this.translateOnAxis(Pc,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),Ms.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kn.lookAt(Ms,_r,this.up):kn.lookAt(_r,Ms,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?(ke("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Ic),ki.child=e,this.dispatchEvent(ki),ki.child=null):ke("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Rd),La.child=e,this.dispatchEvent(La),La.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(Ic),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(Ms,e,Td),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ms,Ad,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 u=c[l];r(e.shapes,u)}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),u=o(e.shapes),d=o(e.skeletons),f=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),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),_.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 Pn=class extends Ut{constructor(){super(),this.isGroup=!0,this.type="Group"}},Cd={type:"move"},is=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Pn,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 Pn,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 Pn,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),p=this._getHandJoint(l,x);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.quaternion,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,_=.005;l.inputState.pinching&&d>f+_?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=f-_&&(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(Cd)))}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 Pn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Dh={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 Da(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 Ye=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=on){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,et.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=et.workingColorSpace){return this.r=e,this.g=t,this.b=n,et.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=et.workingColorSpace){if(e=Rl(e,1),t=Je(t,0,1),n=Je(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=Da(o,r,e+1/3),this.g=Da(o,r,e),this.b=Da(o,r,e-1/3)}return et.colorSpaceToWorking(this,s),this}setStyle(e,t=on){function n(r){r!==void 0&&parseFloat(r)<1&&Fe("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:Fe("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);Fe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=on){let n=Dh[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Fe("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=on){return et.workingToColorSpace(kt.copy(this),e),Math.round(Je(kt.r*255,0,255))*65536+Math.round(Je(kt.g*255,0,255))*256+Math.round(Je(kt.b*255,0,255))}getHexString(e=on){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=et.workingColorSpace){et.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 u=o-a;switch(l=h<=.5?u/(o+a):u/(2-o-a),o){case n:c=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=et.workingColorSpace){return et.workingToColorSpace(kt.copy(this),t),e.r=kt.r,e.g=kt.g,e.b=kt.b,e}getStyle(e=on){et.workingToColorSpace(kt.copy(this),e);let t=kt.r,n=kt.g,s=kt.b;return e!==on?`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=Rs(ri.h,xr.h,t),s=Rs(ri.s,xr.s,t),r=Rs(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 Ye;Ye.NAMES=Dh;var Us=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}},bn=new k,Vn=new k,Na=new k,Gn=new k,Vi=new k,Gi=new k,Lc=new k,Ua=new k,Fa=new k,Oa=new k,Ba=new _t,za=new _t,ka=new _t,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),bn.subVectors(e,t),s.cross(bn);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){bn.subVectors(s,t),Vn.subVectors(n,t),Na.subVectors(e,t);let o=bn.dot(bn),a=bn.dot(Vn),c=bn.dot(Na),l=Vn.dot(Vn),h=Vn.dot(Na),u=o*l-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(l*c-a*h)*d,_=(o*h-a*c)*d;return r.set(1-f-_,_,f)}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 Ba.setScalar(0),za.setScalar(0),ka.setScalar(0),Ba.fromBufferAttribute(e,t),za.fromBufferAttribute(e,n),ka.fromBufferAttribute(e,s),o.setScalar(0),o.addScaledVector(Ba,r.x),o.addScaledVector(za,r.y),o.addScaledVector(ka,r.z),o}static isFrontFacing(e,t,n,s){return bn.subVectors(n,t),Vn.subVectors(e,t),bn.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 bn.subVectors(this.c,this.b),Vn.subVectors(this.a,this.b),bn.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),Ua.subVectors(e,n);let c=Vi.dot(Ua),l=Gi.dot(Ua);if(c<=0&&l<=0)return t.copy(n);Fa.subVectors(e,s);let h=Vi.dot(Fa),u=Gi.dot(Fa);if(h>=0&&u<=h)return t.copy(s);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0&&c-h>0)return o=c/(c-h),t.copy(n).addScaledVector(Vi,o);Oa.subVectors(e,r);let f=Vi.dot(Oa),_=Gi.dot(Oa);if(_>=0&&f<=_)return t.copy(r);let x=f*l-c*_;if(x<=0&&l>=0&&_<=0)return a=l/(l-_),t.copy(n).addScaledVector(Gi,a);let m=h*_-f*u;if(m<=0&&u-h>=0&&f-_>=0)return Lc.subVectors(r,s),a=(u-h)/(u-h+(f-_)),t.copy(s).addScaledVector(Lc,a);let p=1/(m+x+d);return o=x*p,a=d*p,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(Mn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Mn.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=Mn.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,Mn):Mn.fromBufferAttribute(r,o),Mn.applyMatrix4(e.matrixWorld),this.expandByPoint(Mn);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,Mn),Mn.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(Ss),vr.subVectors(this.max,Ss),Hi.subVectors(e.a,Ss),Wi.subVectors(e.b,Ss),Xi.subVectors(e.c,Ss),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!Va(t,Hi,Wi,Xi,vr)||(t=[1,0,0,0,1,0,0,0,1],!Va(t,Hi,Wi,Xi,vr))?!1:(br.crossVectors(oi,ai),t=[br.x,br.y,br.z],Va(t,Hi,Wi,Xi,vr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Mn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Mn).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],Mn=new k,yr=new ci,Hi=new k,Wi=new k,Xi=new k,oi=new k,ai=new k,Si=new k,Ss=new k,vr=new k,br=new k,wi=new k;function Va(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 Ve,Pd=0,Vt=class extends Sn{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:Pd++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Th,this.updateRanges=[],this.gpuType=En,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++)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):Ih(e,this.array)}_normalize(e){let t=this._normalizationScale;return t!==void 0?Math.round(e*t):Lh(e,this.array)}};var Fs=class extends Vt{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var Os=class extends Vt{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var Yt=class extends Vt{constructor(e,t,n){super(new Float32Array(e),t,n)}},Id=new ci,ws=new k,Ga=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):Id.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;ws.subVectors(e,this.center);let t=ws.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(ws,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):(Ga.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ws.copy(e.center).add(Ga)),this.expandByPoint(ws.copy(e.center).sub(Ga))),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}},Ld=0,mn=new mt,Ha=new Ut,qi=new k,rn=new ci,Es=new ci,Ct=new k,$t=class i extends Sn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ld++}),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(id(e)?Os:Fs)(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 mn.makeRotationFromQuaternion(e),this.applyMatrix4(mn),this}rotateX(e){return mn.makeRotationX(e),this.applyMatrix4(mn),this}rotateY(e){return mn.makeRotationY(e),this.applyMatrix4(mn),this}rotateZ(e){return mn.makeRotationZ(e),this.applyMatrix4(mn),this}translate(e,t,n){return mn.makeTranslation(e,t,n),this.applyMatrix4(mn),this}scale(e,t,n){return mn.makeScale(e,t,n),this.applyMatrix4(mn),this}lookAt(e){return Ha.lookAt(e),Ha.updateMatrix(),this.applyMatrix4(Ha.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 Yt(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&&Fe("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){ke("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];rn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ct.addVectors(this.boundingBox.min,rn.min),this.boundingBox.expandByPoint(Ct),Ct.addVectors(this.boundingBox.max,rn.max),this.boundingBox.expandByPoint(Ct)):(this.boundingBox.expandByPoint(rn.min),this.boundingBox.expandByPoint(rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ke('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ai);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){ke("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new k,1/0);return}if(e){let n=this.boundingSphere.center;if(rn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];Es.setFromBufferAttribute(a),this.morphTargetsRelative?(Ct.addVectors(rn.min,Es.min),rn.expandByPoint(Ct),Ct.addVectors(rn.max,Es.max),rn.expandByPoint(Ct)):(rn.expandByPoint(Es.min),rn.expandByPoint(Es.max))}rn.getCenter(n);let s=0;for(let r=0,o=e.count;r<o;r++)Ct.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Ct));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++)Ct.fromBufferAttribute(a,l),c&&(qi.fromBufferAttribute(e,l),Ct.add(qi)),s=Math.max(s,n.distanceToSquared(Ct))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&ke('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){ke("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 L=0;L<n.count;L++)a[L]=new k,c[L]=new k;let h=new k,u=new k,d=new k,f=new Ve,_=new Ve,x=new Ve,m=new k,p=new k;function w(L,R,D){l[L]=l[R]=l[D]=1,h.fromBufferAttribute(n,L),u.fromBufferAttribute(n,R),d.fromBufferAttribute(n,D),f.fromBufferAttribute(r,L),_.fromBufferAttribute(r,R),x.fromBufferAttribute(r,D),u.sub(h),d.sub(h),_.sub(f),x.sub(f);let N=1/(_.x*x.y-x.x*_.y);isFinite(N)&&(m.copy(u).multiplyScalar(x.y).addScaledVector(d,-_.y).multiplyScalar(N),p.copy(d).multiplyScalar(_.x).addScaledVector(u,-x.x).multiplyScalar(N),a[L].add(m),a[R].add(m),a[D].add(m),c[L].add(p),c[R].add(p),c[D].add(p))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let L=0,R=T.length;L<R;++L){let D=T[L],N=D.start,B=D.count;for(let C=N,W=N+B;C<W;C+=3)w(e.getX(C+0),e.getX(C+1),e.getX(C+2))}let S=new k,E=new k,M=new k,g=new k;function v(L){M.fromBufferAttribute(s,L),g.copy(M);let R=a[L];S.copy(R),S.sub(M.multiplyScalar(M.dot(R))).normalize(),E.crossVectors(g,R);let N=E.dot(c[L])<0?-1:1;o.setXYZW(L,S.x,S.y,S.z,N)}for(let L=0,R=n.count;L<R;++L)l[L]&&v(L);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 d=0,f=n.count;d<f;d++)n.setXYZ(d,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,u=new k;if(e)for(let d=0,f=e.count;d<f;d+=3){let _=e.getX(d+0),x=e.getX(d+1),m=e.getX(d+2);s.fromBufferAttribute(t,_),r.fromBufferAttribute(t,x),o.fromBufferAttribute(t,m),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),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 d=0,f=t.count;d<f;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),h.subVectors(o,r),u.subVectors(s,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ct.fromBufferAttribute(e,t),Ct.normalize(),e.setXYZ(t,Ct.x,Ct.y,Ct.z)}toNonIndexed(){function e(a,c){let l=a.array,h=a.itemSize,u=a.normalized,d=new l.constructor(c.length*h),f=0,_=0;for(let x=0,m=c.length;x<m;x++){a.isInterleavedBufferAttribute?f=c[x]*a.data.stride+a.offset:f=c[x]*h;for(let p=0;p<h;p++)d[_++]=l[f++]}return new Vt(d,h,u)}if(this.index===null)return Fe("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,u=l.length;h<u;h++){let d=l[h],f=e(d,n);c.push(f)}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 u=0,d=l.length;u<d;u++){let f=l[u];h.push(f.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=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,h=o.length;l<h;l++){let u=o[l];this.addGroup(u.start,u.count,u.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 Wa=new k,Dd=new k,Nd=new Ge,an=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=Wa.subVectors(n,t).cross(Dd.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(Wa),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||Nd.getNormalMatrix(e),s=this.coplanarPoint(Wa).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}},Ud=0,$n=class extends Sn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ud++}),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=al,this.blendDst=ll,this.blendEquation=Li,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ye(0,0,0),this.blendAlpha=0,this.depthFunc=ji,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=vh,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){Fe(`Material: parameter '${t}' has value of undefined.`);continue}let s=this[t];if(s===void 0){Fe(`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 Ye().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 an().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 Ve().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 Ve().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,Xa=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){Xa.copy(e).add(t).multiplyScalar(.5),Sr.copy(t).sub(e).normalize(),wr.copy(this.origin).sub(Xa);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),u,d,f,_;if(h>0)if(u=o*c-a,d=o*a-c,_=r*h,u>=0)if(d>=-_)if(d<=_){let x=1/h;u*=x,d*=x,f=u*(u+o*d+2*a)+d*(o*u+d+2*c)+l}else d=r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*c)+l;else d<=-_?(u=Math.max(0,-(-o*r+a)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=_?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(o*r+a)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=o>0?-r:r,u=Math.max(0,-(o*d+a)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Xa).addScaledVector(Sr,d),f}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,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,s=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,s=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,o=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,o=(e.min.y-d.y)*h),n>o||r>s||((r>n||isNaN(n))&&(n=r),(o<s||isNaN(s))&&(s=o),u>=0?(a=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),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,u=e.x-o.x,d=e.y-o.y,f=e.z-o.z,_=t.x-o.x,x=t.y-o.y,m=t.z-o.z,p=n.x-o.x,w=n.y-o.y,T=n.z-o.z,S=Math.abs(c),E=Math.abs(l),M=Math.abs(h),g,v,L,R,D,N,B,C,W,Z,z,ee;if(S>=E&&S>=M?(L=c,N=u,W=_,ee=p,c>=0?(g=l,v=h,R=d,D=f,B=x,C=m,Z=w,z=T):(g=h,v=l,R=f,D=d,B=m,C=x,Z=T,z=w)):E>=M?(L=l,N=d,W=x,ee=w,l>=0?(g=h,v=c,R=f,D=u,B=m,C=_,Z=T,z=p):(g=c,v=h,R=u,D=f,B=_,C=m,Z=p,z=T)):(L=h,N=f,W=m,ee=T,h>=0?(g=c,v=l,R=u,D=d,B=_,C=x,Z=p,z=w):(g=l,v=c,R=d,D=u,B=x,C=_,Z=w,z=p)),L===0)return null;let q=g/L,J=v/L,O=1/L,ae=R-q*N,xe=D-J*N,H=B-q*W,ue=C-J*W,de=Z-q*ee,we=z-J*ee,fe=de*ue-we*H,Te=ae*we-xe*de,He=H*xe-ue*ae;if(s){if(fe<0||Te<0||He<0)return null}else if((fe<0||Te<0||He<0)&&(fe>0||Te>0||He>0))return null;let me=fe+Te+He;if(me===0)return null;let Ie=O*(fe*N+Te*W+He*ee);return(me>0?Ie<0:Ie>0)?null:this.at(Ie/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 Ye(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}},Dc=new mt,Ei=new Ri,Er=new Ai,Nc=new k,Tr=new k,Ar=new k,Rr=new k,qa=new k,Cr=new k,Uc=new k,Pr=new k,Qt=class extends Ut{constructor(e=new $t,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],u=r[c];h!==0&&(qa.fromBufferAttribute(u,e),o?Cr.addScaledVector(qa,h):Cr.addScaledVector(qa.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,Nc)===null||Ei.origin.distanceToSquared(Nc)>(e.far-e.near)**2))&&(Dc.copy(r).invert(),Ei.copy(e.ray).applyMatrix4(Dc),!(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,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,x=d.length;_<x;_++){let m=d[_],p=o[m.materialIndex],w=Math.max(m.start,f.start),T=Math.min(a.count,Math.min(m.start+m.count,f.start+f.count));for(let S=w,E=T;S<E;S+=3){let M=a.getX(S),g=a.getX(S+1),v=a.getX(S+2);s=Ir(this,p,e,n,l,h,u,M,g,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let _=Math.max(0,f.start),x=Math.min(a.count,f.start+f.count);for(let m=_,p=x;m<p;m+=3){let w=a.getX(m),T=a.getX(m+1),S=a.getX(m+2);s=Ir(this,o,e,n,l,h,u,w,T,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(c!==void 0)if(Array.isArray(o))for(let _=0,x=d.length;_<x;_++){let m=d[_],p=o[m.materialIndex],w=Math.max(m.start,f.start),T=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let S=w,E=T;S<E;S+=3){let M=S,g=S+1,v=S+2;s=Ir(this,p,e,n,l,h,u,M,g,v),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{let _=Math.max(0,f.start),x=Math.min(c.count,f.start+f.count);for(let m=_,p=x;m<p;m+=3){let w=m,T=m+1,S=m+2;s=Ir(this,o,e,n,l,h,u,w,T,S),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}};function Fd(i,e,t,n,s,r,o,a){let c;if(e.side===Jt?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=Fd(i,e,t,n,Tr,Ar,Rr,Uc);if(h){let u=new k;Xn.getBarycoord(Uc,Tr,Ar,Rr,u),s&&(h.uv=Xn.getInterpolatedAttribute(s,a,c,l,u,new Ve)),r&&(h.uv1=Xn.getInterpolatedAttribute(r,a,c,l,u,new Ve)),o&&(h.normal=Xn.getInterpolatedAttribute(o,a,c,l,u,new k),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new k,materialIndex:0};Xn.getNormal(Tr,Ar,Rr,d.normal),h.face=d,h.barycoord=u}return h}var no=class extends jt{constructor(e=null,t=1,n=1,s,r,o,a,c,l=Pt,h=Pt,u,d){super(null,o,a,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Ti=new Ai,Od=new Ve(.5,.5),Lr=new k,hi=class{constructor(e=new an,t=new an,n=new an,s=new an,r=new an,o=new an){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=gn,n=!1){let s=this.planes,r=e.elements,o=r[0],a=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],_=r[8],x=r[9],m=r[10],p=r[11],w=r[12],T=r[13],S=r[14],E=r[15];if(s[0].setComponents(l-o,f-h,p-_,E-w).normalize(),s[1].setComponents(l+o,f+h,p+_,E+w).normalize(),s[2].setComponents(l+a,f+u,p+x,E+T).normalize(),s[3].setComponents(l-a,f-u,p-x,E-T).normalize(),n)s[4].setComponents(c,d,m,S).normalize(),s[5].setComponents(l-c,f-d,p-m,E-S).normalize();else if(s[4].setComponents(l-c,f-d,p-m,E-S).normalize(),t===gn)s[5].setComponents(l+c,f+d,p+m,E+S).normalize();else if(t===Qi)s[5].setComponents(c,d,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=Od.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)}},Fc=new mt,io=class i{constructor(){this.coordinateSystem=gn,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];Fc.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[s]===void 0&&(n[s]=new hi),n[s].setFromProjectionMatrix(Fc,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 Ye(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,Oc=new mt,Ts=new Ri,Dr=new Ai,Ya=new k,Bc=new k,oo=class extends Ut{constructor(e=new $t,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 Yt(n,1))}else Fe("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;Oc.copy(s).invert(),Ts.copy(e.ray).applyMatrix4(Oc);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){let f=Math.max(0,o.start),_=Math.min(h.count,o.start+o.count);for(let x=f,m=_-1;x<m;x+=l){let p=h.getX(x),w=h.getX(x+1),T=Nr(this,e,Ts,c,p,w,x);T&&t.push(T)}if(this.isLineLoop){let x=h.getX(_-1),m=h.getX(f),p=Nr(this,e,Ts,c,x,m,_-1);p&&t.push(p)}}else{let f=Math.max(0,o.start),_=Math.min(d.count,o.start+o.count);for(let x=f,m=_-1;x<m;x+=l){let p=Nr(this,e,Ts,c,x,x+1,x);p&&t.push(p)}if(this.isLineLoop){let x=Nr(this,e,Ts,c,_-1,f,_-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,Ya,Bc)>n)return;Ya.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Ya);if(!(l<e.near||l>e.far))return{distance:l,point:Bc.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var zc=new k,kc=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)zc.fromBufferAttribute(t,s),kc.fromBufferAttribute(t,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+zc.distanceTo(kc);e.setAttribute("lineDistance",new Yt(n,1))}else Fe("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Bs=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=wn,s,r,o,a=Pt,c=Pt,l,h=Yn,u=1){if(h!==Yn&&h!==jn)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let d={width:e,height:t,depth:u};super(d,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}},zs=class extends Jn{constructor(e,t=wn,n=Di,s,r,o=Pt,a=Pt,c,l=Yn){let h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,o,a,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ks=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 $t{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=[],u=[],d=0,f=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 Yt(l,3)),this.setAttribute("normal",new Yt(h,3)),this.setAttribute("uv",new Yt(u,2));function _(x,m,p,w,T,S,E,M,g,v,L){let R=S/g,D=E/v,N=S/2,B=E/2,C=M/2,W=g+1,Z=v+1,z=0,ee=0,q=new k;for(let J=0;J<Z;J++){let O=J*D-B;for(let ae=0;ae<W;ae++){let xe=ae*R-N;q[x]=xe*w,q[m]=O*T,q[p]=C,l.push(q.x,q.y,q.z),q[x]=0,q[m]=0,q[p]=M>0?1:-1,h.push(q.x,q.y,q.z),u.push(ae/g),u.push(1-J/v),z+=1}}for(let J=0;J<v;J++)for(let O=0;O<g;O++){let ae=d+O+W*J,xe=d+O+W*(J+1),H=d+(O+1)+W*(J+1),ue=d+(O+1)+W*J;c.push(ae,xe,ue),c.push(xe,H,ue),ee+=6}a.addGroup(f,ee,L),f+=ee,d+=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 Ur=new k,Fr=new k,Za=new k,Or=new Xn,Vs=class extends $t{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"],u=new Array(3),d=new Map,f=[];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:p}=Or;if(x.fromBufferAttribute(a,l[0]),m.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),Or.getNormal(Za),u[0]=`${Math.round(x.x*s)},${Math.round(x.y*s)},${Math.round(x.z*s)}`,u[1]=`${Math.round(m.x*s)},${Math.round(m.y*s)},${Math.round(m.z*s)}`,u[2]=`${Math.round(p.x*s)},${Math.round(p.y*s)},${Math.round(p.z*s)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let w=0;w<3;w++){let T=(w+1)%3,S=u[w],E=u[T],M=Or[h[w]],g=Or[h[T]],v=`${S}_${E}`,L=`${E}_${S}`,R=d.get(L);R?(Za.dot(R.normal)<=r&&(f.push(M.x,M.y,M.z),f.push(g.x,g.y,g.z)),d.set(L,null)):d.has(v)||d.set(v,{index0:l[w],index1:l[T],normal:Za.clone()})}}for(let _ of d.values())if(_){let{index0:x,index1:m}=_;Ur.fromBufferAttribute(a,x),Fr.fromBufferAttribute(a,m),f.push(Ur.x,Ur.y,Ur.z),f.push(Fr.x,Fr.y,Fr.z)}this.setAttribute("position",new Yt(f,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};var Gs=class i extends $t{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,u=e/a,d=t/c,f=[],_=[],x=[],m=[];for(let p=0;p<h;p++){let w=p*d-o;for(let T=0;T<l;T++){let S=T*u-r;_.push(S,-w,0),x.push(0,0,1),m.push(T/a),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let w=0;w<a;w++){let T=w+l*p,S=w+l*(p+1),E=w+1+l*(p+1),M=w+1+l*p;f.push(T,S,M),f.push(S,E,M)}this.setIndex(f),this.setAttribute("position",new Yt(_,3)),this.setAttribute("normal",new Yt(x,3)),this.setAttribute("uv",new Yt(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(Vc(s))s.isRenderTargetTexture?(Fe("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(Vc(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 Vc(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function Bd(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Ll(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:et.workingColorSpace}var Nh={clone:Ui,merge:Gt},zd=`void main() {
2
2
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
- }`,Od=`void main() {
3
+ }`,kd=`void main() {
4
4
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
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
5
+ }`,In=class extends $n{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=zd,this.fragmentShader=kd,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=Bd(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 Ye().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ve().fromArray(s.value);break;case"v3":this.uniforms[n].value=new k().fromArray(s.value);break;case"v4":this.uniforms[n].value=new _t().fromArray(s.value);break;case"m3":this.uniforms[n].value=new Ge().fromArray(s.value);break;case"m4":this.uniforms[n].value=new mt().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 In{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 Ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ha,this.normalScale=new Ve(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=xh,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:Ka,endingEnd:Ka}}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 ja:r=e,a=2*t-n;break;case Qa: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 ja:o=e,c=2*n-t;break;case Qa: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,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,_=(n-t)/(s-t),x=_*_,m=x*_,p=-d*m+2*d*x-d*_,w=(1+d)*m+(-1.5-2*d)*x+(-.5+d)*_+1,T=(-1-f)*m+(1.5+f)*x+.5*_,S=f*m-f*x;for(let E=0;E!==a;++E)r[E]=p*o[h+E]+w*o[l+E]+T*o[c+E]+S*o[u+E];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),u=1-h;for(let d=0;d!==a;++d)r[d]=o[l+d]*u+o[c+d]*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,u=this.outTangents;if(!h||!u){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 d=a*2,f=e-1;for(let _=0;_!==a;++_){let x=o[l+_],m=o[c+_],p=f*d+_*2,w=u[p],T=u[p+1],S=e*d+_*2,E=h[S],M=h[S+1],g=Gd(n,t,w,E,s);r[_]=Uh(g,x,T,M,m)}return r}};function Uh(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 Vd(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 o=0;o<8;o++){let a=Uh(r,e,t,n,s)-i;if(Math.abs(a)<1e-10)break;let c=Vd(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 hn=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 Cs:t=this.InterpolantFactoryMethodDiscrete;break;case jr:t=this.InterpolantFactoryMethodLinear;break;case Vr:t=this.InterpolantFactoryMethodSmooth;break;case Ja: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 Fe("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Cs;case this.InterpolantFactoryMethodLinear:return jr;case this.InterpolantFactoryMethodSmooth:return Vr;case this.InterpolantFactoryMethodBezier:return Ja}}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)&&(Gc(this.settings.inTangents,e),Gc(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)&&(Hc(this.settings.inTangents,e),Hc(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&&(ke("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,s=this.values,r=n.length;r===0&&(ke("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)){ke("KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){ke("KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(s!==void 0&&sd(s))for(let a=0,c=s.length;a!==c;++a){let l=s[a];if(isNaN(l)){ke("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 u=a*n,d=u-n,f=u+n;for(let _=0;_!==n;++_){let x=t[u+_];if(x!==t[d+_]||x!==t[f+_]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let u=a*n,d=o*n;for(let f=0;f!==n;++f)t[d+f]=t[u+f]}++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 Gc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function Hc(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}hn.prototype.ValueTypeName="";hn.prototype.TimeBufferType=Float32Array;hn.prototype.ValueBufferType=Float32Array;hn.prototype.DefaultInterpolation=jr;var di=class extends hn{constructor(e,t,n){super(e,t,n)}};di.prototype.ValueTypeName="bool";di.prototype.ValueBufferType=Array;di.prototype.DefaultInterpolation=Cs;di.prototype.InterpolantFactoryMethodLinear=void 0;di.prototype.InterpolantFactoryMethodSmooth=void 0;var mo=class extends hn{constructor(e,t,n,s){super(e,t,n,s)}};mo.prototype.ValueTypeName="color";var go=class extends hn{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)ln.slerpFlat(r,0,o,l-a,o,l,c);return r}},Hs=class extends hn{constructor(e,t,n,s){super(e,t,n,s)}InterpolantFactoryMethodLinear(e){return new _o(this.times,this.values,this.getValueSize(),e)}};Hs.prototype.ValueTypeName="quaternion";Hs.prototype.InterpolantFactoryMethodSmooth=void 0;var fi=class extends hn{constructor(e,t,n){super(e,t,n)}};fi.prototype.ValueTypeName="string";fi.prototype.ValueBufferType=Array;fi.prototype.DefaultInterpolation=Cs;fi.prototype.InterpolantFactoryMethodLinear=void 0;fi.prototype.InterpolantFactoryMethodSmooth=void 0;var xo=class extends hn{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,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){let f=l[u],_=l[u+1];if(f.global&&(f.lastIndex=0),f.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}},Fh=new yo,vo=class{constructor(e){this.manager=e!==void 0?e:Fh,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 Ws=class extends Ut{static registerNode(e){this.prototype._lightNode=e}constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ye(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}},Xs=class extends Ws{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ut.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ye(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}},$a=new mt,Wc=new k,Xc=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 Ve(512,512),this.mapType=en,this.map=null,this.mapPass=null,this.matrix=new mt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new hi,this._frameExtents=new Ve(1,1),this._viewportCount=1,this._viewports=[new _t(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),Xc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Xc),t.updateMatrixWorld(),this._updateMatrix(t,this.matrix,this._frustum)}_updateMatrix(e,t,n,s){$a.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),n.setFromProjectionMatrix($a,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($a)}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 ln,Rn=new k,qs=class extends Ut{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new mt,this.projectionMatrix=new mt,this.projectionMatrixInverse=new mt,this.coordinateSystem=gn,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,Rn),Rn.x===1&&Rn.y===1&&Rn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zr,kr,Rn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(zr,kr,Rn),Rn.x===1&&Rn.y===1&&Rn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(zr,kr,Rn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}},li=new k,qc=new Ve,Yc=new Ve,qt=class extends qs{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,qc,Yc),t.subVectors(Yc,qc)}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 qs{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}},el=class extends bo{constructor(){super(new Pi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},ls=class extends Ws{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 el}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 qt(Zi,$i,e,t);s.layers=this.layers,this.add(s);let r=new qt(Zi,$i,e,t);r.layers=this.layers,this.add(r);let o=new qt(Zi,$i,e,t);o.layers=this.layers,this.add(o);let a=new qt(Zi,$i,e,t);a.layers=this.layers,this.add(a);let c=new qt(Zi,$i,e,t);c.layers=this.layers,this.add(c);let l=new qt(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===gn)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,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=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(u,d,f),e.xr.enabled=_,n.texture.needsPMREMUpdate=!0}},Mo=class extends qt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var Dl="\\[\\]\\.:\\/",Hd=new RegExp("["+Dl+"]","g"),Nl="[^"+Dl+"]",Wd="[^"+Dl.replace("\\.","")+"]",Xd=/((?:WC+[\/:])*)/.source.replace("WC",Nl),qd=/(WCOD+)?/.source.replace("WCOD",Wd),Yd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Nl),Zd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Nl),$d=new RegExp("^"+Xd+qd+Yd+Zd+"$"),Jd=["material","materials","bones","map"],tl=class{constructor(e,t,n){let s=n||pt.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()}},pt=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(Hd,"")}static parseTrackName(e){let t=$d.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);Jd.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){Fe("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){ke("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){ke("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){ke("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){ke("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){ke("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){ke("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[s];if(o===void 0){let l=t.nodeName;ke("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){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){ke("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=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}};pt.Composite=tl;pt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};pt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};pt.prototype.GetterByBindingType=[pt.prototype._getValue_direct,pt.prototype._getValue_array,pt.prototype._getValue_arrayElement,pt.prototype._getValue_toArray];pt.prototype.SetterByBindingTypeAndVersioning=[[pt.prototype._setValue_direct,pt.prototype._setValue_direct_setNeedsUpdate,pt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_array,pt.prototype._setValue_array_setNeedsUpdate,pt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_arrayElement,pt.prototype._setValue_arrayElement_setNeedsUpdate,pt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pt.prototype._setValue_fromArray,pt.prototype._setValue_fromArray_setNeedsUpdate,pt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var T_=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=Je(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(Je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var kl=class kl{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}};kl.prototype.isMatrix2=!0;var nl=kl;var Ys=class extends Sn{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 Ul(i,e,t,n){let s=Kd(n);switch(t){case vl:return i*e;case Ml: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 bl:return i*e*3/s.components*s.byteLength;case An:return i*e*4/s.components*s.byteLength;case Do:return i*e*4/s.components*s.byteLength;case Ks:case js:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Qs:case er: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 tr: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 nr: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 Kd(i){switch(i){case en:case gl:return{byteLength:1,components:1};case ps:case _l:case Tn:return{byteLength:2,components:1};case Co:case Po:return{byteLength:2,components:4};case wn:case Ro:case En:return{byteLength:4,components:1};case xl:case yl: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__?Fe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="187");function su(){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 Qd(i){let e=new WeakMap;function t(a,c){let l=a.array,h=a.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),a.onUploadCallback();let f;if(l instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=i.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=i.SHORT;else if(l instanceof Uint32Array)f=i.UNSIGNED_INT;else if(l instanceof Int32Array)f=i.INT;else if(l instanceof Int8Array)f=i.BYTE;else if(l instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,c,l){let h=c.array,u=c.updateRanges;if(i.bindBuffer(l,a),u.length===0)i.bufferSubData(l,0,h);else{u.sort((f,_)=>f.start-_.start);let d=0;for(let f=1;f<u.length;f++){let _=u[d],x=u[f];x.start<=_.start+_.count+1?_.count=Math.max(_.count,x.start+x.count-_.start):(++d,u[d]=x)}u.length=d+1;for(let f=0,_=u.length;f<_;f++){let x=u[f];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 ef=`#ifdef USE_ALPHAHASH
6
6
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
7
- #endif`,jd=`#ifdef USE_ALPHAHASH
7
+ #endif`,tf=`#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`,Qd=`#ifdef USE_ALPHAMAP
42
+ #endif`,nf=`#ifdef USE_ALPHAMAP
43
43
  diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
44
- #endif`,ef=`#ifdef USE_ALPHAMAP
44
+ #endif`,sf=`#ifdef USE_ALPHAMAP
45
45
  uniform sampler2D alphaMap;
46
- #endif`,tf=`#ifdef USE_ALPHATEST
46
+ #endif`,rf=`#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`,nf=`#ifdef USE_ALPHATEST
53
+ #endif`,of=`#ifdef USE_ALPHATEST
54
54
  uniform float alphaTest;
55
- #endif`,sf=`#ifdef USE_AOMAP
55
+ #endif`,af=`#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`,rf=`#ifdef USE_AOMAP
68
+ #endif`,lf=`#ifdef USE_AOMAP
69
69
  uniform sampler2D aoMap;
70
70
  uniform float aoMapIntensity;
71
- #endif`,of=`#ifdef USE_BATCHING
71
+ #endif`,cf=`#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`,af=`#ifdef USE_BATCHING
105
+ #endif`,hf=`#ifdef USE_BATCHING
106
106
  mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
107
- #endif`,lf=`vec3 transformed = vec3( position );
107
+ #endif`,uf=`vec3 transformed = vec3( position );
108
108
  #ifdef USE_ALPHAHASH
109
109
  vPosition = vec3( position );
110
- #endif`,cf=`vec3 objectNormal = vec3( normal );
110
+ #endif`,df=`vec3 objectNormal = vec3( normal );
111
111
  #ifdef USE_TANGENT
112
112
  vec3 objectTangent = vec3( tangent.xyz );
113
- #endif`,hf=`float G_BlinnPhong_Implicit( ) {
113
+ #endif`,ff=`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`,uf=`#ifdef USE_IRIDESCENCE
127
+ } // validated`,pf=`#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`,df=`#ifdef USE_BUMPMAP
190
+ #endif`,mf=`#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`,ff=`#if NUM_CLIPPING_PLANES > 0
211
+ #endif`,gf=`#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`,pf=`#if NUM_CLIPPING_PLANES > 0
257
+ #endif`,_f=`#if NUM_CLIPPING_PLANES > 0
258
258
  varying vec3 vClipPosition;
259
259
  uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
260
- #endif`,mf=`#if NUM_CLIPPING_PLANES > 0
260
+ #endif`,xf=`#if NUM_CLIPPING_PLANES > 0
261
261
  varying vec3 vClipPosition;
262
- #endif`,gf=`#if NUM_CLIPPING_PLANES > 0
262
+ #endif`,yf=`#if NUM_CLIPPING_PLANES > 0
263
263
  vClipPosition = - mvPosition.xyz;
264
- #endif`,_f=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
264
+ #endif`,vf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
265
265
  diffuseColor *= vColor;
266
- #endif`,xf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
266
+ #endif`,bf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
267
267
  varying vec4 vColor;
268
- #endif`,yf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
268
+ #endif`,Mf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
269
269
  varying vec4 vColor;
270
- #endif`,vf=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
270
+ #endif`,Sf=`#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`,bf=`#define PI 3.141592653589793
283
+ #endif`,wf=`#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`,Mf=`vec3 transformedNormal = objectNormal;
354
+ } // validated`,Ef=`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`,Sf=`#ifdef USE_DISPLACEMENTMAP
380
+ #endif`,Tf=`#ifdef USE_DISPLACEMENTMAP
381
381
  uniform sampler2D displacementMap;
382
382
  uniform float displacementScale;
383
383
  uniform float displacementBias;
384
- #endif`,wf=`#ifdef USE_DISPLACEMENTMAP
384
+ #endif`,Af=`#ifdef USE_DISPLACEMENTMAP
385
385
  transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
386
- #endif`,Ef=`#ifdef USE_EMISSIVEMAP
386
+ #endif`,Rf=`#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`,Tf=`#ifdef USE_EMISSIVEMAP
392
+ #endif`,Cf=`#ifdef USE_EMISSIVEMAP
393
393
  uniform sampler2D emissiveMap;
394
- #endif`,Af="gl_FragColor = linearToOutputTexel( gl_FragColor );",Rf=`vec4 LinearTransferOETF( in vec4 value ) {
394
+ #endif`,Pf="gl_FragColor = linearToOutputTexel( gl_FragColor );",If=`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
- }`,Cf=`#ifdef USE_ENVMAP
402
+ }`,Lf=`#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`,Pf=`#ifdef USE_ENVMAP
429
+ #endif`,Df=`#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`,If=`#ifdef USE_ENVMAP
439
+ #endif`,Nf=`#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`,Lf=`#ifdef USE_ENVMAP
450
+ #endif`,Uf=`#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`,Df=`#ifdef USE_ENVMAP
461
+ #endif`,Ff=`#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`,Nf=`#ifdef USE_FOG
478
+ #endif`,Of=`#ifdef USE_FOG
479
479
  vFogDepth = - mvPosition.z;
480
- #endif`,Uf=`#ifdef USE_FOG
480
+ #endif`,Bf=`#ifdef USE_FOG
481
481
  varying float vFogDepth;
482
- #endif`,Ff=`#ifdef USE_FOG
482
+ #endif`,zf=`#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`,Of=`#ifdef USE_FOG
489
+ #endif`,kf=`#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`,Bf=`#ifdef USE_GRADIENTMAP
498
+ #endif`,Vf=`#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
- }`,zf=`#ifdef USE_LIGHTMAP
510
+ }`,Gf=`#ifdef USE_LIGHTMAP
511
511
  uniform sampler2D lightMap;
512
512
  uniform float lightMapIntensity;
513
- #endif`,kf=`LambertMaterial material;
513
+ #endif`,Hf=`LambertMaterial material;
514
514
  material.diffuseColor = diffuseColor.rgb;
515
- material.specularStrength = specularStrength;`,Vf=`varying vec3 vViewPosition;
515
+ material.specularStrength = specularStrength;`,Wf=`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`,Gf=`uniform bool receiveShadow;
529
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Xf=`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>`,Hf=`#ifdef USE_ENVMAP
658
+ #include <lightprobes_pars_fragment>`,qf=`#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`,Wf=`ToonMaterial material;
716
- material.diffuseColor = diffuseColor.rgb;`,Xf=`varying vec3 vViewPosition;
715
+ #endif`,Yf=`ToonMaterial material;
716
+ material.diffuseColor = diffuseColor.rgb;`,Zf=`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`,qf=`BlinnPhongMaterial material;
728
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,$f=`BlinnPhongMaterial material;
729
729
  material.diffuseColor = diffuseColor.rgb;
730
730
  material.specularColor = specular;
731
731
  material.specularShininess = shininess;
732
- material.specularStrength = specularStrength;`,Yf=`varying vec3 vViewPosition;
732
+ material.specularStrength = specularStrength;`,Jf=`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`,Zf=`PhysicalMaterial material;
749
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Kf=`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`,$f=`uniform sampler2D dfgLUT;
850
+ #endif`,jf=`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
- }`,Jf=`
1273
+ }`,Qf=`
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`,Kf=`#if defined( RE_IndirectDiffuse )
1431
+ #endif`,ep=`#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`,jf=`#if defined( RE_IndirectDiffuse )
1461
+ #endif`,tp=`#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`,Qf=`#if NUM_LIGHT_PROBE_GRIDS > 0
1469
+ #endif`,np=`#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`,ep=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1518
+ #endif`,ip=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1519
1519
  gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1520
- #endif`,tp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1520
+ #endif`,sp=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1521
1521
  uniform float logDepthBufFC;
1522
1522
  varying float vFragDepth;
1523
1523
  varying float vIsPerspective;
1524
- #endif`,np=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1524
+ #endif`,rp=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1525
1525
  varying float vFragDepth;
1526
1526
  varying float vIsPerspective;
1527
- #endif`,ip=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1527
+ #endif`,op=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1528
1528
  vFragDepth = 1.0 + gl_Position.w;
1529
1529
  vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1530
- #endif`,sp=`#ifdef USE_MAP
1530
+ #endif`,ap=`#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`,rp=`#ifdef USE_MAP
1536
+ #endif`,lp=`#ifdef USE_MAP
1537
1537
  uniform sampler2D map;
1538
- #endif`,op=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1538
+ #endif`,cp=`#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`,ap=`#if defined( USE_POINTS_UV )
1550
+ #endif`,hp=`#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`,lp=`float metalnessFactor = metalness;
1562
+ #endif`,up=`float metalnessFactor = metalness;
1563
1563
  #ifdef USE_METALNESSMAP
1564
1564
  vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1565
1565
  metalnessFactor *= texelMetalness.b;
1566
- #endif`,cp=`#ifdef USE_METALNESSMAP
1566
+ #endif`,dp=`#ifdef USE_METALNESSMAP
1567
1567
  uniform sampler2D metalnessMap;
1568
- #endif`,hp=`#ifdef USE_INSTANCING_MORPH
1568
+ #endif`,fp=`#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`,up=`#if defined( USE_MORPHCOLORS )
1574
+ #endif`,pp=`#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`,dp=`#ifdef USE_MORPHNORMALS
1587
+ #endif`,mp=`#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`,fp=`#ifdef USE_MORPHTARGETS
1592
+ #endif`,gp=`#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`,pp=`#ifdef USE_MORPHTARGETS
1606
+ #endif`,_p=`#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`,mp=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1611
+ #endif`,xp=`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;`,gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1652
+ vec3 nonPerturbedNormal = normal;`,yp=`#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;`,gp=`#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`,_p=`#ifndef FLAT_SHADED
1670
+ #endif`,vp=`#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`,xp=`#ifndef FLAT_SHADED
1676
+ #endif`,bp=`#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`,yp=`#ifndef FLAT_SHADED
1682
+ #endif`,Mp=`#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;`,gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1688
1688
  vBitangent = - vBitangent;
1689
1689
  #endif
1690
1690
  #endif
1691
- #endif`,vp=`#ifdef USE_NORMALMAP
1691
+ #endif`,Sp=`#ifdef USE_NORMALMAP
1692
1692
  uniform sampler2D normalMap;
1693
1693
  uniform vec2 normalScale;
1694
1694
  #endif
@@ -1710,13 +1710,13 @@ vec3 nonPerturbedNormal = normal;`,gp=`#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`,bp=`#ifdef USE_CLEARCOAT
1713
+ #endif`,wp=`#ifdef USE_CLEARCOAT
1714
1714
  vec3 clearcoatNormal = nonPerturbedNormal;
1715
- #endif`,Mp=`#ifdef USE_CLEARCOAT_NORMALMAP
1715
+ #endif`,Ep=`#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`,Sp=`#ifdef USE_CLEARCOATMAP
1719
+ #endif`,Tp=`#ifdef USE_CLEARCOATMAP
1720
1720
  uniform sampler2D clearcoatMap;
1721
1721
  #endif
1722
1722
  #ifdef USE_CLEARCOAT_NORMALMAP
@@ -1725,18 +1725,18 @@ vec3 nonPerturbedNormal = normal;`,gp=`#ifdef USE_NORMALMAP_OBJECTSPACE
1725
1725
  #endif
1726
1726
  #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1727
1727
  uniform sampler2D clearcoatRoughnessMap;
1728
- #endif`,wp=`#ifdef USE_IRIDESCENCEMAP
1728
+ #endif`,Ap=`#ifdef USE_IRIDESCENCEMAP
1729
1729
  uniform sampler2D iridescenceMap;
1730
1730
  #endif
1731
1731
  #ifdef USE_IRIDESCENCE_THICKNESSMAP
1732
1732
  uniform sampler2D iridescenceThicknessMap;
1733
- #endif`,Ep=`#ifdef OPAQUE
1733
+ #endif`,Rp=`#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 );`,Tp=`vec3 packNormalToRGB( const in vec3 normal ) {
1739
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Cp=`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
- }`,Ap=`#ifdef PREMULTIPLIED_ALPHA
1818
+ }`,Pp=`#ifdef PREMULTIPLIED_ALPHA
1819
1819
  gl_FragColor.rgb *= gl_FragColor.a;
1820
- #endif`,Rp=`vec4 mvPosition = vec4( transformed, 1.0 );
1820
+ #endif`,Ip=`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;`,Cp=`#ifdef DITHERING
1828
+ gl_Position = projectionMatrix * mvPosition;`,Lp=`#ifdef DITHERING
1829
1829
  gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1830
- #endif`,Pp=`#ifdef DITHERING
1830
+ #endif`,Dp=`#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`,Ip=`float roughnessFactor = roughness;
1837
+ #endif`,Np=`float roughnessFactor = roughness;
1838
1838
  #ifdef USE_ROUGHNESSMAP
1839
1839
  vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1840
1840
  roughnessFactor *= texelRoughness.g;
1841
- #endif`,Lp=`#ifdef USE_ROUGHNESSMAP
1841
+ #endif`,Up=`#ifdef USE_ROUGHNESSMAP
1842
1842
  uniform sampler2D roughnessMap;
1843
- #endif`,Dp=`#if NUM_SPOT_LIGHT_COORDS > 0
1843
+ #endif`,Fp=`#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;`,Cp=`#ifdef DITHERING
2094
2094
  }
2095
2095
  #endif
2096
2096
  #endif
2097
- #endif`,Np=`#if NUM_SPOT_LIGHT_COORDS > 0
2097
+ #endif`,Op=`#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;`,Cp=`#ifdef DITHERING
2139
2139
  };
2140
2140
  uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
2141
2141
  #endif
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 )
2142
+ #endif`,Bp=`#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;`,Cp=`#ifdef DITHERING
2179
2179
  vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
2180
2180
  }
2181
2181
  #pragma unroll_loop_end
2182
- #endif`,Fp=`float getShadowMask() {
2182
+ #endif`,zp=`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;`,Cp=`#ifdef DITHERING
2220
2220
  #endif
2221
2221
  #endif
2222
2222
  return shadow;
2223
- }`,Op=`#ifdef USE_SKINNING
2223
+ }`,kp=`#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`,Bp=`#ifdef USE_SKINNING
2228
+ #endif`,Vp=`#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;`,Cp=`#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`,zp=`#ifdef USE_SKINNING
2243
+ #endif`,Gp=`#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;`,Cp=`#ifdef DITHERING
2248
2248
  skinned += boneMatZ * skinVertex * skinWeight.z;
2249
2249
  skinned += boneMatW * skinVertex * skinWeight.w;
2250
2250
  transformed = ( bindMatrixInverse * skinned ).xyz;
2251
- #endif`,kp=`#ifdef USE_SKINNING
2251
+ #endif`,Hp=`#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;`,Cp=`#ifdef DITHERING
2259
2259
  #ifdef USE_TANGENT
2260
2260
  objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2261
2261
  #endif
2262
- #endif`,Vp=`float specularStrength;
2262
+ #endif`,Wp=`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`,Gp=`#ifdef USE_SPECULARMAP
2268
+ #endif`,Xp=`#ifdef USE_SPECULARMAP
2269
2269
  uniform sampler2D specularMap;
2270
- #endif`,Hp=`#if defined( TONE_MAPPING )
2270
+ #endif`,qp=`#if defined( TONE_MAPPING )
2271
2271
  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2272
- #endif`,Wp=`#ifndef saturate
2272
+ #endif`,Yp=`#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; }`,Xp=`#ifdef USE_TRANSMISSION
2369
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,Zp=`#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; }`,Xp=`#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`,qp=`#ifdef USE_TRANSMISSION
2390
+ #endif`,$p=`#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; }`,Xp=`#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`,Yp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2516
+ #endif`,Jp=`#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; }`,Xp=`#ifdef USE_TRANSMISS
2586
2586
  #ifdef USE_THICKNESSMAP
2587
2587
  uniform mat3 thicknessMapTransform;
2588
2588
  varying vec2 vThicknessMapUv;
2589
- #endif`,Zp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2589
+ #endif`,Kp=`#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; }`,Xp=`#ifdef USE_TRANSMISS
2684
2684
  #ifdef USE_THICKNESSMAP
2685
2685
  uniform mat3 thicknessMapTransform;
2686
2686
  varying vec2 vThicknessMapUv;
2687
- #endif`,$p=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2687
+ #endif`,jp=`#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; }`,Xp=`#ifdef USE_TRANSMISS
2758
2758
  #endif
2759
2759
  #ifdef USE_THICKNESSMAP
2760
2760
  vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2761
- #endif`,Jp=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2761
+ #endif`,Qp=`#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; }`,Xp=`#ifdef USE_TRANSMISS
2767
2767
  worldPosition = instanceMatrix * worldPosition;
2768
2768
  #endif
2769
2769
  worldPosition = modelMatrix * worldPosition;
2770
- #endif`,Kp=`varying vec2 vUv;
2770
+ #endif`,em=`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
- }`,jp=`uniform sampler2D t2D;
2775
+ }`,tm=`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
- }`,Qp=`varying vec3 vWorldDirection;
2787
+ }`,nm=`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
- }`,em=`uniform float backgroundBlurriness;
2794
+ }`,im=`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
- }`,tm=`varying vec3 vWorldDirection;
2809
+ }`,sm=`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
- }`,nm=`uniform samplerCube tCube;
2816
+ }`,rm=`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
- }`,im=`#include <common>
2826
+ }`,om=`#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
- }`,sm=`#if DEPTH_PACKING == 3200
2853
+ }`,am=`#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
- }`,rm=`#define DISTANCE
2891
+ }`,lm=`#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
- }`,om=`#define DISTANCE
2918
+ }`,cm=`#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
- }`,am=`varying vec3 vWorldDirection;
2941
+ }`,hm=`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
- }`,lm=`uniform sampler2D tEquirect;
2947
+ }`,um=`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
- }`,cm=`uniform float scale;
2956
+ }`,dm=`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
- }`,hm=`uniform vec3 diffuse;
2978
+ }`,fm=`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
- }`,um=`#include <common>
3006
+ }`,pm=`#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
- }`,dm=`uniform vec3 diffuse;
3038
+ }`,mm=`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
- }`,fm=`#define LAMBERT
3086
+ }`,gm=`#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
- }`,pm=`#define LAMBERT
3125
+ }`,_m=`#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
- }`,mm=`#define MATCAP
3182
+ }`,xm=`#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
- }`,gm=`#define MATCAP
3216
+ }`,ym=`#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
- }`,_m=`#define NORMAL
3262
+ }`,vm=`#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
- }`,xm=`#define NORMAL
3295
+ }`,bm=`#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
- }`,ym=`#define PHONG
3316
+ }`,Mm=`#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
- }`,vm=`#define PHONG
3355
+ }`,Sm=`#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
- }`,bm=`#define STANDARD
3414
+ }`,wm=`#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
- }`,Mm=`#define STANDARD
3457
+ }`,Em=`#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
- }`,Sm=`#define TOON
3590
+ }`,Tm=`#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
- }`,wm=`#define TOON
3627
+ }`,Am=`#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
- }`,Em=`uniform float size;
3679
+ }`,Rm=`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
- }`,Tm=`uniform vec3 diffuse;
3710
+ }`,Cm=`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
- }`,Am=`#include <common>
3735
+ }`,Pm=`#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
+ }`,Im=`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
- }`,Cm=`uniform float rotation;
3774
+ }`,Lm=`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
- }`,Pm=`uniform vec3 diffuse;
3798
+ }`,Dm=`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
- }`,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:`
3823
+ }`,$e={alphahash_fragment:ef,alphahash_pars_fragment:tf,alphamap_fragment:nf,alphamap_pars_fragment:sf,alphatest_fragment:rf,alphatest_pars_fragment:of,aomap_fragment:af,aomap_pars_fragment:lf,batching_pars_vertex:cf,batching_vertex:hf,begin_vertex:uf,beginnormal_vertex:df,bsdfs:ff,iridescence_fragment:pf,bumpmap_pars_fragment:mf,clipping_planes_fragment:gf,clipping_planes_pars_fragment:_f,clipping_planes_pars_vertex:xf,clipping_planes_vertex:yf,color_fragment:vf,color_pars_fragment:bf,color_pars_vertex:Mf,color_vertex:Sf,common:wf,defaultnormal_vertex:Ef,displacementmap_pars_vertex:Tf,displacementmap_vertex:Af,emissivemap_fragment:Rf,emissivemap_pars_fragment:Cf,colorspace_fragment:Pf,colorspace_pars_fragment:If,envmap_fragment:Lf,envmap_common_pars_fragment:Df,envmap_pars_fragment:Nf,envmap_pars_vertex:Uf,envmap_physical_pars_fragment:qf,envmap_vertex:Ff,fog_vertex:Of,fog_pars_vertex:Bf,fog_fragment:zf,fog_pars_fragment:kf,gradientmap_pars_fragment:Vf,lightmap_pars_fragment:Gf,lights_lambert_fragment:Hf,lights_lambert_pars_fragment:Wf,lights_pars_begin:Xf,lights_toon_fragment:Yf,lights_toon_pars_fragment:Zf,lights_phong_fragment:$f,lights_phong_pars_fragment:Jf,lights_physical_fragment:Kf,lights_physical_pars_fragment:jf,lights_fragment_begin:Qf,lights_fragment_maps:ep,lights_fragment_end:tp,lightprobes_pars_fragment:np,logdepthbuf_fragment:ip,logdepthbuf_pars_fragment:sp,logdepthbuf_pars_vertex:rp,logdepthbuf_vertex:op,map_fragment:ap,map_pars_fragment:lp,map_particle_fragment:cp,map_particle_pars_fragment:hp,metalnessmap_fragment:up,metalnessmap_pars_fragment:dp,morphinstance_vertex:fp,morphcolor_vertex:pp,morphnormal_vertex:mp,morphtarget_pars_vertex:gp,morphtarget_vertex:_p,normal_fragment_begin:xp,normal_fragment_maps:yp,normal_pars_fragment:vp,normal_pars_vertex:bp,normal_vertex:Mp,normalmap_pars_fragment:Sp,clearcoat_normal_fragment_begin:wp,clearcoat_normal_fragment_maps:Ep,clearcoat_pars_fragment:Tp,iridescence_pars_fragment:Ap,opaque_fragment:Rp,packing:Cp,premultiplied_alpha_fragment:Pp,project_vertex:Ip,dithering_fragment:Lp,dithering_pars_fragment:Dp,roughnessmap_fragment:Np,roughnessmap_pars_fragment:Up,shadowmap_pars_fragment:Fp,shadowmap_pars_vertex:Op,shadowmap_vertex:Bp,shadowmask_pars_fragment:zp,skinbase_vertex:kp,skinning_pars_vertex:Vp,skinning_vertex:Gp,skinnormal_vertex:Hp,specularmap_fragment:Wp,specularmap_pars_fragment:Xp,tonemapping_fragment:qp,tonemapping_pars_fragment:Yp,transmission_fragment:Zp,transmission_pars_fragment:$p,uv_pars_fragment:Jp,uv_pars_vertex:Kp,uv_vertex:jp,worldpos_vertex:Qp,background_vert:em,background_frag:tm,backgroundCube_vert:nm,backgroundCube_frag:im,cube_vert:sm,cube_frag:rm,depth_vert:om,depth_frag:am,distance_vert:lm,distance_frag:cm,equirect_vert:hm,equirect_frag:um,linedashed_vert:dm,linedashed_frag:fm,meshbasic_vert:pm,meshbasic_frag:mm,meshlambert_vert:gm,meshlambert_frag:_m,meshmatcap_vert:xm,meshmatcap_frag:ym,meshnormal_vert:vm,meshnormal_frag:bm,meshphong_vert:Mm,meshphong_frag:Sm,meshphysical_vert:wm,meshphysical_frag:Em,meshtoon_vert:Tm,meshtoon_frag:Am,points_vert:Rm,points_frag:Cm,shadow_vert:Pm,shadow_frag:Im,sprite_vert:Lm,sprite_frag:Dm},Me={common:{diffuse:{value:new Ye(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 Ve(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 Ye(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 Ye(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 Ye(16777215)},opacity:{value:1},center:{value:new Ve(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ge},alphaMap:{value:null},alphaMapTransform:{value:new Ge},alphaTest:{value:0}}},Nn={basic:{uniforms:Gt([Me.common,Me.specularmap,Me.envmap,Me.aomap,Me.lightmap,Me.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:Gt([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 Ye(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:Gt([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 Ye(0)},specular:{value:new Ye(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:Gt([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 Ye(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:Gt([Me.common,Me.aomap,Me.lightmap,Me.emissivemap,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.gradientmap,Me.fog,Me.lights,{emissive:{value:new Ye(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:Gt([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,Me.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:Gt([Me.points,Me.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:Gt([Me.common,Me.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:Gt([Me.common,Me.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:Gt([Me.common,Me.bumpmap,Me.normalmap,Me.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:Gt([Me.sprite,Me.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new Ge},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ge}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:Gt([Me.common,Me.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:Gt([Me.lights,Me.fog,{color:{value:new Ye(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Nn.physical={uniforms:Gt([Nn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ge},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ge},clearcoatNormalScale:{value:new Ve(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 Ye(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 Ve},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ge},attenuationDistance:{value:0},attenuationColor:{value:new Ye(0)},specularColor:{value:new Ye(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ge},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ge},anisotropyVector:{value:new Ve},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ge}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};var ua={r:0,b:0,g:0},Nm=new mt,ru=new Ge;ru.set(-1,0,0,0,1,0,0,0,1);function Um(i,e,t,n,s,r){let o=new Ye(0),a=s===!0?0:1,c,l,h=null,u=0,d=null;function f(w){let T=w.isScene===!0?w.background:null;if(T&&T.isTexture){let S=w.backgroundBlurriness>0;T=e.get(T,S)}return T}function _(w){let T=!1,S=f(w);S===null?m(o,a):S&&S.isColor&&(m(S,1),T=!0);let E=i.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(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,T){let S=f(T);S&&S.isCubeTexture?(l===void 0&&(l=new Qt(new os(1,1,1),new In({name:"BackgroundCubeMaterial",uniforms:Ui(Nn.backgroundCube.uniforms),vertexShader:Nn.backgroundCube.vertexShader,fragmentShader:Nn.backgroundCube.fragmentShader,side:Jt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(E,M,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=T.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Nm.makeRotationFromEuler(T.backgroundRotation)).transpose(),S.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(ru),l.material.toneMapped=et.getTransfer(S.colorSpace)!==ct,(h!==S||u!==S.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new Qt(new Gs(2,2),new In({name:"BackgroundMaterial",uniforms:Ui(Nn.background.uniforms),vertexShader:Nn.background.vertexShader,fragmentShader:Nn.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=T.backgroundIntensity,c.material.toneMapped=et.getTransfer(S.colorSpace)!==ct,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(h!==S||u!==S.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=S,u=S.version,d=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function m(w,T){w.getRGB(ua,Ll(i)),t.buffers.color.setClear(ua.r,ua.g,ua.b,T,r)}function p(){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,T=1){o.set(w),a=T,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(w){a=w,m(o,a)},render:_,addToRenderList:x,dispose:p}}function Fm(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null),r=s,o=!1;function a(D,N,B,C,W){let Z=!1,z=u(D,C,B,N);r!==z&&(r=z,l(r.object)),Z=f(D,C,B,W),Z&&_(D,C,B,W),W!==null&&e.update(W,i.ELEMENT_ARRAY_BUFFER),(Z||o)&&(o=!1,S(D,N,B,C),W!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(W).buffer))}function c(){return i.createVertexArray()}function l(D){return i.bindVertexArray(D)}function h(D){return i.deleteVertexArray(D)}function u(D,N,B,C){let W=C.wireframe===!0,Z=n[N.id];Z===void 0&&(Z={},n[N.id]=Z);let z=D.isInstancedMesh===!0?D.id:0,ee=Z[z];ee===void 0&&(ee={},Z[z]=ee);let q=ee[B.id];q===void 0&&(q={},ee[B.id]=q);let J=q[W];return J===void 0&&(J=d(c()),q[W]=J),J}function d(D){let N=[],B=[],C=[];for(let W=0;W<t;W++)N[W]=0,B[W]=0,C[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:N,enabledAttributes:B,attributeDivisors:C,object:D,attributes:{},index:null}}function f(D,N,B,C){let W=r.attributes,Z=N.attributes,z=0,ee=B.getAttributes();for(let q in ee)if(ee[q].location>=0){let O=W[q],ae=Z[q];if(ae===void 0&&(q==="instanceMatrix"&&D.instanceMatrix&&(ae=D.instanceMatrix),q==="instanceColor"&&D.instanceColor&&(ae=D.instanceColor)),O===void 0||O.attribute!==ae||ae&&O.data!==ae.data)return!0;z++}return r.attributesNum!==z||r.index!==C}function _(D,N,B,C){let W={},Z=N.attributes,z=0,ee=B.getAttributes();for(let q in ee)if(ee[q].location>=0){let O=Z[q];O===void 0&&(q==="instanceMatrix"&&D.instanceMatrix&&(O=D.instanceMatrix),q==="instanceColor"&&D.instanceColor&&(O=D.instanceColor));let ae={};ae.attribute=O,O&&O.data&&(ae.data=O.data),W[q]=ae,z++}r.attributes=W,r.attributesNum=z,r.index=C}function x(){let D=r.newAttributes;for(let N=0,B=D.length;N<B;N++)D[N]=0}function m(D){p(D,0)}function p(D,N){let B=r.newAttributes,C=r.enabledAttributes,W=r.attributeDivisors;B[D]=1,C[D]===0&&(i.enableVertexAttribArray(D),C[D]=1),W[D]!==N&&(i.vertexAttribDivisor(D,N),W[D]=N)}function w(){let D=r.newAttributes,N=r.enabledAttributes;for(let B=0,C=N.length;B<C;B++)N[B]!==D[B]&&(i.disableVertexAttribArray(B),N[B]=0)}function T(D,N,B,C,W,Z,z){z===!0?i.vertexAttribIPointer(D,N,B,W,Z):i.vertexAttribPointer(D,N,B,C,W,Z)}function S(D,N,B,C){x();let W=C.attributes,Z=B.getAttributes(),z=N.defaultAttributeValues;for(let ee in Z){let q=Z[ee];if(q.location>=0){let J=W[ee];if(J===void 0&&(ee==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),ee==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){let O=J.normalized,ae=J.itemSize,xe=e.get(J);if(xe===void 0)continue;let H=xe.buffer,ue=xe.type,de=xe.bytesPerElement,we=ue===i.INT||ue===i.UNSIGNED_INT||J.gpuType===Ro;if(J.isInterleavedBufferAttribute){let fe=J.data,Te=fe.isInterleavedBuffer===!0?fe.stride:fe.itemSize,He=J.offset;if(fe.isInstancedInterleavedBuffer||fe.isInstancedBufferAttribute){for(let me=0;me<q.locationSize;me++)p(q.location+me,fe.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=fe.meshPerAttribute*fe.count)}else for(let me=0;me<q.locationSize;me++)m(q.location+me);i.bindBuffer(i.ARRAY_BUFFER,H);for(let me=0;me<q.locationSize;me++)T(q.location+me,ae/q.locationSize,ue,O,Te*de,(He+ae/q.locationSize*me)*de,we)}else{if(J.isInstancedBufferAttribute){for(let fe=0;fe<q.locationSize;fe++)p(q.location+fe,J.meshPerAttribute);D.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let fe=0;fe<q.locationSize;fe++)m(q.location+fe);i.bindBuffer(i.ARRAY_BUFFER,H);for(let fe=0;fe<q.locationSize;fe++)T(q.location+fe,ae/q.locationSize,ue,O,ae*de,ae/q.locationSize*fe*de,we)}}else if(z!==void 0){let O=z[ee];if(O!==void 0)switch(O.length){case 2:i.vertexAttrib2fv(q.location,O);break;case 3:i.vertexAttrib3fv(q.location,O);break;case 4:i.vertexAttrib4fv(q.location,O);break;default:i.vertexAttrib1fv(q.location,O)}}}}w()}function E(){L();for(let D in n){let N=n[D];for(let B in N){let C=N[B];for(let W in C){let Z=C[W];for(let z in Z)h(Z[z].object),delete Z[z];delete C[W]}}delete n[D]}}function M(D){if(n[D.id]===void 0)return;let N=n[D.id];for(let B in N){let C=N[B];for(let W in C){let Z=C[W];for(let z in Z)h(Z[z].object),delete Z[z];delete C[W]}}delete n[D.id]}function g(D){for(let N in n){let B=n[N];for(let C in B){let W=B[C];if(W[D.id]===void 0)continue;let Z=W[D.id];for(let z in Z)h(Z[z].object),delete Z[z];delete W[D.id]}}}function v(D){for(let N in n){let B=n[N],C=D.isInstancedMesh===!0?D.id:0,W=B[C];if(W!==void 0){for(let Z in W){let z=W[Z];for(let ee in z)h(z[ee].object),delete z[ee];delete W[Z]}delete B[C],Object.keys(B).length===0&&delete n[N]}}}function L(){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:L,resetDefaultState:R,dispose:E,releaseStatesOfGeometry:M,releaseStatesOfObject:v,releaseStatesOfProgram:g,initAttributes:x,enableAttribute:m,disableUnusedAttributes:w}}function Om(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 d=0;for(let f=0;f<h;f++)d+=l[f];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=o,this.renderMultiDraw=a}function Bm(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!==An&&n.convert(g)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(g){let v=g===Tn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(g!==en&&g!==En&&!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&&(Fe("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let u=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),d=t.logarithmicDepthBuffer===!0&&u===!1;t.reversedDepthBuffer===!0&&u===!1&&Fe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&u===!0&&Fe("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let f=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),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),E=i.getParameter(i.MAX_SAMPLES),M=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:u,maxTextures:f,maxVertexTextures:_,maxTextureSize:x,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:w,maxVaryings:T,maxFragmentUniforms:S,maxSamples:E,samples:M}}function zm(i){let e=this,t=null,n=0,s=!1,r=!1,o=new an,a=new Ge,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,f){let _=u.clippingPlanes,x=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||_===null||_.length===0||r&&!m)r?h(null):l();else{let w=r?0:n,T=w*4,S=p.clippingState||null;c.value=S,S=h(_,d,T,f);for(let E=0;E!==T;++E)S[E]=t[E];p.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(u,d,f,_){let x=u!==null?u.length:0,m=null;if(x!==0){if(m=c.value,_!==!0||m===null){let p=f+x*4,w=d.matrixWorldInverse;a.getNormalMatrix(w),(m===null||m.length<p)&&(m=new Float32Array(p));for(let T=0,S=f;T!==x;++T,S+=4)o.copy(u[T]).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 rr=class extends cn{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 Bs(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 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}},`
3858
+ `},s=new os(5,5,5),r=new In({name:"CubemapFromEquirect",uniforms:Ui(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Jt,blending:Ii});r.uniforms.tEquirect.value=t;let o=new Qt(s,r),a=t.minFilter;return t.minFilter===Kn&&(t.minFilter=Zt),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)}},Oh=256,km=3,Vm=20,ou=256,au=16,Gm=3,Hm=new k,Wm=new Ye,fa=class i{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new cs(1,10,null),this._boxMesh=new Qt(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=Hm}=r,c=this._renderer;this._setSize(o);let l=this._allocateTarget(),h=this._getSourceTarget(!0);t>0&&(h.texture.mipmapsAutoUpdate=!1);let u=c.autoClear,d=c.autoClearColor,f=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(Wm));let m=new cs(n,s,h);return m.position.copy(a),m.update(c,e),c.autoClear=u,c.autoClearColor=d,c.autoClearDepth=f,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=kh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=zh(),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(Oh,Cl(e))}_fromTexture(e,t){e.mapping===Di||e.mapping===fs?this._setSize(e.image.length===0?Oh: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=Bh(e,!1,!1),n=Math.log2(e)-km;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=Bh(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=kh()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=zh()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=Xm(),this._integrationMaterial=qm());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/au);for(let o=0;o<=n;o++){let a=i.lodToRoughness(o,n);if(o>n-Gm)r.roughness.value=a,this._renderCube(e,o,this._integrationMaterial);else{let c=a>0?Math.log2(t)+.5*Math.log2(6/(ou*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=Ym());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 Bh(i,e,t){return new rr(i,{minFilter:Kn,generateMipmaps:e,type:Tn,colorSpace:Ps,depthBuffer:t})}function or(i,e,t){return new In({name:i,uniforms:e,vertexShader:$e.cube_vert,fragmentShader:t,side:Jt,blending:Ii,depthTest:!1,depthWrite:!1})}function Xm(){return or("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},`
3859
3859
 
3860
- #define GGX_SAMPLES ${ru}u
3860
+ #define GGX_SAMPLES ${ou}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 Hm(){return rr("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:ou}},`
3942
+ `)}function qm(){return or("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:au}},`
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 Wm(){return rr("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},`
3995
+ `)}function Ym(){return or("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},`
3996
3996
 
3997
- #define SAMPLES ${Bm}
3997
+ #define SAMPLES ${Vm}
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 Bh(){return rr("PMREMEquirectangularToCubemap",{envMap:{value:null}},`
4043
+ `)}function zh(){return or("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 zh(){return rr("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},`
4065
+ `)}function kh(){return or("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 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:`
4077
+ `)}function Zm(i){let e=new WeakMap,t=new WeakMap,n=null;function s(d,f=!1){return d==null?null:f?o(d):r(d)}function r(d){if(d&&d.isTexture){let f=d.mapping;if(f===Eo||f===To)if(e.has(d)){let _=e.get(d).texture;return a(_,d.mapping)}else{let _=d.image;if(_&&_.height>0){let x=new rr(_.height);return x.fromEquirectangularTexture(i,d),e.set(d,x),d.addEventListener("dispose",l),a(x.texture,d.mapping)}else return null}}return d}function o(d){if(d&&d.isTexture&&d.isPMREMTexture!==!0){let f=d.mapping,_=f===Eo||f===To,x=f===Di||f===fs;if(_||x){let m=t.get(d),p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new fa(i)),m=_?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),m.texture;if(m!==void 0)return m.texture;{let w=d.image;return _&&w&&w.height>0||x&&w&&c(w)?(n===null&&(n=new fa(i)),m=_?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,t.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function a(d,f){return f===Eo?d.mapping=Di:f===To&&(d.mapping=fs),d}function c(d){let f=0,_=6;for(let x=0;x<_;x++)d[x]!==void 0&&f++;return f===_}function l(d){let f=d.target;f.removeEventListener("dispose",l);let _=e.get(f);_!==void 0&&(e.delete(f),_.dispose())}function h(d){let f=d.target;f.removeEventListener("dispose",h);let _=t.get(f);_!==void 0&&(t.delete(f),_.dispose())}function u(){e=new WeakMap,t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:s,dispose:u}}function $m(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&&As("WebGLRenderer: "+n+" extension not supported."),s}}}function Jm(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 u(_){let x=_.index,m=_.attributes.position,p=0;if(m===void 0)return;let w=x!==null?x.array.length:m.array.length/3-1,T=m.count>=65535?Os:Fs,S=new T(Math.ceil(w/3)*6,1),E=S.array;if(x!==null){let g=x.array;p=x.version;for(let v=0,L=0;v<w;v+=3){let R=g[v+0],D=g[v+1],N=g[v+2];E[L++]=R,E[L++]=D,E[L++]=D,E[L++]=N,E[L++]=N,E[L++]=R}}else{p=m.version;for(let g=0,v=0;g<w;g+=3){let L=g+0,R=g+1,D=g+2;E[v++]=L,E[v++]=R,E[v++]=R,E[v++]=D,E[v++]=D,E[v++]=L}}S.version=p;let M=r.get(_);M&&e.remove(M),r.set(_,S)}function d(_){let x=r.get(_);if(x){let m=_.index;m!==null&&x.version<m.version&&u(_)}else u(_);return r.get(_)}function f(){for(let _ in s){let x=s[_].deref();x!==void 0&&c(x)}}return{get:l,update:h,getWireframeAttribute:d,dispose:f}}function Km(i,e,t){let n;function s(u){n=u}let r,o;function a(u){r=u.type,o=u.bytesPerElement}function c(u,d){i.drawElements(n,d,r,u*o),t.update(d,n,1)}function l(u,d,f){f!==0&&(i.drawElementsInstanced(n,d,r,u*o,f),t.update(d,n,f))}function h(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,f);let x=0;for(let m=0;m<f;m++)x+=d[m];t.update(x,n,1)}this.setMode=s,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function jm(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:ke("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 Qm(i,e,t){let n=new WeakMap,s=new _t;function r(o,a,c){let l=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=h!==void 0?h.length:0,d=n.get(a);if(d===void 0||d.count!==u){let L=function(){g.dispose(),n.delete(a),a.removeEventListener("dispose",L)};d!==void 0&&d.texture.dispose();let f=a.morphAttributes.position!==void 0,_=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],w=a.morphAttributes.color||[],T=0;f===!0&&(T=1),_===!0&&(T=2),x===!0&&(T=3);let S=a.attributes.position.count*T,E=1;S>e.maxTextureSize&&(E=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);let M=new Float32Array(S*E*4*u),g=new Ds(M,S,E,u);g.type=En,g.needsUpdate=!0;let v=T*4;for(let R=0;R<u;R++){let D=m[R],N=p[R],B=w[R],C=S*E*4*R;for(let W=0;W<D.count;W++){let Z=W*v;f===!0&&(s.fromBufferAttribute(D,W),M[C+Z+0]=s.x,M[C+Z+1]=s.y,M[C+Z+2]=s.z,M[C+Z+3]=0),_===!0&&(s.fromBufferAttribute(N,W),M[C+Z+4]=s.x,M[C+Z+5]=s.y,M[C+Z+6]=s.z,M[C+Z+7]=0),x===!0&&(s.fromBufferAttribute(B,W),M[C+Z+8]=s.x,M[C+Z+9]=s.y,M[C+Z+10]=s.z,M[C+Z+11]=B.itemSize===4?s.w:1)}}d={count:u,texture:g,size:new Ve(S,E)},n.set(a,d),a.addEventListener("dispose",L)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let f=0;for(let x=0;x<l.length;x++)f+=l[x];let _=a.morphTargetsRelative?1:1-f;c.getUniforms().setValue(i,"morphTargetBaseInfluence",_),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function eg(i,e,t,n,s){let r=new WeakMap;function o(l){let h=s.render.frame,u=l.geometry,d=e.get(l,u);if(r.get(d)!==h&&(e.update(d),r.set(d,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 f=l.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return d}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 tg={[cl]:"LINEAR_TONE_MAPPING",[hl]:"REINHARD_TONE_MAPPING",[ul]:"CINEON_TONE_MAPPING",[dl]:"ACES_FILMIC_TONE_MAPPING",[pl]:"AGX_TONE_MAPPING",[$s]:"NEUTRAL_TONE_MAPPING",[fl]:"CUSTOM_TONE_MAPPING"};function ng(i,e,t,n,s,r){let o=new cn(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 $t;h.setAttribute("position",new Yt([-1,3,0,-1,-1,0,3,-1,0],3)),h.setAttribute("uv",new Yt([0,2,0,0,2,0],2));let u=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 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(`
4123
+ }`,depthTest:!1,depthWrite:!1}),d=new Qt(h,u),f=new Pi(-1,1,1,-1,0,1),_=null,x=null,m=!1,p,w=null,T=[],S=!1;this.setSize=function(E,M){o.setSize(E,M),a!==null&&a.setSize(E,M),c!==null&&c.setSize(E,M);for(let g=0;g<T.length;g++){let v=T[g];v.setSize&&v.setSize(E,M)}},this.setEffects=function(E){T=E,S=T.length>0&&T[0].isRenderPass===!0;let M=o.width,g=o.height;T.length>0&&a===null&&(a=new cn(M,g,{type:Tn,depthBuffer:!1,stencilBuffer:!1}),c=new cn(M,g,{type:Tn,depthBuffer:!1,stencilBuffer:!1}));let v=s===!0&&T.some(L=>L.needsDepthTexture===!0);v!==(o.depthTexture!==null)&&(v===!0&&l===null&&(l=new Jn(M,g),r===!0&&(l.format=jn,l.type=Ni)),o.dispose(),o.depthTexture=v?l:null,o.resolveDepthBuffer=v,o.storeMultisampledDepthBuffer=v);for(let L=0;L<T.length;L++){let R=T[L];R.setSize&&R.setSize(M,g),v&&R.needsDepthTexture===!0&&R.setDepthTexture&&R.setDepthTexture(l)}},this.begin=function(E,M){if(m||E.toneMapping===Ln&&T.length===0)return!1;if(w=M,M!==null){let g=M.width,v=M.height;(o.width!==g||o.height!==v)&&this.setSize(g,v)}return S===!1&&E.setRenderTarget(o),p=E.toneMapping,E.toneMapping=Ln,!0},this.hasRenderPass=function(){return S},this.end=function(E,M){E.toneMapping=p,m=!0;let g=o,v=a;for(let L=0;L<T.length;L++){let R=T[L];R.enabled!==!1&&(R.render(E,v,g,M),R.needsSwap!==!1&&(g=v,v=v===a?c:a))}if(_!==E.outputColorSpace||x!==E.toneMapping){_=E.outputColorSpace,x=E.toneMapping,u.defines={},et.getTransfer(_)===ct&&(u.defines.SRGB_TRANSFER="");let L=tg[x];L&&(u.defines[L]=""),u.needsUpdate=!0}u.uniforms.tDiffuse.value=g.texture,E.setRenderTarget(w),E.render(d,f),w=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.dispose(),a!==null&&a.dispose(),c!==null&&c.dispose(),h.dispose(),u.dispose()}}var lu=new jt,cu=new Jn(1,1),hu=new zs(1),uu=new Ds,du=new to,fu=new Bs,Vh=[],Gh=[],Hh=new Float32Array(16),Wh=new Float32Array(9),Xh=new Float32Array(4);function _s(i,e,t){let n=i[0];if(n<=0||n>0)return i;let s=e*t,r=Vh[s];if(r===void 0&&(r=new Float32Array(s),Vh[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=Gh[e];t===void 0&&(t=new Int32Array(e),Gh[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function ig(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function sg(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 rg(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 og(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 ag(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;Xh.set(n),i.uniformMatrix2fv(this.addr,!1,Xh),Tt(t,n)}}function lg(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;Wh.set(n),i.uniformMatrix3fv(this.addr,!1,Wh),Tt(t,n)}}function cg(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;Hh.set(n),i.uniformMatrix4fv(this.addr,!1,Hh),Tt(t,n)}}function hg(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function ug(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 dg(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 fg(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 pg(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function mg(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 gg(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 _g(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=El,i.needsUpdate=!0),i}function xg(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(cu):r=lu,t.setTexture2D(e||r,s)}function yg(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture3D(e||du,s)}function vg(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(hu):r=fu,t.setTextureCube(e||r,s)}function bg(i,e,t){let n=this.cache,s=t.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),t.setTexture2DArray(e||uu,s)}function Mg(i){switch(i){case 5126:return ig;case 35664:return sg;case 35665:return rg;case 35666:return og;case 35674:return ag;case 35675:return lg;case 35676:return cg;case 5124:case 35670:return hg;case 35667:case 35671:return ug;case 35668:case 35672:return dg;case 35669:case 35673:return fg;case 5125:return pg;case 36294:return mg;case 36295:return gg;case 36296:return _g;case 35678:case 36198:case 36298:case 36306:case 35682:return xg;case 35679:case 36299:case 36307:return yg;case 35680:case 36300:case 36308:case 36293:return vg;case 36289:case 36303:case 36311:case 36292:return bg}}function Sg(i,e){i.uniform1fv(this.addr,e)}function wg(i,e){let t=_s(e,this.size,2);i.uniform2fv(this.addr,t)}function Eg(i,e){let t=_s(e,this.size,3);i.uniform3fv(this.addr,t)}function Tg(i,e){let t=_s(e,this.size,4);i.uniform4fv(this.addr,t)}function Ag(i,e){let t=_s(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Rg(i,e){let t=_s(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function Cg(i,e){let t=_s(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Pg(i,e){i.uniform1iv(this.addr,e)}function Ig(i,e){i.uniform2iv(this.addr,e)}function Lg(i,e){i.uniform3iv(this.addr,e)}function Dg(i,e){i.uniform4iv(this.addr,e)}function Ng(i,e){i.uniform1uiv(this.addr,e)}function Ug(i,e){i.uniform2uiv(this.addr,e)}function Fg(i,e){i.uniform3uiv(this.addr,e)}function Og(i,e){i.uniform4uiv(this.addr,e)}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));let o;this.type===i.SAMPLER_2D_SHADOW?o=ga(cu):o=lu;for(let a=0;a!==s;++a)t.setTexture2D(e[a]||o,r[a])}function zg(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]||du,r[o])}function kg(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(hu):o=fu;for(let a=0;a!==s;++a)t.setTextureCube(e[a]||o,r[a])}function Vg(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]||uu,r[o])}function Gg(i){switch(i){case 5126:return Sg;case 35664:return wg;case 35665:return Eg;case 35666:return Tg;case 35674:return Ag;case 35675:return Rg;case 35676:return Cg;case 5124:case 35670:return Pg;case 35667:case 35671:return Ig;case 35668:case 35672:return Lg;case 35669:case 35673:return Dg;case 5125:return Ng;case 36294:return Ug;case 36295:return Fg;case 36296:return Og;case 35678:case 36198:case 36298:case 36306:case 35682:return Bg;case 35679:case 36299:case 36307:return zg;case 35680:case 36300:case 36308:case 36293:return kg;case 36289:case 36303:case 36311:case 36292:return Vg}}var Hl=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=Mg(t.type)}},Wl=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)}},Xl=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)}}},Vl=/(\w+)(\])?(\[|\.)?/g;function qh(i,e){i.seq.push(e),i.map[e.id]=e}function Hg(i,e,t){let n=i.name,s=n.length;for(Vl.lastIndex=0;;){let r=Vl.exec(n),o=Vl.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===s){qh(t,l===void 0?new Hl(a,i,e):new Wl(a,i,e));break}else{let u=t.map[a];u===void 0&&(u=new Xl(a),qh(t,u)),t=u}}}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);Hg(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 Yh(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var Wg=37297,Xg=0;function qg(i,e){let t=i.split(`
4124
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()+`
4125
+ `)}var Zh=new Ge;function Yg(i){et._getMatrix(Zh,et.workingColorSpace,i);let e=`mat3( ${Zh.elements.map(t=>t.toFixed(4))} )`;switch(et.getTransfer(i)){case Is:return[e,"LinearTransferOETF"];case ct:return[e,"sRGBTransferOETF"];default:return Fe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function $h(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
- `+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;
4129
+ `+qg(i.getShaderSource(e),a)}else return r}function Zg(i,e){let t=Yg(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( ${t[0]} * value.rgb, value.a ) );`,"}"].join(`
4130
+ `)}var $g={[cl]:"Linear",[hl]:"Reinhard",[ul]:"Cineon",[dl]:"ACESFilmic",[pl]:"AgX",[$s]:"Neutral",[fl]:"Custom"};function Jg(i,e){let t=$g[e];return t===void 0?(Fe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var da=new k;function Kg(){et.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 jg(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(sr).join(`
4132
+ `)}function Qg(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
4133
+ `)}function e0(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 sr(i){return i!==""}function Jh(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 Kh(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var t0=/^[ \t]*#include +<([\w\d./]+)>/gm;function ql(i){return i.replace(t0,n0)}function n0(i,e){let t=$e[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return ql(t)}var i0=/#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 jh(i){return i.replace(i0,s0)}function s0(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 Qh(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 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(`
4153
+ #define LOW_PRECISION`),e}var r0={[Zs]:"SHADOWMAP_TYPE_PCF",[us]:"SHADOWMAP_TYPE_VSM"};function o0(i){return r0[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}var a0={[fs]:"ENVMAP_MODE_REFRACTION"};function l0(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":a0[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}var c0={[wo]:"ENVMAP_BLENDING_MULTIPLY",[mh]:"ENVMAP_BLENDING_MIX",[gh]:"ENVMAP_BLENDING_ADD"};function h0(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":c0[i.combine]||"ENVMAP_BLENDING_NONE"}function u0(i,e,t,n){let s=i.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,c=o0(t),l=t.envMapPMREM===!0?"ENVMAP_TYPE_PMREM":"ENVMAP_TYPE_CUBE",h=l0(t),u=h0(t),d=jg(t),f=Qg(r),_=s.createProgram(),x,m,p=t.glslVersion?"#version "+t.glslVersion+`
4154
+ `:"";t.isRawShaderMaterial?(x=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f].filter(sr).join(`
4155
4155
  `),x.length>0&&(x+=`
4156
- `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(ir).join(`
4156
+ `),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f].filter(sr).join(`
4157
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(`
4158
+ `)):(x=[Qh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f,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(sr).join(`
4160
+ `),m=[Qh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,f,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 "+u:"",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!==Ln?"#define TONE_MAPPING":"",t.toneMapping!==Ln?$e.tonemapping_pars_fragment:"",t.toneMapping!==Ln?Jg("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,Zg("linearToOutputTexel",t.outputColorSpace),Kg(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
4161
+ `].filter(sr).join(`
4162
+ `)),o=ql(o),o=Jh(o,t),o=Kh(o,t),a=ql(a),a=Jh(a,t),a=Kh(a,t),o=jh(o),a=jh(a),t.isRawShaderMaterial!==!0&&(p=`#version 300 es
4163
+ `,x=[d,"#define attribute in","#define varying out","#define texture2D texture"].join(`
4164
4164
  `)+`
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(`
4165
+ `+x,m=["#define varying in",t.glslVersion===Tl?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Tl?"":"#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
- `+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)+`
4167
+ `+m);let w=p+x+o,T=p+m+a,S=Yh(s,s.VERTEX_SHADER,w),E=Yh(s,s.FRAGMENT_SHADER,T);s.attachShader(_,S),s.attachShader(_,E),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(R){if(i.debug.checkShaderErrors){let D=s.getProgramInfoLog(_)||"",N=s.getShaderInfoLog(S)||"",B=s.getShaderInfoLog(E)||"",C=D.trim(),W=N.trim(),Z=B.trim(),z=!0,ee=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(z=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,S,E);else{let q=$h(s,S,"vertex"),J=$h(s,E,"fragment");ke("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
4168
4168
 
4169
4169
  Material Name: `+R.name+`
4170
4170
  Material Type: `+R.type+`
4171
4171
 
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() {
4172
+ Program Info Log: `+C+`
4173
+ `+q+`
4174
+ `+J)}else C!==""?Fe("WebGLProgram: Program Info Log:",C):(W===""||Z==="")&&(ee=!1);ee&&(R.diagnostics={runnable:z,programLog:C,vertexShader:{log:W,prefix:x},fragmentShader:{log:Z,prefix:m}})}s.deleteShader(S),s.deleteShader(E),g=new gs(s,_),v=e0(s,_)}let g;this.getUniforms=function(){return g===void 0&&M(this),g};let v;this.getAttributes=function(){return v===void 0&&M(this),v};let L=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return L===!1&&(L=s.getProgramParameter(_,Wg)),L},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Xg++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=S,this.fragmentShader=E,this}var d0=0,Yl=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 Zl(e),t.set(e,n)),n}},Zl=class{constructor(e){this.id=d0++,this.code=e,this.usedTimes=0}};function f0(i){return i===_i||i===tr||i===nr}function p0(i,e,t,n,s,r){let o=new Ns,a=new Yl,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer,d={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 f(g){return c.add(g),g===0?"uv":`uv${g}`}function _(g,v,L,R,D,N){let B=R.fog,C=D.geometry,W=g.isMeshStandardMaterial||g.isMeshLambertMaterial||g.isMeshPhongMaterial?R.environment:null,Z=g.isMeshStandardMaterial||g.isMeshLambertMaterial&&!g.envMap||g.isMeshPhongMaterial&&!g.envMap,z=e.get(g.envMap||W,Z),ee=d[g.type],q=n.precision;g.precision!==null&&(q=n.getMaxPrecision(g.precision),q!==g.precision&&Fe("WebGLProgram.getParameters:",g.precision,"not supported, using",q,"instead."));let J=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,O=J!==void 0?J.length:0,ae=0;C.morphAttributes.position!==void 0&&(ae=1),C.morphAttributes.normal!==void 0&&(ae=2),C.morphAttributes.color!==void 0&&(ae=3);let xe,H,ue,de;if(ee){let ce=Nn[ee];xe=ce.vertexShader,H=ce.fragmentShader}else{xe=g.vertexShader,H=g.fragmentShader;let ce=a.getVertexShaderStage(g),Ue=a.getFragmentShaderStage(g);a.update(g,ce,Ue),ue=ce.id,de=Ue.id}let we=i.getRenderTarget(),fe=i.state.buffers.depth.getReversed(),Te=D.isInstancedMesh===!0,He=D.isBatchedMesh===!0,me=!!g.map,Ie=!!g.matcap,Ne=!!z,Oe=Ne&&z.isPMREMTexture===!0,Ce=!!g.aoMap,We=!!g.lightMap,vt=!!g.bumpMap&&g.wireframe===!1,nt=!!g.normalMap,gt=!!g.displacementMap,Xe=!!g.emissiveMap,ft=!!g.metalnessMap,It=!!g.roughnessMap,Ft=g.anisotropy>0,F=g.clearcoat>0,Lt=g.diffuseRoughness>0,st=g.dispersion>0,rt=g.retroreflectivity>0,_e=g.iridescence>0,ht=g.sheen>0,De=g.transmission>0,Be=Ft&&!!g.anisotropyMap,A=F&&!!g.clearcoatMap,y=F&&!!g.clearcoatNormalMap,V=F&&!!g.clearcoatRoughnessMap,le=Lt&&!!g.diffuseRoughnessMap,se=_e&&!!g.iridescenceMap,he=_e&&!!g.iridescenceThicknessMap,ye=ht&&!!g.sheenColorMap,j=ht&&!!g.sheenRoughnessMap,Q=!!g.specularMap,ge=!!g.specularColorMap,I=!!g.specularIntensityMap,te=De&&!!g.transmissionMap,P=De&&!!g.thicknessMap,ne=!!g.gradientMap,$=!!g.alphaMap,ie=g.alphaTest>0,oe=!!g.alphaHash,re=!!g.extensions,K=Ln;g.toneMapped&&(we===null||we.isXRRenderTarget===!0)&&(K=i.toneMapping);let pe=Oe?z.isCompressedCubeTexture?z.image[0].mipmaps:z.mipmaps:null,Le={shaderID:ee,shaderType:g.type,shaderName:g.name,vertexShader:xe,fragmentShader:H,defines:g.defines,customVertexShaderID:ue,customFragmentShaderID:de,isRawShaderMaterial:g.isRawShaderMaterial===!0,glslVersion:g.glslVersion,precision:q,batching:He,batchingColor:He&&D._colorsTexture!==null,instancing:Te,instancingColor:Te&&D.instanceColor!==null,instancingMorph:Te&&D.morphTexture!==null,outputColorSpace:we===null?i.outputColorSpace:we.isXRRenderTarget===!0?we.texture.colorSpace:et.workingColorSpace,alphaToCoverage:!!g.alphaToCoverage,map:me,matcap:Ie,envMap:Ne,envMapMode:Ne&&z.mapping,envMapPMREM:Oe,envMapMaxLod:Oe?pe.length-1:null,envMapSize:Oe?pe[0].width:null,aoMap:Ce,lightMap:We,bumpMap:vt,normalMap:nt,displacementMap:gt,emissiveMap:Xe,normalMapObjectSpace:nt&&g.normalMapType===yh,normalMapTangentSpace:nt&&g.normalMapType===ha,packedNormalMap:nt&&g.normalMapType===ha&&f0(g.normalMap.format),metalnessMap:ft,roughnessMap:It,anisotropy:Ft,anisotropyMap:Be,clearcoat:F,clearcoatMap:A,clearcoatNormalMap:y,clearcoatRoughnessMap:V,diffuseRoughness:Lt,diffuseRoughnessMap:le,dispersion:st,retroreflection:rt,iridescence:_e,iridescenceMap:se,iridescenceThicknessMap:he,sheen:ht,sheenColorMap:ye,sheenRoughnessMap:j,specularMap:Q,specularColorMap:ge,specularIntensityMap:I,transmission:De,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&&f(g.map.channel),aoMapUv:Ce&&f(g.aoMap.channel),lightMapUv:We&&f(g.lightMap.channel),bumpMapUv:vt&&f(g.bumpMap.channel),normalMapUv:nt&&f(g.normalMap.channel),displacementMapUv:gt&&f(g.displacementMap.channel),emissiveMapUv:Xe&&f(g.emissiveMap.channel),metalnessMapUv:ft&&f(g.metalnessMap.channel),roughnessMapUv:It&&f(g.roughnessMap.channel),anisotropyMapUv:Be&&f(g.anisotropyMap.channel),clearcoatMapUv:A&&f(g.clearcoatMap.channel),clearcoatNormalMapUv:y&&f(g.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:V&&f(g.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:le&&f(g.diffuseRoughnessMap.channel),iridescenceMapUv:se&&f(g.iridescenceMap.channel),iridescenceThicknessMapUv:he&&f(g.iridescenceThicknessMap.channel),sheenColorMapUv:ye&&f(g.sheenColorMap.channel),sheenRoughnessMapUv:j&&f(g.sheenRoughnessMap.channel),specularMapUv:Q&&f(g.specularMap.channel),specularColorMapUv:ge&&f(g.specularColorMap.channel),specularIntensityMapUv:I&&f(g.specularIntensityMap.channel),transmissionMapUv:te&&f(g.transmissionMap.channel),thicknessMapUv:P&&f(g.thicknessMap.channel),alphaMapUv:$&&f(g.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(nt||Ft),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&&(me||$),fog:!!B,useFog:g.fog===!0,fogExp2:!!B&&B.isFogExp2,flatShading:g.wireframe===!1&&(g.flatShading===!0||C.attributes.normal===void 0&&nt===!1&&(g.isMeshLambertMaterial||g.isMeshPhongMaterial||g.isMeshStandardMaterial||g.isMeshPhysicalMaterial)),sizeAttenuation:g.sizeAttenuation===!0,logarithmicDepthBuffer:u,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:O,morphTextureStride:ae,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:N.filter(ce=>ce.texture!==null).length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:g.dithering,shadowMapEnabled:i.shadowMap.enabled&&L.length>0,shadowMapType:i.shadowMap.type,toneMapping:K,decodeVideoTexture:me&&g.map.isVideoTexture===!0&&et.getTransfer(g.map.colorSpace)===ct,decodeVideoTextureEmissive:Xe&&g.emissiveMap.isVideoTexture===!0&&et.getTransfer(g.emissiveMap.colorSpace)===ct,premultipliedAlpha:g.premultipliedAlpha,doubleSided:g.side===_n,flipSided:g.side===Jt,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||He)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:g.customProgramCacheKey()};return Le.vertexUv1s=c.has(1),Le.vertexUv2s=c.has(2),Le.vertexUv3s=c.has(3),c.clear(),Le}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 L in g.defines)v.push(L),v.push(g.defines[L]);return g.isRawShaderMaterial===!1&&(m(v,g),p(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 p(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=d[g.type],L;if(v){let R=Nn[v];L=Nh.clone(R.uniforms)}else L=g.uniforms;return L}function T(g,v){let L=h.get(v);return L!==void 0?++L.usedTimes:(L=new u0(i,v,g,s),l.push(L),h.set(v,L)),L}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 E(g){a.remove(g)}function M(){a.dispose()}return{getParameters:_,getProgramCacheKey:x,getUniforms:w,acquireProgram:T,releaseProgram:S,releaseShaderCache:E,programs:l,dispose:M}}function m0(){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 g0(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 eu(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 tu(){let i=[],e=0,t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function o(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function a(d,f,_,x,m,p){let w=i[e];return w===void 0?(w={id:d.id,object:d,geometry:f,material:_,materialVariant:o(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:p},i[e]=w):(w.id=d.id,w.object=d,w.geometry=f,w.material=_,w.materialVariant=o(d),w.groupOrder=x,w.renderOrder=d.renderOrder,w.z=m,w.group=p),e++,w}function c(d,f,_,x,m,p,w){w.reversedDepth===!0&&(m=-m);let T=a(d,f,_,x,m,p);_.transmission>0?n.push(T):_.transparent===!0?s.push(T):t.push(T)}function l(d,f,_,x,m,p){let w=a(d,f,_,x,m,p);_.transmission>0?n.unshift(w):_.transparent===!0?s.unshift(w):t.unshift(w)}function h(d,f){t.length>1&&t.sort(d||g0),n.length>1&&n.sort(f||eu),s.length>1&&s.sort(f||eu)}function u(){for(let d=e,f=i.length;d<f;d++){let _=i[d];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:u,sort:h}}function _0(){let i=new WeakMap;function e(n,s){let r=i.get(n),o;return r===void 0?(o=new tu,i.set(n,[o])):s>=r.length?(o=new tu,r.push(o)):o=r[s],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function x0(){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 Ye};break;case"SpotLight":t={position:new k,direction:new k,color:new Ye,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new k,color:new Ye,distance:0,decay:0};break;case"HemisphereLight":t={direction:new k,skyColor:new Ye,groundColor:new Ye};break;case"RectAreaLight":t={color:new Ye,position:new k,halfWidth:new k,halfHeight:new k};break}return i[e.id]=t,t}}}function y0(){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 Ve};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ve,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var v0=0;function b0(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function M0(i){let e=new x0,t=y0(),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 mt,o=new mt;function a(l){let h=0,u=0,d=0;for(let N=0;N<9;N++)n.probe[N].set(0,0,0);let f=0,_=0,x=0,m=0,p=0,w=0,T=0,S=0,E=0,M=0,g=0,v=0,L=0,R=0;l.sort(b0);for(let N=0,B=l.length;N<B;N++){let C=l[N],W=C.color,Z=C.intensity,z=C.distance,ee=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===_i?ee=C.shadow.map.texture:ee=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=W.r*Z,u+=W.g*Z,d+=W.b*Z;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],Z);R++}else if(C.isSunLight){let q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let J=C.shadow,O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize.copy(J.mapSize).multiply(J.getFrameExtents()),n.sunShadow[_]=O,n.sunShadowMap[_]=ee;let ae=J.getViewportCount();for(let xe=0;xe<ae;xe++)n.sunShadowMatrix[x+xe]=J.getMatrix(xe),n.sunShadowCascade[x+xe]=J._cascadeData[xe];x+=ae,_++}n.sun[f]=q,f++}else if(C.isDirectionalLight){let q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){let J=C.shadow,O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize=J.mapSize,n.directionalShadow[m]=O,n.directionalShadowMap[m]=ee,n.directionalShadowMatrix[m]=C.shadow.matrix,E++}n.directional[m]=q,m++}else if(C.isSpotLight){let q=e.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(W).multiplyScalar(Z),q.distance=z,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[w]=q;let J=C.shadow;if(C.map&&(n.spotLightMap[v]=C.map,v++,J.updateMatrices(C),C.castShadow&&L++),n.spotLightMatrix[w]=J.matrix,C.castShadow){let O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize=J.mapSize,n.spotShadow[w]=O,n.spotShadowMap[w]=ee,g++}w++}else if(C.isRectAreaLight){let q=e.get(C);q.color.copy(W).multiplyScalar(Z),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[T]=q,T++}else if(C.isPointLight){let q=e.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){let J=C.shadow,O=t.get(C);O.shadowIntensity=J.intensity,O.shadowBias=J.bias,O.shadowNormalBias=J.normalBias,O.shadowRadius=J.radius,O.shadowMapSize=J.mapSize,O.shadowCameraNear=J.camera.near,O.shadowCameraFar=J.camera.far,n.pointShadow[p]=O,n.pointShadowMap[p]=ee,n.pointShadowMatrix[p]=C.shadow.matrix,M++}n.point[p]=q,p++}else if(C.isHemisphereLight){let q=e.get(C);q.skyColor.copy(C.color).multiplyScalar(Z),q.groundColor.copy(C.groundColor).multiplyScalar(Z),n.hemi[S]=q,S++}}T>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]=u,n.ambient[2]=d;let D=n.hash;(D.sunLength!==f||D.directionalLength!==m||D.pointLength!==p||D.spotLength!==w||D.rectAreaLength!==T||D.hemiLength!==S||D.numSunShadows!==_||D.numDirectionalShadows!==E||D.numPointShadows!==M||D.numSpotShadows!==g||D.numSpotMaps!==v||D.numLightProbes!==R)&&(n.sun.length=f,n.directional.length=m,n.spot.length=w,n.rectArea.length=T,n.point.length=p,n.hemi.length=S,n.sunShadow.length=_,n.sunShadowMap.length=_,n.sunShadowMatrix.length=x,n.sunShadowCascade.length=x,n.directionalShadow.length=E,n.directionalShadowMap.length=E,n.directionalShadowMatrix.length=E,n.pointShadow.length=M,n.pointShadowMap.length=M,n.pointShadowMatrix.length=M,n.spotShadow.length=g,n.spotShadowMap.length=g,n.spotLightMatrix.length=g+v-L,n.spotLightMap.length=v,n.numSpotLightShadowsWithMaps=L,n.numLightProbes=R,D.sunLength=f,D.directionalLength=m,D.pointLength=p,D.spotLength=w,D.rectAreaLength=T,D.hemiLength=S,D.numSunShadows=_,D.numDirectionalShadows=E,D.numPointShadows=M,D.numSpotShadows=g,D.numSpotMaps=v,D.numLightProbes=R,n.version=v0++)}function c(l,h){let u=0,d=0,f=0,_=0,x=0,m=0,p=h.matrixWorldInverse;for(let w=0,T=l.length;w<T;w++){let S=l[w];if(S.isSunLight){let E=n.sun[u];E.direction.setFromMatrixPosition(S.matrixWorld),E.direction.transformDirection(p),u++}else if(S.isDirectionalLight){let E=n.directional[d];E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),d++}else if(S.isSpotLight){let E=n.spot[_];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),E.direction.setFromMatrixPosition(S.matrixWorld),s.setFromMatrixPosition(S.target.matrixWorld),E.direction.sub(s),E.direction.transformDirection(p),_++}else if(S.isRectAreaLight){let E=n.rectArea[x];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),o.identity(),r.copy(S.matrixWorld),r.premultiply(p),o.extractRotation(r),E.halfWidth.set(S.width*.5,0,0),E.halfHeight.set(0,S.height*.5,0),E.halfWidth.applyMatrix4(o),E.halfHeight.applyMatrix4(o),x++}else if(S.isPointLight){let E=n.point[f];E.position.setFromMatrixPosition(S.matrixWorld),E.position.applyMatrix4(p),f++}else if(S.isHemisphereLight){let E=n.hemi[m];E.direction.setFromMatrixPosition(S.matrixWorld),E.direction.transformDirection(p),m++}}}return{setup:a,setupView:c,state:n}}function nu(i){let e=new M0(i),t=[],n=[],s=[];function r(u){h.camera=u,t.length=0,n.length=0,s.length=0}function o(u){u.isLightProbeGrid?s.push(u):t.push(u)}function a(u){n.push(u)}function c(){e.setup(t),s.sort((u,d)=>u.priority-d.priority||u.id-d.id)}function l(u){e.setupView(t,u)}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 S0(i){let e=new WeakMap;function t(s,r=0){let o=e.get(s),a;return o===void 0?(a=new nu(i),e.set(s,[a])):r>=o.length?(a=new nu(i),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var w0=`void main() {
4175
4175
  gl_Position = vec4( position, 1.0 );
4176
- }`,M0=`uniform sampler2D shadow_pass;
4176
+ }`,E0=`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
- }`,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=`
4201
+ }`,T0=[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)],A0=[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)],iu=new mt,ir=new k,Gl=new k;function R0(i,e,t){let n=new hi,s=new Ve,r=new Ve,o=new _t,a=new lo,c=new co,l={},h=t.maxTextureSize,u={[gi]:Jt,[Jt]:gi,[_n]:_n},d=new In({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ve},radius:{value:4}},vertexShader:w0,fragmentShader:E0}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let _=new $t;_.setAttribute("position",new Vt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Qt(_,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Zs;let p=this.type;this.render=function(M,g,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||M.length===0)return;this.type===Jc&&(Fe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Zs);let L=i.getRenderTarget(),R=i.getActiveCubeFace(),D=i.getActiveMipmapLevel(),N=i.state;N.setBlending(Ii),N.buffers.depth.getReversed()===!0?N.buffers.color.setClear(0,0,0,0):N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let B=p!==this.type;B&&g.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(W=>W.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,W=M.length;C<W;C++){let Z=M[C],z=Z.shadow;if(z===void 0){Fe("WebGLShadowMap:",Z,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;s.copy(z.mapSize);let ee=z.getFrameExtents();s.multiply(ee),r.copy(z.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/ee.x),s.x=r.x*ee.x,z.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/ee.y),s.y=r.y*ee.y,z.mapSize.y=r.y));let q=i.state.buffers.depth.getReversed();if(z.camera._reversedDepth=q,z.map===null||B===!0){if(z.map!==null&&(z.map.depthTexture!==null&&(z.map.depthTexture.dispose(),z.map.depthTexture=null),z.map.dispose()),this.type===us){if(Z.isPointLight){Fe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}z.map=new cn(s.x,s.y,{format:_i,type:Tn,minFilter:Zt,magFilter:Zt,generateMipmaps:!1}),z.map.texture.name=Z.name+".shadowMap",z.map.depthTexture=new Jn(s.x,s.y,En),z.map.depthTexture.name=Z.name+".shadowMapDepth",z.map.depthTexture.format=Yn,z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Pt,z.map.depthTexture.magFilter=Pt}else Z.isPointLight?(z.map=new rr(s.x),z.map.depthTexture=new zs(s.x,wn)):(z.map=new cn(s.x,s.y),z.map.depthTexture=new Jn(s.x,s.y,wn)),z.map.depthTexture.name=Z.name+".shadowMap",z.map.depthTexture.format=Yn,this.type===Zs?(z.map.depthTexture.compareFunction=q?wl:Sl,z.map.depthTexture.minFilter=Zt,z.map.depthTexture.magFilter=Zt):(z.map.depthTexture.compareFunction=null,z.map.depthTexture.minFilter=Pt,z.map.depthTexture.magFilter=Pt);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 J=z.map.isWebGLCubeRenderTarget?6:z.getViewportCount();Z.isPointLight!==!0&&z.updateMatrices(Z,v);let O=(z.camera.layers.mask&4294967294)!==0?z.camera.layers:v.layers;for(let ae=0;ae<J;ae++){let xe=z.getCamera(ae);if(Z.isPointLight){let H=z.camera,ue=z.matrix,de=Z.distance||H.far;de!==H.far&&(H.far=de,H.updateProjectionMatrix()),ir.setFromMatrixPosition(Z.matrixWorld),H.position.copy(ir),Gl.copy(H.position),Gl.add(T0[ae]),H.up.copy(A0[ae]),H.lookAt(Gl),H.updateMatrixWorld(),ue.makeTranslation(-ir.x,-ir.y,-ir.z),iu.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse),z._frustum.setFromProjectionMatrix(iu,H.coordinateSystem,H.reversedDepth)}if(z.map.isWebGLCubeRenderTarget)i.setRenderTarget(z.map,ae),i.clear();else{ae===0&&(i.setRenderTarget(z.map),i.clear());let H=z.getViewport(ae);o.set(r.x*H.x,r.y*H.y,r.x*H.z,r.y*H.w),N.viewport(o)}n=z.getFrustum(ae),S(g,v,xe,Z,O,this.type)}z.isPointLightShadow!==!0&&this.type===us&&w(z,v),z.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(L,R,D)};function w(M,g){let v=e.update(x);d.defines.VSM_SAMPLES!==M.blurSamples&&(d.defines.VSM_SAMPLES=M.blurSamples,f.defines.VSM_SAMPLES=M.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),M.mapPass===null?M.mapPass=new cn(s.x,s.y,{format:_i,type:Tn}):(M.mapPass.width!==M.map.width||M.mapPass.height!==M.map.height)&&M.mapPass.setSize(M.map.width,M.map.height),d.uniforms.shadow_pass.value=M.map.depthTexture,d.uniforms.resolution.value.set(M.map.width,M.map.height),d.uniforms.radius.value=M.radius,i.setRenderTarget(M.mapPass),i.clear(),i.renderBufferDirect(g,null,v,d,x,null),f.uniforms.shadow_pass.value=M.mapPass.texture,f.uniforms.resolution.value.set(M.map.width,M.map.height),f.uniforms.radius.value=M.radius,i.setRenderTarget(M.map),i.clear(),i.renderBufferDirect(g,null,v,f,x,null)}function T(M,g,v,L){let R=null,D=v.isPointLight===!0?M.customDistanceMaterial:M.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 N=R.uuid,B=g.uuid,C=l[N];C===void 0&&(C={},l[N]=C);let W=C[B];W===void 0&&(W=R.clone(),C[B]=W,g.addEventListener("dispose",E)),R=W}if(R.visible=g.visible,R.wireframe=g.wireframe,L===us?R.side=g.shadowSide!==null?g.shadowSide:g.side:R.side=g.shadowSide!==null?g.shadowSide:u[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 N=i.properties.get(R);N.light=v}return R}function S(M,g,v,L,R,D){if(M.visible===!1)return;if(M.layers.test(R)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&D===us)&&(!M.frustumCulled||M.intersectsFrustum(n))){M.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,M.matrixWorld);let C=e.update(M),W=M.material;if(Array.isArray(W)){let Z=C.groups;for(let z=0,ee=Z.length;z<ee;z++){let q=Z[z],J=W[q.materialIndex];if(J&&J.visible){let O=T(M,J,L,D);M.onBeforeShadow(i,M,g,v,C,O,q),i.renderBufferDirect(v,null,C,O,M,q),M.onAfterShadow(i,M,g,v,C,O,q)}}}else if(W.visible){let Z=T(M,W,L,D);M.onBeforeShadow(i,M,g,v,C,Z,null),i.renderBufferDirect(v,null,C,Z,M,null),M.onAfterShadow(i,M,g,v,C,Z,null)}}let B=M.children;for(let C=0,W=B.length;C<W;C++)S(B[C],g,v,L,R,D)}function E(M){M.target.removeEventListener("dispose",E);for(let v in l){let L=l[v],R=M.target.uuid;R in L&&(L[R].dispose(),delete L[R])}}}function C0(i,e){function t(){let I=!1,te=new _t,P=null,ne=new _t(0,0,0,0);return{setMask:function($){P!==$&&!I&&(i.colorMask($,$,$,$),P=$)},setLocked:function($){I=$},setClear:function($,ie,oe,re,K){K===!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(){I=!1,P=null,ne.set(-1,0,0,0)}}}function n(){let I=!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?fe(i.DEPTH_TEST):Te(i.DEPTH_TEST)},setMask:function(ie){P!==ie&&!I&&(i.depthMask(ie),P=ie)},setFunc:function(ie){if(te&&(ie=Ph[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){I=ie},setClear:function(ie){$!==ie&&($=ie,te&&(ie=1-ie),i.clearDepth(ie))},reset:function(){I=!1,P=null,ne=null,$=null,te=!1}}}function s(){let I=!1,te=null,P=null,ne=null,$=null,ie=null,oe=null,re=null,K=null;return{setTest:function(pe){I||(pe?fe(i.STENCIL_TEST):Te(i.STENCIL_TEST))},setMask:function(pe){te!==pe&&!I&&(i.stencilMask(pe),te=pe)},setFunc:function(pe,Le,ce){(P!==pe||ne!==Le||$!==ce)&&(i.stencilFunc(pe,Le,ce),P=pe,ne=Le,$=ce)},setOp:function(pe,Le,ce){(ie!==pe||oe!==Le||re!==ce)&&(i.stencilOp(pe,Le,ce),ie=pe,oe=Le,re=ce)},setLocked:function(pe){I=pe},setClear:function(pe){K!==pe&&(i.clearStencil(pe),K=pe)},reset:function(){I=!1,te=null,P=null,ne=null,$=null,ie=null,oe=null,re=null,K=null}}}let r=new t,o=new n,a=new s,c={},l=new WeakMap,h={},u={},d={},f=new WeakMap,_=[],x=null,m=!1,p=null,w=null,T=null,S=null,E=null,M=null,g=null,v=new Ye(0,0,0),L=0,R=!1,D=null,N=null,B=null,C=null,W=null,Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),z=!1,ee=0,q=i.getParameter(i.VERSION);q.indexOf("WebGL")!==-1?(ee=parseFloat(/^WebGL (\d)/.exec(q)[1]),z=ee>=1):q.indexOf("OpenGL ES")!==-1&&(ee=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),z=ee>=2);let J=null,O={},ae=i.getParameter(i.SCISSOR_BOX),xe=i.getParameter(i.VIEWPORT),H=new _t().fromArray(ae),ue=new _t().fromArray(xe);function de(I,te,P,ne){let $=new Uint8Array(4),ie=i.createTexture();i.bindTexture(I,ie),i.texParameteri(I,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(I,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let oe=0;oe<P;oe++)I===i.TEXTURE_3D||I===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 we={};we[i.TEXTURE_2D]=de(i.TEXTURE_2D,i.TEXTURE_2D,1),we[i.TEXTURE_CUBE_MAP]=de(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),we[i.TEXTURE_2D_ARRAY]=de(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),we[i.TEXTURE_3D]=de(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),fe(i.DEPTH_TEST),o.setFunc(ji),vt(!1),nt(il),fe(i.CULL_FACE),Ce(Ii);function fe(I){h[I]!==!0&&(i.enable(I),h[I]=!0)}function Te(I){h[I]!==!1&&(i.disable(I),h[I]=!1)}function He(I,te){return d[I]!==te?(i.bindFramebuffer(I,te),d[I]=te,I===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=te),I===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=te),!0):!1}function me(I,te){let P=_,ne=!1;if(I){P=f.get(te),P===void 0&&(P=[],f.set(te,P));let $=I.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 Ie(I){return x!==I?(i.useProgram(I),x=I,!0):!1}let Ne={[Li]:i.FUNC_ADD,[jc]:i.FUNC_SUBTRACT,[Qc]:i.FUNC_REVERSE_SUBTRACT};Ne[eh]=i.MIN,Ne[th]=i.MAX;let Oe={[nh]:i.ZERO,[ih]:i.ONE,[sh]:i.SRC_COLOR,[al]:i.SRC_ALPHA,[hh]:i.SRC_ALPHA_SATURATE,[lh]:i.DST_COLOR,[oh]:i.DST_ALPHA,[rh]:i.ONE_MINUS_SRC_COLOR,[ll]:i.ONE_MINUS_SRC_ALPHA,[ch]:i.ONE_MINUS_DST_COLOR,[ah]:i.ONE_MINUS_DST_ALPHA,[uh]:i.CONSTANT_COLOR,[dh]:i.ONE_MINUS_CONSTANT_COLOR,[fh]:i.CONSTANT_ALPHA,[ph]:i.ONE_MINUS_CONSTANT_ALPHA};function Ce(I,te,P,ne,$,ie,oe,re,K,pe){if(I===Ii){m===!0&&(Te(i.BLEND),m=!1);return}if(m===!1&&(fe(i.BLEND),m=!0),I!==Kc){if(I!==p||pe!==R){if((w!==Li||E!==Li)&&(i.blendEquation(i.FUNC_ADD),w=Li,E=Li),pe)switch(I){case ds:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case sl:i.blendFunc(i.ONE,i.ONE);break;case rl:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case ol:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:ke("WebGLState: Invalid blending: ",I);break}else switch(I){case ds:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case sl:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case rl:ke("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case ol:ke("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:ke("WebGLState: Invalid blending: ",I);break}T=null,S=null,M=null,g=null,v.set(0,0,0),L=0,p=I,R=pe}return}$=$||te,ie=ie||P,oe=oe||ne,(te!==w||$!==E)&&(i.blendEquationSeparate(Ne[te],Ne[$]),w=te,E=$),(P!==T||ne!==S||ie!==M||oe!==g)&&(i.blendFuncSeparate(Oe[P],Oe[ne],Oe[ie],Oe[oe]),T=P,S=ne,M=ie,g=oe),(re.equals(v)===!1||K!==L)&&(i.blendColor(re.r,re.g,re.b,K),v.copy(re),L=K),p=I,R=!1}function We(I,te){I.side===_n?Te(i.CULL_FACE):fe(i.CULL_FACE);let P=I.side===Jt;te&&(P=!P),vt(P),I.blending===ds&&I.transparent===!1?Ce(Ii):Ce(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),o.setFunc(I.depthFunc),o.setTest(I.depthTest),o.setMask(I.depthWrite),r.setMask(I.colorWrite);let ne=I.stencilWrite;a.setTest(ne),ne&&(a.setMask(I.stencilWriteMask),a.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),a.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),Xe(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?fe(i.SAMPLE_ALPHA_TO_COVERAGE):Te(i.SAMPLE_ALPHA_TO_COVERAGE)}function vt(I){D!==I&&(I?i.frontFace(i.CW):i.frontFace(i.CCW),D=I)}function nt(I){I!==Zc?(fe(i.CULL_FACE),I!==N&&(I===il?i.cullFace(i.BACK):I===$c?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Te(i.CULL_FACE),N=I}function gt(I){I!==B&&(z&&i.lineWidth(I),B=I)}function Xe(I,te,P){I?(fe(i.POLYGON_OFFSET_FILL),(C!==te||W!==P)&&(C=te,W=P,o.getReversed()&&(te=-te,P=-P),i.polygonOffset(te,P))):Te(i.POLYGON_OFFSET_FILL)}function ft(I){I?fe(i.SCISSOR_TEST):Te(i.SCISSOR_TEST)}function It(I){I===void 0&&(I=i.TEXTURE0+Z-1),J!==I&&(i.activeTexture(I),J=I)}function Ft(I,te,P){P===void 0&&(J===null?P=i.TEXTURE0+Z-1:P=J);let ne=O[P];ne===void 0&&(ne={type:void 0,texture:void 0},O[P]=ne),(ne.type!==I||ne.texture!==te)&&(J!==P&&(i.activeTexture(P),J=P),i.bindTexture(I,te||we[I]),ne.type=I,ne.texture=te)}function F(){let I=O[J];I!==void 0&&I.type!==void 0&&(i.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function Lt(){try{i.compressedTexImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function st(){try{i.compressedTexImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function rt(){try{i.texSubImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function _e(){try{i.texSubImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function ht(){try{i.compressedTexSubImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function De(){try{i.compressedTexSubImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function Be(){try{i.texStorage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function A(){try{i.texStorage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function y(){try{i.texImage2D(...arguments)}catch(I){ke("WebGLState:",I)}}function V(){try{i.texImage3D(...arguments)}catch(I){ke("WebGLState:",I)}}function le(I){return u[I]!==void 0?u[I]:i.getParameter(I)}function se(I,te){u[I]!==te&&(i.pixelStorei(I,te),u[I]=te)}function he(I){H.equals(I)===!1&&(i.scissor(I.x,I.y,I.z,I.w),H.copy(I))}function ye(I){ue.equals(I)===!1&&(i.viewport(I.x,I.y,I.z,I.w),ue.copy(I))}function j(I,te){let P=l.get(te);P===void 0&&(P=new WeakMap,l.set(te,P));let ne=P.get(I);ne===void 0&&(ne=i.getUniformBlockIndex(te,I.name),i.uniformBlockBinding(te,ne,ne),P.set(I,ne))}function Q(I,te,P){let $=l.get(te).get(I);c[$]!==P&&(i.bindBufferBase(i.UNIFORM_BUFFER,$,P),c[$]=P)}function ge(){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={},u={},J=null,O={},d={},c={},f=new WeakMap,_=[],x=null,m=!1,p=null,w=null,T=null,S=null,E=null,M=null,g=null,v=new Ye(0,0,0),L=0,R=!1,D=null,N=null,B=null,C=null,W=null,H.set(0,0,i.canvas.width,i.canvas.height),ue.set(0,0,i.canvas.width,i.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:fe,disable:Te,bindFramebuffer:He,drawBuffers:me,useProgram:Ie,setBlending:Ce,setMaterial:We,setFlipSided:vt,setCullFace:nt,setLineWidth:gt,setPolygonOffset:Xe,setScissorTest:ft,activeTexture:It,bindTexture:Ft,unbindTexture:F,compressedTexImage2D:Lt,compressedTexImage3D:st,texImage2D:y,texImage3D:V,pixelStorei:se,getParameter:le,updateUBOMapping:j,uniformBlockBinding:Q,texStorage2D:Be,texStorage3D:A,texSubImage2D:rt,texSubImage3D:_e,compressedTexSubImage2D:ht,compressedTexSubImage3D:De,scissor:he,viewport:ye,reset:ge}}function P0(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 Ve,h=new WeakMap,u=new Set,d,f=new WeakMap,_=new Set,x=new FinalizationRegistry(A=>_.delete(A)),m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(A,y){return m?new OffscreenCanvas(A,y):Ls("canvas")}function w(A,y,V){let le=1,se=Be(A);if((se.width>V||se.height>V)&&(le=V/Math.max(se.width,se.height)),le<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){let he=Math.floor(le*se.width),ye=Math.floor(le*se.height);d===void 0&&(d=p(he,ye));let j=y?p(he,ye):d;return j.width=he,j.height=ye,j.getContext("2d").drawImage(A,0,0,he,ye),Fe("WebGLRenderer: Texture has been resized from ("+se.width+"x"+se.height+") to ("+he+"x"+ye+")."),j}else return"data"in A&&Fe("WebGLRenderer: Image in DataTexture is too big ("+se.width+"x"+se.height+")."),A;return A}function T(A){return A.generateMipmaps}function S(A){i.generateMipmap(A)}function E(A){return A.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?i.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(A,y,V,le,se,he=!1){if(A!==null){if(i[A]!==void 0)return i[A];Fe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let ye;le&&(ye=e.get("EXT_texture_norm16"),ye||Fe("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&&ye&&(j=ye.R16_EXT),V===i.SHORT&&ye&&(j=ye.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&&ye&&(j=ye.RG16_EXT),V===i.SHORT&&ye&&(j=ye.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&&ye&&(j=ye.RGB16_EXT),V===i.SHORT&&ye&&(j=ye.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=he?Is:et.getTransfer(se);V===i.FLOAT&&(j=i.RGBA32F),V===i.HALF_FLOAT&&(j=i.RGBA16F),V===i.UNSIGNED_BYTE&&(j=Q===ct?i.SRGB8_ALPHA8:i.RGBA8),V===i.UNSIGNED_SHORT&&ye&&(j=ye.RGBA16_EXT),V===i.SHORT&&ye&&(j=ye.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(A,y){let V;return A?y===null||y===wn||y===Ni?V=i.DEPTH24_STENCIL8:y===En?V=i.DEPTH32F_STENCIL8:y===ps&&(V=i.DEPTH24_STENCIL8,Fe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===wn||y===Ni?V=i.DEPTH_COMPONENT24:y===En?V=i.DEPTH_COMPONENT32F:y===ps&&(V=i.DEPTH_COMPONENT16),V}function v(A,y){return T(A)===!0||A.isFramebufferTexture&&A.minFilter!==Pt&&A.minFilter!==Zt?Math.log2(Math.max(y.width,y.height))+1:A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?y.mipmaps.length:1}function L(A){let y=new WeakRef(A);n.get(A).__ref=y,_.add(y),x.register(A,y,y)}function R(A){let y=n.get(A).__ref;y!==void 0&&(_.delete(y),x.unregister(y))}function D(A){B(A.target)}function N(A){C(A.target)}function B(A){A.removeEventListener("dispose",D),R(A),Z(A),A.isVideoTexture&&h.delete(A),A.isHTMLTexture&&u.delete(A)}function C(A){A.removeEventListener("dispose",N),R(A),ee(A)}function W(){for(let A of _){let y=A.deref();y!==void 0&&(y.isRenderTarget===!0?C(y):B(y))}_.clear(),u.clear()}function Z(A){let y=n.get(A);if(y.__webglInit===void 0)return;let V=A.source,le=f.get(V);if(le){let se=le[y.__cacheKey];se.usedTimes--,se.usedTimes===0&&z(A),Object.keys(le).length===0&&f.delete(V)}n.remove(A)}function z(A){let y=n.get(A);i.deleteTexture(y.__webglTexture);let V=A.source,le=f.get(V);delete le[y.__cacheKey],o.memory.textures--}function ee(A){let y=n.get(A);y.__depthDisposeCallback&&y.__depthDisposeCallback();let V=A.depthTexture;if(V&&V.renderTarget===A&&B(V),A.isWebGLCubeRenderTarget)for(let se=0;se<6;se++){if(Array.isArray(y.__webglFramebuffer[se]))for(let he=0;he<y.__webglFramebuffer[se].length;he++)i.deleteFramebuffer(y.__webglFramebuffer[se][he]);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 le=A.textures;for(let se=0,he=le.length;se<he;se++){let ye=n.get(le[se]);ye.__webglTexture&&(i.deleteTexture(ye.__webglTexture),o.memory.textures--),n.remove(le[se])}n.remove(A)}let q=0;function J(){q=0}function O(){return q}function ae(A){q=A}function xe(){let A=q;return A>=s.maxTextures&&Fe("WebGLTextures: Trying to use "+(A+1)+" texture units while this GPU supports only "+s.maxTextures),q+=1,A}function H(A){let y=[];return y.push(A.wrapS),y.push(A.wrapT),y.push(A.wrapR||0),y.push(A.magFilter),y.push(A.minFilter),y.push(A.anisotropy),y.push(A.internalFormat),y.push(A.format),y.push(A.type),y.push(A.generateMipmaps),y.push(A.mipmapsAutoUpdate),y.push(A.premultiplyAlpha),y.push(A.flipY),y.push(A.unpackAlignment),y.push(A.colorSpace),y.join()}function ue(A,y){let V=n.get(A);if(A.isVideoTexture&&ht(A),A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&V.__version!==A.version){let le=A.image;if(le===null)Fe("WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)Fe("WebGLRenderer: Texture marked for update but image is incomplete");else{We(V,A,y);return}}else A.isExternalTexture&&(V.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,V.__webglTexture,i.TEXTURE0+y)}function de(A,y){let V=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&V.__version!==A.version){We(V,A,y);return}else A.isExternalTexture&&(V.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,V.__webglTexture,i.TEXTURE0+y)}function we(A,y){let V=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&V.__version!==A.version){We(V,A,y);return}t.bindTexture(i.TEXTURE_3D,V.__webglTexture,i.TEXTURE0+y)}function fe(A,y){let V=n.get(A);if(A.version>0&&V.__version!==A.version){vt(V,A,y);return}t.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture,i.TEXTURE0+y)}let Te={[Jr]:i.REPEAT,[Cn]:i.CLAMP_TO_EDGE,[Kr]:i.MIRRORED_REPEAT},He={[Pt]:i.NEAREST,[_h]:i.NEAREST_MIPMAP_NEAREST,[Js]:i.NEAREST_MIPMAP_LINEAR,[Zt]:i.LINEAR,[Ao]:i.LINEAR_MIPMAP_NEAREST,[Kn]:i.LINEAR_MIPMAP_LINEAR},me={[bh]:i.NEVER,[El]:i.ALWAYS,[Mh]:i.LESS,[Sl]:i.LEQUAL,[Sh]:i.EQUAL,[wl]:i.GEQUAL,[wh]:i.GREATER,[Eh]:i.NOTEQUAL};function Ie(A,y){if(y.type===En&&e.has("OES_texture_float_linear")===!1&&(y.magFilter===Zt||y.magFilter===Ao||y.magFilter===Js||y.magFilter===Kn||y.minFilter===Zt||y.minFilter===Ao||y.minFilter===Js||y.minFilter===Kn)&&Fe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(A,i.TEXTURE_WRAP_S,Te[y.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,Te[y.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,Te[y.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,He[y.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,He[y.minFilter]),y.compareFunction&&(i.texParameteri(A,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(A,i.TEXTURE_COMPARE_FUNC,me[y.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===Pt||y.minFilter!==Js&&y.minFilter!==Kn||y.type===En&&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(A,V.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,s.getMaxAnisotropy())),n.get(y).__currentAnisotropy=y.anisotropy}}}function Ne(A,y){let V=!1;A.__webglInit===void 0&&(A.__webglInit=!0,y.addEventListener("dispose",D),L(y));let le=y.source,se=f.get(le);se===void 0&&(se={},f.set(le,se));let he=H(y);if(he!==A.__cacheKey){se[he]===void 0&&(se[he]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,V=!0),se[he].usedTimes++;let ye=se[A.__cacheKey];ye!==void 0&&(se[A.__cacheKey].usedTimes--,ye.usedTimes===0&&z(y)),A.__cacheKey=he,A.__webglTexture=se[he].texture}return V}function Oe(A,y,V){return Math.floor(Math.floor(A/V)/y)}function Ce(A,y,V,le){let he=A.updateRanges;if(he.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,y.width,y.height,V,le,y.data);else{he.sort((I,te)=>I.start-te.start);let ye=0;for(let I=1;I<he.length;I++){let te=he[ye],P=he[I],ne=te.start+te.count,$=Oe(P.start,y.width,4),ie=Oe(te.start,y.width,4);P.start<=ne+1&&$===ie&&Oe(P.start+P.count-1,y.width,4)===$?te.count=Math.max(te.count,P.start+P.count-te.start):(++ye,he[ye]=P)}he.length=ye+1;let j=t.getParameter(i.UNPACK_ROW_LENGTH),Q=t.getParameter(i.UNPACK_SKIP_PIXELS),ge=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,y.width);for(let I=0,te=he.length;I<te;I++){let P=he[I],ne=Math.floor(P.start/4),$=Math.ceil(P.count/4),ie=ne%y.width,oe=Math.floor(ne/y.width),re=$,K=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,ie),t.pixelStorei(i.UNPACK_SKIP_ROWS,oe),t.texSubImage2D(i.TEXTURE_2D,0,ie,oe,re,K,V,le,y.data)}A.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,j),t.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),t.pixelStorei(i.UNPACK_SKIP_ROWS,ge)}}function We(A,y,V){let le=i.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(le=i.TEXTURE_2D_ARRAY),y.isData3DTexture&&(le=i.TEXTURE_3D);let se=Ne(A,y),he=y.source;t.bindTexture(le,A.__webglTexture,i.TEXTURE0+V);let ye=n.get(he);if(he.version!==ye.__version||se===!0){if(t.activeTexture(i.TEXTURE0+V),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){let K=et.getPrimaries(et.workingColorSpace),pe=y.colorSpace===Qn?null:et.getPrimaries(y.colorSpace),Le=y.colorSpace===Qn||K===pe?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,Le)}t.pixelStorei(i.UNPACK_ALIGNMENT,y.unpackAlignment);let Q=w(y.image,!1,s.maxTextureSize);Q=De(y,Q);let ge=r.convert(y.format,y.colorSpace),I=r.convert(y.type),te=M(y.internalFormat,ge,I,y.normalized,y.colorSpace,y.isVideoTexture);Ie(le,y);let P,ne=y.mipmaps,$=y.isVideoTexture!==!0,ie=ye.__version===void 0||se===!0,oe=he.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,ge,I,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 K=0,pe=ne.length;K<pe;K++)P=ne[K],$?oe&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,P.width,P.height,ge,I,P.data):t.texImage2D(i.TEXTURE_2D,K,te,P.width,P.height,0,ge,I,P.data);y.generateMipmaps=!1}else $?(ie&&t.texStorage2D(i.TEXTURE_2D,re,te,Q.width,Q.height),oe&&Ce(y,Q,ge,I)):t.texImage2D(i.TEXTURE_2D,0,te,Q.width,Q.height,0,ge,I,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 K=0,pe=ne.length;K<pe;K++)if(P=ne[K],y.format!==An)if(ge!==null)if($){if(oe)if(y.layerUpdates.size>0){let Le=Ul(P.width,P.height,y.format,y.type);for(let ce of y.layerUpdates){let Ue=P.data.subarray(ce*Le/P.data.BYTES_PER_ELEMENT,(ce+1)*Le/P.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,ce,P.width,P.height,1,ge,Ue)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,P.width,P.height,Q.depth,ge,P.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,K,te,P.width,P.height,Q.depth,0,P.data,0,0);else Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else $?oe&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,P.width,P.height,Q.depth,ge,I,P.data):t.texImage3D(i.TEXTURE_2D_ARRAY,K,te,P.width,P.height,Q.depth,0,ge,I,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 K=0,pe=ne.length;K<pe;K++)P=ne[K],y.format!==An?ge!==null?$?oe&&t.compressedTexSubImage2D(i.TEXTURE_2D,K,0,0,P.width,P.height,ge,P.data):t.compressedTexImage2D(i.TEXTURE_2D,K,te,P.width,P.height,0,P.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):$?oe&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,P.width,P.height,ge,I,P.data):t.texImage2D(i.TEXTURE_2D,K,te,P.width,P.height,0,ge,I,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 K=Ul(Q.width,Q.height,y.format,y.type);for(let pe of y.layerUpdates){let Le=Q.data.subarray(pe*K/Q.data.BYTES_PER_ELEMENT,(pe+1)*K/Q.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,pe,Q.width,Q.height,1,ge,I,Le)}y.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ge,I,Q.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,te,Q.width,Q.height,Q.depth,0,ge,I,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,ge,I,Q.data)):t.texImage3D(i.TEXTURE_3D,0,te,Q.width,Q.height,Q.depth,0,ge,I,Q.data);else if(y.isFramebufferTexture){if(ie)if($)t.texStorage2D(i.TEXTURE_2D,re,te,Q.width,Q.height);else{let K=Q.width,pe=Q.height;for(let Le=0;Le<re;Le++)t.texImage2D(i.TEXTURE_2D,Le,te,K,pe,0,ge,I,null),K>>=1,pe>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in i){let K=i.canvas;if(K.hasAttribute("layoutsubtree")||K.setAttribute("layoutsubtree","true"),Q.parentNode!==K){K.appendChild(Q),u.add(y),K.onpaint=pe=>{let Le=pe.changedElements;for(let ce of u)Le.includes(ce.image)&&(ce.needsUpdate=!0)},K.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{let Le=i.RGBA,ce=i.RGBA,Ue=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,Le,ce,Ue,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 K=Be(ne[0]);t.texStorage2D(i.TEXTURE_2D,re,te,K.width,K.height)}for(let K=0,pe=ne.length;K<pe;K++)P=ne[K],$?oe&&t.texSubImage2D(i.TEXTURE_2D,K,0,0,ge,I,P):t.texImage2D(i.TEXTURE_2D,K,te,ge,I,P);y.generateMipmaps=!1}else if($){if(ie){let K=Be(Q);t.texStorage2D(i.TEXTURE_2D,re,te,K.width,K.height)}oe&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ge,I,Q)}else t.texImage2D(i.TEXTURE_2D,0,te,ge,I,Q);T(y)&&y.mipmapsAutoUpdate===!0&&S(le),ye.__version=he.version,y.onUpdate&&y.onUpdate(y)}A.__version=y.version}function vt(A,y,V){if(y.image.length!==6)return;let le=Ne(A,y),se=y.source;t.bindTexture(i.TEXTURE_CUBE_MAP,A.__webglTexture,i.TEXTURE0+V);let he=n.get(se);if(se.version!==he.__version||le===!0){t.activeTexture(i.TEXTURE0+V);let ye=et.getPrimaries(et.workingColorSpace),j=y.colorSpace===Qn?null:et.getPrimaries(y.colorSpace),Q=y.colorSpace===Qn||ye===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 ge=y.isCompressedTexture||y.image[0].isCompressedTexture,I=y.image[0]&&y.image[0].isDataTexture,te=[];for(let ce=0;ce<6;ce++)!ge&&!I?te[ce]=w(y.image[ce],!0,s.maxCubemapSize):te[ce]=I?y.image[ce].image:y.image[ce],te[ce]=De(y,te[ce]);let P=te[0],ne=r.convert(y.format,y.colorSpace),$=r.convert(y.type),ie=M(y.internalFormat,ne,$,y.normalized,y.colorSpace),oe=y.isVideoTexture!==!0,re=he.__version===void 0||le===!0,K=se.dataReady,pe=v(y,P);Ie(i.TEXTURE_CUBE_MAP,y);let Le;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(ge){oe&&re&&t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,ie,P.width,P.height);for(let ce=0;ce<6;ce++){Le=te[ce].mipmaps;for(let Ue=0;Ue<Le.length;Ue++){let tt=Le[Ue];y.format!==An?ne!==null?oe?K&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,0,0,tt.width,tt.height,ne,tt.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,ie,tt.width,tt.height,0,tt.data):Fe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,0,0,tt.width,tt.height,ne,$,tt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue,ie,tt.width,tt.height,0,ne,$,tt.data)}}}else{if(Le=y.mipmaps,oe&&re){Le.length>0&&pe++;let ce=Be(te[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,pe,ie,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(I){oe?K&&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 Ue=0;Ue<Le.length;Ue++){let xt=Le[Ue].image[ce].image;oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,0,0,xt.width,xt.height,ne,$,xt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,ie,xt.width,xt.height,0,ne,$,xt.data)}}else{oe?K&&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 Ue=0;Ue<Le.length;Ue++){let tt=Le[Ue];oe?K&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,0,0,ne,$,tt.image[ce]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,Ue+1,ie,ne,$,tt.image[ce])}}}T(y)&&y.mipmapsAutoUpdate===!0&&S(i.TEXTURE_CUBE_MAP),he.__version=se.version,y.onUpdate&&y.onUpdate(y)}A.__version=y.version}function nt(A,y,V,le,se,he){let ye=r.convert(V.format,V.colorSpace),j=r.convert(V.type),Q=M(V.internalFormat,ye,j,V.normalized,V.colorSpace),ge=n.get(y),I=n.get(V);if(I.__renderTarget=y,!ge.__hasExternalTextures){let te=Math.max(1,y.width>>he),P=Math.max(1,y.height>>he);se===i.TEXTURE_3D||se===i.TEXTURE_2D_ARRAY?t.texImage3D(se,he,Q,te,P,y.depth,0,ye,j,null):t.texImage2D(se,he,Q,te,P,0,ye,j,null)}t.bindFramebuffer(i.FRAMEBUFFER,A),_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,le,se,I.__webglTexture,0,rt(y)):(se===i.TEXTURE_2D||se>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&se<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,le,se,I.__webglTexture,he),t.bindFramebuffer(i.FRAMEBUFFER,null)}function gt(A,y,V){if(i.bindRenderbuffer(i.RENDERBUFFER,A),y.depthBuffer){let le=y.depthTexture,se=le&&le.isDepthTexture?le.type:null,he=g(y.stencilBuffer,se),ye=y.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;_e(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,rt(y),he,y.width,y.height):V?i.renderbufferStorageMultisample(i.RENDERBUFFER,rt(y),he,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,he,y.width,y.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ye,i.RENDERBUFFER,A)}else{let le=y.textures;for(let se=0;se<le.length;se++){let he=le[se],ye=r.convert(he.format,he.colorSpace),j=r.convert(he.type),Q=M(he.internalFormat,ye,j,he.normalized,he.colorSpace);_e(y)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,rt(y),Q,y.width,y.height):V?i.renderbufferStorageMultisample(i.RENDERBUFFER,rt(y),Q,y.width,y.height):i.renderbufferStorage(i.RENDERBUFFER,Q,y.width,y.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Xe(A,y,V){let le=y.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,A),!(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 he=le?y.depthTexture.image[0]:y.depthTexture.image;(!se.__webglTexture||he.width!==y.width||he.height!==y.height)&&(he.width=y.width,he.height=y.height,y.depthTexture.needsUpdate=!0),le?fe(y.depthTexture,0):ue(y.depthTexture,0);let ye=se.__webglTexture,j=rt(y),Q=le?i.TEXTURE_CUBE_MAP_POSITIVE_X+V:i.TEXTURE_2D,ge=y.depthTexture.format===jn?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(y.depthTexture.format===Yn)_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ge,Q,ye,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,ge,Q,ye,0);else if(y.depthTexture.format===jn)_e(y)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,ge,Q,ye,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,ge,Q,ye,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function ft(A){let y=n.get(A),V=A.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==A.depthTexture){let le=A.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),le){let se=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,le.removeEventListener("dispose",se)};le.addEventListener("dispose",se),y.__depthDisposeCallback=se}y.__boundDepthTexture=le}if(A.depthTexture&&!y.__autoAllocateDepthBuffer)if(V)for(let le=0;le<6;le++)Xe(y.__webglFramebuffer[le],A,le);else A.texture.mipmaps.length>0?Xe(y.__webglFramebuffer[0],A,0):Xe(y.__webglFramebuffer,A,0);else if(V){y.__webglDepthbuffer=[];for(let le=0;le<6;le++)if(t.bindFramebuffer(i.FRAMEBUFFER,y.__webglFramebuffer[le]),y.__webglDepthbuffer[le]===void 0)y.__webglDepthbuffer[le]=i.createRenderbuffer(),gt(y.__webglDepthbuffer[le],A,!1);else{let se=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=y.__webglDepthbuffer[le];i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,he)}}else if(A.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(),gt(y.__webglDepthbuffer,A,!1);else{let se=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=y.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,se,i.RENDERBUFFER,he)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function It(A,y,V){let le=n.get(A);y!==void 0&&nt(le.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),V!==void 0&&ft(A)}function Ft(A){let y=A.texture,V=n.get(A),le=n.get(y);A.addEventListener("dispose",N),L(A);let se=A.textures,he=A.isWebGLCubeRenderTarget===!0,ye=se.length>1;if(ye||(le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture()),le.__version=y.version,o.memory.textures++),he){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(ye)for(let j=0,Q=se.length;j<Q;j++){let ge=n.get(se[j]);ge.__webglTexture===void 0&&(ge.__webglTexture=i.createTexture(),o.memory.textures++)}if(A.samples>0&&_e(A)===!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 ge=r.convert(Q.format,Q.colorSpace),I=r.convert(Q.type),te=M(Q.internalFormat,ge,I,Q.normalized,Q.colorSpace,A.isXRRenderTarget===!0),P=rt(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,P,te,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+j,i.RENDERBUFFER,V.__webglColorRenderbuffer[j])}i.bindRenderbuffer(i.RENDERBUFFER,null),A.depthBuffer&&(V.__webglDepthRenderbuffer=i.createRenderbuffer(),gt(V.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(he){t.bindTexture(i.TEXTURE_CUBE_MAP,le.__webglTexture),Ie(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++)nt(V.__webglFramebuffer[j][Q],A,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+j,Q);else nt(V.__webglFramebuffer[j],A,y,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0);T(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(ye){for(let j=0,Q=se.length;j<Q;j++){let ge=se[j],I=n.get(ge),te=i.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(te=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(te,I.__webglTexture),Ie(te,ge),nt(V.__webglFramebuffer,A,ge,i.COLOR_ATTACHMENT0+j,te,0),T(ge)&&S(te)}t.unbindTexture()}else{let j=i.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(j=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(j,le.__webglTexture),Ie(j,y),y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)nt(V.__webglFramebuffer[Q],A,y,i.COLOR_ATTACHMENT0,j,Q);else nt(V.__webglFramebuffer,A,y,i.COLOR_ATTACHMENT0,j,0);T(y)?S(j):y.mipmaps.length>0&&i.texParameteri(j,i.TEXTURE_MAX_LEVEL,y.mipmaps.length-1),t.unbindTexture()}A.depthBuffer&&ft(A)}function F(A){let y=A.textures;for(let V=0,le=y.length;V<le;V++){let se=y[V];if(T(se)&&se.mipmapsAutoUpdate===!0){let he=E(A),ye=n.get(se).__webglTexture;t.bindTexture(he,ye),S(he),t.unbindTexture()}}}let Lt=[];function st(A){if(A.samples>0){if(_e(A)===!1){let y=A.textures,V=A.width,le=A.height,se=i.COLOR_BUFFER_BIT,he=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ye=n.get(A),j=y.length>1;if(j)for(let ge=0;ge<y.length;ge++)t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ye.__webglMultisampledFramebuffer),A.texture.mipmaps.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ye.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ye.__webglFramebuffer);for(let ge=0;ge<y.length;ge++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(se|=i.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(se|=i.STENCIL_BUFFER_BIT)),j){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ye.__webglColorRenderbuffer[ge]);let I=n.get(y[ge]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,I,0)}i.blitFramebuffer(0,0,V,le,0,0,V,le,se,i.NEAREST),c===!0&&(Lt.length=0,Lt.push(i.COLOR_ATTACHMENT0+ge),A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&Lt.push(he),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Lt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),j)for(let ge=0;ge<y.length;ge++){t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.RENDERBUFFER,ye.__webglColorRenderbuffer[ge]);let I=n.get(y[ge]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ye.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ge,i.TEXTURE_2D,I,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ye.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.storeMultisampledDepthBuffer===!1&&c){let y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[y])}}}function rt(A){return Math.min(s.maxSamples,A.samples)}function _e(A){let y=n.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function ht(A){let y=o.render.frame;h.get(A)!==y&&(h.set(A,y),A.update())}function De(A,y){let V=A.colorSpace,le=A.format,se=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||V!==Ps&&V!==Qn&&(et.getTransfer(V)===ct?(le!==An||se!==en)&&Fe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):ke("WebGLTextures: Unsupported texture color space:",V)),y}function Be(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(l.width=A.naturalWidth||A.width,l.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(l.width=A.displayWidth,l.height=A.displayHeight):(l.width=A.width,l.height=A.height),l}this.allocateTextureUnit=xe,this.resetTextureUnits=J,this.getTextureUnits=O,this.setTextureUnits=ae,this.setTexture2D=ue,this.setTexture2DArray=de,this.setTexture3D=we,this.setTextureCube=fe,this.rebindTextures=It,this.setupRenderTarget=Ft,this.updateRenderTargetMipmap=F,this.updateMultisampleRenderTarget=st,this.setupDepthRenderbuffer=ft,this.setupFrameBufferTexture=nt,this.useMultisampledRTT=_e,this.dispose=W}function I0(i,e){function t(n,s=Qn){let r,o=et.getTransfer(s);if(n===en)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===xl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===yl)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===gl)return i.BYTE;if(n===_l)return i.SHORT;if(n===ps)return i.UNSIGNED_SHORT;if(n===Ro)return i.INT;if(n===wn)return i.UNSIGNED_INT;if(n===En)return i.FLOAT;if(n===Tn)return i.HALF_FLOAT;if(n===vl)return i.ALPHA;if(n===bl)return i.RGB;if(n===An)return i.RGBA;if(n===Yn)return i.DEPTH_COMPONENT;if(n===jn)return i.DEPTH_STENCIL;if(n===Ml)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===Ks||n===js||n===Qs||n===er)if(o===ct)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ks)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Qs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===er)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ks)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Qs)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===er)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===tr||n===Ho)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Bo||n===zo)return o===ct?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===ko)return o===ct?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===tr)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===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Xo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===qo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Yo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Zo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===$o)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Jo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ko)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===jo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Qo)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ea)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ta)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===na)return o===ct?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ia)return o===ct?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===ct?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===nr||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===nr)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 L0=`
4202
4202
  void main() {
4203
4203
 
4204
4204
  gl_Position = vec4( position, 1.0 );
4205
4205
 
4206
- }`,P0=`
4206
+ }`,D0=`
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
- }`,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_();})();
4225
+ }`,$l=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ks(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 In({vertexShader:L0,fragmentShader:D0,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Qt(new Gs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Jl=class extends Sn{constructor(e,t){super();let n=this,s=null,r=1,o=null,a="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,_=null,x=typeof XRWebGLBinding<"u",m=new $l,p={},w=t.getContextAttributes(),T=null,S=null,E=[],M=[],g=new Ve,v=null,L=null,R=new qt;R.viewport=new _t;let D=new qt;D.viewport=new _t;let N=[R,D],B=new Mo,C=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(H){let ue=E[H];return ue===void 0&&(ue=new is,E[H]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(H){let ue=E[H];return ue===void 0&&(ue=new is,E[H]=ue),ue.getGripSpace()},this.getHand=function(H){let ue=E[H];return ue===void 0&&(ue=new is,E[H]=ue),ue.getHandSpace()};function Z(H){let ue=M.indexOf(H.inputSource);if(ue===-1)return;let de=E[ue];de!==void 0&&(de.update(H.inputSource,H.frame,l||o),de.dispatchEvent({type:H.type,data:H.inputSource}))}function z(){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",z),s.removeEventListener("inputsourceschange",ee);for(let H=0;H<E.length;H++){let ue=M[H];ue!==null&&(M[H]=null,E[H].disconnect(ue))}C=null,W=null,m.reset();for(let H in p)delete p[H];if(e.setRenderTarget(T),f=null,d=null,u=null,s=null,S=null,xe.stop(),n.isPresenting=!1,e.setPixelRatio(v),e.setSize(g.width,g.height,!1),L!==null){let H=L.camera;H.fov=L.fov,H.zoom=L.zoom,H.updateProjectionMatrix(),L=null}n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(H){r=H,n.isPresenting===!0&&Fe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(H){a=H,n.isPresenting===!0&&Fe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(H){l=H},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(s,t)),u},this.getFrame=function(){return _},this.getSession=function(){return s},this.setSession=async function(H){if(s=H,s!==null){if(T=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",z),s.addEventListener("inputsourceschange",ee),w.xrCompatible!==!0&&await t.makeXRCompatible(),v=e.getPixelRatio(),e.getSize(g),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let de=null,we=null,fe=null;w.depth&&(fe=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,de=w.stencil?jn:Yn,we=w.stencil?Ni:wn);let Te={colorFormat:t.RGBA8,depthFormat:fe,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Te),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),S=new cn(d.textureWidth,d.textureHeight,{format:An,type:en,depthTexture:new Jn(d.textureWidth,d.textureHeight,we,void 0,void 0,void 0,void 0,void 0,void 0,de),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let de={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,t,de),s.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),S=new cn(f.framebufferWidth,f.framebufferHeight,{format:An,type:en,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await s.requestReferenceSpace(a),xe.setContext(s),xe.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(H){for(let ue=0;ue<H.removed.length;ue++){let de=H.removed[ue],we=M.indexOf(de);we>=0&&(M[we]=null,E[we].disconnect(de))}for(let ue=0;ue<H.added.length;ue++){let de=H.added[ue],we=M.indexOf(de);if(we===-1){for(let Te=0;Te<E.length;Te++)if(Te>=M.length){M.push(de),we=Te;break}else if(M[Te]===null){M[Te]=de,we=Te;break}if(we===-1)break}let fe=E[we];fe&&fe.connect(de)}}function q(H,ue){ue===null?H.matrixWorld.copy(H.matrix):H.matrixWorld.multiplyMatrices(ue.matrixWorld,H.matrix),H.matrixWorldInverse.copy(H.matrixWorld).invert()}this.updateCamera=function(H){if(s===null)return;let ue=H.near,de=H.far;m.texture!==null&&(m.depthNear>0&&(ue=m.depthNear),m.depthFar>0&&(de=m.depthFar)),B.near=D.near=R.near=ue,B.far=D.far=R.far=de,(C!==B.near||W!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),C=B.near,W=B.far),B.layers.mask=H.layers.mask|6,R.layers.mask=B.layers.mask&-5,D.layers.mask=B.layers.mask&-3;let we=H.parent,fe=B.cameras;q(B,we);for(let Te=0;Te<fe.length;Te++)q(fe[Te],we);B.projectionMatrix.copy(R.projectionMatrix),B.projectionMatrixInverse.copy(R.projectionMatrixInverse),L===null&&H.isPerspectiveCamera&&(L={camera:H,fov:H.fov,zoom:H.zoom}),J(H,B,we)};function J(H,ue,de){de===null?H.matrix.copy(ue.matrixWorld):(H.matrix.copy(de.matrixWorld),H.matrix.invert(),H.matrix.multiply(ue.matrixWorld)),H.matrix.decompose(H.position,H.quaternion,H.scale),H.updateMatrixWorld(!0),H.projectionMatrix.copy(ue.projectionMatrix),H.projectionMatrixInverse.copy(ue.projectionMatrixInverse),H.isPerspectiveCamera&&(H.fov=ts*2*Math.atan(1/H.projectionMatrix.elements[5]),H.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(H){c=H,d!==null&&(d.fixedFoveation=H),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=H)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(B)},this.getCameraTexture=function(H){return p[H]};let O=null;function ae(H,ue){if(h=ue.getViewerPose(l||o),_=ue,h!==null){let de=h.views;f!==null&&(e.setRenderTargetFramebuffer(S,f.framebuffer),e.setRenderTarget(S));let we=!1;de.length!==B.cameras.length&&(B.cameras.length=0,we=!0);for(let me=0;me<de.length;me++){let Ie=de[me],Ne=null;if(f!==null)Ne=f.getViewport(Ie);else{let Ce=u.getViewSubImage(d,Ie);Ne=Ce.viewport,me===0&&(e.setRenderTargetTextures(S,Ce.colorTexture,Ce.depthStencilTexture),e.setRenderTarget(S))}let Oe=N[me];Oe===void 0&&(Oe=new qt,Oe.layers.enable(me),Oe.viewport=new _t,N[me]=Oe),Oe.matrix.fromArray(Ie.transform.matrix),Oe.matrix.decompose(Oe.position,Oe.quaternion,Oe.scale),Oe.projectionMatrix.fromArray(Ie.projectionMatrix),Oe.projectionMatrixInverse.copy(Oe.projectionMatrix).invert(),Oe.viewport.set(Ne.x,Ne.y,Ne.width,Ne.height),me===0&&(B.matrix.copy(Oe.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),we===!0&&B.cameras.push(Oe)}let fe=s.enabledFeatures;if(fe&&fe.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();let me=u.getDepthInformation(de[0]);me&&me.isValid&&me.texture&&m.init(me,s.renderState)}if(fe&&fe.includes("camera-access")&&x){e.state.unbindTexture(),u=n.getBinding();for(let me=0;me<de.length;me++){let Ie=de[me].camera;if(Ie){let Ne=p[Ie];Ne||(Ne=new ks,p[Ie]=Ne);let Oe=u.getCameraImage(Ie);Ne.sourceTexture=Oe}}}}for(let de=0;de<E.length;de++){let we=M[de],fe=E[de];we!==null&&fe!==void 0&&fe.update(we,ue,l||o)}O&&O(H,ue),ue.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ue}),_=null}let xe=new su;xe.setAnimationLoop(ae),this.setAnimationLoop=function(H){O=H},this.dispose=function(){}}},N0=new mt,pu=new Ge;pu.set(-1,0,0,0,1,0,0,0,1);function U0(i,e){function t(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,Ll(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,w,T,S){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,S)):p.isMeshMatcapMaterial?(r(m,p),_(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),x(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(o(m,p),p.isLineDashedMaterial&&a(m,p)):p.isPointsMaterial?c(m,p,w,T):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,t(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Jt&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,t(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Jt&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,t(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,t(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);let w=e.get(p),T=w.envMap,S=w.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(N0.makeRotationFromEuler(S)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(pu),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,m.aoMapTransform))}function o(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform))}function a(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,w,T){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*w,m.scale.value=T*.5,p.map&&(m.map.value=p.map,t(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,t(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,t(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,w){m.ior.value=p.ior,p.diffuseRoughness>0&&(m.diffuseRoughness.value=p.diffuseRoughness,p.diffuseRoughnessMap&&(m.diffuseRoughnessMap.value=p.diffuseRoughnessMap,t(p.diffuseRoughnessMap,m.diffuseRoughnessMapTransform))),p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Jt&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.retroreflectivity>0&&(m.retroreflectivity.value=p.retroreflectivity),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessMinimum,m.iridescenceThicknessMaximum.value=p.iridescenceThicknessMaximum,p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,m.specularIntensityMapTransform))}function _(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){let w=e.get(p).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 F0(i,e,t,n){let s={},r={};function o(w,T){let S=T.program;n.uniformBlockBinding(w,S,s[w.id])}function a(w,T){let S=s[w.id];S===void 0&&(_(w),S=c(w),s[w.id]=S,w.addEventListener("dispose",m));let E=T.program;n.updateUBOMapping(w,E);let M=e.render.frame;r[w.id]!==M&&(l(w),r[w.id]=M)}function c(w){let T=i.createBuffer(),S=w.__size,E=w.usage;return i.bindBuffer(i.UNIFORM_BUFFER,T),i.bufferData(i.UNIFORM_BUFFER,S,E),i.bindBuffer(i.UNIFORM_BUFFER,null),T}function l(w){let T=s[w.id],S=w.uniforms,E=w.__cache;i.bindBuffer(i.UNIFORM_BUFFER,T);for(let M=0,g=S.length;M<g;M++){let v=S[M];if(Array.isArray(v))for(let L=0,R=v.length;L<R;L++)h(v[L],M,L,E);else h(v,M,0,E)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function h(w,T,S,E){if(d(w,T,S,E)===!0){let M=w.__offset,g=w.value;if(Array.isArray(g)){let v=0;for(let L=0;L<g.length;L++){let R=g[L],D=x(R,!0);u(R,w.__data,v),v+=D.storage/Float32Array.BYTES_PER_ELEMENT}}else u(g,w.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,M,w.__data)}}function u(w,T,S){typeof w=="number"||typeof w=="boolean"?T[S]=w:w.isMatrix3?(T[S]=w.elements[0],T[S+1]=w.elements[1],T[S+2]=w.elements[2],T[S+3]=0,T[S+4]=w.elements[3],T[S+5]=w.elements[4],T[S+6]=w.elements[5],T[S+7]=0,T[S+8]=w.elements[6],T[S+9]=w.elements[7],T[S+10]=w.elements[8],T[S+11]=0):ArrayBuffer.isView(w)?T.set(w.subarray(0,T.length-S),S):w.toArray(T,S)}function d(w,T,S,E){let M=w.value,g=T+"_"+S;if(Array.isArray(M)){E[g]===void 0&&(E[g]=[]);let v=E[g],L=!1;for(let R=0;R<M.length;R++)f(M[R],v,R)===!0&&(L=!0);return L}return f(M,E,g)}function f(w,T,S){if(T[S]===void 0)return typeof w=="number"||typeof w=="boolean"?T[S]=w:ArrayBuffer.isView(w)?T[S]=w.slice():T[S]=w.clone(),!0;{let E=T[S];if(typeof w=="number"||typeof w=="boolean"){if(E!==w)return T[S]=w,!0}else{if(ArrayBuffer.isView(w))return!0;if(E.equals(w)===!1)return E.copy(w),!0}}return!1}function _(w){let T=w.uniforms,S=0,E=16;for(let g=0,v=T.length;g<v;g++){let L=Array.isArray(T[g])?T[g]:[T[g]];for(let R=0,D=L.length;R<D;R++){let N=L[R],B=Array.isArray(N.value)?N.value:[N.value],C=Array.isArray(T[g])||Array.isArray(N.value),W=S;for(let z=0,ee=B.length;z<ee;z++){let q=B[z],J=x(q,C),O=S%E,ae=O%J.boundary,xe=O+ae;S+=ae,xe!==0&&E-xe<J.storage&&(S+=E-xe),z===0&&(W=S),S+=J.storage}let Z=N.type==="int"?Int32Array:N.type==="uint"?Uint32Array:Float32Array;N.__data=new Z((S-W)/Float32Array.BYTES_PER_ELEMENT),N.__offset=W}}let M=S%E;return M>0&&(S+=E-M),w.__size=S,w.__cache={},this}function x(w,T){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?Fe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(w)?(S.boundary=16,S.storage=w.byteLength):Fe("WebGLRenderer: Unsupported uniform value type.",w),T===!0&&(S.boundary=16,S.storage=Math.ceil(S.storage/16)*16),S}function m(w){let T=w.target;T.removeEventListener("dispose",m),i.deleteBuffer(s[T.id]),delete s[T.id],delete r[T.id]}function p(){for(let w in s)i.deleteBuffer(s[w]);s={},r={}}return{bind:o,update:a,dispose:p}}var O0=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]),Dn=null;function B0(){return Dn===null&&(Dn=new no(O0,16,16,_i,Tn),Dn.name="DFG_LUT",Dn.minFilter=Zt,Dn.magFilter=Zt,Dn.wrapS=Cn,Dn.wrapT=Cn,Dn.generateMipmaps=!1,Dn.needsUpdate=!0),Dn}var pa=class{constructor(e={}){let{canvas:t=Ah(),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:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=en}=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=f,m=new Set([Do,Lo,Io]),p=new Set([en,wn,ps,Ni,Co,Po]),w=new Uint32Array(4),T=new Int32Array(4),S={textures:[],min:[],max:[],resolution:[]},E=null,M=null,g=[],v=[],L=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=Ln,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let R=this,D=!1,N=null,B=null,C=null,W=null;this._outputColorSpace=on;let Z=0,z=0,ee=null,q=-1,J=null,O=new _t,ae=new _t,xe=null,H=new Ye(0),ue=0,de=t.width,we=t.height,fe=1,Te=null,He=null,me=new _t(0,0,de,we),Ie=new _t(0,0,de,we),Ne=!1,Oe=new hi,Ce=new io,We=!1,vt=!1,nt=new mt,gt=new k,Xe=new _t,ft={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},It=!1;function Ft(){return ee===null?fe:1}let F=n;function Lt(b,U){return t.getContext(b,U)}let st,rt,_e,ht,De,Be,A,y,V,le,se,he,ye,j,Q,ge,I,te,P,ne,$,ie,oe;try{let b={alpha:!0,depth:s,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",pe,!1),t.addEventListener("webglcontextrestored",Le,!1),t.addEventListener("webglcontextcreationerror",ce,!1),F===null){let U="webgl2";if(F=Lt(U,b),F===null)throw Lt(U)?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",pe,!1),t.removeEventListener("webglcontextrestored",Le,!1),t.removeEventListener("webglcontextcreationerror",ce,!1),ke("WebGLRenderer: "+b.message),b}function re(){st=new $m(F),st.init(),$=new I0(F,st),rt=new Bm(F,st,e,$),_e=new C0(F,st),rt.reversedDepthBuffer&&d&&_e.buffers.depth.setReversed(!0),B=F.createFramebuffer(),C=F.createFramebuffer(),W=F.createFramebuffer(),ht=new jm(F),De=new m0,Be=new P0(F,st,_e,De,rt,$,ht),A=new Zm(R),y=new Qd(F),ie=new Fm(F,y),V=new Jm(F,y,ht,ie),le=new eg(F,V,y,ie,ht),te=new Qm(F,rt,Be),Q=new zm(De),se=new p0(R,A,st,rt,ie,Q),he=new U0(R,De),ye=new _0,j=new S0(st),I=new Um(R,A,_e,le,_,c),ge=new R0(R,le,rt),oe=new F0(F,ht,rt,_e),P=new Om(F,st,ht),ne=new Km(F,st,ht),ht.programs=se.programs,R.capabilities=rt,R.extensions=st,R.properties=De,R.renderLists=ye,R.shadowMap=ge,R.state=_e,R.info=ht}x!==en&&(L=new ng(x,t.width,t.height,a,s,r));let K=new Jl(R,F);this.xr=K,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){let b=st.get("WEBGL_lose_context");b&&b.loseContext()},this.forceContextRestore=function(){let b=st.get("WEBGL_lose_context");b&&b.restoreContext()},this.getPixelRatio=function(){return fe},this.setPixelRatio=function(b){b!==void 0&&(fe=b,this.setSize(de,we,!1))},this.getSize=function(b){return b.set(de,we)},this.setSize=function(b,U,Y=!0){if(K.isPresenting){Fe("WebGLRenderer: Can't change size while VR device is presenting.");return}de=b,we=U,t.width=Math.floor(b*fe),t.height=Math.floor(U*fe),Y===!0&&(t.style.width=b+"px",t.style.height=U+"px"),L!==null&&L.setSize(t.width,t.height),this.setViewport(0,0,b,U)},this.getDrawingBufferSize=function(b){return b.set(de*fe,we*fe).floor()},this.setDrawingBufferSize=function(b,U,Y){de=b,we=U,fe=Y,t.width=Math.floor(b*Y),t.height=Math.floor(U*Y),this.setViewport(0,0,b,U)},this.setEffects=function(b){if(x===en){ke("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(b){for(let U=0;U<b.length;U++)if(b[U].isOutputPass===!0){Fe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}L.setEffects(b||[])},this.getCurrentViewport=function(b){return b.copy(O)},this.getViewport=function(b){return b.copy(me)},this.setViewport=function(b,U,Y,G){b.isVector4?me.set(b.x,b.y,b.z,b.w):me.set(b,U,Y,G),_e.viewport(O.copy(me).multiplyScalar(Ft()).round())},this.getScissor=function(b){return b.copy(Ie)},this.setScissor=function(b,U,Y,G){b.isVector4?Ie.set(b.x,b.y,b.z,b.w):Ie.set(b,U,Y,G),_e.scissor(ae.copy(Ie).multiplyScalar(Ft()).round())},this.getScissorTest=function(){return Ne},this.setScissorTest=function(b){_e.setScissorTest(Ne=b)},this.setOpaqueSort=function(b){Te=b},this.setTransparentSort=function(b){He=b},this.getClearColor=function(b){return b.copy(I.getClearColor())},this.setClearColor=function(){I.setClearColor(...arguments)},this.getClearAlpha=function(){return I.getClearAlpha()},this.setClearAlpha=function(){I.setClearAlpha(...arguments)},this.clear=function(b=!0,U=!0,Y=!0){let G=0;if(b){let X=!1;if(ee!==null){let be=ee.texture.format;X=m.has(be)}if(X){let be=ee.texture.type,Ee=p.has(be),ve=I.getClearColor(),Se=I.getClearAlpha(),Pe=ve.r,qe=ve.g,je=ve.b;Ee?(w[0]=Pe,w[1]=qe,w[2]=je,w[3]=Se,F.clearBufferuiv(F.COLOR,0,w)):(T[0]=Pe,T[1]=qe,T[2]=je,T[3]=Se,F.clearBufferiv(F.COLOR,0,T))}else G|=F.COLOR_BUFFER_BIT}U&&(G|=F.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),Y&&(G|=F.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&F.clear(G)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(b){b.setRenderer(this),N=b},this.dispose=function(){t.removeEventListener("webglcontextlost",pe,!1),t.removeEventListener("webglcontextrestored",Le,!1),t.removeEventListener("webglcontextcreationerror",ce,!1),I.dispose(),ye.dispose(),j.dispose(),Be.dispose(),De.dispose(),A.dispose(),le.dispose(),V.dispose(),ie.dispose(),oe.dispose(),se.dispose(),K.dispose(),K.removeEventListener("sessionstart",lt),K.removeEventListener("sessionend",nn),ze.stop()};function pe(b){b.preventDefault(),Al("WebGLRenderer: Context Lost."),D=!0}function Le(){Al("WebGLRenderer: Context Restored."),D=!1;let b=ht.autoReset,U=ge.enabled,Y=ge.autoUpdate,G=ge.needsUpdate,X=ge.type;re(),ht.autoReset=b,ge.enabled=U,ge.autoUpdate=Y,ge.needsUpdate=G,ge.type=X}function ce(b){ke("WebGLRenderer: A WebGL context could not be created. Reason: ",b.statusMessage)}function Ue(b){let U=b.target;U.removeEventListener("dispose",Ue),tt(U)}function tt(b){xt(b),De.remove(b)}function xt(b){let U=De.get(b).programs;U!==void 0&&(U.forEach(function(Y){se.releaseProgram(Y)}),b.isShaderMaterial&&se.releaseShaderCache(b))}this.renderBufferDirect=function(b,U,Y,G,X,be){U===null&&(U=ft);let Ee=X.isMesh&&X.matrixWorld.determinantAffine()<0,ve=ju(b,U,Y,G,X);_e.setMaterial(G,Ee);let Se=Y.index,Pe=1;if(G.wireframe===!0){if(Se=V.getWireframeAttribute(Y),Se===void 0)return;Pe=2}let qe=Y.drawRange,je=Y.attributes.position,Ae=qe.start*Pe,Qe=(qe.start+qe.count)*Pe;be!==null&&(Ae=Math.max(Ae,be.start*Pe),Qe=Math.min(Qe,(be.start+be.count)*Pe)),Se!==null?(Ae=Math.max(Ae,0),Qe=Math.min(Qe,Se.count)):je!=null&&(Ae=Math.max(Ae,0),Qe=Math.min(Qe,je.count));let Mt=Qe-Ae;if(Mt<0||Mt===1/0)return;ie.setup(X,G,ve,Y,Se);let dt,ut=P;if(Se!==null&&(dt=y.get(Se),ut=ne,ut.setIndex(dt)),X.isMesh)G.wireframe===!0?(_e.setLineWidth(G.wireframeLinewidth*Ft()),ut.setMode(F.LINES)):ut.setMode(F.TRIANGLES);else if(X.isLine){let Ot=G.linewidth;Ot===void 0&&(Ot=1),_e.setLineWidth(Ot*Ft()),X.isLineSegments?ut.setMode(F.LINES):X.isLineLoop?ut.setMode(F.LINE_LOOP):ut.setMode(F.LINE_STRIP)}else X.isPoints?ut.setMode(F.POINTS):X.isSprite&&ut.setMode(F.TRIANGLES);if(X.isBatchedMesh)if(st.get("WEBGL_multi_draw"))ut.renderMultiDraw(X._multiDrawStarts,X._multiDrawCounts,X._multiDrawCount);else{let Ot=X._multiDrawStarts,Re=X._multiDrawCounts,Xt=X._multiDrawCount,ot=Se?y.get(Se).bytesPerElement:1,bi=De.get(G).currentProgram.getUniforms();for(let Bt=0;Bt<Xt;Bt++)bi.setValue(F,"_gl_DrawID",Bt),ut.render(Ot[Bt]/ot,Re[Bt])}else if(X.isInstancedMesh)ut.renderInstances(Ae,Mt,X.count);else if(Y.isInstancedBufferGeometry){let Ot=Y._maxInstanceCount!==void 0?Y._maxInstanceCount:1/0,Re=Math.min(Y.instanceCount,Ot);ut.renderInstances(Ae,Mt,Re)}else ut.render(Ae,Mt)};function Ze(b,U,Y,G){N!==null&&b.isNodeMaterial&&N.setObject(G,b),We===!0&&Q.setState(b,Y,!1),b.transparent===!0&&b.side===_n&&b.forceSinglePass===!1?(b.side=Jt,b.needsUpdate=!0,ni(b,U,G),b.side=gi,b.needsUpdate=!0,ni(b,U,G),b.side=_n):ni(b,U,G)}this.compile=function(b,U,Y=null){Y===null&&(Y=b),N!==null&&N.renderStart(b,U,Y),M=j.get(Y),M.init(U),v.push(M),Y.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(M.pushLight(X),X.castShadow&&M.pushShadow(X))}),b!==Y&&b.traverseVisible(function(X){X.isLight&&X.layers.test(U.layers)&&(M.pushLight(X),X.castShadow&&M.pushShadow(X))}),M.setupLights(),N!==null&&N.updateLights(M.state.lightsArray),vt=this.localClippingEnabled,We=Q.init(this.clippingPlanes,vt),We===!0&&Q.setGlobalState(this.clippingPlanes,U),N!==null&&ge.render(M.state.shadowsArray,Y,U);let G=new Set;return b.traverse(function(X){if(!(X.isMesh||X.isPoints||X.isLine||X.isSprite))return;let be=X.material;if(be)if(Array.isArray(be))for(let Ee=0;Ee<be.length;Ee++){let ve=be[Ee];Ze(ve,Y,U,X),G.add(ve)}else Ze(be,Y,U,X),G.add(be)}),M=v.pop(),N!==null&&N.renderEnd(),G},this.compileAsync=function(b,U,Y=null){let G=this.compile(b,U,Y);return new Promise(X=>{function be(){if(G.forEach(function(Ee){let Se=De.get(Ee).currentProgram;(Se===void 0||Se.isReady())&&G.delete(Ee)}),G.size===0){X(b);return}setTimeout(be,10)}st.get("KHR_parallel_shader_compile")!==null?be():setTimeout(be,10)})};let bt=null;function Dt(b){bt&&bt(b)}function lt(){ze.stop()}function nn(){ze.start()}let ze=new su;ze.setAnimationLoop(Dt),typeof self<"u"&&ze.setContext(self),this.setAnimationLoop=function(b){bt=b,K.setAnimationLoop(b),b===null?ze.stop():ze.start()},K.addEventListener("sessionstart",lt),K.addEventListener("sessionend",nn),this.render=function(b,U){if(U!==void 0&&U.isCamera!==!0){ke("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;N!==null&&N.renderStart(b,U);let Y=K.enabled===!0&&K.isPresenting===!0,G=L!==null&&(ee===null||Y)&&L.begin(R,ee);if(b.matrixWorldAutoUpdate===!0&&b.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),K.enabled===!0&&K.isPresenting===!0&&(L===null||L.isCompositing()===!1)&&(K.cameraAutoUpdate===!0&&K.updateCamera(U),U=K.getCamera()),b.isScene===!0&&b.onBeforeRender(R,b,U,ee),M=j.get(b,v.length),M.init(U),M.state.textureUnits=Be.getTextureUnits(),v.push(M),nt.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),U.isArrayCamera?Ce.setFromArrayCamera(U):Oe.setFromProjectionMatrix(nt,gn,U.reversedDepth),vt=this.localClippingEnabled,We=Q.init(this.clippingPlanes,vt),E=ye.get(b,g.length),E.init(),g.push(E),this.info.render.frame++,K.enabled===!0&&K.isPresenting===!0){let Ee=R.xr.getDepthSensingMesh();Ee!==null&&dn(Ee,U,-1/0,R.sortObjects)}dn(b,U,0,R.sortObjects),E.finish(),N!==null&&N.updateLights(M.state.lightsArray),R.sortObjects===!0&&E.sort(Te,He),It=K.enabled===!1||K.isPresenting===!1||K.hasDepthSensing()===!1,It&&I.addToRenderList(E,b),this.info.autoReset===!0&&this.info.reset(),We===!0&&Q.beginShadows();let X=M.state.shadowsArray;if(ge.render(X,b,U),We===!0&&Q.endShadows(),(G&&L.hasRenderPass())===!1){let Ee=E.opaque,ve=E.transmissive;if(M.setupLights(),U.isArrayCamera){let Se=U.cameras;if(ve.length>0)for(let Pe=0,qe=Se.length;Pe<qe;Pe++){let je=Se[Pe];On(Ee,ve,b,je)}It&&I.render(b);for(let Pe=0,qe=Se.length;Pe<qe;Pe++){let je=Se[Pe];fn(E,b,je,je.viewport)}}else ve.length>0&&On(Ee,ve,b,U),It&&I.render(b),fn(E,b,U)}ee!==null&&z===0&&(Be.updateMultisampleRenderTarget(ee),Be.updateRenderTargetMipmap(ee)),G&&L.end(R),b.isScene===!0&&b.onAfterRender(R,b,U),ie.resetDefaultState(),q=-1,J=null,v.pop(),v.length>0?(M=v[v.length-1],Be.setTextureUnits(M.state.textureUnits),We===!0&&Q.setGlobalState(R.clippingPlanes,M.state.camera)):M=null,g.pop(),g.length>0?E=g[g.length-1]:E=null,N!==null&&N.renderEnd()};function dn(b,U,Y,G){if(b.visible===!1)return;if(b.layers.test(U.layers)){if(b.isGroup)Y=b.renderOrder;else if(b.isLOD)b.autoUpdate===!0&&b.update(U);else if(b.isLight)M.pushLight(b),b.castShadow&&M.pushShadow(b);else if(b.isSprite){let Ee=U.isArrayCamera?Ce:Oe;if(!b.frustumCulled||b.intersectsFrustum(Ee)){G&&Xe.setFromMatrixPosition(b.matrixWorld).applyMatrix4(nt);let ve=le.update(b),Se=b.material;Se.visible&&E.push(b,ve,Se,Y,Xe.z,null,U)}}else if(b.isMesh||b.isLine||b.isPoints){let Ee=U.isArrayCamera?Ce:Oe;if(!b.frustumCulled||b.intersectsFrustum(Ee)){let ve=le.update(b),Se=b.material;if(G&&(b.boundingSphere!==void 0?(b.boundingSphere===null&&b.computeBoundingSphere(),Xe.copy(b.boundingSphere.center)):(ve.boundingSphere===null&&ve.computeBoundingSphere(),Xe.copy(ve.boundingSphere.center)),Xe.applyMatrix4(b.matrixWorld).applyMatrix4(nt)),Array.isArray(Se)){let Pe=ve.groups;for(let qe=0,je=Pe.length;qe<je;qe++){let Ae=Pe[qe],Qe=Se[Ae.materialIndex];Qe&&Qe.visible&&E.push(b,ve,Qe,Y,Xe.z,Ae,U)}}else Se.visible&&E.push(b,ve,Se,Y,Xe.z,null,U)}}}let be=b.children;for(let Ee=0,ve=be.length;Ee<ve;Ee++)dn(be[Ee],U,Y,G)}function fn(b,U,Y,G){let{opaque:X,transmissive:be,transparent:Ee}=b;M.setupLightsView(Y),We===!0&&Q.setGlobalState(R.clippingPlanes,Y),G&&_e.viewport(O.copy(G)),X.length>0&&Bn(X,U,Y),be.length>0&&Bn(be,U,Y),Ee.length>0&&Bn(Ee,U,Y),_e.buffers.depth.setTest(!0),_e.buffers.depth.setMask(!0),_e.buffers.color.setMask(!0),_e.setPolygonOffset(!1)}function On(b,U,Y,G){if((Y.isScene===!0?Y.overrideMaterial:null)!==null)return;if(M.state.transmissionRenderTarget[G.id]===void 0){let Ae=st.has("EXT_color_buffer_half_float")||st.has("EXT_color_buffer_float");M.state.transmissionRenderTarget[G.id]=new cn(1,1,{generateMipmaps:!0,type:Ae?Tn:en,minFilter:Kn,samples:Math.max(4,rt.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:et.workingColorSpace})}let be=M.state.transmissionRenderTarget[G.id],Ee=G.viewport||O;be.setSize(Ee.z*R.transmissionResolutionScale,Ee.w*R.transmissionResolutionScale);let ve=R.getRenderTarget(),Se=R.getActiveCubeFace(),Pe=R.getActiveMipmapLevel();R.setRenderTarget(be),R.getClearColor(H),ue=R.getClearAlpha(),ue<1&&R.setClearColor(16777215,.5),R.clear(),It&&I.render(Y);let qe=R.toneMapping;R.toneMapping=Ln;let je=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),M.setupLightsView(G),We===!0&&Q.setGlobalState(R.clippingPlanes,G),Bn(b,Y,G),Be.updateMultisampleRenderTarget(be),Be.updateRenderTargetMipmap(be),st.has("WEBGL_multisampled_render_to_texture")===!1){let Ae=!1;for(let Qe=0,Mt=U.length;Qe<Mt;Qe++){let dt=U[Qe],{object:ut,geometry:Ot,material:Re,group:Xt}=dt;if(Re.side===_n&&ut.layers.test(G.layers)){let ot=Re.side;Re.side=Jt,Re.needsUpdate=!0,vs(ut,Y,G,Ot,Re,Xt),Re.side=ot,Re.needsUpdate=!0,Ae=!0}}Ae===!0&&(Be.updateMultisampleRenderTarget(be),Be.updateRenderTargetMipmap(be))}R.setRenderTarget(ve,Se,Pe),R.setClearColor(H,ue),je!==void 0&&(G.viewport=je),R.toneMapping=qe}function Bn(b,U,Y){let G=U.isScene===!0?U.overrideMaterial:null;for(let X=0,be=b.length;X<be;X++){let Ee=b[X],{object:ve,geometry:Se,group:Pe}=Ee,qe=Ee.material;qe.allowOverride===!0&&G!==null&&(qe=G),ve.layers.test(Y.layers)&&vs(ve,U,Y,Se,qe,Pe)}}function vs(b,U,Y,G,X,be){N!==null&&X.isNodeMaterial&&N.setObject(b,X),b.onBeforeRender(R,U,Y,G,X,be),b.modelViewMatrix.multiplyMatrices(Y.matrixWorldInverse,b.matrixWorld),b.normalMatrix.getNormalMatrix(b.modelViewMatrix),X.onBeforeRender(R,U,Y,G,b,be),X.transparent===!0&&X.side===_n&&X.forceSinglePass===!1?(X.side=Jt,X.needsUpdate=!0,R.renderBufferDirect(Y,U,G,X,b,be),X.side=gi,X.needsUpdate=!0,R.renderBufferDirect(Y,U,G,X,b,be),X.side=_n):R.renderBufferDirect(Y,U,G,X,b,be),b.onAfterRender(R,U,Y,G,X,be)}function bs(b){let U=0;for(let Y of b)Y.texture!==null&&U++;return U}function ni(b,U,Y){U.isScene!==!0&&(U=ft);let G=De.get(b),X=M.state.lights,be=M.state.shadowsArray,Ee=X.state.version,ve=se.getParameters(b,X.state,be,U,Y,M.state.lightProbeGridArray),Se=se.getProgramCacheKey(ve),Pe=G.programs;G.environment=b.isMeshStandardMaterial||b.isMeshLambertMaterial||b.isMeshPhongMaterial?U.environment:null,G.fog=U.fog;let qe=b.isMeshStandardMaterial||b.isMeshLambertMaterial&&!b.envMap||b.isMeshPhongMaterial&&!b.envMap;G.envMap=A.get(b.envMap||G.environment,qe),G.envMapRotation=G.environment!==null&&b.envMap===null?U.environmentRotation:b.envMapRotation,Pe===void 0&&(b.addEventListener("dispose",Ue),Pe=new Map,G.programs=Pe,G.programVariants=new Map);let je=Pe.get(Se);if(je!==void 0){if(G.currentProgram===je&&G.lightsStateVersion===Ee)return _c(b,ve),je}else ve.uniforms=se.getUniforms(b),N!==null&&b.isNodeMaterial&&N.build(b,Y,ve),b.onBeforeCompile(ve,R),je=se.acquireProgram(ve,Se),Pe.set(Se,je),G.uniforms=ve.uniforms;let Ae=G.uniforms;return(!b.isShaderMaterial&&!b.isRawShaderMaterial||b.clipping===!0)&&(Ae.clippingPlanes=Q.uniform),_c(b,ve),G.needsLights=ed(b),G.lightsStateVersion=Ee,G.needsLights&&(Ae.ambientLightColor.value=X.state.ambient,Ae.lightProbe.value=X.state.probe,Ae.sunLights.value=X.state.sun,Ae.sunLightShadows.value=X.state.sunShadow,Ae.directionalLights.value=X.state.directional,Ae.directionalLightShadows.value=X.state.directionalShadow,Ae.spotLights.value=X.state.spot,Ae.spotLightShadows.value=X.state.spotShadow,Ae.rectAreaLights.value=X.state.rectArea,Ae.ltc_1.value=X.state.rectAreaLTC1,Ae.ltc_2.value=X.state.rectAreaLTC2,Ae.pointLights.value=X.state.point,Ae.pointLightShadows.value=X.state.pointShadow,Ae.hemisphereLights.value=X.state.hemi,Ae.sunShadowMatrix.value=X.state.sunShadowMatrix,Ae.sunShadowCascade.value=X.state.sunShadowCascade,Ae.directionalShadowMatrix.value=X.state.directionalShadowMatrix,Ae.spotLightMatrix.value=X.state.spotLightMatrix,Ae.spotLightMap.value=X.state.spotLightMap,Ae.pointShadowMatrix.value=X.state.pointShadowMatrix),G.numLightProbeGrids=bs(M.state.lightProbeGridArray),G.currentProgram=je,G.uniformsList=null,je}function pr(b,U,Y,G,X){let be=De.get(b),Ee=be.currentProgram.id+","+G+","+X,ve=be.programVariants.get(Ee);return ve===void 0?(ve=ni(b,U,Y),be.programVariants.set(Ee,ve)):(be.currentProgram=ve,be.uniformsList=null,be.outputColorSpace=G,be.toneMapping=X),ve}function gc(b){if(b.uniformsList===null){let U=b.currentProgram.getUniforms();b.uniformsList=gs.seqWithValue(U.seq,b.uniforms)}return b.uniformsList}function _c(b,U){let Y=De.get(b);Y.outputColorSpace=U.outputColorSpace,Y.batching=U.batching,Y.batchingColor=U.batchingColor,Y.instancing=U.instancing,Y.instancingColor=U.instancingColor,Y.instancingMorph=U.instancingMorph,Y.skinning=U.skinning,Y.morphTargets=U.morphTargets,Y.morphNormals=U.morphNormals,Y.morphColors=U.morphColors,Y.morphTargetsCount=U.morphTargetsCount,Y.numClippingPlanes=U.numClippingPlanes,Y.numIntersection=U.numClipIntersection,Y.vertexAlphas=U.vertexAlphas,Y.vertexTangents=U.vertexTangents,Y.toneMapping=U.toneMapping}function ju(b,U,Y,G,X){U.isScene!==!0&&(U=ft),Be.resetTextureUnits();let be=U.fog,Ee=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?U.environment:null,ve=ee===null?R.outputColorSpace:ee.isXRRenderTarget===!0?ee.texture.colorSpace:et.workingColorSpace,Se=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Pe=A.get(G.envMap||Ee,Se),qe=G.vertexColors===!0&&!!Y.attributes.color&&Y.attributes.color.itemSize===4,je=!!Y.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ae=!!Y.morphAttributes.position,Qe=!!Y.morphAttributes.normal,Mt=!!Y.morphAttributes.color,dt=Ln;G.toneMapped&&(ee===null||ee.isXRRenderTarget===!0)&&(dt=R.toneMapping);let ut=Y.morphAttributes.position||Y.morphAttributes.normal||Y.morphAttributes.color,Ot=ut!==void 0?ut.length:0,Re=De.get(G),Xt=M.state.lights;if(We===!0&&(vt===!0||b!==J)){let yt=b===J&&G.id===q;Q.setState(G,b,yt)}let ot=!1,bi=!1;G.version===Re.__version?Re.needsLights&&Re.lightsStateVersion!==Xt.state.version||X.isBatchedMesh&&Re.batching===!1||!X.isBatchedMesh&&Re.batching===!0||X.isBatchedMesh&&Re.batchingColor===!0&&X._colorsTexture===null||X.isBatchedMesh&&Re.batchingColor===!1&&X._colorsTexture!==null||X.isInstancedMesh&&Re.instancing===!1||!X.isInstancedMesh&&Re.instancing===!0||X.isSkinnedMesh&&Re.skinning===!1||!X.isSkinnedMesh&&Re.skinning===!0||X.isInstancedMesh&&Re.instancingColor===!0&&X.instanceColor===null||X.isInstancedMesh&&Re.instancingColor===!1&&X.instanceColor!==null||X.isInstancedMesh&&Re.instancingMorph===!0&&X.morphTexture===null||X.isInstancedMesh&&Re.instancingMorph===!1&&X.morphTexture!==null||Re.envMap!==Pe||G.fog===!0&&Re.fog!==be||Re.numClippingPlanes!==void 0&&(Re.numClippingPlanes!==Q.numPlanes||Re.numIntersection!==Q.numIntersection)||Re.vertexAlphas!==qe||Re.vertexTangents!==je||Re.morphTargets!==Ae||Re.morphNormals!==Qe||Re.morphColors!==Mt||Re.morphTargetsCount!==Ot||Re.numLightProbeGrids!==bs(M.state.lightProbeGridArray)?ot=!0:(Re.outputColorSpace!==ve||Re.toneMapping!==dt)&&(bi=!0):(ot=!0,Re.__version=G.version);let Bt=Re.currentProgram;(ot===!0||bi===!0)&&(Bt=bi===!0?pr(G,U,X,ve,dt):ni(G,U,X),N&&G.isNodeMaterial&&N.onUpdateProgram(G,Bt,Re));let mr=!1,ii=!1,Mi=!1,it=Bt.getUniforms(),Nt=Re.uniforms;if(_e.useProgram(Bt.program)&&(mr=!0,ii=!0,Mi=!0),G.id!==q&&(q=G.id,ii=!0),mr||J!==b){_e.buffers.depth.getReversed()&&b.reversedDepth!==!0&&(b._reversedDepth=!0,b.updateProjectionMatrix()),it.setValue(F,"projectionMatrix",b.projectionMatrix),it.setValue(F,"viewMatrix",b.matrixWorldInverse);let Rt=it.map.cameraPosition;Rt!==void 0&&Rt.setValue(F,gt.setFromMatrixPosition(b.matrixWorld)),rt.logarithmicDepthBuffer&&it.setValue(F,"logDepthBufFC",2/(Math.log(b.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&it.setValue(F,"isOrthographic",b.isOrthographicCamera===!0),J!==b&&(J=b,ii=!0,Mi=!0)}if(Re.needsLights&&(Xt.state.sunShadowMap.length>0&&it.setValue(F,"sunShadowMap",Xt.state.sunShadowMap,Be),Xt.state.directionalShadowMap.length>0&&it.setValue(F,"directionalShadowMap",Xt.state.directionalShadowMap,Be),Xt.state.spotShadowMap.length>0&&it.setValue(F,"spotShadowMap",Xt.state.spotShadowMap,Be),Xt.state.pointShadowMap.length>0&&it.setValue(F,"pointShadowMap",Xt.state.pointShadowMap,Be)),X.isSkinnedMesh){it.setOptional(F,X,"bindMatrix"),it.setOptional(F,X,"bindMatrixInverse");let yt=X.skeleton;yt&&(yt.boneTexture===null&&yt.computeBoneTexture(),it.setValue(F,"boneTexture",yt.boneTexture,Be))}X.isBatchedMesh&&(it.setOptional(F,X,"batchingTexture"),it.setValue(F,"batchingTexture",X._matricesTexture,Be),it.setOptional(F,X,"batchingIdTexture"),it.setValue(F,"batchingIdTexture",X._indirectTexture,Be),it.setOptional(F,X,"batchingColorTexture"),X._colorsTexture!==null&&it.setValue(F,"batchingColorTexture",X._colorsTexture,Be));let yn=Y.morphAttributes;if((yn.position!==void 0||yn.normal!==void 0||yn.color!==void 0)&&te.update(X,Y,Bt),(ii||Re.receiveShadow!==X.receiveShadow)&&(Re.receiveShadow=X.receiveShadow,it.setValue(F,"receiveShadow",X.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&U.environment!==null&&(Nt.envMapIntensity.value=U.environmentIntensity),Nt.dfgLUT!==void 0&&(Nt.dfgLUT.value=B0()),ii){if(it.setValue(F,"toneMappingExposure",R.toneMappingExposure),Re.needsLights&&Qu(Nt,Mi),be&&G.fog===!0&&he.refreshFogUniforms(Nt,be),he.refreshMaterialUniforms(Nt,G,fe,we,M.state.transmissionRenderTarget[b.id]),Re.needsLights&&Re.numLightProbeGrids>0){let yt=S,Rt=0;for(let zn of M.state.lightProbeGridArray)zn.texture!==null&&(yt.textures[Rt]=zn.texture,yt.min[Rt]=zn.boundingBox.min,yt.max[Rt]=zn.boundingBox.max,yt.resolution[Rt]=zn.resolution,Rt++);for(let zn in yt)yt[zn].length=Rt;Nt.probesSH.value=yt.textures,Nt.probesMin.value=yt.min,Nt.probesMax.value=yt.max,Nt.probesResolution.value=yt.resolution}gs.upload(F,gc(Re),Nt,Be)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&(gs.upload(F,gc(Re),Nt,Be),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&it.setValue(F,"center",X.center),it.setValue(F,"modelViewMatrix",X.modelViewMatrix),it.setValue(F,"normalMatrix",X.normalMatrix),it.setValue(F,"modelMatrix",X.matrixWorld),G.uniformsGroups!==void 0){let yt=G.uniformsGroups;for(let Rt=0,zn=yt.length;Rt<zn;Rt++){let yc=yt[Rt];oe.update(yc,Bt),oe.bind(yc,Bt)}}return Bt}function Qu(b,U){b.ambientLightColor.needsUpdate=U,b.lightProbe.needsUpdate=U,b.sunLights.needsUpdate=U,b.sunLightShadows.needsUpdate=U,b.directionalLights.needsUpdate=U,b.directionalLightShadows.needsUpdate=U,b.pointLights.needsUpdate=U,b.pointLightShadows.needsUpdate=U,b.spotLights.needsUpdate=U,b.spotLightShadows.needsUpdate=U,b.rectAreaLights.needsUpdate=U,b.hemisphereLights.needsUpdate=U}function ed(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 z},this.getRenderTarget=function(){return ee},this.setRenderTargetTextures=function(b,U,Y){let G=De.get(b);G.__autoAllocateDepthBuffer=b.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),De.get(b.texture).__webglTexture=U,De.get(b.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:Y,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(b,U){let Y=De.get(b);Y.__webglFramebuffer=U,Y.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(b,U=0,Y=0){ee=b,Z=U,z=Y;let G=null,X=!1,be=!1;if(b){let ve=De.get(b);if(ve.__useDefaultFramebuffer!==void 0){_e.bindFramebuffer(F.FRAMEBUFFER,ve.__webglFramebuffer),O.copy(b.viewport),ae.copy(b.scissor),xe=b.scissorTest,_e.viewport(O),_e.scissor(ae),_e.setScissorTest(xe),q=-1;return}else if(ve.__webglFramebuffer===void 0)Be.setupRenderTarget(b);else if(ve.__hasExternalTextures)Be.rebindTextures(b,De.get(b.texture).__webglTexture,De.get(b.depthTexture).__webglTexture);else if(b.depthBuffer){let qe=b.depthTexture;if(ve.__boundDepthTexture!==qe){if(qe!==null&&De.has(qe)&&(b.width!==qe.image.width||b.height!==qe.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Be.setupDepthRenderbuffer(b)}}let Se=b.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(be=!0);let Pe=De.get(b).__webglFramebuffer;b.isWebGLCubeRenderTarget?(Array.isArray(Pe[U])?G=Pe[U][Y]:G=Pe[U],X=!0):b.samples>0&&Be.useMultisampledRTT(b)===!1?G=De.get(b).__webglMultisampledFramebuffer:Array.isArray(Pe)?G=Pe[Y]:G=Pe,O.copy(b.viewport),ae.copy(b.scissor),xe=b.scissorTest}else O.copy(me).multiplyScalar(fe).floor(),ae.copy(Ie).multiplyScalar(fe).floor(),xe=Ne;if(Y!==0&&(G=B),_e.bindFramebuffer(F.FRAMEBUFFER,G)&&_e.drawBuffers(b,G),_e.viewport(O),_e.scissor(ae),_e.setScissorTest(xe),X){let ve=De.get(b.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+U,ve.__webglTexture,Y)}else if(be){let ve=U;for(let Se=0;Se<b.textures.length;Se++){let Pe=De.get(b.textures[Se]);F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0+Se,Pe.__webglTexture,Y,ve)}}else if(b!==null&&Y!==0){let ve=De.get(b.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,ve.__webglTexture,Y)}q=-1};function xc(b){let U=De.get(b);return(U.__readFormat!==b.format||U.__readType!==b.type)&&(U.__readFormat=b.format,U.__readType=b.type,U.__formatReadable=rt.textureFormatReadable(b.format),U.__typeReadable=rt.textureTypeReadable(b.type)),U}this.readRenderTargetPixels=function(b,U,Y,G,X,be,Ee,ve=0){if(!(b&&b.isWebGLRenderTarget)){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Se=De.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ee!==void 0&&(Se=Se[Ee],Array.isArray(Se)&&(Se=Se[0])),Se){_e.bindFramebuffer(F.FRAMEBUFFER,Se);try{let Pe=b.textures[ve],qe=Pe.format,je=Pe.type;b.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+ve);let Ae=xc(Pe);if(Ae.__formatReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Ae.__typeReadable===!1){ke("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=b.width-G&&Y>=0&&Y<=b.height-X&&F.readPixels(U,Y,G,X,$.convert(qe),$.convert(je),be)}finally{let Pe=ee!==null?De.get(ee).__webglFramebuffer:null;_e.bindFramebuffer(F.FRAMEBUFFER,Pe)}}},this.readRenderTargetPixelsAsync=async function(b,U,Y,G,X,be,Ee,ve=0){if(!(b&&b.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Se=De.get(b).__webglFramebuffer;if(b.isWebGLCubeRenderTarget&&Ee!==void 0&&(Se=Se[Ee],Array.isArray(Se)&&(Se=Se[0])),Se)if(U>=0&&U<=b.width-G&&Y>=0&&Y<=b.height-X){_e.bindFramebuffer(F.FRAMEBUFFER,Se);let Pe=b.textures[ve],qe=Pe.format,je=Pe.type;b.textures.length>1&&F.readBuffer(F.COLOR_ATTACHMENT0+ve);let Ae=xc(Pe);if(Ae.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Ae.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let Qe=F.createBuffer();F.bindBuffer(F.PIXEL_PACK_BUFFER,Qe),F.bufferData(F.PIXEL_PACK_BUFFER,be.byteLength,F.STREAM_READ),F.readPixels(U,Y,G,X,$.convert(qe),$.convert(je),0),F.bindBuffer(F.PIXEL_PACK_BUFFER,null);let Mt=ee!==null?De.get(ee).__webglFramebuffer:null;_e.bindFramebuffer(F.FRAMEBUFFER,Mt);let dt=F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE,0);return F.flush(),await Ch(F,dt,4),F.bindBuffer(F.PIXEL_PACK_BUFFER,Qe),F.getBufferSubData(F.PIXEL_PACK_BUFFER,0,be),F.bindBuffer(F.PIXEL_PACK_BUFFER,null),F.deleteBuffer(Qe),F.deleteSync(dt),be}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(b,U=null,Y=0){let G=Math.pow(2,-Y),X=Math.floor(b.image.width*G),be=Math.floor(b.image.height*G),Ee=U!==null?U.x:0,ve=U!==null?U.y:0;Be.setTexture2D(b,0),F.copyTexSubImage2D(F.TEXTURE_2D,Y,0,0,Ee,ve,X,be),_e.unbindTexture()},this.copyTextureToTexture=function(b,U,Y=null,G=null,X=0,be=0){let Ee,ve,Se,Pe,qe,je,Ae,Qe,Mt,dt=b.isCompressedTexture?b.mipmaps[be]:b.image;if(Y!==null)Ee=Y.max.x-Y.min.x,ve=Y.max.y-Y.min.y,Se=Y.isBox3?Y.max.z-Y.min.z:1,Pe=Y.min.x,qe=Y.min.y,je=Y.isBox3?Y.min.z:0;else{let it=Math.pow(2,-X);Ee=Math.floor(dt.width*it),ve=Math.floor(dt.height*it),b.isDataArrayTexture?Se=dt.depth:b.isData3DTexture?Se=Math.floor(dt.depth*it):Se=1,Pe=0,qe=0,je=0}G!==null?(Ae=G.x,Qe=G.y,Mt=G.z):(Ae=0,Qe=0,Mt=0);let ut=$.convert(U.format),Ot=$.convert(U.type),Re;U.isData3DTexture?(Be.setTexture3D(U,0),Re=F.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(Be.setTexture2DArray(U,0),Re=F.TEXTURE_2D_ARRAY):(Be.setTexture2D(U,0),Re=F.TEXTURE_2D),_e.activeTexture(F.TEXTURE0),_e.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,U.flipY),_e.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),_e.pixelStorei(F.UNPACK_ALIGNMENT,U.unpackAlignment);let Xt=_e.getParameter(F.UNPACK_ROW_LENGTH),ot=_e.getParameter(F.UNPACK_IMAGE_HEIGHT),bi=_e.getParameter(F.UNPACK_SKIP_PIXELS),Bt=_e.getParameter(F.UNPACK_SKIP_ROWS),mr=_e.getParameter(F.UNPACK_SKIP_IMAGES);_e.pixelStorei(F.UNPACK_ROW_LENGTH,dt.width),_e.pixelStorei(F.UNPACK_IMAGE_HEIGHT,dt.height),_e.pixelStorei(F.UNPACK_SKIP_PIXELS,Pe),_e.pixelStorei(F.UNPACK_SKIP_ROWS,qe),_e.pixelStorei(F.UNPACK_SKIP_IMAGES,je);let ii=b.isDataArrayTexture||b.isData3DTexture,Mi=U.isDataArrayTexture||U.isData3DTexture;if(b.isDepthTexture){let it=De.get(b),Nt=De.get(U),yn=De.get(it.__renderTarget),yt=De.get(Nt.__renderTarget);_e.bindFramebuffer(F.READ_FRAMEBUFFER,yn.__webglFramebuffer),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,yt.__webglFramebuffer);for(let Rt=0;Rt<Se;Rt++)ii&&(F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,De.get(b).__webglTexture,X,je+Rt),F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,De.get(U).__webglTexture,be,Mt+Rt)),F.blitFramebuffer(Pe,qe,Pe+Ee,qe+ve,Ae,Qe,Ae+Ee,Qe+ve,F.DEPTH_BUFFER_BIT,F.NEAREST);_e.bindFramebuffer(F.READ_FRAMEBUFFER,null),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else if(X!==0||b.isRenderTargetTexture||De.has(b)){let it=De.get(b),Nt=De.get(U);_e.bindFramebuffer(F.READ_FRAMEBUFFER,C),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,W);for(let yn=0;yn<Se;yn++)ii?F.framebufferTextureLayer(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,it.__webglTexture,X,je+yn):F.framebufferTexture2D(F.READ_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,it.__webglTexture,X),Mi?F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,Nt.__webglTexture,be,Mt+yn):F.framebufferTexture2D(F.DRAW_FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_2D,Nt.__webglTexture,be),X!==0?F.blitFramebuffer(Pe,qe,Pe+Ee,qe+ve,Ae,Qe,Ae+Ee,Qe+ve,F.COLOR_BUFFER_BIT,F.NEAREST):Mi?F.copyTexSubImage3D(Re,be,Ae,Qe,Mt+yn,Pe,qe,Ee,ve):F.copyTexSubImage2D(Re,be,Ae,Qe,Pe,qe,Ee,ve);_e.bindFramebuffer(F.READ_FRAMEBUFFER,null),_e.bindFramebuffer(F.DRAW_FRAMEBUFFER,null)}else Mi?b.isDataTexture||b.isData3DTexture?F.texSubImage3D(Re,be,Ae,Qe,Mt,Ee,ve,Se,ut,Ot,dt.data):U.isCompressedArrayTexture?F.compressedTexSubImage3D(Re,be,Ae,Qe,Mt,Ee,ve,Se,ut,dt.data):F.texSubImage3D(Re,be,Ae,Qe,Mt,Ee,ve,Se,ut,Ot,dt):b.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,be,Ae,Qe,Ee,ve,ut,Ot,dt.data):b.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,be,Ae,Qe,dt.width,dt.height,ut,dt.data):F.texSubImage2D(F.TEXTURE_2D,be,Ae,Qe,Ee,ve,ut,Ot,dt);_e.pixelStorei(F.UNPACK_ROW_LENGTH,Xt),_e.pixelStorei(F.UNPACK_IMAGE_HEIGHT,ot),_e.pixelStorei(F.UNPACK_SKIP_PIXELS,bi),_e.pixelStorei(F.UNPACK_SKIP_ROWS,Bt),_e.pixelStorei(F.UNPACK_SKIP_IMAGES,mr),be===0&&U.generateMipmaps===!0&&U.mipmapsAutoUpdate===!0&&F.generateMipmap(Re),_e.unbindTexture()},this.initRenderTarget=function(b){De.get(b).__webglFramebuffer===void 0&&Be.setupRenderTarget(b)},this.initTexture=function(b){b.isCubeTexture?Be.setTextureCube(b,0):b.isData3DTexture?Be.setTexture3D(b,0):b.isDataArrayTexture||b.isCompressedArrayTexture?Be.setTexture2DArray(b,0):Be.setTexture2D(b,0),_e.unbindTexture()},this.resetState=function(){Z=0,z=0,ee=null,_e.reset(),ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return gn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=et._getDrawingBufferColorSpace(e),t.unpackColorSpace=et._getUnpackColorSpace()}};var mu={type:"change"},jl={type:"start"},_u={type:"end"},_a=new Ri,gu=new an,z0=Math.cos(70*Il.DEG2RAD),At=new k,tn=2*Math.PI,at={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Kl=1e-6,xa=class extends Ys{constructor(e,t=null){super(e,t),this.state=at.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 ln,this._lastTargetPosition=new k,this._quat=new ln().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 Ve,this._rotateEnd=new Ve,this._rotateDelta=new Ve,this._panStart=new Ve,this._panEnd=new Ve,this._panDelta=new Ve,this._dollyStart=new Ve,this._dollyEnd=new Ve,this._dollyDelta=new Ve,this._dollyDirection=new k,this._mouse=new Ve,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=V0.bind(this),this._onPointerDown=k0.bind(this),this._onPointerUp=G0.bind(this),this._onContextMenu=$0.bind(this),this._onMouseWheel=X0.bind(this),this._onKeyDown=q0.bind(this),this._onTouchStart=Y0.bind(this),this._onTouchMove=Z0.bind(this),this._onMouseDown=H0.bind(this),this._onMouseMove=W0.bind(this),this._interceptControlDown=J0.bind(this),this._interceptControlUp=K0.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=at.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(mu),this.update(),this.state=at.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===at.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+=tn:n>Math.PI&&(n-=tn),s<-Math.PI?s+=tn:s>Math.PI&&(s-=tn),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))<z0?this.object.lookAt(this.target):(gu.setFromNormalAndCoplanarPoint(this.object.up,this.target),_a.intersectPlane(gu,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)>Kl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Kl||this._lastTargetPosition.distanceToSquared(this.target)>Kl?(this.dispatchEvent(mu),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?tn/60*this.autoRotateSpeed*e:tn/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(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*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(tn*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(-tn*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(tn*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(-tn*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(tn*this._rotateDelta.x/t.clientHeight),this._rotateUp(tn*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 Ve,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 k0(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 V0(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function G0(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(_u),this.state=at.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 H0(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=at.DOLLY;break;case pi.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=at.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=at.ROTATE}break;case pi.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=at.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=at.PAN}break;default:this.state=at.NONE}this.state!==at.NONE&&this.dispatchEvent(jl)}function W0(i){switch(this.state){case at.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case at.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case at.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function X0(i){this.enabled===!1||this.enableZoom===!1||this.state!==at.NONE||(i.preventDefault(),this.dispatchEvent(jl),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(_u))}function q0(i){this.enabled!==!1&&this._handleKeyDown(i)}function Y0(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case mi.ROTATE:if(this.enableRotate===!1){this.state=at.NONE;break}this._handleTouchStartRotate(i),this.state=at.TOUCH_ROTATE;break;case mi.PAN:if(this.enablePan===!1){this.state=at.NONE;break}this._handleTouchStartPan(i),this.state=at.TOUCH_PAN;break;default:this.state=at.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=at.TOUCH_DOLLY_PAN;break;case mi.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=at.TOUCH_DOLLY_ROTATE;break;default:this.state=at.NONE}break;default:this.state=at.NONE}this.state!==at.NONE&&this.dispatchEvent(jl)}function Z0(i){switch(this._trackPointer(i),this.state){case at.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case at.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case at.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case at.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=at.NONE}}function $0(i){this.enabled!==!1&&i.preventDefault()}function J0(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.ownerDocument.addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function K0(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 xu=i=>i<0?0:i>1?1:i,ei=i=>{let e=xu(i);return e*e*(3-2*e)};function ar(i,e){let t=xu(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 u=!h.hidden&&t>=h.appear,d=h.riseTo<=h.riseFrom?t>=h.riseFrom?1:0:ei((t-h.riseFrom)/(h.riseTo-h.riseFrom));s.set(h.key,{visible:u,rise:d})}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 u=r[h-1],d=o[h];t>u&&(c=h-1+(d>u?ei((t-u)/(d-u)):1))}let l=0;if(r.length>1){let h=j0(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 j0=i=>Math.max(wt.done,...i);var yu=.88,xi=i=>i*Math.PI/180;function ec(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 tc(i,e,t){let n=ec(t);return[i[0]+e*n[0],i[1]+e*n[1],i[2]+e*n[2]]}function Mu(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 Q0(i,e,t){let n=ec(t),{right:s,up:r}=Mu(n),o=Math.tan(xi(t.fov)/2),a=1/0,c=-1/0,l=1/0,h=-1/0;for(let u of Su(i)){let d=[u[0]-e.target[0],u[1]-e.target[1],u[2]-e.target[2]],f=e.dist-(d[0]*n[0]+d[1]*n[1]+d[2]*n[2]),_=(d[0]*s[0]+d[2]*s[2])/(f*o*t.aspect),x=(d[0]*r[0]+d[1]*r[1]+d[2]*r[2])/(f*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 Ql(i,e){let t=ec(e),{right:n,up:s}=Mu(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 d of Su(i)){let f=[d[0]-o[0],d[1]-o[1],d[2]-o[2]],_=f[0]*t[0]+f[1]*t[1]+f[2]*t[2],x=Math.abs(f[0]*n[0]+f[2]*n[2]),m=Math.abs(f[0]*s[0]+f[1]*s[1]+f[2]*s[2]);a=Math.max(a,_+x/(yu*r*e.aspect),_+m/(yu*r))}if(c===3)break;let l=Q0(i,{target:o,dist:a},e),h=(l.x[0]+l.x[1])/2*a*r*e.aspect,u=(l.y[0]+l.y[1])/2*a*r;o=[o[0]+h*n[0]+u*s[0],o[1]+h*n[1]+u*s[1],o[2]+h*n[2]+u*s[2]]}return{target:o,dist:a}}var Un=30,nc=-32;function lr(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 wu(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(Ql(lr(i.filter(a=>(n.get(a.key)??0)<=o)),t));return s>1&&r.push(Ql(lr(i,{settle:1}),t)),r}function e_(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=e_(e,i.stop),r=2*s.dist*Math.tan(n(Un)/2),o=ya+(Un-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:nc*i.tilt}}function ic(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 vu={north:180,east:90,south:0,west:-90},cr={min:0,max:90};function Eu(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 Tu(i,e){if(i==="iso")return Ma(ar(e.events,1),e.fits,e.frame);let t=i==="top"?{elevation:cr.max,azimuth:vu.south}:{elevation:cr.min,azimuth:vu[i]},n=Ql(e.box,{...t,fov:Un,aspect:e.aspect});return{target:n.target,dist:n.dist,fov:Un,...t}}function Au(i){return i.fov===Un?i:{...i,fov:Un,dist:i.dist*Math.tan(xi(i.fov)/2)/Math.tan(xi(Un)/2)}}var bu={in:8,out:3};function Ru(i,e){let t=i[i.length-1].dist,n=Math.tan(xi(Un)/2)/Math.tan(xi(e)/2);return{min:t*n/bu.in,max:t*n*bu.out}}function Cu(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}),Kt={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)},t_="wood",n_="wood_dark",sc=Ke("#c2a27e",.7),Pu=Ke("#55534f",.5),Fn={slab:Ke("#bdb6ab",.9),column:Ke("#e6e1d8",.85),wall:Ke("#f2f0eb",.9),door:sc,"window:frame":Pu,"window:glass":Ke("#bcd6e0",.05,0,.4),"window:reveal":Pu,"window:sill":Kt.stone,"window:board":Kt.wood,"opening:lining":sc,"opening:casing":sc,opening:Ke("#e6e1d8",.85),furniture:Ke("#d6cec1",.9),roof:Ke("#9c958a",.9),"wall:demolish":Ke("#c8553d",.9,0,.3),stair:Kt[t_],"stair:rail":Kt[n_]},lb={"door:lining":{material:"door",srgb:Fn.door.srgb},"door:casing":{material:"door",srgb:Fn.door.srgb},"opening:lining":{material:"opening:lining",srgb:Fn["opening:lining"].srgb},"opening:casing":{material:"opening:casing",srgb:Fn["opening:casing"].srgb},"window:reveal":{material:"window:reveal",srgb:Fn["window:reveal"].srgb},"window:sill":{material:"window:sill",srgb:Fn["window:sill"].srgb},"window:board":{material:"window:board",srgb:Fn["window:board"].srgb}},Iu="#8f877d";var i_={timber:Ke("#cdb596",.6),tile:Ke("#e3e1db",.35),neutral:Ke("#e8e2d7",.9),carpeting:Kt.wool,stone:Kt.stone,deck:Kt.wood,paving:Ke("#ab9f87",.85),concrete:Ke("#c9c5be",.6)};var rc={gravel:Ke("#cbc3b4",.95),tarmac:Ke("#8c8984",.85),sand:Ke("#dcc9a3",.95)},cb={planting:Kt.foliage,deck:Kt.wood,gravel:rc.gravel,driveway:rc.tarmac,sand:rc.sand,soil:Kt.soil};var hb={picket:Ke("#eeebe4",.8),panel:Kt.wood,post:Kt.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 Lu(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 Du(i,e,t){let n=Kt[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 Nu(i,e,t){let n=i_[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],Uu=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 s_(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 r_(i,e){let t=Math.abs(i),n=Math.abs(e);for(;n!==0;)[t,n]=[n,t%n];return t}function ac(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 ys(i,e,t,n){let s=t-i,r=n-e,o=r_(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},${s_(s,r,i,e)}`}}var oc=(i,e)=>{for(let t=0;t<i.length;t++){let n=i[t]-e[t];if(n!==0)return n}return 0},hr=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 Fu(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 Ou(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(!Ta(t))return;let s=/^L(-?\d+)\//.exec(t.key)?.[1]??"",r=e.get(s);r?r.push(n):e.set(s,[n])}),hr(e).map(t=>e.get(t)??[])}function zu(i,e){let t=l_(i),n=i.map((s,r)=>Ta(s)?{...s,...c_(s,t[r])}:s);return{faces:t,lines:o_(n,e)}}function o_(i,e){let t=i.map(s=>Ta(s)?[]:void 0),n=i.map(()=>[]);for(let s of Bu(i))a_(i,s,n,e);return n.forEach((s,r)=>{if(!t[r])return;let o=s.map(a=>oc(a.slice(0,3),a.slice(3))<=0?a:[a[3],a[4],a[5],a[0],a[1],a[2]]).sort(oc);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 a_(i,e,t,n){let s=new Map,r=new Map,o=new Map,a=new Map,c=(_,x,m)=>{let p=`${_}|${x}`,w=s.get(p);w?w.edges.push(m):s.set(p,{line:x,plane:_,edges:[m]})},l=(_,x,m,p)=>{let w=oc(x,m)<0,[T,S]=w?[x,m]:[m,x],E=`${_}|${T[0]},${T[1]},${T[2]}|${S[0]},${S[1]},${S[2]}`,M=a.get(E);M?(M.net+=w?1:-1,M.nodes.push(p)):a.set(E,{a:T,b:S,net:w?1:-1,nodes:[p]})},h=(_,x,m,p)=>{let w=`h${_}:${x.key}`,T=r.get(w);if(T||(T={kind:"horizontal",y:_,alongX:x.dx!==0,other:new Map},r.set(w,T)),T.kind==="horizontal")for(let S of[m,p]){let[E,,M]=S;T.alongX?T.other.set(E,M):T.other.set(M,E)}return w},u=(_,x)=>_.dx!==0?x[0]:x[2],d=(_,x,m,p)=>_<x?{t0:_,t1:x,k:1,node:m,f:p}:{t0:x,t1:_,k:-1,node:m,f:p};for(let _ of e){let x=i[_],m=p=>[Math.round(x.positions[p*3]),Math.round(x.positions[p*3+1]),Math.round(x.positions[p*3+2])];for(let p=0;p+2<x.indices.length;p+=3){let w=[m(x.indices[p]),m(x.indices[p+1]),m(x.indices[p+2])],[T,S,E]=w,M=T[0],g=T[1],v=T[2],L=[[T,S],[S,E],[E,T]];if(g===S[1]&&g===E[1]){if(Fi(S[0]-M,S[2]-v,E[0]-M,E[2]-v)===0)continue;let z=`H${g}`;for(let[ee,q]of L){if(ee[0]===q[0]&&ee[2]===q[2])continue;let J=ys(ee[0],ee[2],q[0],q[2]);c(z,h(g,J,ee,q),d(u(J,ee),u(J,q),_,0))}continue}if(!(Fi(S[0]-M,S[2]-v,E[0]-M,E[2]-v)===0)){for(let[z,ee]of L)t[_].push([...z,...ee]);continue}let D=T[0]!==S[0]||T[2]!==S[2]?S:E;if(D[0]===M&&D[2]===v)continue;let N=ys(M,v,D[0],D[2]),B=`V${N.key}`;o.has(B)||o.set(B,[N.dx,N.dz]);let C=z=>u(N,z),W=Fi(C(S)-C(T),S[1]-g,C(E)-C(T),E[1]-g);if(W===0)continue;let Z=W>0?1:-1;for(let[z,ee]of L)if(z[0]===ee[0]&&z[2]===ee[2]){if(z[1]===ee[1])continue;let q=`v${z[0]},${z[2]}`;r.has(q)||r.set(q,{kind:"vertical",x:z[0],z:z[2]}),c(B,q,d(z[1],ee[1],_,Z))}else z[1]===ee[1]?c(B,h(z[1],N,z,ee),d(u(N,z),u(N,ee),_,Z)):l(B,z,ee,_)}}let f=new Map;for(let _ of hr(s)){let{line:x,plane:m,edges:p}=s.get(_),[w,T]=p;p.length===2&&T&&w.t0===T.t0&&w.t1===T.t1&&w.k!==T.k||Ea(p,(S,E,M)=>{let g=0;for(let B of M)g+=B.k;if(g===0)return;let v=new Map;for(let B of M)v.set(B.node,(v.get(B.node)??0)+B.k);let L=ur(M.filter(B=>v.get(B.node)!==0).map(B=>B.node)),R=ur(M.filter(B=>B.k===Math.sign(g)).map(B=>B.f)),D={t0:S,t1:E,nodes:L,plane:m,f:R.length===1?R[0]:0},N=f.get(x);N?N.push(D):f.set(x,[D])})}for(let _ of hr(f)){let x=f.get(_),m=r.get(_),p=[];Ea(x,(w,T,S)=>{if(m.kind==="vertical"&&S.length===2){let[g,v]=S,L=o.get(g.plane),R=o.get(v.plane);if(L&&R&&g.f!==0&&v.f!==0&&ac(L,R,g.f,v.f))return}let E=Ou(S.flatMap(g=>g.nodes),n),M=p[p.length-1];M&&M.t1===w&&M.node===E?M.t1=T:p.push({t0:w,t1:T,node:E})});for(let w of p){let T=S=>{if(m.kind==="vertical")return[m.x,S,m.z];let E=m.other.get(S);return m.alongX?[S,m.y,E]:[E,m.y,S]};t[w.node].push([...T(w.t0),...T(w.t1)])}}for(let _ of hr(a)){let{a:x,b:m,net:p,nodes:w}=a.get(_);p!==0&&t[Ou(w,n)].push([...x,...m])}}function ku(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 l_(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 Bu(i))u_(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 lc(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 c_(i,e,t="joined"){if(!e)return{positions:i.positions,indices:i.indices};let n=lc(i,e);return{positions:n.positions,indices:n.base.concat(t==="joined"?n.joined:n.alone)}}function h_(i){let e=i.map(s=>{let[r,o]=Fu(s.s),[a,c]=Fu(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 u_(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]),u=c(a.indices[l+1]),d=c(a.indices[l+2]),f=h[0],_=h[1],x=h[2];if(_===u[1]&&_===d[1]||Fi(u[0]-f,u[2]-x,d[0]-f,d[2]-x)!==0)continue;let m=h[0]!==u[0]||h[2]!==u[2]?u:d;if(m[0]===f&&m[2]===x)continue;let p=ys(f,x,m[0],m[2]),w=v=>p.dx!==0?v[0]:v[2],T=[w(h),w(u),w(d)],S=Fi(T[1]-T[0],u[1]-_,T[2]-T[0],d[1]-_);if(S===0)continue;let E=`V${p.key}`,M={node:o,tri:l/3,p:[h,u,d],f:S>0?1:-1,s:T},g=r.get(E);g?g.tris.push(M):r.set(E,{pl:p,tris:[M]})}}for(let o of hr(r)){let{tris:a}=r.get(o);if(!h_(a))continue;let c=ur(a.flatMap(S=>S.s)),l=ur(a.flatMap(S=>S.p.map(E=>E[1]))),h=new Map;for(let S of a)for(let E=0;E<3;E++)h.set(S.s[E],S.p[E]);let u=new Map(c.map((S,E)=>[S,E])),d=new Map(l.map((S,E)=>[S,E])),f=l.length-1,_=c.map(()=>[]);for(let S of a)for(let E=0;E<3;E++){let M=S.p[E],g=S.p[(E+1)%3];if(M[0]!==g[0]||M[2]!==g[2]||M[1]===g[1])continue;let v=u.get(S.s[E]),L=Math.min(M[1],g[1]),R=Math.max(M[1],g[1]);_[v].push([S.node,d.get(L),d.get(R),g[1]>M[1]?1:-1])}let x=new Map,m=new Map,p=[],w=new Int32Array(f),T=(S,E,M,g,v)=>{let L=l[g],R=l[g+1],D=(Z,z)=>{let ee=h.get(Z);return[ee[0],z,ee[2]]},[N,B,C,W]=[D(E,L),D(M,L),D(M,R),D(E,R)];v>0?S.push(...N,...B,...C,...N,...C,...W):S.push(...N,...C,...B,...N,...W,...C)};for(let S=0;S+1<c.length;S++){let E=_[S];for(let[v,L,R,D]of E){let N=x.get(v);N||(N=new Int32Array(f),x.set(v,N));let B=m.get(v)??0;for(let C=L;C<R;C++){let W=N[C],Z=W-D;N[C]=Z,w[C]=w[C]-D,W===0?B++:Z===0&&B--}m.set(v,B)}if(E.length>0){for(let v of[...x.keys()])m.get(v)===0&&(x.delete(v),m.delete(v));p=[...x.keys()].sort((v,L)=>v-L)}let M=c[S],g=c[S+1];for(let v=0;v<f;v++){let L=p.filter(N=>x.get(N)[v]!==0);if(L.length===0)continue;if(L.length===1){let N=L[0];T(t[N].add,M,g,v,x.get(N)[v]);continue}for(let N of L)T(t[N].alone,M,g,v,x.get(N)[v]),s.add(N),n(N,L[0]);let R=w[v];if(R===0)continue;let D=L.find(N=>Math.sign(x.get(N)[v])===Math.sign(R));T(t[D].joined,M,g,v,R)}}for(let S of a)t[S.node].hide.push(S.tri)}}var Wt=(i,e,t,n)=>Fi(i,e,t,n),Vu=i=>Number(/^L(-?\d+)\//.exec(i)?.[1]??0),Ht=i=>Math.round(i)+0,Wu=(i,e)=>Math.sqrt(Number(BigInt(i)*BigInt(i)+BigInt(e)*BigInt(e)));function Xu(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 Gu(i,e){let t=Wt(i.b[0]-i.a[0],i.b[1]-i.a[1],e[0]-i.a[0],e[1]-i.a[1]),n=Wt(i.c[0]-i.b[0],i.c[1]-i.b[1],e[0]-i.b[0],e[1]-i.b[1]),s=Wt(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 d_=2,Hu=65536;function f_(i,e,t,n,s){return Math.max(i.a[0],i.b[0],i.c[0])>=e&&Math.min(i.a[0],i.b[0],i.c[0])<=n&&Math.max(i.a[1],i.b[1],i.c[1])>=t&&Math.min(i.a[1],i.b[1],i.c[1])<=s&&!cc(i.a,i.b,i.c,e,t,n,s)&&!cc(i.b,i.c,i.a,e,t,n,s)&&!cc(i.c,i.a,i.b,e,t,n,s)}function cc(i,e,t,n,s,r,o){let a=e[0]-i[0],c=e[1]-i[1],l=Math.sign(Wt(a,c,t[0]-i[0],t[1]-i[1]));return l===0?!1:l*Wt(a,c,n-i[0],s-i[1])<0&&l*Wt(a,c,r-i[0],s-i[1])<0&&l*Wt(a,c,r-i[0],o-i[1])<0&&l*Wt(a,c,n-i[0],o-i[1])<0}var fc=class{constructor(e){pn(this,"x0");pn(this,"z0");pn(this,"w");pn(this,"h");pn(this,"kx");pn(this,"kz");pn(this,"cells");let[t,n,s,r]=[1/0,1/0,-1/0,-1/0];for(let h of e)for(let u of[h.a,h.b,h.c])u[0]<t&&(t=u[0]),u[0]>s&&(s=u[0]),u[1]<n&&(n=u[1]),u[1]>r&&(r=u[1]);if(this.x0=t,this.z0=n,e.length===0){[this.kx,this.kz,this.w,this.h]=[0,0,1,1],this.cells=[];return}let o=s-t+1,a=r-n+1,c=Math.min(Hu,d_*e.length),l=Math.sqrt(o*a/c);this.kx=Math.max(1,Math.min(c,Math.ceil(o/l))),this.kz=Math.max(1,Math.min(Math.floor(Hu/this.kx),Math.ceil(a/l))),this.w=Math.max(1,Math.ceil(o/this.kx)),this.h=Math.max(1,Math.ceil(a/this.kz)),this.cells=new Array(this.kx*this.kz);for(let h of e){let u=this.col(Math.min(h.a[0],h.b[0],h.c[0])),d=this.col(Math.max(h.a[0],h.b[0],h.c[0])),f=this.row(Math.min(h.a[1],h.b[1],h.c[1])),_=this.row(Math.max(h.a[1],h.b[1],h.c[1]));for(let x=f;x<=_;x++){let m=this.z0+x*this.h,p=m+this.h,[w,T]=p_(h,m,p),S=this.col(w),E=this.col(T),M=Math.min(d,E+1);for(let g=Math.max(u,S-1);g<=M;g++){let v=this.x0+g*this.w;if(!(g>S&&g<E||f_(h,v,m,v+this.w,p)))continue;let L=x*this.kx+g,R=this.cells[L];R?R.push(h):this.cells[L]=[h]}}}}col(e){return Math.floor((e-this.x0)/this.w)}row(e){return Math.floor((e-this.z0)/this.h)}at(e){if(this.kx===0)return[];let t=this.col(e[0]),n=this.row(e[1]);return t<0||n<0||t>=this.kx||n>=this.kz?[]:this.cells[n*this.kx+t]??[]}near(e,t,n,s){if(this.kx===0)return[];let r=c=>Math.max(0,Math.min(this.kx-1,c)),o=c=>Math.max(0,Math.min(this.kz-1,c)),a=new Set;for(let c=o(this.row(t));c<=o(this.row(s));c++)for(let l=r(this.col(e));l<=r(this.col(n));l++)for(let h of this.cells[c*this.kx+l]??[])a.add(h);return[...a]}};function p_(i,e,t){let n=1/0,s=-1/0,r=a=>{a<n&&(n=a),a>s&&(s=a)},o=[i.a,i.b,i.c];for(let a of o)a[1]>=e&&a[1]<=t&&r(a[0]);for(let a=0;a<3;a++){let c=o[a],l=o[(a+1)%3];if(c[1]!==l[1])for(let h of[e,t])(c[1]-h)*(l[1]-h)<0&&r(c[0]+(l[0]-c[0])*(h-c[1])/(l[1]-c[1]))}return n>s?[Math.min(i.a[0],i.b[0],i.c[0]),Math.max(i.a[0],i.b[0],i.c[0])]:[n,s]}function m_(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]],u=[s[a*3],s[a*3+2]],d=[s[c*3],s[c*3+2]],f=Wt(u[0]-h[0],u[1]-h[1],d[0]-h[0],d[1]-h[1]);(e?f<0:f>0)&&n.push({a:h,b:u,c:d,y:l})}}function g_(i,e){let t=new Map;for(let o of i){let a=ys(o.a[0],o.a[1],o.b[0],o.b[1]),c=`${a.dx},${a.dz}`,l=t.get(c);l?l.push(o):t.set(c,[o])}let n=new Map,s=(o,a)=>{let c=o.b[0]-o.a[0],l=o.b[1]-o.a[1],h=c*c+l*l,u=((a.a[0]-o.a[0])*c+(a.a[1]-o.a[1])*l)/h,d=((a.b[0]-o.a[0])*c+(a.b[1]-o.a[1])*l)/h,f=Math.max(0,Math.min(u,d)),_=Math.min(1,Math.max(u,d));return _>f?[f,_]:void 0},r=(o,a,c)=>{if(c>=e(o))return;let l=s(o,a);if(!l)return;let h=n.get(o);h?h.push({t0:l[0],t1:l[1],w:c}):n.set(o,[{t0:l[0],t1:l[1],w:c}])};for(let o of[...t.keys()].sort()){let a=t.get(o);if(a.length<2)continue;let[c,l]=o.split(",").map(Number),h=Wu(c,l),u=0;for(let x of a)u=Math.max(u,e(x));let d=2e3*u,f=a.map(x=>{let[m,p]=[(c*x.a[0]+l*x.a[1])/h,(c*x.b[0]+l*x.b[1])/h];return{s:x,off:(c*x.a[1]-l*x.a[0])/h,lo:Math.min(m,p),hi:Math.max(m,p)}}).sort((x,m)=>x.lo-m.lo||x.off-m.off),_=[];for(let x of f){_=_.filter(m=>m.hi>x.lo);for(let m of _){if(Math.abs(m.off-x.off)>d)continue;let[p,w]=[x.s,m.s],T=un(p),S=un(w);if(T.d[0]*S.d[0]+T.d[1]*S.d[1]>=0)continue;let E=w.a[0]-p.a[0],M=w.a[1]-p.a[1];if(Wt(T.d[0],T.d[1],E,M)>=0)continue;let g=BigInt(T.d[0])*BigInt(M)-BigInt(T.d[1])*BigInt(E),v=Math.max(0,-Number(g)/T.len/2e3);r(p,w,v),r(w,p,v)}_.push(x)}}return i.flatMap(o=>{let a=n.get(o);if(!a)return[o];let c=e(o),l=[...new Set([0,1,...a.flatMap(f=>[f.t0,f.t1])])].sort((f,_)=>f-_),h=un(o),u=f=>f===0?o.a:f===1?o.b:[Ht(o.a[0]+h.d[0]*f),Ht(o.a[1]+h.d[1]*f)],d=[];for(let f=0;f+1<l.length;f++){let[_,x]=[l[f],l[f+1]],m=(_+x)/2,p=c;for(let S of a)S.t0<=m&&m<=S.t1&&S.w<p&&(p=S.w);let w=d[d.length-1],T=w?w.w??c:void 0;w&&T===p?w.b=u(x):d.push({a:u(_),b:u(x),node:o.node,...p<c?{w:p}:{}})}return d.filter(f=>f.a[0]!==f.b[0]||f.a[1]!==f.b[1])})}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=ys(o[0],o[1],a[0],a[1]),l=c.dx!==0,h=l?o[0]:o[1],u=l?a[0]:a[1],d=e.get(c.key);d||(d={edges:[],at:new Map},e.set(c.key,d)),d.at.set(h,o),d.at.set(u,a),d.edges.push(h<u?{t0:h,t1:u,k:1,node:n}:{t0:u,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 f of c)l+=f.k,f.node<h&&(h=f.node);if(l===0)return;let u=l>0?1:-1,d=r[r.length-1];d&&d.t1===o&&d.s===u&&d.node===h?d.t1=a:r.push({t0:o,t1:a,s:u,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]],u=[s[c*3],s[c*3+2]];Wt(h[0]-l[0],h[1]-l[1],u[0]-l[0],u[1]-l[1])>0&&n.push({node:e,p:[l,h,u]})}}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(){pn(this,"positions",[]);pn(this,"weight",[]);pn(this,"caster",[]);pn(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=Wu(e,t);return{d:[e,t],len:n,u:[e/n,t/n],n:[t/n,-e/n]}}var xn=(i,e)=>[Ht(i[0]*e*1e3),Ht(i[1]*e*1e3)],vi=(i,e)=>[i[0]+e[0],i[1]+e[1]],__=8;function qu(i,e,t){return x_(i,e,t,n=>new fc(n))}function x_(i,e,t,n){let s={edges:0,convex:0,concave:0,flatJoints:0,dropped:0,furniture:0,fenceSides:0,stairEdges:0,triangles:0,probes:0,tests:0},r=[],o=[],a=[...new Set(i.map(h=>Vu(h.key)))].sort((h,u)=>h-u),c=a[0],l=xs.liftMm*1e3;for(let h of a){let u=i.map((M,g)=>[M,g]).filter(([M])=>Vu(M.key)===h),d=[];for(let[M]of u)(M.kind==="floor"||M.kind==="slab"||M.kind==="outdoor"||M.flat===!0)&&m_(M,!0,void 0,d);let f=n(d),_=h===c?e?.y:void 0,x=M=>{let g;for(let v of M){s.probes++;let L=_;for(let R of f.at(v))s.tests++,!(L!==void 0&&R.y<=L)&&Gu(R,v)&&(L=R.y);L!==void 0&&(g===void 0||L>g)&&(g=L)}return g===void 0?void 0:g+l},m=new dr,p=new dr,w=new dr,T=(M,g,v,L,R)=>{let D=m.vertex(M.a[0],L,M.a[1],1,R),N=m.vertex(M.b[0],L,M.b[1],1,R),B=m.vertex(M.b[0]+v[0],L,M.b[1]+v[1],0,R),C=m.vertex(M.a[0]+g[0],L,M.a[1]+g[1],0,R);m.quad(D,N,B,C)},S=(M,g,v)=>{let L=un(M),R=[Ht((M.a[0]+M.b[0])/2),Ht((M.a[1]+M.b[1])/2)],D=C=>[Ht(C[0]/2),Ht(C[1]/2)],N=[Ht((g[0]+v[0])/4),Ht((g[1]+v[1])/4)],B=[vi(R,N)];return L.len>2e3&&B.push(vi(vi(M.a,xn(L.u,1)),D(g)),vi(vi(M.b,xn(L.u,-1)),D(v))),B},E=u.filter(([M])=>M.band!==void 0&&(M.kind==="wall"||M.kind==="column"));if(E.length>0){let M=r.push(E.map(([O])=>O.key))-1,g=1/0;for(let[O]of E)g=Math.min(g,dc(O)[0]);let v=[];for(let[O,ae]of E)uc(O,ae,g,v);let L=n(v.map(O=>({a:O.p[0],b:O.p[1],c:O.p[2],y:g,node:O.node}))),R=O=>{s.probes++;for(let ae of L.at(O))if(s.tests++,Gu(ae,O))return!0;return!1},D=hc(v).flatMap(O=>{let ae=un(O),xe=[0,1],[H,ue]=[Math.min(O.a[0],O.b[0]),Math.max(O.a[0],O.b[0])],[de,we]=[Math.min(O.a[1],O.b[1]),Math.max(O.a[1],O.b[1])];for(let me of L.near(H,de,ue,we))if(me.node!==O.node){s.tests++;for(let[Ie,Ne]of[[me.a,me.b],[me.b,me.c],[me.c,me.a]]){let Oe=ae.d[0]*(Ne[1]-Ie[1])-ae.d[1]*(Ne[0]-Ie[0]);if(Oe===0)continue;let Ce=((Ie[0]-O.a[0])*(Ne[1]-Ie[1])-(Ie[1]-O.a[1])*(Ne[0]-Ie[0]))/Oe,We=((Ie[0]-O.a[0])*ae.d[1]-(Ie[1]-O.a[1])*ae.d[0])/Oe;Ce>0&&Ce<1&&We>=0&&We<=1&&xe.push(Ce)}}xe.sort((me,Ie)=>me-Ie);let fe=me=>me===0?O.a:me===1?O.b:[Ht(O.a[0]+ae.d[0]*me),Ht(O.a[1]+ae.d[1]*me)],Te=[],He;for(let me=0;me+1<xe.length;me++){let Ie=xe[me],Ne=xe[me+1];if(Ne-Ie<=0)continue;let Oe=fe((Ie+Ne)/2),Ce=!R(vi(Oe,xn(ae.n,1)));Ce&&He===void 0&&(He=Ie),Ce||(s.dropped++,He!==void 0&&Te.push({a:fe(He),b:fe(Ie),node:O.node}),He=void 0)}return He!==void 0&&Te.push({a:fe(He),b:O.b,node:O.node}),Te.filter(me=>me.a[0]!==me.b[0]||me.a[1]!==me.b[1])}),N=O=>O.w??i[O.node]?.band??0,B=g_(D,N),C=O=>`${O[0]},${O[1]}`,W=new Map,Z=new Map;for(let O of B)W.set(C(O.b),[...W.get(C(O.b))??[],O]),Z.set(C(O.a),[...Z.get(C(O.a))??[],O]);let z=new Map,ee=new Map;for(let O of B){let ae=xn(un(O).n,N(O));z.set(O,ae),ee.set(O,ae)}let q=[];for(let O of[...W.keys()].sort()){let ae=W.get(O)??[],xe=Z.get(O)??[];if(ae.length!==1||xe.length!==1)continue;let H=ae[0],ue=xe[0],de=un(H),we=un(ue),fe=Wt(de.d[0],de.d[1],we.d[0],we.d[1]);if(ac(de.d,we.d,1,1)){let Te=[de.n[0]+we.n[0],de.n[1]+we.n[1]],He=1+de.n[0]*we.n[0]+de.n[1]*we.n[1];ee.set(H,xn([Te[0]/He,Te[1]/He],N(H))),z.set(ue,xn([Te[0]/He,Te[1]/He],N(ue))),fe!==0&&s.flatJoints++;continue}fe!==0&&q.push({v:H.b,si:H,so:ue,turn:fe})}for(let O of B){let ae=z.get(O),xe=ee.get(O),H=x(S(O,ae,xe));H!==void 0&&(T(O,ae,xe,H,M),s.edges++)}let J=[];for(let[,O]of E){let ae=t?.[O]??[];for(let xe=0;xe+5<ae.length;xe+=6)ae[xe]===ae[xe+3]&&ae[xe+2]===ae[xe+5]&&ae[xe+1]!==ae[xe+4]&&J.push([ae[xe],ae[xe+2]])}for(let{v:O,si:ae,so:xe,turn:H}of q){let ue=un(ae),de=un(xe),we=N(ae),fe=N(xe);if(H>0){let Te=[];for(let Ce=0;Ce<16;Ce++){let We=[wa[Ce],Uu[Ce]];Wt(ue.n[0],ue.n[1],We[0],We[1])>0&&Wt(We[0],We[1],de.n[0],de.n[1])>0&&Te.push(We)}Te.sort((Ce,We)=>-Math.sign(Wt(Ce[0],Ce[1],We[0],We[1])));let He=[ue.n,...Te.slice(0,__-1),de.n],me=He.map((Ce,We)=>xn(Ce,we+(fe-we)*We/(He.length-1))),Ie=x(me.map(Ce=>vi(O,[Ht(Ce[0]/2),Ht(Ce[1]/2)])));if(Ie===void 0)continue;let Ne=m.vertex(O[0],Ie,O[1],1,M),Oe=me.map(Ce=>m.vertex(O[0]+Ce[0],Ie,O[1]+Ce[1],0,M));for(let Ce=0;Ce+1<Oe.length;Ce++)m.tri(Ne,Oe[Ce],Oe[Ce+1]);s.convex++}else{let Te=Math.max(we,fe),He=x([vi(O,xn([ue.n[0]+de.n[0],ue.n[1]+de.n[1]],Te/2))]);if(He===void 0)continue;let me=Math.min(dc(i[ae.node])[1],dc(i[xe.node])[1]);if(me<=He)continue;let Ie=(Ne,Oe,Ce)=>{let We=Ce?[-Ne.d[0],-Ne.d[1]]:Ne.d,vt=Math.min(Oe*1e3,Ne.len);for(let st of J){let rt=st[0]-O[0],_e=st[1]-O[1];if(Wt(We[0],We[1],rt,_e)!==0)continue;let ht=(We[0]*rt+We[1]*_e)/Ne.len;ht>0&&ht<vt&&(vt=ht)}if(vt<=0)return;let nt=xn(Ne.n,xs.liftMm),gt=xn(Ce?[-Ne.u[0],-Ne.u[1]]:Ne.u,vt/1e3),Xe=O[0]+nt[0],ft=O[1]+nt[1],It=p.vertex(Xe,He,ft,1,M),Ft=p.vertex(Xe,me,ft,1,M),F=p.vertex(Xe+gt[0],me,ft+gt[1],0,M),Lt=p.vertex(Xe+gt[0],He,ft+gt[1],0,M);p.quad(It,Ft,F,Lt)};Ie(ue,we,!0),Ie(de,fe,!1),s.concave++}}}for(let[M,g]of u){if(M.kind!=="fence"||M.band===void 0)continue;let v=r.push([M.key])-1,L=[...new Set(M.positions.filter((D,N)=>N%3===1))].sort((D,N)=>D-N),R=new Set;for(let D of L){let N=[];uc(M,g,D,N);for(let B of hc(N)){if(un(B).len<=2*M.band*1e3)continue;let C=`${B.a[0]},${B.a[1]},${B.b[0]},${B.b[1]}`;if(R.has(C))continue;R.add(C);let W=xn(un(B).n,M.band),Z=x(S(B,W,W));Z!==void 0&&(T(B,W,W,Z,v),s.fenceSides++)}}}for(let[M,g]of u){if(M.kind!=="stair"||M.band===void 0)continue;let v=r.push([M.key])-1,L=[];uc(M,g,void 0,L);for(let R of hc(L)){let D=xn(un(R).n,M.band),N=x(S(R,D,D));N!==void 0&&(T(R,D,D,N,v),s.stairEdges++)}}for(let[M]of u){if(M.kind!=="furniture"||M.band===void 0||M.positions.length===0)continue;let g=1/0,v=-1/0,L=1/0,R=-1/0;for(let J=0;J<M.positions.length;J+=3){let O=M.positions[J],ae=M.positions[J+2];O<g&&(g=O),O>v&&(v=O),ae<L&&(L=ae),ae>R&&(R=ae)}let D=M.band*1e3,N=Ht((g+v)/2),B=Ht((L+R)/2),C=x([[N,B],[N,L-D/2],[v+D/2,B],[N,R+D/2],[g-D/2,B]]);if(C===void 0)continue;let W=r.push([M.key])-1,Z=[[g,L],[v,L],[v,R],[g,R]],z=[[g-D,L-D],[v+D,L-D],[v+D,R+D],[g-D,R+D]],ee=Z.map(J=>w.vertex(J[0],C,J[1],1,W)),q=z.map(J=>w.vertex(J[0],C,J[1],0,W));for(let J=0;J<4;J++){let O=(J+1)%4;w.quad(ee[J],ee[O],q[O],q[J])}s.furniture++}for(let[M,g]of[["foot",m],["corner",p],["halo",w]])g.indices.length!==0&&(s.triangles+=g.indices.length/3,o.push({level:h,cls:M,...g}))}return{layers:o,casters:r,counts:s}}var fr=(i,e,t)=>`${i} ${i===1?e:t}`,Yu=i=>`${Number(i.toFixed(2))} m\xB2`;function pc(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 Zu(i,e,t){let n=pc(e,"rooms",wt.drawn),s=pc(e,"openings",wt.drawn),r=[],o=(a,c)=>{t>=a&&r.push(c)};return i.storeys!==void 0&&o(pc(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 ${Yu(i.areaNet)} (net)`}),o(n,{id:"area-centre",text:`floor area ${Yu(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 $u(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 y_=5,Aa=.9,mc={light:{background:"#f7f5f0",edge:"#8f877c",cap:Iu,colors:Object.fromEntries(Object.entries(Fn).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]},v_=12;function Ju(i,e,t,n={}){let s=mc[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=$s;let u=new Us;u.background=new Ye(s.background),u.add(new Xs(ti.sky,ti.ground,ti.hemi));let d=new ls(ti.keyColour,ti.key);d.position.set(...ti.keyFrom),u.add(d);let f=new ls(ti.fillColour,ti.fill);f.position.set(...ti.fillFrom),u.add(f);let _=new Map,x=[],m=new Map(e.events.map(P=>[P.key,P.rank])),{faces:p,lines:w}=zu(e.nodes,e.nodes.map(P=>m.get(P.key)??0)),T=[];for(let[P,ne]of e.nodes.entries()){let $=w[P],ie=p[P],oe=lc(ne,ie),re={...ne,positions:oe.positions,indices:oe.base},K=new Float32Array(re.positions.length),pe=1/0,Le=-1/0;for(let Ze=1;Ze<re.positions.length;Ze+=3)pe=Math.min(pe,re.positions[Ze]/1e3),Le=Math.max(Le,re.positions[Ze]/1e3);for(let Ze=0;Ze<re.positions.length;Ze+=3){let bt=re.positions[Ze]/1e3,Dt=re.positions[Ze+1]/1e3,lt=re.positions[Ze+2]/1e3;K[Ze]=bt,K[Ze+1]=Dt-pe,K[Ze+2]=lt}let ce=re.part?`${re.kind}:${re.part}`:re.kind,Ue=new Pn;Ue.position.y=pe+(re.lift??0);let tt=(Ze,bt,Dt,lt,nn,ze,dn=!0)=>{let fn=new $t;fn.setAttribute("position",Ze),fn.setIndex(bt),ze&&fn.computeVertexNormals();let On=ce==="wall:demolish",Bn=re.kind==="floor"||re.kind==="slab",vs=new as({color:new Ye(Dt),transparent:lt||On,opacity:lt?nn:On?.3:1,depthWrite:!On,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:re.kind==="outdoor"?8:Bn?4:1});x.push(fn,vs);let bs=new Qt(fn,vs);if(Ue.add(bs),re.kind!=="slab"&&!lt&&dn){let ni=new Vs(fn,30),pr=new Ci({color:new Ye(s.edge)});x.push(ni,pr),Ue.add(new rs(ni,pr))}return bs},xt=new Vt(K,3);if(re.groups){let Ze=0;for(let{slot:bt,count:Dt}of re.groups){let lt=re.indices.slice(Ze,Ze+Dt);if(Ze+=Dt,bt==="body")tt(xt,lt,s.colors[ce]??s.colors[re.kind]??r,!1,1,!1);else{let{alpha:nn}=Kt[bt];tt(xt,lt,Du(bt,e.theme,r),nn<1,nn,!1)}}}else if(re.colour)tt(xt,re.indices,Lu(re.colour,e.theme,mc.dark.colors.floor),!1,1,!0,re.kind!=="fence");else if(re.finish)tt(xt,re.indices,Nu(re.finish,e.theme,mc.dark.colors.floor),!1,1,!0);else if(ce==="wall"){let Ze=lt=>re.positions[lt*3+1]/1e3===Le,bt=[],Dt=[];for(let lt=0;lt<re.indices.length;lt+=3){let nn=re.indices.slice(lt,lt+3);(nn.every(Ze)?bt:Dt).push(...nn)}tt(xt,Dt,s.colors.wall??r,!1,1,!0,$===void 0),bt.length&&tt(xt,bt,s.cap,!1,1,!0,!1)}else{let Ze=ce==="window:glass";tt(xt,re.indices,s.colors[ce]??s.colors[re.kind]??r,Ze,Ze?Fn["window:glass"].alpha:1,!0,$===void 0)}if(ie&&ie.group>=0){let Ze=s.colors[ce]??s.colors[re.kind]??r;T.push({key:re.key,...oe.alone.length>0?{alone:tt(xt,oe.alone,Ze,!1,1,!0,!1)}:{},...oe.joined.length>0?{joined:tt(xt,oe.joined,Ze,!1,1,!0,!1)}:{},group:ie.group})}if($&&$.length>0){let Ze=new Float32Array($.length);for(let lt=0;lt<$.length;lt+=3)Ze[lt]=$[lt]/1e3,Ze[lt+1]=$[lt+1]/1e3-pe,Ze[lt+2]=$[lt+2]/1e3;let bt=new $t;bt.setAttribute("position",new Vt(Ze,3));let Dt=new Ci({color:new Ye(s.edge)});x.push(bt,Dt),Ue.add(new rs(bt,Dt))}Ue.visible=!1,u.add(Ue),_.set(re.key,{g:Ue,flat:Math.min(1,v_/Math.max(1e-6,Le-pe)),base:pe,lift:re.lift??0})}let[S,E,M,g]=e.viewBox,v=o/a,{cx:L,cz:R,ow:D,oh:N}=ic(e.viewBox,v),B=lr(e.nodes,{ghosts:!0}),C=new k(...B.lo),W=new k(...B.hi),Z=W.y+1e3,z,ee;if(e.ground){let P=e.ground.y/1e3,ne=Sa.marginMm,[$,ie,oe,re]=[C.x-ne,C.z-ne,W.x+ne,W.z+ne],K=new $t;K.setAttribute("position",new Vt(new Float32Array([$,P,ie,$,P,re,oe,P,re,oe,P,ie]),3)),K.setIndex([0,1,2,0,2,3]);let pe=new as({color:new Ye(e.theme==="light"?Sa.light:Sa.dark),transparent:!0,opacity:0,depthWrite:!0,flatShading:!0,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:16});x.push(K,pe),z=new Qt(K,pe),ee=pe,z.renderOrder=-1,z.visible=!1,u.add(z)}let q=e.theme==="light"?xs.alpha:xs.alphaDark,J=[],O=new Map(e.events.map(P=>[P.key,P])),ae=[];if(e.shadows!==!1){let P=qu(e.nodes,e.ground,w);ae=P.casters.map($=>{let ie;for(let oe of $){let re=O.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 Ue=0;Ue<$.positions.length;Ue++)ie[Ue]=$.positions[Ue]/1e3;let oe=new Vt(new Float32Array($.weight.length*4),4),re=new $t;re.setAttribute("position",new Vt(ie,3)),re.setAttribute("color",oe),re.setIndex($.indices);let K=new ss({color:16777215,vertexColors:!0,transparent:!0,depthWrite:!1,side:_n,polygonOffset:!0,polygonOffsetFactor:0,polygonOffsetUnits:-2});x.push(re,K);let pe=new Qt(re,K);pe.renderOrder=-.5,pe.visible=!1;let Le=new Pn;Le.add(pe),u.add(Le);let ce=P.casters[$.caster[0]]?.[0]??"";J.push({mesh:pe,group:Le,alpha:oe,weight:$.weight,caster:$.caster,scale:$.cls==="corner"?q.corner:$.cls==="halo"?q.furniture:q.floor,key:ce,lift:ne.get(ce)??0})}}let xe=new Pi(-D/2,D/2,N/2,-N/2,1,Z+1e5);xe.up.set(0,0,-1),xe.position.set(L,Z+5e4,R),xe.lookAt(L,0,R);let H=new qt(ya,v,10,1e9),ue=P=>wu(e.nodes,e.events,{elevation:e.elevation,azimuth:nc,fov:Un,aspect:P}),de=ue(v),we=W.clone().sub(C),fe=C.clone().add(W).multiplyScalar(.5),Te=P=>{let ne=Math.max(...P.map($=>fe.distanceTo(new k(...$.target))));return Math.max(we.length()*.75+ne+Math.hypot(fe.x-(S+M/2),fe.z-(E+g/2)),1e3)},He=Te(de.slice(0,ba(e.events))),me=Te(de),Ie=P=>P*Math.PI/180,Ne=new Image,Oe=new Promise(P=>{Ne.onload=()=>P(),Ne.onerror=()=>P()});Ne.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e.svg)))}`;let Ce=!1,We={cx:L,cz:R,oh:N,elevation:e.elevation},vt=new Map(e.events.map(P=>[P.key,P.storey??0])),nt=Math.max(1,...e.events.filter(P=>!P.hidden).map(P=>(P.storey??0)+1)),gt=nt,Xe="replay",ft=0,It=!1,Ft=we.length()/2,F=P=>Math.max(me,fe.distanceTo(P)+Ft);function Lt(P,ne){let{fov:$,dist:ie,elevation:oe,azimuth:re}=P,K=new k(...P.target),pe=Ie(oe);H.fov=$,H.near=Math.max(10,ie-ne),H.far=ie+ne,H.updateProjectionMatrix(),H.up.set(0,0,-1),pe<Ie(89.99)&&H.up.set(0,1,0),H.position.set(...tc([K.x,K.y,K.z],ie,{elevation:oe,azimuth:re})),H.lookAt(K)}let st={events:e.events,fits:de,frame:We,box:lr(e.nodes,{settle:1}),aspect:v},rt=new Map,_e=P=>{let ne=rt.get(P);if(ne)return ne;let $=Tu(P,st);return rt.set(P,$),$},ht,De=()=>{},Be=()=>{},A=()=>{},y=new Set,V=()=>{for(let P of y)P()},le=Math.max(1,Math.min(4,Math.floor(e.supersample??1)));function se(P){let ne=le*le,$=new Uint32Array(o*a*4);l.globalAlpha=1;for(let oe=0;oe<le;oe++)for(let re=0;re<le;re++){P.setViewOffset(o,a,(re+.5)/le-.5,(oe+.5)/le-.5,o,a),h.render(u,P),l.drawImage(c,0,0);let K=l.getImageData(0,0,o,a).data;for(let pe=0;pe<K.length;pe++)$[pe]=$[pe]+K[pe]}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 he(P){ft=P,It=!0,t&&e.facts&&$u(t,Zu(e.facts,e.events,Math.min(1,Math.max(0,P))));let ne=ar(e.events,P);z&&ee&&(z.visible=ne.ground>0,ee.opacity=ne.ground);for(let[oe,{g:re,flat:K,base:pe,lift:Le}]of _){let ce=ne.nodes.get(oe);re.visible=ce?.visible===!0&&(vt.get(oe)??0)<gt,re.scale.y=Math.max(K,ce?.rise??0),Le!==0&&(re.position.y=pe+va(Le,ne.settle))}let $=ku(p,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:K}of T){let pe=$.has(oe);re&&(re.visible=!pe),K&&(K.visible=pe)}if(J.length>0){let oe=Math.min(1,Math.max(0,P)),re=ae.map(K=>Xu(K,oe));for(let K of J){let pe=K.alpha.array,Le=!1,ce=!1;for(let Ue=0;Ue<K.weight.length;Ue++){let tt=Math.fround(K.weight[Ue]*K.scale*re[K.caster[Ue]]);pe[Ue*4+3]!==tt&&(pe[Ue*4+3]=tt,Le=!0),tt>0&&(ce=!0)}Le&&(K.alpha.needsUpdate=!0),K.mesh.visible=ce&&(vt.get(K.key)??0)<gt,K.group.position.y=va(K.lift,ne.settle)}}let ie=xe;if(Xe==="free"&&ht){let oe=H.position.distanceTo(ht.target),re=F(ht.target);H.near=Math.max(10,oe-re),H.far=oe+re,H.updateProjectionMatrix(),ie=H}else if(Xe!=="replay"&&Xe!=="free"){let oe=_e(Xe);Lt(oe,F(new k(...oe.target))),ie=H}else(ne.tilt>0||ne.dolly>0)&&(Lt(Ma(ne,de,We),ne.settle>0?me:He),ie=H);if(le===1?(h.render(u,ie),l.globalAlpha=1,l.drawImage(c,0,0)):se(ie),Xe==="replay"&&ne.svg>0&&Ne.complete&&Ne.naturalWidth>0){let oe=Math.min(o/M,a/g),re=M*oe,K=g*oe;l.globalAlpha=ne.svg,l.drawImage(Ne,(o-re)/2,(a-K)/2,re,K),l.globalAlpha=1}}function ye(P){Ce||(Xe!=="replay"&&(De(),Xe="replay",V()),he(P),A())}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?ge():void 0;function ge(){let P=new xa(H,i);ht=P,P.enableDamping=!1,P.screenSpacePanning=!1,P.minPolarAngle=Ie(90-cr.max),P.maxPolarAngle=Ie(90-cr.min);let ne=Cu(B);P.cursor.set(...ne.centre);let $=i.getAttribute("tabindex");i.tabIndex=0;let ie=0,oe=!1,re=!1,K=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,pe=()=>{ie=0,!(Ce||Xe!=="free")&&(P.update()||oe)&&(ie=requestAnimationFrame(pe))},Le=()=>{P.enableDamping&&!ie&&(ie=requestAnimationFrame(pe))};De=()=>{ie&&cancelAnimationFrame(ie),ie=0,oe=!1,P.enableDamping&&(re=!0,P.enableDamping=!1,P.update(),re=!1)};let ce=(ze,dn,fn)=>{H.fov=fn,H.up.set(0,1,0),H.position.set(...ze),P.target.set(...Eu(ze,dn,st.box.lo[1])),H.lookAt(P.target);let On=H.position.distanceTo(P.target),Bn=Ru(de,fn);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=!K()},Ue=()=>{if(Xe==="free")return;let ze=Xe==="replay"?Au(Ma(ar(e.events,ft),de,We)):_e(Xe);ce(tc(ze.target,ze.dist,ze),ze.target,ze.fov)},tt=()=>{Xe!=="free"&&(Xe="free",n.onTake?.(),V(),Le())},xt=!1;A=()=>{xt&&Ue()},P.addEventListener("start",()=>{Ue(),xt=!0,oe=!0}),P.addEventListener("end",()=>{xt=!1,oe=!1}),P.addEventListener("change",()=>{re||Ce||(xt=!1,tt(),he(ft))});let Ze=Ie(y_),bt=new Map([["ArrowLeft",()=>P.rotateLeft(Ze)],["ArrowRight",()=>P.rotateLeft(-Ze)],["ArrowUp",()=>P.rotateUp(Ze)],["ArrowDown",()=>P.rotateUp(-Ze)],["+",()=>P.dollyIn(Aa)],["=",()=>P.dollyIn(Aa)],["-",()=>P.dollyOut(Aa)],["_",()=>P.dollyOut(Aa)]]),Dt=ze=>{let dn=bt.get(ze.key);!dn||Ce||ze.ctrlKey||ze.metaKey||ze.altKey||(ze.preventDefault(),Ue(),dn(),Le())};i.addEventListener("keydown",Dt),Be=()=>{i.removeEventListener("keydown",Dt),P.dispose(),$===null?i.removeAttribute("tabindex"):i.setAttribute("tabindex",$),y.clear()};let lt=ze=>Math.min(nt,Math.max(1,Math.round(ze))),nn=()=>gt===nt?"all":gt;return{at:ze=>{Ce||he(ze)},preset:ze=>{Ce||(De(),Xe=ze,n.onTake?.(),V(),he(ft))},reset:()=>{Ce||(De(),Xe="replay",gt=nt,V(),he(ft))},storeys:nt,showStoreys:ze=>{Ce||(gt=lt(ze),V(),he(ft))},onChange:ze=>(y.add(ze),()=>y.delete(ze)),spin:ze=>{if(Ce||oe||!Number.isFinite(ze)||ze===0)return;Ue();let dn=P.enableDamping;P.enableDamping=!1,P.rotateLeft(Ie(ze)),P.update(),P.enableDamping=dn},get shown(){return gt},get camera(){return Xe},state:()=>Xe==="free"?{camera:"free",position:H.position.toArray(),target:P.target.toArray(),fov:H.fov,storeys:nn()}:{camera:Xe,storeys:nn()},restore:ze=>{Ce||(De(),gt=ze.storeys==="all"?nt:lt(ze.storeys),ze.camera==="free"&&ce(ze.position,ze.target,ze.fov),Xe=ze.camera,Xe!=="replay"&&n.onTake?.(),V())}}}function I(P,ne){if(Ce)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:L,cz:R,ow:D,oh:N}=ic(e.viewBox,v),xe.left=-D/2,xe.right=D/2,xe.top=N/2,xe.bottom=-N/2,xe.position.set(L,Z+5e4,R),xe.lookAt(L,0,R),xe.updateProjectionMatrix(),H.aspect=v,H.updateProjectionMatrix(),de=ue(v),He=Te(de.slice(0,ba(e.events))),me=Te(de),We={cx:L,cz:R,oh:N,elevation:e.elevation},st={...st,fits:de,frame:We,aspect:v},rt.clear(),It&&he(ft))}function te(){if(!Ce){De(),Ce=!0,Be();for(let P of x)P.dispose();h.dispose(),h.forceContextLoss()}}return{seek:ye,frameHash:j,ready:Oe,dispose:te,resize:I,...Q?{view:Q}:{}}}var b_=[["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"]],M_="Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";function Ku(i,e={}){let t=document.createElement("div");t.className="archlang-views",t.setAttribute("role","toolbar"),t.setAttribute("aria-label","3D view");let n=(h,u,d)=>{let f=document.createElement("button");return f.type="button",e.buttonClass&&(f.className=e.buttonClass),f.textContent=h,f.setAttribute("aria-label",u),f.addEventListener("click",d),f},s=[],r=[],o=()=>{for(let[h,u]of s)u.setAttribute("aria-pressed",String(i.camera===h));for(let[h,u]of r.entries())u.setAttribute("aria-pressed",String(h+1===i.shown))},a=h=>{};for(let[h,u,d]of b_){let f=n(u,d,()=>{i.preset(h),a(!0)});f.dataset.preset=h,s.push([h,f])}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 u=document.createElement("span");u.className="archlang-views-presets",u.id=`${e.hintId??"archlang-views"}-presets`,u.setAttribute("role","group"),u.setAttribute("aria-label","Preset views"),u.hidden=!0,u.append(...s.map(([,x])=>x));let d=n("View \u25BE","View presets: iso, top, and from north, east, south and west",()=>u.hidden?_():a(!1));d.setAttribute("aria-expanded","false"),d.setAttribute("aria-controls",u.id);let f=x=>{h.contains(x.target)||a(!1)},_=()=>{u.hidden=!1,d.setAttribute("aria-expanded","true"),document.addEventListener("pointerdown",f,!0),(s.find(([x])=>i.camera===x)?.[1]??s[0]?.[1])?.focus()};a=x=>{u.hidden||(u.hidden=!0,d.setAttribute("aria-expanded","false"),document.removeEventListener("pointerdown",f,!0),x&&d.focus())},h.addEventListener("keydown",x=>{x.key!=="Escape"||u.hidden||(x.preventDefault(),x.stopPropagation(),a(!0))}),h.addEventListener("focusout",x=>{h.contains(x.relatedTarget)||a(!1)}),h.append(d,u),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 u=1;u<=i.storeys;u++){let d=u===i.storeys,f=n(d?"All":u===1?"1":`1\u2013${u}`,d?"Show every storey":`Show storeys 1 to ${u}, hide the ones above`,()=>i.showStoreys(u));f.dataset.storeys=String(u),r.push(f),h.append(f)}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=M_,t.append(l),t}function S_(){let i=document.getElementById("archlang-replay-payload");return JSON.parse(i?.textContent??"{}")}function w_(){let i=S_(),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}=Ju(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(Ku(c,{hintId:"archlang-replay-hint"})),e.setAttribute("aria-describedby","archlang-replay-hint"));let h=document.getElementById("archlang-replay-t"),u=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0;window.__ready.then(()=>{if(window.__replayAutoplay===!1)return;if(u){r(1),h&&(h.value="1");return}let d,f=_=>{d??(d=_);let x=Math.min(1,(_-d)/(i.seconds*1e3));r(x),h&&(h.value=String(x)),n=x<1?requestAnimationFrame(f):0};n=requestAnimationFrame(f)}),h?.addEventListener("input",()=>{s(),r(Number(h.value))})}w_();})();