4054 lines
780 KiB
JavaScript
4054 lines
780 KiB
JavaScript
const Zi={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Ki={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},xd=0,pl=1,Md=2,gg=3,vg=0,dh=1,Sd=2,zn=3,Gn=0,Qt=1,Tn=2,_g=2,ii=0,is=1,ml=2,gl=3,vl=4,bd=5,Mi=100,Ad=101,wd=102,_l=103,yl=104,Td=200,Ed=201,Rd=202,Cd=203,wa=204,Ta=205,Ld=206,Pd=207,Id=208,Ud=209,Nd=210,Dd=211,Od=212,Bd=213,Fd=214,zd=0,kd=1,Hd=2,Or=3,Gd=4,Vd=5,Wd=6,Xd=7,eo=0,qd=1,Yd=2,si=0,Zd=1,Kd=2,jd=3,Jd=4,$d=5,Qd=6,xl="attached",ep="detached",Ga=300,oi=301,Ei=302,Br=303,Fr=304,ir=306,vn=1e3,At=1001,Ri=1002,dt=1003,zr=1004,yg=1004,qs=1005,xg=1005,at=1006,Va=1007,Mg=1007,Mn=1008,Sg=1008,ri=1009,tp=1010,np=1011,Wa=1012,ph=1013,ei=1014,En=1015,Ks=1016,mh=1017,gh=1018,Si=1020,ip=1021,nn=1023,sp=1024,rp=1025,bi=1026,cs=1027,op=1028,vh=1029,ap=1030,_h=1031,yh=1033,ma=33776,ga=33777,va=33778,_a=33779,Ml=35840,Sl=35841,bl=35842,Al=35843,xh=36196,wl=37492,Tl=37496,El=37808,Rl=37809,Cl=37810,Ll=37811,Pl=37812,Il=37813,Ul=37814,Nl=37815,Dl=37816,Ol=37817,Bl=37818,Fl=37819,zl=37820,kl=37821,ya=36492,Hl=36494,Gl=36495,cp=36283,Vl=36284,Wl=36285,Xl=36286,lp=2200,hp=2201,up=2202,js=2300,ls=2301,xa=2302,Qi=2400,es=2401,kr=2402,Xa=2500,Mh=2501,fp=0,Sh=1,Ea=2,bh=3e3,Ai=3001,dp=3200,pp=3201,Pi=0,mp=1,ln="",ht="srgb",Rt="srgb-linear",qa="display-p3",to="display-p3-linear",Hr="linear",lt="srgb",Gr="rec709",Vr="p3",bg=0,ji=7680,Ag=7681,wg=7682,Tg=7683,Eg=34055,Rg=34056,Cg=5386,Lg=512,Pg=513,Ig=514,Ug=515,Ng=516,Dg=517,Og=518,ql=519,gp=512,vp=513,_p=514,Ah=515,yp=516,xp=517,Mp=518,Sp=519,Wr=35044,Bg=35048,Fg=35040,zg=35045,kg=35049,Hg=35041,Gg=35046,Vg=35050,Wg=35042,Xg="100",Yl="300 es",Ra=1035,Rn=2e3,Js=2001;class Wn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e);e.target=null}}}const Gt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Eu=1234567;const ss=Math.PI/180,$s=180/Math.PI;function un(){const s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Gt[s&255]+Gt[s>>8&255]+Gt[s>>16&255]+Gt[s>>24&255]+"-"+Gt[e&255]+Gt[e>>8&255]+"-"+Gt[e>>16&15|64]+Gt[e>>24&255]+"-"+Gt[t&63|128]+Gt[t>>8&255]+"-"+Gt[t>>16&255]+Gt[t>>24&255]+Gt[n&255]+Gt[n>>8&255]+Gt[n>>16&255]+Gt[n>>24&255]).toLowerCase()}function yt(s,e,t){return Math.max(e,Math.min(t,s))}function wh(s,e){return(s%e+e)%e}function qg(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function Yg(s,e,t){return s!==e?(t-s)/(e-s):0}function Pr(s,e,t){return(1-t)*s+t*e}function Zg(s,e,t,n){return Pr(s,e,1-Math.exp(-t*n))}function Kg(s,e=1){return e-Math.abs(wh(s,e*2)-e)}function jg(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Jg(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function $g(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Qg(s,e){return s+Math.random()*(e-s)}function ev(s){return s*(.5-Math.random())}function tv(s){s!==void 0&&(Eu=s);let e=Eu+=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 nv(s){return s*ss}function iv(s){return s*$s}function Zl(s){return(s&s-1)===0&&s!==0}function sv(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Ca(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function rv(s,e,t,n,i){const 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),f=o((e-n)/2),d=r((n-e)/2),p=o((n-e)/2);switch(i){case"XYX":s.set(a*h,c*u,c*f,a*l);break;case"YZY":s.set(c*f,a*h,c*u,a*l);break;case"ZXZ":s.set(c*u,c*f,a*h,a*l);break;case"XZX":s.set(a*h,c*p,c*d,a*l);break;case"YXY":s.set(c*d,a*h,c*p,a*l);break;case"ZYZ":s.set(c*p,c*d,a*h,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function sn(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function We(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Ya={DEG2RAD:ss,RAD2DEG:$s,generateUUID:un,clamp:yt,euclideanModulo:wh,mapLinear:qg,inverseLerp:Yg,lerp:Pr,damp:Zg,pingpong:Kg,smoothstep:jg,smootherstep:Jg,randInt:$g,randFloat:Qg,randFloatSpread:ev,seededRandom:tv,degToRad:nv,radToDeg:iv,isPowerOfTwo:Zl,ceilPowerOfTwo:sv,floorPowerOfTwo:Ca,setQuaternionFromProperEuler:rv,normalize:We,denormalize:sn};class ae{constructor(e=0,t=0){ae.prototype.isVector2=!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("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("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Xe{constructor(e,t,n,i,r,o,a,c,l){Xe.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l)}set(e,t,n,i,r,o,a,c,l){const h=this.elements;return h[0]=e,h[1]=i,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){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],h=n[4],u=n[7],f=n[2],d=n[5],p=n[8],v=i[0],g=i[3],m=i[6],y=i[1],_=i[4],x=i[7],T=i[2],b=i[5],A=i[8];return r[0]=o*v+a*y+c*T,r[3]=o*g+a*_+c*b,r[6]=o*m+a*x+c*A,r[1]=l*v+h*y+u*T,r[4]=l*g+h*_+u*b,r[7]=l*m+h*x+u*A,r[2]=f*v+d*y+p*T,r[5]=f*g+d*_+p*b,r[8]=f*m+d*x+p*A,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],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+i*r*l-i*o*c}invert(){const e=this.elements,t=e[0],n=e[1],i=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,f=a*c-h*r,d=l*r-o*c,p=t*u+n*f+i*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return e[0]=u*v,e[1]=(i*l-h*n)*v,e[2]=(a*n-i*o)*v,e[3]=f*v,e[4]=(h*t-i*c)*v,e[5]=(i*r-a*t)*v,e[6]=d*v,e[7]=(n*c-l*t)*v,e[8]=(o*t-n*r)*v,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,o,a){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(bc.makeScale(e,t)),this}rotate(e){return this.premultiply(bc.makeRotation(-e)),this}translate(e,t){return this.premultiply(bc.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const bc=new Xe;function bp(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const ov={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Hs(s,e){return new ov[s](e)}function Xr(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Ap(){const s=Xr("canvas");return s.style.display="block",s}const Ru={};function Ir(s){s in Ru||(Ru[s]=!0,console.warn(s))}const Cu=new Xe().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Lu=new Xe().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),_o={[Rt]:{transfer:Hr,primaries:Gr,toReference:s=>s,fromReference:s=>s},[ht]:{transfer:lt,primaries:Gr,toReference:s=>s.convertSRGBToLinear(),fromReference:s=>s.convertLinearToSRGB()},[to]:{transfer:Hr,primaries:Vr,toReference:s=>s.applyMatrix3(Lu),fromReference:s=>s.applyMatrix3(Cu)},[qa]:{transfer:lt,primaries:Vr,toReference:s=>s.convertSRGBToLinear().applyMatrix3(Lu),fromReference:s=>s.applyMatrix3(Cu).convertLinearToSRGB()}},av=new Set([Rt,to]),rt={enabled:!0,_workingColorSpace:Rt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(s){if(!av.has(s))throw new Error(`Unsupported working color space, "${s}".`);this._workingColorSpace=s},convert:function(s,e,t){if(this.enabled===!1||e===t||!e||!t)return s;const n=_o[e].toReference,i=_o[t].fromReference;return i(n(s))},fromWorkingColorSpace:function(s,e){return this.convert(s,this._workingColorSpace,e)},toWorkingColorSpace:function(s,e){return this.convert(s,e,this._workingColorSpace)},getPrimaries:function(s){return _o[s].primaries},getTransfer:function(s){return s===ln?Hr:_o[s].transfer}};function Ys(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ac(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let _s;class Th{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{_s===void 0&&(_s=Xr("canvas")),_s.width=e.width,_s.height=e.height;const n=_s.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=_s}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Xr("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=Ys(r[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Ys(t[n]/255)*255):t[n]=Ys(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let cv=0;class ts{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:cv++}),this.uuid=un(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(wc(i[o].image)):r.push(wc(i[o]))}else r=wc(i);n.url=r}return t||(e.images[this.uuid]=n),n}}function wc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?Th.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let lv=0;class gt extends Wn{constructor(e=gt.DEFAULT_IMAGE,t=gt.DEFAULT_MAPPING,n=At,i=At,r=at,o=Mn,a=nn,c=ri,l=gt.DEFAULT_ANISOTROPY,h=ln){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:lv++}),this.uuid=un(),this.name="",this.source=new ts(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new ae(0,0),this.repeat=new ae(1,1),this.center=new ae(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xe,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof h=="string"?this.colorSpace=h:(Ir("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Ai?ht:ln),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){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)}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.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.6,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,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ga)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case vn:e.x=e.x-Math.floor(e.x);break;case At:e.x=e.x<0?0:1;break;case Ri: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 vn:e.y=e.y-Math.floor(e.y);break;case At:e.y=e.y<0?0:1;break;case Ri: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)}get encoding(){return Ir("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===ht?Ai:bh}set encoding(e){Ir("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ai?ht:ln}}gt.DEFAULT_IMAGE=null;gt.DEFAULT_MAPPING=Ga;gt.DEFAULT_ANISOTROPY=1;class nt{constructor(e=0,t=0,n=0,i=1){nt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("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("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const c=e.elements,l=c[0],h=c[4],u=c[8],f=c[1],d=c[5],p=c[9],v=c[2],g=c[6],m=c[10];if(Math.abs(h-f)<.01&&Math.abs(u-v)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+f)<.1&&Math.abs(u+v)<.1&&Math.abs(p+g)<.1&&Math.abs(l+d+m-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const _=(l+1)/2,x=(d+1)/2,T=(m+1)/2,b=(h+f)/4,A=(u+v)/4,L=(p+g)/4;return _>x&&_>T?_<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(_),i=b/n,r=A/n):x>T?x<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(x),n=b/i,r=L/i):T<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(T),n=A/r,i=L/r),this.set(n,i,r,t),this}let y=Math.sqrt((g-p)*(g-p)+(u-v)*(u-v)+(f-h)*(f-h));return Math.abs(y)<.001&&(y=1),this.x=(g-p)/y,this.y=(u-v)/y,this.z=(f-h)/y,this.w=Math.acos((l+d+m-1)/2),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=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class wp extends Wn{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new nt(0,0,e,t),this.scissorTest=!1,this.viewport=new nt(0,0,e,t);const i={width:e,height:t,depth:1};n.encoding!==void 0&&(Ir("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Ai?ht:ln),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:at,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},n),this.texture=new gt(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps,this.texture.internalFormat=n.internalFormat,this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,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.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new ts(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Cn extends wp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Za extends gt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=dt,this.minFilter=dt,this.wrapR=At,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class hv extends Cn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Za(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class Eh extends gt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=dt,this.minFilter=dt,this.wrapR=At,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class uv extends Cn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Eh(null,e,t,n),this.texture.isRenderTargetTexture=!0}}class fv extends Cn{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const r=this.texture;this.texture=[];for(let o=0;o<n;o++)this.texture[o]=r.clone(),this.texture[o].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.texture.length;i<r;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}copy(e){this.dispose(),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.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class Ot{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,o,a){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3];const f=r[o+0],d=r[o+1],p=r[o+2],v=r[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=f,e[t+1]=d,e[t+2]=p,e[t+3]=v;return}if(u!==v||c!==f||l!==d||h!==p){let g=1-a;const m=c*f+l*d+h*p+u*v,y=m>=0?1:-1,_=1-m*m;if(_>Number.EPSILON){const T=Math.sqrt(_),b=Math.atan2(T,m*y);g=Math.sin(g*b)/T,a=Math.sin(a*b)/T}const x=a*y;if(c=c*g+f*x,l=l*g+d*x,h=h*g+p*x,u=u*g+v*x,g===1-a){const T=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=T,l*=T,h*=T,u*=T}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[o],f=r[o+1],d=r[o+2],p=r[o+3];return e[t]=a*p+h*u+c*d-l*f,e[t+1]=c*p+h*f+l*u-a*d,e[t+2]=l*p+h*d+a*f-c*u,e[t+3]=h*p-a*u-c*f-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),h=a(i/2),u=a(r/2),f=c(n/2),d=c(i/2),p=c(r/2);switch(o){case"XYZ":this._x=f*h*u+l*d*p,this._y=l*d*u-f*h*p,this._z=l*h*p+f*d*u,this._w=l*h*u-f*d*p;break;case"YXZ":this._x=f*h*u+l*d*p,this._y=l*d*u-f*h*p,this._z=l*h*p-f*d*u,this._w=l*h*u+f*d*p;break;case"ZXY":this._x=f*h*u-l*d*p,this._y=l*d*u+f*h*p,this._z=l*h*p+f*d*u,this._w=l*h*u-f*d*p;break;case"ZYX":this._x=f*h*u-l*d*p,this._y=l*d*u+f*h*p,this._z=l*h*p-f*d*u,this._w=l*h*u+f*d*p;break;case"YZX":this._x=f*h*u+l*d*p,this._y=l*d*u+f*h*p,this._z=l*h*p-f*d*u,this._w=l*h*u-f*d*p;break;case"XZY":this._x=f*h*u-l*d*p,this._y=l*d*u-f*h*p,this._z=l*h*p+f*d*u,this._w=l*h*u+f*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],h=t[6],u=t[10],f=n+a+u;if(f>0){const d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(h-c)*d,this._y=(r-l)*d,this._z=(o-i)*d}else if(n>a&&n>u){const d=2*Math.sqrt(1+n-a-u);this._w=(h-c)/d,this._x=.25*d,this._y=(i+o)/d,this._z=(r+l)/d}else if(a>u){const d=2*Math.sqrt(1+a-n-u);this._w=(r-l)/d,this._x=(i+o)/d,this._y=.25*d,this._z=(c+h)/d}else{const d=2*Math.sqrt(1+u-n-a);this._w=(o-i)/d,this._x=(r+l)/d,this._y=(c+h)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(yt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+o*a+i*l-r*c,this._y=i*h+o*c+r*a-n*l,this._z=r*h+o*l+n*c-i*a,this._w=o*h-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const c=1-a*a;if(c<=Number.EPSILON){const d=1-t;return this._w=d*o+t*this._w,this._x=d*n+t*this._x,this._y=d*i+t*this._y,this._z=d*r+t*this._z,this.normalize(),this}const l=Math.sqrt(c),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,f=Math.sin(t*h)/l;return this._w=o*u+this._w*f,this._x=n*u+this._x*f,this._y=i*u+this._y*f,this._z=r*u+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{constructor(e=0,t=0,n=0){C.prototype.isVector3=!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("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("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(Pu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Pu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*i-a*n),h=2*(a*t-r*i),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=i+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){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Tc.copy(this).projectOnVector(e),this.sub(Tc)}reflect(e){return this.sub(Tc.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Tc=new C,Pu=new Ot;class wt{constructor(e=new C(1/0,1/0,1/0),t=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(bn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(bn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=bn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,bn):bn.fromBufferAttribute(r,o),bn.applyMatrix4(e.matrixWorld),this.expandByPoint(bn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),yo.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),yo.copy(n.boundingBox)),yo.applyMatrix4(e.matrixWorld),this.union(yo)}const i=e.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,bn),bn.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(_r),xo.subVectors(this.max,_r),ys.subVectors(e.a,_r),xs.subVectors(e.b,_r),Ms.subVectors(e.c,_r),ui.subVectors(xs,ys),fi.subVectors(Ms,xs),Bi.subVectors(ys,Ms);let t=[0,-ui.z,ui.y,0,-fi.z,fi.y,0,-Bi.z,Bi.y,ui.z,0,-ui.x,fi.z,0,-fi.x,Bi.z,0,-Bi.x,-ui.y,ui.x,0,-fi.y,fi.x,0,-Bi.y,Bi.x,0];return!Ec(t,ys,xs,Ms,xo)||(t=[1,0,0,0,1,0,0,0,1],!Ec(t,ys,xs,Ms,xo))?!1:(Mo.crossVectors(ui,fi),t=[Mo.x,Mo.y,Mo.z],Ec(t,ys,xs,Ms,xo))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,bn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(bn).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:(qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qn),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)}}const qn=[new C,new C,new C,new C,new C,new C,new C,new C],bn=new C,yo=new wt,ys=new C,xs=new C,Ms=new C,ui=new C,fi=new C,Bi=new C,_r=new C,xo=new C,Mo=new C,Fi=new C;function Ec(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){Fi.fromArray(s,r);const a=i.x*Math.abs(Fi.x)+i.y*Math.abs(Fi.y)+i.z*Math.abs(Fi.z),c=e.dot(Fi),l=t.dot(Fi),h=n.dot(Fi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}const dv=new wt,yr=new C,Rc=new C;class Tt{constructor(e=new C,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):dv.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;r<o;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;yr.subVectors(e,this.center);const t=yr.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(yr,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Rc.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yr.copy(e.center).add(Rc)),this.expandByPoint(yr.copy(e.center).sub(Rc))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Yn=new C,Cc=new C,So=new C,di=new C,Lc=new C,bo=new C,Pc=new C;class ds{constructor(e=new C,t=new C(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Yn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Yn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yn.copy(this.origin).addScaledVector(this.direction,t),Yn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Cc.copy(e).add(t).multiplyScalar(.5),So.copy(t).sub(e).normalize(),di.copy(this.origin).sub(Cc);const r=e.distanceTo(t)*.5,o=-this.direction.dot(So),a=di.dot(this.direction),c=-di.dot(So),l=di.lengthSq(),h=Math.abs(1-o*o);let u,f,d,p;if(h>0)if(u=o*c-a,f=o*a-c,p=r*h,u>=0)if(f>=-p)if(f<=p){const v=1/h;u*=v,f*=v,d=u*(u+o*f+2*a)+f*(o*u+f+2*c)+l}else f=r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*c)+l;else f=-r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*c)+l;else f<=-p?(u=Math.max(0,-(-o*r+a)),f=u>0?-r:Math.min(Math.max(-r,-c),r),d=-u*u+f*(f+2*c)+l):f<=p?(u=0,f=Math.min(Math.max(-r,-c),r),d=f*(f+2*c)+l):(u=Math.max(0,-(o*r+a)),f=u>0?r:Math.min(Math.max(-r,-c),r),d=-u*u+f*(f+2*c)+l);else f=o>0?-r:r,u=Math.max(0,-(o*f+a)),d=-u*u+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Cc).addScaledVector(So,f),d}intersectSphere(e,t){Yn.subVectors(e.center,this.origin);const n=Yn.dot(this.direction),i=Yn.dot(Yn)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,f=this.origin;return l>=0?(n=(e.min.x-f.x)*l,i=(e.max.x-f.x)*l):(n=(e.max.x-f.x)*l,i=(e.min.x-f.x)*l),h>=0?(r=(e.min.y-f.y)*h,o=(e.max.y-f.y)*h):(r=(e.max.y-f.y)*h,o=(e.min.y-f.y)*h),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),u>=0?(a=(e.min.z-f.z)*u,c=(e.max.z-f.z)*u):(a=(e.max.z-f.z)*u,c=(e.min.z-f.z)*u),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Yn)!==null}intersectTriangle(e,t,n,i,r){Lc.subVectors(t,e),bo.subVectors(n,e),Pc.crossVectors(Lc,bo);let o=this.direction.dot(Pc),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;di.subVectors(this.origin,e);const c=a*this.direction.dot(bo.crossVectors(di,bo));if(c<0)return null;const l=a*this.direction.dot(Lc.cross(di));if(l<0||c+l>o)return null;const h=-a*di.dot(Pc);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ne{constructor(e,t,n,i,r,o,a,c,l,h,u,f,d,p,v,g){Ne.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l,h,u,f,d,p,v,g)}set(e,t,n,i,r,o,a,c,l,h,u,f,d,p,v,g){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=i,m[1]=r,m[5]=o,m[9]=a,m[13]=c,m[2]=l,m[6]=h,m[10]=u,m[14]=f,m[3]=d,m[7]=p,m[11]=v,m[15]=g,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 Ne().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return 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){const t=this.elements,n=e.elements,i=1/Ss.setFromMatrixColumn(e,0).length(),r=1/Ss.setFromMatrixColumn(e,1).length(),o=1/Ss.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*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){const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const f=o*h,d=o*u,p=a*h,v=a*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=d+p*l,t[5]=f-v*l,t[9]=-a*c,t[2]=v-f*l,t[6]=p+d*l,t[10]=o*c}else if(e.order==="YXZ"){const f=c*h,d=c*u,p=l*h,v=l*u;t[0]=f+v*a,t[4]=p*a-d,t[8]=o*l,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=d*a-p,t[6]=v+f*a,t[10]=o*c}else if(e.order==="ZXY"){const f=c*h,d=c*u,p=l*h,v=l*u;t[0]=f-v*a,t[4]=-o*u,t[8]=p+d*a,t[1]=d+p*a,t[5]=o*h,t[9]=v-f*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){const f=o*h,d=o*u,p=a*h,v=a*u;t[0]=c*h,t[4]=p*l-d,t[8]=f*l+v,t[1]=c*u,t[5]=v*l+f,t[9]=d*l-p,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){const f=o*c,d=o*l,p=a*c,v=a*l;t[0]=c*h,t[4]=v-f*u,t[8]=p*u+d,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=d*u+p,t[10]=f-v*u}else if(e.order==="XZY"){const f=o*c,d=o*l,p=a*c,v=a*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=f*u+v,t[5]=o*h,t[9]=d*u-p,t[2]=p*u-d,t[6]=a*h,t[10]=v*u+f}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(pv,e,mv)}lookAt(e,t,n){const i=this.elements;return an.subVectors(e,t),an.lengthSq()===0&&(an.z=1),an.normalize(),pi.crossVectors(n,an),pi.lengthSq()===0&&(Math.abs(n.z)===1?an.x+=1e-4:an.z+=1e-4,an.normalize(),pi.crossVectors(n,an)),pi.normalize(),Ao.crossVectors(an,pi),i[0]=pi.x,i[4]=Ao.x,i[8]=an.x,i[1]=pi.y,i[5]=Ao.y,i[9]=an.y,i[2]=pi.z,i[6]=Ao.z,i[10]=an.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],h=n[1],u=n[5],f=n[9],d=n[13],p=n[2],v=n[6],g=n[10],m=n[14],y=n[3],_=n[7],x=n[11],T=n[15],b=i[0],A=i[4],L=i[8],M=i[12],w=i[1],O=i[5],H=i[9],K=i[13],I=i[2],F=i[6],k=i[10],te=i[14],J=i[3],$=i[7],le=i[11],ce=i[15];return r[0]=o*b+a*w+c*I+l*J,r[4]=o*A+a*O+c*F+l*$,r[8]=o*L+a*H+c*k+l*le,r[12]=o*M+a*K+c*te+l*ce,r[1]=h*b+u*w+f*I+d*J,r[5]=h*A+u*O+f*F+d*$,r[9]=h*L+u*H+f*k+d*le,r[13]=h*M+u*K+f*te+d*ce,r[2]=p*b+v*w+g*I+m*J,r[6]=p*A+v*O+g*F+m*$,r[10]=p*L+v*H+g*k+m*le,r[14]=p*M+v*K+g*te+m*ce,r[3]=y*b+_*w+x*I+T*J,r[7]=y*A+_*O+x*F+T*$,r[11]=y*L+_*H+x*k+T*le,r[15]=y*M+_*K+x*te+T*ce,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],h=e[2],u=e[6],f=e[10],d=e[14],p=e[3],v=e[7],g=e[11],m=e[15];return p*(+r*c*u-i*l*u-r*a*f+n*l*f+i*a*d-n*c*d)+v*(+t*c*d-t*l*f+r*o*f-i*o*d+i*l*h-r*c*h)+g*(+t*l*u-t*a*d-r*o*u+n*o*d+r*a*h-n*l*h)+m*(-i*a*h-t*c*u+t*a*f+i*o*u-n*o*f+n*c*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],f=e[10],d=e[11],p=e[12],v=e[13],g=e[14],m=e[15],y=u*g*l-v*f*l+v*c*d-a*g*d-u*c*m+a*f*m,_=p*f*l-h*g*l-p*c*d+o*g*d+h*c*m-o*f*m,x=h*v*l-p*u*l+p*a*d-o*v*d-h*a*m+o*u*m,T=p*u*c-h*v*c-p*a*f+o*v*f+h*a*g-o*u*g,b=t*y+n*_+i*x+r*T;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const A=1/b;return e[0]=y*A,e[1]=(v*f*r-u*g*r-v*i*d+n*g*d+u*i*m-n*f*m)*A,e[2]=(a*g*r-v*c*r+v*i*l-n*g*l-a*i*m+n*c*m)*A,e[3]=(u*c*r-a*f*r-u*i*l+n*f*l+a*i*d-n*c*d)*A,e[4]=_*A,e[5]=(h*g*r-p*f*r+p*i*d-t*g*d-h*i*m+t*f*m)*A,e[6]=(p*c*r-o*g*r-p*i*l+t*g*l+o*i*m-t*c*m)*A,e[7]=(o*f*r-h*c*r+h*i*l-t*f*l-o*i*d+t*c*d)*A,e[8]=x*A,e[9]=(p*u*r-h*v*r-p*n*d+t*v*d+h*n*m-t*u*m)*A,e[10]=(o*v*r-p*a*r+p*n*l-t*v*l-o*n*m+t*a*m)*A,e[11]=(h*a*r-o*u*r-h*n*l+t*u*l+o*n*d-t*a*d)*A,e[12]=T*A,e[13]=(h*v*i-p*u*i+p*n*f-t*v*f-h*n*g+t*u*g)*A,e[14]=(p*a*i-o*v*i-p*n*c+t*v*c+o*n*g-t*a*g)*A,e[15]=(o*u*i-h*a*i+h*n*c-t*u*c-o*n*f+t*a*f)*A,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,h=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,h*a+n,h*c-i*o,0,l*c-i*a,h*c+i*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,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,h=o+o,u=a+a,f=r*l,d=r*h,p=r*u,v=o*h,g=o*u,m=a*u,y=c*l,_=c*h,x=c*u,T=n.x,b=n.y,A=n.z;return i[0]=(1-(v+m))*T,i[1]=(d+x)*T,i[2]=(p-_)*T,i[3]=0,i[4]=(d-x)*b,i[5]=(1-(f+m))*b,i[6]=(g+y)*b,i[7]=0,i[8]=(p+_)*A,i[9]=(g-y)*A,i[10]=(1-(f+v))*A,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Ss.set(i[0],i[1],i[2]).length();const o=Ss.set(i[4],i[5],i[6]).length(),a=Ss.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],An.copy(this);const l=1/r,h=1/o,u=1/a;return An.elements[0]*=l,An.elements[1]*=l,An.elements[2]*=l,An.elements[4]*=h,An.elements[5]*=h,An.elements[6]*=h,An.elements[8]*=u,An.elements[9]*=u,An.elements[10]*=u,t.setFromRotationMatrix(An),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o,a=Rn){const c=this.elements,l=2*r/(t-e),h=2*r/(n-i),u=(t+e)/(t-e),f=(n+i)/(n-i);let d,p;if(a===Rn)d=-(o+r)/(o-r),p=-2*o*r/(o-r);else if(a===Js)d=-o/(o-r),p=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=d,c[14]=p,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,o,a=Rn){const c=this.elements,l=1/(t-e),h=1/(n-i),u=1/(o-r),f=(t+e)*l,d=(n+i)*h;let p,v;if(a===Rn)p=(o+r)*u,v=-2*u;else if(a===Js)p=r*u,v=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-d,c[2]=0,c[6]=0,c[10]=v,c[14]=-p,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ss=new C,An=new Ne,pv=new C(0,0,0),mv=new C(1,1,1),pi=new C,Ao=new C,an=new C,Iu=new Ne,Uu=new Ot;class no{constructor(e=0,t=0,n=0,i=no.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],h=i[9],u=i[2],f=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-yt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(yt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-yt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(f,d),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(yt(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,d));break;case"XZY":this._z=Math.asin(-yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Iu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Iu,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Uu.setFromEuler(this),this.setFromQuaternion(Uu,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}}no.DEFAULT_ORDER="XYZ";class Ka{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let gv=0;const Nu=new C,bs=new Ot,Zn=new Ne,wo=new C,xr=new C,vv=new C,_v=new Ot,Du=new C(1,0,0),Ou=new C(0,1,0),Bu=new C(0,0,1),yv={type:"added"},xv={type:"removed"};class tt extends Wn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gv++}),this.uuid=un(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tt.DEFAULT_UP.clone();const e=new C,t=new no,n=new Ot,i=new C(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:i},modelViewMatrix:{value:new Ne},normalMatrix:{value:new Xe}}),this.matrix=new Ne,this.matrixWorld=new Ne,this.matrixAutoUpdate=tt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Ka,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return bs.setFromAxisAngle(e,t),this.quaternion.multiply(bs),this}rotateOnWorldAxis(e,t){return bs.setFromAxisAngle(e,t),this.quaternion.premultiply(bs),this}rotateX(e){return this.rotateOnAxis(Du,e)}rotateY(e){return this.rotateOnAxis(Ou,e)}rotateZ(e){return this.rotateOnAxis(Bu,e)}translateOnAxis(e,t){return Nu.copy(e).applyQuaternion(this.quaternion),this.position.add(Nu.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Du,e)}translateY(e){return this.translateOnAxis(Ou,e)}translateZ(e){return this.translateOnAxis(Bu,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?wo.copy(e):wo.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),xr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt(xr,wo,this.up):Zn.lookAt(wo,xr,this.up),this.quaternion.setFromRotationMatrix(Zn),i&&(Zn.extractRotation(i.matrixWorld),bs.setFromRotationMatrix(Zn),this.quaternion.premultiply(bs.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(yv)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(xv)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Zn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Zn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Zn),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xr,e,vv),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(xr,_v,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const r=t[n];(r.matrixWorldAutoUpdate===!0||e===!0)&&r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t===!0){const i=this.children;for(let r=0,o=i.length;r<o;r++){const a=i[r];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));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?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];i.animations.push(r(e.animations,c))}}if(t){const a=o(e.geometries),c=o(e.materials),l=o(e.textures),h=o(e.images),u=o(e.shapes),f=o(e.skeletons),d=o(e.animations),p=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),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=i,n;function o(a){const c=[];for(const l in a){const 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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const i=e.children[n];this.add(i.clone())}return this}}tt.DEFAULT_UP=new C(0,1,0);tt.DEFAULT_MATRIX_AUTO_UPDATE=!0;tt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const wn=new C,Kn=new C,Ic=new C,jn=new C,As=new C,ws=new C,Fu=new C,Uc=new C,Nc=new C,Dc=new C;let To=!1;class tn{constructor(e=new C,t=new C,n=new C){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),wn.subVectors(e,t),i.cross(wn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){wn.subVectors(i,t),Kn.subVectors(n,t),Ic.subVectors(e,t);const o=wn.dot(wn),a=wn.dot(Kn),c=wn.dot(Ic),l=Kn.dot(Kn),h=Kn.dot(Ic),u=o*l-a*a;if(u===0)return r.set(0,0,0),null;const f=1/u,d=(l*c-a*h)*f,p=(o*h-a*c)*f;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,jn)===null?!1:jn.x>=0&&jn.y>=0&&jn.x+jn.y<=1}static getUV(e,t,n,i,r,o,a,c){return To===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),To=!0),this.getInterpolation(e,t,n,i,r,o,a,c)}static getInterpolation(e,t,n,i,r,o,a,c){return this.getBarycoord(e,t,n,i,jn)===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,jn.x),c.addScaledVector(o,jn.y),c.addScaledVector(a,jn.z),c)}static isFrontFacing(e,t,n,i){return wn.subVectors(n,t),Kn.subVectors(e,t),wn.cross(Kn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return wn.subVectors(this.c,this.b),Kn.subVectors(this.a,this.b),wn.cross(Kn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return To===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),To=!0),tn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return tn.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return tn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;As.subVectors(i,n),ws.subVectors(r,n),Uc.subVectors(e,n);const c=As.dot(Uc),l=ws.dot(Uc);if(c<=0&&l<=0)return t.copy(n);Nc.subVectors(e,i);const h=As.dot(Nc),u=ws.dot(Nc);if(h>=0&&u<=h)return t.copy(i);const f=c*u-h*l;if(f<=0&&c>=0&&h<=0)return o=c/(c-h),t.copy(n).addScaledVector(As,o);Dc.subVectors(e,r);const d=As.dot(Dc),p=ws.dot(Dc);if(p>=0&&d<=p)return t.copy(r);const v=d*l-c*p;if(v<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(ws,a);const g=h*p-d*u;if(g<=0&&u-h>=0&&d-p>=0)return Fu.subVectors(r,i),a=(u-h)/(u-h+(d-p)),t.copy(i).addScaledVector(Fu,a);const m=1/(g+v+f);return o=v*m,a=f*m,t.copy(n).addScaledVector(As,o).addScaledVector(ws,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Tp={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},mi={h:0,s:0,l:0},Eo={h:0,s:0,l:0};function Oc(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class Te{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ht){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,rt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=rt.workingColorSpace){return this.r=e,this.g=t,this.b=n,rt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=rt.workingColorSpace){if(e=wh(e,1),t=yt(t,0,1),n=yt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=Oc(o,r,e+1/3),this.g=Oc(o,r,e),this.b=Oc(o,r,e-1/3)}return rt.toWorkingColorSpace(this,i),this}setStyle(e,t=ht){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\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+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[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);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ht){const n=Tp[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.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=Ys(e.r),this.g=Ys(e.g),this.b=Ys(e.b),this}copyLinearToSRGB(e){return this.r=Ac(e.r),this.g=Ac(e.g),this.b=Ac(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ht){return rt.fromWorkingColorSpace(Vt.copy(this),e),Math.round(yt(Vt.r*255,0,255))*65536+Math.round(yt(Vt.g*255,0,255))*256+Math.round(yt(Vt.b*255,0,255))}getHexString(e=ht){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=rt.workingColorSpace){rt.fromWorkingColorSpace(Vt.copy(this),t);const n=Vt.r,i=Vt.g,r=Vt.b,o=Math.max(n,i,r),a=Math.min(n,i,r);let c,l;const h=(a+o)/2;if(a===o)c=0,l=0;else{const u=o-a;switch(l=h<=.5?u/(o+a):u/(2-o-a),o){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=rt.workingColorSpace){return rt.fromWorkingColorSpace(Vt.copy(this),t),e.r=Vt.r,e.g=Vt.g,e.b=Vt.b,e}getStyle(e=ht){rt.fromWorkingColorSpace(Vt.copy(this),e);const t=Vt.r,n=Vt.g,i=Vt.b;return e!==ht?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(mi),this.setHSL(mi.h+e,mi.s+t,mi.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(mi),e.getHSL(Eo);const n=Pr(mi.h,Eo.h,t),i=Pr(mi.s,Eo.s,t),r=Pr(mi.l,Eo.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Vt=new Te;Te.NAMES=Tp;let Mv=0;class Et extends Wn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Mv++}),this.uuid=un(),this.name="",this.type="Material",this.blending=is,this.side=Gn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wa,this.blendDst=Ta,this.blendEquation=Mi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Te(0,0,0),this.blendAlpha=0,this.depthFunc=Or,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ql,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ji,this.stencilZFail=ji,this.stencilZPass=ji,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.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}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==is&&(n.blending=this.blending),this.side!==Gn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==wa&&(n.blendSrc=this.blendSrc),this.blendDst!==Ta&&(n.blendDst=this.blendDst),this.blendEquation!==Mi&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Or&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ql&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ji&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ji&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ji&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const o=[];for(const a in r){const c=r[a];delete c.metadata,o.push(c)}return o}if(t){const r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class hn extends Et{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Te(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.combine=eo,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.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Qn=Sv();function Sv(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:o,offsetTable:a}}function en(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=yt(s,-65504,65504),Qn.floatView[0]=s;const e=Qn.uint32View[0],t=e>>23&511;return Qn.baseTable[t]+((e&8388607)>>Qn.shiftTable[t])}function Lr(s){const e=s>>10;return Qn.uint32View[0]=Qn.mantissaTable[Qn.offsetTable[e]+(s&1023)]+Qn.exponentTable[e],Qn.floatView[0]}const bv={toHalfFloat:en,fromHalfFloat:Lr},bt=new C,Ro=new ae;class Fe{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Wr,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=En,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Ro.fromBufferAttribute(this,t),Ro.applyMatrix3(e),this.setXY(t,Ro.x,Ro.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)bt.fromBufferAttribute(this,t),bt.applyMatrix3(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)bt.fromBufferAttribute(this,t),bt.applyMatrix4(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bt.fromBufferAttribute(this,t),bt.applyNormalMatrix(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bt.fromBufferAttribute(this,t),bt.transformDirection(e),this.setXYZ(t,bt.x,bt.y,bt.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=sn(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=We(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),r=We(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Wr&&(e.usage=this.usage),e}}class Av extends Fe{constructor(e,t,n){super(new Int8Array(e),t,n)}}class wv extends Fe{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class Tv extends Fe{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class Ev extends Fe{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Rh extends Fe{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Rv extends Fe{constructor(e,t,n){super(new Int32Array(e),t,n)}}class Ch extends Fe{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Cv extends Fe{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Lr(this.array[e*this.itemSize]);return this.normalized&&(t=sn(t,this.array)),t}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize]=en(t),this}getY(e){let t=Lr(this.array[e*this.itemSize+1]);return this.normalized&&(t=sn(t,this.array)),t}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+1]=en(t),this}getZ(e){let t=Lr(this.array[e*this.itemSize+2]);return this.normalized&&(t=sn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+2]=en(t),this}getW(e){let t=Lr(this.array[e*this.itemSize+3]);return this.normalized&&(t=sn(t,this.array)),t}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.array[e*this.itemSize+3]=en(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.array[e+0]=en(t),this.array[e+1]=en(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.array[e+0]=en(t),this.array[e+1]=en(n),this.array[e+2]=en(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),r=We(r,this.array)),this.array[e+0]=en(t),this.array[e+1]=en(n),this.array[e+2]=en(i),this.array[e+3]=en(r),this}}class Ee extends Fe{constructor(e,t,n){super(new Float32Array(e),t,n)}}class Lv extends Fe{constructor(e,t,n){super(new Float64Array(e),t,n)}}let Pv=0;const pn=new Ne,Bc=new tt,Ts=new C,cn=new wt,Mr=new wt,Ut=new C;class Be extends Wn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Pv++}),this.uuid=un(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(bp(e)?Ch:Rh)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Xe().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return pn.makeRotationFromQuaternion(e),this.applyMatrix4(pn),this}rotateX(e){return pn.makeRotationX(e),this.applyMatrix4(pn),this}rotateY(e){return pn.makeRotationY(e),this.applyMatrix4(pn),this}rotateZ(e){return pn.makeRotationZ(e),this.applyMatrix4(pn),this}translate(e,t,n){return pn.makeTranslation(e,t,n),this.applyMatrix4(pn),this}scale(e,t,n){return pn.makeScale(e,t,n),this.applyMatrix4(pn),this}lookAt(e){return Bc.lookAt(e),Bc.updateMatrix(),this.applyMatrix4(Bc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ts).negate(),this.translate(Ts.x,Ts.y,Ts.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Ee(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){const r=t[n];cn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ut.addVectors(this.boundingBox.min,cn.min),this.boundingBox.expandByPoint(Ut),Ut.addVectors(this.boundingBox.max,cn.max),this.boundingBox.expandByPoint(Ut)):(this.boundingBox.expandByPoint(cn.min),this.boundingBox.expandByPoint(cn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 Tt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new C,1/0);return}if(e){const n=this.boundingSphere.center;if(cn.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){const a=t[r];Mr.setFromBufferAttribute(a),this.morphTargetsRelative?(Ut.addVectors(cn.min,Mr.min),cn.expandByPoint(Ut),Ut.addVectors(cn.max,Mr.max),cn.expandByPoint(Ut)):(cn.expandByPoint(Mr.min),cn.expandByPoint(Mr.max))}cn.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)Ut.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(Ut));if(t)for(let r=0,o=t.length;r<o;r++){const a=t[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)Ut.fromBufferAttribute(a,l),c&&(Ts.fromBufferAttribute(e,l),Ut.add(Ts)),i=Math.max(i,n.distanceToSquared(Ut))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.array,i=t.position.array,r=t.normal.array,o=t.uv.array,a=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Fe(new Float32Array(4*a),4));const c=this.getAttribute("tangent").array,l=[],h=[];for(let w=0;w<a;w++)l[w]=new C,h[w]=new C;const u=new C,f=new C,d=new C,p=new ae,v=new ae,g=new ae,m=new C,y=new C;function _(w,O,H){u.fromArray(i,w*3),f.fromArray(i,O*3),d.fromArray(i,H*3),p.fromArray(o,w*2),v.fromArray(o,O*2),g.fromArray(o,H*2),f.sub(u),d.sub(u),v.sub(p),g.sub(p);const K=1/(v.x*g.y-g.x*v.y);isFinite(K)&&(m.copy(f).multiplyScalar(g.y).addScaledVector(d,-v.y).multiplyScalar(K),y.copy(d).multiplyScalar(v.x).addScaledVector(f,-g.x).multiplyScalar(K),l[w].add(m),l[O].add(m),l[H].add(m),h[w].add(y),h[O].add(y),h[H].add(y))}let x=this.groups;x.length===0&&(x=[{start:0,count:n.length}]);for(let w=0,O=x.length;w<O;++w){const H=x[w],K=H.start,I=H.count;for(let F=K,k=K+I;F<k;F+=3)_(n[F+0],n[F+1],n[F+2])}const T=new C,b=new C,A=new C,L=new C;function M(w){A.fromArray(r,w*3),L.copy(A);const O=l[w];T.copy(O),T.sub(A.multiplyScalar(A.dot(O))).normalize(),b.crossVectors(L,O);const K=b.dot(h[w])<0?-1:1;c[w*4]=T.x,c[w*4+1]=T.y,c[w*4+2]=T.z,c[w*4+3]=K}for(let w=0,O=x.length;w<O;++w){const H=x[w],K=H.start,I=H.count;for(let F=K,k=K+I;F<k;F+=3)M(n[F+0]),M(n[F+1]),M(n[F+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new Fe(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let f=0,d=n.count;f<d;f++)n.setXYZ(f,0,0,0);const i=new C,r=new C,o=new C,a=new C,c=new C,l=new C,h=new C,u=new C;if(e)for(let f=0,d=e.count;f<d;f+=3){const p=e.getX(f+0),v=e.getX(f+1),g=e.getX(f+2);i.fromBufferAttribute(t,p),r.fromBufferAttribute(t,v),o.fromBufferAttribute(t,g),h.subVectors(o,r),u.subVectors(i,r),h.cross(u),a.fromBufferAttribute(n,p),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,g),a.add(h),c.add(h),l.add(h),n.setXYZ(p,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(g,l.x,l.y,l.z)}else for(let f=0,d=t.count;f<d;f+=3)i.fromBufferAttribute(t,f+0),r.fromBufferAttribute(t,f+1),o.fromBufferAttribute(t,f+2),h.subVectors(o,r),u.subVectors(i,r),h.cross(u),n.setXYZ(f+0,h.x,h.y,h.z),n.setXYZ(f+1,h.x,h.y,h.z),n.setXYZ(f+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Ut.fromBufferAttribute(e,t),Ut.normalize(),e.setXYZ(t,Ut.x,Ut.y,Ut.z)}toNonIndexed(){function e(a,c){const l=a.array,h=a.itemSize,u=a.normalized,f=new l.constructor(c.length*h);let d=0,p=0;for(let v=0,g=c.length;v<g;v++){a.isInterleavedBufferAttribute?d=c[v]*a.data.stride+a.offset:d=c[v]*h;for(let m=0;m<h;m++)f[p++]=l[d++]}return new Fe(f,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Be,n=this.index.array,i=this.attributes;for(const a in i){const c=i[a],l=e(c,n);t.setAttribute(a,l)}const r=this.morphAttributes;for(const a in r){const c=[],l=r[a];for(let h=0,u=l.length;h<u;h++){const f=l[h],d=e(f,n);c.push(d)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){const e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const c in n){const l=n[c];e.data.attributes[c]=l.toJSON(e.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,f=l.length;u<f;u++){const d=l[u];h.push(d.toJSON(e.data))}h.length>0&&(i[c]=h,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(t))}const r=e.morphAttributes;for(const l in r){const h=[],u=r[l];for(let f=0,d=u.length;f<d;f++)h.push(u[f].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;const o=e.groups;for(let l=0,h=o.length;l<h;l++){const u=o[l];this.addGroup(u.start,u.count,u.materialIndex)}const a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const zu=new Ne,zi=new ds,Co=new Tt,ku=new C,Es=new C,Rs=new C,Cs=new C,Fc=new C,Lo=new C,Po=new ae,Io=new ae,Uo=new ae,Hu=new C,Gu=new C,Vu=new C,No=new C,Do=new C;class ft extends tt{constructor(e=new Be,t=new hn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(r&&a){Lo.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=a[c],u=r[c];h!==0&&(Fc.fromBufferAttribute(u,e),o?Lo.addScaledVector(Fc,h):Lo.addScaledVector(Fc.sub(t),h))}t.add(Lo)}return t}raycast(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Co.copy(n.boundingSphere),Co.applyMatrix4(r),zi.copy(e.ray).recast(e.near),!(Co.containsPoint(zi.origin)===!1&&(zi.intersectSphere(Co,ku)===null||zi.origin.distanceToSquared(ku)>(e.far-e.near)**2))&&(zu.copy(r).invert(),zi.copy(e.ray).applyMatrix4(zu),!(n.boundingBox!==null&&zi.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,zi)))}_computeIntersections(e,t,n){let i;const 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,f=r.groups,d=r.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,v=f.length;p<v;p++){const g=f[p],m=o[g.materialIndex],y=Math.max(g.start,d.start),_=Math.min(a.count,Math.min(g.start+g.count,d.start+d.count));for(let x=y,T=_;x<T;x+=3){const b=a.getX(x),A=a.getX(x+1),L=a.getX(x+2);i=Oo(this,m,e,n,l,h,u,b,A,L),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),v=Math.min(a.count,d.start+d.count);for(let g=p,m=v;g<m;g+=3){const y=a.getX(g),_=a.getX(g+1),x=a.getX(g+2);i=Oo(this,o,e,n,l,h,u,y,_,x),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let p=0,v=f.length;p<v;p++){const g=f[p],m=o[g.materialIndex],y=Math.max(g.start,d.start),_=Math.min(c.count,Math.min(g.start+g.count,d.start+d.count));for(let x=y,T=_;x<T;x+=3){const b=x,A=x+1,L=x+2;i=Oo(this,m,e,n,l,h,u,b,A,L),i&&(i.faceIndex=Math.floor(x/3),i.face.materialIndex=g.materialIndex,t.push(i))}}else{const p=Math.max(0,d.start),v=Math.min(c.count,d.start+d.count);for(let g=p,m=v;g<m;g+=3){const y=g,_=g+1,x=g+2;i=Oo(this,o,e,n,l,h,u,y,_,x),i&&(i.faceIndex=Math.floor(g/3),t.push(i))}}}}function Iv(s,e,t,n,i,r,o,a){let c;if(e.side===Qt?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,e.side===Gn,a),c===null)return null;Do.copy(a),Do.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Do);return l<t.near||l>t.far?null:{distance:l,point:Do.clone(),object:s}}function Oo(s,e,t,n,i,r,o,a,c,l){s.getVertexPosition(a,Es),s.getVertexPosition(c,Rs),s.getVertexPosition(l,Cs);const h=Iv(s,e,t,n,Es,Rs,Cs,No);if(h){i&&(Po.fromBufferAttribute(i,a),Io.fromBufferAttribute(i,c),Uo.fromBufferAttribute(i,l),h.uv=tn.getInterpolation(No,Es,Rs,Cs,Po,Io,Uo,new ae)),r&&(Po.fromBufferAttribute(r,a),Io.fromBufferAttribute(r,c),Uo.fromBufferAttribute(r,l),h.uv1=tn.getInterpolation(No,Es,Rs,Cs,Po,Io,Uo,new ae),h.uv2=h.uv1),o&&(Hu.fromBufferAttribute(o,a),Gu.fromBufferAttribute(o,c),Vu.fromBufferAttribute(o,l),h.normal=tn.getInterpolation(No,Es,Rs,Cs,Hu,Gu,Vu,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a,b:c,c:l,normal:new C,materialIndex:0};tn.getNormal(Es,Rs,Cs,u.normal),h.face=u}return h}class ps extends Be{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const c=[],l=[],h=[],u=[];let f=0,d=0;p("z","y","x",-1,-1,n,t,e,o,r,0),p("z","y","x",1,-1,n,t,-e,o,r,1),p("x","z","y",1,1,e,n,t,i,o,2),p("x","z","y",1,-1,e,n,-t,i,o,3),p("x","y","z",1,-1,e,t,n,i,r,4),p("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Ee(l,3)),this.setAttribute("normal",new Ee(h,3)),this.setAttribute("uv",new Ee(u,2));function p(v,g,m,y,_,x,T,b,A,L,M){const w=x/A,O=T/L,H=x/2,K=T/2,I=b/2,F=A+1,k=L+1;let te=0,J=0;const $=new C;for(let le=0;le<k;le++){const ce=le*O-K;for(let ge=0;ge<F;ge++){const Z=ge*w-H;$[v]=Z*y,$[g]=ce*_,$[m]=I,l.push($.x,$.y,$.z),$[v]=0,$[g]=0,$[m]=b>0?1:-1,h.push($.x,$.y,$.z),u.push(ge/A),u.push(1-le/L),te+=1}}for(let le=0;le<L;le++)for(let ce=0;ce<A;ce++){const ge=f+ce+F*le,Z=f+ce+F*(le+1),U=f+(ce+1)+F*(le+1),N=f+(ce+1)+F*le;c.push(ge,Z,N),c.push(Z,U,N),J+=6}a.addGroup(d,J,M),d+=J,f+=te}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ps(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Qs(s){const e={};for(const t in s){e[t]={};for(const n in s[t]){const i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function Kt(s){const e={};for(let t=0;t<s.length;t++){const n=Qs(s[t]);for(const i in n)e[i]=n[i]}return e}function Uv(s){const e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function Ep(s){return s.getRenderTarget()===null?s.outputColorSpace:rt.workingColorSpace}const ja={clone:Qs,merge:Kt};var Nv=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,Dv=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class Ln extends Et{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Nv,this.fragmentShader=Dv,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1,clipCullDistance:!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=Qs(e.uniforms),this.uniformsGroups=Uv(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}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const i in this.uniforms){const o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={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;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Ja extends tt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ne,this.projectionMatrix=new Ne,this.projectionMatrixInverse=new Ne,this.coordinateSystem=Rn}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.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class Nt extends Ja{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=$s*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ss*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return $s*2*Math.atan(Math.tan(ss*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,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=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ss*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/c,t-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Ls=-90,Ps=1;class Rp extends tt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Nt(Ls,Ps,e,t);i.layers=this.layers,this.add(i);const r=new Nt(Ls,Ps,e,t);r.layers=this.layers,this.add(r);const o=new Nt(Ls,Ps,e,t);o.layers=this.layers,this.add(o);const a=new Nt(Ls,Ps,e,t);a.layers=this.layers,this.add(a);const c=new Nt(Ls,Ps,e,t);c.layers=this.layers,this.add(c);const l=new Nt(Ls,Ps,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,o,a,c]=t;for(const l of t)this.remove(l);if(e===Rn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),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===Js)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),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(const l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,c,l,h]=this.children,u=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,c),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=v,e.setRenderTarget(n,5,i),e.render(t,h),e.setRenderTarget(u,f,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class io extends gt{constructor(e,t,n,i,r,o,a,c,l,h){e=e!==void 0?e:[],t=t!==void 0?t:oi,super(e,t,n,i,r,o,a,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Cp extends Cn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];t.encoding!==void 0&&(Ir("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Ai?ht:ln),this.texture=new io(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:at}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;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
|
|
uniform sampler2D tEquirect;
|
|
|
|
varying vec3 vWorldDirection;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 direction = normalize( vWorldDirection );
|
|
|
|
vec2 sampleUV = equirectUv( direction );
|
|
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
|
|
}
|
|
`},i=new ps(5,5,5),r=new Ln({name:"CubemapFromEquirect",uniforms:Qs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Qt,blending:ii});r.uniforms.tEquirect.value=t;const o=new ft(i,r),a=t.minFilter;return t.minFilter===Mn&&(t.minFilter=at),new Rp(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}}const zc=new C,Ov=new C,Bv=new Xe;class $n{constructor(e=new C(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=zc.subVectors(n,t).cross(Ov.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(zc),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Bv.getNormalMatrix(e),i=this.coplanarPoint(zc).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ki=new Tt,Bo=new C;class so{constructor(e=new $n,t=new $n,n=new $n,i=new $n,r=new $n,o=new $n){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Rn){const n=this.planes,i=e.elements,r=i[0],o=i[1],a=i[2],c=i[3],l=i[4],h=i[5],u=i[6],f=i[7],d=i[8],p=i[9],v=i[10],g=i[11],m=i[12],y=i[13],_=i[14],x=i[15];if(n[0].setComponents(c-r,f-l,g-d,x-m).normalize(),n[1].setComponents(c+r,f+l,g+d,x+m).normalize(),n[2].setComponents(c+o,f+h,g+p,x+y).normalize(),n[3].setComponents(c-o,f-h,g-p,x-y).normalize(),n[4].setComponents(c-a,f-u,g-v,x-_).normalize(),t===Rn)n[5].setComponents(c+a,f+u,g+v,x+_).normalize();else if(t===Js)n[5].setComponents(a,u,v,_).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(),ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ki)}intersectsSprite(e){return ki.center.set(0,0,0),ki.radius=.7071067811865476,ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(ki)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(Bo.x=i.normal.x>0?e.max.x:e.min.x,Bo.y=i.normal.y>0?e.max.y:e.min.y,Bo.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Bo)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Lp(){let s=null,e=!1,t=null,n=null;function i(r,o){t(r,o),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function Fv(s,e){const t=e.isWebGL2,n=new WeakMap;function i(l,h){const u=l.array,f=l.usage,d=u.byteLength,p=s.createBuffer();s.bindBuffer(h,p),s.bufferData(h,u,f),l.onUploadCallback();let v;if(u instanceof Float32Array)v=s.FLOAT;else if(u instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(t)v=s.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else v=s.UNSIGNED_SHORT;else if(u instanceof Int16Array)v=s.SHORT;else if(u instanceof Uint32Array)v=s.UNSIGNED_INT;else if(u instanceof Int32Array)v=s.INT;else if(u instanceof Int8Array)v=s.BYTE;else if(u instanceof Uint8Array)v=s.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)v=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:p,type:v,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:d}}function r(l,h,u){const f=h.array,d=h._updateRange,p=h.updateRanges;if(s.bindBuffer(u,l),d.count===-1&&p.length===0&&s.bufferSubData(u,0,f),p.length!==0){for(let v=0,g=p.length;v<g;v++){const m=p[v];t?s.bufferSubData(u,m.start*f.BYTES_PER_ELEMENT,f,m.start,m.count):s.bufferSubData(u,m.start*f.BYTES_PER_ELEMENT,f.subarray(m.start,m.start+m.count))}h.clearUpdateRanges()}d.count!==-1&&(t?s.bufferSubData(u,d.offset*f.BYTES_PER_ELEMENT,f,d.offset,d.count):s.bufferSubData(u,d.offset*f.BYTES_PER_ELEMENT,f.subarray(d.offset,d.offset+d.count)),d.count=-1),h.onUploadCallback()}function o(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const h=n.get(l);h&&(s.deleteBuffer(h.buffer),n.delete(l))}function c(l,h){if(l.isGLBufferAttribute){const f=n.get(l);(!f||f.version<l.version)&&n.set(l,{buffer:l.buffer,type:l.type,bytesPerElement:l.elementSize,version:l.version});return}l.isInterleavedBufferAttribute&&(l=l.data);const u=n.get(l);if(u===void 0)n.set(l,i(l,h));else if(u.version<l.version){if(u.size!==l.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.");r(u.buffer,l,h),u.version=l.version}}return{get:o,remove:a,update:c}}class ro extends Be{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,h=c+1,u=e/a,f=t/c,d=[],p=[],v=[],g=[];for(let m=0;m<h;m++){const y=m*f-o;for(let _=0;_<l;_++){const x=_*u-r;p.push(x,-y,0),v.push(0,0,1),g.push(_/a),g.push(1-m/c)}}for(let m=0;m<c;m++)for(let y=0;y<a;y++){const _=y+l*m,x=y+l*(m+1),T=y+1+l*(m+1),b=y+1+l*m;d.push(_,x,b),d.push(x,T,b)}this.setIndex(d),this.setAttribute("position",new Ee(p,3)),this.setAttribute("normal",new Ee(v,3)),this.setAttribute("uv",new Ee(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ro(e.width,e.height,e.widthSegments,e.heightSegments)}}var zv=`#ifdef USE_ALPHAHASH
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
#endif`,kv=`#ifdef USE_ALPHAHASH
|
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
float hash2D( vec2 value ) {
|
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
}
|
|
float hash3D( vec3 value ) {
|
|
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
}
|
|
float getAlphaHashThreshold( vec3 position ) {
|
|
float maxDeriv = max(
|
|
length( dFdx( position.xyz ) ),
|
|
length( dFdy( position.xyz ) )
|
|
);
|
|
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
vec2 pixScales = vec2(
|
|
exp2( floor( log2( pixScale ) ) ),
|
|
exp2( ceil( log2( pixScale ) ) )
|
|
);
|
|
vec2 alpha = vec2(
|
|
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
hash3D( floor( pixScales.y * position.xyz ) )
|
|
);
|
|
float lerpFactor = fract( log2( pixScale ) );
|
|
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
vec3 cases = vec3(
|
|
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
);
|
|
float threshold = ( x < ( 1.0 - a ) )
|
|
? ( ( x < a ) ? cases.x : cases.y )
|
|
: cases.z;
|
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
}
|
|
#endif`,Hv=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
#endif`,Gv=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,Vv=`#ifdef USE_ALPHATEST
|
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
#endif`,Wv=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,Xv=`#ifdef USE_AOMAP
|
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
#if defined( USE_CLEARCOAT )
|
|
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_SHEEN )
|
|
sheenSpecularIndirect *= ambientOcclusion;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
#endif
|
|
#endif`,qv=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,Yv=`#ifdef USE_BATCHING
|
|
attribute float batchId;
|
|
uniform highp sampler2D batchingTexture;
|
|
mat4 getBatchingMatrix( const in float i ) {
|
|
int size = textureSize( batchingTexture, 0 ).x;
|
|
int j = int( i ) * 4;
|
|
int x = j % size;
|
|
int y = j / size;
|
|
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
return mat4( v1, v2, v3, v4 );
|
|
}
|
|
#endif`,Zv=`#ifdef USE_BATCHING
|
|
mat4 batchingMatrix = getBatchingMatrix( batchId );
|
|
#endif`,Kv=`vec3 transformed = vec3( position );
|
|
#ifdef USE_ALPHAHASH
|
|
vPosition = vec3( position );
|
|
#endif`,jv=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,Jv=`float G_BlinnPhong_Implicit( ) {
|
|
return 0.25;
|
|
}
|
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
}
|
|
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
float G = G_BlinnPhong_Implicit( );
|
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
return F * ( G * D );
|
|
} // validated`,$v=`#ifdef USE_IRIDESCENCE
|
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
3.2404542, -0.9692660, 0.0556434,
|
|
-1.5371385, 1.8760108, -0.2040259,
|
|
-0.4985314, 0.0415560, 1.0572252
|
|
);
|
|
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
}
|
|
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
}
|
|
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
}
|
|
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
xyz /= 1.0685e-7;
|
|
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
return rgb;
|
|
}
|
|
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
vec3 I;
|
|
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
if ( cosTheta2Sq < 0.0 ) {
|
|
return vec3( 1.0 );
|
|
}
|
|
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
float T121 = 1.0 - R12;
|
|
float phi12 = 0.0;
|
|
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
float phi21 = PI - phi12;
|
|
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
vec3 phi23 = vec3( 0.0 );
|
|
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
vec3 phi = vec3( phi21 ) + phi23;
|
|
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
vec3 r123 = sqrt( R123 );
|
|
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
vec3 C0 = R12 + Rs;
|
|
I = C0;
|
|
vec3 Cm = Rs - T121;
|
|
for ( int m = 1; m <= 2; ++ m ) {
|
|
Cm *= r123;
|
|
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
I += Cm * Sm;
|
|
}
|
|
return max( I, vec3( 0.0 ) );
|
|
}
|
|
#endif`,Qv=`#ifdef USE_BUMPMAP
|
|
uniform sampler2D bumpMap;
|
|
uniform float bumpScale;
|
|
vec2 dHdxy_fwd() {
|
|
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
return vec2( dBx, dBy );
|
|
}
|
|
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|
vec3 vN = surf_norm;
|
|
vec3 R1 = cross( vSigmaY, vN );
|
|
vec3 R2 = cross( vN, vSigmaX );
|
|
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
}
|
|
#endif`,e0=`#if NUM_CLIPPING_PLANES > 0
|
|
vec4 plane;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
bool clipped = true;
|
|
#pragma unroll_loop_start
|
|
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
plane = clippingPlanes[ i ];
|
|
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
}
|
|
#pragma unroll_loop_end
|
|
if ( clipped ) discard;
|
|
#endif
|
|
#endif`,t0=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
#endif`,n0=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
#endif`,i0=`#if NUM_CLIPPING_PLANES > 0
|
|
vClipPosition = - mvPosition.xyz;
|
|
#endif`,s0=`#if defined( USE_COLOR_ALPHA )
|
|
diffuseColor *= vColor;
|
|
#elif defined( USE_COLOR )
|
|
diffuseColor.rgb *= vColor;
|
|
#endif`,r0=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,o0=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,a0=`#if defined( USE_COLOR_ALPHA )
|
|
vColor = vec4( 1.0 );
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
|
|
vColor = vec3( 1.0 );
|
|
#endif
|
|
#ifdef USE_COLOR
|
|
vColor *= color;
|
|
#endif
|
|
#ifdef USE_INSTANCING_COLOR
|
|
vColor.xyz *= instanceColor.xyz;
|
|
#endif`,c0=`#define PI 3.141592653589793
|
|
#define PI2 6.283185307179586
|
|
#define PI_HALF 1.5707963267948966
|
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
#define RECIPROCAL_PI2 0.15915494309189535
|
|
#define EPSILON 1e-6
|
|
#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
float pow2( const in float x ) { return x*x; }
|
|
vec3 pow2( const in vec3 x ) { return x*x; }
|
|
float pow3( const in float x ) { return x*x*x; }
|
|
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
highp float rand( const in vec2 uv ) {
|
|
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
return fract( sin( sn ) * c );
|
|
}
|
|
#ifdef HIGH_PRECISION
|
|
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
#else
|
|
float precisionSafeLength( vec3 v ) {
|
|
float maxComponent = max3( abs( v ) );
|
|
return length( v / maxComponent ) * maxComponent;
|
|
}
|
|
#endif
|
|
struct IncidentLight {
|
|
vec3 color;
|
|
vec3 direction;
|
|
bool visible;
|
|
};
|
|
struct ReflectedLight {
|
|
vec3 directDiffuse;
|
|
vec3 directSpecular;
|
|
vec3 indirectDiffuse;
|
|
vec3 indirectSpecular;
|
|
};
|
|
#ifdef USE_ALPHAHASH
|
|
varying vec3 vPosition;
|
|
#endif
|
|
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
}
|
|
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
}
|
|
mat3 transposeMat3( const in mat3 m ) {
|
|
mat3 tmp;
|
|
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|
return tmp;
|
|
}
|
|
float luminance( const in vec3 rgb ) {
|
|
const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
|
|
return dot( weights, rgb );
|
|
}
|
|
bool isPerspectiveMatrix( mat4 m ) {
|
|
return m[ 2 ][ 3 ] == - 1.0;
|
|
}
|
|
vec2 equirectUv( in vec3 dir ) {
|
|
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|
return vec2( u, v );
|
|
}
|
|
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
return RECIPROCAL_PI * diffuseColor;
|
|
}
|
|
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
}
|
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
} // validated`,l0=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
#define cubeUV_minMipLevel 4.0
|
|
#define cubeUV_minTileSize 16.0
|
|
float getFace( vec3 direction ) {
|
|
vec3 absDirection = abs( direction );
|
|
float face = - 1.0;
|
|
if ( absDirection.x > absDirection.z ) {
|
|
if ( absDirection.x > absDirection.y )
|
|
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
} else {
|
|
if ( absDirection.z > absDirection.y )
|
|
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
else
|
|
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
}
|
|
return face;
|
|
}
|
|
vec2 getUV( vec3 direction, float face ) {
|
|
vec2 uv;
|
|
if ( face == 0.0 ) {
|
|
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 1.0 ) {
|
|
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
} else if ( face == 2.0 ) {
|
|
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
} else if ( face == 3.0 ) {
|
|
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
} else if ( face == 4.0 ) {
|
|
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
} else {
|
|
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
}
|
|
return 0.5 * ( uv + 1.0 );
|
|
}
|
|
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
float face = getFace( direction );
|
|
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
float faceSize = exp2( mipInt );
|
|
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
if ( face > 2.0 ) {
|
|
uv.y += faceSize;
|
|
face -= 3.0;
|
|
}
|
|
uv.x += face * faceSize;
|
|
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
#ifdef texture2DGradEXT
|
|
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
#else
|
|
return texture2D( envMap, uv ).rgb;
|
|
#endif
|
|
}
|
|
#define cubeUV_r0 1.0
|
|
#define cubeUV_m0 - 2.0
|
|
#define cubeUV_r1 0.8
|
|
#define cubeUV_m1 - 1.0
|
|
#define cubeUV_r4 0.4
|
|
#define cubeUV_m4 2.0
|
|
#define cubeUV_r5 0.305
|
|
#define cubeUV_m5 3.0
|
|
#define cubeUV_r6 0.21
|
|
#define cubeUV_m6 4.0
|
|
float roughnessToMip( float roughness ) {
|
|
float mip = 0.0;
|
|
if ( roughness >= cubeUV_r1 ) {
|
|
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
} else if ( roughness >= cubeUV_r4 ) {
|
|
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
} else if ( roughness >= cubeUV_r5 ) {
|
|
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
} else if ( roughness >= cubeUV_r6 ) {
|
|
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
} else {
|
|
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
return mip;
|
|
}
|
|
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
float mipF = fract( mip );
|
|
float mipInt = floor( mip );
|
|
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
if ( mipF == 0.0 ) {
|
|
return vec4( color0, 1.0 );
|
|
} else {
|
|
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
}
|
|
}
|
|
#endif`,h0=`vec3 transformedNormal = objectNormal;
|
|
#ifdef USE_TANGENT
|
|
vec3 transformedTangent = objectTangent;
|
|
#endif
|
|
#ifdef USE_BATCHING
|
|
mat3 bm = mat3( batchingMatrix );
|
|
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
transformedNormal = bm * transformedNormal;
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = bm * transformedTangent;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
mat3 im = mat3( instanceMatrix );
|
|
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
transformedNormal = im * transformedNormal;
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = im * transformedTangent;
|
|
#endif
|
|
#endif
|
|
transformedNormal = normalMatrix * transformedNormal;
|
|
#ifdef FLIP_SIDED
|
|
transformedNormal = - transformedNormal;
|
|
#endif
|
|
#ifdef USE_TANGENT
|
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
#ifdef FLIP_SIDED
|
|
transformedTangent = - transformedTangent;
|
|
#endif
|
|
#endif`,u0=`#ifdef USE_DISPLACEMENTMAP
|
|
uniform sampler2D displacementMap;
|
|
uniform float displacementScale;
|
|
uniform float displacementBias;
|
|
#endif`,f0=`#ifdef USE_DISPLACEMENTMAP
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
#endif`,d0=`#ifdef USE_EMISSIVEMAP
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
#endif`,p0=`#ifdef USE_EMISSIVEMAP
|
|
uniform sampler2D emissiveMap;
|
|
#endif`,m0="gl_FragColor = linearToOutputTexel( gl_FragColor );",g0=`
|
|
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
|
|
vec3( 0.8224621, 0.177538, 0.0 ),
|
|
vec3( 0.0331941, 0.9668058, 0.0 ),
|
|
vec3( 0.0170827, 0.0723974, 0.9105199 )
|
|
);
|
|
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
|
|
vec3( 1.2249401, - 0.2249404, 0.0 ),
|
|
vec3( - 0.0420569, 1.0420571, 0.0 ),
|
|
vec3( - 0.0196376, - 0.0786361, 1.0982735 )
|
|
);
|
|
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
|
|
return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
|
|
}
|
|
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
|
|
return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
|
|
}
|
|
vec4 LinearTransferOETF( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
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 );
|
|
}
|
|
vec4 LinearToLinear( in vec4 value ) {
|
|
return value;
|
|
}
|
|
vec4 LinearTosRGB( in vec4 value ) {
|
|
return sRGBTransferOETF( value );
|
|
}`,v0=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vec3 cameraToFrag;
|
|
if ( isOrthographic ) {
|
|
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
#else
|
|
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
#endif
|
|
#else
|
|
vec3 reflectVec = vReflect;
|
|
#endif
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
#else
|
|
vec4 envColor = vec4( 0.0 );
|
|
#endif
|
|
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_MIX )
|
|
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
#elif defined( ENVMAP_BLENDING_ADD )
|
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
#endif
|
|
#endif`,_0=`#ifdef USE_ENVMAP
|
|
uniform float envMapIntensity;
|
|
uniform float flipEnvMap;
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#else
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
|
|
#endif`,y0=`#ifdef USE_ENVMAP
|
|
uniform float reflectivity;
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
varying vec3 vWorldPosition;
|
|
uniform float refractionRatio;
|
|
#else
|
|
varying vec3 vReflect;
|
|
#endif
|
|
#endif`,x0=`#ifdef USE_ENVMAP
|
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
#define ENV_WORLDPOS
|
|
#endif
|
|
#ifdef ENV_WORLDPOS
|
|
|
|
varying vec3 vWorldPosition;
|
|
#else
|
|
varying vec3 vReflect;
|
|
uniform float refractionRatio;
|
|
#endif
|
|
#endif`,M0=`#ifdef USE_ENVMAP
|
|
#ifdef ENV_WORLDPOS
|
|
vWorldPosition = worldPosition.xyz;
|
|
#else
|
|
vec3 cameraToVertex;
|
|
if ( isOrthographic ) {
|
|
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
} else {
|
|
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|
}
|
|
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
#ifdef ENVMAP_MODE_REFLECTION
|
|
vReflect = reflect( cameraToVertex, worldNormal );
|
|
#else
|
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
#endif
|
|
#endif
|
|
#endif`,S0=`#ifdef USE_FOG
|
|
vFogDepth = - mvPosition.z;
|
|
#endif`,b0=`#ifdef USE_FOG
|
|
varying float vFogDepth;
|
|
#endif`,A0=`#ifdef USE_FOG
|
|
#ifdef FOG_EXP2
|
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
#else
|
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
#endif
|
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
#endif`,w0=`#ifdef USE_FOG
|
|
uniform vec3 fogColor;
|
|
varying float vFogDepth;
|
|
#ifdef FOG_EXP2
|
|
uniform float fogDensity;
|
|
#else
|
|
uniform float fogNear;
|
|
uniform float fogFar;
|
|
#endif
|
|
#endif`,T0=`#ifdef USE_GRADIENTMAP
|
|
uniform sampler2D gradientMap;
|
|
#endif
|
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
float dotNL = dot( normal, lightDirection );
|
|
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|
#ifdef USE_GRADIENTMAP
|
|
return vec3( texture2D( gradientMap, coord ).r );
|
|
#else
|
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
#endif
|
|
}`,E0=`#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
reflectedLight.indirectDiffuse += lightMapIrradiance;
|
|
#endif`,R0=`#ifdef USE_LIGHTMAP
|
|
uniform sampler2D lightMap;
|
|
uniform float lightMapIntensity;
|
|
#endif`,C0=`LambertMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularStrength = specularStrength;`,L0=`varying vec3 vViewPosition;
|
|
struct LambertMaterial {
|
|
vec3 diffuseColor;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Lambert
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,P0=`uniform bool receiveShadow;
|
|
uniform vec3 ambientLightColor;
|
|
#if defined( USE_LIGHT_PROBES )
|
|
uniform vec3 lightProbe[ 9 ];
|
|
#endif
|
|
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
float x = normal.x, y = normal.y, z = normal.z;
|
|
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
return result;
|
|
}
|
|
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
return irradiance;
|
|
}
|
|
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
vec3 irradiance = ambientLightColor;
|
|
return irradiance;
|
|
}
|
|
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
#if defined ( LEGACY_LIGHTS )
|
|
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
|
|
return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
|
|
}
|
|
return 1.0;
|
|
#else
|
|
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
if ( cutoffDistance > 0.0 ) {
|
|
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
}
|
|
return distanceFalloff;
|
|
#endif
|
|
}
|
|
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
}
|
|
#if NUM_DIR_LIGHTS > 0
|
|
struct DirectionalLight {
|
|
vec3 direction;
|
|
vec3 color;
|
|
};
|
|
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|
light.color = directionalLight.color;
|
|
light.direction = directionalLight.direction;
|
|
light.visible = true;
|
|
}
|
|
#endif
|
|
#if NUM_POINT_LIGHTS > 0
|
|
struct PointLight {
|
|
vec3 position;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
};
|
|
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
vec3 lVector = pointLight.position - geometryPosition;
|
|
light.direction = normalize( lVector );
|
|
float lightDistance = length( lVector );
|
|
light.color = pointLight.color;
|
|
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
}
|
|
#endif
|
|
#if NUM_SPOT_LIGHTS > 0
|
|
struct SpotLight {
|
|
vec3 position;
|
|
vec3 direction;
|
|
vec3 color;
|
|
float distance;
|
|
float decay;
|
|
float coneCos;
|
|
float penumbraCos;
|
|
};
|
|
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
vec3 lVector = spotLight.position - geometryPosition;
|
|
light.direction = normalize( lVector );
|
|
float angleCos = dot( light.direction, spotLight.direction );
|
|
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
if ( spotAttenuation > 0.0 ) {
|
|
float lightDistance = length( lVector );
|
|
light.color = spotLight.color * spotAttenuation;
|
|
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
light.visible = ( light.color != vec3( 0.0 ) );
|
|
} else {
|
|
light.color = vec3( 0.0 );
|
|
light.visible = false;
|
|
}
|
|
}
|
|
#endif
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
struct RectAreaLight {
|
|
vec3 color;
|
|
vec3 position;
|
|
vec3 halfWidth;
|
|
vec3 halfHeight;
|
|
};
|
|
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
#endif
|
|
#if NUM_HEMI_LIGHTS > 0
|
|
struct HemisphereLight {
|
|
vec3 direction;
|
|
vec3 skyColor;
|
|
vec3 groundColor;
|
|
};
|
|
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
float dotNL = dot( normal, hemiLight.direction );
|
|
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
return irradiance;
|
|
}
|
|
#endif`,I0=`#ifdef USE_ENVMAP
|
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
|
|
return PI * envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 reflectVec = reflect( - viewDir, normal );
|
|
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
|
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
|
|
return envMapColor.rgb * envMapIntensity;
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
vec3 bentNormal = cross( bitangent, viewDir );
|
|
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
#else
|
|
return vec3( 0.0 );
|
|
#endif
|
|
}
|
|
#endif
|
|
#endif`,U0=`ToonMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;`,N0=`varying vec3 vViewPosition;
|
|
struct ToonMaterial {
|
|
vec3 diffuseColor;
|
|
};
|
|
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_Toon
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,D0=`BlinnPhongMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularColor = specular;
|
|
material.specularShininess = shininess;
|
|
material.specularStrength = specularStrength;`,O0=`varying vec3 vViewPosition;
|
|
struct BlinnPhongMaterial {
|
|
vec3 diffuseColor;
|
|
vec3 specularColor;
|
|
float specularShininess;
|
|
float specularStrength;
|
|
};
|
|
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
}
|
|
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,B0=`PhysicalMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
material.roughness = min( material.roughness, 1.0 );
|
|
#ifdef IOR
|
|
material.ior = ior;
|
|
#ifdef USE_SPECULAR
|
|
float specularIntensityFactor = specularIntensity;
|
|
vec3 specularColorFactor = specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
#endif
|
|
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
#else
|
|
float specularIntensityFactor = 1.0;
|
|
vec3 specularColorFactor = vec3( 1.0 );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
#else
|
|
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
material.clearcoat = clearcoat;
|
|
material.clearcoatRoughness = clearcoatRoughness;
|
|
material.clearcoatF0 = vec3( 0.04 );
|
|
material.clearcoatF90 = 1.0;
|
|
#ifdef USE_CLEARCOATMAP
|
|
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
#endif
|
|
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
material.clearcoatRoughness += geometryRoughness;
|
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
material.iridescence = iridescence;
|
|
material.iridescenceIOR = iridescenceIOR;
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
#else
|
|
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
material.sheenColor = sheenColor;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
#endif
|
|
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
#ifdef USE_ANISOTROPYMAP
|
|
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
#else
|
|
vec2 anisotropyV = anisotropyVector;
|
|
#endif
|
|
material.anisotropy = length( anisotropyV );
|
|
if( material.anisotropy == 0.0 ) {
|
|
anisotropyV = vec2( 1.0, 0.0 );
|
|
} else {
|
|
anisotropyV /= material.anisotropy;
|
|
material.anisotropy = saturate( material.anisotropy );
|
|
}
|
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
#endif`,F0=`struct PhysicalMaterial {
|
|
vec3 diffuseColor;
|
|
float roughness;
|
|
vec3 specularColor;
|
|
float specularF90;
|
|
#ifdef USE_CLEARCOAT
|
|
float clearcoat;
|
|
float clearcoatRoughness;
|
|
vec3 clearcoatF0;
|
|
float clearcoatF90;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float iridescence;
|
|
float iridescenceIOR;
|
|
float iridescenceThickness;
|
|
vec3 iridescenceFresnel;
|
|
vec3 iridescenceF0;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
vec3 sheenColor;
|
|
float sheenRoughness;
|
|
#endif
|
|
#ifdef IOR
|
|
float ior;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
float transmission;
|
|
float transmissionAlpha;
|
|
float thickness;
|
|
float attenuationDistance;
|
|
vec3 attenuationColor;
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float anisotropy;
|
|
float alphaT;
|
|
vec3 anisotropyT;
|
|
vec3 anisotropyB;
|
|
#endif
|
|
};
|
|
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
float x2 = x * x;
|
|
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
}
|
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
float a2 = pow2( alpha );
|
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
return 0.5 / max( gv + gl, EPSILON );
|
|
}
|
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
float a2 = pow2( alpha );
|
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
|
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
float v = 0.5 / ( gv + gl );
|
|
return saturate(v);
|
|
}
|
|
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
float a2 = alphaT * alphaB;
|
|
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
highp float v2 = dot( v, v );
|
|
float w2 = a2 / v2;
|
|
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
}
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
vec3 f0 = material.clearcoatF0;
|
|
float f90 = material.clearcoatF90;
|
|
float roughness = material.clearcoatRoughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
return F * ( V * D );
|
|
}
|
|
#endif
|
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
vec3 f0 = material.specularColor;
|
|
float f90 = material.specularF90;
|
|
float roughness = material.roughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
#ifdef USE_IRIDESCENCE
|
|
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float dotTL = dot( material.anisotropyT, lightDir );
|
|
float dotTV = dot( material.anisotropyT, viewDir );
|
|
float dotTH = dot( material.anisotropyT, halfDir );
|
|
float dotBL = dot( material.anisotropyB, lightDir );
|
|
float dotBV = dot( material.anisotropyB, viewDir );
|
|
float dotBH = dot( material.anisotropyB, halfDir );
|
|
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
#else
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
#endif
|
|
return F * ( V * D );
|
|
}
|
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
const float LUT_SIZE = 64.0;
|
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
float dotNV = saturate( dot( N, V ) );
|
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
return uv;
|
|
}
|
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
float l = length( f );
|
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
}
|
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
float x = dot( v1, v2 );
|
|
float y = abs( x );
|
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
float v = a / b;
|
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
return cross( v1, v2 ) * theta_sintheta;
|
|
}
|
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
vec3 lightNormal = cross( v1, v2 );
|
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
vec3 T1, T2;
|
|
T1 = normalize( V - N * dot( V, N ) );
|
|
T2 = - cross( N, T1 );
|
|
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
|
vec3 coords[ 4 ];
|
|
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
vec3 vectorFormFactor = vec3( 0.0 );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
return vec3( result );
|
|
}
|
|
#if defined( USE_SHEEN )
|
|
float D_Charlie( float roughness, float dotNH ) {
|
|
float alpha = pow2( roughness );
|
|
float invAlpha = 1.0 / alpha;
|
|
float cos2h = dotNH * dotNH;
|
|
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
}
|
|
float V_Neubelt( float dotNV, float dotNL ) {
|
|
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
}
|
|
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float D = D_Charlie( sheenRoughness, dotNH );
|
|
float V = V_Neubelt( dotNV, dotNL );
|
|
return sheenColor * ( D * V );
|
|
}
|
|
#endif
|
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float r2 = roughness * roughness;
|
|
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
return saturate( DG * RECIPROCAL_PI );
|
|
}
|
|
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
vec4 r = roughness * c0 + c1;
|
|
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|
return fab;
|
|
}
|
|
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
return specularColor * fab.x + specularF90 * fab.y;
|
|
}
|
|
#ifdef USE_IRIDESCENCE
|
|
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#else
|
|
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#endif
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
#ifdef USE_IRIDESCENCE
|
|
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|
#else
|
|
vec3 Fr = specularColor;
|
|
#endif
|
|
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|
float Ess = fab.x + fab.y;
|
|
float Ems = 1.0 - Ess;
|
|
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
singleScatter += FssEss;
|
|
multiScatter += Fms * Ems;
|
|
}
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 normal = geometryNormal;
|
|
vec3 viewDir = geometryViewDir;
|
|
vec3 position = geometryPosition;
|
|
vec3 lightPos = rectAreaLight.position;
|
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
vec3 lightColor = rectAreaLight.color;
|
|
float roughness = material.roughness;
|
|
vec3 rectCoords[ 4 ];
|
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
vec4 t1 = texture2D( ltc_1, uv );
|
|
vec4 t2 = texture2D( ltc_2, uv );
|
|
mat3 mInv = mat3(
|
|
vec3( t1.x, 0, t1.y ),
|
|
vec3( 0, 1, 0 ),
|
|
vec3( t1.z, 0, t1.w )
|
|
);
|
|
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
}
|
|
#endif
|
|
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
#endif
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
#endif
|
|
vec3 singleScattering = vec3( 0.0 );
|
|
vec3 multiScattering = vec3( 0.0 );
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
#ifdef USE_IRIDESCENCE
|
|
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
#else
|
|
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
#endif
|
|
vec3 totalScattering = singleScattering + multiScattering;
|
|
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
}
|
|
#define RE_Direct RE_Direct_Physical
|
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
}`,z0=`
|
|
vec3 geometryPosition = - vViewPosition;
|
|
vec3 geometryNormal = normal;
|
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
#ifdef USE_CLEARCOAT
|
|
geometryClearcoatNormal = clearcoatNormal;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
if ( material.iridescenceThickness == 0.0 ) {
|
|
material.iridescence = 0.0;
|
|
} else {
|
|
material.iridescence = saturate( material.iridescence );
|
|
}
|
|
if ( material.iridescence > 0.0 ) {
|
|
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
}
|
|
#endif
|
|
IncidentLight directLight;
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
PointLight pointLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
pointLight = pointLights[ i ];
|
|
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
pointLightShadow = pointLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
SpotLight spotLight;
|
|
vec4 spotColor;
|
|
vec3 spotLightCoord;
|
|
bool inSpotLightMap;
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
spotLight = spotLights[ i ];
|
|
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
#else
|
|
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#endif
|
|
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
#endif
|
|
#undef SPOT_LIGHT_MAP_INDEX
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
DirectionalLight directionalLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
directionalLight = directionalLights[ i ];
|
|
getDirectionalLightInfo( directionalLight, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
RectAreaLight rectAreaLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
rectAreaLight = rectAreaLights[ i ];
|
|
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if defined( RE_IndirectDiffuse )
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
#if defined( USE_LIGHT_PROBES )
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
#endif
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
vec3 radiance = vec3( 0.0 );
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
#endif`,k0=`#if defined( RE_IndirectDiffuse )
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
irradiance += lightMapIrradiance;
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
#endif
|
|
#endif
|
|
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
#ifdef USE_ANISOTROPY
|
|
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
#else
|
|
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
#endif
|
|
#endif`,H0=`#if defined( RE_IndirectDiffuse )
|
|
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
#endif`,G0=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
#endif`,V0=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
|
|
uniform float logDepthBufFC;
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,W0=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#else
|
|
uniform float logDepthBufFC;
|
|
#endif
|
|
#endif`,X0=`#ifdef USE_LOGDEPTHBUF
|
|
#ifdef USE_LOGDEPTHBUF_EXT
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
#else
|
|
if ( isPerspectiveMatrix( projectionMatrix ) ) {
|
|
gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
|
|
gl_Position.z *= gl_Position.w;
|
|
}
|
|
#endif
|
|
#endif`,q0=`#ifdef USE_MAP
|
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
|
|
|
|
#endif
|
|
diffuseColor *= sampledDiffuseColor;
|
|
#endif`,Y0=`#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif`,Z0=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
#if defined( USE_POINTS_UV )
|
|
vec2 uv = vUv;
|
|
#else
|
|
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
diffuseColor *= texture2D( map, uv );
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
#endif`,K0=`#if defined( USE_POINTS_UV )
|
|
varying vec2 vUv;
|
|
#else
|
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,j0=`float metalnessFactor = metalness;
|
|
#ifdef USE_METALNESSMAP
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
metalnessFactor *= texelMetalness.b;
|
|
#endif`,J0=`#ifdef USE_METALNESSMAP
|
|
uniform sampler2D metalnessMap;
|
|
#endif`,$0=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
|
|
vColor *= morphTargetBaseInfluence;
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
#if defined( USE_COLOR_ALPHA )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
#elif defined( USE_COLOR )
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
#endif
|
|
}
|
|
#endif`,Q0=`#ifdef USE_MORPHNORMALS
|
|
objectNormal *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#else
|
|
objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
|
|
objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
|
|
objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
|
|
objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
|
|
#endif
|
|
#endif`,e_=`#ifdef USE_MORPHTARGETS
|
|
uniform float morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
uniform sampler2DArray morphTargetsTexture;
|
|
uniform ivec2 morphTargetsTextureSize;
|
|
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
int y = texelIndex / morphTargetsTextureSize.x;
|
|
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
}
|
|
#else
|
|
#ifndef USE_MORPHNORMALS
|
|
uniform float morphTargetInfluences[ 8 ];
|
|
#else
|
|
uniform float morphTargetInfluences[ 4 ];
|
|
#endif
|
|
#endif
|
|
#endif`,t_=`#ifdef USE_MORPHTARGETS
|
|
transformed *= morphTargetBaseInfluence;
|
|
#ifdef MORPHTARGETS_TEXTURE
|
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
}
|
|
#else
|
|
transformed += morphTarget0 * morphTargetInfluences[ 0 ];
|
|
transformed += morphTarget1 * morphTargetInfluences[ 1 ];
|
|
transformed += morphTarget2 * morphTargetInfluences[ 2 ];
|
|
transformed += morphTarget3 * morphTargetInfluences[ 3 ];
|
|
#ifndef USE_MORPHNORMALS
|
|
transformed += morphTarget4 * morphTargetInfluences[ 4 ];
|
|
transformed += morphTarget5 * morphTargetInfluences[ 5 ];
|
|
transformed += morphTarget6 * morphTargetInfluences[ 6 ];
|
|
transformed += morphTarget7 * morphTargetInfluences[ 7 ];
|
|
#endif
|
|
#endif
|
|
#endif`,n_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
#ifdef FLAT_SHADED
|
|
vec3 fdx = dFdx( vViewPosition );
|
|
vec3 fdy = dFdy( vViewPosition );
|
|
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
#else
|
|
vec3 normal = normalize( vNormal );
|
|
#ifdef DOUBLE_SIDED
|
|
normal *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
#if defined( USE_NORMALMAP )
|
|
vNormalMapUv
|
|
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
vClearcoatNormalMapUv
|
|
#else
|
|
vUv
|
|
#endif
|
|
);
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn[0] *= faceDirection;
|
|
tbn[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
#ifdef USE_TANGENT
|
|
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
#else
|
|
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|
#endif
|
|
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
tbn2[0] *= faceDirection;
|
|
tbn2[1] *= faceDirection;
|
|
#endif
|
|
#endif
|
|
vec3 nonPerturbedNormal = normal;`,i_=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
#ifdef FLIP_SIDED
|
|
normal = - normal;
|
|
#endif
|
|
#ifdef DOUBLE_SIDED
|
|
normal = normal * faceDirection;
|
|
#endif
|
|
normal = normalize( normalMatrix * normal );
|
|
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
mapN.xy *= normalScale;
|
|
normal = normalize( tbn * mapN );
|
|
#elif defined( USE_BUMPMAP )
|
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
#endif`,s_=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,r_=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,o_=`#ifndef FLAT_SHADED
|
|
vNormal = normalize( transformedNormal );
|
|
#ifdef USE_TANGENT
|
|
vTangent = normalize( transformedTangent );
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
#endif
|
|
#endif`,a_=`#ifdef USE_NORMALMAP
|
|
uniform sampler2D normalMap;
|
|
uniform vec2 normalScale;
|
|
#endif
|
|
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
uniform mat3 normalMatrix;
|
|
#endif
|
|
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|
vec3 q0 = dFdx( eye_pos.xyz );
|
|
vec3 q1 = dFdy( eye_pos.xyz );
|
|
vec2 st0 = dFdx( uv.st );
|
|
vec2 st1 = dFdy( uv.st );
|
|
vec3 N = surf_norm;
|
|
vec3 q1perp = cross( q1, N );
|
|
vec3 q0perp = cross( N, q0 );
|
|
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
float det = max( dot( T, T ), dot( B, B ) );
|
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
return mat3( T * scale, B * scale, N );
|
|
}
|
|
#endif`,c_=`#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
#endif`,l_=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
#endif`,h_=`#ifdef USE_CLEARCOATMAP
|
|
uniform sampler2D clearcoatMap;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform sampler2D clearcoatNormalMap;
|
|
uniform vec2 clearcoatNormalScale;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform sampler2D clearcoatRoughnessMap;
|
|
#endif`,u_=`#ifdef USE_IRIDESCENCEMAP
|
|
uniform sampler2D iridescenceMap;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform sampler2D iridescenceThicknessMap;
|
|
#endif`,f_=`#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
#endif
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,d_=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
return normalize( normal ) * 0.5 + 0.5;
|
|
}
|
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
return 2.0 * rgb.xyz - 1.0;
|
|
}
|
|
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
|
|
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
|
|
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
|
|
const float ShiftRight8 = 1. / 256.;
|
|
vec4 packDepthToRGBA( const in float v ) {
|
|
vec4 r = vec4( fract( v * PackFactors ), v );
|
|
r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
|
|
}
|
|
float unpackRGBAToDepth( const in vec4 v ) {
|
|
return dot( v, UnpackFactors );
|
|
}
|
|
vec2 packDepthToRG( in highp float v ) {
|
|
return packDepthToRGBA( v ).yx;
|
|
}
|
|
float unpackRGToDepth( const in highp vec2 v ) {
|
|
return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
|
|
}
|
|
vec4 pack2HalfToRGBA( vec2 v ) {
|
|
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|
}
|
|
vec2 unpackRGBATo2Half( vec4 v ) {
|
|
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|
}
|
|
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( viewZ + near ) / ( near - far );
|
|
}
|
|
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
return depth * ( near - far ) - near;
|
|
}
|
|
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
}
|
|
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
}`,p_=`#ifdef PREMULTIPLIED_ALPHA
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
#endif`,m_=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_BATCHING
|
|
mvPosition = batchingMatrix * mvPosition;
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
mvPosition = instanceMatrix * mvPosition;
|
|
#endif
|
|
mvPosition = modelViewMatrix * mvPosition;
|
|
gl_Position = projectionMatrix * mvPosition;`,g_=`#ifdef DITHERING
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
#endif`,v_=`#ifdef DITHERING
|
|
vec3 dithering( vec3 color ) {
|
|
float grid_position = rand( gl_FragCoord.xy );
|
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
return color + dither_shift_RGB;
|
|
}
|
|
#endif`,__=`float roughnessFactor = roughness;
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
roughnessFactor *= texelRoughness.g;
|
|
#endif`,y_=`#ifdef USE_ROUGHNESSMAP
|
|
uniform sampler2D roughnessMap;
|
|
#endif`,x_=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
#endif
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
struct SpotLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
|
}
|
|
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
}
|
|
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
|
float occlusion = 1.0;
|
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
float hard_shadow = step( compare , distribution.x );
|
|
if (hard_shadow != 1.0 ) {
|
|
float distance = compare - distribution.x ;
|
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
}
|
|
return occlusion;
|
|
}
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
float shadow = 1.0;
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|
shadowCoord.z += shadowBias;
|
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
if ( frustumTest ) {
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx0 = - texelSize.x * shadowRadius;
|
|
float dy0 = - texelSize.y * shadowRadius;
|
|
float dx1 = + texelSize.x * shadowRadius;
|
|
float dy1 = + texelSize.y * shadowRadius;
|
|
float dx2 = dx0 / 2.0;
|
|
float dy2 = dy0 / 2.0;
|
|
float dx3 = dx1 / 2.0;
|
|
float dy3 = dy1 / 2.0;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
) * ( 1.0 / 17.0 );
|
|
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx = texelSize.x;
|
|
float dy = texelSize.y;
|
|
vec2 uv = shadowCoord.xy;
|
|
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
uv -= f * texelSize;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
f.x ),
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.x ),
|
|
f.y )
|
|
) * ( 1.0 / 9.0 );
|
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#else
|
|
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#endif
|
|
}
|
|
return shadow;
|
|
}
|
|
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
vec3 absV = abs( v );
|
|
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
absV *= scaleToCube;
|
|
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
vec2 planar = v.xy;
|
|
float almostATexel = 1.5 * texelSizeY;
|
|
float almostOne = 1.0 - almostATexel;
|
|
if ( absV.z >= almostOne ) {
|
|
if ( v.z > 0.0 )
|
|
planar.x = 4.0 - v.x;
|
|
} else if ( absV.x >= almostOne ) {
|
|
float signX = sign( v.x );
|
|
planar.x = v.z * signX + 2.0 * signX;
|
|
} else if ( absV.y >= almostOne ) {
|
|
float signY = sign( v.y );
|
|
planar.x = v.x + 2.0 * signY + 2.0;
|
|
planar.y = v.z * signY - 2.0;
|
|
}
|
|
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
}
|
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
return (
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
) * ( 1.0 / 9.0 );
|
|
#else
|
|
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
#endif
|
|
}
|
|
#endif`,M_=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
#endif
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
struct SpotLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#endif`,S_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
vec4 shadowWorldPosition;
|
|
#endif
|
|
#if defined( USE_SHADOWMAP )
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|
shadowWorldPosition = worldPosition;
|
|
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|
#endif
|
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif`,b_=`float getShadowMask() {
|
|
float shadow = 1.0;
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
directionalLight = directionalLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
spotLight = spotLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
pointLight = pointLightShadows[ i ];
|
|
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
return shadow;
|
|
}`,A_=`#ifdef USE_SKINNING
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
#endif`,w_=`#ifdef USE_SKINNING
|
|
uniform mat4 bindMatrix;
|
|
uniform mat4 bindMatrixInverse;
|
|
uniform highp sampler2D boneTexture;
|
|
mat4 getBoneMatrix( const in float i ) {
|
|
int size = textureSize( boneTexture, 0 ).x;
|
|
int j = int( i ) * 4;
|
|
int x = j % size;
|
|
int y = j / size;
|
|
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
return mat4( v1, v2, v3, v4 );
|
|
}
|
|
#endif`,T_=`#ifdef USE_SKINNING
|
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
vec4 skinned = vec4( 0.0 );
|
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
skinned += boneMatY * skinVertex * skinWeight.y;
|
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
#endif`,E_=`#ifdef USE_SKINNING
|
|
mat4 skinMatrix = mat4( 0.0 );
|
|
skinMatrix += skinWeight.x * boneMatX;
|
|
skinMatrix += skinWeight.y * boneMatY;
|
|
skinMatrix += skinWeight.z * boneMatZ;
|
|
skinMatrix += skinWeight.w * boneMatW;
|
|
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|
#ifdef USE_TANGENT
|
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
#endif
|
|
#endif`,R_=`float specularStrength;
|
|
#ifdef USE_SPECULARMAP
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
specularStrength = texelSpecular.r;
|
|
#else
|
|
specularStrength = 1.0;
|
|
#endif`,C_=`#ifdef USE_SPECULARMAP
|
|
uniform sampler2D specularMap;
|
|
#endif`,L_=`#if defined( TONE_MAPPING )
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
#endif`,P_=`#ifndef saturate
|
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
#endif
|
|
uniform float toneMappingExposure;
|
|
vec3 LinearToneMapping( vec3 color ) {
|
|
return saturate( toneMappingExposure * color );
|
|
}
|
|
vec3 ReinhardToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
}
|
|
vec3 OptimizedCineonToneMapping( vec3 color ) {
|
|
color *= toneMappingExposure;
|
|
color = max( vec3( 0.0 ), color - 0.004 );
|
|
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|
}
|
|
vec3 RRTAndODTFit( vec3 v ) {
|
|
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|
return a / b;
|
|
}
|
|
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
const mat3 ACESInputMat = mat3(
|
|
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|
vec3( 0.04823, 0.01566, 0.83777 )
|
|
);
|
|
const mat3 ACESOutputMat = mat3(
|
|
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|
vec3( -0.07367, -0.00605, 1.07602 )
|
|
);
|
|
color *= toneMappingExposure / 0.6;
|
|
color = ACESInputMat * color;
|
|
color = RRTAndODTFit( color );
|
|
color = ACESOutputMat * color;
|
|
return saturate( color );
|
|
}
|
|
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
);
|
|
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
vec3( 0.0433, 0.0113, 0.8956 )
|
|
);
|
|
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
vec3 x2 = x * x;
|
|
vec3 x4 = x2 * x2;
|
|
return + 15.5 * x4 * x2
|
|
- 40.14 * x4 * x
|
|
+ 31.96 * x4
|
|
- 6.868 * x2 * x
|
|
+ 0.4298 * x2
|
|
+ 0.1191 * x
|
|
- 0.00232;
|
|
}
|
|
vec3 AgXToneMapping( vec3 color ) {
|
|
const mat3 AgXInsetMatrix = mat3(
|
|
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
);
|
|
const mat3 AgXOutsetMatrix = mat3(
|
|
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
);
|
|
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
color *= toneMappingExposure;
|
|
color = AgXInsetMatrix * color;
|
|
color = max( color, 1e-10 ); color = log2( color );
|
|
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
color = clamp( color, 0.0, 1.0 );
|
|
color = agxDefaultContrastApprox( color );
|
|
color = AgXOutsetMatrix * color;
|
|
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
return color;
|
|
}
|
|
vec3 CustomToneMapping( vec3 color ) { return color; }`,I_=`#ifdef USE_TRANSMISSION
|
|
material.transmission = transmission;
|
|
material.transmissionAlpha = 1.0;
|
|
material.thickness = thickness;
|
|
material.attenuationDistance = attenuationDistance;
|
|
material.attenuationColor = attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
#endif
|
|
vec3 pos = vWorldPosition;
|
|
vec3 v = normalize( cameraPosition - pos );
|
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 transmitted = getIBLVolumeRefraction(
|
|
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
|
|
material.attenuationColor, material.attenuationDistance );
|
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
#endif`,U_=`#ifdef USE_TRANSMISSION
|
|
uniform float transmission;
|
|
uniform float thickness;
|
|
uniform float attenuationDistance;
|
|
uniform vec3 attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform sampler2D transmissionMap;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform sampler2D thicknessMap;
|
|
#endif
|
|
uniform vec2 transmissionSamplerSize;
|
|
uniform sampler2D transmissionSamplerMap;
|
|
uniform mat4 modelMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
varying vec3 vWorldPosition;
|
|
float w0( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
}
|
|
float w1( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|
}
|
|
float w2( float a ){
|
|
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|
}
|
|
float w3( float a ) {
|
|
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|
}
|
|
float g0( float a ) {
|
|
return w0( a ) + w1( a );
|
|
}
|
|
float g1( float a ) {
|
|
return w2( a ) + w3( a );
|
|
}
|
|
float h0( float a ) {
|
|
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|
}
|
|
float h1( float a ) {
|
|
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|
}
|
|
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|
uv = uv * texelSize.zw + 0.5;
|
|
vec2 iuv = floor( uv );
|
|
vec2 fuv = fract( uv );
|
|
float g0x = g0( fuv.x );
|
|
float g1x = g1( fuv.x );
|
|
float h0x = h0( fuv.x );
|
|
float h1x = h1( fuv.x );
|
|
float h0y = h0( fuv.y );
|
|
float h1y = h1( fuv.y );
|
|
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|
}
|
|
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
return mix( fSample, cSample, fract( lod ) );
|
|
}
|
|
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
vec3 modelScale;
|
|
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
return normalize( refractionVector ) * thickness * modelScale;
|
|
}
|
|
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
}
|
|
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|
}
|
|
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
if ( isinf( attenuationDistance ) ) {
|
|
return vec3( 1.0 );
|
|
} else {
|
|
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|
}
|
|
}
|
|
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
|
|
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
vec3 refractedRayExit = position + transmissionRay;
|
|
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
refractionCoords += 1.0;
|
|
refractionCoords /= 2.0;
|
|
vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
}
|
|
#endif`,N_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,D_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
varying vec2 vUv;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
uniform mat3 mapTransform;
|
|
varying vec2 vMapUv;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
uniform mat3 alphaMapTransform;
|
|
varying vec2 vAlphaMapUv;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
uniform mat3 lightMapTransform;
|
|
varying vec2 vLightMapUv;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
uniform mat3 aoMapTransform;
|
|
varying vec2 vAoMapUv;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
uniform mat3 bumpMapTransform;
|
|
varying vec2 vBumpMapUv;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
uniform mat3 normalMapTransform;
|
|
varying vec2 vNormalMapUv;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
uniform mat3 displacementMapTransform;
|
|
varying vec2 vDisplacementMapUv;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
uniform mat3 emissiveMapTransform;
|
|
varying vec2 vEmissiveMapUv;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
uniform mat3 metalnessMapTransform;
|
|
varying vec2 vMetalnessMapUv;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
uniform mat3 roughnessMapTransform;
|
|
varying vec2 vRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform mat3 anisotropyMapTransform;
|
|
varying vec2 vAnisotropyMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
uniform mat3 clearcoatMapTransform;
|
|
varying vec2 vClearcoatMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
uniform mat3 clearcoatNormalMapTransform;
|
|
varying vec2 vClearcoatNormalMapUv;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
uniform mat3 clearcoatRoughnessMapTransform;
|
|
varying vec2 vClearcoatRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform mat3 sheenColorMapTransform;
|
|
varying vec2 vSheenColorMapUv;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform mat3 sheenRoughnessMapTransform;
|
|
varying vec2 vSheenRoughnessMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
uniform mat3 iridescenceMapTransform;
|
|
varying vec2 vIridescenceMapUv;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform mat3 iridescenceThicknessMapTransform;
|
|
varying vec2 vIridescenceThicknessMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
uniform mat3 specularMapTransform;
|
|
varying vec2 vSpecularMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform mat3 specularColorMapTransform;
|
|
varying vec2 vSpecularColorMapUv;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform mat3 specularIntensityMapTransform;
|
|
varying vec2 vSpecularIntensityMapUv;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
uniform mat3 transmissionMapTransform;
|
|
varying vec2 vTransmissionMapUv;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
uniform mat3 thicknessMapTransform;
|
|
varying vec2 vThicknessMapUv;
|
|
#endif`,O_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
vUv = vec3( uv, 1 ).xy;
|
|
#endif
|
|
#ifdef USE_MAP
|
|
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ALPHAMAP
|
|
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_LIGHTMAP
|
|
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_AOMAP
|
|
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_BUMPMAP
|
|
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_NORMALMAP
|
|
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_EMISSIVEMAP
|
|
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_METALNESSMAP
|
|
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_ANISOTROPYMAP
|
|
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOATMAP
|
|
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULARMAP
|
|
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
#endif`,B_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
#ifdef USE_BATCHING
|
|
worldPosition = batchingMatrix * worldPosition;
|
|
#endif
|
|
#ifdef USE_INSTANCING
|
|
worldPosition = instanceMatrix * worldPosition;
|
|
#endif
|
|
worldPosition = modelMatrix * worldPosition;
|
|
#endif`;const F_=`varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
void main() {
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
}`,z_=`uniform sampler2D t2D;
|
|
uniform float backgroundIntensity;
|
|
varying vec2 vUv;
|
|
void main() {
|
|
vec4 texColor = texture2D( t2D, vUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,k_=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,H_=`#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
uniform float flipEnvMap;
|
|
uniform float backgroundBlurriness;
|
|
uniform float backgroundIntensity;
|
|
varying vec3 vWorldDirection;
|
|
#include <cube_uv_reflection_fragment>
|
|
void main() {
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
|
|
#else
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,G_=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,V_=`uniform samplerCube tCube;
|
|
uniform float tFlip;
|
|
uniform float opacity;
|
|
varying vec3 vWorldDirection;
|
|
void main() {
|
|
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|
gl_FragColor = texColor;
|
|
gl_FragColor.a *= opacity;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,W_=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,X_=`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
|
#if DEPTH_PACKING == 3200
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
#elif DEPTH_PACKING == 3201
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
#endif
|
|
}`,q_=`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,Y_=`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = packDepthToRGBA( dist );
|
|
}`,Z_=`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,K_=`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,j_=`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,J_=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,$_=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,Q_=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
#endif
|
|
#include <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,ey=`#define LAMBERT
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,ty=`#define LAMBERT
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_lambert_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_lambert_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,ny=`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,iy=`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
vec3 viewDir = normalize( vViewPosition );
|
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
vec3 y = cross( viewDir, x );
|
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
#ifdef USE_MATCAP
|
|
vec4 matcapColor = texture2D( matcap, uv );
|
|
#else
|
|
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
#endif
|
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,sy=`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,ry=`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,oy=`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,ay=`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,cy=`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,ly=`#define STANDARD
|
|
#ifdef PHYSICAL
|
|
#define IOR
|
|
#define USE_SPECULAR
|
|
#endif
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float roughness;
|
|
uniform float metalness;
|
|
uniform float opacity;
|
|
#ifdef IOR
|
|
uniform float ior;
|
|
#endif
|
|
#ifdef USE_SPECULAR
|
|
uniform float specularIntensity;
|
|
uniform vec3 specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform sampler2D specularColorMap;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform sampler2D specularIntensityMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
uniform float clearcoat;
|
|
uniform float clearcoatRoughness;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
uniform float iridescence;
|
|
uniform float iridescenceIOR;
|
|
uniform float iridescenceThicknessMinimum;
|
|
uniform float iridescenceThicknessMaximum;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
uniform vec3 sheenColor;
|
|
uniform float sheenRoughness;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform sampler2D sheenColorMap;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform sampler2D sheenRoughnessMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
uniform vec2 anisotropyVector;
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform sampler2D anisotropyMap;
|
|
#endif
|
|
#endif
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <iridescence_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <iridescence_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
#endif
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,hy=`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,uy=`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,fy=`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
#ifdef USE_POINTS_UV
|
|
varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
void main() {
|
|
#ifdef USE_POINTS_UV
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
#endif
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,dy=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,py=`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,my=`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
#include <logdepthbuf_fragment>
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,gy=`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
vec2 scale;
|
|
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
|
|
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
|
|
#ifndef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
#endif
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
vec2 rotatedPosition;
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
mvPosition.xy += rotatedPosition;
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,vy=`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,Ve={alphahash_fragment:zv,alphahash_pars_fragment:kv,alphamap_fragment:Hv,alphamap_pars_fragment:Gv,alphatest_fragment:Vv,alphatest_pars_fragment:Wv,aomap_fragment:Xv,aomap_pars_fragment:qv,batching_pars_vertex:Yv,batching_vertex:Zv,begin_vertex:Kv,beginnormal_vertex:jv,bsdfs:Jv,iridescence_fragment:$v,bumpmap_pars_fragment:Qv,clipping_planes_fragment:e0,clipping_planes_pars_fragment:t0,clipping_planes_pars_vertex:n0,clipping_planes_vertex:i0,color_fragment:s0,color_pars_fragment:r0,color_pars_vertex:o0,color_vertex:a0,common:c0,cube_uv_reflection_fragment:l0,defaultnormal_vertex:h0,displacementmap_pars_vertex:u0,displacementmap_vertex:f0,emissivemap_fragment:d0,emissivemap_pars_fragment:p0,colorspace_fragment:m0,colorspace_pars_fragment:g0,envmap_fragment:v0,envmap_common_pars_fragment:_0,envmap_pars_fragment:y0,envmap_pars_vertex:x0,envmap_physical_pars_fragment:I0,envmap_vertex:M0,fog_vertex:S0,fog_pars_vertex:b0,fog_fragment:A0,fog_pars_fragment:w0,gradientmap_pars_fragment:T0,lightmap_fragment:E0,lightmap_pars_fragment:R0,lights_lambert_fragment:C0,lights_lambert_pars_fragment:L0,lights_pars_begin:P0,lights_toon_fragment:U0,lights_toon_pars_fragment:N0,lights_phong_fragment:D0,lights_phong_pars_fragment:O0,lights_physical_fragment:B0,lights_physical_pars_fragment:F0,lights_fragment_begin:z0,lights_fragment_maps:k0,lights_fragment_end:H0,logdepthbuf_fragment:G0,logdepthbuf_pars_fragment:V0,logdepthbuf_pars_vertex:W0,logdepthbuf_vertex:X0,map_fragment:q0,map_pars_fragment:Y0,map_particle_fragment:Z0,map_particle_pars_fragment:K0,metalnessmap_fragment:j0,metalnessmap_pars_fragment:J0,morphcolor_vertex:$0,morphnormal_vertex:Q0,morphtarget_pars_vertex:e_,morphtarget_vertex:t_,normal_fragment_begin:n_,normal_fragment_maps:i_,normal_pars_fragment:s_,normal_pars_vertex:r_,normal_vertex:o_,normalmap_pars_fragment:a_,clearcoat_normal_fragment_begin:c_,clearcoat_normal_fragment_maps:l_,clearcoat_pars_fragment:h_,iridescence_pars_fragment:u_,opaque_fragment:f_,packing:d_,premultiplied_alpha_fragment:p_,project_vertex:m_,dithering_fragment:g_,dithering_pars_fragment:v_,roughnessmap_fragment:__,roughnessmap_pars_fragment:y_,shadowmap_pars_fragment:x_,shadowmap_pars_vertex:M_,shadowmap_vertex:S_,shadowmask_pars_fragment:b_,skinbase_vertex:A_,skinning_pars_vertex:w_,skinning_vertex:T_,skinnormal_vertex:E_,specularmap_fragment:R_,specularmap_pars_fragment:C_,tonemapping_fragment:L_,tonemapping_pars_fragment:P_,transmission_fragment:I_,transmission_pars_fragment:U_,uv_pars_fragment:N_,uv_pars_vertex:D_,uv_vertex:O_,worldpos_vertex:B_,background_vert:F_,background_frag:z_,backgroundCube_vert:k_,backgroundCube_frag:H_,cube_vert:G_,cube_frag:V_,depth_vert:W_,depth_frag:X_,distanceRGBA_vert:q_,distanceRGBA_frag:Y_,equirect_vert:Z_,equirect_frag:K_,linedashed_vert:j_,linedashed_frag:J_,meshbasic_vert:$_,meshbasic_frag:Q_,meshlambert_vert:ey,meshlambert_frag:ty,meshmatcap_vert:ny,meshmatcap_frag:iy,meshnormal_vert:sy,meshnormal_frag:ry,meshphong_vert:oy,meshphong_frag:ay,meshphysical_vert:cy,meshphysical_frag:ly,meshtoon_vert:hy,meshtoon_frag:uy,points_vert:fy,points_frag:dy,shadow_vert:py,shadow_frag:my,sprite_vert:gy,sprite_frag:vy},_e={common:{diffuse:{value:new Te(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xe}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xe},normalScale:{value:new ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Te(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Te(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0},uvTransform:{value:new Xe}},sprite:{diffuse:{value:new Te(16777215)},opacity:{value:1},center:{value:new ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}}},jt={basic:{uniforms:Kt([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.fog]),vertexShader:Ve.meshbasic_vert,fragmentShader:Ve.meshbasic_frag},lambert:{uniforms:Kt([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new Te(0)}}]),vertexShader:Ve.meshlambert_vert,fragmentShader:Ve.meshlambert_frag},phong:{uniforms:Kt([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new Te(0)},specular:{value:new Te(1118481)},shininess:{value:30}}]),vertexShader:Ve.meshphong_vert,fragmentShader:Ve.meshphong_frag},standard:{uniforms:Kt([_e.common,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.roughnessmap,_e.metalnessmap,_e.fog,_e.lights,{emissive:{value:new Te(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag},toon:{uniforms:Kt([_e.common,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.gradientmap,_e.fog,_e.lights,{emissive:{value:new Te(0)}}]),vertexShader:Ve.meshtoon_vert,fragmentShader:Ve.meshtoon_frag},matcap:{uniforms:Kt([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,{matcap:{value:null}}]),vertexShader:Ve.meshmatcap_vert,fragmentShader:Ve.meshmatcap_frag},points:{uniforms:Kt([_e.points,_e.fog]),vertexShader:Ve.points_vert,fragmentShader:Ve.points_frag},dashed:{uniforms:Kt([_e.common,_e.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ve.linedashed_vert,fragmentShader:Ve.linedashed_frag},depth:{uniforms:Kt([_e.common,_e.displacementmap]),vertexShader:Ve.depth_vert,fragmentShader:Ve.depth_frag},normal:{uniforms:Kt([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,{opacity:{value:1}}]),vertexShader:Ve.meshnormal_vert,fragmentShader:Ve.meshnormal_frag},sprite:{uniforms:Kt([_e.sprite,_e.fog]),vertexShader:Ve.sprite_vert,fragmentShader:Ve.sprite_frag},background:{uniforms:{uvTransform:{value:new Xe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ve.background_vert,fragmentShader:Ve.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Ve.backgroundCube_vert,fragmentShader:Ve.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ve.cube_vert,fragmentShader:Ve.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ve.equirect_vert,fragmentShader:Ve.equirect_frag},distanceRGBA:{uniforms:Kt([_e.common,_e.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ve.distanceRGBA_vert,fragmentShader:Ve.distanceRGBA_frag},shadow:{uniforms:Kt([_e.lights,_e.fog,{color:{value:new Te(0)},opacity:{value:1}}]),vertexShader:Ve.shadow_vert,fragmentShader:Ve.shadow_frag}};jt.physical={uniforms:Kt([jt.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xe},clearcoatNormalScale:{value:new ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xe},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xe},sheen:{value:0},sheenColor:{value:new Te(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xe},transmissionSamplerSize:{value:new ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xe},attenuationDistance:{value:0},attenuationColor:{value:new Te(0)},specularColor:{value:new Te(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xe},anisotropyVector:{value:new ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xe}}]),vertexShader:Ve.meshphysical_vert,fragmentShader:Ve.meshphysical_frag};const Fo={r:0,b:0,g:0};function _y(s,e,t,n,i,r,o){const a=new Te(0);let c=r===!0?0:1,l,h,u=null,f=0,d=null;function p(g,m){let y=!1,_=m.isScene===!0?m.background:null;_&&_.isTexture&&(_=(m.backgroundBlurriness>0?t:e).get(_)),_===null?v(a,c):_&&_.isColor&&(v(_,1),y=!0);const x=s.xr.getEnvironmentBlendMode();x==="additive"?n.buffers.color.setClear(0,0,0,1,o):x==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||y)&&s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil),_&&(_.isCubeTexture||_.mapping===ir)?(h===void 0&&(h=new ft(new ps(1,1,1),new Ln({name:"BackgroundCubeMaterial",uniforms:Qs(jt.backgroundCube.uniforms),vertexShader:jt.backgroundCube.vertexShader,fragmentShader:jt.backgroundCube.fragmentShader,side:Qt,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,b,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,h.material.toneMapped=rt.getTransfer(_.colorSpace)!==lt,(u!==_||f!==_.version||d!==s.toneMapping)&&(h.material.needsUpdate=!0,u=_,f=_.version,d=s.toneMapping),h.layers.enableAll(),g.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new ft(new ro(2,2),new Ln({name:"BackgroundMaterial",uniforms:Qs(jt.background.uniforms),vertexShader:jt.background.vertexShader,fragmentShader:jt.background.fragmentShader,side:Gn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=rt.getTransfer(_.colorSpace)!==lt,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(u!==_||f!==_.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,u=_,f=_.version,d=s.toneMapping),l.layers.enableAll(),g.unshift(l,l.geometry,l.material,0,0,null))}function v(g,m){g.getRGB(Fo,Ep(s)),n.buffers.color.setClear(Fo.r,Fo.g,Fo.b,m,o)}return{getClearColor:function(){return a},setClearColor:function(g,m=1){a.set(g),c=m,v(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(g){c=g,v(a,c)},render:p}}function yy(s,e,t,n){const i=s.getParameter(s.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:e.get("OES_vertex_array_object"),o=n.isWebGL2||r!==null,a={},c=g(null);let l=c,h=!1;function u(I,F,k,te,J){let $=!1;if(o){const le=v(te,k,F);l!==le&&(l=le,d(l.object)),$=m(I,te,k,J),$&&y(I,te,k,J)}else{const le=F.wireframe===!0;(l.geometry!==te.id||l.program!==k.id||l.wireframe!==le)&&(l.geometry=te.id,l.program=k.id,l.wireframe=le,$=!0)}J!==null&&t.update(J,s.ELEMENT_ARRAY_BUFFER),($||h)&&(h=!1,L(I,F,k,te),J!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(J).buffer))}function f(){return n.isWebGL2?s.createVertexArray():r.createVertexArrayOES()}function d(I){return n.isWebGL2?s.bindVertexArray(I):r.bindVertexArrayOES(I)}function p(I){return n.isWebGL2?s.deleteVertexArray(I):r.deleteVertexArrayOES(I)}function v(I,F,k){const te=k.wireframe===!0;let J=a[I.id];J===void 0&&(J={},a[I.id]=J);let $=J[F.id];$===void 0&&($={},J[F.id]=$);let le=$[te];return le===void 0&&(le=g(f()),$[te]=le),le}function g(I){const F=[],k=[],te=[];for(let J=0;J<i;J++)F[J]=0,k[J]=0,te[J]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:F,enabledAttributes:k,attributeDivisors:te,object:I,attributes:{},index:null}}function m(I,F,k,te){const J=l.attributes,$=F.attributes;let le=0;const ce=k.getAttributes();for(const ge in ce)if(ce[ge].location>=0){const U=J[ge];let N=$[ge];if(N===void 0&&(ge==="instanceMatrix"&&I.instanceMatrix&&(N=I.instanceMatrix),ge==="instanceColor"&&I.instanceColor&&(N=I.instanceColor)),U===void 0||U.attribute!==N||N&&U.data!==N.data)return!0;le++}return l.attributesNum!==le||l.index!==te}function y(I,F,k,te){const J={},$=F.attributes;let le=0;const ce=k.getAttributes();for(const ge in ce)if(ce[ge].location>=0){let U=$[ge];U===void 0&&(ge==="instanceMatrix"&&I.instanceMatrix&&(U=I.instanceMatrix),ge==="instanceColor"&&I.instanceColor&&(U=I.instanceColor));const N={};N.attribute=U,U&&U.data&&(N.data=U.data),J[ge]=N,le++}l.attributes=J,l.attributesNum=le,l.index=te}function _(){const I=l.newAttributes;for(let F=0,k=I.length;F<k;F++)I[F]=0}function x(I){T(I,0)}function T(I,F){const k=l.newAttributes,te=l.enabledAttributes,J=l.attributeDivisors;k[I]=1,te[I]===0&&(s.enableVertexAttribArray(I),te[I]=1),J[I]!==F&&((n.isWebGL2?s:e.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](I,F),J[I]=F)}function b(){const I=l.newAttributes,F=l.enabledAttributes;for(let k=0,te=F.length;k<te;k++)F[k]!==I[k]&&(s.disableVertexAttribArray(k),F[k]=0)}function A(I,F,k,te,J,$,le){le===!0?s.vertexAttribIPointer(I,F,k,J,$):s.vertexAttribPointer(I,F,k,te,J,$)}function L(I,F,k,te){if(n.isWebGL2===!1&&(I.isInstancedMesh||te.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;_();const J=te.attributes,$=k.getAttributes(),le=F.defaultAttributeValues;for(const ce in $){const ge=$[ce];if(ge.location>=0){let Z=J[ce];if(Z===void 0&&(ce==="instanceMatrix"&&I.instanceMatrix&&(Z=I.instanceMatrix),ce==="instanceColor"&&I.instanceColor&&(Z=I.instanceColor)),Z!==void 0){const U=Z.normalized,N=Z.itemSize,V=t.get(Z);if(V===void 0)continue;const W=V.buffer,q=V.type,j=V.bytesPerElement,Y=n.isWebGL2===!0&&(q===s.INT||q===s.UNSIGNED_INT||Z.gpuType===ph);if(Z.isInterleavedBufferAttribute){const oe=Z.data,R=oe.stride,ie=Z.offset;if(oe.isInstancedInterleavedBuffer){for(let G=0;G<ge.locationSize;G++)T(ge.location+G,oe.meshPerAttribute);I.isInstancedMesh!==!0&&te._maxInstanceCount===void 0&&(te._maxInstanceCount=oe.meshPerAttribute*oe.count)}else for(let G=0;G<ge.locationSize;G++)x(ge.location+G);s.bindBuffer(s.ARRAY_BUFFER,W);for(let G=0;G<ge.locationSize;G++)A(ge.location+G,N/ge.locationSize,q,U,R*j,(ie+N/ge.locationSize*G)*j,Y)}else{if(Z.isInstancedBufferAttribute){for(let oe=0;oe<ge.locationSize;oe++)T(ge.location+oe,Z.meshPerAttribute);I.isInstancedMesh!==!0&&te._maxInstanceCount===void 0&&(te._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let oe=0;oe<ge.locationSize;oe++)x(ge.location+oe);s.bindBuffer(s.ARRAY_BUFFER,W);for(let oe=0;oe<ge.locationSize;oe++)A(ge.location+oe,N/ge.locationSize,q,U,N*j,N/ge.locationSize*oe*j,Y)}}else if(le!==void 0){const U=le[ce];if(U!==void 0)switch(U.length){case 2:s.vertexAttrib2fv(ge.location,U);break;case 3:s.vertexAttrib3fv(ge.location,U);break;case 4:s.vertexAttrib4fv(ge.location,U);break;default:s.vertexAttrib1fv(ge.location,U)}}}}b()}function M(){H();for(const I in a){const F=a[I];for(const k in F){const te=F[k];for(const J in te)p(te[J].object),delete te[J];delete F[k]}delete a[I]}}function w(I){if(a[I.id]===void 0)return;const F=a[I.id];for(const k in F){const te=F[k];for(const J in te)p(te[J].object),delete te[J];delete F[k]}delete a[I.id]}function O(I){for(const F in a){const k=a[F];if(k[I.id]===void 0)continue;const te=k[I.id];for(const J in te)p(te[J].object),delete te[J];delete k[I.id]}}function H(){K(),h=!0,l!==c&&(l=c,d(l.object))}function K(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:u,reset:H,resetDefaultState:K,dispose:M,releaseStatesOfGeometry:w,releaseStatesOfProgram:O,initAttributes:_,enableAttribute:x,disableUnusedAttributes:b}}function xy(s,e,t,n){const i=n.isWebGL2;let r;function o(h){r=h}function a(h,u){s.drawArrays(r,h,u),t.update(u,r,1)}function c(h,u,f){if(f===0)return;let d,p;if(i)d=s,p="drawArraysInstanced";else if(d=e.get("ANGLE_instanced_arrays"),p="drawArraysInstancedANGLE",d===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}d[p](r,h,u,f),t.update(u,r,f)}function l(h,u,f){if(f===0)return;const d=e.get("WEBGL_multi_draw");if(d===null)for(let p=0;p<f;p++)this.render(h[p],u[p]);else{d.multiDrawArraysWEBGL(r,h,0,u,0,f);let p=0;for(let v=0;v<f;v++)p+=u[v];t.update(p,r,1)}}this.setMode=o,this.render=a,this.renderInstances=c,this.renderMultiDraw=l}function My(s,e,t){let n;function i(){if(n!==void 0)return n;if(e.has("EXT_texture_filter_anisotropic")===!0){const A=e.get("EXT_texture_filter_anisotropic");n=s.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(A){if(A==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const o=typeof WebGL2RenderingContext<"u"&&s.constructor.name==="WebGL2RenderingContext";let a=t.precision!==void 0?t.precision:"highp";const c=r(a);c!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",c,"instead."),a=c);const l=o||e.has("WEBGL_draw_buffers"),h=t.logarithmicDepthBuffer===!0,u=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),f=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=s.getParameter(s.MAX_TEXTURE_SIZE),p=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),v=s.getParameter(s.MAX_VERTEX_ATTRIBS),g=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),m=s.getParameter(s.MAX_VARYING_VECTORS),y=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),_=f>0,x=o||e.has("OES_texture_float"),T=_&&x,b=o?s.getParameter(s.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:r,precision:a,logarithmicDepthBuffer:h,maxTextures:u,maxVertexTextures:f,maxTextureSize:d,maxCubemapSize:p,maxAttributes:v,maxVertexUniforms:g,maxVaryings:m,maxFragmentUniforms:y,vertexTextures:_,floatFragmentTextures:x,floatVertexTextures:T,maxSamples:b}}function Sy(s){const e=this;let t=null,n=0,i=!1,r=!1;const o=new $n,a=new Xe,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,f){const d=u.length!==0||f||n!==0||i;return i=f,n=u.length,d},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,f){t=h(u,f,0)},this.setState=function(u,f,d){const p=u.clippingPlanes,v=u.clipIntersection,g=u.clipShadows,m=s.get(u);if(!i||p===null||p.length===0||r&&!g)r?h(null):l();else{const y=r?0:n,_=y*4;let x=m.clippingState||null;c.value=x,x=h(p,f,_,d);for(let T=0;T!==_;++T)x[T]=t[T];m.clippingState=x,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,f,d,p){const v=u!==null?u.length:0;let g=null;if(v!==0){if(g=c.value,p!==!0||g===null){const m=d+v*4,y=f.matrixWorldInverse;a.getNormalMatrix(y),(g===null||g.length<m)&&(g=new Float32Array(m));for(let _=0,x=d;_!==v;++_,x+=4)o.copy(u[_]).applyMatrix4(y,a),o.normal.toArray(g,x),g[x+3]=o.constant}c.value=g,c.needsUpdate=!0}return e.numPlanes=v,e.numIntersection=0,g}}function by(s){let e=new WeakMap;function t(o,a){return a===Br?o.mapping=oi:a===Fr&&(o.mapping=Ei),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===Br||a===Fr)if(e.has(o)){const c=e.get(o).texture;return t(c,o.mapping)}else{const c=o.image;if(c&&c.height>0){const l=new Cp(c.height/2);return l.fromEquirectangularTexture(s,o),e.set(o,l),o.addEventListener("dispose",i),t(l.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}class oo extends Ja{constructor(e=-1,t=1,n=1,i=-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=i,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,i,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=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,o=n+e,a=i+t,c=i-t;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,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.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Gs=4,Wu=[.125,.215,.35,.446,.526,.582],$i=20,kc=new oo,Xu=new Te;let Hc=null,Gc=0,Vc=0;const Ji=(1+Math.sqrt(5))/2,Is=1/Ji,qu=[new C(1,1,1),new C(-1,1,1),new C(1,1,-1),new C(-1,1,-1),new C(0,Ji,Is),new C(0,Ji,-Is),new C(Is,0,Ji),new C(-Is,0,Ji),new C(Ji,Is,0),new C(-Ji,Is,0)];class Kl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Hc=this._renderer.getRenderTarget(),Gc=this._renderer.getActiveCubeFace(),Vc=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ku(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Zu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Hc,Gc,Vc),e.scissorTest=!1,zo(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===oi||e.mapping===Ei?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Hc=this._renderer.getRenderTarget(),Gc=this._renderer.getActiveCubeFace(),Vc=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:at,minFilter:at,generateMipmaps:!1,type:Ks,format:nn,colorSpace:Rt,depthBuffer:!1},i=Yu(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Yu(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Ay(r)),this._blurMaterial=wy(r,e,t)}return i}_compileMaterial(e){const t=new ft(this._lodPlanes[0],e);this._renderer.compile(t,kc)}_sceneToCubeUV(e,t,n,i){const a=new Nt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,f=h.toneMapping;h.getClearColor(Xu),h.toneMapping=si,h.autoClear=!1;const d=new hn({name:"PMREM.Background",side:Qt,depthWrite:!1,depthTest:!1}),p=new ft(new ps,d);let v=!1;const g=e.background;g?g.isColor&&(d.color.copy(g),e.background=null,v=!0):(d.color.copy(Xu),v=!0);for(let m=0;m<6;m++){const y=m%3;y===0?(a.up.set(0,c[m],0),a.lookAt(l[m],0,0)):y===1?(a.up.set(0,0,c[m]),a.lookAt(0,l[m],0)):(a.up.set(0,c[m],0),a.lookAt(0,0,l[m]));const _=this._cubeSize;zo(i,y*_,m>2?_:0,_,_),h.setRenderTarget(i),v&&h.render(p,a),h.render(e,a)}p.geometry.dispose(),p.material.dispose(),h.toneMapping=f,h.autoClear=u,e.background=g}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===oi||e.mapping===Ei;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ku()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Zu());const r=i?this._cubemapMaterial:this._equirectMaterial,o=new ft(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const c=this._cubeSize;zo(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,kc)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const r=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=qu[(i-1)%qu.length];this._blur(e,i-1,i,r,o)}t.autoClear=n}_blur(e,t,n,i,r){const o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){const c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new ft(this._lodPlanes[i],l),f=l.uniforms,d=this._sizeLods[n]-1,p=isFinite(r)?Math.PI/(2*d):2*Math.PI/(2*$i-1),v=r/p,g=isFinite(r)?1+Math.floor(h*v):$i;g>$i&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${$i}`);const m=[];let y=0;for(let A=0;A<$i;++A){const L=A/v,M=Math.exp(-L*L/2);m.push(M),A===0?y+=M:A<g&&(y+=2*M)}for(let A=0;A<m.length;A++)m[A]=m[A]/y;f.envMap.value=e.texture,f.samples.value=g,f.weights.value=m,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);const{_lodMax:_}=this;f.dTheta.value=p,f.mipInt.value=_-n;const x=this._sizeLods[i],T=3*x*(i>_-Gs?i-_+Gs:0),b=4*(this._cubeSize-x);zo(t,T,b,3*x,2*x),c.setRenderTarget(t),c.render(u,kc)}}function Ay(s){const e=[],t=[],n=[];let i=s;const r=s-Gs+1+Wu.length;for(let o=0;o<r;o++){const a=Math.pow(2,i);t.push(a);let c=1/a;o>s-Gs?c=Wu[o-s+Gs-1]:o===0&&(c=0),n.push(c);const l=1/(a-2),h=-l,u=1+l,f=[h,h,u,h,u,u,h,h,u,u,h,u],d=6,p=6,v=3,g=2,m=1,y=new Float32Array(v*p*d),_=new Float32Array(g*p*d),x=new Float32Array(m*p*d);for(let b=0;b<d;b++){const A=b%3*2/3-1,L=b>2?0:-1,M=[A,L,0,A+2/3,L,0,A+2/3,L+1,0,A,L,0,A+2/3,L+1,0,A,L+1,0];y.set(M,v*p*b),_.set(f,g*p*b);const w=[b,b,b,b,b,b];x.set(w,m*p*b)}const T=new Be;T.setAttribute("position",new Fe(y,v)),T.setAttribute("uv",new Fe(_,g)),T.setAttribute("faceIndex",new Fe(x,m)),e.push(T),i>Gs&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function Yu(s,e,t){const n=new Cn(s,e,t);return n.texture.mapping=ir,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function zo(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function wy(s,e,t){const n=new Float32Array($i),i=new C(0,1,0);return new Ln({name:"SphericalGaussianBlur",defines:{n:$i,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Lh(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
uniform int samples;
|
|
uniform float weights[ n ];
|
|
uniform bool latitudinal;
|
|
uniform float dTheta;
|
|
uniform float mipInt;
|
|
uniform vec3 poleAxis;
|
|
|
|
#define ENVMAP_TYPE_CUBE_UV
|
|
#include <cube_uv_reflection_fragment>
|
|
|
|
vec3 getSample( float theta, vec3 axis ) {
|
|
|
|
float cosTheta = cos( theta );
|
|
// Rodrigues' axis-angle rotation
|
|
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
|
|
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
|
|
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
|
|
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
|
|
}
|
|
|
|
axis = normalize( axis );
|
|
|
|
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
|
|
for ( int i = 1; i < n; i++ ) {
|
|
|
|
if ( i >= samples ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
float theta = dTheta * float( i );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
|
|
}
|
|
|
|
}
|
|
`,blending:ii,depthTest:!1,depthWrite:!1})}function Zu(){return new Ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Lh(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform sampler2D envMap;
|
|
|
|
#include <common>
|
|
|
|
void main() {
|
|
|
|
vec3 outputDirection = normalize( vOutputDirection );
|
|
vec2 uv = equirectUv( outputDirection );
|
|
|
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
|
|
}
|
|
`,blending:ii,depthTest:!1,depthWrite:!1})}function Ku(){return new Ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Lh(),fragmentShader:`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
uniform float flipEnvMap;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
uniform samplerCube envMap;
|
|
|
|
void main() {
|
|
|
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
|
|
}
|
|
`,blending:ii,depthTest:!1,depthWrite:!1})}function Lh(){return`
|
|
|
|
precision mediump float;
|
|
precision mediump int;
|
|
|
|
attribute float faceIndex;
|
|
|
|
varying vec3 vOutputDirection;
|
|
|
|
// RH coordinate system; PMREM face-indexing convention
|
|
vec3 getDirection( vec2 uv, float face ) {
|
|
|
|
uv = 2.0 * uv - 1.0;
|
|
|
|
vec3 direction = vec3( uv, 1.0 );
|
|
|
|
if ( face == 0.0 ) {
|
|
|
|
direction = direction.zyx; // ( 1, v, u ) pos x
|
|
|
|
} else if ( face == 1.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
|
|
} else if ( face == 2.0 ) {
|
|
|
|
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
|
|
} else if ( face == 3.0 ) {
|
|
|
|
direction = direction.zyx;
|
|
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
|
|
} else if ( face == 4.0 ) {
|
|
|
|
direction = direction.xzy;
|
|
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
|
|
} else if ( face == 5.0 ) {
|
|
|
|
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
|
|
}
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
vOutputDirection = getDirection( uv, faceIndex );
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
}
|
|
`}function Ty(s){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const c=a.mapping,l=c===Br||c===Fr,h=c===oi||c===Ei;if(l||h)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let u=e.get(a);return t===null&&(t=new Kl(s)),u=l?t.fromEquirectangular(a,u):t.fromCubemap(a,u),e.set(a,u),u.texture}else{if(e.has(a))return e.get(a).texture;{const u=a.image;if(l&&u&&u.height>0||h&&u&&i(u)){t===null&&(t=new Kl(s));const f=l?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,f),a.addEventListener("dispose",r),f.texture}else return null}}}return a}function i(a){let c=0;const l=6;for(let h=0;h<l;h++)a[h]!==void 0&&c++;return c===l}function r(a){const c=a.target;c.removeEventListener("dispose",r);const l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function Ey(s){const e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(n){n.isWebGL2?(t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance")):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(n){const i=t(n);return i===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function Ry(s,e,t,n){const i={},r=new WeakMap;function o(u){const f=u.target;f.index!==null&&e.remove(f.index);for(const p in f.attributes)e.remove(f.attributes[p]);for(const p in f.morphAttributes){const v=f.morphAttributes[p];for(let g=0,m=v.length;g<m;g++)e.remove(v[g])}f.removeEventListener("dispose",o),delete i[f.id];const d=r.get(f);d&&(e.remove(d),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function a(u,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,t.memory.geometries++),f}function c(u){const f=u.attributes;for(const p in f)e.update(f[p],s.ARRAY_BUFFER);const d=u.morphAttributes;for(const p in d){const v=d[p];for(let g=0,m=v.length;g<m;g++)e.update(v[g],s.ARRAY_BUFFER)}}function l(u){const f=[],d=u.index,p=u.attributes.position;let v=0;if(d!==null){const y=d.array;v=d.version;for(let _=0,x=y.length;_<x;_+=3){const T=y[_+0],b=y[_+1],A=y[_+2];f.push(T,b,b,A,A,T)}}else if(p!==void 0){const y=p.array;v=p.version;for(let _=0,x=y.length/3-1;_<x;_+=3){const T=_+0,b=_+1,A=_+2;f.push(T,b,b,A,A,T)}}else return;const g=new(bp(f)?Ch:Rh)(f,1);g.version=v;const m=r.get(u);m&&e.remove(m),r.set(u,g)}function h(u){const f=r.get(u);if(f){const d=u.index;d!==null&&f.version<d.version&&l(u)}else l(u);return r.get(u)}return{get:a,update:c,getWireframeAttribute:h}}function Cy(s,e,t,n){const i=n.isWebGL2;let r;function o(d){r=d}let a,c;function l(d){a=d.type,c=d.bytesPerElement}function h(d,p){s.drawElements(r,p,a,d*c),t.update(p,r,1)}function u(d,p,v){if(v===0)return;let g,m;if(i)g=s,m="drawElementsInstanced";else if(g=e.get("ANGLE_instanced_arrays"),m="drawElementsInstancedANGLE",g===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}g[m](r,p,a,d*c,v),t.update(p,r,v)}function f(d,p,v){if(v===0)return;const g=e.get("WEBGL_multi_draw");if(g===null)for(let m=0;m<v;m++)this.render(d[m]/c,p[m]);else{g.multiDrawElementsWEBGL(r,p,0,a,d,0,v);let m=0;for(let y=0;y<v;y++)m+=p[y];t.update(m,r,1)}}this.setMode=o,this.setIndex=l,this.render=h,this.renderInstances=u,this.renderMultiDraw=f}function Ly(s){const 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 s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function Py(s,e){return s[0]-e[0]}function Iy(s,e){return Math.abs(e[1])-Math.abs(s[1])}function Uy(s,e,t){const n={},i=new Float32Array(8),r=new WeakMap,o=new nt,a=[];for(let l=0;l<8;l++)a[l]=[l,0];function c(l,h,u){const f=l.morphTargetInfluences;if(e.isWebGL2===!0){const d=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,p=d!==void 0?d.length:0;let v=r.get(h);if(v===void 0||v.count!==p){let y=function(){K.dispose(),r.delete(h),h.removeEventListener("dispose",y)};v!==void 0&&v.texture.dispose();const _=h.morphAttributes.position!==void 0,x=h.morphAttributes.normal!==void 0,T=h.morphAttributes.color!==void 0,b=h.morphAttributes.position||[],A=h.morphAttributes.normal||[],L=h.morphAttributes.color||[];let M=0;_===!0&&(M=1),x===!0&&(M=2),T===!0&&(M=3);let w=h.attributes.position.count*M,O=1;w>e.maxTextureSize&&(O=Math.ceil(w/e.maxTextureSize),w=e.maxTextureSize);const H=new Float32Array(w*O*4*p),K=new Za(H,w,O,p);K.type=En,K.needsUpdate=!0;const I=M*4;for(let F=0;F<p;F++){const k=b[F],te=A[F],J=L[F],$=w*O*4*F;for(let le=0;le<k.count;le++){const ce=le*I;_===!0&&(o.fromBufferAttribute(k,le),H[$+ce+0]=o.x,H[$+ce+1]=o.y,H[$+ce+2]=o.z,H[$+ce+3]=0),x===!0&&(o.fromBufferAttribute(te,le),H[$+ce+4]=o.x,H[$+ce+5]=o.y,H[$+ce+6]=o.z,H[$+ce+7]=0),T===!0&&(o.fromBufferAttribute(J,le),H[$+ce+8]=o.x,H[$+ce+9]=o.y,H[$+ce+10]=o.z,H[$+ce+11]=J.itemSize===4?o.w:1)}}v={count:p,texture:K,size:new ae(w,O)},r.set(h,v),h.addEventListener("dispose",y)}let g=0;for(let y=0;y<f.length;y++)g+=f[y];const m=h.morphTargetsRelative?1:1-g;u.getUniforms().setValue(s,"morphTargetBaseInfluence",m),u.getUniforms().setValue(s,"morphTargetInfluences",f),u.getUniforms().setValue(s,"morphTargetsTexture",v.texture,t),u.getUniforms().setValue(s,"morphTargetsTextureSize",v.size)}else{const d=f===void 0?0:f.length;let p=n[h.id];if(p===void 0||p.length!==d){p=[];for(let _=0;_<d;_++)p[_]=[_,0];n[h.id]=p}for(let _=0;_<d;_++){const x=p[_];x[0]=_,x[1]=f[_]}p.sort(Iy);for(let _=0;_<8;_++)_<d&&p[_][1]?(a[_][0]=p[_][0],a[_][1]=p[_][1]):(a[_][0]=Number.MAX_SAFE_INTEGER,a[_][1]=0);a.sort(Py);const v=h.morphAttributes.position,g=h.morphAttributes.normal;let m=0;for(let _=0;_<8;_++){const x=a[_],T=x[0],b=x[1];T!==Number.MAX_SAFE_INTEGER&&b?(v&&h.getAttribute("morphTarget"+_)!==v[T]&&h.setAttribute("morphTarget"+_,v[T]),g&&h.getAttribute("morphNormal"+_)!==g[T]&&h.setAttribute("morphNormal"+_,g[T]),i[_]=b,m+=b):(v&&h.hasAttribute("morphTarget"+_)===!0&&h.deleteAttribute("morphTarget"+_),g&&h.hasAttribute("morphNormal"+_)===!0&&h.deleteAttribute("morphNormal"+_),i[_]=0)}const y=h.morphTargetsRelative?1:1-m;u.getUniforms().setValue(s,"morphTargetBaseInfluence",y),u.getUniforms().setValue(s,"morphTargetInfluences",i)}}return{update:c}}function Ny(s,e,t,n){let i=new WeakMap;function r(c){const l=n.render.frame,h=c.geometry,u=e.get(c,h);if(i.get(u)!==l&&(e.update(u),i.set(u,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){const f=c.skeleton;i.get(f)!==l&&(f.update(),i.set(f,l))}return u}function o(){i=new WeakMap}function a(c){const l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:o}}class Ph extends gt{constructor(e,t,n,i,r,o,a,c,l,h){if(h=h!==void 0?h:bi,h!==bi&&h!==cs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===bi&&(n=ei),n===void 0&&h===cs&&(n=Si),super(null,i,r,o,a,c,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:dt,this.minFilter=c!==void 0?c:dt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const Pp=new gt,Ip=new Ph(1,1);Ip.compareFunction=Ah;const Up=new Za,Np=new Eh,Dp=new io,ju=[],Ju=[],$u=new Float32Array(16),Qu=new Float32Array(9),ef=new Float32Array(4);function sr(s,e,t){const n=s[0];if(n<=0||n>0)return s;const i=e*t;let r=ju[i];if(r===void 0&&(r=new Float32Array(i),ju[i]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function Ct(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function Lt(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function $a(s,e){let t=Ju[e];t===void 0&&(t=new Int32Array(e),Ju[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function Dy(s,e){const t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function Oy(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ct(t,e))return;s.uniform2fv(this.addr,e),Lt(t,e)}}function By(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ct(t,e))return;s.uniform3fv(this.addr,e),Lt(t,e)}}function Fy(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ct(t,e))return;s.uniform4fv(this.addr,e),Lt(t,e)}}function zy(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ct(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),Lt(t,e)}else{if(Ct(t,n))return;ef.set(n),s.uniformMatrix2fv(this.addr,!1,ef),Lt(t,n)}}function ky(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ct(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),Lt(t,e)}else{if(Ct(t,n))return;Qu.set(n),s.uniformMatrix3fv(this.addr,!1,Qu),Lt(t,n)}}function Hy(s,e){const t=this.cache,n=e.elements;if(n===void 0){if(Ct(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),Lt(t,e)}else{if(Ct(t,n))return;$u.set(n),s.uniformMatrix4fv(this.addr,!1,$u),Lt(t,n)}}function Gy(s,e){const t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function Vy(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ct(t,e))return;s.uniform2iv(this.addr,e),Lt(t,e)}}function Wy(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ct(t,e))return;s.uniform3iv(this.addr,e),Lt(t,e)}}function Xy(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ct(t,e))return;s.uniform4iv(this.addr,e),Lt(t,e)}}function qy(s,e){const t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function Yy(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ct(t,e))return;s.uniform2uiv(this.addr,e),Lt(t,e)}}function Zy(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ct(t,e))return;s.uniform3uiv(this.addr,e),Lt(t,e)}}function Ky(s,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Ct(t,e))return;s.uniform4uiv(this.addr,e),Lt(t,e)}}function jy(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);const r=this.type===s.SAMPLER_2D_SHADOW?Ip:Pp;t.setTexture2D(e||r,i)}function Jy(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Np,i)}function $y(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Dp,i)}function Qy(s,e,t){const n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||Up,i)}function ex(s){switch(s){case 5126:return Dy;case 35664:return Oy;case 35665:return By;case 35666:return Fy;case 35674:return zy;case 35675:return ky;case 35676:return Hy;case 5124:case 35670:return Gy;case 35667:case 35671:return Vy;case 35668:case 35672:return Wy;case 35669:case 35673:return Xy;case 5125:return qy;case 36294:return Yy;case 36295:return Zy;case 36296:return Ky;case 35678:case 36198:case 36298:case 36306:case 35682:return jy;case 35679:case 36299:case 36307:return Jy;case 35680:case 36300:case 36308:case 36293:return $y;case 36289:case 36303:case 36311:case 36292:return Qy}}function tx(s,e){s.uniform1fv(this.addr,e)}function nx(s,e){const t=sr(e,this.size,2);s.uniform2fv(this.addr,t)}function ix(s,e){const t=sr(e,this.size,3);s.uniform3fv(this.addr,t)}function sx(s,e){const t=sr(e,this.size,4);s.uniform4fv(this.addr,t)}function rx(s,e){const t=sr(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function ox(s,e){const t=sr(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function ax(s,e){const t=sr(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function cx(s,e){s.uniform1iv(this.addr,e)}function lx(s,e){s.uniform2iv(this.addr,e)}function hx(s,e){s.uniform3iv(this.addr,e)}function ux(s,e){s.uniform4iv(this.addr,e)}function fx(s,e){s.uniform1uiv(this.addr,e)}function dx(s,e){s.uniform2uiv(this.addr,e)}function px(s,e){s.uniform3uiv(this.addr,e)}function mx(s,e){s.uniform4uiv(this.addr,e)}function gx(s,e,t){const n=this.cache,i=e.length,r=$a(t,i);Ct(n,r)||(s.uniform1iv(this.addr,r),Lt(n,r));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||Pp,r[o])}function vx(s,e,t){const n=this.cache,i=e.length,r=$a(t,i);Ct(n,r)||(s.uniform1iv(this.addr,r),Lt(n,r));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||Np,r[o])}function _x(s,e,t){const n=this.cache,i=e.length,r=$a(t,i);Ct(n,r)||(s.uniform1iv(this.addr,r),Lt(n,r));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||Dp,r[o])}function yx(s,e,t){const n=this.cache,i=e.length,r=$a(t,i);Ct(n,r)||(s.uniform1iv(this.addr,r),Lt(n,r));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||Up,r[o])}function xx(s){switch(s){case 5126:return tx;case 35664:return nx;case 35665:return ix;case 35666:return sx;case 35674:return rx;case 35675:return ox;case 35676:return ax;case 5124:case 35670:return cx;case 35667:case 35671:return lx;case 35668:case 35672:return hx;case 35669:case 35673:return ux;case 5125:return fx;case 36294:return dx;case 36295:return px;case 36296:return mx;case 35678:case 36198:case 36298:case 36306:case 35682:return gx;case 35679:case 36299:case 36307:return vx;case 35680:case 36300:case 36308:case 36293:return _x;case 36289:case 36303:case 36311:case 36292:return yx}}class Mx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=ex(t.type)}}class Sx{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=xx(t.type)}}class bx{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let r=0,o=i.length;r!==o;++r){const a=i[r];a.setValue(e,t[a.id],n)}}}const Wc=/(\w+)(\])?(\[|\.)?/g;function tf(s,e){s.seq.push(e),s.map[e.id]=e}function Ax(s,e,t){const n=s.name,i=n.length;for(Wc.lastIndex=0;;){const r=Wc.exec(n),o=Wc.lastIndex;let a=r[1];const c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){tf(t,l===void 0?new Mx(a,s,e):new Sx(a,s,e));break}else{let u=t.map[a];u===void 0&&(u=new bx(a),tf(t,u)),t=u}}}class Ma{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){const r=e.getActiveUniform(t,i),o=e.getUniformLocation(t,r.name);Ax(r,o,this)}}setValue(e,t,n,i){const r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){const a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,r=e.length;i!==r;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function nf(s,e,t){const n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}const wx=37297;let Tx=0;function Ex(s,e){const t=s.split(`
|
|
`),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=i;o<r;o++){const a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
`)}function Rx(s){const e=rt.getPrimaries(rt.workingColorSpace),t=rt.getPrimaries(s);let n;switch(e===t?n="":e===Vr&&t===Gr?n="LinearDisplayP3ToLinearSRGB":e===Gr&&t===Vr&&(n="LinearSRGBToLinearDisplayP3"),s){case Rt:case to:return[n,"LinearTransferOETF"];case ht:case qa:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",s),[n,"LinearTransferOETF"]}}function sf(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),i=s.getShaderInfoLog(e).trim();if(n&&i==="")return"";const r=/ERROR: 0:(\d+)/.exec(i);if(r){const o=parseInt(r[1]);return t.toUpperCase()+`
|
|
|
|
`+i+`
|
|
|
|
`+Ex(s.getShaderSource(e),o)}else return i}function Cx(s,e){const t=Rx(e);return`vec4 ${s}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function Lx(s,e){let t;switch(e){case Zd:t="Linear";break;case Kd:t="Reinhard";break;case jd:t="OptimizedCineon";break;case Jd:t="ACESFilmic";break;case Qd:t="AgX";break;case $d:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Px(s){return[s.extensionDerivatives||s.envMapCubeUVHeight||s.bumpMap||s.normalMapTangentSpace||s.clearcoatNormalMap||s.flatShading||s.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(s.extensionFragDepth||s.logarithmicDepthBuffer)&&s.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",s.extensionDrawBuffers&&s.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(s.extensionShaderTextureLOD||s.envMap||s.transmission)&&s.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Vs).join(`
|
|
`)}function Ix(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(Vs).join(`
|
|
`)}function Ux(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
`)}function Nx(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(e,i),o=r.name;let a=1;r.type===s.FLOAT_MAT2&&(a=2),r.type===s.FLOAT_MAT3&&(a=3),r.type===s.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:s.getAttribLocation(e,o),locationSize:a}}return t}function Vs(s){return s!==""}function rf(s,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.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_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)}function of(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Dx=/^[ \t]*#include +<([\w\d./]+)>/gm;function jl(s){return s.replace(Dx,Bx)}const Ox=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Bx(s,e){let t=Ve[e];if(t===void 0){const n=Ox.get(e);if(n!==void 0)t=Ve[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return jl(t)}const Fx=/#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 af(s){return s.replace(Fx,zx)}function zx(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function cf(s){let e="precision "+s.precision+` float;
|
|
precision `+s.precision+" int;";return s.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:s.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}function kx(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===dh?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===Sd?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===zn&&(e="SHADOWMAP_TYPE_VSM"),e}function Hx(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case oi:case Ei:e="ENVMAP_TYPE_CUBE";break;case ir:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Gx(s){let e="ENVMAP_MODE_REFLECTION";return s.envMap&&s.envMapMode===Ei&&(e="ENVMAP_MODE_REFRACTION"),e}function Vx(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case eo:e="ENVMAP_BLENDING_MULTIPLY";break;case qd:e="ENVMAP_BLENDING_MIX";break;case Yd:e="ENVMAP_BLENDING_ADD";break}return e}function Wx(s){const e=s.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function Xx(s,e,t,n){const i=s.getContext(),r=t.defines;let o=t.vertexShader,a=t.fragmentShader;const c=kx(t),l=Hx(t),h=Gx(t),u=Vx(t),f=Wx(t),d=t.isWebGL2?"":Px(t),p=Ix(t),v=Ux(r),g=i.createProgram();let m,y,_=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Vs).join(`
|
|
`),m.length>0&&(m+=`
|
|
`),y=[d,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Vs).join(`
|
|
`),y.length>0&&(y+=`
|
|
`)):(m=[cf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",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.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.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.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&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#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.useLegacyLights?"#define LEGACY_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","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","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
`].filter(Vs).join(`
|
|
`),y=[d,cf(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",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:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".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.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.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?"#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.useLegacyLights?"#define LEGACY_LIGHTS":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==si?"#define TONE_MAPPING":"",t.toneMapping!==si?Ve.tonemapping_pars_fragment:"",t.toneMapping!==si?Lx("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Ve.colorspace_pars_fragment,Cx("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
`].filter(Vs).join(`
|
|
`)),o=jl(o),o=rf(o,t),o=of(o,t),a=jl(a),a=rf(a,t),a=of(a,t),o=af(o),a=af(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(_=`#version 300 es
|
|
`,m=[p,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
`)+`
|
|
`+m,y=["precision mediump sampler2DArray;","#define varying in",t.glslVersion===Yl?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Yl?"":"#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(`
|
|
`)+`
|
|
`+y);const x=_+m+o,T=_+y+a,b=nf(i,i.VERTEX_SHADER,x),A=nf(i,i.FRAGMENT_SHADER,T);i.attachShader(g,b),i.attachShader(g,A),t.index0AttributeName!==void 0?i.bindAttribLocation(g,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(g,0,"position"),i.linkProgram(g);function L(H){if(s.debug.checkShaderErrors){const K=i.getProgramInfoLog(g).trim(),I=i.getShaderInfoLog(b).trim(),F=i.getShaderInfoLog(A).trim();let k=!0,te=!0;if(i.getProgramParameter(g,i.LINK_STATUS)===!1)if(k=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,g,b,A);else{const J=sf(i,b,"vertex"),$=sf(i,A,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(g,i.VALIDATE_STATUS)+`
|
|
|
|
Program Info Log: `+K+`
|
|
`+J+`
|
|
`+$)}else K!==""?console.warn("THREE.WebGLProgram: Program Info Log:",K):(I===""||F==="")&&(te=!1);te&&(H.diagnostics={runnable:k,programLog:K,vertexShader:{log:I,prefix:m},fragmentShader:{log:F,prefix:y}})}i.deleteShader(b),i.deleteShader(A),M=new Ma(i,g),w=Nx(i,g)}let M;this.getUniforms=function(){return M===void 0&&L(this),M};let w;this.getAttributes=function(){return w===void 0&&L(this),w};let O=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return O===!1&&(O=i.getProgramParameter(g,wx)),O},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Tx++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=b,this.fragmentShader=A,this}let qx=0;class Yx{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Zx(e),t.set(e,n)),n}}class Zx{constructor(e){this.id=qx++,this.code=e,this.usedTimes=0}}function Kx(s,e,t,n,i,r,o){const a=new Ka,c=new Yx,l=[],h=i.isWebGL2,u=i.logarithmicDepthBuffer,f=i.vertexTextures;let d=i.precision;const p={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 v(M){return M===0?"uv":`uv${M}`}function g(M,w,O,H,K){const I=H.fog,F=K.geometry,k=M.isMeshStandardMaterial?H.environment:null,te=(M.isMeshStandardMaterial?t:e).get(M.envMap||k),J=te&&te.mapping===ir?te.image.height:null,$=p[M.type];M.precision!==null&&(d=i.getMaxPrecision(M.precision),d!==M.precision&&console.warn("THREE.WebGLProgram.getParameters:",M.precision,"not supported, using",d,"instead."));const le=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,ce=le!==void 0?le.length:0;let ge=0;F.morphAttributes.position!==void 0&&(ge=1),F.morphAttributes.normal!==void 0&&(ge=2),F.morphAttributes.color!==void 0&&(ge=3);let Z,U,N,V;if($){const qt=jt[$];Z=qt.vertexShader,U=qt.fragmentShader}else Z=M.vertexShader,U=M.fragmentShader,c.update(M),N=c.getVertexShaderID(M),V=c.getFragmentShaderID(M);const W=s.getRenderTarget(),q=K.isInstancedMesh===!0,j=K.isBatchedMesh===!0,Y=!!M.map,oe=!!M.matcap,R=!!te,ie=!!M.aoMap,G=!!M.lightMap,Q=!!M.bumpMap,re=!!M.normalMap,Me=!!M.displacementMap,me=!!M.emissiveMap,E=!!M.metalnessMap,S=!!M.roughnessMap,z=M.anisotropy>0,he=M.clearcoat>0,ue=M.iridescence>0,fe=M.sheen>0,Re=M.transmission>0,Se=z&&!!M.anisotropyMap,be=he&&!!M.clearcoatMap,Ue=he&&!!M.clearcoatNormalMap,ke=he&&!!M.clearcoatRoughnessMap,de=ue&&!!M.iridescenceMap,Ze=ue&&!!M.iridescenceThicknessMap,D=fe&&!!M.sheenColorMap,pe=fe&&!!M.sheenRoughnessMap,we=!!M.specularMap,ve=!!M.specularColorMap,Le=!!M.specularIntensityMap,Ke=Re&&!!M.transmissionMap,Qe=Re&&!!M.thicknessMap,qe=!!M.gradientMap,Ae=!!M.alphaMap,B=M.alphaTest>0,ye=!!M.alphaHash,xe=!!M.extensions,De=!!F.attributes.uv1,Pe=!!F.attributes.uv2,it=!!F.attributes.uv3;let st=si;return M.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(st=s.toneMapping),{isWebGL2:h,shaderID:$,shaderType:M.type,shaderName:M.name,vertexShader:Z,fragmentShader:U,defines:M.defines,customVertexShaderID:N,customFragmentShaderID:V,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:d,batching:j,instancing:q,instancingColor:q&&K.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:W===null?s.outputColorSpace:W.isXRRenderTarget===!0?W.texture.colorSpace:Rt,map:Y,matcap:oe,envMap:R,envMapMode:R&&te.mapping,envMapCubeUVHeight:J,aoMap:ie,lightMap:G,bumpMap:Q,normalMap:re,displacementMap:f&&Me,emissiveMap:me,normalMapObjectSpace:re&&M.normalMapType===mp,normalMapTangentSpace:re&&M.normalMapType===Pi,metalnessMap:E,roughnessMap:S,anisotropy:z,anisotropyMap:Se,clearcoat:he,clearcoatMap:be,clearcoatNormalMap:Ue,clearcoatRoughnessMap:ke,iridescence:ue,iridescenceMap:de,iridescenceThicknessMap:Ze,sheen:fe,sheenColorMap:D,sheenRoughnessMap:pe,specularMap:we,specularColorMap:ve,specularIntensityMap:Le,transmission:Re,transmissionMap:Ke,thicknessMap:Qe,gradientMap:qe,opaque:M.transparent===!1&&M.blending===is,alphaMap:Ae,alphaTest:B,alphaHash:ye,combine:M.combine,mapUv:Y&&v(M.map.channel),aoMapUv:ie&&v(M.aoMap.channel),lightMapUv:G&&v(M.lightMap.channel),bumpMapUv:Q&&v(M.bumpMap.channel),normalMapUv:re&&v(M.normalMap.channel),displacementMapUv:Me&&v(M.displacementMap.channel),emissiveMapUv:me&&v(M.emissiveMap.channel),metalnessMapUv:E&&v(M.metalnessMap.channel),roughnessMapUv:S&&v(M.roughnessMap.channel),anisotropyMapUv:Se&&v(M.anisotropyMap.channel),clearcoatMapUv:be&&v(M.clearcoatMap.channel),clearcoatNormalMapUv:Ue&&v(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ke&&v(M.clearcoatRoughnessMap.channel),iridescenceMapUv:de&&v(M.iridescenceMap.channel),iridescenceThicknessMapUv:Ze&&v(M.iridescenceThicknessMap.channel),sheenColorMapUv:D&&v(M.sheenColorMap.channel),sheenRoughnessMapUv:pe&&v(M.sheenRoughnessMap.channel),specularMapUv:we&&v(M.specularMap.channel),specularColorMapUv:ve&&v(M.specularColorMap.channel),specularIntensityMapUv:Le&&v(M.specularIntensityMap.channel),transmissionMapUv:Ke&&v(M.transmissionMap.channel),thicknessMapUv:Qe&&v(M.thicknessMap.channel),alphaMapUv:Ae&&v(M.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(re||z),vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,vertexUv1s:De,vertexUv2s:Pe,vertexUv3s:it,pointsUvs:K.isPoints===!0&&!!F.attributes.uv&&(Y||Ae),fog:!!I,useFog:M.fog===!0,fogExp2:I&&I.isFogExp2,flatShading:M.flatShading===!0,sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,skinning:K.isSkinnedMesh===!0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:ce,morphTextureStride:ge,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:M.dithering,shadowMapEnabled:s.shadowMap.enabled&&O.length>0,shadowMapType:s.shadowMap.type,toneMapping:st,useLegacyLights:s._useLegacyLights,decodeVideoTexture:Y&&M.map.isVideoTexture===!0&&rt.getTransfer(M.map.colorSpace)===lt,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Tn,flipSided:M.side===Qt,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionDerivatives:xe&&M.extensions.derivatives===!0,extensionFragDepth:xe&&M.extensions.fragDepth===!0,extensionDrawBuffers:xe&&M.extensions.drawBuffers===!0,extensionShaderTextureLOD:xe&&M.extensions.shaderTextureLOD===!0,extensionClipCullDistance:xe&&M.extensions.clipCullDistance&&n.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()}}function m(M){const w=[];if(M.shaderID?w.push(M.shaderID):(w.push(M.customVertexShaderID),w.push(M.customFragmentShaderID)),M.defines!==void 0)for(const O in M.defines)w.push(O),w.push(M.defines[O]);return M.isRawShaderMaterial===!1&&(y(w,M),_(w,M),w.push(s.outputColorSpace)),w.push(M.customProgramCacheKey),w.join()}function y(M,w){M.push(w.precision),M.push(w.outputColorSpace),M.push(w.envMapMode),M.push(w.envMapCubeUVHeight),M.push(w.mapUv),M.push(w.alphaMapUv),M.push(w.lightMapUv),M.push(w.aoMapUv),M.push(w.bumpMapUv),M.push(w.normalMapUv),M.push(w.displacementMapUv),M.push(w.emissiveMapUv),M.push(w.metalnessMapUv),M.push(w.roughnessMapUv),M.push(w.anisotropyMapUv),M.push(w.clearcoatMapUv),M.push(w.clearcoatNormalMapUv),M.push(w.clearcoatRoughnessMapUv),M.push(w.iridescenceMapUv),M.push(w.iridescenceThicknessMapUv),M.push(w.sheenColorMapUv),M.push(w.sheenRoughnessMapUv),M.push(w.specularMapUv),M.push(w.specularColorMapUv),M.push(w.specularIntensityMapUv),M.push(w.transmissionMapUv),M.push(w.thicknessMapUv),M.push(w.combine),M.push(w.fogExp2),M.push(w.sizeAttenuation),M.push(w.morphTargetsCount),M.push(w.morphAttributeCount),M.push(w.numDirLights),M.push(w.numPointLights),M.push(w.numSpotLights),M.push(w.numSpotLightMaps),M.push(w.numHemiLights),M.push(w.numRectAreaLights),M.push(w.numDirLightShadows),M.push(w.numPointLightShadows),M.push(w.numSpotLightShadows),M.push(w.numSpotLightShadowsWithMaps),M.push(w.numLightProbes),M.push(w.shadowMapType),M.push(w.toneMapping),M.push(w.numClippingPlanes),M.push(w.numClipIntersection),M.push(w.depthPacking)}function _(M,w){a.disableAll(),w.isWebGL2&&a.enable(0),w.supportsVertexTextures&&a.enable(1),w.instancing&&a.enable(2),w.instancingColor&&a.enable(3),w.matcap&&a.enable(4),w.envMap&&a.enable(5),w.normalMapObjectSpace&&a.enable(6),w.normalMapTangentSpace&&a.enable(7),w.clearcoat&&a.enable(8),w.iridescence&&a.enable(9),w.alphaTest&&a.enable(10),w.vertexColors&&a.enable(11),w.vertexAlphas&&a.enable(12),w.vertexUv1s&&a.enable(13),w.vertexUv2s&&a.enable(14),w.vertexUv3s&&a.enable(15),w.vertexTangents&&a.enable(16),w.anisotropy&&a.enable(17),w.alphaHash&&a.enable(18),w.batching&&a.enable(19),M.push(a.mask),a.disableAll(),w.fog&&a.enable(0),w.useFog&&a.enable(1),w.flatShading&&a.enable(2),w.logarithmicDepthBuffer&&a.enable(3),w.skinning&&a.enable(4),w.morphTargets&&a.enable(5),w.morphNormals&&a.enable(6),w.morphColors&&a.enable(7),w.premultipliedAlpha&&a.enable(8),w.shadowMapEnabled&&a.enable(9),w.useLegacyLights&&a.enable(10),w.doubleSided&&a.enable(11),w.flipSided&&a.enable(12),w.useDepthPacking&&a.enable(13),w.dithering&&a.enable(14),w.transmission&&a.enable(15),w.sheen&&a.enable(16),w.opaque&&a.enable(17),w.pointsUvs&&a.enable(18),w.decodeVideoTexture&&a.enable(19),M.push(a.mask)}function x(M){const w=p[M.type];let O;if(w){const H=jt[w];O=ja.clone(H.uniforms)}else O=M.uniforms;return O}function T(M,w){let O;for(let H=0,K=l.length;H<K;H++){const I=l[H];if(I.cacheKey===w){O=I,++O.usedTimes;break}}return O===void 0&&(O=new Xx(s,w,M,r),l.push(O)),O}function b(M){if(--M.usedTimes===0){const w=l.indexOf(M);l[w]=l[l.length-1],l.pop(),M.destroy()}}function A(M){c.remove(M)}function L(){c.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:x,acquireProgram:T,releaseProgram:b,releaseShaderCache:A,programs:l,dispose:L}}function jx(){let s=new WeakMap;function e(r){let o=s.get(r);return o===void 0&&(o={},s.set(r,o)),o}function t(r){s.delete(r)}function n(r,o,a){s.get(r)[o]=a}function i(){s=new WeakMap}return{get:e,remove:t,update:n,dispose:i}}function Jx(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.z!==e.z?s.z-e.z:s.id-e.id}function lf(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function hf(){const s=[];let e=0;const t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function o(u,f,d,p,v,g){let m=s[e];return m===void 0?(m={id:u.id,object:u,geometry:f,material:d,groupOrder:p,renderOrder:u.renderOrder,z:v,group:g},s[e]=m):(m.id=u.id,m.object=u,m.geometry=f,m.material=d,m.groupOrder=p,m.renderOrder=u.renderOrder,m.z=v,m.group=g),e++,m}function a(u,f,d,p,v,g){const m=o(u,f,d,p,v,g);d.transmission>0?n.push(m):d.transparent===!0?i.push(m):t.push(m)}function c(u,f,d,p,v,g){const m=o(u,f,d,p,v,g);d.transmission>0?n.unshift(m):d.transparent===!0?i.unshift(m):t.unshift(m)}function l(u,f){t.length>1&&t.sort(u||Jx),n.length>1&&n.sort(f||lf),i.length>1&&i.sort(f||lf)}function h(){for(let u=e,f=s.length;u<f;u++){const d=s[u];if(d.id===null)break;d.id=null,d.object=null,d.geometry=null,d.material=null,d.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:a,unshift:c,finish:h,sort:l}}function $x(){let s=new WeakMap;function e(n,i){const r=s.get(n);let o;return r===void 0?(o=new hf,s.set(n,[o])):i>=r.length?(o=new hf,r.push(o)):o=r[i],o}function t(){s=new WeakMap}return{get:e,dispose:t}}function Qx(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new C,color:new Te};break;case"SpotLight":t={position:new C,direction:new C,color:new Te,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new C,color:new Te,distance:0,decay:0};break;case"HemisphereLight":t={direction:new C,skyColor:new Te,groundColor:new Te};break;case"RectAreaLight":t={color:new Te,position:new C,halfWidth:new C,halfHeight:new C};break}return s[e.id]=t,t}}}function eM(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ae};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ae};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let tM=0;function nM(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function iM(s,e){const t=new Qx,n=eM(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let h=0;h<9;h++)i.probe.push(new C);const r=new C,o=new Ne,a=new Ne;function c(h,u){let f=0,d=0,p=0;for(let H=0;H<9;H++)i.probe[H].set(0,0,0);let v=0,g=0,m=0,y=0,_=0,x=0,T=0,b=0,A=0,L=0,M=0;h.sort(nM);const w=u===!0?Math.PI:1;for(let H=0,K=h.length;H<K;H++){const I=h[H],F=I.color,k=I.intensity,te=I.distance,J=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)f+=F.r*k*w,d+=F.g*k*w,p+=F.b*k*w;else if(I.isLightProbe){for(let $=0;$<9;$++)i.probe[$].addScaledVector(I.sh.coefficients[$],k);M++}else if(I.isDirectionalLight){const $=t.get(I);if($.color.copy(I.color).multiplyScalar(I.intensity*w),I.castShadow){const le=I.shadow,ce=n.get(I);ce.shadowBias=le.bias,ce.shadowNormalBias=le.normalBias,ce.shadowRadius=le.radius,ce.shadowMapSize=le.mapSize,i.directionalShadow[v]=ce,i.directionalShadowMap[v]=J,i.directionalShadowMatrix[v]=I.shadow.matrix,x++}i.directional[v]=$,v++}else if(I.isSpotLight){const $=t.get(I);$.position.setFromMatrixPosition(I.matrixWorld),$.color.copy(F).multiplyScalar(k*w),$.distance=te,$.coneCos=Math.cos(I.angle),$.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),$.decay=I.decay,i.spot[m]=$;const le=I.shadow;if(I.map&&(i.spotLightMap[A]=I.map,A++,le.updateMatrices(I),I.castShadow&&L++),i.spotLightMatrix[m]=le.matrix,I.castShadow){const ce=n.get(I);ce.shadowBias=le.bias,ce.shadowNormalBias=le.normalBias,ce.shadowRadius=le.radius,ce.shadowMapSize=le.mapSize,i.spotShadow[m]=ce,i.spotShadowMap[m]=J,b++}m++}else if(I.isRectAreaLight){const $=t.get(I);$.color.copy(F).multiplyScalar(k),$.halfWidth.set(I.width*.5,0,0),$.halfHeight.set(0,I.height*.5,0),i.rectArea[y]=$,y++}else if(I.isPointLight){const $=t.get(I);if($.color.copy(I.color).multiplyScalar(I.intensity*w),$.distance=I.distance,$.decay=I.decay,I.castShadow){const le=I.shadow,ce=n.get(I);ce.shadowBias=le.bias,ce.shadowNormalBias=le.normalBias,ce.shadowRadius=le.radius,ce.shadowMapSize=le.mapSize,ce.shadowCameraNear=le.camera.near,ce.shadowCameraFar=le.camera.far,i.pointShadow[g]=ce,i.pointShadowMap[g]=J,i.pointShadowMatrix[g]=I.shadow.matrix,T++}i.point[g]=$,g++}else if(I.isHemisphereLight){const $=t.get(I);$.skyColor.copy(I.color).multiplyScalar(k*w),$.groundColor.copy(I.groundColor).multiplyScalar(k*w),i.hemi[_]=$,_++}}y>0&&(e.isWebGL2?s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=_e.LTC_FLOAT_1,i.rectAreaLTC2=_e.LTC_FLOAT_2):(i.rectAreaLTC1=_e.LTC_HALF_1,i.rectAreaLTC2=_e.LTC_HALF_2):s.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=_e.LTC_FLOAT_1,i.rectAreaLTC2=_e.LTC_FLOAT_2):s.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=_e.LTC_HALF_1,i.rectAreaLTC2=_e.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=f,i.ambient[1]=d,i.ambient[2]=p;const O=i.hash;(O.directionalLength!==v||O.pointLength!==g||O.spotLength!==m||O.rectAreaLength!==y||O.hemiLength!==_||O.numDirectionalShadows!==x||O.numPointShadows!==T||O.numSpotShadows!==b||O.numSpotMaps!==A||O.numLightProbes!==M)&&(i.directional.length=v,i.spot.length=m,i.rectArea.length=y,i.point.length=g,i.hemi.length=_,i.directionalShadow.length=x,i.directionalShadowMap.length=x,i.pointShadow.length=T,i.pointShadowMap.length=T,i.spotShadow.length=b,i.spotShadowMap.length=b,i.directionalShadowMatrix.length=x,i.pointShadowMatrix.length=T,i.spotLightMatrix.length=b+A-L,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=L,i.numLightProbes=M,O.directionalLength=v,O.pointLength=g,O.spotLength=m,O.rectAreaLength=y,O.hemiLength=_,O.numDirectionalShadows=x,O.numPointShadows=T,O.numSpotShadows=b,O.numSpotMaps=A,O.numLightProbes=M,i.version=tM++)}function l(h,u){let f=0,d=0,p=0,v=0,g=0;const m=u.matrixWorldInverse;for(let y=0,_=h.length;y<_;y++){const x=h[y];if(x.isDirectionalLight){const T=i.directional[f];T.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),T.direction.sub(r),T.direction.transformDirection(m),f++}else if(x.isSpotLight){const T=i.spot[p];T.position.setFromMatrixPosition(x.matrixWorld),T.position.applyMatrix4(m),T.direction.setFromMatrixPosition(x.matrixWorld),r.setFromMatrixPosition(x.target.matrixWorld),T.direction.sub(r),T.direction.transformDirection(m),p++}else if(x.isRectAreaLight){const T=i.rectArea[v];T.position.setFromMatrixPosition(x.matrixWorld),T.position.applyMatrix4(m),a.identity(),o.copy(x.matrixWorld),o.premultiply(m),a.extractRotation(o),T.halfWidth.set(x.width*.5,0,0),T.halfHeight.set(0,x.height*.5,0),T.halfWidth.applyMatrix4(a),T.halfHeight.applyMatrix4(a),v++}else if(x.isPointLight){const T=i.point[d];T.position.setFromMatrixPosition(x.matrixWorld),T.position.applyMatrix4(m),d++}else if(x.isHemisphereLight){const T=i.hemi[g];T.direction.setFromMatrixPosition(x.matrixWorld),T.direction.transformDirection(m),g++}}}return{setup:c,setupView:l,state:i}}function uf(s,e){const t=new iM(s,e),n=[],i=[];function r(){n.length=0,i.length=0}function o(u){n.push(u)}function a(u){i.push(u)}function c(u){t.setup(n,u)}function l(u){t.setupView(n,u)}return{init:r,state:{lightsArray:n,shadowsArray:i,lights:t},setupLights:c,setupLightsView:l,pushLight:o,pushShadow:a}}function sM(s,e){let t=new WeakMap;function n(r,o=0){const a=t.get(r);let c;return a===void 0?(c=new uf(s,e),t.set(r,[c])):o>=a.length?(c=new uf(s,e),a.push(c)):c=a[o],c}function i(){t=new WeakMap}return{get:n,dispose:i}}class Ih extends Et{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=dp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Uh extends Et{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}}const rM=`void main() {
|
|
gl_Position = vec4( position, 1.0 );
|
|
}`,oM=`uniform sampler2D shadow_pass;
|
|
uniform vec2 resolution;
|
|
uniform float radius;
|
|
#include <packing>
|
|
void main() {
|
|
const float samples = float( VSM_SAMPLES );
|
|
float mean = 0.0;
|
|
float squared_mean = 0.0;
|
|
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
for ( float i = 0.0; i < samples; i ++ ) {
|
|
float uvOffset = uvStart + i * uvStride;
|
|
#ifdef HORIZONTAL_PASS
|
|
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
mean += distribution.x;
|
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
#else
|
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
mean += depth;
|
|
squared_mean += depth * depth;
|
|
#endif
|
|
}
|
|
mean = mean / samples;
|
|
squared_mean = squared_mean / samples;
|
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
}`;function aM(s,e,t){let n=new so;const i=new ae,r=new ae,o=new nt,a=new Ih({depthPacking:pp}),c=new Uh,l={},h=t.maxTextureSize,u={[Gn]:Qt,[Qt]:Gn,[Tn]:Tn},f=new Ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ae},radius:{value:4}},vertexShader:rM,fragmentShader:oM}),d=f.clone();d.defines.HORIZONTAL_PASS=1;const p=new Be;p.setAttribute("position",new Fe(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new ft(p,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=dh;let m=this.type;this.render=function(b,A,L){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||b.length===0)return;const M=s.getRenderTarget(),w=s.getActiveCubeFace(),O=s.getActiveMipmapLevel(),H=s.state;H.setBlending(ii),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const K=m!==zn&&this.type===zn,I=m===zn&&this.type!==zn;for(let F=0,k=b.length;F<k;F++){const te=b[F],J=te.shadow;if(J===void 0){console.warn("THREE.WebGLShadowMap:",te,"has no shadow.");continue}if(J.autoUpdate===!1&&J.needsUpdate===!1)continue;i.copy(J.mapSize);const $=J.getFrameExtents();if(i.multiply($),r.copy(J.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/$.x),i.x=r.x*$.x,J.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/$.y),i.y=r.y*$.y,J.mapSize.y=r.y)),J.map===null||K===!0||I===!0){const ce=this.type!==zn?{minFilter:dt,magFilter:dt}:{};J.map!==null&&J.map.dispose(),J.map=new Cn(i.x,i.y,ce),J.map.texture.name=te.name+".shadowMap",J.camera.updateProjectionMatrix()}s.setRenderTarget(J.map),s.clear();const le=J.getViewportCount();for(let ce=0;ce<le;ce++){const ge=J.getViewport(ce);o.set(r.x*ge.x,r.y*ge.y,r.x*ge.z,r.y*ge.w),H.viewport(o),J.updateMatrices(te,ce),n=J.getFrustum(),x(A,L,J.camera,te,this.type)}J.isPointLightShadow!==!0&&this.type===zn&&y(J,L),J.needsUpdate=!1}m=this.type,g.needsUpdate=!1,s.setRenderTarget(M,w,O)};function y(b,A){const L=e.update(v);f.defines.VSM_SAMPLES!==b.blurSamples&&(f.defines.VSM_SAMPLES=b.blurSamples,d.defines.VSM_SAMPLES=b.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Cn(i.x,i.y)),f.uniforms.shadow_pass.value=b.map.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,s.setRenderTarget(b.mapPass),s.clear(),s.renderBufferDirect(A,null,L,f,v,null),d.uniforms.shadow_pass.value=b.mapPass.texture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,s.setRenderTarget(b.map),s.clear(),s.renderBufferDirect(A,null,L,d,v,null)}function _(b,A,L,M){let w=null;const O=L.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(O!==void 0)w=O;else if(w=L.isPointLight===!0?c:a,s.localClippingEnabled&&A.clipShadows===!0&&Array.isArray(A.clippingPlanes)&&A.clippingPlanes.length!==0||A.displacementMap&&A.displacementScale!==0||A.alphaMap&&A.alphaTest>0||A.map&&A.alphaTest>0){const H=w.uuid,K=A.uuid;let I=l[H];I===void 0&&(I={},l[H]=I);let F=I[K];F===void 0&&(F=w.clone(),I[K]=F,A.addEventListener("dispose",T)),w=F}if(w.visible=A.visible,w.wireframe=A.wireframe,M===zn?w.side=A.shadowSide!==null?A.shadowSide:A.side:w.side=A.shadowSide!==null?A.shadowSide:u[A.side],w.alphaMap=A.alphaMap,w.alphaTest=A.alphaTest,w.map=A.map,w.clipShadows=A.clipShadows,w.clippingPlanes=A.clippingPlanes,w.clipIntersection=A.clipIntersection,w.displacementMap=A.displacementMap,w.displacementScale=A.displacementScale,w.displacementBias=A.displacementBias,w.wireframeLinewidth=A.wireframeLinewidth,w.linewidth=A.linewidth,L.isPointLight===!0&&w.isMeshDistanceMaterial===!0){const H=s.properties.get(w);H.light=L}return w}function x(b,A,L,M,w){if(b.visible===!1)return;if(b.layers.test(A.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&w===zn)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(L.matrixWorldInverse,b.matrixWorld);const K=e.update(b),I=b.material;if(Array.isArray(I)){const F=K.groups;for(let k=0,te=F.length;k<te;k++){const J=F[k],$=I[J.materialIndex];if($&&$.visible){const le=_(b,$,M,w);b.onBeforeShadow(s,b,A,L,K,le,J),s.renderBufferDirect(L,null,K,le,b,J),b.onAfterShadow(s,b,A,L,K,le,J)}}}else if(I.visible){const F=_(b,I,M,w);b.onBeforeShadow(s,b,A,L,K,F,null),s.renderBufferDirect(L,null,K,F,b,null),b.onAfterShadow(s,b,A,L,K,F,null)}}const H=b.children;for(let K=0,I=H.length;K<I;K++)x(H[K],A,L,M,w)}function T(b){b.target.removeEventListener("dispose",T);for(const L in l){const M=l[L],w=b.target.uuid;w in M&&(M[w].dispose(),delete M[w])}}}function cM(s,e,t){const n=t.isWebGL2;function i(){let B=!1;const ye=new nt;let xe=null;const De=new nt(0,0,0,0);return{setMask:function(Pe){xe!==Pe&&!B&&(s.colorMask(Pe,Pe,Pe,Pe),xe=Pe)},setLocked:function(Pe){B=Pe},setClear:function(Pe,it,st,Pt,qt){qt===!0&&(Pe*=Pt,it*=Pt,st*=Pt),ye.set(Pe,it,st,Pt),De.equals(ye)===!1&&(s.clearColor(Pe,it,st,Pt),De.copy(ye))},reset:function(){B=!1,xe=null,De.set(-1,0,0,0)}}}function r(){let B=!1,ye=null,xe=null,De=null;return{setTest:function(Pe){Pe?j(s.DEPTH_TEST):Y(s.DEPTH_TEST)},setMask:function(Pe){ye!==Pe&&!B&&(s.depthMask(Pe),ye=Pe)},setFunc:function(Pe){if(xe!==Pe){switch(Pe){case zd:s.depthFunc(s.NEVER);break;case kd:s.depthFunc(s.ALWAYS);break;case Hd:s.depthFunc(s.LESS);break;case Or:s.depthFunc(s.LEQUAL);break;case Gd:s.depthFunc(s.EQUAL);break;case Vd:s.depthFunc(s.GEQUAL);break;case Wd:s.depthFunc(s.GREATER);break;case Xd:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}xe=Pe}},setLocked:function(Pe){B=Pe},setClear:function(Pe){De!==Pe&&(s.clearDepth(Pe),De=Pe)},reset:function(){B=!1,ye=null,xe=null,De=null}}}function o(){let B=!1,ye=null,xe=null,De=null,Pe=null,it=null,st=null,Pt=null,qt=null;return{setTest:function(ct){B||(ct?j(s.STENCIL_TEST):Y(s.STENCIL_TEST))},setMask:function(ct){ye!==ct&&!B&&(s.stencilMask(ct),ye=ct)},setFunc:function(ct,Yt,Dn){(xe!==ct||De!==Yt||Pe!==Dn)&&(s.stencilFunc(ct,Yt,Dn),xe=ct,De=Yt,Pe=Dn)},setOp:function(ct,Yt,Dn){(it!==ct||st!==Yt||Pt!==Dn)&&(s.stencilOp(ct,Yt,Dn),it=ct,st=Yt,Pt=Dn)},setLocked:function(ct){B=ct},setClear:function(ct){qt!==ct&&(s.clearStencil(ct),qt=ct)},reset:function(){B=!1,ye=null,xe=null,De=null,Pe=null,it=null,st=null,Pt=null,qt=null}}}const a=new i,c=new r,l=new o,h=new WeakMap,u=new WeakMap;let f={},d={},p=new WeakMap,v=[],g=null,m=!1,y=null,_=null,x=null,T=null,b=null,A=null,L=null,M=new Te(0,0,0),w=0,O=!1,H=null,K=null,I=null,F=null,k=null;const te=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let J=!1,$=0;const le=s.getParameter(s.VERSION);le.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(le)[1]),J=$>=1):le.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(le)[1]),J=$>=2);let ce=null,ge={};const Z=s.getParameter(s.SCISSOR_BOX),U=s.getParameter(s.VIEWPORT),N=new nt().fromArray(Z),V=new nt().fromArray(U);function W(B,ye,xe,De){const Pe=new Uint8Array(4),it=s.createTexture();s.bindTexture(B,it),s.texParameteri(B,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(B,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let st=0;st<xe;st++)n&&(B===s.TEXTURE_3D||B===s.TEXTURE_2D_ARRAY)?s.texImage3D(ye,0,s.RGBA,1,1,De,0,s.RGBA,s.UNSIGNED_BYTE,Pe):s.texImage2D(ye+st,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,Pe);return it}const q={};q[s.TEXTURE_2D]=W(s.TEXTURE_2D,s.TEXTURE_2D,1),q[s.TEXTURE_CUBE_MAP]=W(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(q[s.TEXTURE_2D_ARRAY]=W(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),q[s.TEXTURE_3D]=W(s.TEXTURE_3D,s.TEXTURE_3D,1,1)),a.setClear(0,0,0,1),c.setClear(1),l.setClear(0),j(s.DEPTH_TEST),c.setFunc(Or),me(!1),E(pl),j(s.CULL_FACE),re(ii);function j(B){f[B]!==!0&&(s.enable(B),f[B]=!0)}function Y(B){f[B]!==!1&&(s.disable(B),f[B]=!1)}function oe(B,ye){return d[B]!==ye?(s.bindFramebuffer(B,ye),d[B]=ye,n&&(B===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=ye),B===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=ye)),!0):!1}function R(B,ye){let xe=v,De=!1;if(B)if(xe=p.get(ye),xe===void 0&&(xe=[],p.set(ye,xe)),B.isWebGLMultipleRenderTargets){const Pe=B.texture;if(xe.length!==Pe.length||xe[0]!==s.COLOR_ATTACHMENT0){for(let it=0,st=Pe.length;it<st;it++)xe[it]=s.COLOR_ATTACHMENT0+it;xe.length=Pe.length,De=!0}}else xe[0]!==s.COLOR_ATTACHMENT0&&(xe[0]=s.COLOR_ATTACHMENT0,De=!0);else xe[0]!==s.BACK&&(xe[0]=s.BACK,De=!0);De&&(t.isWebGL2?s.drawBuffers(xe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(xe))}function ie(B){return g!==B?(s.useProgram(B),g=B,!0):!1}const G={[Mi]:s.FUNC_ADD,[Ad]:s.FUNC_SUBTRACT,[wd]:s.FUNC_REVERSE_SUBTRACT};if(n)G[_l]=s.MIN,G[yl]=s.MAX;else{const B=e.get("EXT_blend_minmax");B!==null&&(G[_l]=B.MIN_EXT,G[yl]=B.MAX_EXT)}const Q={[Td]:s.ZERO,[Ed]:s.ONE,[Rd]:s.SRC_COLOR,[wa]:s.SRC_ALPHA,[Nd]:s.SRC_ALPHA_SATURATE,[Id]:s.DST_COLOR,[Ld]:s.DST_ALPHA,[Cd]:s.ONE_MINUS_SRC_COLOR,[Ta]:s.ONE_MINUS_SRC_ALPHA,[Ud]:s.ONE_MINUS_DST_COLOR,[Pd]:s.ONE_MINUS_DST_ALPHA,[Dd]:s.CONSTANT_COLOR,[Od]:s.ONE_MINUS_CONSTANT_COLOR,[Bd]:s.CONSTANT_ALPHA,[Fd]:s.ONE_MINUS_CONSTANT_ALPHA};function re(B,ye,xe,De,Pe,it,st,Pt,qt,ct){if(B===ii){m===!0&&(Y(s.BLEND),m=!1);return}if(m===!1&&(j(s.BLEND),m=!0),B!==bd){if(B!==y||ct!==O){if((_!==Mi||b!==Mi)&&(s.blendEquation(s.FUNC_ADD),_=Mi,b=Mi),ct)switch(B){case is:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ml:s.blendFunc(s.ONE,s.ONE);break;case gl:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case vl:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}else switch(B){case is:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ml:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case gl:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case vl:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",B);break}x=null,T=null,A=null,L=null,M.set(0,0,0),w=0,y=B,O=ct}return}Pe=Pe||ye,it=it||xe,st=st||De,(ye!==_||Pe!==b)&&(s.blendEquationSeparate(G[ye],G[Pe]),_=ye,b=Pe),(xe!==x||De!==T||it!==A||st!==L)&&(s.blendFuncSeparate(Q[xe],Q[De],Q[it],Q[st]),x=xe,T=De,A=it,L=st),(Pt.equals(M)===!1||qt!==w)&&(s.blendColor(Pt.r,Pt.g,Pt.b,qt),M.copy(Pt),w=qt),y=B,O=!1}function Me(B,ye){B.side===Tn?Y(s.CULL_FACE):j(s.CULL_FACE);let xe=B.side===Qt;ye&&(xe=!xe),me(xe),B.blending===is&&B.transparent===!1?re(ii):re(B.blending,B.blendEquation,B.blendSrc,B.blendDst,B.blendEquationAlpha,B.blendSrcAlpha,B.blendDstAlpha,B.blendColor,B.blendAlpha,B.premultipliedAlpha),c.setFunc(B.depthFunc),c.setTest(B.depthTest),c.setMask(B.depthWrite),a.setMask(B.colorWrite);const De=B.stencilWrite;l.setTest(De),De&&(l.setMask(B.stencilWriteMask),l.setFunc(B.stencilFunc,B.stencilRef,B.stencilFuncMask),l.setOp(B.stencilFail,B.stencilZFail,B.stencilZPass)),z(B.polygonOffset,B.polygonOffsetFactor,B.polygonOffsetUnits),B.alphaToCoverage===!0?j(s.SAMPLE_ALPHA_TO_COVERAGE):Y(s.SAMPLE_ALPHA_TO_COVERAGE)}function me(B){H!==B&&(B?s.frontFace(s.CW):s.frontFace(s.CCW),H=B)}function E(B){B!==xd?(j(s.CULL_FACE),B!==K&&(B===pl?s.cullFace(s.BACK):B===Md?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Y(s.CULL_FACE),K=B}function S(B){B!==I&&(J&&s.lineWidth(B),I=B)}function z(B,ye,xe){B?(j(s.POLYGON_OFFSET_FILL),(F!==ye||k!==xe)&&(s.polygonOffset(ye,xe),F=ye,k=xe)):Y(s.POLYGON_OFFSET_FILL)}function he(B){B?j(s.SCISSOR_TEST):Y(s.SCISSOR_TEST)}function ue(B){B===void 0&&(B=s.TEXTURE0+te-1),ce!==B&&(s.activeTexture(B),ce=B)}function fe(B,ye,xe){xe===void 0&&(ce===null?xe=s.TEXTURE0+te-1:xe=ce);let De=ge[xe];De===void 0&&(De={type:void 0,texture:void 0},ge[xe]=De),(De.type!==B||De.texture!==ye)&&(ce!==xe&&(s.activeTexture(xe),ce=xe),s.bindTexture(B,ye||q[B]),De.type=B,De.texture=ye)}function Re(){const B=ge[ce];B!==void 0&&B.type!==void 0&&(s.bindTexture(B.type,null),B.type=void 0,B.texture=void 0)}function Se(){try{s.compressedTexImage2D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function be(){try{s.compressedTexImage3D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ue(){try{s.texSubImage2D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ke(){try{s.texSubImage3D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function de(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Ze(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function D(){try{s.texStorage2D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function pe(){try{s.texStorage3D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function we(){try{s.texImage2D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function ve(){try{s.texImage3D.apply(s,arguments)}catch(B){console.error("THREE.WebGLState:",B)}}function Le(B){N.equals(B)===!1&&(s.scissor(B.x,B.y,B.z,B.w),N.copy(B))}function Ke(B){V.equals(B)===!1&&(s.viewport(B.x,B.y,B.z,B.w),V.copy(B))}function Qe(B,ye){let xe=u.get(ye);xe===void 0&&(xe=new WeakMap,u.set(ye,xe));let De=xe.get(B);De===void 0&&(De=s.getUniformBlockIndex(ye,B.name),xe.set(B,De))}function qe(B,ye){const De=u.get(ye).get(B);h.get(ye)!==De&&(s.uniformBlockBinding(ye,De,B.__bindingPointIndex),h.set(ye,De))}function Ae(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),n===!0&&(s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null)),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),f={},ce=null,ge={},d={},p=new WeakMap,v=[],g=null,m=!1,y=null,_=null,x=null,T=null,b=null,A=null,L=null,M=new Te(0,0,0),w=0,O=!1,H=null,K=null,I=null,F=null,k=null,N.set(0,0,s.canvas.width,s.canvas.height),V.set(0,0,s.canvas.width,s.canvas.height),a.reset(),c.reset(),l.reset()}return{buffers:{color:a,depth:c,stencil:l},enable:j,disable:Y,bindFramebuffer:oe,drawBuffers:R,useProgram:ie,setBlending:re,setMaterial:Me,setFlipSided:me,setCullFace:E,setLineWidth:S,setPolygonOffset:z,setScissorTest:he,activeTexture:ue,bindTexture:fe,unbindTexture:Re,compressedTexImage2D:Se,compressedTexImage3D:be,texImage2D:we,texImage3D:ve,updateUBOMapping:Qe,uniformBlockBinding:qe,texStorage2D:D,texStorage3D:pe,texSubImage2D:Ue,texSubImage3D:ke,compressedTexSubImage2D:de,compressedTexSubImage3D:Ze,scissor:Le,viewport:Ke,reset:Ae}}function lM(s,e,t,n,i,r,o){const a=i.isWebGL2,c=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),h=new WeakMap;let u;const f=new WeakMap;let d=!1;try{d=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function p(E,S){return d?new OffscreenCanvas(E,S):Xr("canvas")}function v(E,S,z,he){let ue=1;if((E.width>he||E.height>he)&&(ue=he/Math.max(E.width,E.height)),ue<1||S===!0)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap){const fe=S?Ca:Math.floor,Re=fe(ue*E.width),Se=fe(ue*E.height);u===void 0&&(u=p(Re,Se));const be=z?p(Re,Se):u;return be.width=Re,be.height=Se,be.getContext("2d").drawImage(E,0,0,Re,Se),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+E.width+"x"+E.height+") to ("+Re+"x"+Se+")."),be}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+E.width+"x"+E.height+")."),E;return E}function g(E){return Zl(E.width)&&Zl(E.height)}function m(E){return a?!1:E.wrapS!==At||E.wrapT!==At||E.minFilter!==dt&&E.minFilter!==at}function y(E,S){return E.generateMipmaps&&S&&E.minFilter!==dt&&E.minFilter!==at}function _(E){s.generateMipmap(E)}function x(E,S,z,he,ue=!1){if(a===!1)return S;if(E!==null){if(s[E]!==void 0)return s[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let fe=S;if(S===s.RED&&(z===s.FLOAT&&(fe=s.R32F),z===s.HALF_FLOAT&&(fe=s.R16F),z===s.UNSIGNED_BYTE&&(fe=s.R8)),S===s.RED_INTEGER&&(z===s.UNSIGNED_BYTE&&(fe=s.R8UI),z===s.UNSIGNED_SHORT&&(fe=s.R16UI),z===s.UNSIGNED_INT&&(fe=s.R32UI),z===s.BYTE&&(fe=s.R8I),z===s.SHORT&&(fe=s.R16I),z===s.INT&&(fe=s.R32I)),S===s.RG&&(z===s.FLOAT&&(fe=s.RG32F),z===s.HALF_FLOAT&&(fe=s.RG16F),z===s.UNSIGNED_BYTE&&(fe=s.RG8)),S===s.RGBA){const Re=ue?Hr:rt.getTransfer(he);z===s.FLOAT&&(fe=s.RGBA32F),z===s.HALF_FLOAT&&(fe=s.RGBA16F),z===s.UNSIGNED_BYTE&&(fe=Re===lt?s.SRGB8_ALPHA8:s.RGBA8),z===s.UNSIGNED_SHORT_4_4_4_4&&(fe=s.RGBA4),z===s.UNSIGNED_SHORT_5_5_5_1&&(fe=s.RGB5_A1)}return(fe===s.R16F||fe===s.R32F||fe===s.RG16F||fe===s.RG32F||fe===s.RGBA16F||fe===s.RGBA32F)&&e.get("EXT_color_buffer_float"),fe}function T(E,S,z){return y(E,z)===!0||E.isFramebufferTexture&&E.minFilter!==dt&&E.minFilter!==at?Math.log2(Math.max(S.width,S.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?S.mipmaps.length:1}function b(E){return E===dt||E===zr||E===qs?s.NEAREST:s.LINEAR}function A(E){const S=E.target;S.removeEventListener("dispose",A),M(S),S.isVideoTexture&&h.delete(S)}function L(E){const S=E.target;S.removeEventListener("dispose",L),O(S)}function M(E){const S=n.get(E);if(S.__webglInit===void 0)return;const z=E.source,he=f.get(z);if(he){const ue=he[S.__cacheKey];ue.usedTimes--,ue.usedTimes===0&&w(E),Object.keys(he).length===0&&f.delete(z)}n.remove(E)}function w(E){const S=n.get(E);s.deleteTexture(S.__webglTexture);const z=E.source,he=f.get(z);delete he[S.__cacheKey],o.memory.textures--}function O(E){const S=E.texture,z=n.get(E),he=n.get(S);if(he.__webglTexture!==void 0&&(s.deleteTexture(he.__webglTexture),o.memory.textures--),E.depthTexture&&E.depthTexture.dispose(),E.isWebGLCubeRenderTarget)for(let ue=0;ue<6;ue++){if(Array.isArray(z.__webglFramebuffer[ue]))for(let fe=0;fe<z.__webglFramebuffer[ue].length;fe++)s.deleteFramebuffer(z.__webglFramebuffer[ue][fe]);else s.deleteFramebuffer(z.__webglFramebuffer[ue]);z.__webglDepthbuffer&&s.deleteRenderbuffer(z.__webglDepthbuffer[ue])}else{if(Array.isArray(z.__webglFramebuffer))for(let ue=0;ue<z.__webglFramebuffer.length;ue++)s.deleteFramebuffer(z.__webglFramebuffer[ue]);else s.deleteFramebuffer(z.__webglFramebuffer);if(z.__webglDepthbuffer&&s.deleteRenderbuffer(z.__webglDepthbuffer),z.__webglMultisampledFramebuffer&&s.deleteFramebuffer(z.__webglMultisampledFramebuffer),z.__webglColorRenderbuffer)for(let ue=0;ue<z.__webglColorRenderbuffer.length;ue++)z.__webglColorRenderbuffer[ue]&&s.deleteRenderbuffer(z.__webglColorRenderbuffer[ue]);z.__webglDepthRenderbuffer&&s.deleteRenderbuffer(z.__webglDepthRenderbuffer)}if(E.isWebGLMultipleRenderTargets)for(let ue=0,fe=S.length;ue<fe;ue++){const Re=n.get(S[ue]);Re.__webglTexture&&(s.deleteTexture(Re.__webglTexture),o.memory.textures--),n.remove(S[ue])}n.remove(S),n.remove(E)}let H=0;function K(){H=0}function I(){const E=H;return E>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+i.maxTextures),H+=1,E}function F(E){const S=[];return S.push(E.wrapS),S.push(E.wrapT),S.push(E.wrapR||0),S.push(E.magFilter),S.push(E.minFilter),S.push(E.anisotropy),S.push(E.internalFormat),S.push(E.format),S.push(E.type),S.push(E.generateMipmaps),S.push(E.premultiplyAlpha),S.push(E.flipY),S.push(E.unpackAlignment),S.push(E.colorSpace),S.join()}function k(E,S){const z=n.get(E);if(E.isVideoTexture&&Me(E),E.isRenderTargetTexture===!1&&E.version>0&&z.__version!==E.version){const he=E.image;if(he===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(he.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{N(z,E,S);return}}t.bindTexture(s.TEXTURE_2D,z.__webglTexture,s.TEXTURE0+S)}function te(E,S){const z=n.get(E);if(E.version>0&&z.__version!==E.version){N(z,E,S);return}t.bindTexture(s.TEXTURE_2D_ARRAY,z.__webglTexture,s.TEXTURE0+S)}function J(E,S){const z=n.get(E);if(E.version>0&&z.__version!==E.version){N(z,E,S);return}t.bindTexture(s.TEXTURE_3D,z.__webglTexture,s.TEXTURE0+S)}function $(E,S){const z=n.get(E);if(E.version>0&&z.__version!==E.version){V(z,E,S);return}t.bindTexture(s.TEXTURE_CUBE_MAP,z.__webglTexture,s.TEXTURE0+S)}const le={[vn]:s.REPEAT,[At]:s.CLAMP_TO_EDGE,[Ri]:s.MIRRORED_REPEAT},ce={[dt]:s.NEAREST,[zr]:s.NEAREST_MIPMAP_NEAREST,[qs]:s.NEAREST_MIPMAP_LINEAR,[at]:s.LINEAR,[Va]:s.LINEAR_MIPMAP_NEAREST,[Mn]:s.LINEAR_MIPMAP_LINEAR},ge={[gp]:s.NEVER,[Sp]:s.ALWAYS,[vp]:s.LESS,[Ah]:s.LEQUAL,[_p]:s.EQUAL,[Mp]:s.GEQUAL,[yp]:s.GREATER,[xp]:s.NOTEQUAL};function Z(E,S,z){if(z?(s.texParameteri(E,s.TEXTURE_WRAP_S,le[S.wrapS]),s.texParameteri(E,s.TEXTURE_WRAP_T,le[S.wrapT]),(E===s.TEXTURE_3D||E===s.TEXTURE_2D_ARRAY)&&s.texParameteri(E,s.TEXTURE_WRAP_R,le[S.wrapR]),s.texParameteri(E,s.TEXTURE_MAG_FILTER,ce[S.magFilter]),s.texParameteri(E,s.TEXTURE_MIN_FILTER,ce[S.minFilter])):(s.texParameteri(E,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(E,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),(E===s.TEXTURE_3D||E===s.TEXTURE_2D_ARRAY)&&s.texParameteri(E,s.TEXTURE_WRAP_R,s.CLAMP_TO_EDGE),(S.wrapS!==At||S.wrapT!==At)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),s.texParameteri(E,s.TEXTURE_MAG_FILTER,b(S.magFilter)),s.texParameteri(E,s.TEXTURE_MIN_FILTER,b(S.minFilter)),S.minFilter!==dt&&S.minFilter!==at&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),S.compareFunction&&(s.texParameteri(E,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(E,s.TEXTURE_COMPARE_FUNC,ge[S.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const he=e.get("EXT_texture_filter_anisotropic");if(S.magFilter===dt||S.minFilter!==qs&&S.minFilter!==Mn||S.type===En&&e.has("OES_texture_float_linear")===!1||a===!1&&S.type===Ks&&e.has("OES_texture_half_float_linear")===!1)return;(S.anisotropy>1||n.get(S).__currentAnisotropy)&&(s.texParameterf(E,he.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy)}}function U(E,S){let z=!1;E.__webglInit===void 0&&(E.__webglInit=!0,S.addEventListener("dispose",A));const he=S.source;let ue=f.get(he);ue===void 0&&(ue={},f.set(he,ue));const fe=F(S);if(fe!==E.__cacheKey){ue[fe]===void 0&&(ue[fe]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,z=!0),ue[fe].usedTimes++;const Re=ue[E.__cacheKey];Re!==void 0&&(ue[E.__cacheKey].usedTimes--,Re.usedTimes===0&&w(S)),E.__cacheKey=fe,E.__webglTexture=ue[fe].texture}return z}function N(E,S,z){let he=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(he=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(he=s.TEXTURE_3D);const ue=U(E,S),fe=S.source;t.bindTexture(he,E.__webglTexture,s.TEXTURE0+z);const Re=n.get(fe);if(fe.version!==Re.__version||ue===!0){t.activeTexture(s.TEXTURE0+z);const Se=rt.getPrimaries(rt.workingColorSpace),be=S.colorSpace===ln?null:rt.getPrimaries(S.colorSpace),Ue=S.colorSpace===ln||Se===be?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const ke=m(S)&&g(S.image)===!1;let de=v(S.image,ke,!1,i.maxTextureSize);de=me(S,de);const Ze=g(de)||a,D=r.convert(S.format,S.colorSpace);let pe=r.convert(S.type),we=x(S.internalFormat,D,pe,S.colorSpace,S.isVideoTexture);Z(he,S,Ze);let ve;const Le=S.mipmaps,Ke=a&&S.isVideoTexture!==!0&&we!==xh,Qe=Re.__version===void 0||ue===!0,qe=T(S,de,Ze);if(S.isDepthTexture)we=s.DEPTH_COMPONENT,a?S.type===En?we=s.DEPTH_COMPONENT32F:S.type===ei?we=s.DEPTH_COMPONENT24:S.type===Si?we=s.DEPTH24_STENCIL8:we=s.DEPTH_COMPONENT16:S.type===En&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===bi&&we===s.DEPTH_COMPONENT&&S.type!==Wa&&S.type!==ei&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=ei,pe=r.convert(S.type)),S.format===cs&&we===s.DEPTH_COMPONENT&&(we=s.DEPTH_STENCIL,S.type!==Si&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=Si,pe=r.convert(S.type))),Qe&&(Ke?t.texStorage2D(s.TEXTURE_2D,1,we,de.width,de.height):t.texImage2D(s.TEXTURE_2D,0,we,de.width,de.height,0,D,pe,null));else if(S.isDataTexture)if(Le.length>0&&Ze){Ke&&Qe&&t.texStorage2D(s.TEXTURE_2D,qe,we,Le[0].width,Le[0].height);for(let Ae=0,B=Le.length;Ae<B;Ae++)ve=Le[Ae],Ke?t.texSubImage2D(s.TEXTURE_2D,Ae,0,0,ve.width,ve.height,D,pe,ve.data):t.texImage2D(s.TEXTURE_2D,Ae,we,ve.width,ve.height,0,D,pe,ve.data);S.generateMipmaps=!1}else Ke?(Qe&&t.texStorage2D(s.TEXTURE_2D,qe,we,de.width,de.height),t.texSubImage2D(s.TEXTURE_2D,0,0,0,de.width,de.height,D,pe,de.data)):t.texImage2D(s.TEXTURE_2D,0,we,de.width,de.height,0,D,pe,de.data);else if(S.isCompressedTexture)if(S.isCompressedArrayTexture){Ke&&Qe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,qe,we,Le[0].width,Le[0].height,de.depth);for(let Ae=0,B=Le.length;Ae<B;Ae++)ve=Le[Ae],S.format!==nn?D!==null?Ke?t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,Ae,0,0,0,ve.width,ve.height,de.depth,D,ve.data,0,0):t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,Ae,we,ve.width,ve.height,de.depth,0,ve.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ke?t.texSubImage3D(s.TEXTURE_2D_ARRAY,Ae,0,0,0,ve.width,ve.height,de.depth,D,pe,ve.data):t.texImage3D(s.TEXTURE_2D_ARRAY,Ae,we,ve.width,ve.height,de.depth,0,D,pe,ve.data)}else{Ke&&Qe&&t.texStorage2D(s.TEXTURE_2D,qe,we,Le[0].width,Le[0].height);for(let Ae=0,B=Le.length;Ae<B;Ae++)ve=Le[Ae],S.format!==nn?D!==null?Ke?t.compressedTexSubImage2D(s.TEXTURE_2D,Ae,0,0,ve.width,ve.height,D,ve.data):t.compressedTexImage2D(s.TEXTURE_2D,Ae,we,ve.width,ve.height,0,ve.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ke?t.texSubImage2D(s.TEXTURE_2D,Ae,0,0,ve.width,ve.height,D,pe,ve.data):t.texImage2D(s.TEXTURE_2D,Ae,we,ve.width,ve.height,0,D,pe,ve.data)}else if(S.isDataArrayTexture)Ke?(Qe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,qe,we,de.width,de.height,de.depth),t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,de.width,de.height,de.depth,D,pe,de.data)):t.texImage3D(s.TEXTURE_2D_ARRAY,0,we,de.width,de.height,de.depth,0,D,pe,de.data);else if(S.isData3DTexture)Ke?(Qe&&t.texStorage3D(s.TEXTURE_3D,qe,we,de.width,de.height,de.depth),t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,de.width,de.height,de.depth,D,pe,de.data)):t.texImage3D(s.TEXTURE_3D,0,we,de.width,de.height,de.depth,0,D,pe,de.data);else if(S.isFramebufferTexture){if(Qe)if(Ke)t.texStorage2D(s.TEXTURE_2D,qe,we,de.width,de.height);else{let Ae=de.width,B=de.height;for(let ye=0;ye<qe;ye++)t.texImage2D(s.TEXTURE_2D,ye,we,Ae,B,0,D,pe,null),Ae>>=1,B>>=1}}else if(Le.length>0&&Ze){Ke&&Qe&&t.texStorage2D(s.TEXTURE_2D,qe,we,Le[0].width,Le[0].height);for(let Ae=0,B=Le.length;Ae<B;Ae++)ve=Le[Ae],Ke?t.texSubImage2D(s.TEXTURE_2D,Ae,0,0,D,pe,ve):t.texImage2D(s.TEXTURE_2D,Ae,we,D,pe,ve);S.generateMipmaps=!1}else Ke?(Qe&&t.texStorage2D(s.TEXTURE_2D,qe,we,de.width,de.height),t.texSubImage2D(s.TEXTURE_2D,0,0,0,D,pe,de)):t.texImage2D(s.TEXTURE_2D,0,we,D,pe,de);y(S,Ze)&&_(he),Re.__version=fe.version,S.onUpdate&&S.onUpdate(S)}E.__version=S.version}function V(E,S,z){if(S.image.length!==6)return;const he=U(E,S),ue=S.source;t.bindTexture(s.TEXTURE_CUBE_MAP,E.__webglTexture,s.TEXTURE0+z);const fe=n.get(ue);if(ue.version!==fe.__version||he===!0){t.activeTexture(s.TEXTURE0+z);const Re=rt.getPrimaries(rt.workingColorSpace),Se=S.colorSpace===ln?null:rt.getPrimaries(S.colorSpace),be=S.colorSpace===ln||Re===Se?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,be);const Ue=S.isCompressedTexture||S.image[0].isCompressedTexture,ke=S.image[0]&&S.image[0].isDataTexture,de=[];for(let Ae=0;Ae<6;Ae++)!Ue&&!ke?de[Ae]=v(S.image[Ae],!1,!0,i.maxCubemapSize):de[Ae]=ke?S.image[Ae].image:S.image[Ae],de[Ae]=me(S,de[Ae]);const Ze=de[0],D=g(Ze)||a,pe=r.convert(S.format,S.colorSpace),we=r.convert(S.type),ve=x(S.internalFormat,pe,we,S.colorSpace),Le=a&&S.isVideoTexture!==!0,Ke=fe.__version===void 0||he===!0;let Qe=T(S,Ze,D);Z(s.TEXTURE_CUBE_MAP,S,D);let qe;if(Ue){Le&&Ke&&t.texStorage2D(s.TEXTURE_CUBE_MAP,Qe,ve,Ze.width,Ze.height);for(let Ae=0;Ae<6;Ae++){qe=de[Ae].mipmaps;for(let B=0;B<qe.length;B++){const ye=qe[B];S.format!==nn?pe!==null?Le?t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B,0,0,ye.width,ye.height,pe,ye.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B,ve,ye.width,ye.height,0,ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Le?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B,0,0,ye.width,ye.height,pe,we,ye.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B,ve,ye.width,ye.height,0,pe,we,ye.data)}}}else{qe=S.mipmaps,Le&&Ke&&(qe.length>0&&Qe++,t.texStorage2D(s.TEXTURE_CUBE_MAP,Qe,ve,de[0].width,de[0].height));for(let Ae=0;Ae<6;Ae++)if(ke){Le?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,de[Ae].width,de[Ae].height,pe,we,de[Ae].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,ve,de[Ae].width,de[Ae].height,0,pe,we,de[Ae].data);for(let B=0;B<qe.length;B++){const xe=qe[B].image[Ae].image;Le?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B+1,0,0,xe.width,xe.height,pe,we,xe.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B+1,ve,xe.width,xe.height,0,pe,we,xe.data)}}else{Le?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,0,0,pe,we,de[Ae]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,0,ve,pe,we,de[Ae]);for(let B=0;B<qe.length;B++){const ye=qe[B];Le?t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B+1,0,0,pe,we,ye.image[Ae]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ae,B+1,ve,pe,we,ye.image[Ae])}}}y(S,D)&&_(s.TEXTURE_CUBE_MAP),fe.__version=ue.version,S.onUpdate&&S.onUpdate(S)}E.__version=S.version}function W(E,S,z,he,ue,fe){const Re=r.convert(z.format,z.colorSpace),Se=r.convert(z.type),be=x(z.internalFormat,Re,Se,z.colorSpace);if(!n.get(S).__hasExternalTextures){const ke=Math.max(1,S.width>>fe),de=Math.max(1,S.height>>fe);ue===s.TEXTURE_3D||ue===s.TEXTURE_2D_ARRAY?t.texImage3D(ue,fe,be,ke,de,S.depth,0,Re,Se,null):t.texImage2D(ue,fe,be,ke,de,0,Re,Se,null)}t.bindFramebuffer(s.FRAMEBUFFER,E),re(S)?c.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,he,ue,n.get(z).__webglTexture,0,Q(S)):(ue===s.TEXTURE_2D||ue>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&ue<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,he,ue,n.get(z).__webglTexture,fe),t.bindFramebuffer(s.FRAMEBUFFER,null)}function q(E,S,z){if(s.bindRenderbuffer(s.RENDERBUFFER,E),S.depthBuffer&&!S.stencilBuffer){let he=a===!0?s.DEPTH_COMPONENT24:s.DEPTH_COMPONENT16;if(z||re(S)){const ue=S.depthTexture;ue&&ue.isDepthTexture&&(ue.type===En?he=s.DEPTH_COMPONENT32F:ue.type===ei&&(he=s.DEPTH_COMPONENT24));const fe=Q(S);re(S)?c.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,fe,he,S.width,S.height):s.renderbufferStorageMultisample(s.RENDERBUFFER,fe,he,S.width,S.height)}else s.renderbufferStorage(s.RENDERBUFFER,he,S.width,S.height);s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,E)}else if(S.depthBuffer&&S.stencilBuffer){const he=Q(S);z&&re(S)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,he,s.DEPTH24_STENCIL8,S.width,S.height):re(S)?c.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,he,s.DEPTH24_STENCIL8,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,E)}else{const he=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let ue=0;ue<he.length;ue++){const fe=he[ue],Re=r.convert(fe.format,fe.colorSpace),Se=r.convert(fe.type),be=x(fe.internalFormat,Re,Se,fe.colorSpace),Ue=Q(S);z&&re(S)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ue,be,S.width,S.height):re(S)?c.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ue,be,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,be,S.width,S.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function j(E,S){if(S&&S.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,E),!(S.depthTexture&&S.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(S.depthTexture).__webglTexture||S.depthTexture.image.width!==S.width||S.depthTexture.image.height!==S.height)&&(S.depthTexture.image.width=S.width,S.depthTexture.image.height=S.height,S.depthTexture.needsUpdate=!0),k(S.depthTexture,0);const he=n.get(S.depthTexture).__webglTexture,ue=Q(S);if(S.depthTexture.format===bi)re(S)?c.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,he,0,ue):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,he,0);else if(S.depthTexture.format===cs)re(S)?c.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,he,0,ue):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,he,0);else throw new Error("Unknown depthTexture format")}function Y(E){const S=n.get(E),z=E.isWebGLCubeRenderTarget===!0;if(E.depthTexture&&!S.__autoAllocateDepthBuffer){if(z)throw new Error("target.depthTexture not supported in Cube render targets");j(S.__webglFramebuffer,E)}else if(z){S.__webglDepthbuffer=[];for(let he=0;he<6;he++)t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[he]),S.__webglDepthbuffer[he]=s.createRenderbuffer(),q(S.__webglDepthbuffer[he],E,!1)}else t.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer=s.createRenderbuffer(),q(S.__webglDepthbuffer,E,!1);t.bindFramebuffer(s.FRAMEBUFFER,null)}function oe(E,S,z){const he=n.get(E);S!==void 0&&W(he.__webglFramebuffer,E,E.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),z!==void 0&&Y(E)}function R(E){const S=E.texture,z=n.get(E),he=n.get(S);E.addEventListener("dispose",L),E.isWebGLMultipleRenderTargets!==!0&&(he.__webglTexture===void 0&&(he.__webglTexture=s.createTexture()),he.__version=S.version,o.memory.textures++);const ue=E.isWebGLCubeRenderTarget===!0,fe=E.isWebGLMultipleRenderTargets===!0,Re=g(E)||a;if(ue){z.__webglFramebuffer=[];for(let Se=0;Se<6;Se++)if(a&&S.mipmaps&&S.mipmaps.length>0){z.__webglFramebuffer[Se]=[];for(let be=0;be<S.mipmaps.length;be++)z.__webglFramebuffer[Se][be]=s.createFramebuffer()}else z.__webglFramebuffer[Se]=s.createFramebuffer()}else{if(a&&S.mipmaps&&S.mipmaps.length>0){z.__webglFramebuffer=[];for(let Se=0;Se<S.mipmaps.length;Se++)z.__webglFramebuffer[Se]=s.createFramebuffer()}else z.__webglFramebuffer=s.createFramebuffer();if(fe)if(i.drawBuffers){const Se=E.texture;for(let be=0,Ue=Se.length;be<Ue;be++){const ke=n.get(Se[be]);ke.__webglTexture===void 0&&(ke.__webglTexture=s.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(a&&E.samples>0&&re(E)===!1){const Se=fe?S:[S];z.__webglMultisampledFramebuffer=s.createFramebuffer(),z.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,z.__webglMultisampledFramebuffer);for(let be=0;be<Se.length;be++){const Ue=Se[be];z.__webglColorRenderbuffer[be]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,z.__webglColorRenderbuffer[be]);const ke=r.convert(Ue.format,Ue.colorSpace),de=r.convert(Ue.type),Ze=x(Ue.internalFormat,ke,de,Ue.colorSpace,E.isXRRenderTarget===!0),D=Q(E);s.renderbufferStorageMultisample(s.RENDERBUFFER,D,Ze,E.width,E.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+be,s.RENDERBUFFER,z.__webglColorRenderbuffer[be])}s.bindRenderbuffer(s.RENDERBUFFER,null),E.depthBuffer&&(z.__webglDepthRenderbuffer=s.createRenderbuffer(),q(z.__webglDepthRenderbuffer,E,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(ue){t.bindTexture(s.TEXTURE_CUBE_MAP,he.__webglTexture),Z(s.TEXTURE_CUBE_MAP,S,Re);for(let Se=0;Se<6;Se++)if(a&&S.mipmaps&&S.mipmaps.length>0)for(let be=0;be<S.mipmaps.length;be++)W(z.__webglFramebuffer[Se][be],E,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Se,be);else W(z.__webglFramebuffer[Se],E,S,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Se,0);y(S,Re)&&_(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(fe){const Se=E.texture;for(let be=0,Ue=Se.length;be<Ue;be++){const ke=Se[be],de=n.get(ke);t.bindTexture(s.TEXTURE_2D,de.__webglTexture),Z(s.TEXTURE_2D,ke,Re),W(z.__webglFramebuffer,E,ke,s.COLOR_ATTACHMENT0+be,s.TEXTURE_2D,0),y(ke,Re)&&_(s.TEXTURE_2D)}t.unbindTexture()}else{let Se=s.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(a?Se=E.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(Se,he.__webglTexture),Z(Se,S,Re),a&&S.mipmaps&&S.mipmaps.length>0)for(let be=0;be<S.mipmaps.length;be++)W(z.__webglFramebuffer[be],E,S,s.COLOR_ATTACHMENT0,Se,be);else W(z.__webglFramebuffer,E,S,s.COLOR_ATTACHMENT0,Se,0);y(S,Re)&&_(Se),t.unbindTexture()}E.depthBuffer&&Y(E)}function ie(E){const S=g(E)||a,z=E.isWebGLMultipleRenderTargets===!0?E.texture:[E.texture];for(let he=0,ue=z.length;he<ue;he++){const fe=z[he];if(y(fe,S)){const Re=E.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:s.TEXTURE_2D,Se=n.get(fe).__webglTexture;t.bindTexture(Re,Se),_(Re),t.unbindTexture()}}}function G(E){if(a&&E.samples>0&&re(E)===!1){const S=E.isWebGLMultipleRenderTargets?E.texture:[E.texture],z=E.width,he=E.height;let ue=s.COLOR_BUFFER_BIT;const fe=[],Re=E.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Se=n.get(E),be=E.isWebGLMultipleRenderTargets===!0;if(be)for(let Ue=0;Ue<S.length;Ue++)t.bindFramebuffer(s.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ue,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,Se.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ue,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,Se.__webglMultisampledFramebuffer),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Se.__webglFramebuffer);for(let Ue=0;Ue<S.length;Ue++){fe.push(s.COLOR_ATTACHMENT0+Ue),E.depthBuffer&&fe.push(Re);const ke=Se.__ignoreDepthValues!==void 0?Se.__ignoreDepthValues:!1;if(ke===!1&&(E.depthBuffer&&(ue|=s.DEPTH_BUFFER_BIT),E.stencilBuffer&&(ue|=s.STENCIL_BUFFER_BIT)),be&&s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,Se.__webglColorRenderbuffer[Ue]),ke===!0&&(s.invalidateFramebuffer(s.READ_FRAMEBUFFER,[Re]),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[Re])),be){const de=n.get(S[Ue]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,de,0)}s.blitFramebuffer(0,0,z,he,0,0,z,he,ue,s.NEAREST),l&&s.invalidateFramebuffer(s.READ_FRAMEBUFFER,fe)}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),be)for(let Ue=0;Ue<S.length;Ue++){t.bindFramebuffer(s.FRAMEBUFFER,Se.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ue,s.RENDERBUFFER,Se.__webglColorRenderbuffer[Ue]);const ke=n.get(S[Ue]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,Se.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Ue,s.TEXTURE_2D,ke,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,Se.__webglMultisampledFramebuffer)}}function Q(E){return Math.min(i.maxSamples,E.samples)}function re(E){const S=n.get(E);return a&&E.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Me(E){const S=o.render.frame;h.get(E)!==S&&(h.set(E,S),E.update())}function me(E,S){const z=E.colorSpace,he=E.format,ue=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||E.format===Ra||z!==Rt&&z!==ln&&(rt.getTransfer(z)===lt?a===!1?e.has("EXT_sRGB")===!0&&he===nn?(E.format=Ra,E.minFilter=at,E.generateMipmaps=!1):S=Th.sRGBToLinear(S):(he!==nn||ue!==ri)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",z)),S}this.allocateTextureUnit=I,this.resetTextureUnits=K,this.setTexture2D=k,this.setTexture2DArray=te,this.setTexture3D=J,this.setTextureCube=$,this.rebindTextures=oe,this.setupRenderTarget=R,this.updateRenderTargetMipmap=ie,this.updateMultisampleRenderTarget=G,this.setupDepthRenderbuffer=Y,this.setupFrameBufferTexture=W,this.useMultisampledRTT=re}function Op(s,e,t){const n=t.isWebGL2;function i(r,o=ln){let a;const c=rt.getTransfer(o);if(r===ri)return s.UNSIGNED_BYTE;if(r===mh)return s.UNSIGNED_SHORT_4_4_4_4;if(r===gh)return s.UNSIGNED_SHORT_5_5_5_1;if(r===tp)return s.BYTE;if(r===np)return s.SHORT;if(r===Wa)return s.UNSIGNED_SHORT;if(r===ph)return s.INT;if(r===ei)return s.UNSIGNED_INT;if(r===En)return s.FLOAT;if(r===Ks)return n?s.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(r===ip)return s.ALPHA;if(r===nn)return s.RGBA;if(r===sp)return s.LUMINANCE;if(r===rp)return s.LUMINANCE_ALPHA;if(r===bi)return s.DEPTH_COMPONENT;if(r===cs)return s.DEPTH_STENCIL;if(r===Ra)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(r===op)return s.RED;if(r===vh)return s.RED_INTEGER;if(r===ap)return s.RG;if(r===_h)return s.RG_INTEGER;if(r===yh)return s.RGBA_INTEGER;if(r===ma||r===ga||r===va||r===_a)if(c===lt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===ma)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===ga)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===va)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===_a)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===ma)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===ga)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===va)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===_a)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Ml||r===Sl||r===bl||r===Al)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===Ml)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Sl)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===bl)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Al)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===xh)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===wl||r===Tl)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===wl)return c===lt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===Tl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===El||r===Rl||r===Cl||r===Ll||r===Pl||r===Il||r===Ul||r===Nl||r===Dl||r===Ol||r===Bl||r===Fl||r===zl||r===kl)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===El)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===Rl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===Cl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===Ll)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===Pl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===Il)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Ul)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Nl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Dl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Ol)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===Bl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===Fl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===zl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===kl)return c===lt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===ya||r===Hl||r===Gl)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===ya)return c===lt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Hl)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Gl)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===cp||r===Vl||r===Wl||r===Xl)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===ya)return a.COMPRESSED_RED_RGTC1_EXT;if(r===Vl)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===Wl)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===Xl)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Si?n?s.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):s[r]!==void 0?s[r]:null}return{convert:i}}class Bp extends Nt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class _n extends tt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const hM={type:"move"};class Xc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new _n,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 _n,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new _n,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(const v of e.hand.values()){const g=t.getJointPose(v,n),m=this._getHandJoint(l,v);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],f=h.position.distanceTo(u.position),d=.02,p=.005;l.inputState.pinching&&f>d+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&f<=d-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(hM)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new _n;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class uM extends Wn{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor",c=1,l=null,h=null,u=null,f=null,d=null,p=null;const v=t.getContextAttributes();let g=null,m=null;const y=[],_=[],x=new ae;let T=null;const b=new Nt;b.layers.enable(1),b.viewport=new nt;const A=new Nt;A.layers.enable(2),A.viewport=new nt;const L=[b,A],M=new Bp;M.layers.enable(1),M.layers.enable(2);let w=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let U=y[Z];return U===void 0&&(U=new Xc,y[Z]=U),U.getTargetRaySpace()},this.getControllerGrip=function(Z){let U=y[Z];return U===void 0&&(U=new Xc,y[Z]=U),U.getGripSpace()},this.getHand=function(Z){let U=y[Z];return U===void 0&&(U=new Xc,y[Z]=U),U.getHandSpace()};function H(Z){const U=_.indexOf(Z.inputSource);if(U===-1)return;const N=y[U];N!==void 0&&(N.update(Z.inputSource,Z.frame,l||o),N.dispatchEvent({type:Z.type,data:Z.inputSource}))}function K(){i.removeEventListener("select",H),i.removeEventListener("selectstart",H),i.removeEventListener("selectend",H),i.removeEventListener("squeeze",H),i.removeEventListener("squeezestart",H),i.removeEventListener("squeezeend",H),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",I);for(let Z=0;Z<y.length;Z++){const U=_[Z];U!==null&&(_[Z]=null,y[Z].disconnect(U))}w=null,O=null,e.setRenderTarget(g),d=null,f=null,u=null,i=null,m=null,ge.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(x.width,x.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){r=Z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){a=Z,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(Z){l=Z},this.getBaseLayer=function(){return f!==null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(Z){if(i=Z,i!==null){if(g=e.getRenderTarget(),i.addEventListener("select",H),i.addEventListener("selectstart",H),i.addEventListener("selectend",H),i.addEventListener("squeeze",H),i.addEventListener("squeezestart",H),i.addEventListener("squeezeend",H),i.addEventListener("end",K),i.addEventListener("inputsourceschange",I),v.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(x),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const U={antialias:i.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,U),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),m=new Cn(d.framebufferWidth,d.framebufferHeight,{format:nn,type:ri,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil})}else{let U=null,N=null,V=null;v.depth&&(V=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,U=v.stencil?cs:bi,N=v.stencil?Si:ei);const W={colorFormat:t.RGBA8,depthFormat:V,scaleFactor:r};u=new XRWebGLBinding(i,t),f=u.createProjectionLayer(W),i.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),m=new Cn(f.textureWidth,f.textureHeight,{format:nn,type:ri,depthTexture:new Ph(f.textureWidth,f.textureHeight,N,void 0,void 0,void 0,void 0,void 0,void 0,U),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:v.antialias?4:0});const q=e.properties.get(m);q.__ignoreDepthValues=f.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),ge.setContext(i),ge.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function I(Z){for(let U=0;U<Z.removed.length;U++){const N=Z.removed[U],V=_.indexOf(N);V>=0&&(_[V]=null,y[V].disconnect(N))}for(let U=0;U<Z.added.length;U++){const N=Z.added[U];let V=_.indexOf(N);if(V===-1){for(let q=0;q<y.length;q++)if(q>=_.length){_.push(N),V=q;break}else if(_[q]===null){_[q]=N,V=q;break}if(V===-1)break}const W=y[V];W&&W.connect(N)}}const F=new C,k=new C;function te(Z,U,N){F.setFromMatrixPosition(U.matrixWorld),k.setFromMatrixPosition(N.matrixWorld);const V=F.distanceTo(k),W=U.projectionMatrix.elements,q=N.projectionMatrix.elements,j=W[14]/(W[10]-1),Y=W[14]/(W[10]+1),oe=(W[9]+1)/W[5],R=(W[9]-1)/W[5],ie=(W[8]-1)/W[0],G=(q[8]+1)/q[0],Q=j*ie,re=j*G,Me=V/(-ie+G),me=Me*-ie;U.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(me),Z.translateZ(Me),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const E=j+Me,S=Y+Me,z=Q-me,he=re+(V-me),ue=oe*Y/S*E,fe=R*Y/S*E;Z.projectionMatrix.makePerspective(z,he,ue,fe,E,S),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function J(Z,U){U===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(U.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(i===null)return;M.near=A.near=b.near=Z.near,M.far=A.far=b.far=Z.far,(w!==M.near||O!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),w=M.near,O=M.far);const U=Z.parent,N=M.cameras;J(M,U);for(let V=0;V<N.length;V++)J(N[V],U);N.length===2?te(M,b,A):M.projectionMatrix.copy(b.projectionMatrix),$(Z,M,U)};function $(Z,U,N){N===null?Z.matrix.copy(U.matrixWorld):(Z.matrix.copy(N.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(U.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(U.projectionMatrix),Z.projectionMatrixInverse.copy(U.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=$s*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(f===null&&d===null))return c},this.setFoveation=function(Z){c=Z,f!==null&&(f.fixedFoveation=Z),d!==null&&d.fixedFoveation!==void 0&&(d.fixedFoveation=Z)};let le=null;function ce(Z,U){if(h=U.getViewerPose(l||o),p=U,h!==null){const N=h.views;d!==null&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let V=!1;N.length!==M.cameras.length&&(M.cameras.length=0,V=!0);for(let W=0;W<N.length;W++){const q=N[W];let j=null;if(d!==null)j=d.getViewport(q);else{const oe=u.getViewSubImage(f,q);j=oe.viewport,W===0&&(e.setRenderTargetTextures(m,oe.colorTexture,f.ignoreDepthValues?void 0:oe.depthStencilTexture),e.setRenderTarget(m))}let Y=L[W];Y===void 0&&(Y=new Nt,Y.layers.enable(W),Y.viewport=new nt,L[W]=Y),Y.matrix.fromArray(q.transform.matrix),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.projectionMatrix.fromArray(q.projectionMatrix),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert(),Y.viewport.set(j.x,j.y,j.width,j.height),W===0&&(M.matrix.copy(Y.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),V===!0&&M.cameras.push(Y)}}for(let N=0;N<y.length;N++){const V=_[N],W=y[N];V!==null&&W!==void 0&&W.update(V,U,l||o)}le&&le(Z,U),U.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:U}),p=null}const ge=new Lp;ge.setAnimationLoop(ce),this.setAnimationLoop=function(Z){le=Z},this.dispose=function(){}}}function fM(s,e){function t(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,Ep(s)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,y,_,x){m.isMeshBasicMaterial||m.isMeshLambertMaterial?r(g,m):m.isMeshToonMaterial?(r(g,m),u(g,m)):m.isMeshPhongMaterial?(r(g,m),h(g,m)):m.isMeshStandardMaterial?(r(g,m),f(g,m),m.isMeshPhysicalMaterial&&d(g,m,x)):m.isMeshMatcapMaterial?(r(g,m),p(g,m)):m.isMeshDepthMaterial?r(g,m):m.isMeshDistanceMaterial?(r(g,m),v(g,m)):m.isMeshNormalMaterial?r(g,m):m.isLineBasicMaterial?(o(g,m),m.isLineDashedMaterial&&a(g,m)):m.isPointsMaterial?c(g,m,y,_):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,t(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===Qt&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,t(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===Qt&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,t(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,t(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,t(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const y=e.get(m).envMap;if(y&&(g.envMap.value=y,g.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap){g.lightMap.value=m.lightMap;const _=s._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=m.lightMapIntensity*_,t(m.lightMap,g.lightMapTransform)}m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,t(m.aoMap,g.aoMapTransform))}function o(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform))}function a(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function c(g,m,y,_){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*y,g.scale.value=_*.5,m.map&&(g.map.value=m.map,t(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,t(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,t(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function f(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,t(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,t(m.roughnessMap,g.roughnessMapTransform)),e.get(m).envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function d(g,m,y){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,t(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,t(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,t(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,t(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,t(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Qt&&g.clearcoatNormalScale.value.negate())),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,t(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,t(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,t(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,t(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,t(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,t(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,t(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function v(g,m){const y=e.get(m).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function dM(s,e,t,n){let i={},r={},o=[];const a=t.isWebGL2?s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(y,_){const x=_.program;n.uniformBlockBinding(y,x)}function l(y,_){let x=i[y.id];x===void 0&&(p(y),x=h(y),i[y.id]=x,y.addEventListener("dispose",g));const T=_.program;n.updateUBOMapping(y,T);const b=e.render.frame;r[y.id]!==b&&(f(y),r[y.id]=b)}function h(y){const _=u();y.__bindingPointIndex=_;const x=s.createBuffer(),T=y.__size,b=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,x),s.bufferData(s.UNIFORM_BUFFER,T,b),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,_,x),x}function u(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(y){const _=i[y.id],x=y.uniforms,T=y.__cache;s.bindBuffer(s.UNIFORM_BUFFER,_);for(let b=0,A=x.length;b<A;b++){const L=Array.isArray(x[b])?x[b]:[x[b]];for(let M=0,w=L.length;M<w;M++){const O=L[M];if(d(O,b,M,T)===!0){const H=O.__offset,K=Array.isArray(O.value)?O.value:[O.value];let I=0;for(let F=0;F<K.length;F++){const k=K[F],te=v(k);typeof k=="number"||typeof k=="boolean"?(O.__data[0]=k,s.bufferSubData(s.UNIFORM_BUFFER,H+I,O.__data)):k.isMatrix3?(O.__data[0]=k.elements[0],O.__data[1]=k.elements[1],O.__data[2]=k.elements[2],O.__data[3]=0,O.__data[4]=k.elements[3],O.__data[5]=k.elements[4],O.__data[6]=k.elements[5],O.__data[7]=0,O.__data[8]=k.elements[6],O.__data[9]=k.elements[7],O.__data[10]=k.elements[8],O.__data[11]=0):(k.toArray(O.__data,I),I+=te.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,H,O.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function d(y,_,x,T){const b=y.value,A=_+"_"+x;if(T[A]===void 0)return typeof b=="number"||typeof b=="boolean"?T[A]=b:T[A]=b.clone(),!0;{const L=T[A];if(typeof b=="number"||typeof b=="boolean"){if(L!==b)return T[A]=b,!0}else if(L.equals(b)===!1)return L.copy(b),!0}return!1}function p(y){const _=y.uniforms;let x=0;const T=16;for(let A=0,L=_.length;A<L;A++){const M=Array.isArray(_[A])?_[A]:[_[A]];for(let w=0,O=M.length;w<O;w++){const H=M[w],K=Array.isArray(H.value)?H.value:[H.value];for(let I=0,F=K.length;I<F;I++){const k=K[I],te=v(k),J=x%T;J!==0&&T-J<te.boundary&&(x+=T-J),H.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=x,x+=te.storage}}}const b=x%T;return b>0&&(x+=T-b),y.__size=x,y.__cache={},this}function v(y){const _={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(_.boundary=4,_.storage=4):y.isVector2?(_.boundary=8,_.storage=8):y.isVector3||y.isColor?(_.boundary=16,_.storage=12):y.isVector4?(_.boundary=16,_.storage=16):y.isMatrix3?(_.boundary=48,_.storage=48):y.isMatrix4?(_.boundary=64,_.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),_}function g(y){const _=y.target;_.removeEventListener("dispose",g);const x=o.indexOf(_.__bindingPointIndex);o.splice(x,1),s.deleteBuffer(i[_.id]),delete i[_.id],delete r[_.id]}function m(){for(const y in i)s.deleteBuffer(i[y]);o=[],i={},r={}}return{bind:c,update:l,dispose:m}}class Fp{constructor(e={}){const{canvas:t=Ap(),context:n=null,depth:i=!0,stencil:r=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let f;n!==null?f=n.getContextAttributes().alpha:f=o;const d=new Uint32Array(4),p=new Int32Array(4);let v=null,g=null;const m=[],y=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=ht,this._useLegacyLights=!1,this.toneMapping=si,this.toneMappingExposure=1;const _=this;let x=!1,T=0,b=0,A=null,L=-1,M=null;const w=new nt,O=new nt;let H=null;const K=new Te(0);let I=0,F=t.width,k=t.height,te=1,J=null,$=null;const le=new nt(0,0,F,k),ce=new nt(0,0,F,k);let ge=!1;const Z=new so;let U=!1,N=!1,V=null;const W=new Ne,q=new ae,j=new C,Y={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function oe(){return A===null?te:1}let R=n;function ie(P,X){for(let ne=0;ne<P.length;ne++){const se=P[ne],ee=t.getContext(se,X);if(ee!==null)return ee}return null}try{const P={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r160"),t.addEventListener("webglcontextlost",Ae,!1),t.addEventListener("webglcontextrestored",B,!1),t.addEventListener("webglcontextcreationerror",ye,!1),R===null){const X=["webgl2","webgl","experimental-webgl"];if(_.isWebGL1Renderer===!0&&X.shift(),R=ie(X,P),R===null)throw ie(X)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&R instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),R.getShaderPrecisionFormat===void 0&&(R.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(P){throw console.error("THREE.WebGLRenderer: "+P.message),P}let G,Q,re,Me,me,E,S,z,he,ue,fe,Re,Se,be,Ue,ke,de,Ze,D,pe,we,ve,Le,Ke;function Qe(){G=new Ey(R),Q=new My(R,G,e),G.init(Q),ve=new Op(R,G,Q),re=new cM(R,G,Q),Me=new Ly(R),me=new jx,E=new lM(R,G,re,me,Q,ve,Me),S=new by(_),z=new Ty(_),he=new Fv(R,Q),Le=new yy(R,G,he,Q),ue=new Ry(R,he,Me,Le),fe=new Ny(R,ue,he,Me),D=new Uy(R,Q,E),ke=new Sy(me),Re=new Kx(_,S,z,G,Q,Le,ke),Se=new fM(_,me),be=new $x,Ue=new sM(G,Q),Ze=new _y(_,S,z,re,fe,f,c),de=new aM(_,fe,Q),Ke=new dM(R,Me,Q,re),pe=new xy(R,G,Me,Q),we=new Cy(R,G,Me,Q),Me.programs=Re.programs,_.capabilities=Q,_.extensions=G,_.properties=me,_.renderLists=be,_.shadowMap=de,_.state=re,_.info=Me}Qe();const qe=new uM(_,R);this.xr=qe,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){const P=G.get("WEBGL_lose_context");P&&P.loseContext()},this.forceContextRestore=function(){const P=G.get("WEBGL_lose_context");P&&P.restoreContext()},this.getPixelRatio=function(){return te},this.setPixelRatio=function(P){P!==void 0&&(te=P,this.setSize(F,k,!1))},this.getSize=function(P){return P.set(F,k)},this.setSize=function(P,X,ne=!0){if(qe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}F=P,k=X,t.width=Math.floor(P*te),t.height=Math.floor(X*te),ne===!0&&(t.style.width=P+"px",t.style.height=X+"px"),this.setViewport(0,0,P,X)},this.getDrawingBufferSize=function(P){return P.set(F*te,k*te).floor()},this.setDrawingBufferSize=function(P,X,ne){F=P,k=X,te=ne,t.width=Math.floor(P*ne),t.height=Math.floor(X*ne),this.setViewport(0,0,P,X)},this.getCurrentViewport=function(P){return P.copy(w)},this.getViewport=function(P){return P.copy(le)},this.setViewport=function(P,X,ne,se){P.isVector4?le.set(P.x,P.y,P.z,P.w):le.set(P,X,ne,se),re.viewport(w.copy(le).multiplyScalar(te).floor())},this.getScissor=function(P){return P.copy(ce)},this.setScissor=function(P,X,ne,se){P.isVector4?ce.set(P.x,P.y,P.z,P.w):ce.set(P,X,ne,se),re.scissor(O.copy(ce).multiplyScalar(te).floor())},this.getScissorTest=function(){return ge},this.setScissorTest=function(P){re.setScissorTest(ge=P)},this.setOpaqueSort=function(P){J=P},this.setTransparentSort=function(P){$=P},this.getClearColor=function(P){return P.copy(Ze.getClearColor())},this.setClearColor=function(){Ze.setClearColor.apply(Ze,arguments)},this.getClearAlpha=function(){return Ze.getClearAlpha()},this.setClearAlpha=function(){Ze.setClearAlpha.apply(Ze,arguments)},this.clear=function(P=!0,X=!0,ne=!0){let se=0;if(P){let ee=!1;if(A!==null){const Ce=A.texture.format;ee=Ce===yh||Ce===_h||Ce===vh}if(ee){const Ce=A.texture.type,Ie=Ce===ri||Ce===ei||Ce===Wa||Ce===Si||Ce===mh||Ce===gh,Oe=Ze.getClearColor(),ze=Ze.getClearAlpha(),Ye=Oe.r,He=Oe.g,Ge=Oe.b;Ie?(d[0]=Ye,d[1]=He,d[2]=Ge,d[3]=ze,R.clearBufferuiv(R.COLOR,0,d)):(p[0]=Ye,p[1]=He,p[2]=Ge,p[3]=ze,R.clearBufferiv(R.COLOR,0,p))}else se|=R.COLOR_BUFFER_BIT}X&&(se|=R.DEPTH_BUFFER_BIT),ne&&(se|=R.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),R.clear(se)},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.dispose=function(){t.removeEventListener("webglcontextlost",Ae,!1),t.removeEventListener("webglcontextrestored",B,!1),t.removeEventListener("webglcontextcreationerror",ye,!1),be.dispose(),Ue.dispose(),me.dispose(),S.dispose(),z.dispose(),fe.dispose(),Le.dispose(),Ke.dispose(),Re.dispose(),qe.dispose(),qe.removeEventListener("sessionstart",qt),qe.removeEventListener("sessionend",ct),V&&(V.dispose(),V=null),Yt.stop()};function Ae(P){P.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function B(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;const P=Me.autoReset,X=de.enabled,ne=de.autoUpdate,se=de.needsUpdate,ee=de.type;Qe(),Me.autoReset=P,de.enabled=X,de.autoUpdate=ne,de.needsUpdate=se,de.type=ee}function ye(P){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",P.statusMessage)}function xe(P){const X=P.target;X.removeEventListener("dispose",xe),De(X)}function De(P){Pe(P),me.remove(P)}function Pe(P){const X=me.get(P).programs;X!==void 0&&(X.forEach(function(ne){Re.releaseProgram(ne)}),P.isShaderMaterial&&Re.releaseShaderCache(P))}this.renderBufferDirect=function(P,X,ne,se,ee,Ce){X===null&&(X=Y);const Ie=ee.isMesh&&ee.matrixWorld.determinant()<0,Oe=fg(P,X,ne,se,ee);re.setMaterial(se,Ie);let ze=ne.index,Ye=1;if(se.wireframe===!0){if(ze=ue.getWireframeAttribute(ne),ze===void 0)return;Ye=2}const He=ne.drawRange,Ge=ne.attributes.position;let xt=He.start*Ye,on=(He.start+He.count)*Ye;Ce!==null&&(xt=Math.max(xt,Ce.start*Ye),on=Math.min(on,(Ce.start+Ce.count)*Ye)),ze!==null?(xt=Math.max(xt,0),on=Math.min(on,ze.count)):Ge!=null&&(xt=Math.max(xt,0),on=Math.min(on,Ge.count));const It=on-xt;if(It<0||It===1/0)return;Le.setup(ee,se,Oe,ne,ze);let Xn,pt=pe;if(ze!==null&&(Xn=he.get(ze),pt=we,pt.setIndex(Xn)),ee.isMesh)se.wireframe===!0?(re.setLineWidth(se.wireframeLinewidth*oe()),pt.setMode(R.LINES)):pt.setMode(R.TRIANGLES);else if(ee.isLine){let je=se.linewidth;je===void 0&&(je=1),re.setLineWidth(je*oe()),ee.isLineSegments?pt.setMode(R.LINES):ee.isLineLoop?pt.setMode(R.LINE_LOOP):pt.setMode(R.LINE_STRIP)}else ee.isPoints?pt.setMode(R.POINTS):ee.isSprite&&pt.setMode(R.TRIANGLES);if(ee.isBatchedMesh)pt.renderMultiDraw(ee._multiDrawStarts,ee._multiDrawCounts,ee._multiDrawCount);else if(ee.isInstancedMesh)pt.renderInstances(xt,It,ee.count);else if(ne.isInstancedBufferGeometry){const je=ne._maxInstanceCount!==void 0?ne._maxInstanceCount:1/0,yc=Math.min(ne.instanceCount,je);pt.renderInstances(xt,It,yc)}else pt.render(xt,It)};function it(P,X,ne){P.transparent===!0&&P.side===Tn&&P.forceSinglePass===!1?(P.side=Qt,P.needsUpdate=!0,vo(P,X,ne),P.side=Gn,P.needsUpdate=!0,vo(P,X,ne),P.side=Tn):vo(P,X,ne)}this.compile=function(P,X,ne=null){ne===null&&(ne=P),g=Ue.get(ne),g.init(),y.push(g),ne.traverseVisible(function(ee){ee.isLight&&ee.layers.test(X.layers)&&(g.pushLight(ee),ee.castShadow&&g.pushShadow(ee))}),P!==ne&&P.traverseVisible(function(ee){ee.isLight&&ee.layers.test(X.layers)&&(g.pushLight(ee),ee.castShadow&&g.pushShadow(ee))}),g.setupLights(_._useLegacyLights);const se=new Set;return P.traverse(function(ee){const Ce=ee.material;if(Ce)if(Array.isArray(Ce))for(let Ie=0;Ie<Ce.length;Ie++){const Oe=Ce[Ie];it(Oe,ne,ee),se.add(Oe)}else it(Ce,ne,ee),se.add(Ce)}),y.pop(),g=null,se},this.compileAsync=function(P,X,ne=null){const se=this.compile(P,X,ne);return new Promise(ee=>{function Ce(){if(se.forEach(function(Ie){me.get(Ie).currentProgram.isReady()&&se.delete(Ie)}),se.size===0){ee(P);return}setTimeout(Ce,10)}G.get("KHR_parallel_shader_compile")!==null?Ce():setTimeout(Ce,10)})};let st=null;function Pt(P){st&&st(P)}function qt(){Yt.stop()}function ct(){Yt.start()}const Yt=new Lp;Yt.setAnimationLoop(Pt),typeof self<"u"&&Yt.setContext(self),this.setAnimationLoop=function(P){st=P,qe.setAnimationLoop(P),P===null?Yt.stop():Yt.start()},qe.addEventListener("sessionstart",qt),qe.addEventListener("sessionend",ct),this.render=function(P,X){if(X!==void 0&&X.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(x===!0)return;P.matrixWorldAutoUpdate===!0&&P.updateMatrixWorld(),X.parent===null&&X.matrixWorldAutoUpdate===!0&&X.updateMatrixWorld(),qe.enabled===!0&&qe.isPresenting===!0&&(qe.cameraAutoUpdate===!0&&qe.updateCamera(X),X=qe.getCamera()),P.isScene===!0&&P.onBeforeRender(_,P,X,A),g=Ue.get(P,y.length),g.init(),y.push(g),W.multiplyMatrices(X.projectionMatrix,X.matrixWorldInverse),Z.setFromProjectionMatrix(W),N=this.localClippingEnabled,U=ke.init(this.clippingPlanes,N),v=be.get(P,m.length),v.init(),m.push(v),Dn(P,X,0,_.sortObjects),v.finish(),_.sortObjects===!0&&v.sort(J,$),this.info.render.frame++,U===!0&&ke.beginShadows();const ne=g.state.shadowsArray;if(de.render(ne,P,X),U===!0&&ke.endShadows(),this.info.autoReset===!0&&this.info.reset(),Ze.render(v,P),g.setupLights(_._useLegacyLights),X.isArrayCamera){const se=X.cameras;for(let ee=0,Ce=se.length;ee<Ce;ee++){const Ie=se[ee];Mu(v,P,Ie,Ie.viewport)}}else Mu(v,P,X);A!==null&&(E.updateMultisampleRenderTarget(A),E.updateRenderTargetMipmap(A)),P.isScene===!0&&P.onAfterRender(_,P,X),Le.resetDefaultState(),L=-1,M=null,y.pop(),y.length>0?g=y[y.length-1]:g=null,m.pop(),m.length>0?v=m[m.length-1]:v=null};function Dn(P,X,ne,se){if(P.visible===!1)return;if(P.layers.test(X.layers)){if(P.isGroup)ne=P.renderOrder;else if(P.isLOD)P.autoUpdate===!0&&P.update(X);else if(P.isLight)g.pushLight(P),P.castShadow&&g.pushShadow(P);else if(P.isSprite){if(!P.frustumCulled||Z.intersectsSprite(P)){se&&j.setFromMatrixPosition(P.matrixWorld).applyMatrix4(W);const Ie=fe.update(P),Oe=P.material;Oe.visible&&v.push(P,Ie,Oe,ne,j.z,null)}}else if((P.isMesh||P.isLine||P.isPoints)&&(!P.frustumCulled||Z.intersectsObject(P))){const Ie=fe.update(P),Oe=P.material;if(se&&(P.boundingSphere!==void 0?(P.boundingSphere===null&&P.computeBoundingSphere(),j.copy(P.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),j.copy(Ie.boundingSphere.center)),j.applyMatrix4(P.matrixWorld).applyMatrix4(W)),Array.isArray(Oe)){const ze=Ie.groups;for(let Ye=0,He=ze.length;Ye<He;Ye++){const Ge=ze[Ye],xt=Oe[Ge.materialIndex];xt&&xt.visible&&v.push(P,Ie,xt,ne,j.z,Ge)}}else Oe.visible&&v.push(P,Ie,Oe,ne,j.z,null)}}const Ce=P.children;for(let Ie=0,Oe=Ce.length;Ie<Oe;Ie++)Dn(Ce[Ie],X,ne,se)}function Mu(P,X,ne,se){const ee=P.opaque,Ce=P.transmissive,Ie=P.transparent;g.setupLightsView(ne),U===!0&&ke.setGlobalState(_.clippingPlanes,ne),Ce.length>0&&ug(ee,Ce,X,ne),se&&re.viewport(w.copy(se)),ee.length>0&&go(ee,X,ne),Ce.length>0&&go(Ce,X,ne),Ie.length>0&&go(Ie,X,ne),re.buffers.depth.setTest(!0),re.buffers.depth.setMask(!0),re.buffers.color.setMask(!0),re.setPolygonOffset(!1)}function ug(P,X,ne,se){if((ne.isScene===!0?ne.overrideMaterial:null)!==null)return;const Ce=Q.isWebGL2;V===null&&(V=new Cn(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?Ks:ri,minFilter:Mn,samples:Ce?4:0})),_.getDrawingBufferSize(q),Ce?V.setSize(q.x,q.y):V.setSize(Ca(q.x),Ca(q.y));const Ie=_.getRenderTarget();_.setRenderTarget(V),_.getClearColor(K),I=_.getClearAlpha(),I<1&&_.setClearColor(16777215,.5),_.clear();const Oe=_.toneMapping;_.toneMapping=si,go(P,ne,se),E.updateMultisampleRenderTarget(V),E.updateRenderTargetMipmap(V);let ze=!1;for(let Ye=0,He=X.length;Ye<He;Ye++){const Ge=X[Ye],xt=Ge.object,on=Ge.geometry,It=Ge.material,Xn=Ge.group;if(It.side===Tn&&xt.layers.test(se.layers)){const pt=It.side;It.side=Qt,It.needsUpdate=!0,Su(xt,ne,se,on,It,Xn),It.side=pt,It.needsUpdate=!0,ze=!0}}ze===!0&&(E.updateMultisampleRenderTarget(V),E.updateRenderTargetMipmap(V)),_.setRenderTarget(Ie),_.setClearColor(K,I),_.toneMapping=Oe}function go(P,X,ne){const se=X.isScene===!0?X.overrideMaterial:null;for(let ee=0,Ce=P.length;ee<Ce;ee++){const Ie=P[ee],Oe=Ie.object,ze=Ie.geometry,Ye=se===null?Ie.material:se,He=Ie.group;Oe.layers.test(ne.layers)&&Su(Oe,X,ne,ze,Ye,He)}}function Su(P,X,ne,se,ee,Ce){P.onBeforeRender(_,X,ne,se,ee,Ce),P.modelViewMatrix.multiplyMatrices(ne.matrixWorldInverse,P.matrixWorld),P.normalMatrix.getNormalMatrix(P.modelViewMatrix),ee.onBeforeRender(_,X,ne,se,P,Ce),ee.transparent===!0&&ee.side===Tn&&ee.forceSinglePass===!1?(ee.side=Qt,ee.needsUpdate=!0,_.renderBufferDirect(ne,X,se,ee,P,Ce),ee.side=Gn,ee.needsUpdate=!0,_.renderBufferDirect(ne,X,se,ee,P,Ce),ee.side=Tn):_.renderBufferDirect(ne,X,se,ee,P,Ce),P.onAfterRender(_,X,ne,se,ee,Ce)}function vo(P,X,ne){X.isScene!==!0&&(X=Y);const se=me.get(P),ee=g.state.lights,Ce=g.state.shadowsArray,Ie=ee.state.version,Oe=Re.getParameters(P,ee.state,Ce,X,ne),ze=Re.getProgramCacheKey(Oe);let Ye=se.programs;se.environment=P.isMeshStandardMaterial?X.environment:null,se.fog=X.fog,se.envMap=(P.isMeshStandardMaterial?z:S).get(P.envMap||se.environment),Ye===void 0&&(P.addEventListener("dispose",xe),Ye=new Map,se.programs=Ye);let He=Ye.get(ze);if(He!==void 0){if(se.currentProgram===He&&se.lightsStateVersion===Ie)return Au(P,Oe),He}else Oe.uniforms=Re.getUniforms(P),P.onBuild(ne,Oe,_),P.onBeforeCompile(Oe,_),He=Re.acquireProgram(Oe,ze),Ye.set(ze,He),se.uniforms=Oe.uniforms;const Ge=se.uniforms;return(!P.isShaderMaterial&&!P.isRawShaderMaterial||P.clipping===!0)&&(Ge.clippingPlanes=ke.uniform),Au(P,Oe),se.needsLights=pg(P),se.lightsStateVersion=Ie,se.needsLights&&(Ge.ambientLightColor.value=ee.state.ambient,Ge.lightProbe.value=ee.state.probe,Ge.directionalLights.value=ee.state.directional,Ge.directionalLightShadows.value=ee.state.directionalShadow,Ge.spotLights.value=ee.state.spot,Ge.spotLightShadows.value=ee.state.spotShadow,Ge.rectAreaLights.value=ee.state.rectArea,Ge.ltc_1.value=ee.state.rectAreaLTC1,Ge.ltc_2.value=ee.state.rectAreaLTC2,Ge.pointLights.value=ee.state.point,Ge.pointLightShadows.value=ee.state.pointShadow,Ge.hemisphereLights.value=ee.state.hemi,Ge.directionalShadowMap.value=ee.state.directionalShadowMap,Ge.directionalShadowMatrix.value=ee.state.directionalShadowMatrix,Ge.spotShadowMap.value=ee.state.spotShadowMap,Ge.spotLightMatrix.value=ee.state.spotLightMatrix,Ge.spotLightMap.value=ee.state.spotLightMap,Ge.pointShadowMap.value=ee.state.pointShadowMap,Ge.pointShadowMatrix.value=ee.state.pointShadowMatrix),se.currentProgram=He,se.uniformsList=null,He}function bu(P){if(P.uniformsList===null){const X=P.currentProgram.getUniforms();P.uniformsList=Ma.seqWithValue(X.seq,P.uniforms)}return P.uniformsList}function Au(P,X){const ne=me.get(P);ne.outputColorSpace=X.outputColorSpace,ne.batching=X.batching,ne.instancing=X.instancing,ne.instancingColor=X.instancingColor,ne.skinning=X.skinning,ne.morphTargets=X.morphTargets,ne.morphNormals=X.morphNormals,ne.morphColors=X.morphColors,ne.morphTargetsCount=X.morphTargetsCount,ne.numClippingPlanes=X.numClippingPlanes,ne.numIntersection=X.numClipIntersection,ne.vertexAlphas=X.vertexAlphas,ne.vertexTangents=X.vertexTangents,ne.toneMapping=X.toneMapping}function fg(P,X,ne,se,ee){X.isScene!==!0&&(X=Y),E.resetTextureUnits();const Ce=X.fog,Ie=se.isMeshStandardMaterial?X.environment:null,Oe=A===null?_.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Rt,ze=(se.isMeshStandardMaterial?z:S).get(se.envMap||Ie),Ye=se.vertexColors===!0&&!!ne.attributes.color&&ne.attributes.color.itemSize===4,He=!!ne.attributes.tangent&&(!!se.normalMap||se.anisotropy>0),Ge=!!ne.morphAttributes.position,xt=!!ne.morphAttributes.normal,on=!!ne.morphAttributes.color;let It=si;se.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(It=_.toneMapping);const Xn=ne.morphAttributes.position||ne.morphAttributes.normal||ne.morphAttributes.color,pt=Xn!==void 0?Xn.length:0,je=me.get(se),yc=g.state.lights;if(U===!0&&(N===!0||P!==M)){const dn=P===M&&se.id===L;ke.setState(se,P,dn)}let vt=!1;se.version===je.__version?(je.needsLights&&je.lightsStateVersion!==yc.state.version||je.outputColorSpace!==Oe||ee.isBatchedMesh&&je.batching===!1||!ee.isBatchedMesh&&je.batching===!0||ee.isInstancedMesh&&je.instancing===!1||!ee.isInstancedMesh&&je.instancing===!0||ee.isSkinnedMesh&&je.skinning===!1||!ee.isSkinnedMesh&&je.skinning===!0||ee.isInstancedMesh&&je.instancingColor===!0&&ee.instanceColor===null||ee.isInstancedMesh&&je.instancingColor===!1&&ee.instanceColor!==null||je.envMap!==ze||se.fog===!0&&je.fog!==Ce||je.numClippingPlanes!==void 0&&(je.numClippingPlanes!==ke.numPlanes||je.numIntersection!==ke.numIntersection)||je.vertexAlphas!==Ye||je.vertexTangents!==He||je.morphTargets!==Ge||je.morphNormals!==xt||je.morphColors!==on||je.toneMapping!==It||Q.isWebGL2===!0&&je.morphTargetsCount!==pt)&&(vt=!0):(vt=!0,je.__version=se.version);let Di=je.currentProgram;vt===!0&&(Di=vo(se,X,ee));let wu=!1,vr=!1,xc=!1;const Ht=Di.getUniforms(),Oi=je.uniforms;if(re.useProgram(Di.program)&&(wu=!0,vr=!0,xc=!0),se.id!==L&&(L=se.id,vr=!0),wu||M!==P){Ht.setValue(R,"projectionMatrix",P.projectionMatrix),Ht.setValue(R,"viewMatrix",P.matrixWorldInverse);const dn=Ht.map.cameraPosition;dn!==void 0&&dn.setValue(R,j.setFromMatrixPosition(P.matrixWorld)),Q.logarithmicDepthBuffer&&Ht.setValue(R,"logDepthBufFC",2/(Math.log(P.far+1)/Math.LN2)),(se.isMeshPhongMaterial||se.isMeshToonMaterial||se.isMeshLambertMaterial||se.isMeshBasicMaterial||se.isMeshStandardMaterial||se.isShaderMaterial)&&Ht.setValue(R,"isOrthographic",P.isOrthographicCamera===!0),M!==P&&(M=P,vr=!0,xc=!0)}if(ee.isSkinnedMesh){Ht.setOptional(R,ee,"bindMatrix"),Ht.setOptional(R,ee,"bindMatrixInverse");const dn=ee.skeleton;dn&&(Q.floatVertexTextures?(dn.boneTexture===null&&dn.computeBoneTexture(),Ht.setValue(R,"boneTexture",dn.boneTexture,E)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ee.isBatchedMesh&&(Ht.setOptional(R,ee,"batchingTexture"),Ht.setValue(R,"batchingTexture",ee._matricesTexture,E));const Mc=ne.morphAttributes;if((Mc.position!==void 0||Mc.normal!==void 0||Mc.color!==void 0&&Q.isWebGL2===!0)&&D.update(ee,ne,Di),(vr||je.receiveShadow!==ee.receiveShadow)&&(je.receiveShadow=ee.receiveShadow,Ht.setValue(R,"receiveShadow",ee.receiveShadow)),se.isMeshGouraudMaterial&&se.envMap!==null&&(Oi.envMap.value=ze,Oi.flipEnvMap.value=ze.isCubeTexture&&ze.isRenderTargetTexture===!1?-1:1),vr&&(Ht.setValue(R,"toneMappingExposure",_.toneMappingExposure),je.needsLights&&dg(Oi,xc),Ce&&se.fog===!0&&Se.refreshFogUniforms(Oi,Ce),Se.refreshMaterialUniforms(Oi,se,te,k,V),Ma.upload(R,bu(je),Oi,E)),se.isShaderMaterial&&se.uniformsNeedUpdate===!0&&(Ma.upload(R,bu(je),Oi,E),se.uniformsNeedUpdate=!1),se.isSpriteMaterial&&Ht.setValue(R,"center",ee.center),Ht.setValue(R,"modelViewMatrix",ee.modelViewMatrix),Ht.setValue(R,"normalMatrix",ee.normalMatrix),Ht.setValue(R,"modelMatrix",ee.matrixWorld),se.isShaderMaterial||se.isRawShaderMaterial){const dn=se.uniformsGroups;for(let Sc=0,mg=dn.length;Sc<mg;Sc++)if(Q.isWebGL2){const Tu=dn[Sc];Ke.update(Tu,Di),Ke.bind(Tu,Di)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Di}function dg(P,X){P.ambientLightColor.needsUpdate=X,P.lightProbe.needsUpdate=X,P.directionalLights.needsUpdate=X,P.directionalLightShadows.needsUpdate=X,P.pointLights.needsUpdate=X,P.pointLightShadows.needsUpdate=X,P.spotLights.needsUpdate=X,P.spotLightShadows.needsUpdate=X,P.rectAreaLights.needsUpdate=X,P.hemisphereLights.needsUpdate=X}function pg(P){return P.isMeshLambertMaterial||P.isMeshToonMaterial||P.isMeshPhongMaterial||P.isMeshStandardMaterial||P.isShadowMaterial||P.isShaderMaterial&&P.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(P,X,ne){me.get(P.texture).__webglTexture=X,me.get(P.depthTexture).__webglTexture=ne;const se=me.get(P);se.__hasExternalTextures=!0,se.__hasExternalTextures&&(se.__autoAllocateDepthBuffer=ne===void 0,se.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),se.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(P,X){const ne=me.get(P);ne.__webglFramebuffer=X,ne.__useDefaultFramebuffer=X===void 0},this.setRenderTarget=function(P,X=0,ne=0){A=P,T=X,b=ne;let se=!0,ee=null,Ce=!1,Ie=!1;if(P){const ze=me.get(P);ze.__useDefaultFramebuffer!==void 0?(re.bindFramebuffer(R.FRAMEBUFFER,null),se=!1):ze.__webglFramebuffer===void 0?E.setupRenderTarget(P):ze.__hasExternalTextures&&E.rebindTextures(P,me.get(P.texture).__webglTexture,me.get(P.depthTexture).__webglTexture);const Ye=P.texture;(Ye.isData3DTexture||Ye.isDataArrayTexture||Ye.isCompressedArrayTexture)&&(Ie=!0);const He=me.get(P).__webglFramebuffer;P.isWebGLCubeRenderTarget?(Array.isArray(He[X])?ee=He[X][ne]:ee=He[X],Ce=!0):Q.isWebGL2&&P.samples>0&&E.useMultisampledRTT(P)===!1?ee=me.get(P).__webglMultisampledFramebuffer:Array.isArray(He)?ee=He[ne]:ee=He,w.copy(P.viewport),O.copy(P.scissor),H=P.scissorTest}else w.copy(le).multiplyScalar(te).floor(),O.copy(ce).multiplyScalar(te).floor(),H=ge;if(re.bindFramebuffer(R.FRAMEBUFFER,ee)&&Q.drawBuffers&&se&&re.drawBuffers(P,ee),re.viewport(w),re.scissor(O),re.setScissorTest(H),Ce){const ze=me.get(P.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_CUBE_MAP_POSITIVE_X+X,ze.__webglTexture,ne)}else if(Ie){const ze=me.get(P.texture),Ye=X||0;R.framebufferTextureLayer(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,ze.__webglTexture,ne||0,Ye)}L=-1},this.readRenderTargetPixels=function(P,X,ne,se,ee,Ce,Ie){if(!(P&&P.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Oe=me.get(P).__webglFramebuffer;if(P.isWebGLCubeRenderTarget&&Ie!==void 0&&(Oe=Oe[Ie]),Oe){re.bindFramebuffer(R.FRAMEBUFFER,Oe);try{const ze=P.texture,Ye=ze.format,He=ze.type;if(Ye!==nn&&ve.convert(Ye)!==R.getParameter(R.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Ge=He===Ks&&(G.has("EXT_color_buffer_half_float")||Q.isWebGL2&&G.has("EXT_color_buffer_float"));if(He!==ri&&ve.convert(He)!==R.getParameter(R.IMPLEMENTATION_COLOR_READ_TYPE)&&!(He===En&&(Q.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!Ge){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}X>=0&&X<=P.width-se&&ne>=0&&ne<=P.height-ee&&R.readPixels(X,ne,se,ee,ve.convert(Ye),ve.convert(He),Ce)}finally{const ze=A!==null?me.get(A).__webglFramebuffer:null;re.bindFramebuffer(R.FRAMEBUFFER,ze)}}},this.copyFramebufferToTexture=function(P,X,ne=0){const se=Math.pow(2,-ne),ee=Math.floor(X.image.width*se),Ce=Math.floor(X.image.height*se);E.setTexture2D(X,0),R.copyTexSubImage2D(R.TEXTURE_2D,ne,0,0,P.x,P.y,ee,Ce),re.unbindTexture()},this.copyTextureToTexture=function(P,X,ne,se=0){const ee=X.image.width,Ce=X.image.height,Ie=ve.convert(ne.format),Oe=ve.convert(ne.type);E.setTexture2D(ne,0),R.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,ne.flipY),R.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ne.premultiplyAlpha),R.pixelStorei(R.UNPACK_ALIGNMENT,ne.unpackAlignment),X.isDataTexture?R.texSubImage2D(R.TEXTURE_2D,se,P.x,P.y,ee,Ce,Ie,Oe,X.image.data):X.isCompressedTexture?R.compressedTexSubImage2D(R.TEXTURE_2D,se,P.x,P.y,X.mipmaps[0].width,X.mipmaps[0].height,Ie,X.mipmaps[0].data):R.texSubImage2D(R.TEXTURE_2D,se,P.x,P.y,Ie,Oe,X.image),se===0&&ne.generateMipmaps&&R.generateMipmap(R.TEXTURE_2D),re.unbindTexture()},this.copyTextureToTexture3D=function(P,X,ne,se,ee=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ce=P.max.x-P.min.x+1,Ie=P.max.y-P.min.y+1,Oe=P.max.z-P.min.z+1,ze=ve.convert(se.format),Ye=ve.convert(se.type);let He;if(se.isData3DTexture)E.setTexture3D(se,0),He=R.TEXTURE_3D;else if(se.isDataArrayTexture||se.isCompressedArrayTexture)E.setTexture2DArray(se,0),He=R.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}R.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,se.flipY),R.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,se.premultiplyAlpha),R.pixelStorei(R.UNPACK_ALIGNMENT,se.unpackAlignment);const Ge=R.getParameter(R.UNPACK_ROW_LENGTH),xt=R.getParameter(R.UNPACK_IMAGE_HEIGHT),on=R.getParameter(R.UNPACK_SKIP_PIXELS),It=R.getParameter(R.UNPACK_SKIP_ROWS),Xn=R.getParameter(R.UNPACK_SKIP_IMAGES),pt=ne.isCompressedTexture?ne.mipmaps[ee]:ne.image;R.pixelStorei(R.UNPACK_ROW_LENGTH,pt.width),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,pt.height),R.pixelStorei(R.UNPACK_SKIP_PIXELS,P.min.x),R.pixelStorei(R.UNPACK_SKIP_ROWS,P.min.y),R.pixelStorei(R.UNPACK_SKIP_IMAGES,P.min.z),ne.isDataTexture||ne.isData3DTexture?R.texSubImage3D(He,ee,X.x,X.y,X.z,Ce,Ie,Oe,ze,Ye,pt.data):ne.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),R.compressedTexSubImage3D(He,ee,X.x,X.y,X.z,Ce,Ie,Oe,ze,pt.data)):R.texSubImage3D(He,ee,X.x,X.y,X.z,Ce,Ie,Oe,ze,Ye,pt),R.pixelStorei(R.UNPACK_ROW_LENGTH,Ge),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,xt),R.pixelStorei(R.UNPACK_SKIP_PIXELS,on),R.pixelStorei(R.UNPACK_SKIP_ROWS,It),R.pixelStorei(R.UNPACK_SKIP_IMAGES,Xn),ee===0&&se.generateMipmaps&&R.generateMipmap(He),re.unbindTexture()},this.initTexture=function(P){P.isCubeTexture?E.setTextureCube(P,0):P.isData3DTexture?E.setTexture3D(P,0):P.isDataArrayTexture||P.isCompressedArrayTexture?E.setTexture2DArray(P,0):E.setTexture2D(P,0),re.unbindTexture()},this.resetState=function(){T=0,b=0,A=null,re.reset(),Le.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Rn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===qa?"display-p3":"srgb",t.unpackColorSpace=rt.workingColorSpace===to?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===ht?Ai:bh}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ai?ht:Rt}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class zp extends Fp{}zp.prototype.isWebGL1Renderer=!0;class Qa{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Te(e),this.density=t}clone(){return new Qa(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class ec{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Te(e),this.near=t,this.far=n}clone(){return new ec(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class kp extends tt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class rr{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Wr,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=un()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=un()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=un()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Zt=new C;class $t{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Zt.fromBufferAttribute(this,t),Zt.applyMatrix4(e),this.setXYZ(t,Zt.x,Zt.y,Zt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Zt.fromBufferAttribute(this,t),Zt.applyNormalMatrix(e),this.setXYZ(t,Zt.x,Zt.y,Zt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Zt.fromBufferAttribute(this,t),Zt.transformDirection(e),this.setXYZ(t,Zt.x,Zt.y,Zt.z);return this}setX(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=We(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=sn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=sn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=sn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=sn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=We(t,this.array),n=We(n,this.array),i=We(i,this.array),r=We(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new Fe(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new $t(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Nh extends Et{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Te(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Us;const Sr=new C,Ns=new C,Ds=new C,Os=new ae,br=new ae,Hp=new Ne,ko=new C,Ar=new C,Ho=new C,ff=new ae,qc=new ae,df=new ae;class Gp extends tt{constructor(e=new Nh){if(super(),this.isSprite=!0,this.type="Sprite",Us===void 0){Us=new Be;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new rr(t,5);Us.setIndex([0,1,2,0,2,3]),Us.setAttribute("position",new $t(n,3,0,!1)),Us.setAttribute("uv",new $t(n,2,3,!1))}this.geometry=Us,this.material=e,this.center=new ae(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ns.setFromMatrixScale(this.matrixWorld),Hp.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ns.multiplyScalar(-Ds.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const o=this.center;Go(ko.set(-.5,-.5,0),Ds,o,Ns,i,r),Go(Ar.set(.5,-.5,0),Ds,o,Ns,i,r),Go(Ho.set(.5,.5,0),Ds,o,Ns,i,r),ff.set(0,0),qc.set(1,0),df.set(1,1);let a=e.ray.intersectTriangle(ko,Ar,Ho,!1,Sr);if(a===null&&(Go(Ar.set(-.5,.5,0),Ds,o,Ns,i,r),qc.set(0,1),a=e.ray.intersectTriangle(ko,Ho,Ar,!1,Sr),a===null))return;const c=e.ray.origin.distanceTo(Sr);c<e.near||c>e.far||t.push({distance:c,point:Sr.clone(),uv:tn.getInterpolation(Sr,ko,Ar,Ho,ff,qc,df,new ae),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Go(s,e,t,n,i,r){Os.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(br.x=r*Os.x-i*Os.y,br.y=i*Os.x+r*Os.y):br.copy(Os),s.copy(e),s.x+=br.x,s.y+=br.y,s.applyMatrix4(Hp)}const Vo=new C,pf=new C;class Vp extends tt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n<i;n++){const r=t[n];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let r;for(r=0;r<i.length&&!(t<i[r].distance);r++);return i.splice(r,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let r=t[n].distance;if(t[n].object.visible&&(r-=r*t[n].hysteresis),e<r)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Vo.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(Vo);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Vo.setFromMatrixPosition(e.matrixWorld),pf.setFromMatrixPosition(this.matrixWorld);const n=Vo.distanceTo(pf)/e.zoom;t[0].object.visible=!0;let i,r;for(i=1,r=t.length;i<r;i++){let o=t[i].distance;if(t[i].object.visible&&(o-=o*t[i].hysteresis),n>=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<r;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let i=0,r=n.length;i<r;i++){const o=n[i];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}}const mf=new C,gf=new nt,vf=new nt,pM=new C,_f=new Ne,Wo=new C,Yc=new Tt,yf=new Ne,Zc=new ds;class Dh extends ft{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=xl,this.bindMatrix=new Ne,this.bindMatrixInverse=new Ne,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new wt),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Wo),this.boundingBox.expandByPoint(Wo)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Tt),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Wo),this.boundingSphere.expandByPoint(Wo)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Yc.copy(this.boundingSphere),Yc.applyMatrix4(i),e.ray.intersectsSphere(Yc)!==!1&&(yf.copy(i).invert(),Zc.copy(e.ray).applyMatrix4(yf),!(this.boundingBox!==null&&Zc.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Zc)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new nt,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===xl?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===ep?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,i=this.geometry;gf.fromBufferAttribute(i.attributes.skinIndex,e),vf.fromBufferAttribute(i.attributes.skinWeight,e),mf.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){const o=vf.getComponent(r);if(o!==0){const a=gf.getComponent(r);_f.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(pM.copy(mf).applyMatrix4(_f),o)}}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class tc extends tt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class rs extends gt{constructor(e=null,t=1,n=1,i,r,o,a,c,l=dt,h=dt,u,f){super(null,o,a,c,l,h,i,r,u,f),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const xf=new Ne,mM=new Ne;class ao{constructor(e=[],t=[]){this.uuid=un(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Ne)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Ne;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=e.length;r<o;r++){const a=e[r]?e[r].matrixWorld:mM;xf.multiplyMatrices(a,t[r]),xf.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new ao(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new rs(t,e,e,nn,En);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const r=e.bones[n];let o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new tc),this.bones.push(o),this.boneInverses.push(new Ne().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){const o=t[i];e.bones.push(o.uuid);const a=n[i];e.boneInverses.push(a.toArray())}return e}}class ai extends Fe{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Bs=new Ne,Mf=new Ne,Xo=[],Sf=new wt,gM=new Ne,wr=new ft,Tr=new Tt;class Oh extends ft{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ai(new Float32Array(n*16),16),this.instanceColor=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,gM)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new wt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Bs),Sf.copy(e.boundingBox).applyMatrix4(Bs),this.boundingBox.union(Sf)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Tt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Bs),Tr.copy(e.boundingSphere).applyMatrix4(Bs),this.boundingSphere.union(Tr)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(wr.geometry=this.geometry,wr.material=this.material,wr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Tr.copy(this.boundingSphere),Tr.applyMatrix4(n),e.ray.intersectsSphere(Tr)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Bs),Mf.multiplyMatrices(n,Bs),wr.matrixWorld=Mf,wr.raycast(e,Xo);for(let o=0,a=Xo.length;o<a;o++){const c=Xo[o];c.instanceId=r,c.object=this,t.push(c)}Xo.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ai(new Float32Array(this.instanceMatrix.count*3),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}function vM(s,e){return s.z-e.z}function _M(s,e){return e.z-s.z}class yM{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t){const n=this.pool,i=this.list;this.index>=n.length&&n.push({start:-1,count:-1,z:-1});const r=n[this.index];i.push(r),this.index++,r.start=e.start,r.count=e.count,r.z=t}reset(){this.list.length=0,this.index=0}}const Fs="batchId",gi=new Ne,bf=new Ne,xM=new Ne,Af=new Ne,Kc=new so,qo=new wt,Hi=new Tt,Er=new C,jc=new yM,Wt=new ft,Yo=[];function MM(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)e.setComponent(r+t,o,s.getComponent(r,o))}else e.array.set(s.array,t*n);e.needsUpdate=!0}class Wp extends ft{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,t,n=t*2,i){super(new Be,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._drawRanges=[],this._reservedRanges=[],this._visibility=[],this._active=[],this._bounds=[],this._maxGeometryCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._geometryInitialized=!1,this._geometryCount=0,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._visibilityChanged=!0,this._matricesTexture=null,this._initMatricesTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxGeometryCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new rs(t,e,e,nn,En);this._matricesTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,i=this._maxGeometryCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const a in e.attributes){const c=e.getAttribute(a),{array:l,itemSize:h,normalized:u}=c,f=new l.constructor(n*h),d=new c.constructor(f,h,u);d.setUsage(c.usage),t.setAttribute(a,d)}if(e.getIndex()!==null){const a=n>65536?new Uint32Array(r):new Uint16Array(r);t.setIndex(new Fe(a,1))}const o=i>65536?new Uint32Array(n):new Uint16Array(n);t.setAttribute(Fs,new Fe(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Fs))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Fs}"`);const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(n===Fs)continue;if(!e.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wt);const e=this._geometryCount,t=this.boundingBox,n=this._active;t.makeEmpty();for(let i=0;i<e;i++)n[i]!==!1&&(this.getMatrixAt(i,gi),this.getBoundingBoxAt(i,qo).applyMatrix4(gi),t.union(qo))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tt);const e=this._geometryCount,t=this.boundingSphere,n=this._active;t.makeEmpty();for(let i=0;i<e;i++)n[i]!==!1&&(this.getMatrixAt(i,gi),this.getBoundingSphereAt(i,Hi).applyMatrix4(gi),t.union(Hi))}addGeometry(e,t=-1,n=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const o=this._reservedRanges,a=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(r=o[o.length-1]),t===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=t,r===null?i.vertexStart=0:i.vertexStart=r.vertexStart+r.vertexCount;const l=e.getIndex(),h=l!==null;if(h&&(n===-1?i.indexCount=l.count:i.indexCount=n,r===null?i.indexStart=0:i.indexStart=r.indexStart+r.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._visibility,f=this._active,d=this._matricesTexture,p=this._matricesTexture.image.data;u.push(!0),f.push(!0);const v=this._geometryCount;this._geometryCount++,xM.toArray(p,v*16),d.needsUpdate=!0,o.push(i),a.push({start:h?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new wt,sphereInitialized:!1,sphere:new Tt});const g=this.geometry.getAttribute(Fs);for(let m=0;m<i.vertexCount;m++)g.setX(i.vertexStart+m,v);return g.needsUpdate=!0,this.setGeometryAt(v,e),v}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=t.getIndex(),a=this._reservedRanges[e];if(i&&o.count>a.indexCount||t.attributes.position.count>a.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const c=a.vertexStart,l=a.vertexCount;for(const d in n.attributes){if(d===Fs)continue;const p=t.getAttribute(d),v=n.getAttribute(d);MM(p,v,c);const g=p.itemSize;for(let m=p.count,y=l;m<y;m++){const _=c+m;for(let x=0;x<g;x++)v.setComponent(_,x,0)}v.needsUpdate=!0}if(i){const d=a.indexStart;for(let p=0;p<o.count;p++)r.setX(d+p,c+o.getX(p));for(let p=o.count,v=a.indexCount;p<v;p++)r.setX(d+p,c);r.needsUpdate=!0}const h=this._bounds[e];t.boundingBox!==null?(h.box.copy(t.boundingBox),h.boxInitialized=!0):h.boxInitialized=!1,t.boundingSphere!==null?(h.sphere.copy(t.boundingSphere),h.sphereInitialized=!0):h.sphereInitialized=!1;const u=this._drawRanges[e],f=t.getAttribute("position");return u.count=i?o.count:f.count,this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._active;return e>=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return this;const i=this._bounds[e],r=i.box,o=this.geometry;if(i.boxInitialized===!1){r.makeEmpty();const a=o.index,c=o.attributes.position,l=this._drawRanges[e];for(let h=l.start,u=l.start+l.count;h<u;h++){let f=h;a&&(f=a.getX(f)),r.expandByPoint(Er.fromBufferAttribute(c,f))}i.boxInitialized=!0}return t.copy(r),t}getBoundingSphereAt(e,t){if(this._active[e]===!1)return this;const i=this._bounds[e],r=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){r.makeEmpty(),this.getBoundingBoxAt(e,qo),qo.getCenter(r.center);const a=o.index,c=o.attributes.position,l=this._drawRanges[e];let h=0;for(let u=l.start,f=l.start+l.count;u<f;u++){let d=u;a&&(d=a.getX(d)),Er.fromBufferAttribute(c,d),h=Math.max(h,r.center.distanceToSquared(Er))}r.radius=Math.sqrt(h),i.sphereInitialized=!0}return t.copy(r),t}setMatrixAt(e,t){const n=this._active,i=this._matricesTexture,r=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||n[e]===!1?this:(t.toArray(r,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,t){const n=this._active,i=this._matricesTexture.image.data,r=this._geometryCount;return e>=r||n[e]===!1?null:t.fromArray(i,e*16)}setVisibleAt(e,t){const n=this._visibility,i=this._active,r=this._geometryCount;return e>=r||i[e]===!1||n[e]===t?this:(n[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){const t=this._visibility,n=this._active,i=this._geometryCount;return e>=i||n[e]===!1?!1:t[e]}raycast(e,t){const n=this._visibility,i=this._active,r=this._drawRanges,o=this._geometryCount,a=this.matrixWorld,c=this.geometry;Wt.material=this.material,Wt.geometry.index=c.index,Wt.geometry.attributes=c.attributes,Wt.geometry.boundingBox===null&&(Wt.geometry.boundingBox=new wt),Wt.geometry.boundingSphere===null&&(Wt.geometry.boundingSphere=new Tt);for(let l=0;l<o;l++){if(!n[l]||!i[l])continue;const h=r[l];Wt.geometry.setDrawRange(h.start,h.count),this.getMatrixAt(l,Wt.matrixWorld).premultiply(a),this.getBoundingBoxAt(l,Wt.geometry.boundingBox),this.getBoundingSphereAt(l,Wt.geometry.boundingSphere),Wt.raycast(e,Yo);for(let u=0,f=Yo.length;u<f;u++){const d=Yo[u];d.object=this,d.batchId=l,t.push(d)}Yo.length=0}Wt.material=null,Wt.geometry.index=null,Wt.geometry.attributes={},Wt.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(t=>({...t})),this._reservedRanges=e._reservedRanges.map(t=>({...t})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(t=>({boxInitialized:t.boxInitialized,box:t.box.clone(),sphereInitialized:t.sphereInitialized,sphere:t.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,l=this._multiDrawStarts,h=this._multiDrawCounts,u=this._drawRanges,f=this.perObjectFrustumCulled;f&&(Af.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Kc.setFromProjectionMatrix(Af,e.isWebGPURenderer?Js:Rn));let d=0;if(this.sortObjects){bf.copy(this.matrixWorld).invert(),Er.setFromMatrixPosition(n.matrixWorld).applyMatrix4(bf);for(let g=0,m=c.length;g<m;g++)if(c[g]){this.getMatrixAt(g,gi),this.getBoundingSphereAt(g,Hi).applyMatrix4(gi);let y=!1;if(f&&(y=!Kc.intersectsSphere(Hi)),!y){const _=Er.distanceTo(Hi.center);jc.push(u[g],_)}}const p=jc.list,v=this.customSort;v===null?p.sort(r.transparent?_M:vM):v.call(this,p,n);for(let g=0,m=p.length;g<m;g++){const y=p[g];l[d]=y.start*a,h[d]=y.count,d++}jc.reset()}else for(let p=0,v=c.length;p<v;p++)if(c[p]){let g=!1;if(f&&(this.getMatrixAt(p,gi),this.getBoundingSphereAt(p,Hi).applyMatrix4(gi),g=!Kc.intersectsSphere(Hi)),!g){const m=u[p];l[d]=m.start*a,h[d]=m.count,d++}}this._multiDrawCount=d,this._visibilityChanged=!1}onBeforeShadow(e,t,n,i,r,o){this.onBeforeRender(e,null,i,r,o)}}class Xt extends Et{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Te(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const wf=new C,Tf=new C,Ef=new Ne,Jc=new ds,Zo=new Tt;class ci extends tt{constructor(e=new Be,t=new Xt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)wf.fromBufferAttribute(t,i-1),Tf.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=wf.distanceTo(Tf);e.setAttribute("lineDistance",new Ee(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Zo.copy(n.boundingSphere),Zo.applyMatrix4(i),Zo.radius+=r,e.ray.intersectsSphere(Zo)===!1)return;Ef.copy(i).invert(),Jc.copy(e.ray).applyMatrix4(Ef);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=new C,h=new C,u=new C,f=new C,d=this.isLineSegments?2:1,p=n.index,g=n.attributes.position;if(p!==null){const m=Math.max(0,o.start),y=Math.min(p.count,o.start+o.count);for(let _=m,x=y-1;_<x;_+=d){const T=p.getX(_),b=p.getX(_+1);if(l.fromBufferAttribute(g,T),h.fromBufferAttribute(g,b),Jc.distanceSqToSegment(l,h,f,u)>c)continue;f.applyMatrix4(this.matrixWorld);const L=e.ray.origin.distanceTo(f);L<e.near||L>e.far||t.push({distance:L,point:u.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}else{const m=Math.max(0,o.start),y=Math.min(g.count,o.start+o.count);for(let _=m,x=y-1;_<x;_+=d){if(l.fromBufferAttribute(g,_),h.fromBufferAttribute(g,_+1),Jc.distanceSqToSegment(l,h,f,u)>c)continue;f.applyMatrix4(this.matrixWorld);const b=e.ray.origin.distanceTo(f);b<e.near||b>e.far||t.push({distance:b,point:u.clone().applyMatrix4(this.matrixWorld),index:_,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}const Rf=new C,Cf=new C;class Pn extends ci{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Rf.fromBufferAttribute(t,i),Cf.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Rf.distanceTo(Cf);e.setAttribute("lineDistance",new Ee(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Bh extends ci{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class nc extends Et{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Te(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Lf=new Ne,Jl=new ds,Ko=new Tt,jo=new C;class Fh extends tt{constructor(e=new Be,t=new nc){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ko.copy(n.boundingSphere),Ko.applyMatrix4(i),Ko.radius+=r,e.ray.intersectsSphere(Ko)===!1)return;Lf.copy(i).invert(),Jl.copy(e.ray).applyMatrix4(Lf);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,u=n.attributes.position;if(l!==null){const f=Math.max(0,o.start),d=Math.min(l.count,o.start+o.count);for(let p=f,v=d;p<v;p++){const g=l.getX(p);jo.fromBufferAttribute(u,g),Pf(jo,g,c,i,e,t,this)}}else{const f=Math.max(0,o.start),d=Math.min(u.count,o.start+o.count);for(let p=f,v=d;p<v;p++)jo.fromBufferAttribute(u,p),Pf(jo,p,c,i,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}}function Pf(s,e,t,n,i,r,o){const a=Jl.distanceSqToPoint(s);if(a<t){const c=new C;Jl.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,object:o})}}class SM extends gt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:at,this.magFilter=r!==void 0?r:at,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,e.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class bM extends gt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=dt,this.minFilter=dt,this.generateMipmaps=!1,this.needsUpdate=!0}}class ic extends gt{constructor(e,t,n,i,r,o,a,c,l,h,u,f){super(null,o,a,c,l,h,i,r,u,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class AM extends ic{constructor(e,t,n,i,r,o){super(e,t,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=At}}class wM extends ic{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,oi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class TM extends gt{constructor(e,t,n,i,r,o,a,c,l){super(e,t,n,i,r,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class In{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let o;t?o=t:o=e*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);const h=n[i],f=n[i+1]-h,d=(o-h)/f;return(i+d)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),c=t||(o.isVector2?new ae:new C);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new C,i=[],r=[],o=[],a=new C,c=new Ne;for(let d=0;d<=e;d++){const p=d/e;i[d]=this.getTangentAt(p,new C)}r[0]=new C,o[0]=new C;let l=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),f=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),o[d]=o[d-1].clone(),a.crossVectors(i[d-1],i[d]),a.length()>Number.EPSILON){a.normalize();const p=Math.acos(yt(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(c.makeRotationAxis(a,p))}o[d].crossVectors(i[d],r[d])}if(t===!0){let d=Math.acos(yt(r[0].dot(r[e]),-1,1));d/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(d=-d);for(let p=1;p<=e;p++)r[p].applyMatrix4(c.makeRotationAxis(i[p],d*p)),o[p].crossVectors(i[p],r[p])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class sc extends In{constructor(e=0,t=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t){const n=t||new ae,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);const a=this.aStartAngle+e*r;let c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),f=c-this.aX,d=l-this.aY;c=f*h-d*u+this.aX,l=f*u+d*h+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Xp extends sc{constructor(e,t,n,i,r,o){super(e,t,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}}function zh(){let s=0,e=0,t=0,n=0;function i(r,o,a,c){s=r,e=a,t=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,h,u){let f=(o-r)/l-(a-r)/(l+h)+(a-o)/h,d=(a-o)/h-(c-o)/(h+u)+(c-a)/u;f*=h,d*=h,i(o,a,f,d)},calc:function(r){const o=r*r,a=o*r;return s+e*r+t*o+n*a}}}const Jo=new C,$c=new zh,Qc=new zh,el=new zh;class qp extends In{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new C){const n=t,i=this.points,r=i.length,o=(r-(this.closed?0:1))*e;let a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,h;this.closed||a>0?l=i[(a-1)%r]:(Jo.subVectors(i[0],i[1]).add(i[0]),l=Jo);const u=i[a%r],f=i[(a+1)%r];if(this.closed||a+2<r?h=i[(a+2)%r]:(Jo.subVectors(i[r-1],i[r-2]).add(i[r-1]),h=Jo),this.curveType==="centripetal"||this.curveType==="chordal"){const d=this.curveType==="chordal"?.5:.25;let p=Math.pow(l.distanceToSquared(u),d),v=Math.pow(u.distanceToSquared(f),d),g=Math.pow(f.distanceToSquared(h),d);v<1e-4&&(v=1),p<1e-4&&(p=v),g<1e-4&&(g=v),$c.initNonuniformCatmullRom(l.x,u.x,f.x,h.x,p,v,g),Qc.initNonuniformCatmullRom(l.y,u.y,f.y,h.y,p,v,g),el.initNonuniformCatmullRom(l.z,u.z,f.z,h.z,p,v,g)}else this.curveType==="catmullrom"&&($c.initCatmullRom(l.x,u.x,f.x,h.x,this.tension),Qc.initCatmullRom(l.y,u.y,f.y,h.y,this.tension),el.initCatmullRom(l.z,u.z,f.z,h.z,this.tension));return n.set($c.calc(c),Qc.calc(c),el.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new C().fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function If(s,e,t,n,i){const r=(n-e)*.5,o=(i-t)*.5,a=s*s,c=s*a;return(2*t-2*n+r+o)*c+(-3*t+3*n-2*r-o)*a+r*s+t}function EM(s,e){const t=1-s;return t*t*e}function RM(s,e){return 2*(1-s)*s*e}function CM(s,e){return s*s*e}function Ur(s,e,t,n){return EM(s,e)+RM(s,t)+CM(s,n)}function LM(s,e){const t=1-s;return t*t*t*e}function PM(s,e){const t=1-s;return 3*t*t*s*e}function IM(s,e){return 3*(1-s)*s*s*e}function UM(s,e){return s*s*s*e}function Nr(s,e,t,n,i){return LM(s,e)+PM(s,t)+IM(s,n)+UM(s,i)}class kh extends In{constructor(e=new ae,t=new ae,n=new ae,i=new ae){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new ae){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Nr(e,i.x,r.x,o.x,a.x),Nr(e,i.y,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Yp extends In{constructor(e=new C,t=new C,n=new C,i=new C){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new C){const n=t,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Nr(e,i.x,r.x,o.x,a.x),Nr(e,i.y,r.y,o.y,a.y),Nr(e,i.z,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Hh extends In{constructor(e=new ae,t=new ae){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ae){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ae){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Zp extends In{constructor(e=new C,t=new C){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new C){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new C){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Gh extends In{constructor(e=new ae,t=new ae,n=new ae){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ae){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Ur(e,i.x,r.x,o.x),Ur(e,i.y,r.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Vh extends In{constructor(e=new C,t=new C,n=new C){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new C){const n=t,i=this.v0,r=this.v1,o=this.v2;return n.set(Ur(e,i.x,r.x,o.x),Ur(e,i.y,r.y,o.y),Ur(e,i.z,r.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Wh extends In{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ae){const n=t,i=this.points,r=(i.length-1)*e,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],h=i[o>i.length-2?i.length-1:o+1],u=i[o>i.length-3?i.length-1:o+2];return n.set(If(a,c.x,l.x,h.x,u.x),If(a,c.y,l.y,h.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const i=e.points[t];this.points.push(new ae().fromArray(i))}return this}}var La=Object.freeze({__proto__:null,ArcCurve:Xp,CatmullRomCurve3:qp,CubicBezierCurve:kh,CubicBezierCurve3:Yp,EllipseCurve:sc,LineCurve:Hh,LineCurve3:Zp,QuadraticBezierCurve:Gh,QuadraticBezierCurve3:Vh,SplineCurve:Wh});class Kp extends In{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new La[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let r=0;for(;r<i.length;){if(i[r]>=n){const o=i[r]-n,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,r=this.curves;i<r.length;i++){const o=r[i],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){const h=c[l];n&&n.equals(h)||(t.push(h),n=h)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const i=e.curves[t];this.curves.push(new La[i.type]().fromJSON(i))}return this}}class qr extends Kp{constructor(e){super(),this.type="Path",this.currentPoint=new ae,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Hh(this.currentPoint.clone(),new ae(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const r=new Gh(this.currentPoint.clone(),new ae(e,t),new ae(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,o){const a=new kh(this.currentPoint.clone(),new ae(e,t),new ae(n,i),new ae(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Wh(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,r,o){const a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,i,r,o),this}absarc(e,t,n,i,r,o){return this.absellipse(e,t,n,n,i,r,o),this}ellipse(e,t,n,i,r,o,a,c){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,n,i,r,o,a,c),this}absellipse(e,t,n,i,r,o,a,c){const l=new sc(e,t,n,i,r,o,a,c);if(this.curves.length>0){const u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);const h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class co extends Be{constructor(e=[new ae(0,-.5),new ae(.5,0),new ae(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=yt(i,0,Math.PI*2);const r=[],o=[],a=[],c=[],l=[],h=1/t,u=new C,f=new ae,d=new C,p=new C,v=new C;let g=0,m=0;for(let y=0;y<=e.length-1;y++)switch(y){case 0:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,v.copy(d),d.normalize(),c.push(d.x,d.y,d.z);break;case e.length-1:c.push(v.x,v.y,v.z);break;default:g=e[y+1].x-e[y].x,m=e[y+1].y-e[y].y,d.x=m*1,d.y=-g,d.z=m*0,p.copy(d),d.x+=v.x,d.y+=v.y,d.z+=v.z,d.normalize(),c.push(d.x,d.y,d.z),v.copy(p)}for(let y=0;y<=t;y++){const _=n+y*h*i,x=Math.sin(_),T=Math.cos(_);for(let b=0;b<=e.length-1;b++){u.x=e[b].x*x,u.y=e[b].y,u.z=e[b].x*T,o.push(u.x,u.y,u.z),f.x=y/t,f.y=b/(e.length-1),a.push(f.x,f.y);const A=c[3*b+0]*x,L=c[3*b+1],M=c[3*b+0]*T;l.push(A,L,M)}}for(let y=0;y<t;y++)for(let _=0;_<e.length-1;_++){const x=_+y*e.length,T=x,b=x+e.length,A=x+e.length+1,L=x+1;r.push(T,b,L),r.push(A,L,b)}this.setIndex(r),this.setAttribute("position",new Ee(o,3)),this.setAttribute("uv",new Ee(a,2)),this.setAttribute("normal",new Ee(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new co(e.points,e.segments,e.phiStart,e.phiLength)}}class rc extends co{constructor(e=1,t=1,n=4,i=8){const r=new qr;r.absarc(0,-t/2,e,Math.PI*1.5,0),r.absarc(0,t/2,e,0,Math.PI*.5),super(r.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new rc(e.radius,e.length,e.capSegments,e.radialSegments)}}class oc extends Be{constructor(e=1,t=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],o=[],a=[],c=[],l=new C,h=new ae;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let u=0,f=3;u<=t;u++,f+=3){const d=n+u/t*i;l.x=e*Math.cos(d),l.y=e*Math.sin(d),o.push(l.x,l.y,l.z),a.push(0,0,1),h.x=(o[f]/e+1)/2,h.y=(o[f+1]/e+1)/2,c.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Ee(o,3)),this.setAttribute("normal",new Ee(a,3)),this.setAttribute("uv",new Ee(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class or extends Be{constructor(e=1,t=1,n=1,i=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],f=[],d=[];let p=0;const v=[],g=n/2;let m=0;y(),o===!1&&(e>0&&_(!0),t>0&&_(!1)),this.setIndex(h),this.setAttribute("position",new Ee(u,3)),this.setAttribute("normal",new Ee(f,3)),this.setAttribute("uv",new Ee(d,2));function y(){const x=new C,T=new C;let b=0;const A=(t-e)/n;for(let L=0;L<=r;L++){const M=[],w=L/r,O=w*(t-e)+e;for(let H=0;H<=i;H++){const K=H/i,I=K*c+a,F=Math.sin(I),k=Math.cos(I);T.x=O*F,T.y=-w*n+g,T.z=O*k,u.push(T.x,T.y,T.z),x.set(F,A,k).normalize(),f.push(x.x,x.y,x.z),d.push(K,1-w),M.push(p++)}v.push(M)}for(let L=0;L<i;L++)for(let M=0;M<r;M++){const w=v[M][L],O=v[M+1][L],H=v[M+1][L+1],K=v[M][L+1];h.push(w,O,K),h.push(O,H,K),b+=6}l.addGroup(m,b,0),m+=b}function _(x){const T=p,b=new ae,A=new C;let L=0;const M=x===!0?e:t,w=x===!0?1:-1;for(let H=1;H<=i;H++)u.push(0,g*w,0),f.push(0,w,0),d.push(.5,.5),p++;const O=p;for(let H=0;H<=i;H++){const I=H/i*c+a,F=Math.cos(I),k=Math.sin(I);A.x=M*k,A.y=g*w,A.z=M*F,u.push(A.x,A.y,A.z),f.push(0,w,0),b.x=F*.5+.5,b.y=k*.5*w+.5,d.push(b.x,b.y),p++}for(let H=0;H<i;H++){const K=T+H,I=O+H;x===!0?h.push(I,I+1,K):h.push(I+1,I,K),L+=3}l.addGroup(m,L,x===!0?1:2),m+=L}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new or(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class ac extends or{constructor(e=1,t=1,n=32,i=1,r=!1,o=0,a=Math.PI*2){super(0,e,t,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(e){return new ac(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ii extends Be{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],o=[];a(i),l(n),h(),this.setAttribute("position",new Ee(r,3)),this.setAttribute("normal",new Ee(r.slice(),3)),this.setAttribute("uv",new Ee(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(y){const _=new C,x=new C,T=new C;for(let b=0;b<t.length;b+=3)d(t[b+0],_),d(t[b+1],x),d(t[b+2],T),c(_,x,T,y)}function c(y,_,x,T){const b=T+1,A=[];for(let L=0;L<=b;L++){A[L]=[];const M=y.clone().lerp(x,L/b),w=_.clone().lerp(x,L/b),O=b-L;for(let H=0;H<=O;H++)H===0&&L===b?A[L][H]=M:A[L][H]=M.clone().lerp(w,H/O)}for(let L=0;L<b;L++)for(let M=0;M<2*(b-L)-1;M++){const w=Math.floor(M/2);M%2===0?(f(A[L][w+1]),f(A[L+1][w]),f(A[L][w])):(f(A[L][w+1]),f(A[L+1][w+1]),f(A[L+1][w]))}}function l(y){const _=new C;for(let x=0;x<r.length;x+=3)_.x=r[x+0],_.y=r[x+1],_.z=r[x+2],_.normalize().multiplyScalar(y),r[x+0]=_.x,r[x+1]=_.y,r[x+2]=_.z}function h(){const y=new C;for(let _=0;_<r.length;_+=3){y.x=r[_+0],y.y=r[_+1],y.z=r[_+2];const x=g(y)/2/Math.PI+.5,T=m(y)/Math.PI+.5;o.push(x,1-T)}p(),u()}function u(){for(let y=0;y<o.length;y+=6){const _=o[y+0],x=o[y+2],T=o[y+4],b=Math.max(_,x,T),A=Math.min(_,x,T);b>.9&&A<.1&&(_<.2&&(o[y+0]+=1),x<.2&&(o[y+2]+=1),T<.2&&(o[y+4]+=1))}}function f(y){r.push(y.x,y.y,y.z)}function d(y,_){const x=y*3;_.x=e[x+0],_.y=e[x+1],_.z=e[x+2]}function p(){const y=new C,_=new C,x=new C,T=new C,b=new ae,A=new ae,L=new ae;for(let M=0,w=0;M<r.length;M+=9,w+=6){y.set(r[M+0],r[M+1],r[M+2]),_.set(r[M+3],r[M+4],r[M+5]),x.set(r[M+6],r[M+7],r[M+8]),b.set(o[w+0],o[w+1]),A.set(o[w+2],o[w+3]),L.set(o[w+4],o[w+5]),T.copy(y).add(_).add(x).divideScalar(3);const O=g(T);v(b,w+0,y,O),v(A,w+2,_,O),v(L,w+4,x,O)}}function v(y,_,x,T){T<0&&y.x===1&&(o[_]=y.x-1),x.x===0&&x.z===0&&(o[_]=T/2/Math.PI+.5)}function g(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ii(e.vertices,e.indices,e.radius,e.details)}}class cc extends Ii{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n,r=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(r,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new cc(e.radius,e.detail)}}const $o=new C,Qo=new C,tl=new C,ea=new tn;class jp extends Be{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const i=Math.pow(10,4),r=Math.cos(ss*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),f={},d=[];for(let p=0;p<c;p+=3){o?(l[0]=o.getX(p),l[1]=o.getX(p+1),l[2]=o.getX(p+2)):(l[0]=p,l[1]=p+1,l[2]=p+2);const{a:v,b:g,c:m}=ea;if(v.fromBufferAttribute(a,l[0]),g.fromBufferAttribute(a,l[1]),m.fromBufferAttribute(a,l[2]),ea.getNormal(tl),u[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,u[1]=`${Math.round(g.x*i)},${Math.round(g.y*i)},${Math.round(g.z*i)}`,u[2]=`${Math.round(m.x*i)},${Math.round(m.y*i)},${Math.round(m.z*i)}`,!(u[0]===u[1]||u[1]===u[2]||u[2]===u[0]))for(let y=0;y<3;y++){const _=(y+1)%3,x=u[y],T=u[_],b=ea[h[y]],A=ea[h[_]],L=`${x}_${T}`,M=`${T}_${x}`;M in f&&f[M]?(tl.dot(f[M].normal)<=r&&(d.push(b.x,b.y,b.z),d.push(A.x,A.y,A.z)),f[M]=null):L in f||(f[L]={index0:l[y],index1:l[_],normal:tl.clone()})}}for(const p in f)if(f[p]){const{index0:v,index1:g}=f[p];$o.fromBufferAttribute(a,v),Qo.fromBufferAttribute(a,g),d.push($o.x,$o.y,$o.z),d.push(Qo.x,Qo.y,Qo.z)}this.setAttribute("position",new Ee(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class os extends qr{constructor(e){super(e),this.uuid=un(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const i=e.holes[t];this.holes.push(new qr().fromJSON(i))}return this}}const NM={triangulate:function(s,e,t=2){const n=e&&e.length,i=n?e[0]*t:s.length;let r=Jp(s,0,i,t,!0);const o=[];if(!r||r.next===r.prev)return o;let a,c,l,h,u,f,d;if(n&&(r=zM(s,e,r,t)),s.length>80*t){a=l=s[0],c=h=s[1];for(let p=t;p<i;p+=t)u=s[p],f=s[p+1],u<a&&(a=u),f<c&&(c=f),u>l&&(l=u),f>h&&(h=f);d=Math.max(l-a,h-c),d=d!==0?32767/d:0}return Yr(r,o,t,a,c,d,0),o}};function Jp(s,e,t,n,i){let r,o;if(i===jM(s,e,t,n)>0)for(r=e;r<t;r+=n)o=Uf(r,s[r],s[r+1],o);else for(r=t-n;r>=e;r-=n)o=Uf(r,s[r],s[r+1],o);return o&&lc(o,o.next)&&(Kr(o),o=o.next),o}function hs(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(lc(t,t.next)||mt(t.prev,t,t.next)===0)){if(Kr(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Yr(s,e,t,n,i,r,o){if(!s)return;!o&&r&&WM(s,n,i,r);let a=s,c,l;for(;s.prev!==s.next;){if(c=s.prev,l=s.next,r?OM(s,n,i,r):DM(s)){e.push(c.i/t|0),e.push(s.i/t|0),e.push(l.i/t|0),Kr(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=BM(hs(s),e,t),Yr(s,e,t,n,i,r,2)):o===2&&FM(s,e,t,n,i,r):Yr(hs(s),e,t,n,i,r,1);break}}}function DM(s){const e=s.prev,t=s,n=s.next;if(mt(e,t,n)>=0)return!1;const i=e.x,r=t.x,o=n.x,a=e.y,c=t.y,l=n.y,h=i<r?i<o?i:o:r<o?r:o,u=a<c?a<l?a:l:c<l?c:l,f=i>r?i>o?i:o:r>o?r:o,d=a>c?a>l?a:l:c>l?c:l;let p=n.next;for(;p!==e;){if(p.x>=h&&p.x<=f&&p.y>=u&&p.y<=d&&Ws(i,a,r,c,o,l,p.x,p.y)&&mt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function OM(s,e,t,n){const i=s.prev,r=s,o=s.next;if(mt(i,r,o)>=0)return!1;const a=i.x,c=r.x,l=o.x,h=i.y,u=r.y,f=o.y,d=a<c?a<l?a:l:c<l?c:l,p=h<u?h<f?h:f:u<f?u:f,v=a>c?a>l?a:l:c>l?c:l,g=h>u?h>f?h:f:u>f?u:f,m=$l(d,p,e,t,n),y=$l(v,g,e,t,n);let _=s.prevZ,x=s.nextZ;for(;_&&_.z>=m&&x&&x.z<=y;){if(_.x>=d&&_.x<=v&&_.y>=p&&_.y<=g&&_!==i&&_!==o&&Ws(a,h,c,u,l,f,_.x,_.y)&&mt(_.prev,_,_.next)>=0||(_=_.prevZ,x.x>=d&&x.x<=v&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Ws(a,h,c,u,l,f,x.x,x.y)&&mt(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;_&&_.z>=m;){if(_.x>=d&&_.x<=v&&_.y>=p&&_.y<=g&&_!==i&&_!==o&&Ws(a,h,c,u,l,f,_.x,_.y)&&mt(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=y;){if(x.x>=d&&x.x<=v&&x.y>=p&&x.y<=g&&x!==i&&x!==o&&Ws(a,h,c,u,l,f,x.x,x.y)&&mt(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function BM(s,e,t){let n=s;do{const i=n.prev,r=n.next.next;!lc(i,r)&&$p(i,n,n.next,r)&&Zr(i,r)&&Zr(r,i)&&(e.push(i.i/t|0),e.push(n.i/t|0),e.push(r.i/t|0),Kr(n),Kr(n.next),n=s=r),n=n.next}while(n!==s);return hs(n)}function FM(s,e,t,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&YM(o,a)){let c=Qp(o,a);o=hs(o,o.next),c=hs(c,c.next),Yr(o,e,t,n,i,r,0),Yr(c,e,t,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function zM(s,e,t,n){const i=[];let r,o,a,c,l;for(r=0,o=e.length;r<o;r++)a=e[r]*n,c=r<o-1?e[r+1]*n:s.length,l=Jp(s,a,c,n,!1),l===l.next&&(l.steiner=!0),i.push(qM(l));for(i.sort(kM),r=0;r<i.length;r++)t=HM(i[r],t);return t}function kM(s,e){return s.x-e.x}function HM(s,e){const t=GM(s,e);if(!t)return e;const n=Qp(t,s);return hs(n,n.next),hs(t,t.next)}function GM(s,e){let t=e,n=-1/0,i;const r=s.x,o=s.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){const f=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>n&&(n=f,i=t.x<t.next.x?t:t.next,f===r))return i}t=t.next}while(t!==e);if(!i)return null;const a=i,c=i.x,l=i.y;let h=1/0,u;t=i;do r>=t.x&&t.x>=c&&r!==t.x&&Ws(o<l?r:n,o,c,l,o<l?n:r,o,t.x,t.y)&&(u=Math.abs(o-t.y)/(r-t.x),Zr(t,s)&&(u<h||u===h&&(t.x>i.x||t.x===i.x&&VM(i,t)))&&(i=t,h=u)),t=t.next;while(t!==a);return i}function VM(s,e){return mt(s.prev,s,e.prev)<0&&mt(e.next,s,s.next)<0}function WM(s,e,t,n){let i=s;do i.z===0&&(i.z=$l(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,XM(i)}function XM(s){let e,t,n,i,r,o,a,c,l=1;do{for(t=s,s=null,r=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(i=t,t=t.nextZ,a--):(i=n,n=n.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;t=n}r.nextZ=null,l*=2}while(o>1);return s}function $l(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function qM(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function Ws(s,e,t,n,i,r,o,a){return(i-o)*(e-a)>=(s-o)*(r-a)&&(s-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(i-o)*(n-a)}function YM(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!ZM(s,e)&&(Zr(s,e)&&Zr(e,s)&&KM(s,e)&&(mt(s.prev,s,e.prev)||mt(s,e.prev,e))||lc(s,e)&&mt(s.prev,s,s.next)>0&&mt(e.prev,e,e.next)>0)}function mt(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function lc(s,e){return s.x===e.x&&s.y===e.y}function $p(s,e,t,n){const i=na(mt(s,e,t)),r=na(mt(s,e,n)),o=na(mt(t,n,s)),a=na(mt(t,n,e));return!!(i!==r&&o!==a||i===0&&ta(s,t,e)||r===0&&ta(s,n,e)||o===0&&ta(t,s,n)||a===0&&ta(t,e,n))}function ta(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function na(s){return s>0?1:s<0?-1:0}function ZM(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&$p(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Zr(s,e){return mt(s.prev,s,s.next)<0?mt(s,e,s.next)>=0&&mt(s,s.prev,e)>=0:mt(s,e,s.prev)<0||mt(s,s.next,e)<0}function KM(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function Qp(s,e){const t=new Ql(s.i,s.x,s.y),n=new Ql(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function Uf(s,e,t,n){const i=new Ql(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Kr(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Ql(s,e,t){this.i=s,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function jM(s,e,t,n){let i=0;for(let r=e,o=t-n;r<t;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}class Hn{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r<t;i=r++)n+=e[i].x*e[r].y-e[r].x*e[i].y;return n*.5}static isClockWise(e){return Hn.area(e)<0}static triangulateShape(e,t){const n=[],i=[],r=[];Nf(e),Df(n,e);let o=e.length;t.forEach(Nf);for(let c=0;c<t.length;c++)i.push(o),o+=t[c].length,Df(n,t[c]);const a=NM.triangulate(n,i);for(let c=0;c<a.length;c+=3)r.push(a.slice(c,c+3));return r}}function Nf(s){const e=s.length;e>2&&s[e-1].equals(s[0])&&s.pop()}function Df(s,e){for(let t=0;t<e.length;t++)s.push(e[t].x),s.push(e[t].y)}class hc extends Be{constructor(e=new os([new ae(.5,.5),new ae(-.5,.5),new ae(-.5,-.5),new ae(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],r=[];for(let a=0,c=e.length;a<c;a++){const l=e[a];o(l)}this.setAttribute("position",new Ee(i,3)),this.setAttribute("uv",new Ee(r,2)),this.computeVertexNormals();function o(a){const c=[],l=t.curveSegments!==void 0?t.curveSegments:12,h=t.steps!==void 0?t.steps:1,u=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,d=t.bevelThickness!==void 0?t.bevelThickness:.2,p=t.bevelSize!==void 0?t.bevelSize:d-.1,v=t.bevelOffset!==void 0?t.bevelOffset:0,g=t.bevelSegments!==void 0?t.bevelSegments:3;const m=t.extrudePath,y=t.UVGenerator!==void 0?t.UVGenerator:JM;let _,x=!1,T,b,A,L;m&&(_=m.getSpacedPoints(h),x=!0,f=!1,T=m.computeFrenetFrames(h,!1),b=new C,A=new C,L=new C),f||(g=0,d=0,p=0,v=0);const M=a.extractPoints(l);let w=M.shape;const O=M.holes;if(!Hn.isClockWise(w)){w=w.reverse();for(let R=0,ie=O.length;R<ie;R++){const G=O[R];Hn.isClockWise(G)&&(O[R]=G.reverse())}}const K=Hn.triangulateShape(w,O),I=w;for(let R=0,ie=O.length;R<ie;R++){const G=O[R];w=w.concat(G)}function F(R,ie,G){return ie||console.error("THREE.ExtrudeGeometry: vec does not exist"),R.clone().addScaledVector(ie,G)}const k=w.length,te=K.length;function J(R,ie,G){let Q,re,Me;const me=R.x-ie.x,E=R.y-ie.y,S=G.x-R.x,z=G.y-R.y,he=me*me+E*E,ue=me*z-E*S;if(Math.abs(ue)>Number.EPSILON){const fe=Math.sqrt(he),Re=Math.sqrt(S*S+z*z),Se=ie.x-E/fe,be=ie.y+me/fe,Ue=G.x-z/Re,ke=G.y+S/Re,de=((Ue-Se)*z-(ke-be)*S)/(me*z-E*S);Q=Se+me*de-R.x,re=be+E*de-R.y;const Ze=Q*Q+re*re;if(Ze<=2)return new ae(Q,re);Me=Math.sqrt(Ze/2)}else{let fe=!1;me>Number.EPSILON?S>Number.EPSILON&&(fe=!0):me<-Number.EPSILON?S<-Number.EPSILON&&(fe=!0):Math.sign(E)===Math.sign(z)&&(fe=!0),fe?(Q=-E,re=me,Me=Math.sqrt(he)):(Q=me,re=E,Me=Math.sqrt(he/2))}return new ae(Q/Me,re/Me)}const $=[];for(let R=0,ie=I.length,G=ie-1,Q=R+1;R<ie;R++,G++,Q++)G===ie&&(G=0),Q===ie&&(Q=0),$[R]=J(I[R],I[G],I[Q]);const le=[];let ce,ge=$.concat();for(let R=0,ie=O.length;R<ie;R++){const G=O[R];ce=[];for(let Q=0,re=G.length,Me=re-1,me=Q+1;Q<re;Q++,Me++,me++)Me===re&&(Me=0),me===re&&(me=0),ce[Q]=J(G[Q],G[Me],G[me]);le.push(ce),ge=ge.concat(ce)}for(let R=0;R<g;R++){const ie=R/g,G=d*Math.cos(ie*Math.PI/2),Q=p*Math.sin(ie*Math.PI/2)+v;for(let re=0,Me=I.length;re<Me;re++){const me=F(I[re],$[re],Q);W(me.x,me.y,-G)}for(let re=0,Me=O.length;re<Me;re++){const me=O[re];ce=le[re];for(let E=0,S=me.length;E<S;E++){const z=F(me[E],ce[E],Q);W(z.x,z.y,-G)}}}const Z=p+v;for(let R=0;R<k;R++){const ie=f?F(w[R],ge[R],Z):w[R];x?(A.copy(T.normals[0]).multiplyScalar(ie.x),b.copy(T.binormals[0]).multiplyScalar(ie.y),L.copy(_[0]).add(A).add(b),W(L.x,L.y,L.z)):W(ie.x,ie.y,0)}for(let R=1;R<=h;R++)for(let ie=0;ie<k;ie++){const G=f?F(w[ie],ge[ie],Z):w[ie];x?(A.copy(T.normals[R]).multiplyScalar(G.x),b.copy(T.binormals[R]).multiplyScalar(G.y),L.copy(_[R]).add(A).add(b),W(L.x,L.y,L.z)):W(G.x,G.y,u/h*R)}for(let R=g-1;R>=0;R--){const ie=R/g,G=d*Math.cos(ie*Math.PI/2),Q=p*Math.sin(ie*Math.PI/2)+v;for(let re=0,Me=I.length;re<Me;re++){const me=F(I[re],$[re],Q);W(me.x,me.y,u+G)}for(let re=0,Me=O.length;re<Me;re++){const me=O[re];ce=le[re];for(let E=0,S=me.length;E<S;E++){const z=F(me[E],ce[E],Q);x?W(z.x,z.y+_[h-1].y,_[h-1].x+G):W(z.x,z.y,u+G)}}}U(),N();function U(){const R=i.length/3;if(f){let ie=0,G=k*ie;for(let Q=0;Q<te;Q++){const re=K[Q];q(re[2]+G,re[1]+G,re[0]+G)}ie=h+g*2,G=k*ie;for(let Q=0;Q<te;Q++){const re=K[Q];q(re[0]+G,re[1]+G,re[2]+G)}}else{for(let ie=0;ie<te;ie++){const G=K[ie];q(G[2],G[1],G[0])}for(let ie=0;ie<te;ie++){const G=K[ie];q(G[0]+k*h,G[1]+k*h,G[2]+k*h)}}n.addGroup(R,i.length/3-R,0)}function N(){const R=i.length/3;let ie=0;V(I,ie),ie+=I.length;for(let G=0,Q=O.length;G<Q;G++){const re=O[G];V(re,ie),ie+=re.length}n.addGroup(R,i.length/3-R,1)}function V(R,ie){let G=R.length;for(;--G>=0;){const Q=G;let re=G-1;re<0&&(re=R.length-1);for(let Me=0,me=h+g*2;Me<me;Me++){const E=k*Me,S=k*(Me+1),z=ie+Q+E,he=ie+re+E,ue=ie+re+S,fe=ie+Q+S;j(z,he,ue,fe)}}}function W(R,ie,G){c.push(R),c.push(ie),c.push(G)}function q(R,ie,G){Y(R),Y(ie),Y(G);const Q=i.length/3,re=y.generateTopUV(n,i,Q-3,Q-2,Q-1);oe(re[0]),oe(re[1]),oe(re[2])}function j(R,ie,G,Q){Y(R),Y(ie),Y(Q),Y(ie),Y(G),Y(Q);const re=i.length/3,Me=y.generateSideWallUV(n,i,re-6,re-3,re-2,re-1);oe(Me[0]),oe(Me[1]),oe(Me[3]),oe(Me[1]),oe(Me[2]),oe(Me[3])}function Y(R){i.push(c[R*3+0]),i.push(c[R*3+1]),i.push(c[R*3+2])}function oe(R){r.push(R.x),r.push(R.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return $M(t,n,e)}static fromJSON(e,t){const n=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];n.push(a)}const i=e.options.extrudePath;return i!==void 0&&(e.options.extrudePath=new La[i.type]().fromJSON(i)),new hc(n,e.options)}}const JM={generateTopUV:function(s,e,t,n,i){const r=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[i*3],h=e[i*3+1];return[new ae(r,o),new ae(a,c),new ae(l,h)]},generateSideWallUV:function(s,e,t,n,i,r){const o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],h=e[n*3+1],u=e[n*3+2],f=e[i*3],d=e[i*3+1],p=e[i*3+2],v=e[r*3],g=e[r*3+1],m=e[r*3+2];return Math.abs(a-h)<Math.abs(o-l)?[new ae(o,1-c),new ae(l,1-u),new ae(f,1-p),new ae(v,1-m)]:[new ae(a,1-c),new ae(h,1-u),new ae(d,1-p),new ae(g,1-m)]}};function $M(s,e,t){if(t.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){const r=s[n];t.shapes.push(r.uuid)}else t.shapes.push(s.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class uc extends Ii{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(i,r,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new uc(e.radius,e.detail)}}class lo extends Ii{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new lo(e.radius,e.detail)}}class fc extends Be{constructor(e=.5,t=1,n=32,i=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);const a=[],c=[],l=[],h=[];let u=e;const f=(t-e)/i,d=new C,p=new ae;for(let v=0;v<=i;v++){for(let g=0;g<=n;g++){const m=r+g/n*o;d.x=u*Math.cos(m),d.y=u*Math.sin(m),c.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,h.push(p.x,p.y)}u+=f}for(let v=0;v<i;v++){const g=v*(n+1);for(let m=0;m<n;m++){const y=m+g,_=y,x=y+n+1,T=y+n+2,b=y+1;a.push(_,x,b),a.push(x,T,b)}}this.setIndex(a),this.setAttribute("position",new Ee(c,3)),this.setAttribute("normal",new Ee(l,3)),this.setAttribute("uv",new Ee(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class dc extends Be{constructor(e=new os([new ae(0,.5),new ae(-.5,-.5),new ae(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],r=[],o=[];let a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let h=0;h<e.length;h++)l(e[h]),this.addGroup(a,c,h),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Ee(i,3)),this.setAttribute("normal",new Ee(r,3)),this.setAttribute("uv",new Ee(o,2));function l(h){const u=i.length/3,f=h.extractPoints(t);let d=f.shape;const p=f.holes;Hn.isClockWise(d)===!1&&(d=d.reverse());for(let g=0,m=p.length;g<m;g++){const y=p[g];Hn.isClockWise(y)===!0&&(p[g]=y.reverse())}const v=Hn.triangulateShape(d,p);for(let g=0,m=p.length;g<m;g++){const y=p[g];d=d.concat(y)}for(let g=0,m=d.length;g<m;g++){const y=d[g];i.push(y.x,y.y,0),r.push(0,0,1),o.push(y.x,y.y)}for(let g=0,m=v.length;g<m;g++){const y=v[g],_=y[0]+u,x=y[1]+u,T=y[2]+u;n.push(_,x,T),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return QM(t,e)}static fromJSON(e,t){const n=[];for(let i=0,r=e.shapes.length;i<r;i++){const o=t[e.shapes[i]];n.push(o)}return new dc(n,e.curveSegments)}}function QM(s,e){if(e.shapes=[],Array.isArray(s))for(let t=0,n=s.length;t<n;t++){const i=s[t];e.shapes.push(i.uuid)}else e.shapes.push(s.uuid);return e}class ho extends Be{constructor(e=1,t=32,n=16,i=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const c=Math.min(o+a,Math.PI);let l=0;const h=[],u=new C,f=new C,d=[],p=[],v=[],g=[];for(let m=0;m<=n;m++){const y=[],_=m/n;let x=0;m===0&&o===0?x=.5/t:m===n&&c===Math.PI&&(x=-.5/t);for(let T=0;T<=t;T++){const b=T/t;u.x=-e*Math.cos(i+b*r)*Math.sin(o+_*a),u.y=e*Math.cos(o+_*a),u.z=e*Math.sin(i+b*r)*Math.sin(o+_*a),p.push(u.x,u.y,u.z),f.copy(u).normalize(),v.push(f.x,f.y,f.z),g.push(b+x,1-_),y.push(l++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<t;y++){const _=h[m][y+1],x=h[m][y],T=h[m+1][y],b=h[m+1][y+1];(m!==0||o>0)&&d.push(_,x,b),(m!==n-1||c<Math.PI)&&d.push(x,T,b)}this.setIndex(d),this.setAttribute("position",new Ee(p,3)),this.setAttribute("normal",new Ee(v,3)),this.setAttribute("uv",new Ee(g,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ho(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class pc extends Ii{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new pc(e.radius,e.detail)}}class mc extends Be{constructor(e=1,t=.4,n=12,i=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);const o=[],a=[],c=[],l=[],h=new C,u=new C,f=new C;for(let d=0;d<=n;d++)for(let p=0;p<=i;p++){const v=p/i*r,g=d/n*Math.PI*2;u.x=(e+t*Math.cos(g))*Math.cos(v),u.y=(e+t*Math.cos(g))*Math.sin(v),u.z=t*Math.sin(g),a.push(u.x,u.y,u.z),h.x=e*Math.cos(v),h.y=e*Math.sin(v),f.subVectors(u,h).normalize(),c.push(f.x,f.y,f.z),l.push(p/i),l.push(d/n)}for(let d=1;d<=n;d++)for(let p=1;p<=i;p++){const v=(i+1)*d+p-1,g=(i+1)*(d-1)+p-1,m=(i+1)*(d-1)+p,y=(i+1)*d+p;o.push(v,g,y),o.push(g,m,y)}this.setIndex(o),this.setAttribute("position",new Ee(a,3)),this.setAttribute("normal",new Ee(c,3)),this.setAttribute("uv",new Ee(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class gc extends Be{constructor(e=1,t=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);const a=[],c=[],l=[],h=[],u=new C,f=new C,d=new C,p=new C,v=new C,g=new C,m=new C;for(let _=0;_<=n;++_){const x=_/n*r*Math.PI*2;y(x,r,o,e,d),y(x+.01,r,o,e,p),g.subVectors(p,d),m.addVectors(p,d),v.crossVectors(g,m),m.crossVectors(v,g),v.normalize(),m.normalize();for(let T=0;T<=i;++T){const b=T/i*Math.PI*2,A=-t*Math.cos(b),L=t*Math.sin(b);u.x=d.x+(A*m.x+L*v.x),u.y=d.y+(A*m.y+L*v.y),u.z=d.z+(A*m.z+L*v.z),c.push(u.x,u.y,u.z),f.subVectors(u,d).normalize(),l.push(f.x,f.y,f.z),h.push(_/n),h.push(T/i)}}for(let _=1;_<=n;_++)for(let x=1;x<=i;x++){const T=(i+1)*(_-1)+(x-1),b=(i+1)*_+(x-1),A=(i+1)*_+x,L=(i+1)*(_-1)+x;a.push(T,b,L),a.push(b,A,L)}this.setIndex(a),this.setAttribute("position",new Ee(c,3)),this.setAttribute("normal",new Ee(l,3)),this.setAttribute("uv",new Ee(h,2));function y(_,x,T,b,A){const L=Math.cos(_),M=Math.sin(_),w=T/x*_,O=Math.cos(w);A.x=b*(2+O)*.5*L,A.y=b*(2+O)*M*.5,A.z=b*Math.sin(w)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gc(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class vc extends Be{constructor(e=new Vh(new C(-1,-1,0),new C(-1,1,0),new C(1,1,0)),t=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:r};const o=e.computeFrenetFrames(t,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;const a=new C,c=new C,l=new ae;let h=new C;const u=[],f=[],d=[],p=[];v(),this.setIndex(p),this.setAttribute("position",new Ee(u,3)),this.setAttribute("normal",new Ee(f,3)),this.setAttribute("uv",new Ee(d,2));function v(){for(let _=0;_<t;_++)g(_);g(r===!1?t:0),y(),m()}function g(_){h=e.getPointAt(_/t,h);const x=o.normals[_],T=o.binormals[_];for(let b=0;b<=i;b++){const A=b/i*Math.PI*2,L=Math.sin(A),M=-Math.cos(A);c.x=M*x.x+L*T.x,c.y=M*x.y+L*T.y,c.z=M*x.z+L*T.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=h.x+n*c.x,a.y=h.y+n*c.y,a.z=h.z+n*c.z,u.push(a.x,a.y,a.z)}}function m(){for(let _=1;_<=t;_++)for(let x=1;x<=i;x++){const T=(i+1)*(_-1)+(x-1),b=(i+1)*_+(x-1),A=(i+1)*_+x,L=(i+1)*(_-1)+x;p.push(T,b,L),p.push(b,A,L)}}function y(){for(let _=0;_<=t;_++)for(let x=0;x<=i;x++)l.x=_/t,l.y=x/i,d.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new vc(new La[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Xh extends Be{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,i=new C,r=new C;if(e.index!==null){const o=e.attributes.position,a=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,h=c.length;l<h;++l){const u=c[l],f=u.start,d=u.count;for(let p=f,v=f+d;p<v;p+=3)for(let g=0;g<3;g++){const m=a.getX(p+g),y=a.getX(p+(g+1)%3);i.fromBufferAttribute(o,m),r.fromBufferAttribute(o,y),Of(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}}else{const o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){const h=3*a+l,u=3*a+(l+1)%3;i.fromBufferAttribute(o,h),r.fromBufferAttribute(o,u),Of(i,r,n)===!0&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new Ee(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Of(s,e,t){const n=`${s.x},${s.y},${s.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${s.x},${s.y},${s.z}`;return t.has(n)===!0||t.has(i)===!0?!1:(t.add(n),t.add(i),!0)}var Bf=Object.freeze({__proto__:null,BoxGeometry:ps,CapsuleGeometry:rc,CircleGeometry:oc,ConeGeometry:ac,CylinderGeometry:or,DodecahedronGeometry:cc,EdgesGeometry:jp,ExtrudeGeometry:hc,IcosahedronGeometry:uc,LatheGeometry:co,OctahedronGeometry:lo,PlaneGeometry:ro,PolyhedronGeometry:Ii,RingGeometry:fc,ShapeGeometry:dc,SphereGeometry:ho,TetrahedronGeometry:pc,TorusGeometry:mc,TorusKnotGeometry:gc,TubeGeometry:vc,WireframeGeometry:Xh});class em extends Et{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Te(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class tm extends Ln{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ar extends Et{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Te(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Te(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pi,this.normalScale=new ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Un extends ar{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ae(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Te(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Te(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Te(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Xs extends Et{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Te(16777215),this.specular=new Te(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Te(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pi,this.normalScale=new ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=eo,this.reflectivity=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.specular.copy(e.specular),this.shininess=e.shininess,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.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.flatShading=e.flatShading,this.fog=e.fog,this}}class nm extends Et{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Te(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Te(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pi,this.normalScale=new ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=e.gradientMap,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.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class im extends Et{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pi,this.normalScale=new ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),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.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class sm extends Et{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Te(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Te(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pi,this.normalScale=new ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=eo,this.reflectivity=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.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.flatShading=e.flatShading,this.fog=e.fog,this}}class rm extends Et{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Te(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pi,this.normalScale=new ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,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.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class om extends Xt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function ns(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function am(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function cm(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function eh(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){const a=t[r]*e;for(let c=0;c!==e;++c)i[o++]=s[a+c]}return i}function qh(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)}function eS(s,e,t,n,i=30){const r=s.clone();r.name=e;const o=[];for(let c=0;c<r.tracks.length;++c){const l=r.tracks[c],h=l.getValueSize(),u=[],f=[];for(let d=0;d<l.times.length;++d){const p=l.times[d]*i;if(!(p<t||p>=n)){u.push(l.times[d]);for(let v=0;v<h;++v)f.push(l.values[d*h+v])}}u.length!==0&&(l.times=ns(u,l.times.constructor),l.values=ns(f,l.values.constructor),o.push(l))}r.tracks=o;let a=1/0;for(let c=0;c<r.tracks.length;++c)a>r.tracks[c].times[0]&&(a=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*a);return r.resetDuration(),r}function tS(s,e=0,t=s,n=30){n<=0&&(n=30);const i=t.tracks.length,r=e/n;for(let o=0;o<i;++o){const a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;const l=s.tracks.find(function(m){return m.name===a.name&&m.ValueTypeName===c});if(l===void 0)continue;let h=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let f=0;const d=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=d/3);const p=a.times.length-1;let v;if(r<=a.times[0]){const m=h,y=u-h;v=a.values.slice(m,y)}else if(r>=a.times[p]){const m=p*u+h,y=m+u-h;v=a.values.slice(m,y)}else{const m=a.createInterpolant(),y=h,_=u-h;m.evaluate(r),v=m.resultBuffer.slice(y,_)}c==="quaternion"&&new Ot().fromArray(v).normalize().conjugate().toArray(v);const g=l.times.length;for(let m=0;m<g;++m){const y=m*d+f;if(c==="quaternion")Ot.multiplyQuaternionsFlat(l.values,y,v,0,l.values,y);else{const _=d-f*2;for(let x=0;x<_;++x)l.values[y+x]-=v[x]}}}return s.blendMode=Mh,s}const nS={convertArray:ns,isTypedArray:am,getKeyframeOrder:cm,sortedArray:eh,flattenJSON:qh,subclip:eS,makeClipAdditive:tS};class cr{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=r)){const 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(i=r,r=t[--n-1],e>=r)break t}o=n,n=0;break n}break e}for(;n<o;){const a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let o=0;o!==i;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class lm extends cr{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Qi,endingEnd:Qi}}intervalChanged_(e,t,n){const i=this.parameterPositions;let r=e-2,o=e+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case es:r=e,a=2*t-n;break;case kr:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case es:o=e,c=2*n-t;break;case kr:o=1,c=n+i[1]-i[0];break;default:o=e-1,c=t}const 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,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this._offsetPrev,u=this._offsetNext,f=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),v=p*p,g=v*p,m=-f*g+2*f*v-f*p,y=(1+f)*g+(-1.5-2*f)*v+(-.5+f)*p+1,_=(-1-d)*g+(1.5+d)*v+.5*p,x=d*g-d*v;for(let T=0;T!==a;++T)r[T]=m*o[h+T]+y*o[l+T]+_*o[c+T]+x*o[u+T];return r}}class Yh extends cr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=(n-t)/(i-t),u=1-h;for(let f=0;f!==a;++f)r[f]=o[l+f]*u+o[c+f]*h;return r}}class hm extends cr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}class Nn{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ns(t,this.TimeBufferType),this.values=ns(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:ns(e.times,Array),values:ns(e.values,Array)};const i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new hm(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Yh(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new lm(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case js:t=this.InterpolantFactoryMethodDiscrete;break;case ls:t=this.InterpolantFactoryMethodLinear;break;case xa:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return js;case this.InterpolantFactoryMethodLinear:return ls;case this.InterpolantFactoryMethodSmooth:return xa}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(i!==void 0&&am(i))for(let a=0,c=i.length;a!==c;++a){const l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===xa,r=e.length-1;let o=1;for(let a=1;a<r;++a){let c=!1;const l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(i)c=!0;else{const u=a*n,f=u-n,d=u+n;for(let p=0;p!==n;++p){const v=t[u+p];if(v!==t[f+p]||v!==t[d+p]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];const u=a*n,f=o*n;for(let d=0;d!==n;++d)t[f+d]=t[u+d]}++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(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Nn.prototype.TimeBufferType=Float32Array;Nn.prototype.ValueBufferType=Float32Array;Nn.prototype.DefaultInterpolation=ls;class ms extends Nn{}ms.prototype.ValueTypeName="bool";ms.prototype.ValueBufferType=Array;ms.prototype.DefaultInterpolation=js;ms.prototype.InterpolantFactoryMethodLinear=void 0;ms.prototype.InterpolantFactoryMethodSmooth=void 0;class Zh extends Nn{}Zh.prototype.ValueTypeName="color";class us extends Nn{}us.prototype.ValueTypeName="number";class um extends cr{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t);let l=e*a;for(let h=l+a;l!==h;l+=4)Ot.slerpFlat(r,0,o,l-a,o,l,c);return r}}class Ci extends Nn{InterpolantFactoryMethodLinear(e){return new um(this.times,this.values,this.getValueSize(),e)}}Ci.prototype.ValueTypeName="quaternion";Ci.prototype.DefaultInterpolation=ls;Ci.prototype.InterpolantFactoryMethodSmooth=void 0;class gs extends Nn{}gs.prototype.ValueTypeName="string";gs.prototype.ValueBufferType=Array;gs.prototype.DefaultInterpolation=js;gs.prototype.InterpolantFactoryMethodLinear=void 0;gs.prototype.InterpolantFactoryMethodSmooth=void 0;class fs extends Nn{}fs.prototype.ValueTypeName="vector";class er{constructor(e,t=-1,n,i=Xa){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=un(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(sS(n[o]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(Nn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);const h=cm(c);c=eh(c,1,h),l=eh(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new us(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){const l=e[a],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let f=i[u];f||(i[u]=f=[]),f.push(l)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,f,d,p,v){if(d.length!==0){const g=[],m=[];qh(d,g,m,p),g.length!==0&&v.push(new u(f,g,m))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let c=e.length||-1;const l=e.hierarchy||[];for(let u=0;u<l.length;u++){const f=l[u].keys;if(!(!f||f.length===0))if(f[0].morphTargets){const d={};let p;for(p=0;p<f.length;p++)if(f[p].morphTargets)for(let v=0;v<f[p].morphTargets.length;v++)d[f[p].morphTargets[v]]=-1;for(const v in d){const g=[],m=[];for(let y=0;y!==f[p].morphTargets.length;++y){const _=f[p];g.push(_.time),m.push(_.morphTarget===v?1:0)}i.push(new us(".morphTargetInfluence["+v+"]",g,m))}c=d.length*o}else{const d=".bones["+t[u].name+"]";n(fs,d+".position",f,"pos",i),n(Ci,d+".quaternion",f,"rot",i),n(fs,d+".scale",f,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,i=e.length;n!==i;++n){const r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function iS(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return us;case"vector":case"vector2":case"vector3":case"vector4":return fs;case"color":return Zh;case"quaternion":return Ci;case"bool":case"boolean":return ms;case"string":return gs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function sS(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=iS(s.type);if(s.times===void 0){const t=[],n=[];qh(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}const ti={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};class Kh{constructor(e,t,n){const i=this;let r=!1,o=0,a=0,c;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,r===!1&&i.onStart!==void 0&&i.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,f=l.length;u<f;u+=2){const d=l[u],p=l[u+1];if(d.global&&(d.lastIndex=0),d.test(h))return p}return null}}}const fm=new Kh;class Bt{constructor(e){this.manager=e!==void 0?e:fm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}Bt.DEFAULT_MATERIAL_NAME="__DEFAULT";const Jn={};class rS extends Error{constructor(e,t){super(e),this.response=t}}class fn extends Bt{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=ti.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(Jn[e]!==void 0){Jn[e].push({onLoad:t,onProgress:n,onError:i});return}Jn[e]=[],Jn[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=Jn[e],u=l.body.getReader(),f=l.headers.get("Content-Length")||l.headers.get("X-File-Size"),d=f?parseInt(f):0,p=d!==0;let v=0;const g=new ReadableStream({start(m){y();function y(){u.read().then(({done:_,value:x})=>{if(_)m.close();else{v+=x.byteLength;const T=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:d});for(let b=0,A=h.length;b<A;b++){const L=h[b];L.onProgress&&L.onProgress(T)}m.enqueue(x),y()}})}}});return new Response(g)}else throw new rS(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),f=u&&u[1]?u[1].toLowerCase():void 0,d=new TextDecoder(f);return l.arrayBuffer().then(p=>d.decode(p))}}}).then(l=>{ti.add(e,l);const h=Jn[e];delete Jn[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onLoad&&d.onLoad(l)}}).catch(l=>{const h=Jn[e];if(h===void 0)throw this.manager.itemError(e),l;delete Jn[e];for(let u=0,f=h.length;u<f;u++){const d=h[u];d.onError&&d.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class oS extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new fn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=er.parse(e[n]);t.push(i)}return t}}class aS extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=[],a=new ic,c=new fn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(r.withCredentials);let l=0;function h(u){c.load(e[u],function(f){const d=r.parse(f,!0);o[u]={width:d.width,height:d.height,format:d.format,mipmaps:d.mipmaps},l+=1,l===6&&(d.mipmapCount===1&&(a.minFilter=at),a.image=o,a.format=d.format,a.needsUpdate=!0,t&&t(a))},n,i)}if(Array.isArray(e))for(let u=0,f=e.length;u<f;++u)h(u);else c.load(e,function(u){const f=r.parse(u,!0);if(f.isCubemap){const d=f.mipmaps.length/f.mipmapCount;for(let p=0;p<d;p++){o[p]={mipmaps:[]};for(let v=0;v<f.mipmapCount;v++)o[p].mipmaps.push(f.mipmaps[p*f.mipmapCount+v]),o[p].format=f.format,o[p].width=f.width,o[p].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=at),a.format=f.format,a.needsUpdate=!0,t&&t(a)},n,i);return a}}class jr extends Bt{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=ti.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;const a=Xr("img");function c(){h(),ti.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(u){h(),i&&i(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class cS extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=new io;r.colorSpace=ht;const o=new jr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(h){r.images[l]=h,a++,a===6&&(r.needsUpdate=!0,t&&t(r))},void 0,i)}for(let l=0;l<e.length;++l)c(l);return r}}class lS extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new rs,a=new fn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(e,function(c){let l;try{l=r.parse(c)}catch(h){if(i!==void 0)i(h);else{console.error(h);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:At,o.wrapT=l.wrapT!==void 0?l.wrapT:At,o.magFilter=l.magFilter!==void 0?l.magFilter:at,o.minFilter=l.minFilter!==void 0?l.minFilter:at,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0?o.colorSpace=l.colorSpace:l.encoding!==void 0&&(o.encoding=l.encoding),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Mn),l.mipmapCount===1&&(o.minFilter=at),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},n,i),o}}class jh extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=new gt,o=new jr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}}class Ui extends tt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Te(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}class dm extends Ui{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Te(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const nl=new Ne,Ff=new C,zf=new C;class Jh{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ae(512,512),this.map=null,this.mapPass=null,this.matrix=new Ne,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new so,this._frameExtents=new ae(1,1),this._viewportCount=1,this._viewports=[new nt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Ff.setFromMatrixPosition(e.matrixWorld),t.position.copy(Ff),zf.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zf),t.updateMatrixWorld(),nl.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(nl),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(nl)}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.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class hS extends Jh{constructor(){super(new Nt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=$s*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class $h extends Ui{constructor(e,t,n=0,i=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.target=new tt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new hS}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const kf=new Ne,Rr=new C,il=new C;class uS extends Jh{constructor(){super(new Nt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new ae(4,2),this._viewportCount=6,this._viewports=[new nt(2,1,1,1),new nt(0,1,1,1),new nt(3,1,1,1),new nt(1,1,1,1),new nt(3,0,1,1),new nt(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Rr.setFromMatrixPosition(e.matrixWorld),n.position.copy(Rr),il.copy(n.position),il.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(il),n.updateMatrixWorld(),i.makeTranslation(-Rr.x,-Rr.y,-Rr.z),kf.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(kf)}}class Qh extends Ui{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new uS}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class fS extends Jh{constructor(){super(new oo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class eu extends Ui{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(tt.DEFAULT_UP),this.updateMatrix(),this.target=new tt,this.shadow=new fS}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class pm extends Ui{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class mm extends Ui{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class gm{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new C)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*i),t.addScaledVector(o[2],.488603*r),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*i)),t.addScaledVector(o[5],1.092548*(i*r)),t.addScaledVector(o[6],.315392*(3*r*r-1)),t.addScaledVector(o[7],1.092548*(n*r)),t.addScaledVector(o[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*i),t.addScaledVector(o[2],2*.511664*r),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*i),t.addScaledVector(o[5],2*.429043*i*r),t.addScaledVector(o[6],.743125*r*r-.247708),t.addScaledVector(o[7],2*.429043*n*r),t.addScaledVector(o[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+i*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+i*3);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class vm extends Ui{constructor(e=new gm,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class _c extends Bt{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,o=new fn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t=this.textures;function n(r){return t[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),t[r]}const i=_c.createMaterialFromType(e.type);if(e.uuid!==void 0&&(i.uuid=e.uuid),e.name!==void 0&&(i.name=e.name),e.color!==void 0&&i.color!==void 0&&i.color.setHex(e.color),e.roughness!==void 0&&(i.roughness=e.roughness),e.metalness!==void 0&&(i.metalness=e.metalness),e.sheen!==void 0&&(i.sheen=e.sheen),e.sheenColor!==void 0&&(i.sheenColor=new Te().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(i.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(e.emissive),e.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(e.specular),e.specularIntensity!==void 0&&(i.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(i.shininess=e.shininess),e.clearcoat!==void 0&&(i.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(i.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(i.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(i.transmission=e.transmission),e.thickness!==void 0&&(i.thickness=e.thickness),e.attenuationDistance!==void 0&&(i.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(i.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(i.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(i.fog=e.fog),e.flatShading!==void 0&&(i.flatShading=e.flatShading),e.blending!==void 0&&(i.blending=e.blending),e.combine!==void 0&&(i.combine=e.combine),e.side!==void 0&&(i.side=e.side),e.shadowSide!==void 0&&(i.shadowSide=e.shadowSide),e.opacity!==void 0&&(i.opacity=e.opacity),e.transparent!==void 0&&(i.transparent=e.transparent),e.alphaTest!==void 0&&(i.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(i.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(i.depthFunc=e.depthFunc),e.depthTest!==void 0&&(i.depthTest=e.depthTest),e.depthWrite!==void 0&&(i.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(i.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(i.blendSrc=e.blendSrc),e.blendDst!==void 0&&(i.blendDst=e.blendDst),e.blendEquation!==void 0&&(i.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(i.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(i.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(i.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(i.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(i.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(i.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(i.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(i.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(i.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(i.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(i.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(i.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(i.rotation=e.rotation),e.linewidth!==void 0&&(i.linewidth=e.linewidth),e.dashSize!==void 0&&(i.dashSize=e.dashSize),e.gapSize!==void 0&&(i.gapSize=e.gapSize),e.scale!==void 0&&(i.scale=e.scale),e.polygonOffset!==void 0&&(i.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(i.dithering=e.dithering),e.alphaToCoverage!==void 0&&(i.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(i.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(i.visible=e.visible),e.toneMapped!==void 0&&(i.toneMapped=e.toneMapped),e.userData!==void 0&&(i.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new Te().setHex(o.value);break;case"v2":i.uniforms[r].value=new ae().fromArray(o.value);break;case"v3":i.uniforms[r].value=new C().fromArray(o.value);break;case"v4":i.uniforms[r].value=new nt().fromArray(o.value);break;case"m3":i.uniforms[r].value=new Xe().fromArray(o.value);break;case"m4":i.uniforms[r].value=new Ne().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)i.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new ae().fromArray(r)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new ae().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:em,SpriteMaterial:Nh,RawShaderMaterial:tm,ShaderMaterial:Ln,PointsMaterial:nc,MeshPhysicalMaterial:Un,MeshStandardMaterial:ar,MeshPhongMaterial:Xs,MeshToonMaterial:nm,MeshNormalMaterial:im,MeshLambertMaterial:sm,MeshDepthMaterial:Ih,MeshDistanceMaterial:Uh,MeshBasicMaterial:hn,MeshMatcapMaterial:rm,LineDashedMaterial:om,LineBasicMaterial:Xt,Material:Et};return new t[e]}}class wi{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class tu extends Be{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class _m extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new fn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(d,p){if(t[p]!==void 0)return t[p];const g=d.interleavedBuffers[p],m=r(d,g.buffer),y=Hs(g.type,m),_=new rr(y,g.stride);return _.uuid=g.uuid,t[p]=_,_}function r(d,p){if(n[p]!==void 0)return n[p];const g=d.arrayBuffers[p],m=new Uint32Array(g).buffer;return n[p]=m,m}const o=e.isInstancedBufferGeometry?new tu:new Be,a=e.data.index;if(a!==void 0){const d=Hs(a.type,a.array);o.setIndex(new Fe(d,1))}const c=e.data.attributes;for(const d in c){const p=c[d];let v;if(p.isInterleavedBufferAttribute){const g=i(e.data,p.data);v=new $t(g,p.itemSize,p.offset,p.normalized)}else{const g=Hs(p.type,p.array),m=p.isInstancedBufferAttribute?ai:Fe;v=new m(g,p.itemSize,p.normalized)}p.name!==void 0&&(v.name=p.name),p.usage!==void 0&&v.setUsage(p.usage),o.setAttribute(d,v)}const l=e.data.morphAttributes;if(l)for(const d in l){const p=l[d],v=[];for(let g=0,m=p.length;g<m;g++){const y=p[g];let _;if(y.isInterleavedBufferAttribute){const x=i(e.data,y.data);_=new $t(x,y.itemSize,y.offset,y.normalized)}else{const x=Hs(y.type,y.array);_=new Fe(x,y.itemSize,y.normalized)}y.name!==void 0&&(_.name=y.name),v.push(_)}o.morphAttributes[d]=v}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const u=e.data.groups||e.data.drawcalls||e.data.offsets;if(u!==void 0)for(let d=0,p=u.length;d!==p;++d){const v=u[d];o.addGroup(v.start,v.count,v.materialIndex)}const f=e.data.boundingSphere;if(f!==void 0){const d=new C;f.center!==void 0&&d.fromArray(f.center),o.boundingSphere=new Tt(d,f.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}class dS extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=this.path===""?wi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;const a=new fn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(u){i!==void 0&&i(u),console.error("THREE:ObjectLoader: Can't parse "+e+".",u.message);return}const h=l.metadata;if(h===void 0||h.type===void 0||h.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}r.parse(l,t)},n,i)}async loadAsync(e,t){const n=this,i=this.path===""?wi.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;const r=new fn(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);const o=await r.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,i),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,r,c,a,n),h=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,h),t!==void 0){let u=!1;for(const f in o)if(o[f].data instanceof HTMLImageElement){u=!0;break}u===!1&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),r=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,r),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,i,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),c}parseShapes(e){const t={};if(e!==void 0)for(let n=0,i=e.length;n<i;n++){const r=new os().fromJSON(e[n]);t[r.uuid]=r}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse(function(r){r.isBone&&(i[r.uuid]=r)}),e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=new ao().fromJSON(e[r],i);n[a.uuid]=a}return n}parseGeometries(e,t){const n={};if(e!==void 0){const i=new _m;for(let r=0,o=e.length;r<o;r++){let a;const c=e[r];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(c);break;default:c.type in Bf?a=Bf[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(e,t){const n={},i={};if(e!==void 0){const r=new _c;r.setTextures(t);for(let o=0,a=e.length;o<a;o++){const c=e[o];n[c.uuid]===void 0&&(n[c.uuid]=r.parse(c)),i[c.uuid]=n[c.uuid]}}return i}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const i=e[n],r=er.parse(i);t[r.uuid]=r}return t}parseImages(e,t){const n=this,i={};let r;function o(c){return n.manager.itemStart(c),r.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){const l=c,h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(h)}else return c.data?{data:Hs(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){const c=new Kh(t);r=new jr(c),r.setCrossOrigin(this.crossOrigin);for(let l=0,h=e.length;l<h;l++){const u=e[l],f=u.url;if(Array.isArray(f)){const d=[];for(let p=0,v=f.length;p<v;p++){const g=f[p],m=a(g);m!==null&&(m instanceof HTMLImageElement?d.push(m):d.push(new rs(m.data,m.width,m.height)))}i[u.uuid]=new ts(d)}else{const d=a(u.url);i[u.uuid]=new ts(d)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function r(o){if(typeof o=="string"){const a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await i.loadAsync(c)}else return o.data?{data:Hs(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){i=new jr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){const c=e[o],l=c.url;if(Array.isArray(l)){const h=[];for(let u=0,f=l.length;u<f;u++){const d=l[u],p=await r(d);p!==null&&(p instanceof HTMLImageElement?h.push(p):h.push(new rs(p.data,p.width,p.height)))}n[c.uuid]=new ts(h)}else{const h=await r(c.url);n[c.uuid]=new ts(h)}}}return n}parseTextures(e,t){function n(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}const i={};if(e!==void 0)for(let r=0,o=e.length;r<o;r++){const a=e[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);const c=t[a.image],l=c.data;let h;Array.isArray(l)?(h=new io,l.length===6&&(h.needsUpdate=!0)):(l&&l.data?h=new rs:h=new gt,l&&(h.needsUpdate=!0)),h.source=c,h.uuid=a.uuid,a.name!==void 0&&(h.name=a.name),a.mapping!==void 0&&(h.mapping=n(a.mapping,pS)),a.channel!==void 0&&(h.channel=a.channel),a.offset!==void 0&&h.offset.fromArray(a.offset),a.repeat!==void 0&&h.repeat.fromArray(a.repeat),a.center!==void 0&&h.center.fromArray(a.center),a.rotation!==void 0&&(h.rotation=a.rotation),a.wrap!==void 0&&(h.wrapS=n(a.wrap[0],Hf),h.wrapT=n(a.wrap[1],Hf)),a.format!==void 0&&(h.format=a.format),a.internalFormat!==void 0&&(h.internalFormat=a.internalFormat),a.type!==void 0&&(h.type=a.type),a.colorSpace!==void 0&&(h.colorSpace=a.colorSpace),a.encoding!==void 0&&(h.encoding=a.encoding),a.minFilter!==void 0&&(h.minFilter=n(a.minFilter,Gf)),a.magFilter!==void 0&&(h.magFilter=n(a.magFilter,Gf)),a.anisotropy!==void 0&&(h.anisotropy=a.anisotropy),a.flipY!==void 0&&(h.flipY=a.flipY),a.generateMipmaps!==void 0&&(h.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(h.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(h.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(h.compareFunction=a.compareFunction),a.userData!==void 0&&(h.userData=a.userData),i[a.uuid]=h}return i}parseObject(e,t,n,i,r){let o;function a(f){return t[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),t[f]}function c(f){if(f!==void 0){if(Array.isArray(f)){const d=[];for(let p=0,v=f.length;p<v;p++){const g=f[p];n[g]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",g),d.push(n[g])}return d}return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),n[f]}}function l(f){return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),i[f]}let h,u;switch(e.type){case"Scene":o=new kp,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Te(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new ec(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Qa(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":o=new Nt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new oo(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new pm(e.color,e.intensity);break;case"DirectionalLight":o=new eu(e.color,e.intensity);break;case"PointLight":o=new Qh(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new mm(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new $h(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":o=new dm(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new vm().fromJSON(e);break;case"SkinnedMesh":h=a(e.geometry),u=c(e.material),o=new Dh(h,u),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":h=a(e.geometry),u=c(e.material),o=new ft(h,u);break;case"InstancedMesh":h=a(e.geometry),u=c(e.material);const f=e.count,d=e.instanceMatrix,p=e.instanceColor;o=new Oh(h,u,f),o.instanceMatrix=new ai(new Float32Array(d.array),16),p!==void 0&&(o.instanceColor=new ai(new Float32Array(p.array),p.itemSize));break;case"BatchedMesh":h=a(e.geometry),u=c(e.material),o=new Wp(e.maxGeometryCount,e.maxVertexCount,e.maxIndexCount,u),o.geometry=h,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(v=>{const g=new wt;g.min.fromArray(v.boxMin),g.max.fromArray(v.boxMax);const m=new Tt;return m.radius=v.sphereRadius,m.center.fromArray(v.sphereCenter),{boxInitialized:v.boxInitialized,box:g,sphereInitialized:v.sphereInitialized,sphere:m}}),o._maxGeometryCount=e.maxGeometryCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid);break;case"LOD":o=new Vp;break;case"Line":o=new ci(a(e.geometry),c(e.material));break;case"LineLoop":o=new Bh(a(e.geometry),c(e.material));break;case"LineSegments":o=new Pn(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new Fh(a(e.geometry),c(e.material));break;case"Sprite":o=new Gp(c(e.material));break;case"Group":o=new _n;break;case"Bone":o=new tc;break;default:o=new tt}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const f=e.children;for(let d=0;d<f.length;d++)o.add(this.parseObject(f[d],t,n,i,r))}if(e.animations!==void 0){const f=e.animations;for(let d=0;d<f.length;d++){const p=f[d];o.animations.push(r[p])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);const f=e.levels;for(let d=0;d<f.length;d++){const p=f[d],v=o.getObjectByProperty("uuid",p.object);v!==void 0&&o.addLevel(v,p.distance,p.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const i=t[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}}const pS={UVMapping:Ga,CubeReflectionMapping:oi,CubeRefractionMapping:Ei,EquirectangularReflectionMapping:Br,EquirectangularRefractionMapping:Fr,CubeUVReflectionMapping:ir},Hf={RepeatWrapping:vn,ClampToEdgeWrapping:At,MirroredRepeatWrapping:Ri},Gf={NearestFilter:dt,NearestMipmapNearestFilter:zr,NearestMipmapLinearFilter:qs,LinearFilter:at,LinearMipmapNearestFilter:Va,LinearMipmapLinearFilter:Mn};class ym extends Bt{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=ti.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),r.manager.itemEnd(e)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return ti.add(e,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){i&&i(l),ti.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});ti.add(e,c),r.manager.itemStart(e)}}let ia;class nu{static getContext(){return ia===void 0&&(ia=new(window.AudioContext||window.webkitAudioContext)),ia}static setContext(e){ia=e}}class mS extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new fn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{const l=c.slice(0);nu.getContext().decodeAudioData(l,function(u){t(u)}).catch(a)}catch(l){a(l)}},n,i);function a(c){i?i(c):console.error(c),r.manager.itemError(e)}}}const Vf=new Ne,Wf=new Ne,Gi=new Ne;class gS{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Nt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Nt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Gi.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,o=t.near*Math.tan(ss*t.fov*.5)/t.zoom;let a,c;Wf.elements[12]=-i,Vf.elements[12]=i,a=-o*t.aspect+r,c=o*t.aspect+r,Gi.elements[0]=2*t.near/(c-a),Gi.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Gi),a=-o*t.aspect-r,c=o*t.aspect-r,Gi.elements[0]=2*t.near/(c-a),Gi.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Gi)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Wf),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Vf)}}class xm{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Xf(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=Xf();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Xf(){return(typeof performance>"u"?Date:performance).now()}const Vi=new C,qf=new Ot,vS=new C,Wi=new C;class _S extends tt{constructor(){super(),this.type="AudioListener",this.context=nu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new xm}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Vi,qf,vS),Wi.set(0,0,-1).applyQuaternion(qf),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Vi.x,i),t.positionY.linearRampToValueAtTime(Vi.y,i),t.positionZ.linearRampToValueAtTime(Vi.z,i),t.forwardX.linearRampToValueAtTime(Wi.x,i),t.forwardY.linearRampToValueAtTime(Wi.y,i),t.forwardZ.linearRampToValueAtTime(Wi.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(Vi.x,Vi.y,Vi.z),t.setOrientation(Wi.x,Wi.y,Wi.z,n.x,n.y,n.z)}}class Mm extends tt{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Xi=new C,Yf=new Ot,yS=new C,qi=new C;class xS extends Mm{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Xi,Yf,yS),qi.set(0,0,1).applyQuaternion(Yf);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Xi.x,n),t.positionY.linearRampToValueAtTime(Xi.y,n),t.positionZ.linearRampToValueAtTime(Xi.z,n),t.orientationX.linearRampToValueAtTime(qi.x,n),t.orientationY.linearRampToValueAtTime(qi.y,n),t.orientationZ.linearRampToValueAtTime(qi.z,n)}else t.setPosition(Xi.x,Xi.y,Xi.z),t.setOrientation(qi.x,qi.y,qi.z)}}class MS{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class Sm{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,o;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,r=e*i+i;let o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=t}else{o+=t;const a=t/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){const c=t*this._origIndex;this._mixBufferRegion(n,i,c,1-r,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,o=i;r!==o;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){Ot.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const o=this._workIndex*r;Ot.multiplyQuaternionsFlat(e,o,e,t,e,n),Ot.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const c=t+a;e[c]=e[c]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const iu="\\[\\]\\.:\\/",SS=new RegExp("["+iu+"]","g"),su="[^"+iu+"]",bS="[^"+iu.replace("\\.","")+"]",AS=/((?:WC+[\/:])*)/.source.replace("WC",su),wS=/(WCOD+)?/.source.replace("WCOD",bS),TS=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",su),ES=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",su),RS=new RegExp("^"+AS+wS+TS+ES+"$"),CS=["material","materials","bones","map"];class LS{constructor(e,t,n){const i=n||et.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class et{constructor(e,t,n){this.path=t,this.parsedPath=n||et.parseTrackName(t),this.node=et.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 et.Composite(e,t,n):new et(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(SS,"")}static parseTrackName(e){const t=RS.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);CS.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let o=0;o<r.length;o++){const a=r[o];if(a.name===t||a.uuid===t)return a;const c=n(a.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let r=t.propertyIndex;if(e||(e=et.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.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){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}const o=e[i];if(o===void 0){const l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.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=i;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}}et.Composite=LS;et.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};et.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};et.prototype.GetterByBindingType=[et.prototype._getValue_direct,et.prototype._getValue_array,et.prototype._getValue_arrayElement,et.prototype._getValue_toArray];et.prototype.SetterByBindingTypeAndVersioning=[[et.prototype._setValue_direct,et.prototype._setValue_direct_setNeedsUpdate,et.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[et.prototype._setValue_array,et.prototype._setValue_array_setNeedsUpdate,et.prototype._setValue_array_setMatrixWorldNeedsUpdate],[et.prototype._setValue_arrayElement,et.prototype._setValue_arrayElement_setNeedsUpdate,et.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[et.prototype._setValue_fromArray,et.prototype._setValue_fromArray_setNeedsUpdate,et.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class PS{constructor(){this.isAnimationObjectGroup=!0,this.uuid=un(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,i=arguments.length;n!==i;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length;let a,c=e.length,l=this.nCachedObjects_;for(let h=0,u=arguments.length;h!==u;++h){const f=arguments[h],d=f.uuid;let p=t[d];if(p===void 0){p=c++,t[d]=p,e.push(f);for(let v=0,g=o;v!==g;++v)r[v].push(new et(f,n[v],i[v]))}else if(p<l){a=e[p];const v=--l,g=e[v];t[g.uuid]=p,e[p]=g,t[d]=v,e[v]=f;for(let m=0,y=o;m!==y;++m){const _=r[m],x=_[v];let T=_[p];_[p]=x,T===void 0&&(T=new et(f,n[m],i[m])),_[v]=T}}else e[p]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){const c=arguments[o],l=c.uuid,h=t[l];if(h!==void 0&&h>=r){const u=r++,f=e[u];t[f.uuid]=h,e[h]=f,t[l]=u,e[u]=c;for(let d=0,p=i;d!==p;++d){const v=n[d],g=v[u],m=v[h];v[h]=g,v[u]=m}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){const l=arguments[a],h=l.uuid,u=t[h];if(u!==void 0)if(delete t[h],u<r){const f=--r,d=e[f],p=--o,v=e[p];t[d.uuid]=u,e[u]=d,t[v.uuid]=f,e[f]=v,e.pop();for(let g=0,m=i;g!==m;++g){const y=n[g],_=y[f],x=y[p];y[u]=_,y[f]=x,y.pop()}}else{const f=--o,d=e[f];f>0&&(t[d.uuid]=u),e[u]=d,e.pop();for(let p=0,v=i;p!==v;++p){const g=n[p];g[u]=g[f],g.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(i!==void 0)return r[i];const o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,h=this.nCachedObjects_,u=new Array(l);i=r.length,n[e]=i,o.push(e),a.push(t),r.push(u);for(let f=h,d=c.length;f!==d;++f){const p=c[f];u[f]=new et(p,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=n,o[n]=c,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class bm{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),c={endingStart:Qi,endingEnd:Qi};for(let l=0;l!==o;++l){const h=r[l].createInterpolant(null);a[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=hp,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const i=this._clip.duration,r=e._clip.duration,o=r/i,a=i/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const c=a.parameterPositions,l=a.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const c=(e-r)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Mh:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulateAdditive(a);break;case Xa:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const o=n===up;if(e===0)return r===-1?i:o&&(r&1)===1?t-i:i;if(n===lp){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);const c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){const l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=es,i.endingEnd=es):(e?i.endingStart=this.zeroSlopeAtStart?es:Qi:i.endingStart=kr,t?i.endingEnd=this.zeroSlopeAtEnd?es:Qi:i.endingEnd=kr)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,c=o.sampleValues;return a[0]=r,c[0]=t,a[1]=r+e,c[1]=n,this}}const IS=new Float32Array(1);class US extends Wn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){const f=i[u],d=f.name;let p=h[d];if(p!==void 0)++p.referenceCount,o[u]=p;else{if(p=o[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,d));continue}const v=t&&t._propertyBindings[u].binding.parsedPath;p=new Sm(et.create(n,d,v),f.ValueTypeName,f.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,d),o[u]=p}a[u].resultBuffer=p.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,r=this._actionsByClip;let o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{const a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const r=e._clip.uuid,o=this._actionsByClip,a=o[r],c=a.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;const u=a.actionByRoot,f=(e._localRoot||this._root).uuid;delete u[f],c.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,r=this._bindings;let o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Yh(new Float32Array(2),new Float32Array(2),1,IS),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){const i=t||this._root,r=i.uuid;let o=typeof e=="string"?er.findByName(i,e):e;const a=o!==null?o.uuid:e,c=this._actionsByClip[a];let l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Xa),c!==void 0){const u=c.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;const h=new bm(this,o,t,n);return this._bindAction(h,l),this._addInactiveAction(h,a,r),h}existingAction(e,t){const n=t||this._root,i=n.uuid,r=typeof e=="string"?er.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,o);const a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){const o=r.knownActions;for(let a=0,c=o.length;a!==c;++a){const l=o[a];this._deactivateAction(l);const h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const o in n){const a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(const o in r){const a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class ru{constructor(e){this.value=e}clone(){return new ru(this.value.clone===void 0?this.value:this.value.clone())}}let NS=0;class DS extends Wn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:NS++}),this.name="",this.usage=Wr,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,i=t.length;n<i;n++){const r=Array.isArray(t[n])?t[n]:[t[n]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}}class Pa extends rr{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class OS{constructor(e,t,n,i,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=r,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class BS{constructor(e,t,n=0,i=1/0){this.ray=new ds(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Ka,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return th(e,this,n,t),n.sort(Zf),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)th(e[i],this,n,t);return n.sort(Zf),n}}function Zf(s,e){return s.distance-e.distance}function th(s,e,t,n){if(s.layers.test(e.layers)&&s.raycast(e,t),n===!0){const i=s.children;for(let r=0,o=i.length;r<o;r++)th(i[r],e,t,!0)}}class nh{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}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=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),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(yt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class FS{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}const Kf=new ae;class zS{constructor(e=new ae(1/0,1/0),t=new ae(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Kf.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}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}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))}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)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kf).distanceTo(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}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)}}const jf=new C,sa=new C;class Am{constructor(e=new C,t=new C){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){jf.subVectors(e,this.start),sa.subVectors(this.end,this.start);const n=sa.dot(sa);let r=sa.dot(jf)/n;return t&&(r=yt(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Jf=new C;class kS extends tt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Be,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){const l=o/c*Math.PI*2,h=a/c*Math.PI*2;i.push(Math.cos(l),Math.sin(l),1,Math.cos(h),Math.sin(h),1)}n.setAttribute("position",new Ee(i,3));const r=new Xt({fog:!1,toneMapped:!1});this.cone=new Pn(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Jf.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Jf),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const vi=new C,ra=new Ne,sl=new Ne;class HS extends Pn{constructor(e){const t=wm(e),n=new Be,i=[],r=[],o=new Te(0,0,1),a=new Te(0,1,0);for(let l=0;l<t.length;l++){const h=t[l];h.parent&&h.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}n.setAttribute("position",new Ee(i,3)),n.setAttribute("color",new Ee(r,3));const c=new Xt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");sl.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<t.length;r++){const a=t[r];a.parent&&a.parent.isBone&&(ra.multiplyMatrices(sl,a.matrixWorld),vi.setFromMatrixPosition(ra),i.setXYZ(o,vi.x,vi.y,vi.z),ra.multiplyMatrices(sl,a.parent.matrixWorld),vi.setFromMatrixPosition(ra),i.setXYZ(o+1,vi.x,vi.y,vi.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}function wm(s){const e=[];s.isBone===!0&&e.push(s);for(let t=0;t<s.children.length;t++)e.push.apply(e,wm(s.children[t]));return e}class GS extends ft{constructor(e,t,n){const i=new ho(t,4,2),r=new hn({wireframe:!0,fog:!1,toneMapped:!1});super(i,r),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const VS=new C,$f=new Te,Qf=new Te;class WS extends tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new lo(t);i.rotateY(Math.PI*.5),this.material=new hn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),o=new Float32Array(r.count*3);i.setAttribute("color",new Fe(o,3)),this.add(new ft(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");$f.copy(this.light.color),Qf.copy(this.light.groundColor);for(let n=0,i=t.count;n<i;n++){const r=n<i/2?$f:Qf;t.setXYZ(n,r.r,r.g,r.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(VS.setFromMatrixPosition(this.light.matrixWorld).negate())}}class XS extends Pn{constructor(e=10,t=10,n=4473924,i=8947848){n=new Te(n),i=new Te(i);const r=t/2,o=e/t,a=e/2,c=[],l=[];for(let f=0,d=0,p=-a;f<=t;f++,p+=o){c.push(-a,0,p,a,0,p),c.push(p,0,-a,p,0,a);const v=f===r?n:i;v.toArray(l,d),d+=3,v.toArray(l,d),d+=3,v.toArray(l,d),d+=3,v.toArray(l,d),d+=3}const h=new Be;h.setAttribute("position",new Ee(c,3)),h.setAttribute("color",new Ee(l,3));const u=new Xt({vertexColors:!0,toneMapped:!1});super(h,u),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class qS extends Pn{constructor(e=10,t=16,n=8,i=64,r=4473924,o=8947848){r=new Te(r),o=new Te(o);const a=[],c=[];if(t>1)for(let u=0;u<t;u++){const f=u/t*(Math.PI*2),d=Math.sin(f)*e,p=Math.cos(f)*e;a.push(0,0,0),a.push(d,0,p);const v=u&1?r:o;c.push(v.r,v.g,v.b),c.push(v.r,v.g,v.b)}for(let u=0;u<n;u++){const f=u&1?r:o,d=e-e/n*u;for(let p=0;p<i;p++){let v=p/i*(Math.PI*2),g=Math.sin(v)*d,m=Math.cos(v)*d;a.push(g,0,m),c.push(f.r,f.g,f.b),v=(p+1)/i*(Math.PI*2),g=Math.sin(v)*d,m=Math.cos(v)*d,a.push(g,0,m),c.push(f.r,f.g,f.b)}}const l=new Be;l.setAttribute("position",new Ee(a,3)),l.setAttribute("color",new Ee(c,3));const h=new Xt({vertexColors:!0,toneMapped:!1});super(l,h),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const ed=new C,oa=new C,td=new C;class YS extends tt{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let i=new Be;i.setAttribute("position",new Ee([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Xt({fog:!1,toneMapped:!1});this.lightPlane=new ci(i,r),this.add(this.lightPlane),i=new Be,i.setAttribute("position",new Ee([0,0,0,0,0,1],3)),this.targetLine=new ci(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),ed.setFromMatrixPosition(this.light.matrixWorld),oa.setFromMatrixPosition(this.light.target.matrixWorld),td.subVectors(oa,ed),this.lightPlane.lookAt(oa),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(oa),this.targetLine.scale.z=td.length()}}const aa=new C,_t=new Ja;class ZS extends Pn{constructor(e){const t=new Be,n=new Xt({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(p,v){c(p),c(v)}function c(p){i.push(0,0,0),r.push(0,0,0),o[p]===void 0&&(o[p]=[]),o[p].push(i.length/3-1)}t.setAttribute("position",new Ee(i,3)),t.setAttribute("color",new Ee(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();const l=new Te(16755200),h=new Te(16711680),u=new Te(43775),f=new Te(16777215),d=new Te(3355443);this.setColors(l,h,u,f,d)}setColors(e,t,n,i,r){const a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap,n=1,i=1;_t.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Mt("c",t,e,_t,0,0,-1),Mt("t",t,e,_t,0,0,1),Mt("n1",t,e,_t,-n,-i,-1),Mt("n2",t,e,_t,n,-i,-1),Mt("n3",t,e,_t,-n,i,-1),Mt("n4",t,e,_t,n,i,-1),Mt("f1",t,e,_t,-n,-i,1),Mt("f2",t,e,_t,n,-i,1),Mt("f3",t,e,_t,-n,i,1),Mt("f4",t,e,_t,n,i,1),Mt("u1",t,e,_t,n*.7,i*1.1,-1),Mt("u2",t,e,_t,-n*.7,i*1.1,-1),Mt("u3",t,e,_t,0,i*2,-1),Mt("cf1",t,e,_t,-n,0,1),Mt("cf2",t,e,_t,n,0,1),Mt("cf3",t,e,_t,0,-i,1),Mt("cf4",t,e,_t,0,i,1),Mt("cn1",t,e,_t,-n,0,-1),Mt("cn2",t,e,_t,n,0,-1),Mt("cn3",t,e,_t,0,-i,-1),Mt("cn4",t,e,_t,0,i,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Mt(s,e,t,n,i,r,o){aa.set(i,r,o).unproject(n);const a=e[s];if(a!==void 0){const c=t.getAttribute("position");for(let l=0,h=a.length;l<h;l++)c.setXYZ(a[l],aa.x,aa.y,aa.z)}}const ca=new wt;class KS extends Pn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Be;r.setIndex(new Fe(n,1)),r.setAttribute("position",new Fe(i,3)),super(r,new Xt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&ca.setFromObject(this.object),ca.isEmpty())return;const t=ca.min,n=ca.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class jS extends Pn{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new Be;r.setIndex(new Fe(n,1)),r.setAttribute("position",new Ee(i,3)),super(r,new Xt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class JS extends ci{constructor(e,t=1,n=16776960){const i=n,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new Be;o.setAttribute("position",new Ee(r,3)),o.computeBoundingSphere(),super(o,new Xt({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new Be;c.setAttribute("position",new Ee(a,3)),c.computeBoundingSphere(),this.add(new ft(c,new hn({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const nd=new C;let la,rl;class $S extends tt{constructor(e=new C(0,0,1),t=new C(0,0,0),n=1,i=16776960,r=n*.2,o=r*.2){super(),this.type="ArrowHelper",la===void 0&&(la=new Be,la.setAttribute("position",new Ee([0,0,0,0,1,0],3)),rl=new or(0,.5,1,5,1),rl.translate(0,-.5,0)),this.position.copy(t),this.line=new ci(la,new Xt({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ft(rl,new hn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{nd.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(nd,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class QS extends Pn{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Be;i.setAttribute("position",new Ee(t,3)),i.setAttribute("color",new Ee(n,3));const r=new Xt({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new Te,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class eb{constructor(){this.type="ShapePath",this.color=new Te,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new qr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,o){return this.currentPath.bezierCurveTo(e,t,n,i,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(m){const y=[];for(let _=0,x=m.length;_<x;_++){const T=m[_],b=new os;b.curves=T.curves,y.push(b)}return y}function n(m,y){const _=y.length;let x=!1;for(let T=_-1,b=0;b<_;T=b++){let A=y[T],L=y[b],M=L.x-A.x,w=L.y-A.y;if(Math.abs(w)>Number.EPSILON){if(w<0&&(A=y[b],M=-M,L=y[T],w=-w),m.y<A.y||m.y>L.y)continue;if(m.y===A.y){if(m.x===A.x)return!0}else{const O=w*(m.x-A.x)-M*(m.y-A.y);if(O===0)return!0;if(O<0)continue;x=!x}}else{if(m.y!==A.y)continue;if(L.x<=m.x&&m.x<=A.x||A.x<=m.x&&m.x<=L.x)return!0}}return x}const i=Hn.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,c;const l=[];if(r.length===1)return a=r[0],c=new os,c.curves=a.curves,l.push(c),l;let h=!i(r[0].getPoints());h=e?!h:h;const u=[],f=[];let d=[],p=0,v;f[p]=void 0,d[p]=[];for(let m=0,y=r.length;m<y;m++)a=r[m],v=a.getPoints(),o=i(v),o=e?!o:o,o?(!h&&f[p]&&p++,f[p]={s:new os,p:v},f[p].s.curves=a.curves,h&&p++,d[p]=[]):d[p].push({h:a,p:v[0]});if(!f[0])return t(r);if(f.length>1){let m=!1,y=0;for(let _=0,x=f.length;_<x;_++)u[_]=[];for(let _=0,x=f.length;_<x;_++){const T=d[_];for(let b=0;b<T.length;b++){const A=T[b];let L=!0;for(let M=0;M<f.length;M++)n(A.p,f[M].p)&&(_!==M&&y++,L?(L=!1,u[M].push(A)):m=!0);L&&u[_].push(A)}}y>0&&m===!1&&(d=u)}let g;for(let m=0,y=f.length;m<y;m++){c=f[m].s,l.push(c),g=d[m];for(let _=0,x=g.length;_<x;_++)c.holes.push(g[_].h)}return l}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"160"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="160");const vA=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:Jd,AddEquation:Mi,AddOperation:Yd,AdditiveAnimationBlendMode:Mh,AdditiveBlending:ml,AgXToneMapping:Qd,AlphaFormat:ip,AlwaysCompare:Sp,AlwaysDepth:kd,AlwaysStencilFunc:ql,AmbientLight:pm,AnimationAction:bm,AnimationClip:er,AnimationLoader:oS,AnimationMixer:US,AnimationObjectGroup:PS,AnimationUtils:nS,ArcCurve:Xp,ArrayCamera:Bp,ArrowHelper:$S,AttachedBindMode:xl,Audio:Mm,AudioAnalyser:MS,AudioContext:nu,AudioListener:_S,AudioLoader:mS,AxesHelper:QS,BackSide:Qt,BasicDepthPacking:dp,BasicShadowMap:vg,BatchedMesh:Wp,Bone:tc,BooleanKeyframeTrack:ms,Box2:zS,Box3:wt,Box3Helper:jS,BoxGeometry:ps,BoxHelper:KS,BufferAttribute:Fe,BufferGeometry:Be,BufferGeometryLoader:_m,ByteType:tp,Cache:ti,Camera:Ja,CameraHelper:ZS,CanvasTexture:TM,CapsuleGeometry:rc,CatmullRomCurve3:qp,CineonToneMapping:jd,CircleGeometry:oc,ClampToEdgeWrapping:At,Clock:xm,Color:Te,ColorKeyframeTrack:Zh,ColorManagement:rt,CompressedArrayTexture:AM,CompressedCubeTexture:wM,CompressedTexture:ic,CompressedTextureLoader:aS,ConeGeometry:ac,ConstantAlphaFactor:Bd,ConstantColorFactor:Dd,CubeCamera:Rp,CubeReflectionMapping:oi,CubeRefractionMapping:Ei,CubeTexture:io,CubeTextureLoader:cS,CubeUVReflectionMapping:ir,CubicBezierCurve:kh,CubicBezierCurve3:Yp,CubicInterpolant:lm,CullFaceBack:pl,CullFaceFront:Md,CullFaceFrontBack:gg,CullFaceNone:xd,Curve:In,CurvePath:Kp,CustomBlending:bd,CustomToneMapping:$d,CylinderGeometry:or,Cylindrical:FS,Data3DTexture:Eh,DataArrayTexture:Za,DataTexture:rs,DataTextureLoader:lS,DataUtils:bv,DecrementStencilOp:Tg,DecrementWrapStencilOp:Rg,DefaultLoadingManager:fm,DepthFormat:bi,DepthStencilFormat:cs,DepthTexture:Ph,DetachedBindMode:ep,DirectionalLight:eu,DirectionalLightHelper:YS,DiscreteInterpolant:hm,DisplayP3ColorSpace:qa,DodecahedronGeometry:cc,DoubleSide:Tn,DstAlphaFactor:Ld,DstColorFactor:Id,DynamicCopyUsage:Vg,DynamicDrawUsage:Bg,DynamicReadUsage:kg,EdgesGeometry:jp,EllipseCurve:sc,EqualCompare:_p,EqualDepth:Gd,EqualStencilFunc:Ig,EquirectangularReflectionMapping:Br,EquirectangularRefractionMapping:Fr,Euler:no,EventDispatcher:Wn,ExtrudeGeometry:hc,FileLoader:fn,Float16BufferAttribute:Cv,Float32BufferAttribute:Ee,Float64BufferAttribute:Lv,FloatType:En,Fog:ec,FogExp2:Qa,FramebufferTexture:bM,FrontSide:Gn,Frustum:so,GLBufferAttribute:OS,GLSL1:Xg,GLSL3:Yl,GreaterCompare:yp,GreaterDepth:Wd,GreaterEqualCompare:Mp,GreaterEqualDepth:Vd,GreaterEqualStencilFunc:Og,GreaterStencilFunc:Ng,GridHelper:XS,Group:_n,HalfFloatType:Ks,HemisphereLight:dm,HemisphereLightHelper:WS,IcosahedronGeometry:uc,ImageBitmapLoader:ym,ImageLoader:jr,ImageUtils:Th,IncrementStencilOp:wg,IncrementWrapStencilOp:Eg,InstancedBufferAttribute:ai,InstancedBufferGeometry:tu,InstancedInterleavedBuffer:Pa,InstancedMesh:Oh,Int16BufferAttribute:Ev,Int32BufferAttribute:Rv,Int8BufferAttribute:Av,IntType:ph,InterleavedBuffer:rr,InterleavedBufferAttribute:$t,Interpolant:cr,InterpolateDiscrete:js,InterpolateLinear:ls,InterpolateSmooth:xa,InvertStencilOp:Cg,KeepStencilOp:ji,KeyframeTrack:Nn,LOD:Vp,LatheGeometry:co,Layers:Ka,LessCompare:vp,LessDepth:Hd,LessEqualCompare:Ah,LessEqualDepth:Or,LessEqualStencilFunc:Ug,LessStencilFunc:Pg,Light:Ui,LightProbe:vm,Line:ci,Line3:Am,LineBasicMaterial:Xt,LineCurve:Hh,LineCurve3:Zp,LineDashedMaterial:om,LineLoop:Bh,LineSegments:Pn,LinearDisplayP3ColorSpace:to,LinearEncoding:bh,LinearFilter:at,LinearInterpolant:Yh,LinearMipMapLinearFilter:Sg,LinearMipMapNearestFilter:Mg,LinearMipmapLinearFilter:Mn,LinearMipmapNearestFilter:Va,LinearSRGBColorSpace:Rt,LinearToneMapping:Zd,LinearTransfer:Hr,Loader:Bt,LoaderUtils:wi,LoadingManager:Kh,LoopOnce:lp,LoopPingPong:up,LoopRepeat:hp,LuminanceAlphaFormat:rp,LuminanceFormat:sp,MOUSE:Zi,Material:Et,MaterialLoader:_c,MathUtils:Ya,Matrix3:Xe,Matrix4:Ne,MaxEquation:yl,Mesh:ft,MeshBasicMaterial:hn,MeshDepthMaterial:Ih,MeshDistanceMaterial:Uh,MeshLambertMaterial:sm,MeshMatcapMaterial:rm,MeshNormalMaterial:im,MeshPhongMaterial:Xs,MeshPhysicalMaterial:Un,MeshStandardMaterial:ar,MeshToonMaterial:nm,MinEquation:_l,MirroredRepeatWrapping:Ri,MixOperation:qd,MultiplyBlending:vl,MultiplyOperation:eo,NearestFilter:dt,NearestMipMapLinearFilter:xg,NearestMipMapNearestFilter:yg,NearestMipmapLinearFilter:qs,NearestMipmapNearestFilter:zr,NeverCompare:gp,NeverDepth:zd,NeverStencilFunc:Lg,NoBlending:ii,NoColorSpace:ln,NoToneMapping:si,NormalAnimationBlendMode:Xa,NormalBlending:is,NotEqualCompare:xp,NotEqualDepth:Xd,NotEqualStencilFunc:Dg,NumberKeyframeTrack:us,Object3D:tt,ObjectLoader:dS,ObjectSpaceNormalMap:mp,OctahedronGeometry:lo,OneFactor:Ed,OneMinusConstantAlphaFactor:Fd,OneMinusConstantColorFactor:Od,OneMinusDstAlphaFactor:Pd,OneMinusDstColorFactor:Ud,OneMinusSrcAlphaFactor:Ta,OneMinusSrcColorFactor:Cd,OrthographicCamera:oo,P3Primaries:Vr,PCFShadowMap:dh,PCFSoftShadowMap:Sd,PMREMGenerator:Kl,Path:qr,PerspectiveCamera:Nt,Plane:$n,PlaneGeometry:ro,PlaneHelper:JS,PointLight:Qh,PointLightHelper:GS,Points:Fh,PointsMaterial:nc,PolarGridHelper:qS,PolyhedronGeometry:Ii,PositionalAudio:xS,PropertyBinding:et,PropertyMixer:Sm,QuadraticBezierCurve:Gh,QuadraticBezierCurve3:Vh,Quaternion:Ot,QuaternionKeyframeTrack:Ci,QuaternionLinearInterpolant:um,RED_GREEN_RGTC2_Format:Wl,RED_RGTC1_Format:cp,REVISION:"160",RGBADepthPacking:pp,RGBAFormat:nn,RGBAIntegerFormat:yh,RGBA_ASTC_10x10_Format:Fl,RGBA_ASTC_10x5_Format:Dl,RGBA_ASTC_10x6_Format:Ol,RGBA_ASTC_10x8_Format:Bl,RGBA_ASTC_12x10_Format:zl,RGBA_ASTC_12x12_Format:kl,RGBA_ASTC_4x4_Format:El,RGBA_ASTC_5x4_Format:Rl,RGBA_ASTC_5x5_Format:Cl,RGBA_ASTC_6x5_Format:Ll,RGBA_ASTC_6x6_Format:Pl,RGBA_ASTC_8x5_Format:Il,RGBA_ASTC_8x6_Format:Ul,RGBA_ASTC_8x8_Format:Nl,RGBA_BPTC_Format:ya,RGBA_ETC2_EAC_Format:Tl,RGBA_PVRTC_2BPPV1_Format:Al,RGBA_PVRTC_4BPPV1_Format:bl,RGBA_S3TC_DXT1_Format:ga,RGBA_S3TC_DXT3_Format:va,RGBA_S3TC_DXT5_Format:_a,RGB_BPTC_SIGNED_Format:Hl,RGB_BPTC_UNSIGNED_Format:Gl,RGB_ETC1_Format:xh,RGB_ETC2_Format:wl,RGB_PVRTC_2BPPV1_Format:Sl,RGB_PVRTC_4BPPV1_Format:Ml,RGB_S3TC_DXT1_Format:ma,RGFormat:ap,RGIntegerFormat:_h,RawShaderMaterial:tm,Ray:ds,Raycaster:BS,Rec709Primaries:Gr,RectAreaLight:mm,RedFormat:op,RedIntegerFormat:vh,ReinhardToneMapping:Kd,RenderTarget:wp,RepeatWrapping:vn,ReplaceStencilOp:Ag,ReverseSubtractEquation:wd,RingGeometry:fc,SIGNED_RED_GREEN_RGTC2_Format:Xl,SIGNED_RED_RGTC1_Format:Vl,SRGBColorSpace:ht,SRGBTransfer:lt,Scene:kp,ShaderChunk:Ve,ShaderLib:jt,ShaderMaterial:Ln,ShadowMaterial:em,Shape:os,ShapeGeometry:dc,ShapePath:eb,ShapeUtils:Hn,ShortType:np,Skeleton:ao,SkeletonHelper:HS,SkinnedMesh:Dh,Source:ts,Sphere:Tt,SphereGeometry:ho,Spherical:nh,SphericalHarmonics3:gm,SplineCurve:Wh,SpotLight:$h,SpotLightHelper:kS,Sprite:Gp,SpriteMaterial:Nh,SrcAlphaFactor:wa,SrcAlphaSaturateFactor:Nd,SrcColorFactor:Rd,StaticCopyUsage:Gg,StaticDrawUsage:Wr,StaticReadUsage:zg,StereoCamera:gS,StreamCopyUsage:Wg,StreamDrawUsage:Fg,StreamReadUsage:Hg,StringKeyframeTrack:gs,SubtractEquation:Ad,SubtractiveBlending:gl,TOUCH:Ki,TangentSpaceNormalMap:Pi,TetrahedronGeometry:pc,Texture:gt,TextureLoader:jh,TorusGeometry:mc,TorusKnotGeometry:gc,Triangle:tn,TriangleFanDrawMode:Ea,TriangleStripDrawMode:Sh,TrianglesDrawMode:fp,TubeGeometry:vc,TwoPassDoubleSide:_g,UVMapping:Ga,Uint16BufferAttribute:Rh,Uint32BufferAttribute:Ch,Uint8BufferAttribute:wv,Uint8ClampedBufferAttribute:Tv,Uniform:ru,UniformsGroup:DS,UniformsLib:_e,UniformsUtils:ja,UnsignedByteType:ri,UnsignedInt248Type:Si,UnsignedIntType:ei,UnsignedShort4444Type:mh,UnsignedShort5551Type:gh,UnsignedShortType:Wa,VSMShadowMap:zn,Vector2:ae,Vector3:C,Vector4:nt,VectorKeyframeTrack:fs,VideoTexture:SM,WebGL1Renderer:zp,WebGL3DRenderTarget:uv,WebGLArrayRenderTarget:hv,WebGLCoordinateSystem:Rn,WebGLCubeRenderTarget:Cp,WebGLMultipleRenderTargets:fv,WebGLRenderTarget:Cn,WebGLRenderer:Fp,WebGLUtils:Op,WebGPUCoordinateSystem:Js,WireframeGeometry:Xh,WrapAroundEnding:kr,ZeroCurvatureEnding:Qi,ZeroFactor:Td,ZeroSlopeEnding:es,ZeroStencilOp:bg,_SRGBAFormat:Ra,createCanvasElement:Ap,sRGBEncoding:Ai},Symbol.toStringTag,{value:"Module"})),id={type:"change"},ol={type:"start"},sd={type:"end"},ha=new ds,rd=new $n,tb=Math.cos(70*Ya.DEG2RAD);class nb extends Wn{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new C,this.cursor=new C,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.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:Zi.ROTATE,MIDDLE:Zi.DOLLY,RIGHT:Zi.PAN},this.touches={ONE:Ki.ROTATE,TWO:Ki.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return a.phi},this.getAzimuthalAngle=function(){return a.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(D){D.addEventListener("keydown",fe),this._domElementKeyEvents=D},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",fe),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(id),n.update(),r=i.NONE},this.update=(function(){const D=new C,pe=new Ot().setFromUnitVectors(e.up,new C(0,1,0)),we=pe.clone().invert(),ve=new C,Le=new Ot,Ke=new C,Qe=2*Math.PI;return function(Ae=null){const B=n.object.position;D.copy(B).sub(n.target),D.applyQuaternion(pe),a.setFromVector3(D),n.autoRotate&&r===i.NONE&&O(M(Ae)),n.enableDamping?(a.theta+=c.theta*n.dampingFactor,a.phi+=c.phi*n.dampingFactor):(a.theta+=c.theta,a.phi+=c.phi);let ye=n.minAzimuthAngle,xe=n.maxAzimuthAngle;isFinite(ye)&&isFinite(xe)&&(ye<-Math.PI?ye+=Qe:ye>Math.PI&&(ye-=Qe),xe<-Math.PI?xe+=Qe:xe>Math.PI&&(xe-=Qe),ye<=xe?a.theta=Math.max(ye,Math.min(xe,a.theta)):a.theta=a.theta>(ye+xe)/2?Math.max(ye,a.theta):Math.min(xe,a.theta)),a.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,a.phi)),a.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(h,n.dampingFactor):n.target.add(h),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&b||n.object.isOrthographicCamera?a.radius=$(a.radius):a.radius=$(a.radius*l),D.setFromSpherical(a),D.applyQuaternion(we),B.copy(n.target).add(D),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,h.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),h.set(0,0,0));let De=!1;if(n.zoomToCursor&&b){let Pe=null;if(n.object.isPerspectiveCamera){const it=D.length();Pe=$(it*l);const st=it-Pe;n.object.position.addScaledVector(x,st),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const it=new C(T.x,T.y,0);it.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),De=!0;const st=new C(T.x,T.y,0);st.unproject(n.object),n.object.position.sub(st).add(it),n.object.updateMatrixWorld(),Pe=D.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;Pe!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(Pe).add(n.object.position):(ha.origin.copy(n.object.position),ha.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(ha.direction))<tb?e.lookAt(n.target):(rd.setFromNormalAndCoplanarPoint(n.object.up,n.target),ha.intersectPlane(rd,n.target))))}else n.object.isOrthographicCamera&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/l)),n.object.updateProjectionMatrix(),De=!0);return l=1,b=!1,De||ve.distanceToSquared(n.object.position)>o||8*(1-Le.dot(n.object.quaternion))>o||Ke.distanceToSquared(n.target)>0?(n.dispatchEvent(id),ve.copy(n.object.position),Le.copy(n.object.quaternion),Ke.copy(n.target),!0):!1}})(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",be),n.domElement.removeEventListener("pointerdown",me),n.domElement.removeEventListener("pointercancel",S),n.domElement.removeEventListener("wheel",ue),n.domElement.removeEventListener("pointermove",E),n.domElement.removeEventListener("pointerup",S),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener("keydown",fe),n._domElementKeyEvents=null)};const n=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let r=i.NONE;const o=1e-6,a=new nh,c=new nh;let l=1;const h=new C,u=new ae,f=new ae,d=new ae,p=new ae,v=new ae,g=new ae,m=new ae,y=new ae,_=new ae,x=new C,T=new ae;let b=!1;const A=[],L={};function M(D){return D!==null?2*Math.PI/60*n.autoRotateSpeed*D:2*Math.PI/60/60*n.autoRotateSpeed}function w(D){const pe=Math.abs(D)/(100*(window.devicePixelRatio|0));return Math.pow(.95,n.zoomSpeed*pe)}function O(D){c.theta-=D}function H(D){c.phi-=D}const K=(function(){const D=new C;return function(we,ve){D.setFromMatrixColumn(ve,0),D.multiplyScalar(-we),h.add(D)}})(),I=(function(){const D=new C;return function(we,ve){n.screenSpacePanning===!0?D.setFromMatrixColumn(ve,1):(D.setFromMatrixColumn(ve,0),D.crossVectors(n.object.up,D)),D.multiplyScalar(we),h.add(D)}})(),F=(function(){const D=new C;return function(we,ve){const Le=n.domElement;if(n.object.isPerspectiveCamera){const Ke=n.object.position;D.copy(Ke).sub(n.target);let Qe=D.length();Qe*=Math.tan(n.object.fov/2*Math.PI/180),K(2*we*Qe/Le.clientHeight,n.object.matrix),I(2*ve*Qe/Le.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(K(we*(n.object.right-n.object.left)/n.object.zoom/Le.clientWidth,n.object.matrix),I(ve*(n.object.top-n.object.bottom)/n.object.zoom/Le.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function k(D){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l/=D:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function te(D){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?l*=D:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function J(D,pe){if(!n.zoomToCursor)return;b=!0;const we=n.domElement.getBoundingClientRect(),ve=D-we.left,Le=pe-we.top,Ke=we.width,Qe=we.height;T.x=ve/Ke*2-1,T.y=-(Le/Qe)*2+1,x.set(T.x,T.y,1).unproject(n.object).sub(n.object.position).normalize()}function $(D){return Math.max(n.minDistance,Math.min(n.maxDistance,D))}function le(D){u.set(D.clientX,D.clientY)}function ce(D){J(D.clientX,D.clientX),m.set(D.clientX,D.clientY)}function ge(D){p.set(D.clientX,D.clientY)}function Z(D){f.set(D.clientX,D.clientY),d.subVectors(f,u).multiplyScalar(n.rotateSpeed);const pe=n.domElement;O(2*Math.PI*d.x/pe.clientHeight),H(2*Math.PI*d.y/pe.clientHeight),u.copy(f),n.update()}function U(D){y.set(D.clientX,D.clientY),_.subVectors(y,m),_.y>0?k(w(_.y)):_.y<0&&te(w(_.y)),m.copy(y),n.update()}function N(D){v.set(D.clientX,D.clientY),g.subVectors(v,p).multiplyScalar(n.panSpeed),F(g.x,g.y),p.copy(v),n.update()}function V(D){J(D.clientX,D.clientY),D.deltaY<0?te(w(D.deltaY)):D.deltaY>0&&k(w(D.deltaY)),n.update()}function W(D){let pe=!1;switch(D.code){case n.keys.UP:D.ctrlKey||D.metaKey||D.shiftKey?H(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):F(0,n.keyPanSpeed),pe=!0;break;case n.keys.BOTTOM:D.ctrlKey||D.metaKey||D.shiftKey?H(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):F(0,-n.keyPanSpeed),pe=!0;break;case n.keys.LEFT:D.ctrlKey||D.metaKey||D.shiftKey?O(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):F(n.keyPanSpeed,0),pe=!0;break;case n.keys.RIGHT:D.ctrlKey||D.metaKey||D.shiftKey?O(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):F(-n.keyPanSpeed,0),pe=!0;break}pe&&(D.preventDefault(),n.update())}function q(D){if(A.length===1)u.set(D.pageX,D.pageY);else{const pe=Ze(D),we=.5*(D.pageX+pe.x),ve=.5*(D.pageY+pe.y);u.set(we,ve)}}function j(D){if(A.length===1)p.set(D.pageX,D.pageY);else{const pe=Ze(D),we=.5*(D.pageX+pe.x),ve=.5*(D.pageY+pe.y);p.set(we,ve)}}function Y(D){const pe=Ze(D),we=D.pageX-pe.x,ve=D.pageY-pe.y,Le=Math.sqrt(we*we+ve*ve);m.set(0,Le)}function oe(D){n.enableZoom&&Y(D),n.enablePan&&j(D)}function R(D){n.enableZoom&&Y(D),n.enableRotate&&q(D)}function ie(D){if(A.length==1)f.set(D.pageX,D.pageY);else{const we=Ze(D),ve=.5*(D.pageX+we.x),Le=.5*(D.pageY+we.y);f.set(ve,Le)}d.subVectors(f,u).multiplyScalar(n.rotateSpeed);const pe=n.domElement;O(2*Math.PI*d.x/pe.clientHeight),H(2*Math.PI*d.y/pe.clientHeight),u.copy(f)}function G(D){if(A.length===1)v.set(D.pageX,D.pageY);else{const pe=Ze(D),we=.5*(D.pageX+pe.x),ve=.5*(D.pageY+pe.y);v.set(we,ve)}g.subVectors(v,p).multiplyScalar(n.panSpeed),F(g.x,g.y),p.copy(v)}function Q(D){const pe=Ze(D),we=D.pageX-pe.x,ve=D.pageY-pe.y,Le=Math.sqrt(we*we+ve*ve);y.set(0,Le),_.set(0,Math.pow(y.y/m.y,n.zoomSpeed)),k(_.y),m.copy(y);const Ke=(D.pageX+pe.x)*.5,Qe=(D.pageY+pe.y)*.5;J(Ke,Qe)}function re(D){n.enableZoom&&Q(D),n.enablePan&&G(D)}function Me(D){n.enableZoom&&Q(D),n.enableRotate&&ie(D)}function me(D){n.enabled!==!1&&(A.length===0&&(n.domElement.setPointerCapture(D.pointerId),n.domElement.addEventListener("pointermove",E),n.domElement.addEventListener("pointerup",S)),Ue(D),D.pointerType==="touch"?Re(D):z(D))}function E(D){n.enabled!==!1&&(D.pointerType==="touch"?Se(D):he(D))}function S(D){ke(D),A.length===0&&(n.domElement.releasePointerCapture(D.pointerId),n.domElement.removeEventListener("pointermove",E),n.domElement.removeEventListener("pointerup",S)),n.dispatchEvent(sd),r=i.NONE}function z(D){let pe;switch(D.button){case 0:pe=n.mouseButtons.LEFT;break;case 1:pe=n.mouseButtons.MIDDLE;break;case 2:pe=n.mouseButtons.RIGHT;break;default:pe=-1}switch(pe){case Zi.DOLLY:if(n.enableZoom===!1)return;ce(D),r=i.DOLLY;break;case Zi.ROTATE:if(D.ctrlKey||D.metaKey||D.shiftKey){if(n.enablePan===!1)return;ge(D),r=i.PAN}else{if(n.enableRotate===!1)return;le(D),r=i.ROTATE}break;case Zi.PAN:if(D.ctrlKey||D.metaKey||D.shiftKey){if(n.enableRotate===!1)return;le(D),r=i.ROTATE}else{if(n.enablePan===!1)return;ge(D),r=i.PAN}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(ol)}function he(D){switch(r){case i.ROTATE:if(n.enableRotate===!1)return;Z(D);break;case i.DOLLY:if(n.enableZoom===!1)return;U(D);break;case i.PAN:if(n.enablePan===!1)return;N(D);break}}function ue(D){n.enabled===!1||n.enableZoom===!1||r!==i.NONE||(D.preventDefault(),n.dispatchEvent(ol),V(D),n.dispatchEvent(sd))}function fe(D){n.enabled===!1||n.enablePan===!1||W(D)}function Re(D){switch(de(D),A.length){case 1:switch(n.touches.ONE){case Ki.ROTATE:if(n.enableRotate===!1)return;q(D),r=i.TOUCH_ROTATE;break;case Ki.PAN:if(n.enablePan===!1)return;j(D),r=i.TOUCH_PAN;break;default:r=i.NONE}break;case 2:switch(n.touches.TWO){case Ki.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;oe(D),r=i.TOUCH_DOLLY_PAN;break;case Ki.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;R(D),r=i.TOUCH_DOLLY_ROTATE;break;default:r=i.NONE}break;default:r=i.NONE}r!==i.NONE&&n.dispatchEvent(ol)}function Se(D){switch(de(D),r){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;ie(D),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;G(D),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;re(D),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;Me(D),n.update();break;default:r=i.NONE}}function be(D){n.enabled!==!1&&D.preventDefault()}function Ue(D){A.push(D.pointerId)}function ke(D){delete L[D.pointerId];for(let pe=0;pe<A.length;pe++)if(A[pe]==D.pointerId){A.splice(pe,1);return}}function de(D){let pe=L[D.pointerId];pe===void 0&&(pe=new ae,L[D.pointerId]=pe),pe.set(D.pageX,D.pageY)}function Ze(D){const pe=D.pointerId===A[0]?A[1]:A[0];return L[pe]}n.domElement.addEventListener("contextmenu",be),n.domElement.addEventListener("pointerdown",me),n.domElement.addEventListener("pointercancel",S),n.domElement.addEventListener("wheel",ue,{passive:!1}),this.update()}}const _A=Object.freeze(Object.defineProperty({__proto__:null,OrbitControls:nb},Symbol.toStringTag,{value:"Module"})),od=new wt,ua=new C;class ou extends tu{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new Ee(e,3)),this.setAttribute("uv",new Ee(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new Pa(t,6,1);return this.setAttribute("instanceStart",new $t(n,3,0)),this.setAttribute("instanceEnd",new $t(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new Pa(t,6,1);return this.setAttribute("instanceColorStart",new $t(n,3,0)),this.setAttribute("instanceColorEnd",new $t(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new Xh(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wt);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),od.setFromBufferAttribute(t),this.boundingBox.union(od))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Tt),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)ua.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(ua)),ua.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(ua));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}const yA=Object.freeze(Object.defineProperty({__proto__:null,LineSegmentsGeometry:ou},Symbol.toStringTag,{value:"Module"}));_e.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new ae(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}};jt.line={uniforms:ja.merge([_e.common,_e.fog,_e.line]),vertexShader:`
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
|
|
uniform float linewidth;
|
|
uniform vec2 resolution;
|
|
|
|
attribute vec3 instanceStart;
|
|
attribute vec3 instanceEnd;
|
|
|
|
attribute vec3 instanceColorStart;
|
|
attribute vec3 instanceColorEnd;
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
varying vec4 worldPos;
|
|
varying vec3 worldStart;
|
|
varying vec3 worldEnd;
|
|
|
|
#ifdef USE_DASH
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_DASH
|
|
|
|
uniform float dashScale;
|
|
attribute float instanceDistanceStart;
|
|
attribute float instanceDistanceEnd;
|
|
varying float vLineDistance;
|
|
|
|
#endif
|
|
|
|
void trimSegment( const in vec4 start, inout vec4 end ) {
|
|
|
|
// trim end segment so it terminates between the camera plane and the near plane
|
|
|
|
// conservative estimate of the near plane
|
|
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
|
|
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
|
|
float nearEstimate = - 0.5 * b / a;
|
|
|
|
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
|
|
|
|
end.xyz = mix( start.xyz, end.xyz, alpha );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
#ifdef USE_COLOR
|
|
|
|
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
|
|
|
|
#endif
|
|
|
|
#ifdef USE_DASH
|
|
|
|
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
|
|
vUv = uv;
|
|
|
|
#endif
|
|
|
|
float aspect = resolution.x / resolution.y;
|
|
|
|
// camera space
|
|
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
|
|
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
worldStart = start.xyz;
|
|
worldEnd = end.xyz;
|
|
|
|
#else
|
|
|
|
vUv = uv;
|
|
|
|
#endif
|
|
|
|
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
|
|
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
|
|
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
|
|
// perhaps there is a more elegant solution -- WestLangley
|
|
|
|
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
|
|
|
|
if ( perspective ) {
|
|
|
|
if ( start.z < 0.0 && end.z >= 0.0 ) {
|
|
|
|
trimSegment( start, end );
|
|
|
|
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
|
|
|
|
trimSegment( end, start );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// clip space
|
|
vec4 clipStart = projectionMatrix * start;
|
|
vec4 clipEnd = projectionMatrix * end;
|
|
|
|
// ndc space
|
|
vec3 ndcStart = clipStart.xyz / clipStart.w;
|
|
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
|
|
|
|
// direction
|
|
vec2 dir = ndcEnd.xy - ndcStart.xy;
|
|
|
|
// account for clip-space aspect ratio
|
|
dir.x *= aspect;
|
|
dir = normalize( dir );
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
vec3 worldDir = normalize( end.xyz - start.xyz );
|
|
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
|
|
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
|
|
vec3 worldFwd = cross( worldDir, worldUp );
|
|
worldPos = position.y < 0.5 ? start: end;
|
|
|
|
// height offset
|
|
float hw = linewidth * 0.5;
|
|
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
|
|
|
|
// don't extend the line if we're rendering dashes because we
|
|
// won't be rendering the endcaps
|
|
#ifndef USE_DASH
|
|
|
|
// cap extension
|
|
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
|
|
|
|
// add width to the box
|
|
worldPos.xyz += worldFwd * hw;
|
|
|
|
// endcaps
|
|
if ( position.y > 1.0 || position.y < 0.0 ) {
|
|
|
|
worldPos.xyz -= worldFwd * 2.0 * hw;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// project the worldpos
|
|
vec4 clip = projectionMatrix * worldPos;
|
|
|
|
// shift the depth of the projected points so the line
|
|
// segments overlap neatly
|
|
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
|
|
clip.z = clipPose.z * clip.w;
|
|
|
|
#else
|
|
|
|
vec2 offset = vec2( dir.y, - dir.x );
|
|
// undo aspect ratio adjustment
|
|
dir.x /= aspect;
|
|
offset.x /= aspect;
|
|
|
|
// sign flip
|
|
if ( position.x < 0.0 ) offset *= - 1.0;
|
|
|
|
// endcaps
|
|
if ( position.y < 0.0 ) {
|
|
|
|
offset += - dir;
|
|
|
|
} else if ( position.y > 1.0 ) {
|
|
|
|
offset += dir;
|
|
|
|
}
|
|
|
|
// adjust for linewidth
|
|
offset *= linewidth;
|
|
|
|
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
|
|
offset /= resolution.y;
|
|
|
|
// select end
|
|
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
|
|
|
|
// back to clip space
|
|
offset *= clip.w;
|
|
|
|
clip.xy += offset;
|
|
|
|
#endif
|
|
|
|
gl_Position = clip;
|
|
|
|
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
|
|
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
|
|
}
|
|
`,fragmentShader:`
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float linewidth;
|
|
|
|
#ifdef USE_DASH
|
|
|
|
uniform float dashOffset;
|
|
uniform float dashSize;
|
|
uniform float gapSize;
|
|
|
|
#endif
|
|
|
|
varying float vLineDistance;
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
varying vec4 worldPos;
|
|
varying vec3 worldStart;
|
|
varying vec3 worldEnd;
|
|
|
|
#ifdef USE_DASH
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
varying vec2 vUv;
|
|
|
|
#endif
|
|
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
|
|
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
|
|
|
|
float mua;
|
|
float mub;
|
|
|
|
vec3 p13 = p1 - p3;
|
|
vec3 p43 = p4 - p3;
|
|
|
|
vec3 p21 = p2 - p1;
|
|
|
|
float d1343 = dot( p13, p43 );
|
|
float d4321 = dot( p43, p21 );
|
|
float d1321 = dot( p13, p21 );
|
|
float d4343 = dot( p43, p43 );
|
|
float d2121 = dot( p21, p21 );
|
|
|
|
float denom = d2121 * d4343 - d4321 * d4321;
|
|
|
|
float numer = d1343 * d4321 - d1321 * d4343;
|
|
|
|
mua = numer / denom;
|
|
mua = clamp( mua, 0.0, 1.0 );
|
|
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
|
|
mub = clamp( mub, 0.0, 1.0 );
|
|
|
|
return vec2( mua, mub );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
#include <clipping_planes_fragment>
|
|
|
|
#ifdef USE_DASH
|
|
|
|
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
|
|
|
|
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
|
|
|
|
#endif
|
|
|
|
float alpha = opacity;
|
|
|
|
#ifdef WORLD_UNITS
|
|
|
|
// Find the closest points on the view ray and the line segment
|
|
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
|
|
vec3 lineDir = worldEnd - worldStart;
|
|
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
|
|
|
|
vec3 p1 = worldStart + lineDir * params.x;
|
|
vec3 p2 = rayEnd * params.y;
|
|
vec3 delta = p1 - p2;
|
|
float len = length( delta );
|
|
float norm = len / linewidth;
|
|
|
|
#ifndef USE_DASH
|
|
|
|
#ifdef USE_ALPHA_TO_COVERAGE
|
|
|
|
float dnorm = fwidth( norm );
|
|
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
|
|
|
|
#else
|
|
|
|
if ( norm > 0.5 ) {
|
|
|
|
discard;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#ifdef USE_ALPHA_TO_COVERAGE
|
|
|
|
// artifacts appear on some hardware if a derivative is taken within a conditional
|
|
float a = vUv.x;
|
|
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
float len2 = a * a + b * b;
|
|
float dlen = fwidth( len2 );
|
|
|
|
if ( abs( vUv.y ) > 1.0 ) {
|
|
|
|
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if ( abs( vUv.y ) > 1.0 ) {
|
|
|
|
float a = vUv.x;
|
|
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
|
|
float len2 = a * a + b * b;
|
|
|
|
if ( len2 > 1.0 ) discard;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
vec4 diffuseColor = vec4( diffuse, alpha );
|
|
|
|
#include <logdepthbuf_fragment>
|
|
#include <color_fragment>
|
|
|
|
gl_FragColor = vec4( diffuseColor.rgb, alpha );
|
|
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
|
|
}
|
|
`};class au extends Ln{constructor(e){super({type:"LineMaterial",uniforms:ja.clone(jt.line.uniforms),vertexShader:jt.line.vertexShader,fragmentShader:jt.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const xA=Object.freeze(Object.defineProperty({__proto__:null,LineMaterial:au},Symbol.toStringTag,{value:"Module"})),ad=new C,cd=new C,Ft=new nt,zt=new nt,On=new nt,al=new C,cl=new Ne,kt=new Am,ld=new C,fa=new wt,da=new Tt,Bn=new nt;let kn,as;function hd(s,e,t){return Bn.set(0,0,-e,1).applyMatrix4(s.projectionMatrix),Bn.multiplyScalar(1/Bn.w),Bn.x=as/t.width,Bn.y=as/t.height,Bn.applyMatrix4(s.projectionMatrixInverse),Bn.multiplyScalar(1/Bn.w),Math.abs(Math.max(Bn.x,Bn.y))}function ib(s,e){const t=s.matrixWorld,n=s.geometry,i=n.attributes.instanceStart,r=n.attributes.instanceEnd,o=Math.min(n.instanceCount,i.count);for(let a=0,c=o;a<c;a++){kt.start.fromBufferAttribute(i,a),kt.end.fromBufferAttribute(r,a),kt.applyMatrix4(t);const l=new C,h=new C;kn.distanceSqToSegment(kt.start,kt.end,h,l),h.distanceTo(l)<as*.5&&e.push({point:h,pointOnLine:l,distance:kn.origin.distanceTo(h),object:s,face:null,faceIndex:a,uv:null,uv1:null})}}function sb(s,e,t){const n=e.projectionMatrix,r=s.material.resolution,o=s.matrixWorld,a=s.geometry,c=a.attributes.instanceStart,l=a.attributes.instanceEnd,h=Math.min(a.instanceCount,c.count),u=-e.near;kn.at(1,On),On.w=1,On.applyMatrix4(e.matrixWorldInverse),On.applyMatrix4(n),On.multiplyScalar(1/On.w),On.x*=r.x/2,On.y*=r.y/2,On.z=0,al.copy(On),cl.multiplyMatrices(e.matrixWorldInverse,o);for(let f=0,d=h;f<d;f++){if(Ft.fromBufferAttribute(c,f),zt.fromBufferAttribute(l,f),Ft.w=1,zt.w=1,Ft.applyMatrix4(cl),zt.applyMatrix4(cl),Ft.z>u&&zt.z>u)continue;if(Ft.z>u){const _=Ft.z-zt.z,x=(Ft.z-u)/_;Ft.lerp(zt,x)}else if(zt.z>u){const _=zt.z-Ft.z,x=(zt.z-u)/_;zt.lerp(Ft,x)}Ft.applyMatrix4(n),zt.applyMatrix4(n),Ft.multiplyScalar(1/Ft.w),zt.multiplyScalar(1/zt.w),Ft.x*=r.x/2,Ft.y*=r.y/2,zt.x*=r.x/2,zt.y*=r.y/2,kt.start.copy(Ft),kt.start.z=0,kt.end.copy(zt),kt.end.z=0;const v=kt.closestPointToPointParameter(al,!0);kt.at(v,ld);const g=Ya.lerp(Ft.z,zt.z,v),m=g>=-1&&g<=1,y=al.distanceTo(ld)<as*.5;if(m&&y){kt.start.fromBufferAttribute(c,f),kt.end.fromBufferAttribute(l,f),kt.start.applyMatrix4(o),kt.end.applyMatrix4(o);const _=new C,x=new C;kn.distanceSqToSegment(kt.start,kt.end,x,_),t.push({point:x,pointOnLine:_,distance:kn.origin.distanceTo(x),object:s,face:null,faceIndex:f,uv:null,uv1:null})}}}class Tm extends ft{constructor(e=new ou,t=new au({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let o=0,a=0,c=t.count;o<c;o++,a+=2)ad.fromBufferAttribute(t,o),cd.fromBufferAttribute(n,o),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+ad.distanceTo(cd);const r=new Pa(i,2,1);return e.setAttribute("instanceDistanceStart",new $t(r,1,0)),e.setAttribute("instanceDistanceEnd",new $t(r,1,1)),this}raycast(e,t){const n=this.material.worldUnits,i=e.camera;i===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;kn=e.ray;const o=this.matrixWorld,a=this.geometry,c=this.material;as=c.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),da.copy(a.boundingSphere).applyMatrix4(o);let l;if(n)l=as*.5;else{const u=Math.max(i.near,da.distanceToPoint(kn.origin));l=hd(i,u,c.resolution)}if(da.radius+=l,kn.intersectsSphere(da)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),fa.copy(a.boundingBox).applyMatrix4(o);let h;if(n)h=as*.5;else{const u=Math.max(i.near,fa.distanceToPoint(kn.origin));h=hd(i,u,c.resolution)}fa.expandByScalar(h),kn.intersectsBox(fa)!==!1&&(n?ib(this,t):sb(this,i,t))}}const MA=Object.freeze(Object.defineProperty({__proto__:null,LineSegments2:Tm},Symbol.toStringTag,{value:"Module"}));class Em extends ou{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setColors(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}const SA=Object.freeze(Object.defineProperty({__proto__:null,LineGeometry:Em},Symbol.toStringTag,{value:"Module"}));class rb extends Tm{constructor(e=new Em,t=new au({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const bA=Object.freeze(Object.defineProperty({__proto__:null,Line2:rb},Symbol.toStringTag,{value:"Module"}));function ob(s,e,t=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!s.hasAttribute("position")||!s.hasAttribute("normal")||!s.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function n(o){if(o.normalized||o.isInterleavedBufferAttribute){const a=new Float32Array(o.count*o.itemSize);for(let c=0,l=0;c<o.count;c++)a[l++]=o.getX(c),a[l++]=o.getY(c),o.itemSize>2&&(a[l++]=o.getZ(c));return a}return o.array instanceof Float32Array?o.array:new Float32Array(o.array)}const i=s.index?s.toNonIndexed():s,r=e.generateTangents(n(i.attributes.position),n(i.attributes.normal),n(i.attributes.uv));if(t)for(let o=3;o<r.length;o+=4)r[o]*=-1;return i.setAttribute("tangent",new Fe(r,4)),s!==i&&s.copy(i),s}function Rm(s,e=!1){const t=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,c=new Be;let l=0;for(let h=0;h<s.length;++h){const u=s[h];let f=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;r[d]===void 0&&(r[d]=[]),r[d].push(u.attributes[d]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(e){let d;if(t)d=u.index.count;else if(u.attributes.position!==void 0)d=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,d,h),l+=d}}if(t){let h=0;const u=[];for(let f=0;f<s.length;++f){const d=s[f].index;for(let p=0;p<d.count;++p)u.push(d.getX(p)+h);h+=s[f].attributes.position.count}c.setIndex(u)}for(const h in r){const u=Ia(r[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;c.setAttribute(h,u)}for(const h in o){const u=o[h][0].length;if(u===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[h]=[];for(let f=0;f<u;++f){const d=[];for(let v=0;v<o[h].length;++v)d.push(o[h][v][f]);const p=Ia(d);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;c.morphAttributes[h].push(p)}}return c}function Ia(s){let e,t,n,i=-1,r=0;for(let l=0;l<s.length;++l){const h=s[l];if(h.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=h.array.length}const o=new e(r);let a=0;for(let l=0;l<s.length;++l)o.set(s[l].array,a),a+=s[l].array.length;const c=new Fe(o,t,n);return i!==void 0&&(c.gpuType=i),c}function ab(s){return s.isInstancedInterleavedBufferAttribute||s.isInterleavedBufferAttribute?Ua(s):s.isInstancedBufferAttribute?new ai().copy(s):new Fe().copy(s)}function cb(s){let e,t=0,n=0;for(let l=0,h=s.length;l<h;++l){const u=s[l];if(e===void 0&&(e=u.array.constructor),e!==u.array.constructor)return console.error("AttributeBuffers of different types cannot be interleaved"),null;t+=u.array.length,n+=u.itemSize}const i=new rr(new e(t),n);let r=0;const o=[],a=["getX","getY","getZ","getW"],c=["setX","setY","setZ","setW"];for(let l=0,h=s.length;l<h;l++){const u=s[l],f=u.itemSize,d=u.count,p=new $t(i,f,r,u.normalized);o.push(p),r+=f;for(let v=0;v<d;v++)for(let g=0;g<f;g++)p[c[g]](v,u[a[g]](v))}return o}function Ua(s){const e=s.data.array.constructor,t=s.count,n=s.itemSize,i=s.normalized,r=new e(t*n);let o;s.isInstancedInterleavedBufferAttribute?o=new ai(r,n,i,s.meshPerAttribute):o=new Fe(r,n,i);for(let a=0;a<t;a++)o.setX(a,s.getX(a)),n>=2&&o.setY(a,s.getY(a)),n>=3&&o.setZ(a,s.getZ(a)),n>=4&&o.setW(a,s.getW(a));return o}function lb(s){const e=s.attributes,t=s.morphTargets,n=new Map;for(const i in e){const r=e[i];r.isInterleavedBufferAttribute&&(n.has(r)||n.set(r,Ua(r)),e[i]=n.get(r))}for(const i in t){const r=t[i];r.isInterleavedBufferAttribute&&(n.has(r)||n.set(r,Ua(r)),t[i]=n.get(r))}}function hb(s){let e=0;for(const n in s.attributes){const i=s.getAttribute(n);e+=i.count*i.itemSize*i.array.BYTES_PER_ELEMENT}const t=s.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function ub(s,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},n=s.getIndex(),i=s.getAttribute("position"),r=n?n.count:i.count;let o=0;const a=Object.keys(s.attributes),c={},l={},h=[],u=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let y=0,_=a.length;y<_;y++){const x=a[y],T=s.attributes[x];c[x]=new Fe(new T.array.constructor(T.count*T.itemSize),T.itemSize,T.normalized);const b=s.morphAttributes[x];b&&(l[x]=new Fe(new b.array.constructor(b.count*b.itemSize),b.itemSize,b.normalized))}const d=e*.5,p=Math.log10(1/e),v=Math.pow(10,p),g=d*v;for(let y=0;y<r;y++){const _=n?n.getX(y):y;let x="";for(let T=0,b=a.length;T<b;T++){const A=a[T],L=s.getAttribute(A),M=L.itemSize;for(let w=0;w<M;w++)x+=`${~~(L[u[w]](_)*v+g)},`}if(x in t)h.push(t[x]);else{for(let T=0,b=a.length;T<b;T++){const A=a[T],L=s.getAttribute(A),M=s.morphAttributes[A],w=L.itemSize,O=c[A],H=l[A];for(let K=0;K<w;K++){const I=u[K],F=f[K];if(O[F](o,L[I](_)),M)for(let k=0,te=M.length;k<te;k++)H[k][F](o,M[k][I](_))}}t[x]=o,h.push(o),o++}}const m=s.clone();for(const y in s.attributes){const _=c[y];if(m.setAttribute(y,new Fe(_.array.slice(0,o*_.itemSize),_.itemSize,_.normalized)),y in l)for(let x=0;x<l[y].length;x++){const T=l[y][x];m.morphAttributes[y][x]=new Fe(T.array.slice(0,o*T.itemSize),T.itemSize,T.normalized)}}return m.setIndex(h),m}function ih(s,e){if(e===fp)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===Ea||e===Sh){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===Ea)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function fb(s){const e=new C,t=new C,n=new C,i=new C,r=new C,o=new C,a=new C,c=new C,l=new C;function h($,le,ce,ge,Z,U,N,V){e.fromBufferAttribute(le,Z),t.fromBufferAttribute(le,U),n.fromBufferAttribute(le,N);const W=$.morphTargetInfluences;if(ce&&W){a.set(0,0,0),c.set(0,0,0),l.set(0,0,0);for(let q=0,j=ce.length;q<j;q++){const Y=W[q],oe=ce[q];Y!==0&&(i.fromBufferAttribute(oe,Z),r.fromBufferAttribute(oe,U),o.fromBufferAttribute(oe,N),ge?(a.addScaledVector(i,Y),c.addScaledVector(r,Y),l.addScaledVector(o,Y)):(a.addScaledVector(i.sub(e),Y),c.addScaledVector(r.sub(t),Y),l.addScaledVector(o.sub(n),Y)))}e.add(a),t.add(c),n.add(l)}$.isSkinnedMesh&&($.applyBoneTransform(Z,e),$.applyBoneTransform(U,t),$.applyBoneTransform(N,n)),V[Z*3+0]=e.x,V[Z*3+1]=e.y,V[Z*3+2]=e.z,V[U*3+0]=t.x,V[U*3+1]=t.y,V[U*3+2]=t.z,V[N*3+0]=n.x,V[N*3+1]=n.y,V[N*3+2]=n.z}const u=s.geometry,f=s.material;let d,p,v;const g=u.index,m=u.attributes.position,y=u.morphAttributes.position,_=u.morphTargetsRelative,x=u.attributes.normal,T=u.morphAttributes.position,b=u.groups,A=u.drawRange;let L,M,w,O,H,K,I;const F=new Float32Array(m.count*m.itemSize),k=new Float32Array(x.count*x.itemSize);if(g!==null)if(Array.isArray(f))for(L=0,w=b.length;L<w;L++)for(H=b[L],K=Math.max(H.start,A.start),I=Math.min(H.start+H.count,A.start+A.count),M=K,O=I;M<O;M+=3)d=g.getX(M),p=g.getX(M+1),v=g.getX(M+2),h(s,m,y,_,d,p,v,F),h(s,x,T,_,d,p,v,k);else for(K=Math.max(0,A.start),I=Math.min(g.count,A.start+A.count),L=K,w=I;L<w;L+=3)d=g.getX(L),p=g.getX(L+1),v=g.getX(L+2),h(s,m,y,_,d,p,v,F),h(s,x,T,_,d,p,v,k);else if(Array.isArray(f))for(L=0,w=b.length;L<w;L++)for(H=b[L],K=Math.max(H.start,A.start),I=Math.min(H.start+H.count,A.start+A.count),M=K,O=I;M<O;M+=3)d=M,p=M+1,v=M+2,h(s,m,y,_,d,p,v,F),h(s,x,T,_,d,p,v,k);else for(K=Math.max(0,A.start),I=Math.min(m.count,A.start+A.count),L=K,w=I;L<w;L+=3)d=L,p=L+1,v=L+2,h(s,m,y,_,d,p,v,F),h(s,x,T,_,d,p,v,k);const te=new Ee(F,3),J=new Ee(k,3);return{positionAttribute:m,normalAttribute:x,morphedPositionAttribute:te,morphedNormalAttribute:J}}function db(s){if(s.groups.length===0)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),s;let e=s.groups;if(e=e.sort((o,a)=>o.materialIndex!==a.materialIndex?o.materialIndex-a.materialIndex:o.start-a.start),s.getIndex()===null){const o=s.getAttribute("position"),a=[];for(let c=0;c<o.count;c+=3)a.push(c,c+1,c+2);s.setIndex(a)}const t=s.getIndex(),n=[];for(let o=0;o<e.length;o++){const a=e[o],c=a.start,l=c+a.count;for(let h=c;h<l;h++)n.push(t.getX(h))}s.dispose(),s.setIndex(n);let i=0;for(let o=0;o<e.length;o++){const a=e[o];a.start=i,i+=a.count}let r=e[0];s.groups=[r];for(let o=1;o<e.length;o++){const a=e[o];r.materialIndex===a.materialIndex?r.count+=a.count:(r=a,s.groups.push(r))}return s}function pb(s,e=Math.PI/3){const t=Math.cos(e),n=(1+1e-10)*100,i=[new C,new C,new C],r=new C,o=new C,a=new C,c=new C;function l(v){const g=~~(v.x*n),m=~~(v.y*n),y=~~(v.z*n);return`${g},${m},${y}`}const h=s.index?s.toNonIndexed():s,u=h.attributes.position,f={};for(let v=0,g=u.count/3;v<g;v++){const m=3*v,y=i[0].fromBufferAttribute(u,m+0),_=i[1].fromBufferAttribute(u,m+1),x=i[2].fromBufferAttribute(u,m+2);r.subVectors(x,_),o.subVectors(y,_);const T=new C().crossVectors(r,o).normalize();for(let b=0;b<3;b++){const A=i[b],L=l(A);L in f||(f[L]=[]),f[L].push(T)}}const d=new Float32Array(u.count*3),p=new Fe(d,3,!1);for(let v=0,g=u.count/3;v<g;v++){const m=3*v,y=i[0].fromBufferAttribute(u,m+0),_=i[1].fromBufferAttribute(u,m+1),x=i[2].fromBufferAttribute(u,m+2);r.subVectors(x,_),o.subVectors(y,_),a.crossVectors(r,o).normalize();for(let T=0;T<3;T++){const b=i[T],A=l(b),L=f[A];c.set(0,0,0);for(let M=0,w=L.length;M<w;M++){const O=L[M];a.dot(O)>t&&c.add(O)}c.normalize(),p.setXYZ(m+T,c.x,c.y,c.z)}}return h.setAttribute("normal",p),h}function mb(s,e=!1){return console.warn("THREE.BufferGeometryUtils: mergeBufferGeometries() has been renamed to mergeGeometries()."),Rm(s,e)}function gb(s){return console.warn("THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes()."),Ia(s)}const AA=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:ob,computeMorphedAttributes:fb,deepCloneAttribute:ab,deinterleaveAttribute:Ua,deinterleaveGeometry:lb,estimateBytesUsed:hb,interleaveAttributes:cb,mergeAttributes:Ia,mergeBufferAttributes:gb,mergeBufferGeometries:mb,mergeGeometries:Rm,mergeGroups:db,mergeVertices:ub,toCreasedNormals:pb,toTrianglesDrawMode:ih},Symbol.toStringTag,{value:"Module"}));class vb extends Bt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Sb(t)}),this.register(function(t){return new Pb(t)}),this.register(function(t){return new Ib(t)}),this.register(function(t){return new Ub(t)}),this.register(function(t){return new Ab(t)}),this.register(function(t){return new wb(t)}),this.register(function(t){return new Tb(t)}),this.register(function(t){return new Eb(t)}),this.register(function(t){return new Mb(t)}),this.register(function(t){return new Rb(t)}),this.register(function(t){return new bb(t)}),this.register(function(t){return new Lb(t)}),this.register(function(t){return new Cb(t)}),this.register(function(t){return new yb(t)}),this.register(function(t){return new Nb(t)}),this.register(function(t){return new Db(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=wi.extractUrlBase(e);o=wi.resolveURL(l,this.path)}else o=wi.extractUrlBase(e);this.manager.itemStart(e);const a=function(l){i?i(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new fn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r;const o={},a={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Cm){try{o[Je.KHR_BINARY_GLTF]=new Ob(e)}catch(u){i&&i(u);return}r=JSON.parse(o[Je.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Kb(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const u=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(u){case Je.KHR_MATERIALS_UNLIT:o[u]=new xb;break;case Je.KHR_DRACO_MESH_COMPRESSION:o[u]=new Bb(r,this.dracoLoader);break;case Je.KHR_TEXTURE_TRANSFORM:o[u]=new Fb;break;case Je.KHR_MESH_QUANTIZATION:o[u]=new zb;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function _b(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const Je={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class yb{constructor(e){this.parser=e,this.name=Je.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let l;const h=new Te(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],Rt);const u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new eu(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Qh(h),l.distance=u;break;case"spot":l=new $h(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,xi(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),i=Promise.resolve(l),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}}class xb{constructor(){this.name=Je.KHR_MATERIALS_UNLIT}getMaterialType(){return hn}extendParams(e,t,n){const i=[];e.color=new Te(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],Rt),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,ht))}return Promise.all(i)}}class Mb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Sb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new ae(a,a)}return Promise.all(r)}}class bb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class Ab{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new Te(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],Rt)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,ht)),o.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class wb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class Tb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new Te().setRGB(a[0],a[1],a[2],Rt),Promise.all(r)}}class Eb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class Rb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new Te().setRGB(a[0],a[1],a[2],Rt),o.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,ht)),Promise.all(r)}}class Cb{constructor(e){this.parser=e,this.name=Je.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}}class Lb{constructor(e){this.parser=e,this.name=Je.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Un}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}}class Pb{constructor(e){this.parser=e,this.name=Je.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class Ib{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ub{constructor(e){this.parser=e,this.name=Je.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let c=n.textureLoader;if(a.uri){const l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Nb{constructor(e){this.name=Je.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const c=i.byteOffset||0,l=i.byteLength||0,h=i.count,u=i.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,i.mode,i.filter).then(function(d){return d.buffer}):o.ready.then(function(){const d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})})}else return null}}class Db{constructor(e){this.name=Je.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const l of i.primitives)if(l.mode!==gn.TRIANGLES&&l.mode!==gn.TRIANGLE_STRIP&&l.mode!==gn.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],c={};for(const l in o)a.push(this.parser.getDependency("accessor",o[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{const h=l.pop(),u=h.isGroup?h.children:[h],f=l[0].count,d=[];for(const p of u){const v=new Ne,g=new C,m=new Ot,y=new C(1,1,1),_=new Oh(p.geometry,p.material,f);for(let x=0;x<f;x++)c.TRANSLATION&&g.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&m.fromBufferAttribute(c.ROTATION,x),c.SCALE&&y.fromBufferAttribute(c.SCALE,x),_.setMatrixAt(x,v.compose(g,m,y));for(const x in c)if(x==="_COLOR_0"){const T=c[x];_.instanceColor=new ai(T.array,T.itemSize,T.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&p.geometry.setAttribute(x,c[x]);tt.prototype.copy.call(_,p),this.parser.assignFinalMaterial(_),d.push(_)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}}const Cm="glTF",Cr=12,ud={JSON:1313821514,BIN:5130562};class Ob{constructor(e){this.name=Je.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Cr),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Cm)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-Cr,r=new DataView(e,Cr);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const c=r.getUint32(o,!0);if(o+=4,c===ud.JSON){const l=new Uint8Array(e,Cr+o,a);this.content=n.decode(l)}else if(c===ud.BIN){const l=Cr+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Bb{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Je.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const h in o){const u=sh[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=sh[h]||h.toLowerCase();if(o[h]!==void 0){const f=n.accessors[e.attributes[h]],d=Zs[f.componentType];l[u]=d.name,c[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,f){i.decodeDracoFile(h,function(d){for(const p in d.attributes){const v=d.attributes[p],g=c[p];g!==void 0&&(v.normalized=g)}u(d)},a,l,Rt,f)})})}}class Fb{constructor(){this.name=Je.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class zb{constructor(){this.name=Je.KHR_MESH_QUANTIZATION}}class Lm extends cr{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=i-t,u=(n-t)/h,f=u*u,d=f*u,p=e*l,v=p-l,g=-2*d+3*f,m=d-f,y=1-g,_=m-f+u;for(let x=0;x!==a;x++){const T=o[v+x+a],b=o[v+x+c]*h,A=o[p+x+a],L=o[p+x]*h;r[x]=y*T+_*b+g*A+m*L}return r}}const kb=new Ot;class Hb extends Lm{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return kb.fromArray(r).normalize().toArray(r),r}}const gn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Zs={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},fd={9728:dt,9729:at,9984:zr,9985:Va,9986:qs,9987:Mn},dd={33071:At,33648:Ri,10497:vn},ll={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},sh={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_i={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Gb={CUBICSPLINE:void 0,LINEAR:ls,STEP:js},hl={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Vb(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new ar({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Gn})),s.DefaultMaterial}function Yi(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function xi(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Wb(s,e,t){let n=!1,i=!1,r=!1;for(let l=0,h=e.length;l<h;l++){const u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){const u=e[l];if(n){const f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(f)}if(r){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){const h=l[0],u=l[1],f=l[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function Xb(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function qb(s){let e;const t=s.extensions&&s.extensions[Je.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ul(t.attributes):e=s.indices+":"+ul(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+ul(s.targets[n]);return e}function ul(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function rh(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Yb(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Zb=new Ne;class Kb{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new _b,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;typeof navigator<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&r<98?this.textureLoader=new jh(this.options.manager):this.textureLoader=new ym(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new fn(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return Yi(r,a,i),xi(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){const o=t[i].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(o,a)=>{const c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(const[l,h]of o.children.entries())r(h,a.children[l])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Je.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(wi.resolveURL(t.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=ll[i.type],a=Zs[i.componentType],c=i.normalized===!0,l=new a(i.count*o);return Promise.resolve(new Fe(l,o,c))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],c=ll[i.type],l=Zs[i.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,f=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,p=i.normalized===!0;let v,g;if(d&&d!==u){const m=Math.floor(f/d),y="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+m+":"+i.count;let _=t.cache.get(y);_||(v=new l(a,m*d,i.count*d/h),_=new rr(v,d/h),t.cache.add(y,_)),g=new $t(_,c,f%d/h,p)}else a===null?v=new l(i.count*c):v=new l(a,f,i.count*c),g=new Fe(v,c,p);if(i.sparse!==void 0){const m=ll.SCALAR,y=Zs[i.sparse.indices.componentType],_=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,T=new y(o[1],_,i.sparse.count*m),b=new l(o[2],x,i.sparse.count*c);a!==null&&(g=new Fe(g.array.slice(),g.itemSize,g.normalized));for(let A=0,L=T.length;A<L;A++){const M=T[A];if(g.setX(M,b[A*c]),c>=2&&g.setY(M,b[A*c+1]),c>=3&&g.setZ(M,b[A*c+2]),c>=4&&g.setW(M,b[A*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(r.samplers||{})[o.sampler]||{};return h.magFilter=fd[f.magFilter]||at,h.minFilter=fd[f.minFilter]||Mn,h.wrapS=dd[f.wrapS]||vn,h.wrapT=dd[f.wrapT]||vn,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(u){l=!0;const f=new Blob([u],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(c).then(function(u){return new Promise(function(f,d){let p=f;t.isImageBitmapLoader===!0&&(p=function(v){const g=new gt(v);g.needsUpdate=!0,f(g)}),t.load(wi.resolveURL(u,r.path),p,void 0,d)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),u.userData.mimeType=o.mimeType||Yb(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[Je.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[Je.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=r.associations.get(o);o=r.extensions[Je.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new nc,Et.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new Xt,Et.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),r&&(c.vertexColors=!0),o&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return ar}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},c=r.extensions||{},l=[];if(c[Je.KHR_MATERIALS_UNLIT]){const u=i[Je.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new Te(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Rt),a.opacity=f[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,ht)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Tn);const h=r.alphaMode||hl.OPAQUE;if(h===hl.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===hl.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==hn&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new ae(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==hn&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==hn){const u=r.emissiveFactor;a.emissive=new Te().setRGB(u[0],u[1],u[2],Rt)}return r.emissiveTexture!==void 0&&o!==hn&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,ht)),Promise.all(l).then(function(){const u=new o(a);return r.name&&(u.name=r.name),xi(u,r),t.associations.set(u,{materials:e}),r.extensions&&Yi(i,u,r),u})}createUniqueName(e){const t=et.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[Je.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return pd(c,a,t)})}const o=[];for(let a=0,c=e.length;a<c;a++){const l=e[a],h=qb(l),u=i[h];if(u)o.push(u.promise);else{let f;l.extensions&&l.extensions[Je.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=pd(new Be,l,t),i[h]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let c=0,l=o.length;c<l;c++){const h=o[c].material===void 0?Vb(this.cache):this.getDependency("material",o[c].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){const l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let d=0,p=h.length;d<p;d++){const v=h[d],g=o[d];let m;const y=l[d];if(g.mode===gn.TRIANGLES||g.mode===gn.TRIANGLE_STRIP||g.mode===gn.TRIANGLE_FAN||g.mode===void 0)m=r.isSkinnedMesh===!0?new Dh(v,y):new ft(v,y),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),g.mode===gn.TRIANGLE_STRIP?m.geometry=ih(m.geometry,Sh):g.mode===gn.TRIANGLE_FAN&&(m.geometry=ih(m.geometry,Ea));else if(g.mode===gn.LINES)m=new Pn(v,y);else if(g.mode===gn.LINE_STRIP)m=new ci(v,y);else if(g.mode===gn.LINE_LOOP)m=new Bh(v,y);else if(g.mode===gn.POINTS)m=new Fh(v,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(m.geometry.morphAttributes).length>0&&Xb(m,r),m.name=t.createUniqueName(r.name||"mesh_"+e),xi(m,r),g.extensions&&Yi(i,m,g),t.assignFinalMaterial(m),u.push(m)}for(let d=0,p=u.length;d<p;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return r.extensions&&Yi(i,u[0],r),u[0];const f=new _n;r.extensions&&Yi(i,f,r),t.associations.set(f,{meshes:e});for(let d=0,p=u.length;d<p;d++)f.add(u[d]);return f})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new Nt(Ya.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new oo(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),xi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),o=i,a=[],c=[];for(let l=0,h=o.length;l<h;l++){const u=o[l];if(u){a.push(u);const f=new Ne;r!==null&&f.fromArray(r.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new ao(a,c)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];for(let u=0,f=i.channels.length;u<f;u++){const d=i.channels[u],p=i.samplers[d.sampler],v=d.target,g=v.node,m=i.parameters!==void 0?i.parameters[p.input]:p.input,y=i.parameters!==void 0?i.parameters[p.output]:p.output;v.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",m)),c.push(this.getDependency("accessor",y)),l.push(p),h.push(v))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){const f=u[0],d=u[1],p=u[2],v=u[3],g=u[4],m=[];for(let y=0,_=f.length;y<_;y++){const x=f[y],T=d[y],b=p[y],A=v[y],L=g[y];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const M=n._createAnimationTracks(x,T,b,A,L);if(M)for(let w=0;w<M.length;w++)m.push(M[w])}return new er(r,void 0,m)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=i.weights.length;c<l;c++)a.morphTargetInfluences[c]=i.weights[c]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=i.children||[];for(let l=0,h=a.length;l<h;l++)o.push(n.getDependency("node",a[l]));const c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){const h=l[0],u=l[1],f=l[2];f!==null&&h.traverse(function(d){d.isSkinnedMesh&&d.bind(f,Zb)});for(let d=0,p=u.length;d<p;d++)h.add(u[d]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"",a=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(l){return i._getNodeRef(i.cameraCache,r.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(r.isBone===!0?h=new tc:l.length>1?h=new _n:l.length===1?h=l[0]:h=new tt,h!==l[0])for(let u=0,f=l.length;u<f;u++)h.add(l[u]);if(r.name&&(h.userData.name=r.name,h.name=o),xi(h,r),r.extensions&&Yi(n,h,r),r.matrix!==void 0){const u=new Ne;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return i.associations.has(h)||i.associations.set(h,{}),i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new _n;n.name&&(r.name=i.createUniqueName(n.name)),xi(r,n),n.extensions&&Yi(t,r,n);const o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(i.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++)r.add(c[h]);const l=h=>{const u=new Map;for(const[f,d]of i.associations)(f instanceof Et||f instanceof gt)&&u.set(f,d);return h.traverse(f=>{const d=i.associations.get(f);d!=null&&u.set(f,d)}),u};return i.associations=l(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,c=[];_i[r.path]===_i.weights?e.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(_i[r.path]){case _i.weights:l=us;break;case _i.rotation:l=Ci;break;case _i.position:case _i.scale:l=fs;break;default:n.itemSize===1?l=us:l=fs;break}const h=i.interpolation!==void 0?Gb[i.interpolation]:ls,u=this._getArrayFromAccessor(n);for(let f=0,d=c.length;f<d;f++){const p=new l(c[f]+"."+_i[r.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(p),o.push(p)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=rh(t.constructor),i=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof Ci?Hb:Lm;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function jb(s,e,t){const n=e.attributes,i=new wt;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(i.set(new C(c[0],c[1],c[2]),new C(l[0],l[1],l[2])),a.normalized){const h=rh(Zs[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new C,c=new C;for(let l=0,h=r.length;l<h;l++){const u=r[l];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],d=f.min,p=f.max;if(d!==void 0&&p!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(p[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(p[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(p[2]))),f.normalized){const v=rh(Zs[f.componentType]);c.multiplyScalar(v)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new Tt;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function pd(s,e,t){const n=e.attributes,i=[];function r(o,a){return t.getDependency("accessor",o).then(function(c){s.setAttribute(a,c)})}for(const o in n){const a=sh[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(e.indices!==void 0&&!s.index){const o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});i.push(o)}return rt.workingColorSpace!==Rt&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${rt.workingColorSpace}" not supported.`),xi(s,e),jb(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?Wb(s,e.targets,t):s})}const wA=Object.freeze(Object.defineProperty({__proto__:null,GLTFLoader:vb},Symbol.toStringTag,{value:"Module"}));class Jb extends Bt{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new fn(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){function t(l){const h=new DataView(l),u=32/8*3+32/8*3*3+16/8,f=h.getUint32(80,!0);if(80+32/8+f*u===h.byteLength)return!0;const p=[115,111,108,105,100];for(let v=0;v<5;v++)if(n(p,h,v))return!1;return!0}function n(l,h,u){for(let f=0,d=l.length;f<d;f++)if(l[f]!==h.getUint8(u+f))return!1;return!0}function i(l){const h=new DataView(l),u=h.getUint32(80,!0);let f,d,p,v=!1,g,m,y,_,x;for(let O=0;O<70;O++)h.getUint32(O,!1)==1129270351&&h.getUint8(O+4)==82&&h.getUint8(O+5)==61&&(v=!0,g=new Float32Array(u*3*3),m=h.getUint8(O+6)/255,y=h.getUint8(O+7)/255,_=h.getUint8(O+8)/255,x=h.getUint8(O+9)/255);const T=84,b=50,A=new Be,L=new Float32Array(u*3*3),M=new Float32Array(u*3*3),w=new Te;for(let O=0;O<u;O++){const H=T+O*b,K=h.getFloat32(H,!0),I=h.getFloat32(H+4,!0),F=h.getFloat32(H+8,!0);if(v){const k=h.getUint16(H+48,!0);(k&32768)===0?(f=(k&31)/31,d=(k>>5&31)/31,p=(k>>10&31)/31):(f=m,d=y,p=_)}for(let k=1;k<=3;k++){const te=H+k*12,J=O*3*3+(k-1)*3;L[J]=h.getFloat32(te,!0),L[J+1]=h.getFloat32(te+4,!0),L[J+2]=h.getFloat32(te+8,!0),M[J]=K,M[J+1]=I,M[J+2]=F,v&&(w.set(f,d,p).convertSRGBToLinear(),g[J]=w.r,g[J+1]=w.g,g[J+2]=w.b)}}return A.setAttribute("position",new Fe(L,3)),A.setAttribute("normal",new Fe(M,3)),v&&(A.setAttribute("color",new Fe(g,3)),A.hasColors=!0,A.alpha=x),A}function r(l){const h=new Be,u=/solid([\s\S]*?)endsolid/g,f=/facet([\s\S]*?)endfacet/g,d=/solid\s(.+)/;let p=0;const v=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,g=new RegExp("vertex"+v+v+v,"g"),m=new RegExp("normal"+v+v+v,"g"),y=[],_=[],x=[],T=new C;let b,A=0,L=0,M=0;for(;(b=u.exec(l))!==null;){L=M;const w=b[0],O=(b=d.exec(w))!==null?b[1]:"";for(x.push(O);(b=f.exec(w))!==null;){let I=0,F=0;const k=b[0];for(;(b=m.exec(k))!==null;)T.x=parseFloat(b[1]),T.y=parseFloat(b[2]),T.z=parseFloat(b[3]),F++;for(;(b=g.exec(k))!==null;)y.push(parseFloat(b[1]),parseFloat(b[2]),parseFloat(b[3])),_.push(T.x,T.y,T.z),I++,M++;F!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+p),I!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+p),p++}const H=L,K=M-L;h.userData.groupNames=x,h.addGroup(H,K,A),A++}return h.setAttribute("position",new Ee(y,3)),h.setAttribute("normal",new Ee(_,3)),h}function o(l){return typeof l!="string"?new TextDecoder().decode(l):l}function a(l){if(typeof l=="string"){const h=new Uint8Array(l.length);for(let u=0;u<l.length;u++)h[u]=l.charCodeAt(u)&255;return h.buffer||h}else return l}const c=a(e);return t(c)?i(c):r(o(e))}}const TA=Object.freeze(Object.defineProperty({__proto__:null,STLLoader:Jb},Symbol.toStringTag,{value:"Module"}));var md={},oh=function(s){return URL.createObjectURL(new Blob([s],{type:"text/javascript"}))},Pm=function(s){return new Worker(s)};try{URL.revokeObjectURL(oh(""))}catch{oh=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Pm=function(e){return new Worker(e,{type:"module"})}}var $b=(function(s,e,t,n,i){var r=Pm(md[e]||(md[e]=oh(s)));return r.onerror=function(o){return i(o.error,null)},r.onmessage=function(o){return i(null,o.data)},r.postMessage(t,n),r}),$e=Uint8Array,Dt=Uint16Array,li=Uint32Array,lr=new $e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),hr=new $e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Jr=new $e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Im=function(s,e){for(var t=new Dt(31),n=0;n<31;++n)t[n]=e+=1<<s[n-1];for(var i=new li(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)i[r]=r-t[n]<<5|n;return[t,i]},Um=Im(lr,2),cu=Um[0],Na=Um[1];cu[28]=258,Na[258]=28;var Nm=Im(hr,0),Dm=Nm[0],ah=Nm[1],$r=new Dt(32768);for(var ut=0;ut<32768;++ut){var yi=(ut&43690)>>>1|(ut&21845)<<1;yi=(yi&52428)>>>2|(yi&13107)<<2,yi=(yi&61680)>>>4|(yi&3855)<<4,$r[ut]=((yi&65280)>>>8|(yi&255)<<8)>>>1}var yn=(function(s,e,t){for(var n=s.length,i=0,r=new Dt(e);i<n;++i)++r[s[i]-1];var o=new Dt(e);for(i=0;i<e;++i)o[i]=o[i-1]+r[i-1]<<1;var a;if(t){a=new Dt(1<<e);var c=15-e;for(i=0;i<n;++i)if(s[i])for(var l=i<<4|s[i],h=e-s[i],u=o[s[i]-1]++<<h,f=u|(1<<h)-1;u<=f;++u)a[$r[u]>>>c]=l}else for(a=new Dt(n),i=0;i<n;++i)s[i]&&(a[i]=$r[o[s[i]-1]++]>>>15-s[i]);return a}),hi=new $e(288);for(var ut=0;ut<144;++ut)hi[ut]=8;for(var ut=144;ut<256;++ut)hi[ut]=9;for(var ut=256;ut<280;++ut)hi[ut]=7;for(var ut=280;ut<288;++ut)hi[ut]=8;var tr=new $e(32);for(var ut=0;ut<32;++ut)tr[ut]=5;var Om=yn(hi,9,0),Bm=yn(hi,9,1),Fm=yn(tr,5,0),zm=yn(tr,5,1),Sa=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},mn=function(s,e,t){var n=e/8|0;return(s[n]|s[n+1]<<8)>>(e&7)&t},ba=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},uo=function(s){return(s/8|0)+(s&7&&1)},xn=function(s,e,t){(e==null||e<0)&&(e=0),(t==null||t>s.length)&&(t=s.length);var n=new(s instanceof Dt?Dt:s instanceof li?li:$e)(t-e);return n.set(s.subarray(e,t)),n},fo=function(s,e,t){var n=s.length;if(!n||t&&!t.l&&n<5)return e||new $e(0);var i=!e||t,r=!t||t.i;t||(t={}),e||(e=new $e(n*3));var o=function(V){var W=e.length;if(V>W){var q=new $e(Math.max(W*2,V));q.set(e),e=q}},a=t.f||0,c=t.p||0,l=t.b||0,h=t.l,u=t.d,f=t.m,d=t.n,p=n*8;do{if(!h){t.f=a=mn(s,c,1);var v=mn(s,c+1,3);if(c+=3,v)if(v==1)h=Bm,u=zm,f=9,d=5;else if(v==2){var _=mn(s,c,31)+257,x=mn(s,c+10,15)+4,T=_+mn(s,c+5,31)+1;c+=14;for(var b=new $e(T),A=new $e(19),L=0;L<x;++L)A[Jr[L]]=mn(s,c+L*3,7);c+=x*3;for(var M=Sa(A),w=(1<<M)-1,O=yn(A,M,1),L=0;L<T;){var H=O[mn(s,c,w)];c+=H&15;var g=H>>>4;if(g<16)b[L++]=g;else{var K=0,I=0;for(g==16?(I=3+mn(s,c,3),c+=2,K=b[L-1]):g==17?(I=3+mn(s,c,7),c+=3):g==18&&(I=11+mn(s,c,127),c+=7);I--;)b[L++]=K}}var F=b.subarray(0,_),k=b.subarray(_);f=Sa(F),d=Sa(k),h=yn(F,f,1),u=yn(k,d,1)}else throw"invalid block type";else{var g=uo(c)+4,m=s[g-4]|s[g-3]<<8,y=g+m;if(y>n){if(r)throw"unexpected EOF";break}i&&o(l+m),e.set(s.subarray(g,y),l),t.b=l+=m,t.p=c=y*8;continue}if(c>p){if(r)throw"unexpected EOF";break}}i&&o(l+131072);for(var te=(1<<f)-1,J=(1<<d)-1,$=c;;$=c){var K=h[ba(s,c)&te],le=K>>>4;if(c+=K&15,c>p){if(r)throw"unexpected EOF";break}if(!K)throw"invalid length/literal";if(le<256)e[l++]=le;else if(le==256){$=c,h=null;break}else{var ce=le-254;if(le>264){var L=le-257,ge=lr[L];ce=mn(s,c,(1<<ge)-1)+cu[L],c+=ge}var Z=u[ba(s,c)&J],U=Z>>>4;if(!Z)throw"invalid distance";c+=Z&15;var k=Dm[U];if(U>3){var ge=hr[U];k+=ba(s,c)&(1<<ge)-1,c+=ge}if(c>p){if(r)throw"unexpected EOF";break}i&&o(l+131072);for(var N=l+ce;l<N;l+=4)e[l]=e[l-k],e[l+1]=e[l+1-k],e[l+2]=e[l+2-k],e[l+3]=e[l+3-k];l=N}}t.l=h,t.p=$,t.b=l,h&&(a=1,t.m=f,t.d=u,t.n=d)}while(!a);return l==e.length?e:xn(e,0,l)},Fn=function(s,e,t){t<<=e&7;var n=e/8|0;s[n]|=t,s[n+1]|=t>>>8},zs=function(s,e,t){t<<=e&7;var n=e/8|0;s[n]|=t,s[n+1]|=t>>>8,s[n+2]|=t>>>16},Aa=function(s,e){for(var t=[],n=0;n<s.length;++n)s[n]&&t.push({s:n,f:s[n]});var i=t.length,r=t.slice();if(!i)return[ni,0];if(i==1){var o=new $e(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort(function(T,b){return T.f-b.f}),t.push({s:-1,f:25001});var a=t[0],c=t[1],l=0,h=1,u=2;for(t[0]={s:-1,f:a.f+c.f,l:a,r:c};h!=i-1;)a=t[t[l].f<t[u].f?l++:u++],c=t[l!=h&&t[l].f<t[u].f?l++:u++],t[h++]={s:-1,f:a.f+c.f,l:a,r:c};for(var f=r[0].s,n=1;n<i;++n)r[n].s>f&&(f=r[n].s);var d=new Dt(f+1),p=Da(t[h-1],d,0);if(p>e){var n=0,v=0,g=p-e,m=1<<g;for(r.sort(function(b,A){return d[A.s]-d[b.s]||b.f-A.f});n<i;++n){var y=r[n].s;if(d[y]>e)v+=m-(1<<p-d[y]),d[y]=e;else break}for(v>>>=g;v>0;){var _=r[n].s;d[_]<e?v-=1<<e-d[_]++-1:++n}for(;n>=0&&v;--n){var x=r[n].s;d[x]==e&&(--d[x],++v)}p=e}return[new $e(d),p]},Da=function(s,e,t){return s.s==-1?Math.max(Da(s.l,e,t+1),Da(s.r,e,t+1)):e[s.s]=t},ch=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new Dt(++e),n=0,i=s[0],r=1,o=function(c){t[n++]=c},a=1;a<=e;++a)if(s[a]==i&&a!=e)++r;else{if(!i&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(i),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(i);r=1,i=s[a]}return[t.subarray(0,n),e]},ks=function(s,e){for(var t=0,n=0;n<e.length;++n)t+=s[n]*e[n];return t},Dr=function(s,e,t){var n=t.length,i=uo(e+2);s[i]=n&255,s[i+1]=n>>>8,s[i+2]=s[i]^255,s[i+3]=s[i+1]^255;for(var r=0;r<n;++r)s[i+r+4]=t[r];return(i+4+n)*8},lh=function(s,e,t,n,i,r,o,a,c,l,h){Fn(e,h++,t),++i[256];for(var u=Aa(i,15),f=u[0],d=u[1],p=Aa(r,15),v=p[0],g=p[1],m=ch(f),y=m[0],_=m[1],x=ch(v),T=x[0],b=x[1],A=new Dt(19),L=0;L<y.length;++L)A[y[L]&31]++;for(var L=0;L<T.length;++L)A[T[L]&31]++;for(var M=Aa(A,7),w=M[0],O=M[1],H=19;H>4&&!w[Jr[H-1]];--H);var K=l+5<<3,I=ks(i,hi)+ks(r,tr)+o,F=ks(i,f)+ks(r,v)+o+14+3*H+ks(A,w)+(2*A[16]+3*A[17]+7*A[18]);if(K<=I&&K<=F)return Dr(e,h,s.subarray(c,c+l));var k,te,J,$;if(Fn(e,h,1+(F<I)),h+=2,F<I){k=yn(f,d,0),te=f,J=yn(v,g,0),$=v;var le=yn(w,O,0);Fn(e,h,_-257),Fn(e,h+5,b-1),Fn(e,h+10,H-4),h+=14;for(var L=0;L<H;++L)Fn(e,h+3*L,w[Jr[L]]);h+=3*H;for(var ce=[y,T],ge=0;ge<2;++ge)for(var Z=ce[ge],L=0;L<Z.length;++L){var U=Z[L]&31;Fn(e,h,le[U]),h+=w[U],U>15&&(Fn(e,h,Z[L]>>>5&127),h+=Z[L]>>>12)}}else k=Om,te=hi,J=Fm,$=tr;for(var L=0;L<a;++L)if(n[L]>255){var U=n[L]>>>18&31;zs(e,h,k[U+257]),h+=te[U+257],U>7&&(Fn(e,h,n[L]>>>23&31),h+=lr[U]);var N=n[L]&31;zs(e,h,J[N]),h+=$[N],N>3&&(zs(e,h,n[L]>>>5&8191),h+=hr[N])}else zs(e,h,k[n[L]]),h+=te[n[L]];return zs(e,h,k[256]),h+te[256]},km=new li([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ni=new $e(0),Hm=function(s,e,t,n,i,r){var o=s.length,a=new $e(n+o+5*(1+Math.ceil(o/7e3))+i),c=a.subarray(n,a.length-i),l=0;if(!e||o<8)for(var h=0;h<=o;h+=65535){var u=h+65535;u<o?l=Dr(c,l,s.subarray(h,u)):(c[h]=r,l=Dr(c,l,s.subarray(h,o)))}else{for(var f=km[e-1],d=f>>>13,p=f&8191,v=(1<<t)-1,g=new Dt(32768),m=new Dt(v+1),y=Math.ceil(t/3),_=2*y,x=function(G){return(s[G]^s[G+1]<<y^s[G+2]<<_)&v},T=new li(25e3),b=new Dt(288),A=new Dt(32),L=0,M=0,h=0,w=0,O=0,H=0;h<o;++h){var K=x(h),I=h&32767,F=m[K];if(g[I]=F,m[K]=I,O<=h){var k=o-h;if((L>7e3||w>24576)&&k>423){l=lh(s,c,0,T,b,A,M,w,H,h-H,l),w=L=M=0,H=h;for(var te=0;te<286;++te)b[te]=0;for(var te=0;te<30;++te)A[te]=0}var J=2,$=0,le=p,ce=I-F&32767;if(k>2&&K==x(h-ce))for(var ge=Math.min(d,k)-1,Z=Math.min(32767,h),U=Math.min(258,k);ce<=Z&&--le&&I!=F;){if(s[h+J]==s[h+J-ce]){for(var N=0;N<U&&s[h+N]==s[h+N-ce];++N);if(N>J){if(J=N,$=ce,N>ge)break;for(var V=Math.min(ce,N-2),W=0,te=0;te<V;++te){var q=h-ce+te+32768&32767,j=g[q],Y=q-j+32768&32767;Y>W&&(W=Y,F=q)}}}I=F,F=g[I],ce+=I-F+32768&32767}if($){T[w++]=268435456|Na[J]<<18|ah[$];var oe=Na[J]&31,R=ah[$]&31;M+=lr[oe]+hr[R],++b[257+oe],++A[R],O=h+J,++L}else T[w++]=s[h],++b[s[h]]}}l=lh(s,c,r,T,b,A,M,w,H,h-H,l),!r&&l&7&&(l=Dr(c,l+1,ni))}return xn(a,0,n+uo(l)+i)},Gm=(function(){for(var s=new li(256),e=0;e<256;++e){for(var t=e,n=9;--n;)t=(t&1&&3988292384)^t>>>1;s[e]=t}return s})(),ur=function(){var s=-1;return{p:function(e){for(var t=s,n=0;n<e.length;++n)t=Gm[t&255^e[n]]^t>>>8;s=t},d:function(){return~s}}},lu=function(){var s=1,e=0;return{p:function(t){for(var n=s,i=e,r=t.length,o=0;o!=r;){for(var a=Math.min(o+2655,r);o<a;++o)i+=n+=t[o];n=(n&65535)+15*(n>>16),i=(i&65535)+15*(i>>16)}s=n,e=i},d:function(){return s%=65521,e%=65521,(s&255)<<24|s>>>8<<16|(e&255)<<8|e>>>8}}},vs=function(s,e,t,n,i){return Hm(s,e.level==null?6:e.level,e.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(s.length)))*1.5):12+e.mem,t,n,!i)},po=function(s,e){var t={};for(var n in s)t[n]=s[n];for(var n in e)t[n]=e[n];return t},gd=function(s,e,t){for(var n=s(),i=s.toString(),r=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o<n.length;++o){var a=n[o],c=r[o];if(typeof a=="function"){e+=";"+c+"=";var l=a.toString();if(a.prototype)if(l.indexOf("[native code]")!=-1){var h=l.indexOf(" ",8)+1;e+=l.slice(h,l.indexOf("(",h))}else{e+=l;for(var u in a.prototype)e+=";"+c+".prototype."+u+"="+a.prototype[u].toString()}else e+=l}else t[c]=a}return[e,t]},pa=[],Qb=function(s){var e=[];for(var t in s)(s[t]instanceof $e||s[t]instanceof Dt||s[t]instanceof li)&&e.push((s[t]=new s[t].constructor(s[t])).buffer);return e},Vm=function(s,e,t,n){var i;if(!pa[t]){for(var r="",o={},a=s.length-1,c=0;c<a;++c)i=gd(s[c],r,o),r=i[0],o=i[1];pa[t]=gd(s[a],r,o)}var l=po({},pa[t][1]);return $b(pa[t][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",t,l,Qb(l),n)},fr=function(){return[$e,Dt,li,lr,hr,Jr,cu,Dm,Bm,zm,$r,yn,Sa,mn,ba,uo,xn,fo,gr,Ni,hu]},dr=function(){return[$e,Dt,li,lr,hr,Jr,Na,ah,Om,hi,Fm,tr,$r,km,ni,yn,Fn,zs,Aa,Da,ch,ks,Dr,lh,uo,xn,Hm,vs,mo,Ni]},Wm=function(){return[uu,du,ot,ur,Gm]},Xm=function(){return[fu,Zm]},qm=function(){return[pu,ot,lu]},Ym=function(){return[Km]},Ni=function(s){return postMessage(s,[s.buffer])},hu=function(s){return s&&s.size&&new $e(s.size)},pr=function(s,e,t,n,i,r){var o=Vm(t,n,i,function(a,c){o.terminate(),r(a,c)});return o.postMessage([s,e],e.consume?[s.buffer]:[]),function(){o.terminate()}},Sn=function(s){return s.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(e){return s.push(e.data[0],e.data[1])}},mr=function(s,e,t,n,i){var r,o=Vm(s,n,i,function(a,c){a?(o.terminate(),e.ondata.call(e,a)):(c[1]&&o.terminate(),e.ondata.call(e,a,c[0],c[1]))});o.postMessage(t),e.push=function(a,c){if(r)throw"stream finished";if(!e.ondata)throw"no stream handler";o.postMessage([a,r=c],[a.buffer])},e.terminate=function(){o.terminate()}},Jt=function(s,e){return s[e]|s[e+1]<<8},St=function(s,e){return(s[e]|s[e+1]<<8|s[e+2]<<16|s[e+3]<<24)>>>0},fl=function(s,e){return St(s,e)+St(s,e+4)*4294967296},ot=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8},uu=function(s,e){var t=e.filename;if(s[0]=31,s[1]=139,s[2]=8,s[8]=e.level<2?4:e.level==9?2:0,s[9]=3,e.mtime!=0&&ot(s,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),t){s[3]=8;for(var n=0;n<=t.length;++n)s[n+10]=t.charCodeAt(n)}},fu=function(s){if(s[0]!=31||s[1]!=139||s[2]!=8)throw"invalid gzip data";var e=s[3],t=10;e&4&&(t+=s[10]|(s[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!s[t++]);return t+(e&2)},Zm=function(s){var e=s.length;return(s[e-4]|s[e-3]<<8|s[e-2]<<16|s[e-1]<<24)>>>0},du=function(s){return 10+(s.filename&&s.filename.length+1||0)},pu=function(s,e){var t=e.level,n=t==0?0:t<6?1:t==9?3:2;s[0]=120,s[1]=n<<6|(n?32-2*n:1)},Km=function(s){if((s[0]&15)!=8||s[0]>>>4>7||(s[0]<<8|s[1])%31)throw"invalid zlib data";if(s[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function mu(s,e){return!e&&typeof s=="function"&&(e=s,s={}),this.ondata=e,s}var Vn=(function(){function s(e,t){!t&&typeof e=="function"&&(t=e,e={}),this.ondata=t,this.o=e||{}}return s.prototype.p=function(e,t){this.ondata(vs(e,this.o,0,0,!t),t)},s.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},s})(),jm=(function(){function s(e,t){mr([dr,function(){return[Sn,Vn]}],this,mu.call(this,e,t),function(n){var i=new Vn(n.data);onmessage=Sn(i)},6)}return s})();function Jm(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return pr(s,e,[dr],function(n){return Ni(mo(n.data[0],n.data[1]))},0,t)}function mo(s,e){return vs(s,e||{},0,0)}var rn=(function(){function s(e){this.s={},this.p=new $e(0),this.ondata=e}return s.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new $e(t+e.length);n.set(this.p),n.set(e,t),this.p=n},s.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=fo(this.p,this.o,this.s);this.ondata(xn(n,t,this.s.b),this.d),this.o=xn(n,this.s.b-32768),this.s.b=this.o.length,this.p=xn(this.p,this.s.p/8|0),this.s.p&=7},s.prototype.push=function(e,t){this.e(e),this.c(t)},s})(),gu=(function(){function s(e){this.ondata=e,mr([fr,function(){return[Sn,rn]}],this,0,function(){var t=new rn;onmessage=Sn(t)},7)}return s})();function vu(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return pr(s,e,[fr],function(n){return Ni(gr(n.data[0],hu(n.data[1])))},1,t)}function gr(s,e){return fo(s,e)}var Oa=(function(){function s(e,t){this.c=ur(),this.l=0,this.v=1,Vn.call(this,e,t)}return s.prototype.push=function(e,t){Vn.prototype.push.call(this,e,t)},s.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=vs(e,this.o,this.v&&du(this.o),t&&8,!t);this.v&&(uu(n,this.o),this.v=0),t&&(ot(n,n.length-8,this.c.d()),ot(n,n.length-4,this.l)),this.ondata(n,t)},s})(),vd=(function(){function s(e,t){mr([dr,Wm,function(){return[Sn,Vn,Oa]}],this,mu.call(this,e,t),function(n){var i=new Oa(n.data);onmessage=Sn(i)},8)}return s})();function _d(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return pr(s,e,[dr,Wm,function(){return[Ba]}],function(n){return Ni(Ba(n.data[0],n.data[1]))},2,t)}function Ba(s,e){e||(e={});var t=ur(),n=s.length;t.p(s);var i=vs(s,e,du(e),8),r=i.length;return uu(i,e),ot(i,r-8,t.d()),ot(i,r-4,n),i}var Fa=(function(){function s(e){this.v=1,rn.call(this,e)}return s.prototype.push=function(e,t){if(rn.prototype.e.call(this,e),this.v){var n=this.p.length>3?fu(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}rn.prototype.c.call(this,t)},s})(),$m=(function(){function s(e){this.ondata=e,mr([fr,Xm,function(){return[Sn,rn,Fa]}],this,0,function(){var t=new Fa;onmessage=Sn(t)},9)}return s})();function Qm(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return pr(s,e,[fr,Xm,function(){return[za]}],function(n){return Ni(za(n.data[0]))},3,t)}function za(s,e){return fo(s.subarray(fu(s),-8),e||new $e(Zm(s)))}var hh=(function(){function s(e,t){this.c=lu(),this.v=1,Vn.call(this,e,t)}return s.prototype.push=function(e,t){Vn.prototype.push.call(this,e,t)},s.prototype.p=function(e,t){this.c.p(e);var n=vs(e,this.o,this.v&&2,t&&4,!t);this.v&&(pu(n,this.o),this.v=0),t&&ot(n,n.length-4,this.c.d()),this.ondata(n,t)},s})(),eA=(function(){function s(e,t){mr([dr,qm,function(){return[Sn,Vn,hh]}],this,mu.call(this,e,t),function(n){var i=new hh(n.data);onmessage=Sn(i)},10)}return s})();function tA(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return pr(s,e,[dr,qm,function(){return[uh]}],function(n){return Ni(uh(n.data[0],n.data[1]))},4,t)}function uh(s,e){e||(e={});var t=lu();t.p(s);var n=vs(s,e,2,4);return pu(n,e),ot(n,n.length-4,t.d()),n}var ka=(function(){function s(e){this.v=1,rn.call(this,e)}return s.prototype.push=function(e,t){if(rn.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}rn.prototype.c.call(this,t)},s})(),eg=(function(){function s(e){this.ondata=e,mr([fr,Ym,function(){return[Sn,rn,ka]}],this,0,function(){var t=new ka;onmessage=Sn(t)},11)}return s})();function tg(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return pr(s,e,[fr,Ym,function(){return[Ha]}],function(n){return Ni(Ha(n.data[0],hu(n.data[1])))},5,t)}function Ha(s,e){return fo((Km(s),s.subarray(2,-4)),e)}var ng=(function(){function s(e){this.G=Fa,this.I=rn,this.Z=ka,this.ondata=e}return s.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new $e(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var i=this,r=function(){i.ondata.apply(i,arguments)};this.s=this.p[0]==31&&this.p[1]==139&&this.p[2]==8?new this.G(r):(this.p[0]&15)!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(r):new this.Z(r),this.s.push(this.p,t),this.p=null}}},s})(),nA=(function(){function s(e){this.G=$m,this.I=gu,this.Z=eg,this.ondata=e}return s.prototype.push=function(e,t){ng.prototype.push.call(this,e,t)},s})();function iA(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";return s[0]==31&&s[1]==139&&s[2]==8?Qm(s,e,t):(s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31?vu(s,e,t):tg(s,e,t)}function sA(s,e){return s[0]==31&&s[1]==139&&s[2]==8?za(s,e):(s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31?gr(s,e):Ha(s,e)}var _u=function(s,e,t,n){for(var i in s){var r=s[i],o=e+i;r instanceof $e?t[o]=[r,n]:Array.isArray(r)?t[o]=[r[0],po(n,r[1])]:_u(r,o+"/",t,n)}},yd=typeof TextEncoder<"u"&&new TextEncoder,fh=typeof TextDecoder<"u"&&new TextDecoder,ig=0;try{fh.decode(ni,{stream:!0}),ig=1}catch{}var sg=function(s){for(var e="",t=0;;){var n=s[t++],i=(n>127)+(n>223)+(n>239);if(t+i>s.length)return[e,xn(s,t-1)];i?i==3?(n=((n&15)<<18|(s[t++]&63)<<12|(s[t++]&63)<<6|s[t++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|s[t++]&63):e+=String.fromCharCode((n&15)<<12|(s[t++]&63)<<6|s[t++]&63):e+=String.fromCharCode(n)}},rA=(function(){function s(e){this.ondata=e,ig?this.t=new TextDecoder:this.p=ni}return s.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}return}if(!this.p)throw"stream finished";var n=new $e(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var i=sg(n),r=i[0],o=i[1];if(t){if(o.length)throw"invalid utf-8 data";this.p=null}else this.p=o;this.ondata(r,t)},s})(),oA=(function(){function s(e){this.ondata=e}return s.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(Li(e),this.d=t||!1)},s})();function Li(s,e){if(e){for(var t=new $e(s.length),n=0;n<s.length;++n)t[n]=s.charCodeAt(n);return t}if(yd)return yd.encode(s);for(var i=s.length,r=new $e(s.length+(s.length>>1)),o=0,a=function(h){r[o++]=h},n=0;n<i;++n){if(o+5>r.length){var c=new $e(o+8+(i-n<<1));c.set(r),r=c}var l=s.charCodeAt(n);l<128||e?a(l):l<2048?(a(192|l>>6),a(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|s.charCodeAt(++n)&1023,a(240|l>>18),a(128|l>>12&63),a(128|l>>6&63),a(128|l&63)):(a(224|l>>12),a(128|l>>6&63),a(128|l&63))}return xn(r,0,o)}function yu(s,e){if(e){for(var t="",n=0;n<s.length;n+=16384)t+=String.fromCharCode.apply(null,s.subarray(n,n+16384));return t}else{if(fh)return fh.decode(s);var i=sg(s),r=i[0],o=i[1];if(o.length)throw"invalid utf-8 data";return r}}var rg=function(s){return s==1?3:s<6?2:s==9?1:0},og=function(s,e){return e+30+Jt(s,e+26)+Jt(s,e+28)},ag=function(s,e,t){var n=Jt(s,e+28),i=yu(s.subarray(e+46,e+46+n),!(Jt(s,e+8)&2048)),r=e+46+n,o=St(s,e+20),a=t&&o==4294967295?cg(s,r):[o,St(s,e+24),St(s,e+42)],c=a[0],l=a[1],h=a[2];return[Jt(s,e+10),c,l,i,r+Jt(s,e+30)+Jt(s,e+32),h]},cg=function(s,e){for(;Jt(s,e)!=1;e+=4+Jt(s,e+2));return[fl(s,e+12),fl(s,e+4),fl(s,e+20)]},Ti=function(s){var e=0;if(s)for(var t in s){var n=s[t].length;if(n>65535)throw"extra field too long";e+=n+4}return e},nr=function(s,e,t,n,i,r,o,a){var c=n.length,l=t.extra,h=a&&a.length,u=Ti(l);ot(s,e,o!=null?33639248:67324752),e+=4,o!=null&&(s[e++]=20,s[e++]=t.os),s[e]=20,e+=2,s[e++]=t.flag<<1|(r==null&&8),s[e++]=i&&8,s[e++]=t.compression&255,s[e++]=t.compression>>8;var f=new Date(t.mtime==null?Date.now():t.mtime),d=f.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(ot(s,e,d<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>>1),e+=4,r!=null&&(ot(s,e,t.crc),ot(s,e+4,r),ot(s,e+8,t.size)),ot(s,e+12,c),ot(s,e+14,u),e+=16,o!=null&&(ot(s,e,h),ot(s,e+6,t.attrs),ot(s,e+10,o),e+=14),s.set(n,e),e+=c,u)for(var p in l){var v=l[p],g=v.length;ot(s,e,+p),ot(s,e+2,g),s.set(v,e+4),e+=4+g}return h&&(s.set(a,e),e+=h),e},xu=function(s,e,t,n,i){ot(s,e,101010256),ot(s,e+8,t),ot(s,e+10,t),ot(s,e+12,n),ot(s,e+16,i)},Qr=(function(){function s(e){this.filename=e,this.c=ur(),this.size=0,this.compression=0}return s.prototype.process=function(e,t){this.ondata(null,e,t)},s.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},s})(),aA=(function(){function s(e,t){var n=this;t||(t={}),Qr.call(this,e),this.d=new Vn(t,function(i,r){n.ondata(null,i,r)}),this.compression=8,this.flag=rg(t.level)}return s.prototype.process=function(e,t){try{this.d.push(e,t)}catch(n){this.ondata(n,null,t)}},s.prototype.push=function(e,t){Qr.prototype.push.call(this,e,t)},s})(),cA=(function(){function s(e,t){var n=this;t||(t={}),Qr.call(this,e),this.d=new jm(t,function(i,r,o){n.ondata(i,r,o)}),this.compression=8,this.flag=rg(t.level),this.terminate=this.d.terminate}return s.prototype.process=function(e,t){this.d.push(e,t)},s.prototype.push=function(e,t){Qr.prototype.push.call(this,e,t)},s})(),lA=(function(){function s(e){this.ondata=e,this.u=[],this.d=1}return s.prototype.add=function(e){var t=this;if(this.d&2)throw"stream finished";var n=Li(e.filename),i=n.length,r=e.comment,o=r&&Li(r),a=i!=e.filename.length||o&&r.length!=o.length,c=i+Ti(e.extra)+30;if(i>65535)throw"filename too long";var l=new $e(c);nr(l,0,e,n,a);var h=[l],u=function(){for(var g=0,m=h;g<m.length;g++){var y=m[g];t.ondata(null,y,!1)}h=[]},f=this.d;this.d=0;var d=this.u.length,p=po(e,{f:n,u:a,o,t:function(){e.terminate&&e.terminate()},r:function(){if(u(),f){var g=t.u[d+1];g?g.r():t.d=1}f=1}}),v=0;e.ondata=function(g,m,y){if(g)t.ondata(g,m,y),t.terminate();else if(v+=m.length,h.push(m),y){var _=new $e(16);ot(_,0,134695760),ot(_,4,e.crc),ot(_,8,v),ot(_,12,e.size),h.push(_),p.c=v,p.b=c+v+16,p.crc=e.crc,p.size=e.size,f&&p.r(),f=1}else f&&u()},this.u.push(p)},s.prototype.end=function(){var e=this;if(this.d&2)throw this.d&1?"stream finishing":"stream finished";this.d?this.e():this.u.push({r:function(){e.d&1&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},s.prototype.e=function(){for(var e=0,t=0,n=0,i=0,r=this.u;i<r.length;i++){var o=r[i];n+=46+o.f.length+Ti(o.extra)+(o.o?o.o.length:0)}for(var a=new $e(n+22),c=0,l=this.u;c<l.length;c++){var o=l[c];nr(a,e,o,o.f,o.u,o.c,t,o.o),e+=46+o.f.length+Ti(o.extra)+(o.o?o.o.length:0),t+=o.b}xu(a,e,this.u.length,n,t),this.ondata(null,a,!0),this.d=2},s.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++){var n=t[e];n.t()}this.d=2},s})();function hA(s,e,t){if(t||(t=e,e={}),typeof t!="function")throw"no callback";var n={};_u(s,"",n,e);var i=Object.keys(n),r=i.length,o=0,a=0,c=r,l=new Array(r),h=[],u=function(){for(var v=0;v<h.length;++v)h[v]()},f=function(){var v=new $e(a+22),g=o,m=a-o;a=0;for(var y=0;y<c;++y){var _=l[y];try{var x=_.c.length;nr(v,a,_,_.f,_.u,x);var T=30+_.f.length+Ti(_.extra),b=a+T;v.set(_.c,b),nr(v,o,_,_.f,_.u,x,a,_.m),o+=16+T+(_.m?_.m.length:0),a=b+x}catch(A){return t(A,null)}}xu(v,o,l.length,m,g),t(null,v)};r||f();for(var d=function(v){var g=i[v],m=n[g],y=m[0],_=m[1],x=ur(),T=y.length;x.p(y);var b=Li(g),A=b.length,L=_.comment,M=L&&Li(L),w=M&&M.length,O=Ti(_.extra),H=_.level==0?0:8,K=function(I,F){if(I)u(),t(I,null);else{var k=F.length;l[v]=po(_,{size:T,crc:x.d(),c:F,f:b,m:M,u:A!=g.length||M&&L.length!=w,compression:H}),o+=30+A+O+k,a+=76+2*(A+O)+(w||0)+k,--r||f()}};if(A>65535&&K("filename too long",null),!H)K(null,y);else if(T<16e4)try{K(null,mo(y,_))}catch(I){K(I,null)}else h.push(Jm(y,_,K))},p=0;p<c;++p)d(p);return u}function uA(s,e){e||(e={});var t={},n=[];_u(s,"",t,e);var i=0,r=0;for(var o in t){var a=t[o],c=a[0],l=a[1],h=l.level==0?0:8,u=Li(o),f=u.length,d=l.comment,p=d&&Li(d),v=p&&p.length,g=Ti(l.extra);if(f>65535)throw"filename too long";var m=h?mo(c,l):c,y=m.length,_=ur();_.p(c),n.push(po(l,{size:c.length,crc:_.d(),c:m,f:u,m:p,u:f!=o.length||p&&d.length!=v,o:i,compression:h})),i+=30+f+g+y,r+=76+2*(f+g)+(v||0)+y}for(var x=new $e(r+22),T=i,b=r-i,A=0;A<n.length;++A){var u=n[A];nr(x,u.o,u,u.f,u.u,u.c.length);var L=30+u.f.length+Ti(u.extra);x.set(u.c,u.o+L),nr(x,i,u,u.f,u.u,u.c.length,u.o,u.m),i+=16+L+(u.m?u.m.length:0)}return xu(x,i,n.length,b,T),x}var lg=(function(){function s(){}return s.prototype.push=function(e,t){this.ondata(null,e,t)},s.compression=0,s})(),fA=(function(){function s(){var e=this;this.i=new rn(function(t,n){e.ondata(null,t,n)})}return s.prototype.push=function(e,t){try{this.i.push(e,t)}catch(n){this.ondata(n,e,t)}},s.compression=8,s})(),dA=(function(){function s(e,t){var n=this;t<32e4?this.i=new rn(function(i,r){n.ondata(null,i,r)}):(this.i=new gu(function(i,r,o){n.ondata(i,r,o)}),this.terminate=this.i.terminate)}return s.prototype.push=function(e,t){this.i.terminate&&(e=xn(e,0)),this.i.push(e,t)},s.compression=8,s})(),pA=(function(){function s(e){this.onfile=e,this.k=[],this.o={0:lg},this.p=ni}return s.prototype.push=function(e,t){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var i=Math.min(this.c,e.length),r=e.subarray(0,i);if(this.c-=i,this.d?this.d.push(r,!this.c):this.k[0].push(r),e=e.subarray(i),e.length)return this.push(e,t)}else{var o=0,a=0,c=void 0,l=void 0;this.p.length?e.length?(l=new $e(this.p.length+e.length),l.set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var h=l.length,u=this.c,f=u&&this.d,d=function(){var m,y=St(l,a);if(y==67324752){o=1,c=a,p.d=null,p.c=0;var _=Jt(l,a+6),x=Jt(l,a+8),T=_&2048,b=_&8,A=Jt(l,a+26),L=Jt(l,a+28);if(h>a+30+A+L){var M=[];p.k.unshift(M),o=2;var w=St(l,a+18),O=St(l,a+22),H=yu(l.subarray(a+30,a+=30+A),!T);w==4294967295?(m=b?[-2]:cg(l,a),w=m[0],O=m[1]):b&&(w=-1),a+=L,p.c=w;var K,I={name:H,compression:x,start:function(){if(!I.ondata)throw"no callback";if(!w)I.ondata(null,ni,!0);else{var F=n.o[x];if(!F)throw"unknown compression type "+x;K=w<0?new F(H):new F(H,w,O),K.ondata=function($,le,ce){I.ondata($,le,ce)};for(var k=0,te=M;k<te.length;k++){var J=te[k];K.push(J,!1)}n.k[0]==M&&n.c?n.d=K:K.push(ni,!0)}},terminate:function(){K&&K.terminate&&K.terminate()}};w>=0&&(I.size=w,I.originalSize=O),p.onfile(I)}return"break"}else if(u){if(y==134695760)return c=a+=12+(u==-2&&8),o=3,p.c=0,"break";if(y==33639248)return c=a-=4,o=3,p.c=0,"break"}},p=this;a<h-4;++a){var v=d();if(v==="break")break}if(this.p=ni,u<0){var g=o?l.subarray(0,c-12-(u==-2&&8)-(St(l,c-16)==134695760&&4)):l.subarray(0,a);f?f.push(g,!!o):this.k[+(o==2)].push(g)}if(o&2)return this.push(l.subarray(a),t);this.p=l.subarray(a)}if(t){if(this.c)throw"invalid zip file";this.p=null}},s.prototype.register=function(e){this.o[e.compression]=e},s})();function mA(s,e){if(typeof e!="function")throw"no callback";for(var t=[],n=function(){for(var f=0;f<t.length;++f)t[f]()},i={},r=s.length-22;St(s,r)!=101010256;--r)if(!r||s.length-r>65558){e("invalid zip file",null);return}var o=Jt(s,r+8);o||e(null,{});var a=o,c=St(s,r+16),l=c==4294967295;if(l){if(r=St(s,r-12),St(s,r)!=101075792){e("invalid zip file",null);return}a=o=St(s,r+32),c=St(s,r+48)}for(var h=function(f){var d=ag(s,c,l),p=d[0],v=d[1],g=d[2],m=d[3],y=d[4],_=d[5],x=og(s,_);c=y;var T=function(A,L){A?(n(),e(A,null)):(i[m]=L,--o||e(null,i))};if(!p)T(null,xn(s,x,x+v));else if(p==8){var b=s.subarray(x,x+v);if(v<32e4)try{T(null,gr(b,new $e(g)))}catch(A){T(A,null)}else t.push(vu(b,{size:g},T))}else T("unknown compression type "+p,null)},u=0;u<a;++u)h();return n}function hg(s){for(var e={},t=s.length-22;St(s,t)!=101010256;--t)if(!t||s.length-t>65558)throw"invalid zip file";var n=Jt(s,t+8);if(!n)return{};var i=St(s,t+16),r=i==4294967295;if(r){if(t=St(s,t-12),St(s,t)!=101075792)throw"invalid zip file";n=St(s,t+32),i=St(s,t+48)}for(var o=0;o<n;++o){var a=ag(s,i,r),c=a[0],l=a[1],h=a[2],u=a[3],f=a[4],d=a[5],p=og(s,d);if(i=f,!c)e[u]=xn(s,p,p+l);else if(c==8)e[u]=gr(s.subarray(p,p+l),new $e(h));else throw"unknown compression type "+c}return e}const EA=Object.freeze(Object.defineProperty({__proto__:null,AsyncCompress:vd,AsyncDecompress:nA,AsyncDeflate:jm,AsyncGunzip:$m,AsyncGzip:vd,AsyncInflate:gu,AsyncUnzipInflate:dA,AsyncUnzlib:eg,AsyncZipDeflate:cA,AsyncZlib:eA,Compress:Oa,DecodeUTF8:rA,Decompress:ng,Deflate:Vn,EncodeUTF8:oA,Gunzip:Fa,Gzip:Oa,Inflate:rn,Unzip:pA,UnzipInflate:fA,UnzipPassThrough:lg,Unzlib:ka,Zip:lA,ZipDeflate:aA,ZipPassThrough:Qr,Zlib:hh,compress:_d,compressSync:Ba,decompress:iA,decompressSync:sA,deflate:Jm,deflateSync:mo,gunzip:Qm,gunzipSync:za,gzip:_d,gzipSync:Ba,inflate:vu,inflateSync:gr,strFromU8:yu,strToU8:Li,unzip:mA,unzipSync:hg,unzlib:tg,unzlibSync:Ha,zip:hA,zipSync:uA,zlib:tA,zlibSync:uh},Symbol.toStringTag,{value:"Module"})),dl=ht;class gA extends Bt{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,i){const r=this,o=new fn(r.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(c){i?i(c):console.error(c),r.manager.itemError(e)}},n,i)}parse(e){const t=this,n=new jh(this.manager);function i(U){let N=null,V=null,W,q;const j=[],Y=[];let oe;const R={},ie={},G={},Q=new TextDecoder;try{N=hg(new Uint8Array(U))}catch(E){if(E instanceof ReferenceError)return console.error("THREE.3MFLoader: fflate missing and file is compressed."),null}for(V in N)V.match(/\_rels\/.rels$/)?W=V:V.match(/3D\/_rels\/.*\.model\.rels$/)?q=V:V.match(/^3D\/.*\.model$/)?j.push(V):V.match(/^3D\/Textures?\/.*/)&&Y.push(V);const re=N[W],Me=Q.decode(re),me=r(Me);if(q){const E=N[q],S=Q.decode(E);oe=r(S)}for(let E=0;E<j.length;E++){const S=j[E],z=N[S],he=Q.decode(z),ue=new DOMParser().parseFromString(he,"application/xml");ue.documentElement.nodeName.toLowerCase()!=="model"&&console.error("THREE.3MFLoader: Error loading 3MF - no 3MF document found: ",S);const fe=ue.querySelector("model"),Re={};for(let be=0;be<fe.attributes.length;be++){const Ue=fe.attributes[be];Ue.name.match(/^xmlns:(.+)$/)&&(Re[Ue.value]=RegExp.$1)}const Se=x(fe);Se.xml=fe,0<Object.keys(Re).length&&(Se.extensions=Re),R[S]=Se}for(let E=0;E<Y.length;E++){const S=Y[E];G[S]=N[S].buffer}return{rels:me,modelRels:oe,model:R,printTicket:ie,texture:G}}function r(U){const N=[],W=new DOMParser().parseFromString(U,"application/xml").querySelectorAll("Relationship");for(let q=0;q<W.length;q++){const j=W[q],Y={target:j.getAttribute("Target"),id:j.getAttribute("Id"),type:j.getAttribute("Type")};N.push(Y)}return N}function o(U){const N={};for(let V=0;V<U.length;V++){const W=U[V],q=W.getAttribute("name");0<=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate"].indexOf(q)&&(N[q]=W.textContent)}return N}function a(U){const N={id:U.getAttribute("id"),basematerials:[]},V=U.querySelectorAll("base");for(let W=0;W<V.length;W++){const q=V[W],j=f(q);j.index=W,N.basematerials.push(j)}return N}function c(U){return{id:U.getAttribute("id"),path:U.getAttribute("path"),contenttype:U.getAttribute("contenttype"),tilestyleu:U.getAttribute("tilestyleu"),tilestylev:U.getAttribute("tilestylev"),filter:U.getAttribute("filter")}}function l(U){const N={id:U.getAttribute("id"),texid:U.getAttribute("texid"),displaypropertiesid:U.getAttribute("displaypropertiesid")},V=U.querySelectorAll("tex2coord"),W=[];for(let q=0;q<V.length;q++){const j=V[q],Y=j.getAttribute("u"),oe=j.getAttribute("v");W.push(parseFloat(Y),parseFloat(oe))}return N.uvs=new Float32Array(W),N}function h(U){const N={id:U.getAttribute("id"),displaypropertiesid:U.getAttribute("displaypropertiesid")},V=U.querySelectorAll("color"),W=[],q=new Te;for(let j=0;j<V.length;j++){const oe=V[j].getAttribute("color");q.setStyle(oe.substring(0,7),dl),W.push(q.r,q.g,q.b)}return N.colors=new Float32Array(W),N}function u(U){const N={id:U.getAttribute("id")},V=U.querySelectorAll("pbmetallic"),W=[];for(let q=0;q<V.length;q++){const j=V[q];W.push({name:j.getAttribute("name"),metallicness:parseFloat(j.getAttribute("metallicness")),roughness:parseFloat(j.getAttribute("roughness"))})}return N.data=W,N}function f(U){const N={};return N.name=U.getAttribute("name"),N.displaycolor=U.getAttribute("displaycolor"),N.displaypropertiesid=U.getAttribute("displaypropertiesid"),N}function d(U){const N={},V=[],W=U.querySelectorAll("vertices vertex");for(let oe=0;oe<W.length;oe++){const R=W[oe],ie=R.getAttribute("x"),G=R.getAttribute("y"),Q=R.getAttribute("z");V.push(parseFloat(ie),parseFloat(G),parseFloat(Q))}N.vertices=new Float32Array(V);const q=[],j=[],Y=U.querySelectorAll("triangles triangle");for(let oe=0;oe<Y.length;oe++){const R=Y[oe],ie=R.getAttribute("v1"),G=R.getAttribute("v2"),Q=R.getAttribute("v3"),re=R.getAttribute("p1"),Me=R.getAttribute("p2"),me=R.getAttribute("p3"),E=R.getAttribute("pid"),S={};S.v1=parseInt(ie,10),S.v2=parseInt(G,10),S.v3=parseInt(Q,10),j.push(S.v1,S.v2,S.v3),re&&(S.p1=parseInt(re,10)),Me&&(S.p2=parseInt(Me,10)),me&&(S.p3=parseInt(me,10)),E&&(S.pid=E),0<Object.keys(S).length&&q.push(S)}return N.triangleProperties=q,N.triangles=new Uint32Array(j),N}function p(U){const N=[],V=U.querySelectorAll("component");for(let W=0;W<V.length;W++){const q=V[W],j=v(q);N.push(j)}return N}function v(U){const N={};N.objectId=U.getAttribute("objectid");const V=U.getAttribute("transform");return V&&(N.transform=g(V)),N}function g(U){const N=[];U.split(" ").forEach(function(W){N.push(parseFloat(W))});const V=new Ne;return V.set(N[0],N[3],N[6],N[9],N[1],N[4],N[7],N[10],N[2],N[5],N[8],N[11],0,0,0,1),V}function m(U){const N={type:U.getAttribute("type")},V=U.getAttribute("id");V&&(N.id=V);const W=U.getAttribute("pid");W&&(N.pid=W);const q=U.getAttribute("pindex");q&&(N.pindex=q);const j=U.getAttribute("thumbnail");j&&(N.thumbnail=j);const Y=U.getAttribute("partnumber");Y&&(N.partnumber=Y);const oe=U.getAttribute("name");oe&&(N.name=oe);const R=U.querySelector("mesh");R&&(N.mesh=d(R));const ie=U.querySelector("components");return ie&&(N.components=p(ie)),N}function y(U){const N={};N.basematerials={};const V=U.querySelectorAll("basematerials");for(let R=0;R<V.length;R++){const ie=V[R],G=a(ie);N.basematerials[G.id]=G}N.texture2d={};const W=U.querySelectorAll("texture2d");for(let R=0;R<W.length;R++){const ie=W[R],G=c(ie);N.texture2d[G.id]=G}N.colorgroup={};const q=U.querySelectorAll("colorgroup");for(let R=0;R<q.length;R++){const ie=q[R],G=h(ie);N.colorgroup[G.id]=G}N.pbmetallicdisplayproperties={};const j=U.querySelectorAll("pbmetallicdisplayproperties");for(let R=0;R<j.length;R++){const ie=j[R],G=u(ie);N.pbmetallicdisplayproperties[G.id]=G}N.texture2dgroup={};const Y=U.querySelectorAll("texture2dgroup");for(let R=0;R<Y.length;R++){const ie=Y[R],G=l(ie);N.texture2dgroup[G.id]=G}N.object={};const oe=U.querySelectorAll("object");for(let R=0;R<oe.length;R++){const ie=oe[R],G=m(ie);N.object[G.id]=G}return N}function _(U){const N=[],V=U.querySelectorAll("item");for(let W=0;W<V.length;W++){const q=V[W],j={objectId:q.getAttribute("objectid")},Y=q.getAttribute("transform");Y&&(j.transform=g(Y)),N.push(j)}return N}function x(U){const N={unit:U.getAttribute("unit")||"millimeter"},V=U.querySelectorAll("metadata");V&&(N.metadata=o(V));const W=U.querySelector("resources");W&&(N.resources=y(W));const q=U.querySelector("build");return q&&(N.build=_(q)),N}function T(U,N,V,W){const q=U.texid,Y=V.resources.texture2d[q];if(Y){const oe=W[Y.path],R=Y.contenttype,ie=new Blob([oe],{type:R}),G=URL.createObjectURL(ie),Q=n.load(G,function(){URL.revokeObjectURL(G)});switch(Q.colorSpace=dl,Y.tilestyleu){case"wrap":Q.wrapS=vn;break;case"mirror":Q.wrapS=Ri;break;case"none":case"clamp":Q.wrapS=At;break;default:Q.wrapS=vn}switch(Y.tilestylev){case"wrap":Q.wrapT=vn;break;case"mirror":Q.wrapT=Ri;break;case"none":case"clamp":Q.wrapT=At;break;default:Q.wrapT=vn}switch(Y.filter){case"auto":Q.magFilter=at,Q.minFilter=Mn;break;case"linear":Q.magFilter=at,Q.minFilter=at;break;case"nearest":Q.magFilter=dt,Q.minFilter=dt;break;default:Q.magFilter=at,Q.minFilter=Mn}return Q}else return null}function b(U,N,V,W,q,j,Y){const oe=Y.pindex,R={};for(let Q=0,re=N.length;Q<re;Q++){const Me=N[Q],me=Me.p1!==void 0?Me.p1:oe;R[me]===void 0&&(R[me]=[]),R[me].push(Me)}const ie=Object.keys(R),G=[];for(let Q=0,re=ie.length;Q<re;Q++){const Me=ie[Q],me=R[Me],E=U.basematerials[Me],S=F(E,W,q,j,Y,k),z=new Be,he=[],ue=V.vertices;for(let Re=0,Se=me.length;Re<Se;Re++){const be=me[Re];he.push(ue[be.v1*3+0]),he.push(ue[be.v1*3+1]),he.push(ue[be.v1*3+2]),he.push(ue[be.v2*3+0]),he.push(ue[be.v2*3+1]),he.push(ue[be.v2*3+2]),he.push(ue[be.v3*3+0]),he.push(ue[be.v3*3+1]),he.push(ue[be.v3*3+2])}z.setAttribute("position",new Ee(he,3));const fe=new ft(z,S);G.push(fe)}return G}function A(U,N,V,W,q,j,Y){const oe=new Be,R=[],ie=[],G=V.vertices,Q=U.uvs;for(let E=0,S=N.length;E<S;E++){const z=N[E];R.push(G[z.v1*3+0]),R.push(G[z.v1*3+1]),R.push(G[z.v1*3+2]),R.push(G[z.v2*3+0]),R.push(G[z.v2*3+1]),R.push(G[z.v2*3+2]),R.push(G[z.v3*3+0]),R.push(G[z.v3*3+1]),R.push(G[z.v3*3+2]),ie.push(Q[z.p1*2+0]),ie.push(Q[z.p1*2+1]),ie.push(Q[z.p2*2+0]),ie.push(Q[z.p2*2+1]),ie.push(Q[z.p3*2+0]),ie.push(Q[z.p3*2+1])}oe.setAttribute("position",new Ee(R,3)),oe.setAttribute("uv",new Ee(ie,2));const re=F(U,W,q,j,Y,T),Me=new Xs({map:re,flatShading:!0});return new ft(oe,Me)}function L(U,N,V,W){const q=new Be,j=[],Y=[],oe=V.vertices,R=U.colors;for(let Q=0,re=N.length;Q<re;Q++){const Me=N[Q],me=Me.v1,E=Me.v2,S=Me.v3;j.push(oe[me*3+0]),j.push(oe[me*3+1]),j.push(oe[me*3+2]),j.push(oe[E*3+0]),j.push(oe[E*3+1]),j.push(oe[E*3+2]),j.push(oe[S*3+0]),j.push(oe[S*3+1]),j.push(oe[S*3+2]);const z=Me.p1!==void 0?Me.p1:W.pindex,he=Me.p2!==void 0?Me.p2:z,ue=Me.p3!==void 0?Me.p3:z;Y.push(R[z*3+0]),Y.push(R[z*3+1]),Y.push(R[z*3+2]),Y.push(R[he*3+0]),Y.push(R[he*3+1]),Y.push(R[he*3+2]),Y.push(R[ue*3+0]),Y.push(R[ue*3+1]),Y.push(R[ue*3+2])}q.setAttribute("position",new Ee(j,3)),q.setAttribute("color",new Ee(Y,3));const ie=new Xs({vertexColors:!0,flatShading:!0});return new ft(q,ie)}function M(U){const N=new Be;N.setIndex(new Fe(U.triangles,1)),N.setAttribute("position",new Fe(U.vertices,3));const V=new Xs({name:Bt.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new ft(N,V)}function w(U,N,V,W,q,j){const Y=Object.keys(U),oe=[];for(let R=0,ie=Y.length;R<ie;R++){const G=Y[R],Q=U[G];switch(O(G,W)){case"material":const Me=W.resources.basematerials[G],me=b(Me,Q,N,V,W,q,j);for(let z=0,he=me.length;z<he;z++)oe.push(me[z]);break;case"texture":const E=W.resources.texture2dgroup[G];oe.push(A(E,Q,N,V,W,q,j));break;case"vertexColors":const S=W.resources.colorgroup[G];oe.push(L(S,Q,N,j));break;case"default":oe.push(M(N));break;default:console.error("THREE.3MFLoader: Unsupported resource type.")}}if(j.name)for(let R=0;R<oe.length;R++)oe[R].name=j.name;return oe}function O(U,N){return N.resources.texture2dgroup[U]!==void 0?"texture":N.resources.basematerials[U]!==void 0?"material":N.resources.colorgroup[U]!==void 0?"vertexColors":U==="default"?"default":void 0}function H(U,N){const V={},W=U.triangleProperties,q=N.pid;for(let j=0,Y=W.length;j<Y;j++){const oe=W[j];let R=oe.pid!==void 0?oe.pid:q;R===void 0&&(R="default"),V[R]===void 0&&(V[R]=[]),V[R].push(oe)}return V}function K(U,N,V,W,q){const j=new _n,Y=H(U,q),oe=w(Y,U,N,V,W,q);for(let R=0,ie=oe.length;R<ie;R++)j.add(oe[R]);return j}function I(U,N,V){if(!U)return;const W=[],q=Object.keys(U);for(let j=0;j<q.length;j++){const Y=q[j];for(let oe=0;oe<t.availableExtensions.length;oe++){const R=t.availableExtensions[oe];R.ns===Y&&W.push(R)}}for(let j=0;j<W.length;j++){const Y=W[j];Y.apply(V,U[Y.ns],N)}}function F(U,N,V,W,q,j){return U.build!==void 0||(U.build=j(U,N,V,W,q)),U.build}function k(U,N,V){let W;const q=U.displaypropertiesid,j=V.resources.pbmetallicdisplayproperties;if(q!==null&&j[q]!==void 0){const ie=j[q].data[U.index];W=new ar({flatShading:!0,roughness:ie.roughness,metalness:ie.metallicness})}else W=new Xs({flatShading:!0});W.name=U.name;const Y=U.displaycolor,oe=Y.substring(0,7);return W.color.setStyle(oe,dl),Y.length===9&&(W.opacity=parseInt(Y.charAt(7)+Y.charAt(8),16)/255),W}function te(U,N,V,W){const q=new _n;for(let j=0;j<U.length;j++){const Y=U[j];let oe=N[Y.objectId];oe===void 0&&(J(Y.objectId,N,V,W),oe=N[Y.objectId]);const R=oe.clone(),ie=Y.transform;ie&&R.applyMatrix4(ie),q.add(R)}return q}function J(U,N,V,W){const q=V.resources.object[U];if(q.mesh){const j=q.mesh,Y=V.extensions,oe=V.xml;I(Y,j,oe),N[q.id]=F(j,N,V,W,q,K)}else{const j=q.components;N[q.id]=F(j,N,V,W,q,te)}q.name&&(N[q.id].name=q.name)}function $(U){const N=U.model,V=U.modelRels,W={},q=Object.keys(N),j={};if(V)for(let Y=0,oe=V.length;Y<oe;Y++){const R=V[Y],ie=R.target.substring(1);U.texture[ie]&&(j[R.target]=U.texture[ie])}for(let Y=0;Y<q.length;Y++){const oe=q[Y],R=N[oe],ie=Object.keys(R.resources.object);for(let G=0;G<ie.length;G++){const Q=ie[G];J(Q,W,R,j)}}return W}function le(U){for(let N=0;N<U.length;N++){const V=U[N];if(V.target.split(".").pop().toLowerCase()==="model")return V}}function ce(U,N){const V=new _n,W=le(N.rels),q=N.model[W.target.substring(1)].build;for(let j=0;j<q.length;j++){const Y=q[j],oe=U[Y.objectId].clone(),R=Y.transform;R&&oe.applyMatrix4(R),V.add(oe)}return V}const ge=i(e),Z=$(ge);return ce(Z,ge)}addExtension(e){this.availableExtensions.push(e)}}const RA=Object.freeze(Object.defineProperty({__proto__:null,ThreeMFLoader:gA},Symbol.toStringTag,{value:"Module"}));export{AA as B,wA as G,yA as L,Ne as M,oo as O,Nt as P,Hn as S,vA as T,C as V,Fp as W,RA as _,nb as a,ae as b,_A as c,xA as d,MA as e,SA as f,bA as g,TA as h,EA as i};
|
|
//# sourceMappingURL=vendor-three-SYzIooV9.js.map
|