Untitled
var uk=Object.defineProperty;var dk=(Wn,ur,Vr)=>ur in Wn?uk(Wn,ur,{enumerable:!0,configurable:!0,writable:!0,value:Vr}):Wn[ur]=Vr;var vt=(Wn,ur,Vr)=>(dk(Wn,typeof ur!="symbol"?ur+"":ur,Vr),Vr);(async()=>{(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))t(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&t(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function t(i){if(i.ep)return;i.ep=!0;const r=e(i);fetch(i.href,r)}})();const Wn="160",ur={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Vr={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},o1=0,hm=1,l1=2,cm=1,h1=2,En=3,jn=0,dr=1,xi=2,pn=0,zs=1,Pu=2,um=3,dm=4,c1=5,Ka=100,u1=101,d1=102,pm=103,fm=104,p1=200,f1=201,m1=202,g1=203,Du=204,Iu=205,_1=206,v1=207,y1=208,x1=209,b1=210,w1=211,M1=212,T1=213,S1=214,E1=0,A1=1,R1=2,mh=3,C1=4,L1=5,P1=6,D1=7,gh=0,I1=1,O1=2,_a=0,mm=1,N1=2,U1=3,z1=4,B1=5,F1=6,gm="attached",k1="detached",_m=300,Bs=301,Fs=302,Ou=303,Nu=304,_h=306,pr=1e3,Wr=1001,vh=1002,zi=1003,Uu=1004,yh=1005,fr=1006,vm=1007,Za=1008,va=1009,H1=1010,G1=1011,zu=1012,ym=1013,ya=1014,Xn=1015,Rr=1016,xm=1017,bm=1018,Ja=1020,V1=1021,Cr=1023,W1=1024,j1=1025,$a=1026,ks=1027,X1=1028,wm=1029,q1=1030,Mm=1031,Tm=1033,Bu=33776,Fu=33777,ku=33778,Hu=33779,Sm=35840,Em=35841,Am=35842,Rm=35843,Cm=36196,Lm=37492,Pm=37496,Dm=37808,Im=37809,Om=37810,Nm=37811,Um=37812,zm=37813,Bm=37814,Fm=37815,km=37816,Hm=37817,Gm=37818,Vm=37819,Wm=37820,jm=37821,Gu=36492,Xm=36494,qm=36495,Y1=36283,Ym=36284,Km=36285,Zm=36286,hl=2300,Hs=2301,Vu=2302,Jm=2400,$m=2401,Qm=2402,K1=2500,Z1=0,eg=1,Wu=2,tg=3e3,Qa=3001,J1=3200,ig=3201,xh=0,$1=1,jr="",Bt="srgb",Bi="srgb-linear",ju="display-p3",bh="display-p3-linear",wh="linear",ii="srgb",Mh="rec709",Th="p3",Gs=7680,rg=519,Q1=512,eb=513,tb=514,ng=515,ib=516,rb=517,nb=518,ab=519,Xu=35044,sb=35048,ag="300 es",qu=1035,qn=2e3,Sh=2001;class Yn{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[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 t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,e);e.target=null}}}const qi=["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 sg=1234567;const cl=Math.PI/180,Vs=180/Math.PI;function Xr(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(qi[n&255]+qi[n>>8&255]+qi[n>>16&255]+qi[n>>24&255]+"-"+qi[e&255]+qi[e>>8&255]+"-"+qi[e>>16&15|64]+qi[e>>24&255]+"-"+qi[t&63|128]+qi[t>>8&255]+"-"+qi[t>>16&255]+qi[t>>24&255]+qi[i&255]+qi[i>>8&255]+qi[i>>16&255]+qi[i>>24&255]).toLowerCase()}function Ri(n,e,t){return Math.max(e,Math.min(t,n))}function Yu(n,e){return(n%e+e)%e}function ob(n,e,t,i,r){return i+(n-e)*(r-i)/(t-e)}function lb(n,e,t){return n!==e?(t-n)/(e-n):0}function ul(n,e,t){return(1-t)*n+t*e}function hb(n,e,t,i){return ul(n,e,1-Math.exp(-t*i))}function cb(n,e=1){return e-Math.abs(Yu(n,e*2)-e)}function ub(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function db(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function pb(n,e){return n+Math.floor(Math.random()*(e-n+1))}function fb(n,e){return n+Math.random()*(e-n)}function mb(n){return n*(.5-Math.random())}function gb(n){n!==void 0&&(sg=n);let e=sg+=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 _b(n){return n*cl}function vb(n){return n*Vs}function Ku(n){return(n&n-1)===0&&n!==0}function yb(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Eh(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function xb(n,e,t,i,r){const a=Math.cos,s=Math.sin,l=a(t/2),h=s(t/2),c=a((e+i)/2),d=s((e+i)/2),p=a((e-i)/2),f=s((e-i)/2),m=a((i-e)/2),_=s((i-e)/2);switch(r){case"XYX":n.set(l*d,h*p,h*f,l*c);break;case"YZY":n.set(h*f,l*d,h*p,l*c);break;case"ZXZ":n.set(h*p,h*f,l*d,l*c);break;case"XZX":n.set(l*d,h*_,h*m,l*c);break;case"YXY":n.set(h*m,l*d,h*_,l*c);break;case"ZYZ":n.set(h*_,h*m,l*d,l*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function An(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("Invalid component type.")}}function Kt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("Invalid component type.")}}const dl={DEG2RAD:cl,RAD2DEG:Vs,generateUUID:Xr,clamp:Ri,euclideanModulo:Yu,mapLinear:ob,inverseLerp:lb,lerp:ul,damp:hb,pingpong:cb,smoothstep:ub,smootherstep:db,randInt:pb,randFloat:fb,randFloatSpread:mb,seededRandom:gb,degToRad:_b,radToDeg:vb,isPowerOfTwo:Ku,ceilPowerOfTwo:yb,floorPowerOfTwo:Eh,setQuaternionFromProperEuler:xb,normalize:Kt,denormalize:An};class pe{constructor(e=0,t=0){pe.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,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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 i=this.dot(e)/t;return Math.acos(Ri(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,s=this.y-e.y;return this.x=a*i-s*r+e.x,this.y=a*r+s*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class yt{constructor(e,t,i,r,a,s,l,h,c){yt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,r,a,s,l,h,c)}set(e,t,i,r,a,s,l,h,c){const d=this.elements;return d[0]=e,d[1]=r,d[2]=l,d[3]=t,d[4]=a,d[5]=h,d[6]=i,d[7]=s,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,r=t.elements,a=this.elements,s=i[0],l=i[3],h=i[6],c=i[1],d=i[4],p=i[7],f=i[2],m=i[5],_=i[8],x=r[0],y=r[3],v=r[6],M=r[1],b=r[4],S=r[7],A=r[2],T=r[5],E=r[8];return a[0]=s*x+l*M+h*A,a[3]=s*y+l*b+h*T,a[6]=s*v+l*S+h*E,a[1]=c*x+d*M+p*A,a[4]=c*y+d*b+p*T,a[7]=c*v+d*S+p*E,a[2]=f*x+m*M+_*A,a[5]=f*y+m*b+_*T,a[8]=f*v+m*S+_*E,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],i=e[1],r=e[2],a=e[3],s=e[4],l=e[5],h=e[6],c=e[7],d=e[8];return t*s*d-t*l*c-i*a*d+i*l*h+r*a*c-r*s*h}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],l=e[5],h=e[6],c=e[7],d=e[8],p=d*s-l*c,f=l*h-d*a,m=c*a-s*h,_=t*p+i*f+r*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/_;return e[0]=p*x,e[1]=(r*c-d*i)*x,e[2]=(l*i-r*s)*x,e[3]=f*x,e[4]=(d*t-r*h)*x,e[5]=(r*a-l*t)*x,e[6]=m*x,e[7]=(i*h-c*t)*x,e[8]=(s*t-i*a)*x,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,i,r,a,s,l){const h=Math.cos(a),c=Math.sin(a);return this.set(i*h,i*c,-i*(h*s+c*l)+s+e,-r*c,r*h,-r*(-c*s+h*l)+l+t,0,0,1),this}scale(e,t){return this.premultiply(Zu.makeScale(e,t)),this}rotate(e){return this.premultiply(Zu.makeRotation(-e)),this}translate(e,t){return this.premultiply(Zu.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let r=0;r<9;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Zu=new yt;function og(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function pl(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function bb(){const n=pl("canvas");return n.style.display="block",n}const lg={};function fl(n){n in lg||(lg[n]=!0,console.warn(n))}const hg=new yt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),cg=new yt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Ah={[Bi]:{transfer:wh,primaries:Mh,toReference:n=>n,fromReference:n=>n},[Bt]:{transfer:ii,primaries:Mh,toReference:n=>n.convertSRGBToLinear(),fromReference:n=>n.convertLinearToSRGB()},[bh]:{transfer:wh,primaries:Th,toReference:n=>n.applyMatrix3(cg),fromReference:n=>n.applyMatrix3(hg)},[ju]:{transfer:ii,primaries:Th,toReference:n=>n.convertSRGBToLinear().applyMatrix3(cg),fromReference:n=>n.applyMatrix3(hg).convertLinearToSRGB()}},wb=new Set([Bi,bh]),Gt={enabled:!0,_workingColorSpace:Bi,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(n){if(!wb.has(n))throw new Error(`Unsupported working color space, "${n}".`);this._workingColorSpace=n},convert:function(n,e,t){if(this.enabled===!1||e===t||!e||!t)return n;const i=Ah[e].toReference,r=Ah[t].fromReference;return r(i(n))},fromWorkingColorSpace:function(n,e){return this.convert(n,this._workingColorSpace,e)},toWorkingColorSpace:function(n,e){return this.convert(n,e,this._workingColorSpace)},getPrimaries:function(n){return Ah[n].primaries},getTransfer:function(n){return n===jr?wh:Ah[n].transfer}};function Ws(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Ju(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let js;class ug{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{js===void 0&&(js=pl("canvas")),js.width=e.width,js.height=e.height;const i=js.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=js}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=pl("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let s=0;s<a.length;s++)a[s]=Ws(a[s]/255)*255;return i.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let i=0;i<t.length;i++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[i]=Math.floor(Ws(t[i]/255)*255):t[i]=Ws(t[i]);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 Mb=0;class dg{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Mb++}),this.uuid=Xr(),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 i={uuid:this.uuid,url:""},r=this.data;if(r!==null){let a;if(Array.isArray(r)){a=[];for(let s=0,l=r.length;s<l;s++)r[s].isDataTexture?a.push($u(r[s].image)):a.push($u(r[s]))}else a=$u(r);i.url=a}return t||(e.images[this.uuid]=i),i}}function $u(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap?ug.getDataURL(n):n.data?{data:Array.from(n.data),width:n.width,height:n.height,type:n.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Tb=0;class Wi extends Yn{constructor(e=Wi.DEFAULT_IMAGE,t=Wi.DEFAULT_MAPPING,i=Wr,r=Wr,a=fr,s=Za,l=Cr,h=va,c=Wi.DEFAULT_ANISOTROPY,d=jr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Tb++}),this.uuid=Xr(),this.name="",this.source=new dg(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=a,this.minFilter=s,this.anisotropy=c,this.format=l,this.internalFormat=null,this.type=h,this.offset=new pe(0,0),this.repeat=new pe(1,1),this.center=new pe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(fl("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Qa?Bt:jr),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 i={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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==_m)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pr:e.x=e.x-Math.floor(e.x);break;case Wr:e.x=e.x<0?0:1;break;case vh: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 pr:e.y=e.y-Math.floor(e.y);break;case Wr:e.y=e.y<0?0:1;break;case vh: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 fl("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Bt?Qa:tg}set encoding(e){fl("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Qa?Bt:jr}}Wi.DEFAULT_IMAGE=null,Wi.DEFAULT_MAPPING=_m,Wi.DEFAULT_ANISOTROPY=1;class Zt{constructor(e=0,t=0,i=0,r=1){Zt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}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,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,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,i=this.y,r=this.z,a=this.w,s=e.elements;return this.x=s[0]*t+s[4]*i+s[8]*r+s[12]*a,this.y=s[1]*t+s[5]*i+s[9]*r+s[13]*a,this.z=s[2]*t+s[6]*i+s[10]*r+s[14]*a,this.w=s[3]*t+s[7]*i+s[11]*r+s[15]*a,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,i,r,a;const s=e.elements,l=s[0],h=s[4],c=s[8],d=s[1],p=s[5],f=s[9],m=s[2],_=s[6],x=s[10];if(Math.abs(h-d)<.01&&Math.abs(c-m)<.01&&Math.abs(f-_)<.01){if(Math.abs(h+d)<.1&&Math.abs(c+m)<.1&&Math.abs(f+_)<.1&&Math.abs(l+p+x-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const v=(l+1)/2,M=(p+1)/2,b=(x+1)/2,S=(h+d)/4,A=(c+m)/4,T=(f+_)/4;return v>M&&v>b?v<.01?(i=0,r=.707106781,a=.707106781):(i=Math.sqrt(v),r=S/i,a=A/i):M>b?M<.01?(i=.707106781,r=0,a=.707106781):(r=Math.sqrt(M),i=S/r,a=T/r):b<.01?(i=.707106781,r=.707106781,a=0):(a=Math.sqrt(b),i=A/a,r=T/a),this.set(i,r,a,t),this}let y=Math.sqrt((_-f)*(_-f)+(c-m)*(c-m)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(_-f)/y,this.y=(c-m)/y,this.z=(d-h)/y,this.w=Math.acos((l+p+x-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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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 Sb extends Yn{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Zt(0,0,e,t),this.scissorTest=!1,this.viewport=new Zt(0,0,e,t);const r={width:e,height:t,depth:1};i.encoding!==void 0&&(fl("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Qa?Bt:jr),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:fr,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},i),this.texture=new Wi(r,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=i.generateMipmaps,this.texture.internalFormat=i.internalFormat,this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.depthTexture=i.depthTexture,this.samples=i.samples}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,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 dg(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 Yi extends Sb{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class pg extends Wi{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=zi,this.minFilter=zi,this.wrapR=Wr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Eb extends Wi{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=zi,this.minFilter=zi,this.wrapR=Wr,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Rn{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,s,l){let h=i[r+0],c=i[r+1],d=i[r+2],p=i[r+3];const f=a[s+0],m=a[s+1],_=a[s+2],x=a[s+3];if(l===0){e[t+0]=h,e[t+1]=c,e[t+2]=d,e[t+3]=p;return}if(l===1){e[t+0]=f,e[t+1]=m,e[t+2]=_,e[t+3]=x;return}if(p!==x||h!==f||c!==m||d!==_){let y=1-l;const v=h*f+c*m+d*_+p*x,M=v>=0?1:-1,b=1-v*v;if(b>Number.EPSILON){const A=Math.sqrt(b),T=Math.atan2(A,v*M);y=Math.sin(y*T)/A,l=Math.sin(l*T)/A}const S=l*M;if(h=h*y+f*S,c=c*y+m*S,d=d*y+_*S,p=p*y+x*S,y===1-l){const A=1/Math.sqrt(h*h+c*c+d*d+p*p);h*=A,c*=A,d*=A,p*=A}}e[t]=h,e[t+1]=c,e[t+2]=d,e[t+3]=p}static multiplyQuaternionsFlat(e,t,i,r,a,s){const l=i[r],h=i[r+1],c=i[r+2],d=i[r+3],p=a[s],f=a[s+1],m=a[s+2],_=a[s+3];return e[t]=l*_+d*p+h*m-c*f,e[t+1]=h*_+d*f+c*p-l*m,e[t+2]=c*_+d*m+l*f-h*p,e[t+3]=d*_-l*p-h*f-c*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,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 i=e._x,r=e._y,a=e._z,s=e._order,l=Math.cos,h=Math.sin,c=l(i/2),d=l(r/2),p=l(a/2),f=h(i/2),m=h(r/2),_=h(a/2);switch(s){case"XYZ":this._x=f*d*p+c*m*_,this._y=c*m*p-f*d*_,this._z=c*d*_+f*m*p,this._w=c*d*p-f*m*_;break;case"YXZ":this._x=f*d*p+c*m*_,this._y=c*m*p-f*d*_,this._z=c*d*_-f*m*p,this._w=c*d*p+f*m*_;break;case"ZXY":this._x=f*d*p-c*m*_,this._y=c*m*p+f*d*_,this._z=c*d*_+f*m*p,this._w=c*d*p-f*m*_;break;case"ZYX":this._x=f*d*p-c*m*_,this._y=c*m*p+f*d*_,this._z=c*d*_-f*m*p,this._w=c*d*p+f*m*_;break;case"YZX":this._x=f*d*p+c*m*_,this._y=c*m*p+f*d*_,this._z=c*d*_-f*m*p,this._w=c*d*p-f*m*_;break;case"XZY":this._x=f*d*p-c*m*_,this._y=c*m*p-f*d*_,this._z=c*d*_+f*m*p,this._w=c*d*p+f*m*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],r=t[4],a=t[8],s=t[1],l=t[5],h=t[9],c=t[2],d=t[6],p=t[10],f=i+l+p;if(f>0){const m=.5/Math.sqrt(f+1);this._w=.25/m,this._x=(d-h)*m,this._y=(a-c)*m,this._z=(s-r)*m}else if(i>l&&i>p){const m=2*Math.sqrt(1+i-l-p);this._w=(d-h)/m,this._x=.25*m,this._y=(r+s)/m,this._z=(a+c)/m}else if(l>p){const m=2*Math.sqrt(1+l-i-p);this._w=(a-c)/m,this._x=(r+s)/m,this._y=.25*m,this._z=(h+d)/m}else{const m=2*Math.sqrt(1+p-i-l);this._w=(s-r)/m,this._x=(a+c)/m,this._y=(h+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ri(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const r=Math.min(1,t/i);return this.slerp(e,r),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 i=e._x,r=e._y,a=e._z,s=e._w,l=t._x,h=t._y,c=t._z,d=t._w;return this._x=i*d+s*l+r*c-a*h,this._y=r*d+s*h+a*l-i*c,this._z=a*d+s*c+i*h-r*l,this._w=s*d-i*l-r*h-a*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,r=this._y,a=this._z,s=this._w;let l=s*e._w+i*e._x+r*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=s,this._x=i,this._y=r,this._z=a,this;const h=1-l*l;if(h<=Number.EPSILON){const m=1-t;return this._w=m*s+t*this._w,this._x=m*i+t*this._x,this._y=m*r+t*this._y,this._z=m*a+t*this._z,this.normalize(),this}const c=Math.sqrt(h),d=Math.atan2(c,l),p=Math.sin((1-t)*d)/c,f=Math.sin(t*d)/c;return this._w=s*p+this._w*f,this._x=i*p+this._x*f,this._y=r*p+this._y*f,this._z=a*p+this._z*f,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(a),i*Math.cos(a),t*Math.sin(r))}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 z{constructor(e=0,t=0,i=0){z.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,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(fg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fg.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,r=this.z,a=e.elements,s=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*s,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*s,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*s,this}applyQuaternion(e){const t=this.x,i=this.y,r=this.z,a=e.x,s=e.y,l=e.z,h=e.w,c=2*(s*r-l*i),d=2*(l*t-a*r),p=2*(a*i-s*t);return this.x=t+h*c+s*p-l*d,this.y=i+h*d+l*c-a*p,this.z=r+h*p+a*d-s*c,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,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[10]*r,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,r=e.y,a=e.z,s=t.x,l=t.y,h=t.z;return this.x=r*h-a*l,this.y=a*s-i*h,this.z=i*l-r*s,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Qu.copy(this).projectOnVector(e),this.sub(Qu)}reflect(e){return this.sub(Qu.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 i=this.dot(e)/t;return Math.acos(Ri(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}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,i){const r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,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,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Qu=new z,fg=new Rn;class Fi{constructor(e=new z(1/0,1/0,1/0),t=new z(-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,i=e.length;t<i;t+=3)this.expandByPoint(fn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(fn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=fn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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 i=e.geometry;if(i!==void 0){const a=i.getAttribute("position");if(t===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let s=0,l=a.count;s<l;s++)e.isMesh===!0?e.getVertexPosition(s,fn):fn.fromBufferAttribute(a,s),fn.applyMatrix4(e.matrixWorld),this.expandByPoint(fn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Rh.copy(e.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Rh.copy(i.boundingBox)),Rh.applyMatrix4(e.matrixWorld),this.union(Rh)}const r=e.children;for(let a=0,s=r.length;a<s;a++)this.expandByObject(r[a],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,fn),fn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ml),Ch.subVectors(this.max,ml),Xs.subVectors(e.a,ml),qs.subVectors(e.b,ml),Ys.subVectors(e.c,ml),xa.subVectors(qs,Xs),ba.subVectors(Ys,qs),es.subVectors(Xs,Ys);let t=[0,-xa.z,xa.y,0,-ba.z,ba.y,0,-es.z,es.y,xa.z,0,-xa.x,ba.z,0,-ba.x,es.z,0,-es.x,-xa.y,xa.x,0,-ba.y,ba.x,0,-es.y,es.x,0];return!ed(t,Xs,qs,Ys,Ch)||(t=[1,0,0,0,1,0,0,0,1],!ed(t,Xs,qs,Ys,Ch))?!1:(Lh.crossVectors(xa,ba),t=[Lh.x,Lh.y,Lh.z],ed(t,Xs,qs,Ys,Ch))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,fn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(fn).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:(Kn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Kn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Kn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Kn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Kn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Kn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Kn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Kn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Kn),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 Kn=[new z,new z,new z,new z,new z,new z,new z,new z],fn=new z,Rh=new Fi,Xs=new z,qs=new z,Ys=new z,xa=new z,ba=new z,es=new z,ml=new z,Ch=new z,Lh=new z,ts=new z;function ed(n,e,t,i,r){for(let a=0,s=n.length-3;a<=s;a+=3){ts.fromArray(n,a);const l=r.x*Math.abs(ts.x)+r.y*Math.abs(ts.y)+r.z*Math.abs(ts.z),h=e.dot(ts),c=t.dot(ts),d=i.dot(ts);if(Math.max(-Math.max(h,c,d),Math.min(h,c,d))>l)return!1}return!0}const Ab=new Fi,gl=new z,td=new z;class Cn{constructor(e=new z,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 i=this.center;t!==void 0?i.copy(t):Ab.setFromPoints(e).getCenter(i);let r=0;for(let a=0,s=e.length;a<s;a++)r=Math.max(r,i.distanceToSquared(e[a]));return this.radius=Math.sqrt(r),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 i=this.center.distanceToSquared(e);return t.copy(e),i>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;gl.subVectors(e,this.center);const t=gl.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),r=(i-this.radius)*.5;this.center.addScaledVector(gl,r/i),this.radius+=r}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):(td.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(gl.copy(e.center).add(td)),this.expandByPoint(gl.copy(e.center).sub(td))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Zn=new z,id=new z,Ph=new z,wa=new z,rd=new z,Dh=new z,nd=new z;class is{constructor(e=new z,t=new z(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,Zn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Zn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Zn.copy(this.origin).addScaledVector(this.direction,t),Zn.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){id.copy(e).add(t).multiplyScalar(.5),Ph.copy(t).sub(e).normalize(),wa.copy(this.origin).sub(id);const a=e.distanceTo(t)*.5,s=-this.direction.dot(Ph),l=wa.dot(this.direction),h=-wa.dot(Ph),c=wa.lengthSq(),d=Math.abs(1-s*s);let p,f,m,_;if(d>0)if(p=s*h-l,f=s*l-h,_=a*d,p>=0)if(f>=-_)if(f<=_){const x=1/d;p*=x,f*=x,m=p*(p+s*f+2*l)+f*(s*p+f+2*h)+c}else f=a,p=Math.max(0,-(s*f+l)),m=-p*p+f*(f+2*h)+c;else f=-a,p=Math.max(0,-(s*f+l)),m=-p*p+f*(f+2*h)+c;else f<=-_?(p=Math.max(0,-(-s*a+l)),f=p>0?-a:Math.min(Math.max(-a,-h),a),m=-p*p+f*(f+2*h)+c):f<=_?(p=0,f=Math.min(Math.max(-a,-h),a),m=f*(f+2*h)+c):(p=Math.max(0,-(s*a+l)),f=p>0?a:Math.min(Math.max(-a,-h),a),m=-p*p+f*(f+2*h)+c);else f=s>0?-a:a,p=Math.max(0,-(s*f+l)),m=-p*p+f*(f+2*h)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,p),r&&r.copy(id).addScaledVector(Ph,f),m}intersectSphere(e,t){Zn.subVectors(e.center,this.origin);const i=Zn.dot(this.direction),r=Zn.dot(Zn)-i*i,a=e.radius*e.radius;if(r>a)return null;const s=Math.sqrt(a-r),l=i-s,h=i+s;return h<0?null:l<0?this.at(h,t):this.at(l,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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,a,s,l,h;const c=1/this.direction.x,d=1/this.direction.y,p=1/this.direction.z,f=this.origin;return c>=0?(i=(e.min.x-f.x)*c,r=(e.max.x-f.x)*c):(i=(e.max.x-f.x)*c,r=(e.min.x-f.x)*c),d>=0?(a=(e.min.y-f.y)*d,s=(e.max.y-f.y)*d):(a=(e.max.y-f.y)*d,s=(e.min.y-f.y)*d),i>s||a>r||((a>i||isNaN(i))&&(i=a),(s<r||isNaN(r))&&(r=s),p>=0?(l=(e.min.z-f.z)*p,h=(e.max.z-f.z)*p):(l=(e.max.z-f.z)*p,h=(e.min.z-f.z)*p),i>h||l>r)||((l>i||i!==i)&&(i=l),(h<r||r!==r)&&(r=h),r<0)?null:this.at(i>=0?i:r,t)}intersectsBox(e){return this.intersectBox(e,Zn)!==null}intersectTriangle(e,t,i,r,a){rd.subVectors(t,e),Dh.subVectors(i,e),nd.crossVectors(rd,Dh);let s=this.direction.dot(nd),l;if(s>0){if(r)return null;l=1}else if(s<0)l=-1,s=-s;else return null;wa.subVectors(this.origin,e);const h=l*this.direction.dot(Dh.crossVectors(wa,Dh));if(h<0)return null;const c=l*this.direction.dot(rd.cross(wa));if(c<0||h+c>s)return null;const d=-l*wa.dot(nd);return d<0?null:this.at(d/s,a)}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 Ze{constructor(e,t,i,r,a,s,l,h,c,d,p,f,m,_,x,y){Ze.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,i,r,a,s,l,h,c,d,p,f,m,_,x,y)}set(e,t,i,r,a,s,l,h,c,d,p,f,m,_,x,y){const v=this.elements;return v[0]=e,v[4]=t,v[8]=i,v[12]=r,v[1]=a,v[5]=s,v[9]=l,v[13]=h,v[2]=c,v[6]=d,v[10]=p,v[14]=f,v[3]=m,v[7]=_,v[11]=x,v[15]=y,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 Ze().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,r=1/Ks.setFromMatrixColumn(e,0).length(),a=1/Ks.setFromMatrixColumn(e,1).length(),s=1/Ks.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*s,t[9]=i[9]*s,t[10]=i[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,i=e.x,r=e.y,a=e.z,s=Math.cos(i),l=Math.sin(i),h=Math.cos(r),c=Math.sin(r),d=Math.cos(a),p=Math.sin(a);if(e.order==="XYZ"){const f=s*d,m=s*p,_=l*d,x=l*p;t[0]=h*d,t[4]=-h*p,t[8]=c,t[1]=m+_*c,t[5]=f-x*c,t[9]=-l*h,t[2]=x-f*c,t[6]=_+m*c,t[10]=s*h}else if(e.order==="YXZ"){const f=h*d,m=h*p,_=c*d,x=c*p;t[0]=f+x*l,t[4]=_*l-m,t[8]=s*c,t[1]=s*p,t[5]=s*d,t[9]=-l,t[2]=m*l-_,t[6]=x+f*l,t[10]=s*h}else if(e.order==="ZXY"){const f=h*d,m=h*p,_=c*d,x=c*p;t[0]=f-x*l,t[4]=-s*p,t[8]=_+m*l,t[1]=m+_*l,t[5]=s*d,t[9]=x-f*l,t[2]=-s*c,t[6]=l,t[10]=s*h}else if(e.order==="ZYX"){const f=s*d,m=s*p,_=l*d,x=l*p;t[0]=h*d,t[4]=_*c-m,t[8]=f*c+x,t[1]=h*p,t[5]=x*c+f,t[9]=m*c-_,t[2]=-c,t[6]=l*h,t[10]=s*h}else if(e.order==="YZX"){const f=s*h,m=s*c,_=l*h,x=l*c;t[0]=h*d,t[4]=x-f*p,t[8]=_*p+m,t[1]=p,t[5]=s*d,t[9]=-l*d,t[2]=-c*d,t[6]=m*p+_,t[10]=f-x*p}else if(e.order==="XZY"){const f=s*h,m=s*c,_=l*h,x=l*c;t[0]=h*d,t[4]=-p,t[8]=c*d,t[1]=f*p+x,t[5]=s*d,t[9]=m*p-_,t[2]=_*p-m,t[6]=l*d,t[10]=x*p+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(Rb,e,Cb)}lookAt(e,t,i){const r=this.elements;return Lr.subVectors(e,t),Lr.lengthSq()===0&&(Lr.z=1),Lr.normalize(),Ma.crossVectors(i,Lr),Ma.lengthSq()===0&&(Math.abs(i.z)===1?Lr.x+=1e-4:Lr.z+=1e-4,Lr.normalize(),Ma.crossVectors(i,Lr)),Ma.normalize(),Ih.crossVectors(Lr,Ma),r[0]=Ma.x,r[4]=Ih.x,r[8]=Lr.x,r[1]=Ma.y,r[5]=Ih.y,r[9]=Lr.y,r[2]=Ma.z,r[6]=Ih.z,r[10]=Lr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,r=t.elements,a=this.elements,s=i[0],l=i[4],h=i[8],c=i[12],d=i[1],p=i[5],f=i[9],m=i[13],_=i[2],x=i[6],y=i[10],v=i[14],M=i[3],b=i[7],S=i[11],A=i[15],T=r[0],E=r[4],I=r[8],C=r[12],P=r[1],X=r[5],q=r[9],te=r[13],k=r[2],H=r[6],V=r[10],J=r[14],ie=r[3],$=r[7],ne=r[11],he=r[15];return a[0]=s*T+l*P+h*k+c*ie,a[4]=s*E+l*X+h*H+c*$,a[8]=s*I+l*q+h*V+c*ne,a[12]=s*C+l*te+h*J+c*he,a[1]=d*T+p*P+f*k+m*ie,a[5]=d*E+p*X+f*H+m*$,a[9]=d*I+p*q+f*V+m*ne,a[13]=d*C+p*te+f*J+m*he,a[2]=_*T+x*P+y*k+v*ie,a[6]=_*E+x*X+y*H+v*$,a[10]=_*I+x*q+y*V+v*ne,a[14]=_*C+x*te+y*J+v*he,a[3]=M*T+b*P+S*k+A*ie,a[7]=M*E+b*X+S*H+A*$,a[11]=M*I+b*q+S*V+A*ne,a[15]=M*C+b*te+S*J+A*he,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],i=e[4],r=e[8],a=e[12],s=e[1],l=e[5],h=e[9],c=e[13],d=e[2],p=e[6],f=e[10],m=e[14],_=e[3],x=e[7],y=e[11],v=e[15];return _*(+a*h*p-r*c*p-a*l*f+i*c*f+r*l*m-i*h*m)+x*(+t*h*m-t*c*f+a*s*f-r*s*m+r*c*d-a*h*d)+y*(+t*c*p-t*l*m-a*s*p+i*s*m+a*l*d-i*c*d)+v*(-r*l*d-t*h*p+t*l*f+r*s*p-i*s*f+i*h*d)}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,i){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],s=e[4],l=e[5],h=e[6],c=e[7],d=e[8],p=e[9],f=e[10],m=e[11],_=e[12],x=e[13],y=e[14],v=e[15],M=p*y*c-x*f*c+x*h*m-l*y*m-p*h*v+l*f*v,b=_*f*c-d*y*c-_*h*m+s*y*m+d*h*v-s*f*v,S=d*x*c-_*p*c+_*l*m-s*x*m-d*l*v+s*p*v,A=_*p*h-d*x*h-_*l*f+s*x*f+d*l*y-s*p*y,T=t*M+i*b+r*S+a*A;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/T;return e[0]=M*E,e[1]=(x*f*a-p*y*a-x*r*m+i*y*m+p*r*v-i*f*v)*E,e[2]=(l*y*a-x*h*a+x*r*c-i*y*c-l*r*v+i*h*v)*E,e[3]=(p*h*a-l*f*a-p*r*c+i*f*c+l*r*m-i*h*m)*E,e[4]=b*E,e[5]=(d*y*a-_*f*a+_*r*m-t*y*m-d*r*v+t*f*v)*E,e[6]=(_*h*a-s*y*a-_*r*c+t*y*c+s*r*v-t*h*v)*E,e[7]=(s*f*a-d*h*a+d*r*c-t*f*c-s*r*m+t*h*m)*E,e[8]=S*E,e[9]=(_*p*a-d*x*a-_*i*m+t*x*m+d*i*v-t*p*v)*E,e[10]=(s*x*a-_*l*a+_*i*c-t*x*c-s*i*v+t*l*v)*E,e[11]=(d*l*a-s*p*a-d*i*c+t*p*c+s*i*m-t*l*m)*E,e[12]=A*E,e[13]=(d*x*r-_*p*r+_*i*f-t*x*f-d*i*y+t*p*y)*E,e[14]=(_*l*r-s*x*r-_*i*h+t*x*h+s*i*y-t*l*y)*E,e[15]=(s*p*r-d*l*r+d*i*h-t*p*h-s*i*f+t*l*f)*E,this}scale(e){const t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),r=Math.sin(t),a=1-i,s=e.x,l=e.y,h=e.z,c=a*s,d=a*l;return this.set(c*s+i,c*l-r*h,c*h+r*l,0,c*l+r*h,d*l+i,d*h-r*s,0,c*h-r*l,d*h+r*s,a*h*h+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,s){return this.set(1,i,a,0,e,1,s,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){const r=this.elements,a=t._x,s=t._y,l=t._z,h=t._w,c=a+a,d=s+s,p=l+l,f=a*c,m=a*d,_=a*p,x=s*d,y=s*p,v=l*p,M=h*c,b=h*d,S=h*p,A=i.x,T=i.y,E=i.z;return r[0]=(1-(x+v))*A,r[1]=(m+S)*A,r[2]=(_-b)*A,r[3]=0,r[4]=(m-S)*T,r[5]=(1-(f+v))*T,r[6]=(y+M)*T,r[7]=0,r[8]=(_+b)*E,r[9]=(y-M)*E,r[10]=(1-(f+x))*E,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){const r=this.elements;let a=Ks.set(r[0],r[1],r[2]).length();const s=Ks.set(r[4],r[5],r[6]).length(),l=Ks.set(r[8],r[9],r[10]).length();this.determinant()<0&&(a=-a),e.x=r[12],e.y=r[13],e.z=r[14],mn.copy(this);const h=1/a,c=1/s,d=1/l;return mn.elements[0]*=h,mn.elements[1]*=h,mn.elements[2]*=h,mn.elements[4]*=c,mn.elements[5]*=c,mn.elements[6]*=c,mn.elements[8]*=d,mn.elements[9]*=d,mn.elements[10]*=d,t.setFromRotationMatrix(mn),i.x=a,i.y=s,i.z=l,this}makePerspective(e,t,i,r,a,s,l=qn){const h=this.elements,c=2*a/(t-e),d=2*a/(i-r),p=(t+e)/(t-e),f=(i+r)/(i-r);let m,_;if(l===qn)m=-(s+a)/(s-a),_=-2*s*a/(s-a);else if(l===Sh)m=-s/(s-a),_=-s*a/(s-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return h[0]=c,h[4]=0,h[8]=p,h[12]=0,h[1]=0,h[5]=d,h[9]=f,h[13]=0,h[2]=0,h[6]=0,h[10]=m,h[14]=_,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,r,a,s,l=qn){const h=this.elements,c=1/(t-e),d=1/(i-r),p=1/(s-a),f=(t+e)*c,m=(i+r)*d;let _,x;if(l===qn)_=(s+a)*p,x=-2*p;else if(l===Sh)_=a*p,x=-1*p;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return h[0]=2*c,h[4]=0,h[8]=0,h[12]=-f,h[1]=0,h[5]=2*d,h[9]=0,h[13]=-m,h[2]=0,h[6]=0,h[10]=x,h[14]=-_,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){const t=this.elements,i=e.elements;for(let r=0;r<16;r++)if(t[r]!==i[r])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Ks=new z,mn=new Ze,Rb=new z(0,0,0),Cb=new z(1,1,1),Ma=new z,Ih=new z,Lr=new z,mg=new Ze,gg=new Rn;class rs{constructor(e=0,t=0,i=0,r=rs.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}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,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,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,i=!0){const r=e.elements,a=r[0],s=r[4],l=r[8],h=r[1],c=r[5],d=r[9],p=r[2],f=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(Ri(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-s,a)):(this._x=Math.atan2(f,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ri(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(h,c)):(this._y=Math.atan2(-p,a),this._z=0);break;case"ZXY":this._x=Math.asin(Ri(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-p,m),this._z=Math.atan2(-s,c)):(this._y=0,this._z=Math.atan2(h,a));break;case"ZYX":this._y=Math.asin(-Ri(p,-1,1)),Math.abs(p)<.9999999?(this._x=Math.atan2(f,m),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-s,c));break;case"YZX":this._z=Math.asin(Ri(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-p,a)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Ri(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(f,c),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return mg.makeRotationFromQuaternion(e),this.setFromRotationMatrix(mg,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gg.setFromEuler(this),this.setFromQuaternion(gg,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}}rs.DEFAULT_ORDER="XYZ";class ad{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 Lb=0;const _g=new z,Zs=new Rn,Jn=new Ze,Oh=new z,_l=new z,Pb=new z,Db=new Rn,vg=new z(1,0,0),yg=new z(0,1,0),xg=new z(0,0,1),Ib={type:"added"},Ob={type:"removed"};class ei extends Yn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Lb++}),this.uuid=Xr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ei.DEFAULT_UP.clone();const e=new z,t=new rs,i=new Rn,r=new z(1,1,1);function a(){i.setFromEuler(t,!1)}function s(){t.setFromQuaternion(i,void 0,!1)}t._onChange(a),i._onChange(s),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Ze},normalMatrix:{value:new yt}}),this.matrix=new Ze,this.matrixWorld=new Ze,this.matrixAutoUpdate=ei.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ei.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ad,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 Zs.setFromAxisAngle(e,t),this.quaternion.multiply(Zs),this}rotateOnWorldAxis(e,t){return Zs.setFromAxisAngle(e,t),this.quaternion.premultiply(Zs),this}rotateX(e){return this.rotateOnAxis(vg,e)}rotateY(e){return this.rotateOnAxis(yg,e)}rotateZ(e){return this.rotateOnAxis(xg,e)}translateOnAxis(e,t){return _g.copy(e).applyQuaternion(this.quaternion),this.position.add(_g.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(vg,e)}translateY(e){return this.translateOnAxis(yg,e)}translateZ(e){return this.translateOnAxis(xg,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Jn.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?Oh.copy(e):Oh.set(e,t,i);const r=this.parent;this.updateWorldMatrix(!0,!1),_l.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Jn.lookAt(_l,Oh,this.up):Jn.lookAt(Oh,_l,this.up),this.quaternion.setFromRotationMatrix(Jn),r&&(Jn.extractRotation(r.matrixWorld),Zs.setFromRotationMatrix(Jn),this.quaternion.premultiply(Zs.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(Ib)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ob)),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),Jn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Jn.multiply(e.parent.matrixWorld)),e.applyMatrix4(Jn),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 i=0,r=this.children.length;i<r;i++){const a=this.children[i].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,i=[]){this[e]===t&&i.push(this);const r=this.children;for(let a=0,s=r.length;a<s;a++)r[a].getObjectsByProperty(e,t,i);return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_l,e,Pb),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(_l,Db,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 i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].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 i=0,r=t.length;i<r;i++){const a=t[i];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const i=this.parent;if(e===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.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 r=this.children;for(let a=0,s=r.length;a<s;a++){const l=r[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=e===void 0||typeof e=="string",i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function a(l,h){return l[h.uuid]===void 0&&(l[h.uuid]=h.toJSON(e)),h.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const h=l.shapes;if(Array.isArray(h))for(let c=0,d=h.length;c<d;c++){const p=h[c];a(e.shapes,p)}else a(e.shapes,h)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let h=0,c=this.material.length;h<c;h++)l.push(a(e.materials,this.material[h]));r.material=l}else r.material=a(e.materials,this.material);if(this.children.length>0){r.children=[];for(let l=0;l<this.children.length;l++)r.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let l=0;l<this.animations.length;l++){const h=this.animations[l];r.animations.push(a(e.animations,h))}}if(t){const l=s(e.geometries),h=s(e.materials),c=s(e.textures),d=s(e.images),p=s(e.shapes),f=s(e.skeletons),m=s(e.animations),_=s(e.nodes);l.length>0&&(i.geometries=l),h.length>0&&(i.materials=h),c.length>0&&(i.textures=c),d.length>0&&(i.images=d),p.length>0&&(i.shapes=p),f.length>0&&(i.skeletons=f),m.length>0&&(i.animations=m),_.length>0&&(i.nodes=_)}return i.object=r,i;function s(l){const h=[];for(const c in l){const d=l[c];delete d.metadata,h.push(d)}return h}}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 i=0;i<e.children.length;i++){const r=e.children[i];this.add(r.clone())}return this}}ei.DEFAULT_UP=new z(0,1,0),ei.DEFAULT_MATRIX_AUTO_UPDATE=!0,ei.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const gn=new z,$n=new z,sd=new z,Qn=new z,Js=new z,$s=new z,bg=new z,od=new z,ld=new z,hd=new z;let Nh=!1;class _n{constructor(e=new z,t=new z,i=new z){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){r.subVectors(i,t),gn.subVectors(e,t),r.cross(gn);const a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){gn.subVectors(r,t),$n.subVectors(i,t),sd.subVectors(e,t);const s=gn.dot(gn),l=gn.dot($n),h=gn.dot(sd),c=$n.dot($n),d=$n.dot(sd),p=s*c-l*l;if(p===0)return a.set(0,0,0),null;const f=1/p,m=(c*h-l*d)*f,_=(s*d-l*h)*f;return a.set(1-m-_,_,m)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,Qn)===null?!1:Qn.x>=0&&Qn.y>=0&&Qn.x+Qn.y<=1}static getUV(e,t,i,r,a,s,l,h){return Nh===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Nh=!0),this.getInterpolation(e,t,i,r,a,s,l,h)}static getInterpolation(e,t,i,r,a,s,l,h){return this.getBarycoord(e,t,i,r,Qn)===null?(h.x=0,h.y=0,"z"in h&&(h.z=0),"w"in h&&(h.w=0),null):(h.setScalar(0),h.addScaledVector(a,Qn.x),h.addScaledVector(s,Qn.y),h.addScaledVector(l,Qn.z),h)}static isFrontFacing(e,t,i,r){return gn.subVectors(i,t),$n.subVectors(e,t),gn.cross($n).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),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 gn.subVectors(this.c,this.b),$n.subVectors(this.a,this.b),gn.cross($n).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return _n.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return _n.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,a){return Nh===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Nh=!0),_n.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}getInterpolation(e,t,i,r,a){return _n.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return _n.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return _n.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,r=this.b,a=this.c;let s,l;Js.subVectors(r,i),$s.subVectors(a,i),od.subVectors(e,i);const h=Js.dot(od),c=$s.dot(od);if(h<=0&&c<=0)return t.copy(i);ld.subVectors(e,r);const d=Js.dot(ld),p=$s.dot(ld);if(d>=0&&p<=d)return t.copy(r);const f=h*p-d*c;if(f<=0&&h>=0&&d<=0)return s=h/(h-d),t.copy(i).addScaledVector(Js,s);hd.subVectors(e,a);const m=Js.dot(hd),_=$s.dot(hd);if(_>=0&&m<=_)return t.copy(a);const x=m*c-h*_;if(x<=0&&c>=0&&_<=0)return l=c/(c-_),t.copy(i).addScaledVector($s,l);const y=d*_-m*p;if(y<=0&&p-d>=0&&m-_>=0)return bg.subVectors(a,r),l=(p-d)/(p-d+(m-_)),t.copy(r).addScaledVector(bg,l);const v=1/(y+x+f);return s=x*v,l=f*v,t.copy(i).addScaledVector(Js,s).addScaledVector($s,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const wg={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},Ta={h:0,s:0,l:0},Uh={h:0,s:0,l:0};function cd(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Ke{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Bt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Gt.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Gt.workingColorSpace){return this.r=e,this.g=t,this.b=i,Gt.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Gt.workingColorSpace){if(e=Yu(e,1),t=Ri(t,0,1),i=Ri(i,0,1),t===0)this.r=this.g=this.b=i;else{const a=i<=.5?i*(1+t):i+t-i*t,s=2*i-a;this.r=cd(s,a,e+1/3),this.g=cd(s,a,e),this.b=cd(s,a,e-1/3)}return Gt.toWorkingColorSpace(this,r),this}setStyle(e,t=Bt){function i(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const s=r[1],l=r[2];switch(s){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return i(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return i(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return i(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=r[1],s=a.length;if(s===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,t);if(s===6)return this.setHex(parseInt(a,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=Bt){const i=wg[e.toLowerCase()];return i!==void 0?this.setHex(i,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=Ws(e.r),this.g=Ws(e.g),this.b=Ws(e.b),this}copyLinearToSRGB(e){return this.r=Ju(e.r),this.g=Ju(e.g),this.b=Ju(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Bt){return Gt.fromWorkingColorSpace(Ki.copy(this),e),Math.round(Ri(Ki.r*255,0,255))*65536+Math.round(Ri(Ki.g*255,0,255))*256+Math.round(Ri(Ki.b*255,0,255))}getHexString(e=Bt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Gt.workingColorSpace){Gt.fromWorkingColorSpace(Ki.copy(this),t);const i=Ki.r,r=Ki.g,a=Ki.b,s=Math.max(i,r,a),l=Math.min(i,r,a);let h,c;const d=(l+s)/2;if(l===s)h=0,c=0;else{const p=s-l;switch(c=d<=.5?p/(s+l):p/(2-s-l),s){case i:h=(r-a)/p+(r<a?6:0);break;case r:h=(a-i)/p+2;break;case a:h=(i-r)/p+4;break}h/=6}return e.h=h,e.s=c,e.l=d,e}getRGB(e,t=Gt.workingColorSpace){return Gt.fromWorkingColorSpace(Ki.copy(this),t),e.r=Ki.r,e.g=Ki.g,e.b=Ki.b,e}getStyle(e=Bt){Gt.fromWorkingColorSpace(Ki.copy(this),e);const t=Ki.r,i=Ki.g,r=Ki.b;return e!==Bt?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(r*255)})`}offsetHSL(e,t,i){return this.getHSL(Ta),this.setHSL(Ta.h+e,Ta.s+t,Ta.l+i)}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,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(Ta),e.getHSL(Uh);const i=ul(Ta.h,Uh.h,t),r=ul(Ta.s,Uh.s,t),a=ul(Ta.l,Uh.l,t);return this.setHSL(i,r,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,i=this.g,r=this.b,a=e.elements;return this.r=a[0]*t+a[3]*i+a[6]*r,this.g=a[1]*t+a[4]*i+a[7]*r,this.b=a[2]*t+a[5]*i+a[8]*r,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 Ki=new Ke;Ke.NAMES=wg;let Nb=0;class qr extends Yn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Nb++}),this.uuid=Xr(),this.name="",this.type="Material",this.blending=zs,this.side=jn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Du,this.blendDst=Iu,this.blendEquation=Ka,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ke(0,0,0),this.blendAlpha=0,this.depthFunc=mh,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=rg,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Gs,this.stencilZFail=Gs,this.stencilZPass=Gs,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 i=e[t];if(i===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==jn&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Du&&(i.blendSrc=this.blendSrc),this.blendDst!==Iu&&(i.blendDst=this.blendDst),this.blendEquation!==Ka&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==mh&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==rg&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Gs&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Gs&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Gs&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function r(a){const s=[];for(const l in a){const h=a[l];delete h.metadata,s.push(h)}return s}if(t){const a=r(e.textures),s=r(e.images);a.length>0&&(i.textures=a),s.length>0&&(i.images=s)}return i}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 i=null;if(t!==null){const r=t.length;i=new Array(r);for(let a=0;a!==r;++a)i[a]=t[a].clone()}return this.clippingPlanes=i,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 vn extends qr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ke(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=gh,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 Ei=new z,zh=new pe;class mi{constructor(e,t,i=!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=i,this.usage=Xu,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Xn,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,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,a=this.itemSize;r<a;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,i=this.count;t<i;t++)zh.fromBufferAttribute(this,t),zh.applyMatrix3(e),this.setXY(t,zh.x,zh.y);else if(this.itemSize===3)for(let t=0,i=this.count;t<i;t++)Ei.fromBufferAttribute(this,t),Ei.applyMatrix3(e),this.setXYZ(t,Ei.x,Ei.y,Ei.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Ei.fromBufferAttribute(this,t),Ei.applyMatrix4(e),this.setXYZ(t,Ei.x,Ei.y,Ei.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Ei.fromBufferAttribute(this,t),Ei.applyNormalMatrix(e),this.setXYZ(t,Ei.x,Ei.y,Ei.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Ei.fromBufferAttribute(this,t),Ei.transformDirection(e),this.setXYZ(t,Ei.x,Ei.y,Ei.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=An(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=Kt(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=An(t,this.array)),t}setX(e,t){return this.normalized&&(t=Kt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=An(t,this.array)),t}setY(e,t){return this.normalized&&(t=Kt(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=An(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Kt(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=An(t,this.array)),t}setW(e,t){return this.normalized&&(t=Kt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e*=this.itemSize,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array),a=Kt(a,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=a,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!==Xu&&(e.usage=this.usage),e}}class Mg extends mi{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Tg extends mi{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class bi extends mi{constructor(e,t,i){super(new Float32Array(e),t,i)}}let Ub=0;const Yr=new Ze,ud=new ei,Qs=new z,Pr=new Fi,vl=new Fi,ki=new z;class si extends Yn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ub++}),this.uuid=Xr(),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(og(e)?Tg:Mg)(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,i=0){this.groups.push({start:e,count:t,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const a=new yt().getNormalMatrix(e);i.applyNormalMatrix(a),i.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Yr.makeRotationFromQuaternion(e),this.applyMatrix4(Yr),this}rotateX(e){return Yr.makeRotationX(e),this.applyMatrix4(Yr),this}rotateY(e){return Yr.makeRotationY(e),this.applyMatrix4(Yr),this}rotateZ(e){return Yr.makeRotationZ(e),this.applyMatrix4(Yr),this}translate(e,t,i){return Yr.makeTranslation(e,t,i),this.applyMatrix4(Yr),this}scale(e,t,i){return Yr.makeScale(e,t,i),this.applyMatrix4(Yr),this}lookAt(e){return ud.lookAt(e),ud.updateMatrix(),this.applyMatrix4(ud.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Qs).negate(),this.translate(Qs.x,Qs.y,Qs.z),this}setFromPoints(e){const t=[];for(let i=0,r=e.length;i<r;i++){const a=e[i];t.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new bi(t,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Fi);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 z(-1/0,-1/0,-1/0),new z(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,r=t.length;i<r;i++){const a=t[i];Pr.setFromBufferAttribute(a),this.morphTargetsRelative?(ki.addVectors(this.boundingBox.min,Pr.min),this.boundingBox.expandByPoint(ki),ki.addVectors(this.boundingBox.max,Pr.max),this.boundingBox.expandByPoint(ki)):(this.boundingBox.expandByPoint(Pr.min),this.boundingBox.expandByPoint(Pr.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 Cn);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 z,1/0);return}if(e){const i=this.boundingSphere.center;if(Pr.setFromBufferAttribute(e),t)for(let a=0,s=t.length;a<s;a++){const l=t[a];vl.setFromBufferAttribute(l),this.morphTargetsRelative?(ki.addVectors(Pr.min,vl.min),Pr.expandByPoint(ki),ki.addVectors(Pr.max,vl.max),Pr.expandByPoint(ki)):(Pr.expandByPoint(vl.min),Pr.expandByPoint(vl.max))}Pr.getCenter(i);let r=0;for(let a=0,s=e.count;a<s;a++)ki.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(ki));if(t)for(let a=0,s=t.length;a<s;a++){const l=t[a],h=this.morphTargetsRelative;for(let c=0,d=l.count;c<d;c++)ki.fromBufferAttribute(l,c),h&&(Qs.fromBufferAttribute(e,c),ki.add(Qs)),r=Math.max(r,i.distanceToSquared(ki))}this.boundingSphere.radius=Math.sqrt(r),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 i=e.array,r=t.position.array,a=t.normal.array,s=t.uv.array,l=r.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new mi(new Float32Array(4*l),4));const h=this.getAttribute("tangent").array,c=[],d=[];for(let P=0;P<l;P++)c[P]=new z,d[P]=new z;const p=new z,f=new z,m=new z,_=new pe,x=new pe,y=new pe,v=new z,M=new z;function b(P,X,q){p.fromArray(r,P*3),f.fromArray(r,X*3),m.fromArray(r,q*3),_.fromArray(s,P*2),x.fromArray(s,X*2),y.fromArray(s,q*2),f.sub(p),m.sub(p),x.sub(_),y.sub(_);const te=1/(x.x*y.y-y.x*x.y);isFinite(te)&&(v.copy(f).multiplyScalar(y.y).addScaledVector(m,-x.y).multiplyScalar(te),M.copy(m).multiplyScalar(x.x).addScaledVector(f,-y.x).multiplyScalar(te),c[P].add(v),c[X].add(v),c[q].add(v),d[P].add(M),d[X].add(M),d[q].add(M))}let S=this.groups;S.length===0&&(S=[{start:0,count:i.length}]);for(let P=0,X=S.length;P<X;++P){const q=S[P],te=q.start,k=q.count;for(let H=te,V=te+k;H<V;H+=3)b(i[H+0],i[H+1],i[H+2])}const A=new z,T=new z,E=new z,I=new z;function C(P){E.fromArray(a,P*3),I.copy(E);const X=c[P];A.copy(X),A.sub(E.multiplyScalar(E.dot(X))).normalize(),T.crossVectors(I,X);const q=T.dot(d[P])<0?-1:1;h[P*4]=A.x,h[P*4+1]=A.y,h[P*4+2]=A.z,h[P*4+3]=q}for(let P=0,X=S.length;P<X;++P){const q=S[P],te=q.start,k=q.count;for(let H=te,V=te+k;H<V;H+=3)C(i[H+0]),C(i[H+1]),C(i[H+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new mi(new Float32Array(t.count*3),3),this.setAttribute("normal",i);else for(let f=0,m=i.count;f<m;f++)i.setXYZ(f,0,0,0);const r=new z,a=new z,s=new z,l=new z,h=new z,c=new z,d=new z,p=new z;if(e)for(let f=0,m=e.count;f<m;f+=3){const _=e.getX(f+0),x=e.getX(f+1),y=e.getX(f+2);r.fromBufferAttribute(t,_),a.fromBufferAttribute(t,x),s.fromBufferAttribute(t,y),d.subVectors(s,a),p.subVectors(r,a),d.cross(p),l.fromBufferAttribute(i,_),h.fromBufferAttribute(i,x),c.fromBufferAttribute(i,y),l.add(d),h.add(d),c.add(d),i.setXYZ(_,l.x,l.y,l.z),i.setXYZ(x,h.x,h.y,h.z),i.setXYZ(y,c.x,c.y,c.z)}else for(let f=0,m=t.count;f<m;f+=3)r.fromBufferAttribute(t,f+0),a.fromBufferAttribute(t,f+1),s.fromBufferAttribute(t,f+2),d.subVectors(s,a),p.subVectors(r,a),d.cross(p),i.setXYZ(f+0,d.x,d.y,d.z),i.setXYZ(f+1,d.x,d.y,d.z),i.setXYZ(f+2,d.x,d.y,d.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ki.fromBufferAttribute(e,t),ki.normalize(),e.setXYZ(t,ki.x,ki.y,ki.z)}toNonIndexed(){function e(l,h){const c=l.array,d=l.itemSize,p=l.normalized,f=new c.constructor(h.length*d);let m=0,_=0;for(let x=0,y=h.length;x<y;x++){l.isInterleavedBufferAttribute?m=h[x]*l.data.stride+l.offset:m=h[x]*d;for(let v=0;v<d;v++)f[_++]=c[m++]}return new mi(f,d,p)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new si,i=this.index.array,r=this.attributes;for(const l in r){const h=r[l],c=e(h,i);t.setAttribute(l,c)}const a=this.morphAttributes;for(const l in a){const h=[],c=a[l];for(let d=0,p=c.length;d<p;d++){const f=c[d],m=e(f,i);h.push(m)}t.morphAttributes[l]=h}t.morphTargetsRelative=this.morphTargetsRelative;const s=this.groups;for(let l=0,h=s.length;l<h;l++){const c=s[l];t.addGroup(c.start,c.count,c.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 h=this.parameters;for(const c in h)h[c]!==void 0&&(e[c]=h[c]);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 i=this.attributes;for(const h in i){const c=i[h];e.data.attributes[h]=c.toJSON(e.data)}const r={};let a=!1;for(const h in this.morphAttributes){const c=this.morphAttributes[h],d=[];for(let p=0,f=c.length;p<f;p++){const m=c[p];d.push(m.toJSON(e.data))}d.length>0&&(r[h]=d,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const l=this.boundingSphere;return l!==null&&(e.data.boundingSphere={center:l.center.toArray(),radius:l.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 i=e.index;i!==null&&this.setIndex(i.clone(t));const r=e.attributes;for(const c in r){const d=r[c];this.setAttribute(c,d.clone(t))}const a=e.morphAttributes;for(const c in a){const d=[],p=a[c];for(let f=0,m=p.length;f<m;f++)d.push(p[f].clone(t));this.morphAttributes[c]=d}this.morphTargetsRelative=e.morphTargetsRelative;const s=e.groups;for(let c=0,d=s.length;c<d;c++){const p=s[c];this.addGroup(p.start,p.count,p.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const h=e.boundingSphere;return h!==null&&(this.boundingSphere=h.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Sg=new Ze,ns=new is,Bh=new Cn,Eg=new z,eo=new z,to=new z,io=new z,dd=new z,Fh=new z,kh=new pe,Hh=new pe,Gh=new pe,Ag=new z,Rg=new z,Cg=new z,Vh=new z,Wh=new z;class rt extends ei{constructor(e=new si,t=new vn){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 e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}getVertexPosition(e,t){const i=this.geometry,r=i.attributes.position,a=i.morphAttributes.position,s=i.morphTargetsRelative;t.fromBufferAttribute(r,e);const l=this.morphTargetInfluences;if(a&&l){Fh.set(0,0,0);for(let h=0,c=a.length;h<c;h++){const d=l[h],p=a[h];d!==0&&(dd.fromBufferAttribute(p,e),s?Fh.addScaledVector(dd,d):Fh.addScaledVector(dd.sub(t),d))}t.add(Fh)}return t}raycast(e,t){const i=this.geometry,r=this.material,a=this.matrixWorld;r!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Bh.copy(i.boundingSphere),Bh.applyMatrix4(a),ns.copy(e.ray).recast(e.near),!(Bh.containsPoint(ns.origin)===!1&&(ns.intersectSphere(Bh,Eg)===null||ns.origin.distanceToSquared(Eg)>(e.far-e.near)**2))&&(Sg.copy(a).invert(),ns.copy(e.ray).applyMatrix4(Sg),!(i.boundingBox!==null&&ns.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,ns)))}_computeIntersections(e,t,i){let r;const a=this.geometry,s=this.material,l=a.index,h=a.attributes.position,c=a.attributes.uv,d=a.attributes.uv1,p=a.attributes.normal,f=a.groups,m=a.drawRange;if(l!==null)if(Array.isArray(s))for(let _=0,x=f.length;_<x;_++){const y=f[_],v=s[y.materialIndex],M=Math.max(y.start,m.start),b=Math.min(l.count,Math.min(y.start+y.count,m.start+m.count));for(let S=M,A=b;S<A;S+=3){const T=l.getX(S),E=l.getX(S+1),I=l.getX(S+2);r=jh(this,v,e,i,c,d,p,T,E,I),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=y.materialIndex,t.push(r))}}else{const _=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let y=_,v=x;y<v;y+=3){const M=l.getX(y),b=l.getX(y+1),S=l.getX(y+2);r=jh(this,s,e,i,c,d,p,M,b,S),r&&(r.faceIndex=Math.floor(y/3),t.push(r))}}else if(h!==void 0)if(Array.isArray(s))for(let _=0,x=f.length;_<x;_++){const y=f[_],v=s[y.materialIndex],M=Math.max(y.start,m.start),b=Math.min(h.count,Math.min(y.start+y.count,m.start+m.count));for(let S=M,A=b;S<A;S+=3){const T=S,E=S+1,I=S+2;r=jh(this,v,e,i,c,d,p,T,E,I),r&&(r.faceIndex=Math.floor(S/3),r.face.materialIndex=y.materialIndex,t.push(r))}}else{const _=Math.max(0,m.start),x=Math.min(h.count,m.start+m.count);for(let y=_,v=x;y<v;y+=3){const M=y,b=y+1,S=y+2;r=jh(this,s,e,i,c,d,p,M,b,S),r&&(r.faceIndex=Math.floor(y/3),t.push(r))}}}}function zb(n,e,t,i,r,a,s,l){let h;if(e.side===dr?h=i.intersectTriangle(s,a,r,!0,l):h=i.intersectTriangle(r,a,s,e.side===jn,l),h===null)return null;Wh.copy(l),Wh.applyMatrix4(n.matrixWorld);const c=t.ray.origin.distanceTo(Wh);return c<t.near||c>t.far?null:{distance:c,point:Wh.clone(),object:n}}function jh(n,e,t,i,r,a,s,l,h,c){n.getVertexPosition(l,eo),n.getVertexPosition(h,to),n.getVertexPosition(c,io);const d=zb(n,e,t,i,eo,to,io,Vh);if(d){r&&(kh.fromBufferAttribute(r,l),Hh.fromBufferAttribute(r,h),Gh.fromBufferAttribute(r,c),d.uv=_n.getInterpolation(Vh,eo,to,io,kh,Hh,Gh,new pe)),a&&(kh.fromBufferAttribute(a,l),Hh.fromBufferAttribute(a,h),Gh.fromBufferAttribute(a,c),d.uv1=_n.getInterpolation(Vh,eo,to,io,kh,Hh,Gh,new pe),d.uv2=d.uv1),s&&(Ag.fromBufferAttribute(s,l),Rg.fromBufferAttribute(s,h),Cg.fromBufferAttribute(s,c),d.normal=_n.getInterpolation(Vh,eo,to,io,Ag,Rg,Cg,new z),d.normal.dot(i.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:h,c,normal:new z,materialIndex:0};_n.getNormal(eo,to,io,p.normal),d.face=p}return d}class st extends si{constructor(e=1,t=1,i=1,r=1,a=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:s};const l=this;r=Math.floor(r),a=Math.floor(a),s=Math.floor(s);const h=[],c=[],d=[],p=[];let f=0,m=0;_("z","y","x",-1,-1,i,t,e,s,a,0),_("z","y","x",1,-1,i,t,-e,s,a,1),_("x","z","y",1,1,e,i,t,r,s,2),_("x","z","y",1,-1,e,i,-t,r,s,3),_("x","y","z",1,-1,e,t,i,r,a,4),_("x","y","z",-1,-1,e,t,-i,r,a,5),this.setIndex(h),this.setAttribute("position",new bi(c,3)),this.setAttribute("normal",new bi(d,3)),this.setAttribute("uv",new bi(p,2));function _(x,y,v,M,b,S,A,T,E,I,C){const P=S/E,X=A/I,q=S/2,te=A/2,k=T/2,H=E+1,V=I+1;let J=0,ie=0;const $=new z;for(let ne=0;ne<V;ne++){const he=ne*X-te;for(let De=0;De<H;De++){const ee=De*P-q;$[x]=ee*M,$[y]=he*b,$[v]=k,c.push($.x,$.y,$.z),$[x]=0,$[y]=0,$[v]=T>0?1:-1,d.push($.x,$.y,$.z),p.push(De/E),p.push(1-ne/I),J+=1}}for(let ne=0;ne<I;ne++)for(let he=0;he<E;he++){const De=f+he+H*ne,ee=f+he+H*(ne+1),ce=f+(he+1)+H*(ne+1),Te=f+(he+1)+H*ne;h.push(De,ee,Te),h.push(ee,ce,Te),ie+=6}l.addGroup(m,ie,C),m+=ie,f+=J}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new st(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ro(n){const e={};for(const t in n){e[t]={};for(const i in n[t]){const r=n[t][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=r.clone():Array.isArray(r)?e[t][i]=r.slice():e[t][i]=r}}return e}function rr(n){const e={};for(let t=0;t<n.length;t++){const i=ro(n[t]);for(const r in i)e[r]=i[r]}return e}function Bb(n){const e=[];for(let t=0;t<n.length;t++)e.push(n[t].clone());return e}function Lg(n){return n.getRenderTarget()===null?n.outputColorSpace:Gt.workingColorSpace}const pd={clone:ro,merge:rr};var Fb=`void main() { gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,kb=`void main() { gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); }`;class mr extends qr{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Fb,this.fragmentShader=kb,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=ro(e.uniforms),this.uniformsGroups=Bb(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 r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const r in this.extensions)this.extensions[r]===!0&&(i[r]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}let Pg=class extends ei{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ze,this.projectionMatrix=new Ze,this.projectionMatrixInverse=new Ze,this.coordinateSystem=qn}copy(n,e){return super.copy(n,e),this.matrixWorldInverse.copy(n.matrixWorldInverse),this.projectionMatrix.copy(n.projectionMatrix),this.projectionMatrixInverse.copy(n.projectionMatrixInverse),this.coordinateSystem=n.coordinateSystem,this}getWorldDirection(n){return super.getWorldDirection(n).negate()}updateMatrixWorld(n){super.updateMatrixWorld(n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(n,e){super.updateWorldMatrix(n,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};class nr extends Pg{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,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=Vs*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(cl*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Vs*2*Math.atan(Math.tan(cl*.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,i,r,a,s){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=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(cl*.5*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r;const s=this.view;if(this.view!==null&&this.view.enabled){const h=s.fullWidth,c=s.fullHeight;a+=s.offsetX*r/h,t-=s.offsetY*i/c,r*=s.width/h,i*=s.height/c}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,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 no=-90,ao=1;class Hb extends ei{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new nr(no,ao,e,t);r.layers=this.layers,this.add(r);const a=new nr(no,ao,e,t);a.layers=this.layers,this.add(a);const s=new nr(no,ao,e,t);s.layers=this.layers,this.add(s);const l=new nr(no,ao,e,t);l.layers=this.layers,this.add(l);const h=new nr(no,ao,e,t);h.layers=this.layers,this.add(h);const c=new nr(no,ao,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,r,a,s,l,h]=t;for(const c of t)this.remove(c);if(e===qn)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),l.up.set(0,1,0),l.lookAt(0,0,1),h.up.set(0,1,0),h.lookAt(0,0,-1);else if(e===Sh)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),l.up.set(0,-1,0),l.lookAt(0,0,1),h.up.set(0,-1,0),h.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[a,s,l,h,c,d]=this.children,p=e.getRenderTarget(),f=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),_=e.xr.enabled;e.xr.enabled=!1;const x=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0,r),e.render(t,a),e.setRenderTarget(i,1,r),e.render(t,s),e.setRenderTarget(i,2,r),e.render(t,l),e.setRenderTarget(i,3,r),e.render(t,h),e.setRenderTarget(i,4,r),e.render(t,c),i.texture.generateMipmaps=x,e.setRenderTarget(i,5,r),e.render(t,d),e.setRenderTarget(p,f,m),e.xr.enabled=_,i.texture.needsPMREMUpdate=!0}}class Dg extends Wi{constructor(e,t,i,r,a,s,l,h,c,d){e=e!==void 0?e:[],t=t!==void 0?t:Bs,super(e,t,i,r,a,s,l,h,c,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Gb extends Yi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},r=[i,i,i,i,i,i];t.encoding!==void 0&&(fl("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Qa?Bt:jr),this.texture=new Dg(r,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:fr}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 i={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 ); } `},r=new st(5,5,5),a=new mr({name:"CubemapFromEquirect",uniforms:ro(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:dr,blending:pn});a.uniforms.tEquirect.value=t;const s=new rt(r,a),l=t.minFilter;return t.minFilter===Za&&(t.minFilter=fr),new Hb(1,10,this).update(e,s),t.minFilter=l,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,i,r){const a=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,r);e.setRenderTarget(a)}}const fd=new z,Vb=new z,Wb=new yt;let ea=class{constructor(n=new z(1,0,0),e=0){this.isPlane=!0,this.normal=n,this.constant=e}set(n,e){return this.normal.copy(n),this.constant=e,this}setComponents(n,e,t,i){return this.normal.set(n,e,t),this.constant=i,this}setFromNormalAndCoplanarPoint(n,e){return this.normal.copy(n),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(n,e,t){const i=fd.subVectors(t,e).cross(Vb.subVectors(n,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,n),this}copy(n){return this.normal.copy(n.normal),this.constant=n.constant,this}normalize(){const n=1/this.normal.length();return this.normal.multiplyScalar(n),this.constant*=n,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(n){return this.normal.dot(n)+this.constant}distanceToSphere(n){return this.distanceToPoint(n.center)-n.radius}projectPoint(n,e){return e.copy(n).addScaledVector(this.normal,-this.distanceToPoint(n))}intersectLine(n,e){const t=n.delta(fd),i=this.normal.dot(t);if(i===0)return this.distanceToPoint(n.start)===0?e.copy(n.start):null;const r=-(n.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(n.start).addScaledVector(t,r)}intersectsLine(n){const e=this.distanceToPoint(n.start),t=this.distanceToPoint(n.end);return e<0&&t>0||t<0&&e>0}intersectsBox(n){return n.intersectsPlane(this)}intersectsSphere(n){return n.intersectsPlane(this)}coplanarPoint(n){return n.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(n,e){const t=e||Wb.getNormalMatrix(n),i=this.coplanarPoint(fd).applyMatrix4(n),r=this.normal.applyMatrix3(t).normalize();return this.constant=-i.dot(r),this}translate(n){return this.constant-=n.dot(this.normal),this}equals(n){return n.normal.equals(this.normal)&&n.constant===this.constant}clone(){return new this.constructor().copy(this)}};const as=new Cn,Xh=new z;class md{constructor(e=new ea,t=new ea,i=new ea,r=new ea,a=new ea,s=new ea){this.planes=[e,t,i,r,a,s]}set(e,t,i,r,a,s){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(i),l[3].copy(r),l[4].copy(a),l[5].copy(s),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=qn){const i=this.planes,r=e.elements,a=r[0],s=r[1],l=r[2],h=r[3],c=r[4],d=r[5],p=r[6],f=r[7],m=r[8],_=r[9],x=r[10],y=r[11],v=r[12],M=r[13],b=r[14],S=r[15];if(i[0].setComponents(h-a,f-c,y-m,S-v).normalize(),i[1].setComponents(h+a,f+c,y+m,S+v).normalize(),i[2].setComponents(h+s,f+d,y+_,S+M).normalize(),i[3].setComponents(h-s,f-d,y-_,S-M).normalize(),i[4].setComponents(h-l,f-p,y-x,S-b).normalize(),t===qn)i[5].setComponents(h+l,f+p,y+x,S+b).normalize();else if(t===Sh)i[5].setComponents(l,p,x,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),as.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),as.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(as)}intersectsSprite(e){return as.center.set(0,0,0),as.radius=.7071067811865476,as.applyMatrix4(e.matrixWorld),this.intersectsSphere(as)}intersectsSphere(e){const t=this.planes,i=e.center,r=-e.radius;for(let a=0;a<6;a++)if(t[a].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let i=0;i<6;i++){const r=t[i];if(Xh.x=r.normal.x>0?e.max.x:e.min.x,Xh.y=r.normal.y>0?e.max.y:e.min.y,Xh.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Xh)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function Ig(){let n=null,e=!1,t=null,i=null;function r(a,s){t(a,s),i=n.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(i=n.requestAnimationFrame(r),e=!0)},stop:function(){n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){n=a}}}function jb(n,e){const t=e.isWebGL2,i=new WeakMap;function r(c,d){const p=c.array,f=c.usage,m=p.byteLength,_=n.createBuffer();n.bindBuffer(d,_),n.bufferData(d,p,f),c.onUploadCallback();let x;if(p instanceof Float32Array)x=n.FLOAT;else if(p instanceof Uint16Array)if(c.isFloat16BufferAttribute)if(t)x=n.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else x=n.UNSIGNED_SHORT;else if(p instanceof Int16Array)x=n.SHORT;else if(p instanceof Uint32Array)x=n.UNSIGNED_INT;else if(p instanceof Int32Array)x=n.INT;else if(p instanceof Int8Array)x=n.BYTE;else if(p instanceof Uint8Array)x=n.UNSIGNED_BYTE;else if(p instanceof Uint8ClampedArray)x=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+p);return{buffer:_,type:x,bytesPerElement:p.BYTES_PER_ELEMENT,version:c.version,size:m}}function a(c,d,p){const f=d.array,m=d._updateRange,_=d.updateRanges;if(n.bindBuffer(p,c),m.count===-1&&_.length===0&&n.bufferSubData(p,0,f),_.length!==0){for(let x=0,y=_.length;x<y;x++){const v=_[x];t?n.bufferSubData(p,v.start*f.BYTES_PER_ELEMENT,f,v.start,v.count):n.bufferSubData(p,v.start*f.BYTES_PER_ELEMENT,f.subarray(v.start,v.start+v.count))}d.clearUpdateRanges()}m.count!==-1&&(t?n.bufferSubData(p,m.offset*f.BYTES_PER_ELEMENT,f,m.offset,m.count):n.bufferSubData(p,m.offset*f.BYTES_PER_ELEMENT,f.subarray(m.offset,m.offset+m.count)),m.count=-1),d.onUploadCallback()}function s(c){return c.isInterleavedBufferAttribute&&(c=c.data),i.get(c)}function l(c){c.isInterleavedBufferAttribute&&(c=c.data);const d=i.get(c);d&&(n.deleteBuffer(d.buffer),i.delete(c))}function h(c,d){if(c.isGLBufferAttribute){const f=i.get(c);(!f||f.version<c.version)&&i.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}c.isInterleavedBufferAttribute&&(c=c.data);const p=i.get(c);if(p===void 0)i.set(c,r(c,d));else if(p.version<c.version){if(p.size!==c.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.");a(p.buffer,c,d),p.version=c.version}}return{get:s,remove:l,update:h}}class Sa extends si{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};const a=e/2,s=t/2,l=Math.floor(i),h=Math.floor(r),c=l+1,d=h+1,p=e/l,f=t/h,m=[],_=[],x=[],y=[];for(let v=0;v<d;v++){const M=v*f-s;for(let b=0;b<c;b++){const S=b*p-a;_.push(S,-M,0),x.push(0,0,1),y.push(b/l),y.push(1-v/h)}}for(let v=0;v<h;v++)for(let M=0;M<l;M++){const b=M+c*v,S=M+c*(v+1),A=M+1+c*(v+1),T=M+1+c*v;m.push(b,S,T),m.push(S,A,T)}this.setIndex(m),this.setAttribute("position",new bi(_,3)),this.setAttribute("normal",new bi(x,3)),this.setAttribute("uv",new bi(y,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sa(e.width,e.height,e.widthSegments,e.heightSegments)}}var Xb=`#ifdef USE_ALPHAHASH if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; #endif`,qb=`#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`,Yb=`#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; #endif`,Kb=`#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,Zb=`#ifdef USE_ALPHATEST if ( diffuseColor.a < alphaTest ) discard; #endif`,Jb=`#ifdef USE_ALPHATEST uniform float alphaTest; #endif`,$b=`#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`,Qb=`#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; #endif`,ew=`#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`,tw=`#ifdef USE_BATCHING mat4 batchingMatrix = getBatchingMatrix( batchId ); #endif`,iw=`vec3 transformed = vec3( position ); #ifdef USE_ALPHAHASH vPosition = vec3( position ); #endif`,rw=`vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); #endif`,nw=`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`,aw=`#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`,sw=`#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`,ow=`#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`,lw=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,hw=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,cw=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,uw=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,dw=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,pw=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,fw=`#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`,mw=`#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`,gw=`#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`,_w=`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`,vw=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,yw=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,xw=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,bw=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,ww="gl_FragColor = linearToOutputTexel( gl_FragColor );",Mw=` 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 ); }`,Tw=`#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`,Sw=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,Ew=`#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`,Aw=`#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`,Rw=`#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`,Cw=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,Lw=`#ifdef USE_FOG varying float vFogDepth; #endif`,Pw=`#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`,Dw=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,Iw=`#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 }`,Ow=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,Nw=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,Uw=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,zw=`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`,Bw=`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`,Fw=`#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`,kw=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,Hw=`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`,Gw=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,Vw=`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`,Ww=`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`,jw=`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 ); }`,Xw=` 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`,qw=`#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`,Yw=`#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`,Kw=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,Zw=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,Jw=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,$w=`#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`,Qw=`#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`,eM=`#ifdef USE_MAP uniform sampler2D map; #endif`,tM=`#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`,iM=`#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`,rM=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,nM=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,aM=`#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`,sM=`#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`,oM=`#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`,lM=`#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`,hM=`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;`,cM=`#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`,uM=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,dM=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,pM=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,fM=`#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`,mM=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,gM=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,_M=`#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`,vM=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,yM=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,xM=`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 ); }`,bM=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,wM=`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;`,MM=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,TM=`#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`,SM=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,EM=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,AM=`#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`,RM=`#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`,CM=`#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`,LM=`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; }`,PM=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,DM=`#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`,IM=`#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`,OM=`#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`,NM=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,UM=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,zM=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,BM=`#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; }`,FM=`#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`,kM=`#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`,HM=`#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`,GM=`#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`,VM=`#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`,WM=`#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 jM=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,XM=`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> }`,qM=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> gl_Position.z = gl_Position.w; }`,YM=`#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> }`,KM=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> gl_Position.z = gl_Position.w; }`,ZM=`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> }`,JM=`#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; }`,$M=`#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 }`,QM=`#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; }`,eT=`#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 ); }`,tT=`varying vec3 vWorldDirection; #include <common> void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include <begin_vertex> #include <project_vertex> }`,iT=`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> }`,rT=`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> }`,nT=`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> }`,aT=`#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> }`,sT=`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> }`,oT=`#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> }`,lT=`#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> }`,hT=`#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; }`,cT=`#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> }`,uT=`#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 }`,dT=`#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 }`,pT=`#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> }`,fT=`#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> }`,mT=`#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 }`,gT=`#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> }`,_T=`#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> }`,vT=`#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> }`,yT=`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> }`,xT=`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> }`,bT=`#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> }`,wT=`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> }`,MT=`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> }`,TT=`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> }`,Mt={alphahash_fragment:Xb,alphahash_pars_fragment:qb,alphamap_fragment:Yb,alphamap_pars_fragment:Kb,alphatest_fragment:Zb,alphatest_pars_fragment:Jb,aomap_fragment:$b,aomap_pars_fragment:Qb,batching_pars_vertex:ew,batching_vertex:tw,begin_vertex:iw,beginnormal_vertex:rw,bsdfs:nw,iridescence_fragment:aw,bumpmap_pars_fragment:sw,clipping_planes_fragment:ow,clipping_planes_pars_fragment:lw,clipping_planes_pars_vertex:hw,clipping_planes_vertex:cw,color_fragment:uw,color_pars_fragment:dw,color_pars_vertex:pw,color_vertex:fw,common:mw,cube_uv_reflection_fragment:gw,defaultnormal_vertex:_w,displacementmap_pars_vertex:vw,displacementmap_vertex:yw,emissivemap_fragment:xw,emissivemap_pars_fragment:bw,colorspace_fragment:ww,colorspace_pars_fragment:Mw,envmap_fragment:Tw,envmap_common_pars_fragment:Sw,envmap_pars_fragment:Ew,envmap_pars_vertex:Aw,envmap_physical_pars_fragment:Fw,envmap_vertex:Rw,fog_vertex:Cw,fog_pars_vertex:Lw,fog_fragment:Pw,fog_pars_fragment:Dw,gradientmap_pars_fragment:Iw,lightmap_fragment:Ow,lightmap_pars_fragment:Nw,lights_lambert_fragment:Uw,lights_lambert_pars_fragment:zw,lights_pars_begin:Bw,lights_toon_fragment:kw,lights_toon_pars_fragment:Hw,lights_phong_fragment:Gw,lights_phong_pars_fragment:Vw,lights_physical_fragment:Ww,lights_physical_pars_fragment:jw,lights_fragment_begin:Xw,lights_fragment_maps:qw,lights_fragment_end:Yw,logdepthbuf_fragment:Kw,logdepthbuf_pars_fragment:Zw,logdepthbuf_pars_vertex:Jw,logdepthbuf_vertex:$w,map_fragment:Qw,map_pars_fragment:eM,map_particle_fragment:tM,map_particle_pars_fragment:iM,metalnessmap_fragment:rM,metalnessmap_pars_fragment:nM,morphcolor_vertex:aM,morphnormal_vertex:sM,morphtarget_pars_vertex:oM,morphtarget_vertex:lM,normal_fragment_begin:hM,normal_fragment_maps:cM,normal_pars_fragment:uM,normal_pars_vertex:dM,normal_vertex:pM,normalmap_pars_fragment:fM,clearcoat_normal_fragment_begin:mM,clearcoat_normal_fragment_maps:gM,clearcoat_pars_fragment:_M,iridescence_pars_fragment:vM,opaque_fragment:yM,packing:xM,premultiplied_alpha_fragment:bM,project_vertex:wM,dithering_fragment:MM,dithering_pars_fragment:TM,roughnessmap_fragment:SM,roughnessmap_pars_fragment:EM,shadowmap_pars_fragment:AM,shadowmap_pars_vertex:RM,shadowmap_vertex:CM,shadowmask_pars_fragment:LM,skinbase_vertex:PM,skinning_pars_vertex:DM,skinning_vertex:IM,skinnormal_vertex:OM,specularmap_fragment:NM,specularmap_pars_fragment:UM,tonemapping_fragment:zM,tonemapping_pars_fragment:BM,transmission_fragment:FM,transmission_pars_fragment:kM,uv_pars_fragment:HM,uv_pars_vertex:GM,uv_vertex:VM,worldpos_vertex:WM,background_vert:jM,background_frag:XM,backgroundCube_vert:qM,backgroundCube_frag:YM,cube_vert:KM,cube_frag:ZM,depth_vert:JM,depth_frag:$M,distanceRGBA_vert:QM,distanceRGBA_frag:eT,equirect_vert:tT,equirect_frag:iT,linedashed_vert:rT,linedashed_frag:nT,meshbasic_vert:aT,meshbasic_frag:sT,meshlambert_vert:oT,meshlambert_frag:lT,meshmatcap_vert:hT,meshmatcap_frag:cT,meshnormal_vert:uT,meshnormal_frag:dT,meshphong_vert:pT,meshphong_frag:fT,meshphysical_vert:mT,meshphysical_frag:gT,meshtoon_vert:_T,meshtoon_frag:vT,points_vert:yT,points_frag:xT,shadow_vert:bT,shadow_frag:wT,sprite_vert:MT,sprite_frag:TT},Oe={common:{diffuse:{value:new Ke(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new yt},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new yt}},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 yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new yt},normalScale:{value:new pe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ke(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 Ke(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0},uvTransform:{value:new yt}},sprite:{diffuse:{value:new Ke(16777215)},opacity:{value:1},center:{value:new pe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new yt},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0}}},Ln={basic:{uniforms:rr([Oe.common,Oe.specularmap,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.fog]),vertexShader:Mt.meshbasic_vert,fragmentShader:Mt.meshbasic_frag},lambert:{uniforms:rr([Oe.common,Oe.specularmap,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.fog,Oe.lights,{emissive:{value:new Ke(0)}}]),vertexShader:Mt.meshlambert_vert,fragmentShader:Mt.meshlambert_frag},phong:{uniforms:rr([Oe.common,Oe.specularmap,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.fog,Oe.lights,{emissive:{value:new Ke(0)},specular:{value:new Ke(1118481)},shininess:{value:30}}]),vertexShader:Mt.meshphong_vert,fragmentShader:Mt.meshphong_frag},standard:{uniforms:rr([Oe.common,Oe.envmap,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.roughnessmap,Oe.metalnessmap,Oe.fog,Oe.lights,{emissive:{value:new Ke(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag},toon:{uniforms:rr([Oe.common,Oe.aomap,Oe.lightmap,Oe.emissivemap,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.gradientmap,Oe.fog,Oe.lights,{emissive:{value:new Ke(0)}}]),vertexShader:Mt.meshtoon_vert,fragmentShader:Mt.meshtoon_frag},matcap:{uniforms:rr([Oe.common,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,Oe.fog,{matcap:{value:null}}]),vertexShader:Mt.meshmatcap_vert,fragmentShader:Mt.meshmatcap_frag},points:{uniforms:rr([Oe.points,Oe.fog]),vertexShader:Mt.points_vert,fragmentShader:Mt.points_frag},dashed:{uniforms:rr([Oe.common,Oe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Mt.linedashed_vert,fragmentShader:Mt.linedashed_frag},depth:{uniforms:rr([Oe.common,Oe.displacementmap]),vertexShader:Mt.depth_vert,fragmentShader:Mt.depth_frag},normal:{uniforms:rr([Oe.common,Oe.bumpmap,Oe.normalmap,Oe.displacementmap,{opacity:{value:1}}]),vertexShader:Mt.meshnormal_vert,fragmentShader:Mt.meshnormal_frag},sprite:{uniforms:rr([Oe.sprite,Oe.fog]),vertexShader:Mt.sprite_vert,fragmentShader:Mt.sprite_frag},background:{uniforms:{uvTransform:{value:new yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Mt.background_vert,fragmentShader:Mt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Mt.backgroundCube_vert,fragmentShader:Mt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Mt.cube_vert,fragmentShader:Mt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Mt.equirect_vert,fragmentShader:Mt.equirect_frag},distanceRGBA:{uniforms:rr([Oe.common,Oe.displacementmap,{referencePosition:{value:new z},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Mt.distanceRGBA_vert,fragmentShader:Mt.distanceRGBA_frag},shadow:{uniforms:rr([Oe.lights,Oe.fog,{color:{value:new Ke(0)},opacity:{value:1}}]),vertexShader:Mt.shadow_vert,fragmentShader:Mt.shadow_frag}};Ln.physical={uniforms:rr([Ln.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new yt},clearcoatNormalScale:{value:new pe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new yt},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new yt},sheen:{value:0},sheenColor:{value:new Ke(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new yt},transmissionSamplerSize:{value:new pe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new yt},attenuationDistance:{value:0},attenuationColor:{value:new Ke(0)},specularColor:{value:new Ke(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new yt},anisotropyVector:{value:new pe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new yt}}]),vertexShader:Mt.meshphysical_vert,fragmentShader:Mt.meshphysical_frag};const qh={r:0,b:0,g:0};function ST(n,e,t,i,r,a,s){const l=new Ke(0);let h=a===!0?0:1,c,d,p=null,f=0,m=null;function _(y,v){let M=!1,b=v.isScene===!0?v.background:null;b&&b.isTexture&&(b=(v.backgroundBlurriness>0?t:e).get(b)),b===null?x(l,h):b&&b.isColor&&(x(b,1),M=!0);const S=n.xr.getEnvironmentBlendMode();S==="additive"?i.buffers.color.setClear(0,0,0,1,s):S==="alpha-blend"&&i.buffers.color.setClear(0,0,0,0,s),(n.autoClear||M)&&n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil),b&&(b.isCubeTexture||b.mapping===_h)?(d===void 0&&(d=new rt(new st(1,1,1),new mr({name:"BackgroundCubeMaterial",uniforms:ro(Ln.backgroundCube.uniforms),vertexShader:Ln.backgroundCube.vertexShader,fragmentShader:Ln.backgroundCube.fragmentShader,side:dr,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(A,T,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(d)),d.material.uniforms.envMap.value=b,d.material.uniforms.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,d.material.toneMapped=Gt.getTransfer(b.colorSpace)!==ii,(p!==b||f!==b.version||m!==n.toneMapping)&&(d.material.needsUpdate=!0,p=b,f=b.version,m=n.toneMapping),d.layers.enableAll(),y.unshift(d,d.geometry,d.material,0,0,null)):b&&b.isTexture&&(c===void 0&&(c=new rt(new Sa(2,2),new mr({name:"BackgroundMaterial",uniforms:ro(Ln.background.uniforms),vertexShader:Ln.background.vertexShader,fragmentShader:Ln.background.fragmentShader,side:jn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=b,c.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,c.material.toneMapped=Gt.getTransfer(b.colorSpace)!==ii,b.matrixAutoUpdate===!0&&b.updateMatrix(),c.material.uniforms.uvTransform.value.copy(b.matrix),(p!==b||f!==b.version||m!==n.toneMapping)&&(c.material.needsUpdate=!0,p=b,f=b.version,m=n.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function x(y,v){y.getRGB(qh,Lg(n)),i.buffers.color.setClear(qh.r,qh.g,qh.b,v,s)}return{getClearColor:function(){return l},setClearColor:function(y,v=1){l.set(y),h=v,x(l,h)},getClearAlpha:function(){return h},setClearAlpha:function(y){h=y,x(l,h)},render:_}}function ET(n,e,t,i){const r=n.getParameter(n.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:e.get("OES_vertex_array_object"),s=i.isWebGL2||a!==null,l={},h=y(null);let c=h,d=!1;function p(k,H,V,J,ie){let $=!1;if(s){const ne=x(J,V,H);c!==ne&&(c=ne,m(c.object)),$=v(k,J,V,ie),$&&M(k,J,V,ie)}else{const ne=H.wireframe===!0;(c.geometry!==J.id||c.program!==V.id||c.wireframe!==ne)&&(c.geometry=J.id,c.program=V.id,c.wireframe=ne,$=!0)}ie!==null&&t.update(ie,n.ELEMENT_ARRAY_BUFFER),($||d)&&(d=!1,I(k,H,V,J),ie!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.get(ie).buffer))}function f(){return i.isWebGL2?n.createVertexArray():a.createVertexArrayOES()}function m(k){return i.isWebGL2?n.bindVertexArray(k):a.bindVertexArrayOES(k)}function _(k){return i.isWebGL2?n.deleteVertexArray(k):a.deleteVertexArrayOES(k)}function x(k,H,V){const J=V.wireframe===!0;let ie=l[k.id];ie===void 0&&(ie={},l[k.id]=ie);let $=ie[H.id];$===void 0&&($={},ie[H.id]=$);let ne=$[J];return ne===void 0&&(ne=y(f()),$[J]=ne),ne}function y(k){const H=[],V=[],J=[];for(let ie=0;ie<r;ie++)H[ie]=0,V[ie]=0,J[ie]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:H,enabledAttributes:V,attributeDivisors:J,object:k,attributes:{},index:null}}function v(k,H,V,J){const ie=c.attributes,$=H.attributes;let ne=0;const he=V.getAttributes();for(const De in he)if(he[De].location>=0){const ee=ie[De];let ce=$[De];if(ce===void 0&&(De==="instanceMatrix"&&k.instanceMatrix&&(ce=k.instanceMatrix),De==="instanceColor"&&k.instanceColor&&(ce=k.instanceColor)),ee===void 0||ee.attribute!==ce||ce&&ee.data!==ce.data)return!0;ne++}return c.attributesNum!==ne||c.index!==J}function M(k,H,V,J){const ie={},$=H.attributes;let ne=0;const he=V.getAttributes();for(const De in he)if(he[De].location>=0){let ee=$[De];ee===void 0&&(De==="instanceMatrix"&&k.instanceMatrix&&(ee=k.instanceMatrix),De==="instanceColor"&&k.instanceColor&&(ee=k.instanceColor));const ce={};ce.attribute=ee,ee&&ee.data&&(ce.data=ee.data),ie[De]=ce,ne++}c.attributes=ie,c.attributesNum=ne,c.index=J}function b(){const k=c.newAttributes;for(let H=0,V=k.length;H<V;H++)k[H]=0}function S(k){A(k,0)}function A(k,H){const V=c.newAttributes,J=c.enabledAttributes,ie=c.attributeDivisors;V[k]=1,J[k]===0&&(n.enableVertexAttribArray(k),J[k]=1),ie[k]!==H&&((i.isWebGL2?n:e.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](k,H),ie[k]=H)}function T(){const k=c.newAttributes,H=c.enabledAttributes;for(let V=0,J=H.length;V<J;V++)H[V]!==k[V]&&(n.disableVertexAttribArray(V),H[V]=0)}function E(k,H,V,J,ie,$,ne){ne===!0?n.vertexAttribIPointer(k,H,V,ie,$):n.vertexAttribPointer(k,H,V,J,ie,$)}function I(k,H,V,J){if(i.isWebGL2===!1&&(k.isInstancedMesh||J.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;b();const ie=J.attributes,$=V.getAttributes(),ne=H.defaultAttributeValues;for(const he in $){const De=$[he];if(De.location>=0){let ee=ie[he];if(ee===void 0&&(he==="instanceMatrix"&&k.instanceMatrix&&(ee=k.instanceMatrix),he==="instanceColor"&&k.instanceColor&&(ee=k.instanceColor)),ee!==void 0){const ce=ee.normalized,Te=ee.itemSize,Be=t.get(ee);if(Be===void 0)continue;const je=Be.buffer,$e=Be.type,qe=Be.bytesPerElement,Xe=i.isWebGL2===!0&&($e===n.INT||$e===n.UNSIGNED_INT||ee.gpuType===ym);if(ee.isInterleavedBufferAttribute){const ge=ee.data,G=ge.stride,Ae=ee.offset;if(ge.isInstancedInterleavedBuffer){for(let ue=0;ue<De.locationSize;ue++)A(De.location+ue,ge.meshPerAttribute);k.isInstancedMesh!==!0&&J._maxInstanceCount===void 0&&(J._maxInstanceCount=ge.meshPerAttribute*ge.count)}else for(let ue=0;ue<De.locationSize;ue++)S(De.location+ue);n.bindBuffer(n.ARRAY_BUFFER,je);for(let ue=0;ue<De.locationSize;ue++)E(De.location+ue,Te/De.locationSize,$e,ce,G*qe,(Ae+Te/De.locationSize*ue)*qe,Xe)}else{if(ee.isInstancedBufferAttribute){for(let ge=0;ge<De.locationSize;ge++)A(De.location+ge,ee.meshPerAttribute);k.isInstancedMesh!==!0&&J._maxInstanceCount===void 0&&(J._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let ge=0;ge<De.locationSize;ge++)S(De.location+ge);n.bindBuffer(n.ARRAY_BUFFER,je);for(let ge=0;ge<De.locationSize;ge++)E(De.location+ge,Te/De.locationSize,$e,ce,Te*qe,Te/De.locationSize*ge*qe,Xe)}}else if(ne!==void 0){const ce=ne[he];if(ce!==void 0)switch(ce.length){case 2:n.vertexAttrib2fv(De.location,ce);break;case 3:n.vertexAttrib3fv(De.location,ce);break;case 4:n.vertexAttrib4fv(De.location,ce);break;default:n.vertexAttrib1fv(De.location,ce)}}}}T()}function C(){q();for(const k in l){const H=l[k];for(const V in H){const J=H[V];for(const ie in J)_(J[ie].object),delete J[ie];delete H[V]}delete l[k]}}function P(k){if(l[k.id]===void 0)return;const H=l[k.id];for(const V in H){const J=H[V];for(const ie in J)_(J[ie].object),delete J[ie];delete H[V]}delete l[k.id]}function X(k){for(const H in l){const V=l[H];if(V[k.id]===void 0)continue;const J=V[k.id];for(const ie in J)_(J[ie].object),delete J[ie];delete V[k.id]}}function q(){te(),d=!0,c!==h&&(c=h,m(c.object))}function te(){h.geometry=null,h.program=null,h.wireframe=!1}return{setup:p,reset:q,resetDefaultState:te,dispose:C,releaseStatesOfGeometry:P,releaseStatesOfProgram:X,initAttributes:b,enableAttribute:S,disableUnusedAttributes:T}}function AT(n,e,t,i){const r=i.isWebGL2;let a;function s(d){a=d}function l(d,p){n.drawArrays(a,d,p),t.update(p,a,1)}function h(d,p,f){if(f===0)return;let m,_;if(r)m=n,_="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),_="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[_](a,d,p,f),t.update(p,a,f)}function c(d,p,f){if(f===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let _=0;_<f;_++)this.render(d[_],p[_]);else{m.multiDrawArraysWEBGL(a,d,0,p,0,f);let _=0;for(let x=0;x<f;x++)_+=p[x];t.update(_,a,1)}}this.setMode=s,this.render=l,this.renderInstances=h,this.renderMultiDraw=c}function RT(n,e,t){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");i=n.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(E){if(E==="highp"){if(n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.HIGH_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s=typeof WebGL2RenderingContext<"u"&&n.constructor.name==="WebGL2RenderingContext";let l=t.precision!==void 0?t.precision:"highp";const h=a(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const c=s||e.has("WEBGL_draw_buffers"),d=t.logarithmicDepthBuffer===!0,p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),f=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=n.getParameter(n.MAX_TEXTURE_SIZE),_=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),x=n.getParameter(n.MAX_VERTEX_ATTRIBS),y=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),v=n.getParameter(n.MAX_VARYING_VECTORS),M=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),b=f>0,S=s||e.has("OES_texture_float"),A=b&&S,T=s?n.getParameter(n.MAX_SAMPLES):0;return{isWebGL2:s,drawBuffers:c,getMaxAnisotropy:r,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:p,maxVertexTextures:f,maxTextureSize:m,maxCubemapSize:_,maxAttributes:x,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:M,vertexTextures:b,floatFragmentTextures:S,floatVertexTextures:A,maxSamples:T}}function CT(n){const e=this;let t=null,i=0,r=!1,a=!1;const s=new ea,l=new yt,h={value:null,needsUpdate:!1};this.uniform=h,this.numPlanes=0,this.numIntersection=0,this.init=function(p,f){const m=p.length!==0||f||i!==0||r;return r=f,i=p.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(p,f){t=d(p,f,0)},this.setState=function(p,f,m){const _=p.clippingPlanes,x=p.clipIntersection,y=p.clipShadows,v=n.get(p);if(!r||_===null||_.length===0||a&&!y)a?d(null):c();else{const M=a?0:i,b=M*4;let S=v.clippingState||null;h.value=S,S=d(_,f,b,m);for(let A=0;A!==b;++A)S[A]=t[A];v.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=M}};function c(){h.value!==t&&(h.value=t,h.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function d(p,f,m,_){const x=p!==null?p.length:0;let y=null;if(x!==0){if(y=h.value,_!==!0||y===null){const v=m+x*4,M=f.matrixWorldInverse;l.getNormalMatrix(M),(y===null||y.length<v)&&(y=new Float32Array(v));for(let b=0,S=m;b!==x;++b,S+=4)s.copy(p[b]).applyMatrix4(M,l),s.normal.toArray(y,S),y[S+3]=s.constant}h.value=y,h.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,y}}function LT(n){let e=new WeakMap;function t(s,l){return l===Ou?s.mapping=Bs:l===Nu&&(s.mapping=Fs),s}function i(s){if(s&&s.isTexture){const l=s.mapping;if(l===Ou||l===Nu)if(e.has(s)){const h=e.get(s).texture;return t(h,s.mapping)}else{const h=s.image;if(h&&h.height>0){const c=new Gb(h.height/2);return c.fromEquirectangularTexture(n,s),e.set(s,c),s.addEventListener("dispose",r),t(c.texture,s.mapping)}else return null}}return s}function r(s){const l=s.target;l.removeEventListener("dispose",r);const h=e.get(l);h!==void 0&&(e.delete(l),h.dispose())}function a(){e=new WeakMap}return{get:i,dispose:a}}class Yh extends Pg{constructor(e=-1,t=1,i=1,r=-1,a=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=a,this.far=s,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,i,r,a,s){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=i,this.view.offsetY=r,this.view.width=a,this.view.height=s,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),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let a=i-e,s=i+e,l=r+t,h=r-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,d=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,s=a+c*this.view.width,l-=d*this.view.offsetY,h=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,s,l,h,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 so=4,Og=[.125,.215,.35,.446,.526,.582],ss=20,gd=new Yh,Ng=new Ke;let _d=null,vd=0,yd=0;const os=(1+Math.sqrt(5))/2,oo=1/os,Ug=[new z(1,1,1),new z(-1,1,1),new z(1,1,-1),new z(-1,1,-1),new z(0,os,oo),new z(0,os,-oo),new z(oo,0,os),new z(-oo,0,os),new z(os,oo,0),new z(-os,oo,0)];class zg{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,i=.1,r=100){_d=this._renderer.getRenderTarget(),vd=this._renderer.getActiveCubeFace(),yd=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,i,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=kg(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Fg(),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(_d,vd,yd),e.scissorTest=!1,Kh(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Bs||e.mapping===Fs?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),_d=this._renderer.getRenderTarget(),vd=this._renderer.getActiveCubeFace(),yd=this._renderer.getActiveMipmapLevel();const i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:fr,minFilter:fr,generateMipmaps:!1,type:Rr,format:Cr,colorSpace:Bi,depthBuffer:!1},r=Bg(e,t,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Bg(e,t,i);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=PT(a)),this._blurMaterial=DT(a,e,t)}return r}_compileMaterial(e){const t=new rt(this._lodPlanes[0],e);this._renderer.compile(t,gd)}_sceneToCubeUV(e,t,i,r){const a=new nr(90,1,t,i),s=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,c=h.autoClear,d=h.toneMapping;h.getClearColor(Ng),h.toneMapping=_a,h.autoClear=!1;const p=new vn({name:"PMREM.Background",side:dr,depthWrite:!1,depthTest:!1}),f=new rt(new st,p);let m=!1;const _=e.background;_?_.isColor&&(p.color.copy(_),e.background=null,m=!0):(p.color.copy(Ng),m=!0);for(let x=0;x<6;x++){const y=x%3;y===0?(a.up.set(0,s[x],0),a.lookAt(l[x],0,0)):y===1?(a.up.set(0,0,s[x]),a.lookAt(0,l[x],0)):(a.up.set(0,s[x],0),a.lookAt(0,0,l[x]));const v=this._cubeSize;Kh(r,y*v,x>2?v:0,v,v),h.setRenderTarget(r),m&&h.render(f,a),h.render(e,a)}f.geometry.dispose(),f.material.dispose(),h.toneMapping=d,h.autoClear=c,e.background=_}_textureToCubeUV(e,t){const i=this._renderer,r=e.mapping===Bs||e.mapping===Fs;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=kg()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Fg());const a=r?this._cubemapMaterial:this._equirectMaterial,s=new rt(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const h=this._cubeSize;Kh(t,0,0,3*h,2*h),i.setRenderTarget(t),i.render(s,gd)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let r=1;r<this._lodPlanes.length;r++){const a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),s=Ug[(r-1)%Ug.length];this._blur(e,r-1,r,a,s)}t.autoClear=i}_blur(e,t,i,r,a){const s=this._pingPongRenderTarget;this._halfBlur(e,s,t,i,r,"latitudinal",a),this._halfBlur(s,e,i,i,r,"longitudinal",a)}_halfBlur(e,t,i,r,a,s,l){const h=this._renderer,c=this._blurMaterial;s!=="latitudinal"&&s!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,p=new rt(this._lodPlanes[r],c),f=c.uniforms,m=this._sizeLods[i]-1,_=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*ss-1),x=a/_,y=isFinite(a)?1+Math.floor(d*x):ss;y>ss&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${ss}`);const v=[];let M=0;for(let E=0;E<ss;++E){const I=E/x,C=Math.exp(-I*I/2);v.push(C),E===0?M+=C:E<y&&(M+=2*C)}for(let E=0;E<v.length;E++)v[E]=v[E]/M;f.envMap.value=e.texture,f.samples.value=y,f.weights.value=v,f.latitudinal.value=s==="latitudinal",l&&(f.poleAxis.value=l);const{_lodMax:b}=this;f.dTheta.value=_,f.mipInt.value=b-i;const S=this._sizeLods[r],A=3*S*(r>b-so?r-b+so:0),T=4*(this._cubeSize-S);Kh(t,A,T,3*S,2*S),h.setRenderTarget(t),h.render(p,gd)}}function PT(n){const e=[],t=[],i=[];let r=n;const a=n-so+1+Og.length;for(let s=0;s<a;s++){const l=Math.pow(2,r);t.push(l);let h=1/l;s>n-so?h=Og[s-n+so-1]:s===0&&(h=0),i.push(h);const c=1/(l-2),d=-c,p=1+c,f=[d,d,p,d,p,p,d,d,p,p,d,p],m=6,_=6,x=3,y=2,v=1,M=new Float32Array(x*_*m),b=new Float32Array(y*_*m),S=new Float32Array(v*_*m);for(let T=0;T<m;T++){const E=T%3*2/3-1,I=T>2?0:-1,C=[E,I,0,E+2/3,I,0,E+2/3,I+1,0,E,I,0,E+2/3,I+1,0,E,I+1,0];M.set(C,x*_*T),b.set(f,y*_*T);const P=[T,T,T,T,T,T];S.set(P,v*_*T)}const A=new si;A.setAttribute("position",new mi(M,x)),A.setAttribute("uv",new mi(b,y)),A.setAttribute("faceIndex",new mi(S,v)),e.push(A),r>so&&r--}return{lodPlanes:e,sizeLods:t,sigmas:i}}function Bg(n,e,t){const i=new Yi(n,e,t);return i.texture.mapping=_h,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Kh(n,e,t,i,r){n.viewport.set(e,t,i,r),n.scissor.set(e,t,i,r)}function DT(n,e,t){const i=new Float32Array(ss),r=new z(0,1,0);return new mr({name:"SphericalGaussianBlur",defines:{n:ss,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:xd(),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:pn,depthTest:!1,depthWrite:!1})}function Fg(){return new mr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:xd(),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:pn,depthTest:!1,depthWrite:!1})}function kg(){return new mr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:xd(),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:pn,depthTest:!1,depthWrite:!1})}function xd(){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 IT(n){let e=new WeakMap,t=null;function i(l){if(l&&l.isTexture){const h=l.mapping,c=h===Ou||h===Nu,d=h===Bs||h===Fs;if(c||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let p=e.get(l);return t===null&&(t=new zg(n)),p=c?t.fromEquirectangular(l,p):t.fromCubemap(l,p),e.set(l,p),p.texture}else{if(e.has(l))return e.get(l).texture;{const p=l.image;if(c&&p&&p.height>0||d&&p&&r(p)){t===null&&(t=new zg(n));const f=c?t.fromEquirectangular(l):t.fromCubemap(l);return e.set(l,f),l.addEventListener("dispose",a),f.texture}else return null}}}return l}function r(l){let h=0;const c=6;for(let d=0;d<c;d++)l[d]!==void 0&&h++;return h===c}function a(l){const h=l.target;h.removeEventListener("dispose",a);const c=e.get(h);c!==void 0&&(e.delete(h),c.dispose())}function s(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:s}}function OT(n){const e={};function t(i){if(e[i]!==void 0)return e[i];let r;switch(i){case"WEBGL_depth_texture":r=n.getExtension("WEBGL_depth_texture")||n.getExtension("MOZ_WEBGL_depth_texture")||n.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=n.getExtension("EXT_texture_filter_anisotropic")||n.getExtension("MOZ_EXT_texture_filter_anisotropic")||n.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=n.getExtension("WEBGL_compressed_texture_s3tc")||n.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=n.getExtension("WEBGL_compressed_texture_pvrtc")||n.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=n.getExtension(i)}return e[i]=r,r}return{has:function(i){return t(i)!==null},init:function(i){i.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(i){const r=t(i);return r===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),r}}}function NT(n,e,t,i){const r={},a=new WeakMap;function s(p){const f=p.target;f.index!==null&&e.remove(f.index);for(const _ in f.attributes)e.remove(f.attributes[_]);for(const _ in f.morphAttributes){const x=f.morphAttributes[_];for(let y=0,v=x.length;y<v;y++)e.remove(x[y])}f.removeEventListener("dispose",s),delete r[f.id];const m=a.get(f);m&&(e.remove(m),a.delete(f)),i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function l(p,f){return r[f.id]===!0||(f.addEventListener("dispose",s),r[f.id]=!0,t.memory.geometries++),f}function h(p){const f=p.attributes;for(const _ in f)e.update(f[_],n.ARRAY_BUFFER);const m=p.morphAttributes;for(const _ in m){const x=m[_];for(let y=0,v=x.length;y<v;y++)e.update(x[y],n.ARRAY_BUFFER)}}function c(p){const f=[],m=p.index,_=p.attributes.position;let x=0;if(m!==null){const M=m.array;x=m.version;for(let b=0,S=M.length;b<S;b+=3){const A=M[b+0],T=M[b+1],E=M[b+2];f.push(A,T,T,E,E,A)}}else if(_!==void 0){const M=_.array;x=_.version;for(let b=0,S=M.length/3-1;b<S;b+=3){const A=b+0,T=b+1,E=b+2;f.push(A,T,T,E,E,A)}}else return;const y=new(og(f)?Tg:Mg)(f,1);y.version=x;const v=a.get(p);v&&e.remove(v),a.set(p,y)}function d(p){const f=a.get(p);if(f){const m=p.index;m!==null&&f.version<m.version&&c(p)}else c(p);return a.get(p)}return{get:l,update:h,getWireframeAttribute:d}}function UT(n,e,t,i){const r=i.isWebGL2;let a;function s(m){a=m}let l,h;function c(m){l=m.type,h=m.bytesPerElement}function d(m,_){n.drawElements(a,_,l,m*h),t.update(_,a,1)}function p(m,_,x){if(x===0)return;let y,v;if(r)y=n,v="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),v="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[v](a,_,l,m*h,x),t.update(_,a,x)}function f(m,_,x){if(x===0)return;const y=e.get("WEBGL_multi_draw");if(y===null)for(let v=0;v<x;v++)this.render(m[v]/h,_[v]);else{y.multiDrawElementsWEBGL(a,_,0,l,m,0,x);let v=0;for(let M=0;M<x;M++)v+=_[M];t.update(v,a,1)}}this.setMode=s,this.setIndex=c,this.render=d,this.renderInstances=p,this.renderMultiDraw=f}function zT(n){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function i(a,s,l){switch(t.calls++,s){case n.TRIANGLES:t.triangles+=l*(a/3);break;case n.LINES:t.lines+=l*(a/2);break;case n.LINE_STRIP:t.lines+=l*(a-1);break;case n.LINE_LOOP:t.lines+=l*a;break;case n.POINTS:t.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",s);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:i}}function BT(n,e){return n[0]-e[0]}function FT(n,e){return Math.abs(e[1])-Math.abs(n[1])}function kT(n,e,t){const i={},r=new Float32Array(8),a=new WeakMap,s=new Zt,l=[];for(let c=0;c<8;c++)l[c]=[c,0];function h(c,d,p){const f=c.morphTargetInfluences;if(e.isWebGL2===!0){const m=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,_=m!==void 0?m.length:0;let x=a.get(d);if(x===void 0||x.count!==_){let M=function(){te.dispose(),a.delete(d),d.removeEventListener("dispose",M)};x!==void 0&&x.texture.dispose();const b=d.morphAttributes.position!==void 0,S=d.morphAttributes.normal!==void 0,A=d.morphAttributes.color!==void 0,T=d.morphAttributes.position||[],E=d.morphAttributes.normal||[],I=d.morphAttributes.color||[];let C=0;b===!0&&(C=1),S===!0&&(C=2),A===!0&&(C=3);let P=d.attributes.position.count*C,X=1;P>e.maxTextureSize&&(X=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);const q=new Float32Array(P*X*4*_),te=new pg(q,P,X,_);te.type=Xn,te.needsUpdate=!0;const k=C*4;for(let H=0;H<_;H++){const V=T[H],J=E[H],ie=I[H],$=P*X*4*H;for(let ne=0;ne<V.count;ne++){const he=ne*k;b===!0&&(s.fromBufferAttribute(V,ne),q[$+he+0]=s.x,q[$+he+1]=s.y,q[$+he+2]=s.z,q[$+he+3]=0),S===!0&&(s.fromBufferAttribute(J,ne),q[$+he+4]=s.x,q[$+he+5]=s.y,q[$+he+6]=s.z,q[$+he+7]=0),A===!0&&(s.fromBufferAttribute(ie,ne),q[$+he+8]=s.x,q[$+he+9]=s.y,q[$+he+10]=s.z,q[$+he+11]=ie.itemSize===4?s.w:1)}}x={count:_,texture:te,size:new pe(P,X)},a.set(d,x),d.addEventListener("dispose",M)}let y=0;for(let M=0;M<f.length;M++)y+=f[M];const v=d.morphTargetsRelative?1:1-y;p.getUniforms().setValue(n,"morphTargetBaseInfluence",v),p.getUniforms().setValue(n,"morphTargetInfluences",f),p.getUniforms().setValue(n,"morphTargetsTexture",x.texture,t),p.getUniforms().setValue(n,"morphTargetsTextureSize",x.size)}else{const m=f===void 0?0:f.length;let _=i[d.id];if(_===void 0||_.length!==m){_=[];for(let b=0;b<m;b++)_[b]=[b,0];i[d.id]=_}for(let b=0;b<m;b++){const S=_[b];S[0]=b,S[1]=f[b]}_.sort(FT);for(let b=0;b<8;b++)b<m&&_[b][1]?(l[b][0]=_[b][0],l[b][1]=_[b][1]):(l[b][0]=Number.MAX_SAFE_INTEGER,l[b][1]=0);l.sort(BT);const x=d.morphAttributes.position,y=d.morphAttributes.normal;let v=0;for(let b=0;b<8;b++){const S=l[b],A=S[0],T=S[1];A!==Number.MAX_SAFE_INTEGER&&T?(x&&d.getAttribute("morphTarget"+b)!==x[A]&&d.setAttribute("morphTarget"+b,x[A]),y&&d.getAttribute("morphNormal"+b)!==y[A]&&d.setAttribute("morphNormal"+b,y[A]),r[b]=T,v+=T):(x&&d.hasAttribute("morphTarget"+b)===!0&&d.deleteAttribute("morphTarget"+b),y&&d.hasAttribute("morphNormal"+b)===!0&&d.deleteAttribute("morphNormal"+b),r[b]=0)}const M=d.morphTargetsRelative?1:1-v;p.getUniforms().setValue(n,"morphTargetBaseInfluence",M),p.getUniforms().setValue(n,"morphTargetInfluences",r)}}return{update:h}}function HT(n,e,t,i){let r=new WeakMap;function a(h){const c=i.render.frame,d=h.geometry,p=e.get(h,d);if(r.get(p)!==c&&(e.update(p),r.set(p,c)),h.isInstancedMesh&&(h.hasEventListener("dispose",l)===!1&&h.addEventListener("dispose",l),r.get(h)!==c&&(t.update(h.instanceMatrix,n.ARRAY_BUFFER),h.instanceColor!==null&&t.update(h.instanceColor,n.ARRAY_BUFFER),r.set(h,c))),h.isSkinnedMesh){const f=h.skeleton;r.get(f)!==c&&(f.update(),r.set(f,c))}return p}function s(){r=new WeakMap}function l(h){const c=h.target;c.removeEventListener("dispose",l),t.remove(c.instanceMatrix),c.instanceColor!==null&&t.remove(c.instanceColor)}return{update:a,dispose:s}}class Hg extends Wi{constructor(e,t,i,r,a,s,l,h,c,d){if(d=d!==void 0?d:$a,d!==$a&&d!==ks)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&d===$a&&(i=ya),i===void 0&&d===ks&&(i=Ja),super(null,r,a,s,l,h,d,i,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=l!==void 0?l:zi,this.minFilter=h!==void 0?h:zi,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 Gg=new Wi,Vg=new Hg(1,1);Vg.compareFunction=ng;const Wg=new pg,jg=new Eb,Xg=new Dg,qg=[],Yg=[],Kg=new Float32Array(16),Zg=new Float32Array(9),Jg=new Float32Array(4);function lo(n,e,t){const i=n[0];if(i<=0||i>0)return n;const r=e*t;let a=qg[r];if(a===void 0&&(a=new Float32Array(r),qg[r]=a),e!==0){i.toArray(a,0);for(let s=1,l=0;s!==e;++s)l+=t,n[s].toArray(a,l)}return a}function Ci(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t<i;t++)if(n[t]!==e[t])return!1;return!0}function Li(n,e){for(let t=0,i=e.length;t<i;t++)n[t]=e[t]}function Zh(n,e){let t=Yg[e];t===void 0&&(t=new Int32Array(e),Yg[e]=t);for(let i=0;i!==e;++i)t[i]=n.allocateTextureUnit();return t}function GT(n,e){const t=this.cache;t[0]!==e&&(n.uniform1f(this.addr,e),t[0]=e)}function VT(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ci(t,e))return;n.uniform2fv(this.addr,e),Li(t,e)}}function WT(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.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)&&(n.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Ci(t,e))return;n.uniform3fv(this.addr,e),Li(t,e)}}function jT(n,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)&&(n.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(Ci(t,e))return;n.uniform4fv(this.addr,e),Li(t,e)}}function XT(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Ci(t,e))return;n.uniformMatrix2fv(this.addr,!1,e),Li(t,e)}else{if(Ci(t,i))return;Jg.set(i),n.uniformMatrix2fv(this.addr,!1,Jg),Li(t,i)}}function qT(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Ci(t,e))return;n.uniformMatrix3fv(this.addr,!1,e),Li(t,e)}else{if(Ci(t,i))return;Zg.set(i),n.uniformMatrix3fv(this.addr,!1,Zg),Li(t,i)}}function YT(n,e){const t=this.cache,i=e.elements;if(i===void 0){if(Ci(t,e))return;n.uniformMatrix4fv(this.addr,!1,e),Li(t,e)}else{if(Ci(t,i))return;Kg.set(i),n.uniformMatrix4fv(this.addr,!1,Kg),Li(t,i)}}function KT(n,e){const t=this.cache;t[0]!==e&&(n.uniform1i(this.addr,e),t[0]=e)}function ZT(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ci(t,e))return;n.uniform2iv(this.addr,e),Li(t,e)}}function JT(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ci(t,e))return;n.uniform3iv(this.addr,e),Li(t,e)}}function $T(n,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)&&(n.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(Ci(t,e))return;n.uniform4iv(this.addr,e),Li(t,e)}}function QT(n,e){const t=this.cache;t[0]!==e&&(n.uniform1ui(this.addr,e),t[0]=e)}function eS(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(n.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Ci(t,e))return;n.uniform2uiv(this.addr,e),Li(t,e)}}function tS(n,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(n.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Ci(t,e))return;n.uniform3uiv(this.addr,e),Li(t,e)}}function iS(n,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)&&(n.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(Ci(t,e))return;n.uniform4uiv(this.addr,e),Li(t,e)}}function rS(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r);const a=this.type===n.SAMPLER_2D_SHADOW?Vg:Gg;t.setTexture2D(e||a,r)}function nS(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture3D(e||jg,r)}function aS(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTextureCube(e||Xg,r)}function sS(n,e,t){const i=this.cache,r=t.allocateTextureUnit();i[0]!==r&&(n.uniform1i(this.addr,r),i[0]=r),t.setTexture2DArray(e||Wg,r)}function oS(n){switch(n){case 5126:return GT;case 35664:return VT;case 35665:return WT;case 35666:return jT;case 35674:return XT;case 35675:return qT;case 35676:return YT;case 5124:case 35670:return KT;case 35667:case 35671:return ZT;case 35668:case 35672:return JT;case 35669:case 35673:return $T;case 5125:return QT;case 36294:return eS;case 36295:return tS;case 36296:return iS;case 35678:case 36198:case 36298:case 36306:case 35682:return rS;case 35679:case 36299:case 36307:return nS;case 35680:case 36300:case 36308:case 36293:return aS;case 36289:case 36303:case 36311:case 36292:return sS}}function lS(n,e){n.uniform1fv(this.addr,e)}function hS(n,e){const t=lo(e,this.size,2);n.uniform2fv(this.addr,t)}function cS(n,e){const t=lo(e,this.size,3);n.uniform3fv(this.addr,t)}function uS(n,e){const t=lo(e,this.size,4);n.uniform4fv(this.addr,t)}function dS(n,e){const t=lo(e,this.size,4);n.uniformMatrix2fv(this.addr,!1,t)}function pS(n,e){const t=lo(e,this.size,9);n.uniformMatrix3fv(this.addr,!1,t)}function fS(n,e){const t=lo(e,this.size,16);n.uniformMatrix4fv(this.addr,!1,t)}function mS(n,e){n.uniform1iv(this.addr,e)}function gS(n,e){n.uniform2iv(this.addr,e)}function _S(n,e){n.uniform3iv(this.addr,e)}function vS(n,e){n.uniform4iv(this.addr,e)}function yS(n,e){n.uniform1uiv(this.addr,e)}function xS(n,e){n.uniform2uiv(this.addr,e)}function bS(n,e){n.uniform3uiv(this.addr,e)}function wS(n,e){n.uniform4uiv(this.addr,e)}function MS(n,e,t){const i=this.cache,r=e.length,a=Zh(t,r);Ci(i,a)||(n.uniform1iv(this.addr,a),Li(i,a));for(let s=0;s!==r;++s)t.setTexture2D(e[s]||Gg,a[s])}function TS(n,e,t){const i=this.cache,r=e.length,a=Zh(t,r);Ci(i,a)||(n.uniform1iv(this.addr,a),Li(i,a));for(let s=0;s!==r;++s)t.setTexture3D(e[s]||jg,a[s])}function SS(n,e,t){const i=this.cache,r=e.length,a=Zh(t,r);Ci(i,a)||(n.uniform1iv(this.addr,a),Li(i,a));for(let s=0;s!==r;++s)t.setTextureCube(e[s]||Xg,a[s])}function ES(n,e,t){const i=this.cache,r=e.length,a=Zh(t,r);Ci(i,a)||(n.uniform1iv(this.addr,a),Li(i,a));for(let s=0;s!==r;++s)t.setTexture2DArray(e[s]||Wg,a[s])}function AS(n){switch(n){case 5126:return lS;case 35664:return hS;case 35665:return cS;case 35666:return uS;case 35674:return dS;case 35675:return pS;case 35676:return fS;case 5124:case 35670:return mS;case 35667:case 35671:return gS;case 35668:case 35672:return _S;case 35669:case 35673:return vS;case 5125:return yS;case 36294:return xS;case 36295:return bS;case 36296:return wS;case 35678:case 36198:case 36298:case 36306:case 35682:return MS;case 35679:case 36299:case 36307:return TS;case 35680:case 36300:case 36308:case 36293:return SS;case 36289:case 36303:case 36311:case 36292:return ES}}class RS{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.setValue=oS(t.type)}}class CS{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=AS(t.type)}}class LS{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){const r=this.seq;for(let a=0,s=r.length;a!==s;++a){const l=r[a];l.setValue(e,t[l.id],i)}}}const bd=/(\w+)(\])?(\[|\.)?/g;function $g(n,e){n.seq.push(e),n.map[e.id]=e}function PS(n,e,t){const i=n.name,r=i.length;for(bd.lastIndex=0;;){const a=bd.exec(i),s=bd.lastIndex;let l=a[1];const h=a[2]==="]",c=a[3];if(h&&(l=l|0),c===void 0||c==="["&&s+2===r){$g(t,c===void 0?new RS(l,n,e):new CS(l,n,e));break}else{let d=t.map[l];d===void 0&&(d=new LS(l),$g(t,d)),t=d}}}class Jh{constructor(e,t){this.seq=[],this.map={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<i;++r){const a=e.getActiveUniform(t,r),s=e.getUniformLocation(t,a.name);PS(a,s,this)}}setValue(e,t,i,r){const a=this.map[t];a!==void 0&&a.setValue(e,i,r)}setOptional(e,t,i){const r=t[i];r!==void 0&&this.setValue(e,i,r)}static upload(e,t,i,r){for(let a=0,s=t.length;a!==s;++a){const l=t[a],h=i[l.id];h.needsUpdate!==!1&&l.setValue(e,h.value,r)}}static seqWithValue(e,t){const i=[];for(let r=0,a=e.length;r!==a;++r){const s=e[r];s.id in t&&i.push(s)}return i}}function Qg(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const DS=37297;let IS=0;function OS(n,e){const t=n.split(` `),i=[],r=Math.max(e-6,0),a=Math.min(e+6,t.length);for(let s=r;s<a;s++){const l=s+1;i.push(`${l===e?">":" "} ${l}: ${t[s]}`)}return i.join(` `)}function NS(n){const e=Gt.getPrimaries(Gt.workingColorSpace),t=Gt.getPrimaries(n);let i;switch(e===t?i="":e===Th&&t===Mh?i="LinearDisplayP3ToLinearSRGB":e===Mh&&t===Th&&(i="LinearSRGBToLinearDisplayP3"),n){case Bi:case bh:return[i,"LinearTransferOETF"];case Bt:case ju:return[i,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",n),[i,"LinearTransferOETF"]}}function e_(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=n.getShaderInfoLog(e).trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const s=parseInt(a[1]);return t.toUpperCase()+` `+r+` `+OS(n.getShaderSource(e),s)}else return r}function US(n,e){const t=NS(e);return`vec4 ${n}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`}function zS(n,e){let t;switch(e){case mm:t="Linear";break;case N1:t="Reinhard";break;case U1:t="OptimizedCineon";break;case z1:t="ACESFilmic";break;case F1:t="AgX";break;case B1:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function BS(n){return[n.extensionDerivatives||n.envMapCubeUVHeight||n.bumpMap||n.normalMapTangentSpace||n.clearcoatNormalMap||n.flatShading||n.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(n.extensionFragDepth||n.logarithmicDepthBuffer)&&n.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",n.extensionDrawBuffers&&n.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(n.extensionShaderTextureLOD||n.envMap||n.transmission)&&n.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ho).join(` `)}function FS(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":""].filter(ho).join(` `)}function kS(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` `)}function HS(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let r=0;r<i;r++){const a=n.getActiveAttrib(e,r),s=a.name;let l=1;a.type===n.FLOAT_MAT2&&(l=2),a.type===n.FLOAT_MAT3&&(l=3),a.type===n.FLOAT_MAT4&&(l=4),t[s]={type:a.type,location:n.getAttribLocation(e,s),locationSize:l}}return t}function ho(n){return n!==""}function t_(n,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return n.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 i_(n,e){return n.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const GS=/^[ \t]*#include +<([\w\d./]+)>/gm;function wd(n){return n.replace(GS,WS)}const VS=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function WS(n,e){let t=Mt[e];if(t===void 0){const i=VS.get(e);if(i!==void 0)t=Mt[i],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("Can not resolve #include <"+e+">")}return wd(t)}const jS=/#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 r_(n){return n.replace(jS,XS)}function XS(n,e,t,i){let r="";for(let a=parseInt(e);a<parseInt(t);a++)r+=i.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function n_(n){let e="precision "+n.precision+` float; precision `+n.precision+" int;";return n.precision==="highp"?e+=` #define HIGH_PRECISION`:n.precision==="mediump"?e+=` #define MEDIUM_PRECISION`:n.precision==="lowp"&&(e+=` #define LOW_PRECISION`),e}function qS(n){let e="SHADOWMAP_TYPE_BASIC";return n.shadowMapType===cm?e="SHADOWMAP_TYPE_PCF":n.shadowMapType===h1?e="SHADOWMAP_TYPE_PCF_SOFT":n.shadowMapType===En&&(e="SHADOWMAP_TYPE_VSM"),e}function YS(n){let e="ENVMAP_TYPE_CUBE";if(n.envMap)switch(n.envMapMode){case Bs:case Fs:e="ENVMAP_TYPE_CUBE";break;case _h:e="ENVMAP_TYPE_CUBE_UV";break}return e}function KS(n){let e="ENVMAP_MODE_REFLECTION";if(n.envMap)switch(n.envMapMode){case Fs:e="ENVMAP_MODE_REFRACTION";break}return e}function ZS(n){let e="ENVMAP_BLENDING_NONE";if(n.envMap)switch(n.combine){case gh:e="ENVMAP_BLENDING_MULTIPLY";break;case I1:e="ENVMAP_BLENDING_MIX";break;case O1:e="ENVMAP_BLENDING_ADD";break}return e}function JS(n){const e=n.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,i=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:i,maxMip:t}}function $S(n,e,t,i){const r=n.getContext(),a=t.defines;let s=t.vertexShader,l=t.fragmentShader;const h=qS(t),c=YS(t),d=KS(t),p=ZS(t),f=JS(t),m=t.isWebGL2?"":BS(t),_=FS(t),x=kS(a),y=r.createProgram();let v,M,b=t.glslVersion?"#version "+t.glslVersion+` `:"";t.isRawShaderMaterial?(v=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(ho).join(` `),v.length>0&&(v+=` `),M=[m,"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x].filter(ho).join(` `),M.length>0&&(M+=` `)):(v=[n_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,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 "+d:"",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 "+h:"",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(ho).join(` `),M=[m,n_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,x,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 "+c:"",t.envMap?"#define "+d:"",t.envMap?"#define "+p:"",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 "+h:"",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!==_a?"#define TONE_MAPPING":"",t.toneMapping!==_a?Mt.tonemapping_pars_fragment:"",t.toneMapping!==_a?zS("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Mt.colorspace_pars_fragment,US("linearToOutputTexel",t.outputColorSpace),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(ho).join(` `)),s=wd(s),s=t_(s,t),s=i_(s,t),l=wd(l),l=t_(l,t),l=i_(l,t),s=r_(s),l=r_(l),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(b=`#version 300 es `,v=[_,"precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+v,M=["precision mediump sampler2DArray;","#define varying in",t.glslVersion===ag?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===ag?"":"#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(` `)+` `+M);const S=b+v+s,A=b+M+l,T=Qg(r,r.VERTEX_SHADER,S),E=Qg(r,r.FRAGMENT_SHADER,A);r.attachShader(y,T),r.attachShader(y,E),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function I(q){if(n.debug.checkShaderErrors){const te=r.getProgramInfoLog(y).trim(),k=r.getShaderInfoLog(T).trim(),H=r.getShaderInfoLog(E).trim();let V=!0,J=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if(V=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(r,y,T,E);else{const ie=e_(r,T,"vertex"),$=e_(r,E,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+` Program Info Log: `+te+` `+ie+` `+$)}else te!==""?console.warn("THREE.WebGLProgram: Program Info Log:",te):(k===""||H==="")&&(J=!1);J&&(q.diagnostics={runnable:V,programLog:te,vertexShader:{log:k,prefix:v},fragmentShader:{log:H,prefix:M}})}r.deleteShader(T),r.deleteShader(E),C=new Jh(r,y),P=HS(r,y)}let C;this.getUniforms=function(){return C===void 0&&I(this),C};let P;this.getAttributes=function(){return P===void 0&&I(this),P};let X=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return X===!1&&(X=r.getProgramParameter(y,DS)),X},this.destroy=function(){i.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=IS++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=T,this.fragmentShader=E,this}let QS=0;class eE{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,i=e.fragmentShader,r=this._getShaderStage(t),a=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(r)===!1&&(s.add(r),r.usedTimes++),s.has(a)===!1&&(s.add(a),a.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new tE(e),t.set(e,i)),i}}class tE{constructor(e){this.id=QS++,this.code=e,this.usedTimes=0}}function iE(n,e,t,i,r,a,s){const l=new ad,h=new eE,c=[],d=r.isWebGL2,p=r.logarithmicDepthBuffer,f=r.vertexTextures;let m=r.precision;const _={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 x(C){return C===0?"uv":`uv${C}`}function y(C,P,X,q,te){const k=q.fog,H=te.geometry,V=C.isMeshStandardMaterial?q.environment:null,J=(C.isMeshStandardMaterial?t:e).get(C.envMap||V),ie=J&&J.mapping===_h?J.image.height:null,$=_[C.type];C.precision!==null&&(m=r.getMaxPrecision(C.precision),m!==C.precision&&console.warn("THREE.WebGLProgram.getParameters:",C.precision,"not supported, using",m,"instead."));const ne=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,he=ne!==void 0?ne.length:0;let De=0;H.morphAttributes.position!==void 0&&(De=1),H.morphAttributes.normal!==void 0&&(De=2),H.morphAttributes.color!==void 0&&(De=3);let ee,ce,Te,Be;if($){const oi=Ln[$];ee=oi.vertexShader,ce=oi.fragmentShader}else ee=C.vertexShader,ce=C.fragmentShader,h.update(C),Te=h.getVertexShaderID(C),Be=h.getFragmentShaderID(C);const je=n.getRenderTarget(),$e=te.isInstancedMesh===!0,qe=te.isBatchedMesh===!0,Xe=!!C.map,ge=!!C.matcap,G=!!J,Ae=!!C.aoMap,ue=!!C.lightMap,de=!!C.bumpMap,Ee=!!C.normalMap,Fe=!!C.displacementMap,ke=!!C.emissiveMap,N=!!C.metalnessMap,L=!!C.roughnessMap,Z=C.anisotropy>0,xe=C.clearcoat>0,fe=C.iridescence>0,Se=C.sheen>0,He=C.transmission>0,Ie=Z&&!!C.anisotropyMap,Ue=xe&&!!C.clearcoatMap,Ge=xe&&!!C.clearcoatNormalMap,Je=xe&&!!C.clearcoatRoughnessMap,be=fe&&!!C.iridescenceMap,dt=fe&&!!C.iridescenceThicknessMap,B=Se&&!!C.sheenColorMap,_e=Se&&!!C.sheenRoughnessMap,Ce=!!C.specularMap,Re=!!C.specularColorMap,Ve=!!C.specularIntensityMap,tt=He&&!!C.transmissionMap,Tt=He&&!!C.thicknessMap,ut=!!C.gradientMap,Le=!!C.alphaMap,W=C.alphaTest>0,we=!!C.alphaHash,Pe=!!C.extensions,et=!!H.attributes.uv1,ye=!!H.attributes.uv2,it=!!H.attributes.uv3;let Ut=_a;return C.toneMapped&&(je===null||je.isXRRenderTarget===!0)&&(Ut=n.toneMapping),{isWebGL2:d,shaderID:$,shaderType:C.type,shaderName:C.name,vertexShader:ee,fragmentShader:ce,defines:C.defines,customVertexShaderID:Te,customFragmentShaderID:Be,isRawShaderMaterial:C.isRawShaderMaterial===!0,glslVersion:C.glslVersion,precision:m,batching:qe,instancing:$e,instancingColor:$e&&te.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:je===null?n.outputColorSpace:je.isXRRenderTarget===!0?je.texture.colorSpace:Bi,map:Xe,matcap:ge,envMap:G,envMapMode:G&&J.mapping,envMapCubeUVHeight:ie,aoMap:Ae,lightMap:ue,bumpMap:de,normalMap:Ee,displacementMap:f&&Fe,emissiveMap:ke,normalMapObjectSpace:Ee&&C.normalMapType===$1,normalMapTangentSpace:Ee&&C.normalMapType===xh,metalnessMap:N,roughnessMap:L,anisotropy:Z,anisotropyMap:Ie,clearcoat:xe,clearcoatMap:Ue,clearcoatNormalMap:Ge,clearcoatRoughnessMap:Je,iridescence:fe,iridescenceMap:be,iridescenceThicknessMap:dt,sheen:Se,sheenColorMap:B,sheenRoughnessMap:_e,specularMap:Ce,specularColorMap:Re,specularIntensityMap:Ve,transmission:He,transmissionMap:tt,thicknessMap:Tt,gradientMap:ut,opaque:C.transparent===!1&&C.blending===zs,alphaMap:Le,alphaTest:W,alphaHash:we,combine:C.combine,mapUv:Xe&&x(C.map.channel),aoMapUv:Ae&&x(C.aoMap.channel),lightMapUv:ue&&x(C.lightMap.channel),bumpMapUv:de&&x(C.bumpMap.channel),normalMapUv:Ee&&x(C.normalMap.channel),displacementMapUv:Fe&&x(C.displacementMap.channel),emissiveMapUv:ke&&x(C.emissiveMap.channel),metalnessMapUv:N&&x(C.metalnessMap.channel),roughnessMapUv:L&&x(C.roughnessMap.channel),anisotropyMapUv:Ie&&x(C.anisotropyMap.channel),clearcoatMapUv:Ue&&x(C.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&x(C.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Je&&x(C.clearcoatRoughnessMap.channel),iridescenceMapUv:be&&x(C.iridescenceMap.channel),iridescenceThicknessMapUv:dt&&x(C.iridescenceThicknessMap.channel),sheenColorMapUv:B&&x(C.sheenColorMap.channel),sheenRoughnessMapUv:_e&&x(C.sheenRoughnessMap.channel),specularMapUv:Ce&&x(C.specularMap.channel),specularColorMapUv:Re&&x(C.specularColorMap.channel),specularIntensityMapUv:Ve&&x(C.specularIntensityMap.channel),transmissionMapUv:tt&&x(C.transmissionMap.channel),thicknessMapUv:Tt&&x(C.thicknessMap.channel),alphaMapUv:Le&&x(C.alphaMap.channel),vertexTangents:!!H.attributes.tangent&&(Ee||Z),vertexColors:C.vertexColors,vertexAlphas:C.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,vertexUv1s:et,vertexUv2s:ye,vertexUv3s:it,pointsUvs:te.isPoints===!0&&!!H.attributes.uv&&(Xe||Le),fog:!!k,useFog:C.fog===!0,fogExp2:k&&k.isFogExp2,flatShading:C.flatShading===!0,sizeAttenuation:C.sizeAttenuation===!0,logarithmicDepthBuffer:p,skinning:te.isSkinnedMesh===!0,morphTargets:H.morphAttributes.position!==void 0,morphNormals:H.morphAttributes.normal!==void 0,morphColors:H.morphAttributes.color!==void 0,morphTargetsCount:he,morphTextureStride:De,numDirLights:P.directional.length,numPointLights:P.point.length,numSpotLights:P.spot.length,numSpotLightMaps:P.spotLightMap.length,numRectAreaLights:P.rectArea.length,numHemiLights:P.hemi.length,numDirLightShadows:P.directionalShadowMap.length,numPointLightShadows:P.pointShadowMap.length,numSpotLightShadows:P.spotShadowMap.length,numSpotLightShadowsWithMaps:P.numSpotLightShadowsWithMaps,numLightProbes:P.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:C.dithering,shadowMapEnabled:n.shadowMap.enabled&&X.length>0,shadowMapType:n.shadowMap.type,toneMapping:Ut,useLegacyLights:n._useLegacyLights,decodeVideoTexture:Xe&&C.map.isVideoTexture===!0&&Gt.getTransfer(C.map.colorSpace)===ii,premultipliedAlpha:C.premultipliedAlpha,doubleSided:C.side===xi,flipSided:C.side===dr,useDepthPacking:C.depthPacking>=0,depthPacking:C.depthPacking||0,index0AttributeName:C.index0AttributeName,extensionDerivatives:Pe&&C.extensions.derivatives===!0,extensionFragDepth:Pe&&C.extensions.fragDepth===!0,extensionDrawBuffers:Pe&&C.extensions.drawBuffers===!0,extensionShaderTextureLOD:Pe&&C.extensions.shaderTextureLOD===!0,extensionClipCullDistance:Pe&&C.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),rendererExtensionFragDepth:d||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||i.has("EXT_shader_texture_lod"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:C.customProgramCacheKey()}}function v(C){const P=[];if(C.shaderID?P.push(C.shaderID):(P.push(C.customVertexShaderID),P.push(C.customFragmentShaderID)),C.defines!==void 0)for(const X in C.defines)P.push(X),P.push(C.defines[X]);return C.isRawShaderMaterial===!1&&(M(P,C),b(P,C),P.push(n.outputColorSpace)),P.push(C.customProgramCacheKey),P.join()}function M(C,P){C.push(P.precision),C.push(P.outputColorSpace),C.push(P.envMapMode),C.push(P.envMapCubeUVHeight),C.push(P.mapUv),C.push(P.alphaMapUv),C.push(P.lightMapUv),C.push(P.aoMapUv),C.push(P.bumpMapUv),C.push(P.normalMapUv),C.push(P.displacementMapUv),C.push(P.emissiveMapUv),C.push(P.metalnessMapUv),C.push(P.roughnessMapUv),C.push(P.anisotropyMapUv),C.push(P.clearcoatMapUv),C.push(P.clearcoatNormalMapUv),C.push(P.clearcoatRoughnessMapUv),C.push(P.iridescenceMapUv),C.push(P.iridescenceThicknessMapUv),C.push(P.sheenColorMapUv),C.push(P.sheenRoughnessMapUv),C.push(P.specularMapUv),C.push(P.specularColorMapUv),C.push(P.specularIntensityMapUv),C.push(P.transmissionMapUv),C.push(P.thicknessMapUv),C.push(P.combine),C.push(P.fogExp2),C.push(P.sizeAttenuation),C.push(P.morphTargetsCount),C.push(P.morphAttributeCount),C.push(P.numDirLights),C.push(P.numPointLights),C.push(P.numSpotLights),C.push(P.numSpotLightMaps),C.push(P.numHemiLights),C.push(P.numRectAreaLights),C.push(P.numDirLightShadows),C.push(P.numPointLightShadows),C.push(P.numSpotLightShadows),C.push(P.numSpotLightShadowsWithMaps),C.push(P.numLightProbes),C.push(P.shadowMapType),C.push(P.toneMapping),C.push(P.numClippingPlanes),C.push(P.numClipIntersection),C.push(P.depthPacking)}function b(C,P){l.disableAll(),P.isWebGL2&&l.enable(0),P.supportsVertexTextures&&l.enable(1),P.instancing&&l.enable(2),P.instancingColor&&l.enable(3),P.matcap&&l.enable(4),P.envMap&&l.enable(5),P.normalMapObjectSpace&&l.enable(6),P.normalMapTangentSpace&&l.enable(7),P.clearcoat&&l.enable(8),P.iridescence&&l.enable(9),P.alphaTest&&l.enable(10),P.vertexColors&&l.enable(11),P.vertexAlphas&&l.enable(12),P.vertexUv1s&&l.enable(13),P.vertexUv2s&&l.enable(14),P.vertexUv3s&&l.enable(15),P.vertexTangents&&l.enable(16),P.anisotropy&&l.enable(17),P.alphaHash&&l.enable(18),P.batching&&l.enable(19),C.push(l.mask),l.disableAll(),P.fog&&l.enable(0),P.useFog&&l.enable(1),P.flatShading&&l.enable(2),P.logarithmicDepthBuffer&&l.enable(3),P.skinning&&l.enable(4),P.morphTargets&&l.enable(5),P.morphNormals&&l.enable(6),P.morphColors&&l.enable(7),P.premultipliedAlpha&&l.enable(8),P.shadowMapEnabled&&l.enable(9),P.useLegacyLights&&l.enable(10),P.doubleSided&&l.enable(11),P.flipSided&&l.enable(12),P.useDepthPacking&&l.enable(13),P.dithering&&l.enable(14),P.transmission&&l.enable(15),P.sheen&&l.enable(16),P.opaque&&l.enable(17),P.pointsUvs&&l.enable(18),P.decodeVideoTexture&&l.enable(19),C.push(l.mask)}function S(C){const P=_[C.type];let X;if(P){const q=Ln[P];X=pd.clone(q.uniforms)}else X=C.uniforms;return X}function A(C,P){let X;for(let q=0,te=c.length;q<te;q++){const k=c[q];if(k.cacheKey===P){X=k,++X.usedTimes;break}}return X===void 0&&(X=new $S(n,P,C,a),c.push(X)),X}function T(C){if(--C.usedTimes===0){const P=c.indexOf(C);c[P]=c[c.length-1],c.pop(),C.destroy()}}function E(C){h.remove(C)}function I(){h.dispose()}return{getParameters:y,getProgramCacheKey:v,getUniforms:S,acquireProgram:A,releaseProgram:T,releaseShaderCache:E,programs:c,dispose:I}}function rE(){let n=new WeakMap;function e(a){let s=n.get(a);return s===void 0&&(s={},n.set(a,s)),s}function t(a){n.delete(a)}function i(a,s,l){n.get(a)[s]=l}function r(){n=new WeakMap}return{get:e,remove:t,update:i,dispose:r}}function nE(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.z!==e.z?n.z-e.z:n.id-e.id}function a_(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function s_(){const n=[];let e=0;const t=[],i=[],r=[];function a(){e=0,t.length=0,i.length=0,r.length=0}function s(p,f,m,_,x,y){let v=n[e];return v===void 0?(v={id:p.id,object:p,geometry:f,material:m,groupOrder:_,renderOrder:p.renderOrder,z:x,group:y},n[e]=v):(v.id=p.id,v.object=p,v.geometry=f,v.material=m,v.groupOrder=_,v.renderOrder=p.renderOrder,v.z=x,v.group=y),e++,v}function l(p,f,m,_,x,y){const v=s(p,f,m,_,x,y);m.transmission>0?i.push(v):m.transparent===!0?r.push(v):t.push(v)}function h(p,f,m,_,x,y){const v=s(p,f,m,_,x,y);m.transmission>0?i.unshift(v):m.transparent===!0?r.unshift(v):t.unshift(v)}function c(p,f){t.length>1&&t.sort(p||nE),i.length>1&&i.sort(f||a_),r.length>1&&r.sort(f||a_)}function d(){for(let p=e,f=n.length;p<f;p++){const m=n[p];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:i,transparent:r,init:a,push:l,unshift:h,finish:d,sort:c}}function aE(){let n=new WeakMap;function e(i,r){const a=n.get(i);let s;return a===void 0?(s=new s_,n.set(i,[s])):r>=a.length?(s=new s_,a.push(s)):s=a[r],s}function t(){n=new WeakMap}return{get:e,dispose:t}}function sE(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new z,color:new Ke};break;case"SpotLight":t={position:new z,direction:new z,color:new Ke,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new z,color:new Ke,distance:0,decay:0};break;case"HemisphereLight":t={direction:new z,skyColor:new Ke,groundColor:new Ke};break;case"RectAreaLight":t={color:new Ke,position:new z,halfWidth:new z,halfHeight:new z};break}return n[e.id]=t,t}}}function oE(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pe};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pe};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new pe,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let lE=0;function hE(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function cE(n,e){const t=new sE,i=oE(),r={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 d=0;d<9;d++)r.probe.push(new z);const a=new z,s=new Ze,l=new Ze;function h(d,p){let f=0,m=0,_=0;for(let q=0;q<9;q++)r.probe[q].set(0,0,0);let x=0,y=0,v=0,M=0,b=0,S=0,A=0,T=0,E=0,I=0,C=0;d.sort(hE);const P=p===!0?Math.PI:1;for(let q=0,te=d.length;q<te;q++){const k=d[q],H=k.color,V=k.intensity,J=k.distance,ie=k.shadow&&k.shadow.map?k.shadow.map.texture:null;if(k.isAmbientLight)f+=H.r*V*P,m+=H.g*V*P,_+=H.b*V*P;else if(k.isLightProbe){for(let $=0;$<9;$++)r.probe[$].addScaledVector(k.sh.coefficients[$],V);C++}else if(k.isDirectionalLight){const $=t.get(k);if($.color.copy(k.color).multiplyScalar(k.intensity*P),k.castShadow){const ne=k.shadow,he=i.get(k);he.shadowBias=ne.bias,he.shadowNormalBias=ne.normalBias,he.shadowRadius=ne.radius,he.shadowMapSize=ne.mapSize,r.directionalShadow[x]=he,r.directionalShadowMap[x]=ie,r.directionalShadowMatrix[x]=k.shadow.matrix,S++}r.directional[x]=$,x++}else if(k.isSpotLight){const $=t.get(k);$.position.setFromMatrixPosition(k.matrixWorld),$.color.copy(H).multiplyScalar(V*P),$.distance=J,$.coneCos=Math.cos(k.angle),$.penumbraCos=Math.cos(k.angle*(1-k.penumbra)),$.decay=k.decay,r.spot[v]=$;const ne=k.shadow;if(k.map&&(r.spotLightMap[E]=k.map,E++,ne.updateMatrices(k),k.castShadow&&I++),r.spotLightMatrix[v]=ne.matrix,k.castShadow){const he=i.get(k);he.shadowBias=ne.bias,he.shadowNormalBias=ne.normalBias,he.shadowRadius=ne.radius,he.shadowMapSize=ne.mapSize,r.spotShadow[v]=he,r.spotShadowMap[v]=ie,T++}v++}else if(k.isRectAreaLight){const $=t.get(k);$.color.copy(H).multiplyScalar(V),$.halfWidth.set(k.width*.5,0,0),$.halfHeight.set(0,k.height*.5,0),r.rectArea[M]=$,M++}else if(k.isPointLight){const $=t.get(k);if($.color.copy(k.color).multiplyScalar(k.intensity*P),$.distance=k.distance,$.decay=k.decay,k.castShadow){const ne=k.shadow,he=i.get(k);he.shadowBias=ne.bias,he.shadowNormalBias=ne.normalBias,he.shadowRadius=ne.radius,he.shadowMapSize=ne.mapSize,he.shadowCameraNear=ne.camera.near,he.shadowCameraFar=ne.camera.far,r.pointShadow[y]=he,r.pointShadowMap[y]=ie,r.pointShadowMatrix[y]=k.shadow.matrix,A++}r.point[y]=$,y++}else if(k.isHemisphereLight){const $=t.get(k);$.skyColor.copy(k.color).multiplyScalar(V*P),$.groundColor.copy(k.groundColor).multiplyScalar(V*P),r.hemi[b]=$,b++}}M>0&&(e.isWebGL2?n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Oe.LTC_FLOAT_1,r.rectAreaLTC2=Oe.LTC_FLOAT_2):(r.rectAreaLTC1=Oe.LTC_HALF_1,r.rectAreaLTC2=Oe.LTC_HALF_2):n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Oe.LTC_FLOAT_1,r.rectAreaLTC2=Oe.LTC_FLOAT_2):n.has("OES_texture_half_float_linear")===!0?(r.rectAreaLTC1=Oe.LTC_HALF_1,r.rectAreaLTC2=Oe.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=f,r.ambient[1]=m,r.ambient[2]=_;const X=r.hash;(X.directionalLength!==x||X.pointLength!==y||X.spotLength!==v||X.rectAreaLength!==M||X.hemiLength!==b||X.numDirectionalShadows!==S||X.numPointShadows!==A||X.numSpotShadows!==T||X.numSpotMaps!==E||X.numLightProbes!==C)&&(r.directional.length=x,r.spot.length=v,r.rectArea.length=M,r.point.length=y,r.hemi.length=b,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=A,r.pointShadowMap.length=A,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=A,r.spotLightMatrix.length=T+E-I,r.spotLightMap.length=E,r.numSpotLightShadowsWithMaps=I,r.numLightProbes=C,X.directionalLength=x,X.pointLength=y,X.spotLength=v,X.rectAreaLength=M,X.hemiLength=b,X.numDirectionalShadows=S,X.numPointShadows=A,X.numSpotShadows=T,X.numSpotMaps=E,X.numLightProbes=C,r.version=lE++)}function c(d,p){let f=0,m=0,_=0,x=0,y=0;const v=p.matrixWorldInverse;for(let M=0,b=d.length;M<b;M++){const S=d[M];if(S.isDirectionalLight){const A=r.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),a.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),f++}else if(S.isSpotLight){const A=r.spot[_];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),A.direction.setFromMatrixPosition(S.matrixWorld),a.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(a),A.direction.transformDirection(v),_++}else if(S.isRectAreaLight){const A=r.rectArea[x];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),l.identity(),s.copy(S.matrixWorld),s.premultiply(v),l.extractRotation(s),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(l),A.halfHeight.applyMatrix4(l),x++}else if(S.isPointLight){const A=r.point[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(v),m++}else if(S.isHemisphereLight){const A=r.hemi[y];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(v),y++}}}return{setup:h,setupView:c,state:r}}function o_(n,e){const t=new cE(n,e),i=[],r=[];function a(){i.length=0,r.length=0}function s(d){i.push(d)}function l(d){r.push(d)}function h(d){t.setup(i,d)}function c(d){t.setupView(i,d)}return{init:a,state:{lightsArray:i,shadowsArray:r,lights:t},setupLights:h,setupLightsView:c,pushLight:s,pushShadow:l}}function uE(n,e){let t=new WeakMap;function i(a,s=0){const l=t.get(a);let h;return l===void 0?(h=new o_(n,e),t.set(a,[h])):s>=l.length?(h=new o_(n,e),l.push(h)):h=l[s],h}function r(){t=new WeakMap}return{get:i,dispose:r}}class l_ extends qr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=J1,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 dE extends qr{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 pE=`void main() { gl_Position = vec4( position, 1.0 ); }`,fE=`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 mE(n,e,t){let i=new md;const r=new pe,a=new pe,s=new Zt,l=new l_({depthPacking:ig}),h=new dE,c={},d=t.maxTextureSize,p={[jn]:dr,[dr]:jn,[xi]:xi},f=new mr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new pe},radius:{value:4}},vertexShader:pE,fragmentShader:fE}),m=f.clone();m.defines.HORIZONTAL_PASS=1;const _=new si;_.setAttribute("position",new mi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new rt(_,f),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=cm;let v=this.type;this.render=function(T,E,I){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||T.length===0)return;const C=n.getRenderTarget(),P=n.getActiveCubeFace(),X=n.getActiveMipmapLevel(),q=n.state;q.setBlending(pn),q.buffers.color.setClear(1,1,1,1),q.buffers.depth.setTest(!0),q.setScissorTest(!1);const te=v!==En&&this.type===En,k=v===En&&this.type!==En;for(let H=0,V=T.length;H<V;H++){const J=T[H],ie=J.shadow;if(ie===void 0){console.warn("THREE.WebGLShadowMap:",J,"has no shadow.");continue}if(ie.autoUpdate===!1&&ie.needsUpdate===!1)continue;r.copy(ie.mapSize);const $=ie.getFrameExtents();if(r.multiply($),a.copy(ie.mapSize),(r.x>d||r.y>d)&&(r.x>d&&(a.x=Math.floor(d/$.x),r.x=a.x*$.x,ie.mapSize.x=a.x),r.y>d&&(a.y=Math.floor(d/$.y),r.y=a.y*$.y,ie.mapSize.y=a.y)),ie.map===null||te===!0||k===!0){const he=this.type!==En?{minFilter:zi,magFilter:zi}:{};ie.map!==null&&ie.map.dispose(),ie.map=new Yi(r.x,r.y,he),ie.map.texture.name=J.name+".shadowMap",ie.camera.updateProjectionMatrix()}n.setRenderTarget(ie.map),n.clear();const ne=ie.getViewportCount();for(let he=0;he<ne;he++){const De=ie.getViewport(he);s.set(a.x*De.x,a.y*De.y,a.x*De.z,a.y*De.w),q.viewport(s),ie.updateMatrices(J,he),i=ie.getFrustum(),S(E,I,ie.camera,J,this.type)}ie.isPointLightShadow!==!0&&this.type===En&&M(ie,I),ie.needsUpdate=!1}v=this.type,y.needsUpdate=!1,n.setRenderTarget(C,P,X)};function M(T,E){const I=e.update(x);f.defines.VSM_SAMPLES!==T.blurSamples&&(f.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,f.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new Yi(r.x,r.y)),f.uniforms.shadow_pass.value=T.map.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,n.setRenderTarget(T.mapPass),n.clear(),n.renderBufferDirect(E,null,I,f,x,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,n.setRenderTarget(T.map),n.clear(),n.renderBufferDirect(E,null,I,m,x,null)}function b(T,E,I,C){let P=null;const X=I.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(X!==void 0)P=X;else if(P=I.isPointLight===!0?h:l,n.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0){const q=P.uuid,te=E.uuid;let k=c[q];k===void 0&&(k={},c[q]=k);let H=k[te];H===void 0&&(H=P.clone(),k[te]=H,E.addEventListener("dispose",A)),P=H}if(P.visible=E.visible,P.wireframe=E.wireframe,C===En?P.side=E.shadowSide!==null?E.shadowSide:E.side:P.side=E.shadowSide!==null?E.shadowSide:p[E.side],P.alphaMap=E.alphaMap,P.alphaTest=E.alphaTest,P.map=E.map,P.clipShadows=E.clipShadows,P.clippingPlanes=E.clippingPlanes,P.clipIntersection=E.clipIntersection,P.displacementMap=E.displacementMap,P.displacementScale=E.displacementScale,P.displacementBias=E.displacementBias,P.wireframeLinewidth=E.wireframeLinewidth,P.linewidth=E.linewidth,I.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const q=n.properties.get(P);q.light=I}return P}function S(T,E,I,C,P){if(T.visible===!1)return;if(T.layers.test(E.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&P===En)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,T.matrixWorld);const q=e.update(T),te=T.material;if(Array.isArray(te)){const k=q.groups;for(let H=0,V=k.length;H<V;H++){const J=k[H],ie=te[J.materialIndex];if(ie&&ie.visible){const $=b(T,ie,C,P);T.onBeforeShadow(n,T,E,I,q,$,J),n.renderBufferDirect(I,null,q,$,T,J),T.onAfterShadow(n,T,E,I,q,$,J)}}}else if(te.visible){const k=b(T,te,C,P);T.onBeforeShadow(n,T,E,I,q,k,null),n.renderBufferDirect(I,null,q,k,T,null),T.onAfterShadow(n,T,E,I,q,k,null)}}const X=T.children;for(let q=0,te=X.length;q<te;q++)S(X[q],E,I,C,P)}function A(T){T.target.removeEventListener("dispose",A);for(const E in c){const I=c[E],C=T.target.uuid;C in I&&(I[C].dispose(),delete I[C])}}}function gE(n,e,t){const i=t.isWebGL2;function r(){let W=!1;const we=new Zt;let Pe=null;const et=new Zt(0,0,0,0);return{setMask:function(ye){Pe!==ye&&!W&&(n.colorMask(ye,ye,ye,ye),Pe=ye)},setLocked:function(ye){W=ye},setClear:function(ye,it,Ut,oi,er){er===!0&&(ye*=oi,it*=oi,Ut*=oi),we.set(ye,it,Ut,oi),et.equals(we)===!1&&(n.clearColor(ye,it,Ut,oi),et.copy(we))},reset:function(){W=!1,Pe=null,et.set(-1,0,0,0)}}}function a(){let W=!1,we=null,Pe=null,et=null;return{setTest:function(ye){ye?qe(n.DEPTH_TEST):Xe(n.DEPTH_TEST)},setMask:function(ye){we!==ye&&!W&&(n.depthMask(ye),we=ye)},setFunc:function(ye){if(Pe!==ye){switch(ye){case E1:n.depthFunc(n.NEVER);break;case A1:n.depthFunc(n.ALWAYS);break;case R1:n.depthFunc(n.LESS);break;case mh:n.depthFunc(n.LEQUAL);break;case C1:n.depthFunc(n.EQUAL);break;case L1:n.depthFunc(n.GEQUAL);break;case P1:n.depthFunc(n.GREATER);break;case D1:n.depthFunc(n.NOTEQUAL);break;default:n.depthFunc(n.LEQUAL)}Pe=ye}},setLocked:function(ye){W=ye},setClear:function(ye){et!==ye&&(n.clearDepth(ye),et=ye)},reset:function(){W=!1,we=null,Pe=null,et=null}}}function s(){let W=!1,we=null,Pe=null,et=null,ye=null,it=null,Ut=null,oi=null,er=null;return{setTest:function(jt){W||(jt?qe(n.STENCIL_TEST):Xe(n.STENCIL_TEST))},setMask:function(jt){we!==jt&&!W&&(n.stencilMask(jt),we=jt)},setFunc:function(jt,Di,rn){(Pe!==jt||et!==Di||ye!==rn)&&(n.stencilFunc(jt,Di,rn),Pe=jt,et=Di,ye=rn)},setOp:function(jt,Di,rn){(it!==jt||Ut!==Di||oi!==rn)&&(n.stencilOp(jt,Di,rn),it=jt,Ut=Di,oi=rn)},setLocked:function(jt){W=jt},setClear:function(jt){er!==jt&&(n.clearStencil(jt),er=jt)},reset:function(){W=!1,we=null,Pe=null,et=null,ye=null,it=null,Ut=null,oi=null,er=null}}}const l=new r,h=new a,c=new s,d=new WeakMap,p=new WeakMap;let f={},m={},_=new WeakMap,x=[],y=null,v=!1,M=null,b=null,S=null,A=null,T=null,E=null,I=null,C=new Ke(0,0,0),P=0,X=!1,q=null,te=null,k=null,H=null,V=null;const J=n.getParameter(n.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ie=!1,$=0;const ne=n.getParameter(n.VERSION);ne.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(ne)[1]),ie=$>=1):ne.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(ne)[1]),ie=$>=2);let he=null,De={};const ee=n.getParameter(n.SCISSOR_BOX),ce=n.getParameter(n.VIEWPORT),Te=new Zt().fromArray(ee),Be=new Zt().fromArray(ce);function je(W,we,Pe,et){const ye=new Uint8Array(4),it=n.createTexture();n.bindTexture(W,it),n.texParameteri(W,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(W,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Ut=0;Ut<Pe;Ut++)i&&(W===n.TEXTURE_3D||W===n.TEXTURE_2D_ARRAY)?n.texImage3D(we,0,n.RGBA,1,1,et,0,n.RGBA,n.UNSIGNED_BYTE,ye):n.texImage2D(we+Ut,0,n.RGBA,1,1,0,n.RGBA,n.UNSIGNED_BYTE,ye);return it}const $e={};$e[n.TEXTURE_2D]=je(n.TEXTURE_2D,n.TEXTURE_2D,1),$e[n.TEXTURE_CUBE_MAP]=je(n.TEXTURE_CUBE_MAP,n.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&($e[n.TEXTURE_2D_ARRAY]=je(n.TEXTURE_2D_ARRAY,n.TEXTURE_2D_ARRAY,1,1),$e[n.TEXTURE_3D]=je(n.TEXTURE_3D,n.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),h.setClear(1),c.setClear(0),qe(n.DEPTH_TEST),h.setFunc(mh),ke(!1),N(hm),qe(n.CULL_FACE),Ee(pn);function qe(W){f[W]!==!0&&(n.enable(W),f[W]=!0)}function Xe(W){f[W]!==!1&&(n.disable(W),f[W]=!1)}function ge(W,we){return m[W]!==we?(n.bindFramebuffer(W,we),m[W]=we,i&&(W===n.DRAW_FRAMEBUFFER&&(m[n.FRAMEBUFFER]=we),W===n.FRAMEBUFFER&&(m[n.DRAW_FRAMEBUFFER]=we)),!0):!1}function G(W,we){let Pe=x,et=!1;if(W)if(Pe=_.get(we),Pe===void 0&&(Pe=[],_.set(we,Pe)),W.isWebGLMultipleRenderTargets){const ye=W.texture;if(Pe.length!==ye.length||Pe[0]!==n.COLOR_ATTACHMENT0){for(let it=0,Ut=ye.length;it<Ut;it++)Pe[it]=n.COLOR_ATTACHMENT0+it;Pe.length=ye.length,et=!0}}else Pe[0]!==n.COLOR_ATTACHMENT0&&(Pe[0]=n.COLOR_ATTACHMENT0,et=!0);else Pe[0]!==n.BACK&&(Pe[0]=n.BACK,et=!0);et&&(t.isWebGL2?n.drawBuffers(Pe):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Pe))}function Ae(W){return y!==W?(n.useProgram(W),y=W,!0):!1}const ue={[Ka]:n.FUNC_ADD,[u1]:n.FUNC_SUBTRACT,[d1]:n.FUNC_REVERSE_SUBTRACT};if(i)ue[pm]=n.MIN,ue[fm]=n.MAX;else{const W=e.get("EXT_blend_minmax");W!==null&&(ue[pm]=W.MIN_EXT,ue[fm]=W.MAX_EXT)}const de={[p1]:n.ZERO,[f1]:n.ONE,[m1]:n.SRC_COLOR,[Du]:n.SRC_ALPHA,[b1]:n.SRC_ALPHA_SATURATE,[y1]:n.DST_COLOR,[_1]:n.DST_ALPHA,[g1]:n.ONE_MINUS_SRC_COLOR,[Iu]:n.ONE_MINUS_SRC_ALPHA,[x1]:n.ONE_MINUS_DST_COLOR,[v1]:n.ONE_MINUS_DST_ALPHA,[w1]:n.CONSTANT_COLOR,[M1]:n.ONE_MINUS_CONSTANT_COLOR,[T1]:n.CONSTANT_ALPHA,[S1]:n.ONE_MINUS_CONSTANT_ALPHA};function Ee(W,we,Pe,et,ye,it,Ut,oi,er,jt){if(W===pn){v===!0&&(Xe(n.BLEND),v=!1);return}if(v===!1&&(qe(n.BLEND),v=!0),W!==c1){if(W!==M||jt!==X){if((b!==Ka||T!==Ka)&&(n.blendEquation(n.FUNC_ADD),b=Ka,T=Ka),jt)switch(W){case zs:n.blendFuncSeparate(n.ONE,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Pu:n.blendFunc(n.ONE,n.ONE);break;case um:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case dm:n.blendFuncSeparate(n.ZERO,n.SRC_COLOR,n.ZERO,n.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}else switch(W){case zs:n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA);break;case Pu:n.blendFunc(n.SRC_ALPHA,n.ONE);break;case um:n.blendFuncSeparate(n.ZERO,n.ONE_MINUS_SRC_COLOR,n.ZERO,n.ONE);break;case dm:n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",W);break}S=null,A=null,E=null,I=null,C.set(0,0,0),P=0,M=W,X=jt}return}ye=ye||we,it=it||Pe,Ut=Ut||et,(we!==b||ye!==T)&&(n.blendEquationSeparate(ue[we],ue[ye]),b=we,T=ye),(Pe!==S||et!==A||it!==E||Ut!==I)&&(n.blendFuncSeparate(de[Pe],de[et],de[it],de[Ut]),S=Pe,A=et,E=it,I=Ut),(oi.equals(C)===!1||er!==P)&&(n.blendColor(oi.r,oi.g,oi.b,er),C.copy(oi),P=er),M=W,X=!1}function Fe(W,we){W.side===xi?Xe(n.CULL_FACE):qe(n.CULL_FACE);let Pe=W.side===dr;we&&(Pe=!Pe),ke(Pe),W.blending===zs&&W.transparent===!1?Ee(pn):Ee(W.blending,W.blendEquation,W.blendSrc,W.blendDst,W.blendEquationAlpha,W.blendSrcAlpha,W.blendDstAlpha,W.blendColor,W.blendAlpha,W.premultipliedAlpha),h.setFunc(W.depthFunc),h.setTest(W.depthTest),h.setMask(W.depthWrite),l.setMask(W.colorWrite);const et=W.stencilWrite;c.setTest(et),et&&(c.setMask(W.stencilWriteMask),c.setFunc(W.stencilFunc,W.stencilRef,W.stencilFuncMask),c.setOp(W.stencilFail,W.stencilZFail,W.stencilZPass)),Z(W.polygonOffset,W.polygonOffsetFactor,W.polygonOffsetUnits),W.alphaToCoverage===!0?qe(n.SAMPLE_ALPHA_TO_COVERAGE):Xe(n.SAMPLE_ALPHA_TO_COVERAGE)}function ke(W){q!==W&&(W?n.frontFace(n.CW):n.frontFace(n.CCW),q=W)}function N(W){W!==o1?(qe(n.CULL_FACE),W!==te&&(W===hm?n.cullFace(n.BACK):W===l1?n.cullFace(n.FRONT):n.cullFace(n.FRONT_AND_BACK))):Xe(n.CULL_FACE),te=W}function L(W){W!==k&&(ie&&n.lineWidth(W),k=W)}function Z(W,we,Pe){W?(qe(n.POLYGON_OFFSET_FILL),(H!==we||V!==Pe)&&(n.polygonOffset(we,Pe),H=we,V=Pe)):Xe(n.POLYGON_OFFSET_FILL)}function xe(W){W?qe(n.SCISSOR_TEST):Xe(n.SCISSOR_TEST)}function fe(W){W===void 0&&(W=n.TEXTURE0+J-1),he!==W&&(n.activeTexture(W),he=W)}function Se(W,we,Pe){Pe===void 0&&(he===null?Pe=n.TEXTURE0+J-1:Pe=he);let et=De[Pe];et===void 0&&(et={type:void 0,texture:void 0},De[Pe]=et),(et.type!==W||et.texture!==we)&&(he!==Pe&&(n.activeTexture(Pe),he=Pe),n.bindTexture(W,we||$e[W]),et.type=W,et.texture=we)}function He(){const W=De[he];W!==void 0&&W.type!==void 0&&(n.bindTexture(W.type,null),W.type=void 0,W.texture=void 0)}function Ie(){try{n.compressedTexImage2D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ue(){try{n.compressedTexImage3D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ge(){try{n.texSubImage2D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Je(){try{n.texSubImage3D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function be(){try{n.compressedTexSubImage2D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function dt(){try{n.compressedTexSubImage3D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function B(){try{n.texStorage2D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function _e(){try{n.texStorage3D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ce(){try{n.texImage2D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Re(){try{n.texImage3D.apply(n,arguments)}catch(W){console.error("THREE.WebGLState:",W)}}function Ve(W){Te.equals(W)===!1&&(n.scissor(W.x,W.y,W.z,W.w),Te.copy(W))}function tt(W){Be.equals(W)===!1&&(n.viewport(W.x,W.y,W.z,W.w),Be.copy(W))}function Tt(W,we){let Pe=p.get(we);Pe===void 0&&(Pe=new WeakMap,p.set(we,Pe));let et=Pe.get(W);et===void 0&&(et=n.getUniformBlockIndex(we,W.name),Pe.set(W,et))}function ut(W,we){const Pe=p.get(we).get(W);d.get(we)!==Pe&&(n.uniformBlockBinding(we,Pe,W.__bindingPointIndex),d.set(we,Pe))}function Le(){n.disable(n.BLEND),n.disable(n.CULL_FACE),n.disable(n.DEPTH_TEST),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SCISSOR_TEST),n.disable(n.STENCIL_TEST),n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),n.blendEquation(n.FUNC_ADD),n.blendFunc(n.ONE,n.ZERO),n.blendFuncSeparate(n.ONE,n.ZERO,n.ONE,n.ZERO),n.blendColor(0,0,0,0),n.colorMask(!0,!0,!0,!0),n.clearColor(0,0,0,0),n.depthMask(!0),n.depthFunc(n.LESS),n.clearDepth(1),n.stencilMask(4294967295),n.stencilFunc(n.ALWAYS,0,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.KEEP),n.clearStencil(0),n.cullFace(n.BACK),n.frontFace(n.CCW),n.polygonOffset(0,0),n.activeTexture(n.TEXTURE0),n.bindFramebuffer(n.FRAMEBUFFER,null),i===!0&&(n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.bindFramebuffer(n.READ_FRAMEBUFFER,null)),n.useProgram(null),n.lineWidth(1),n.scissor(0,0,n.canvas.width,n.canvas.height),n.viewport(0,0,n.canvas.width,n.canvas.height),f={},he=null,De={},m={},_=new WeakMap,x=[],y=null,v=!1,M=null,b=null,S=null,A=null,T=null,E=null,I=null,C=new Ke(0,0,0),P=0,X=!1,q=null,te=null,k=null,H=null,V=null,Te.set(0,0,n.canvas.width,n.canvas.height),Be.set(0,0,n.canvas.width,n.canvas.height),l.reset(),h.reset(),c.reset()}return{buffers:{color:l,depth:h,stencil:c},enable:qe,disable:Xe,bindFramebuffer:ge,drawBuffers:G,useProgram:Ae,setBlending:Ee,setMaterial:Fe,setFlipSided:ke,setCullFace:N,setLineWidth:L,setPolygonOffset:Z,setScissorTest:xe,activeTexture:fe,bindTexture:Se,unbindTexture:He,compressedTexImage2D:Ie,compressedTexImage3D:Ue,texImage2D:Ce,texImage3D:Re,updateUBOMapping:Tt,uniformBlockBinding:ut,texStorage2D:B,texStorage3D:_e,texSubImage2D:Ge,texSubImage3D:Je,compressedTexSubImage2D:be,compressedTexSubImage3D:dt,scissor:Ve,viewport:tt,reset:Le}}function _E(n,e,t,i,r,a,s){const l=r.isWebGL2,h=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),d=new WeakMap;let p;const f=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(N,L){return m?new OffscreenCanvas(N,L):pl("canvas")}function x(N,L,Z,xe){let fe=1;if((N.width>xe||N.height>xe)&&(fe=xe/Math.max(N.width,N.height)),fe<1||L===!0)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap){const Se=L?Eh:Math.floor,He=Se(fe*N.width),Ie=Se(fe*N.height);p===void 0&&(p=_(He,Ie));const Ue=Z?_(He,Ie):p;return Ue.width=He,Ue.height=Ie,Ue.getContext("2d").drawImage(N,0,0,He,Ie),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+He+"x"+Ie+")."),Ue}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),N;return N}function y(N){return Ku(N.width)&&Ku(N.height)}function v(N){return l?!1:N.wrapS!==Wr||N.wrapT!==Wr||N.minFilter!==zi&&N.minFilter!==fr}function M(N,L){return N.generateMipmaps&&L&&N.minFilter!==zi&&N.minFilter!==fr}function b(N){n.generateMipmap(N)}function S(N,L,Z,xe,fe=!1){if(l===!1)return L;if(N!==null){if(n[N]!==void 0)return n[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let Se=L;if(L===n.RED&&(Z===n.FLOAT&&(Se=n.R32F),Z===n.HALF_FLOAT&&(Se=n.R16F),Z===n.UNSIGNED_BYTE&&(Se=n.R8)),L===n.RED_INTEGER&&(Z===n.UNSIGNED_BYTE&&(Se=n.R8UI),Z===n.UNSIGNED_SHORT&&(Se=n.R16UI),Z===n.UNSIGNED_INT&&(Se=n.R32UI),Z===n.BYTE&&(Se=n.R8I),Z===n.SHORT&&(Se=n.R16I),Z===n.INT&&(Se=n.R32I)),L===n.RG&&(Z===n.FLOAT&&(Se=n.RG32F),Z===n.HALF_FLOAT&&(Se=n.RG16F),Z===n.UNSIGNED_BYTE&&(Se=n.RG8)),L===n.RGBA){const He=fe?wh:Gt.getTransfer(xe);Z===n.FLOAT&&(Se=n.RGBA32F),Z===n.HALF_FLOAT&&(Se=n.RGBA16F),Z===n.UNSIGNED_BYTE&&(Se=He===ii?n.SRGB8_ALPHA8:n.RGBA8),Z===n.UNSIGNED_SHORT_4_4_4_4&&(Se=n.RGBA4),Z===n.UNSIGNED_SHORT_5_5_5_1&&(Se=n.RGB5_A1)}return(Se===n.R16F||Se===n.R32F||Se===n.RG16F||Se===n.RG32F||Se===n.RGBA16F||Se===n.RGBA32F)&&e.get("EXT_color_buffer_float"),Se}function A(N,L,Z){return M(N,Z)===!0||N.isFramebufferTexture&&N.minFilter!==zi&&N.minFilter!==fr?Math.log2(Math.max(L.width,L.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?L.mipmaps.length:1}function T(N){return N===zi||N===Uu||N===yh?n.NEAREST:n.LINEAR}function E(N){const L=N.target;L.removeEventListener("dispose",E),C(L),L.isVideoTexture&&d.delete(L)}function I(N){const L=N.target;L.removeEventListener("dispose",I),X(L)}function C(N){const L=i.get(N);if(L.__webglInit===void 0)return;const Z=N.source,xe=f.get(Z);if(xe){const fe=xe[L.__cacheKey];fe.usedTimes--,fe.usedTimes===0&&P(N),Object.keys(xe).length===0&&f.delete(Z)}i.remove(N)}function P(N){const L=i.get(N);n.deleteTexture(L.__webglTexture);const Z=N.source,xe=f.get(Z);delete xe[L.__cacheKey],s.memory.textures--}function X(N){const L=N.texture,Z=i.get(N),xe=i.get(L);if(xe.__webglTexture!==void 0&&(n.deleteTexture(xe.__webglTexture),s.memory.textures--),N.depthTexture&&N.depthTexture.dispose(),N.isWebGLCubeRenderTarget)for(let fe=0;fe<6;fe++){if(Array.isArray(Z.__webglFramebuffer[fe]))for(let Se=0;Se<Z.__webglFramebuffer[fe].length;Se++)n.deleteFramebuffer(Z.__webglFramebuffer[fe][Se]);else n.deleteFramebuffer(Z.__webglFramebuffer[fe]);Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer[fe])}else{if(Array.isArray(Z.__webglFramebuffer))for(let fe=0;fe<Z.__webglFramebuffer.length;fe++)n.deleteFramebuffer(Z.__webglFramebuffer[fe]);else n.deleteFramebuffer(Z.__webglFramebuffer);if(Z.__webglDepthbuffer&&n.deleteRenderbuffer(Z.__webglDepthbuffer),Z.__webglMultisampledFramebuffer&&n.deleteFramebuffer(Z.__webglMultisampledFramebuffer),Z.__webglColorRenderbuffer)for(let fe=0;fe<Z.__webglColorRenderbuffer.length;fe++)Z.__webglColorRenderbuffer[fe]&&n.deleteRenderbuffer(Z.__webglColorRenderbuffer[fe]);Z.__webglDepthRenderbuffer&&n.deleteRenderbuffer(Z.__webglDepthRenderbuffer)}if(N.isWebGLMultipleRenderTargets)for(let fe=0,Se=L.length;fe<Se;fe++){const He=i.get(L[fe]);He.__webglTexture&&(n.deleteTexture(He.__webglTexture),s.memory.textures--),i.remove(L[fe])}i.remove(L),i.remove(N)}let q=0;function te(){q=0}function k(){const N=q;return N>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+r.maxTextures),q+=1,N}function H(N){const L=[];return L.push(N.wrapS),L.push(N.wrapT),L.push(N.wrapR||0),L.push(N.magFilter),L.push(N.minFilter),L.push(N.anisotropy),L.push(N.internalFormat),L.push(N.format),L.push(N.type),L.push(N.generateMipmaps),L.push(N.premultiplyAlpha),L.push(N.flipY),L.push(N.unpackAlignment),L.push(N.colorSpace),L.join()}function V(N,L){const Z=i.get(N);if(N.isVideoTexture&&Fe(N),N.isRenderTargetTexture===!1&&N.version>0&&Z.__version!==N.version){const xe=N.image;if(xe===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(xe.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Te(Z,N,L);return}}t.bindTexture(n.TEXTURE_2D,Z.__webglTexture,n.TEXTURE0+L)}function J(N,L){const Z=i.get(N);if(N.version>0&&Z.__version!==N.version){Te(Z,N,L);return}t.bindTexture(n.TEXTURE_2D_ARRAY,Z.__webglTexture,n.TEXTURE0+L)}function ie(N,L){const Z=i.get(N);if(N.version>0&&Z.__version!==N.version){Te(Z,N,L);return}t.bindTexture(n.TEXTURE_3D,Z.__webglTexture,n.TEXTURE0+L)}function $(N,L){const Z=i.get(N);if(N.version>0&&Z.__version!==N.version){Be(Z,N,L);return}t.bindTexture(n.TEXTURE_CUBE_MAP,Z.__webglTexture,n.TEXTURE0+L)}const ne={[pr]:n.REPEAT,[Wr]:n.CLAMP_TO_EDGE,[vh]:n.MIRRORED_REPEAT},he={[zi]:n.NEAREST,[Uu]:n.NEAREST_MIPMAP_NEAREST,[yh]:n.NEAREST_MIPMAP_LINEAR,[fr]:n.LINEAR,[vm]:n.LINEAR_MIPMAP_NEAREST,[Za]:n.LINEAR_MIPMAP_LINEAR},De={[Q1]:n.NEVER,[ab]:n.ALWAYS,[eb]:n.LESS,[ng]:n.LEQUAL,[tb]:n.EQUAL,[nb]:n.GEQUAL,[ib]:n.GREATER,[rb]:n.NOTEQUAL};function ee(N,L,Z){if(Z?(n.texParameteri(N,n.TEXTURE_WRAP_S,ne[L.wrapS]),n.texParameteri(N,n.TEXTURE_WRAP_T,ne[L.wrapT]),(N===n.TEXTURE_3D||N===n.TEXTURE_2D_ARRAY)&&n.texParameteri(N,n.TEXTURE_WRAP_R,ne[L.wrapR]),n.texParameteri(N,n.TEXTURE_MAG_FILTER,he[L.magFilter]),n.texParameteri(N,n.TEXTURE_MIN_FILTER,he[L.minFilter])):(n.texParameteri(N,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(N,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(N===n.TEXTURE_3D||N===n.TEXTURE_2D_ARRAY)&&n.texParameteri(N,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),(L.wrapS!==Wr||L.wrapT!==Wr)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(N,n.TEXTURE_MAG_FILTER,T(L.magFilter)),n.texParameteri(N,n.TEXTURE_MIN_FILTER,T(L.minFilter)),L.minFilter!==zi&&L.minFilter!==fr&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),L.compareFunction&&(n.texParameteri(N,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(N,n.TEXTURE_COMPARE_FUNC,De[L.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const xe=e.get("EXT_texture_filter_anisotropic");if(L.magFilter===zi||L.minFilter!==yh&&L.minFilter!==Za||L.type===Xn&&e.has("OES_texture_float_linear")===!1||l===!1&&L.type===Rr&&e.has("OES_texture_half_float_linear")===!1)return;(L.anisotropy>1||i.get(L).__currentAnisotropy)&&(n.texParameterf(N,xe.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(L.anisotropy,r.getMaxAnisotropy())),i.get(L).__currentAnisotropy=L.anisotropy)}}function ce(N,L){let Z=!1;N.__webglInit===void 0&&(N.__webglInit=!0,L.addEventListener("dispose",E));const xe=L.source;let fe=f.get(xe);fe===void 0&&(fe={},f.set(xe,fe));const Se=H(L);if(Se!==N.__cacheKey){fe[Se]===void 0&&(fe[Se]={texture:n.createTexture(),usedTimes:0},s.memory.textures++,Z=!0),fe[Se].usedTimes++;const He=fe[N.__cacheKey];He!==void 0&&(fe[N.__cacheKey].usedTimes--,He.usedTimes===0&&P(L)),N.__cacheKey=Se,N.__webglTexture=fe[Se].texture}return Z}function Te(N,L,Z){let xe=n.TEXTURE_2D;(L.isDataArrayTexture||L.isCompressedArrayTexture)&&(xe=n.TEXTURE_2D_ARRAY),L.isData3DTexture&&(xe=n.TEXTURE_3D);const fe=ce(N,L),Se=L.source;t.bindTexture(xe,N.__webglTexture,n.TEXTURE0+Z);const He=i.get(Se);if(Se.version!==He.__version||fe===!0){t.activeTexture(n.TEXTURE0+Z);const Ie=Gt.getPrimaries(Gt.workingColorSpace),Ue=L.colorSpace===jr?null:Gt.getPrimaries(L.colorSpace),Ge=L.colorSpace===jr||Ie===Ue?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,L.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,L.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);const Je=v(L)&&y(L.image)===!1;let be=x(L.image,Je,!1,r.maxTextureSize);be=ke(L,be);const dt=y(be)||l,B=a.convert(L.format,L.colorSpace);let _e=a.convert(L.type),Ce=S(L.internalFormat,B,_e,L.colorSpace,L.isVideoTexture);ee(xe,L,dt);let Re;const Ve=L.mipmaps,tt=l&&L.isVideoTexture!==!0&&Ce!==Cm,Tt=He.__version===void 0||fe===!0,ut=A(L,be,dt);if(L.isDepthTexture)Ce=n.DEPTH_COMPONENT,l?L.type===Xn?Ce=n.DEPTH_COMPONENT32F:L.type===ya?Ce=n.DEPTH_COMPONENT24:L.type===Ja?Ce=n.DEPTH24_STENCIL8:Ce=n.DEPTH_COMPONENT16:L.type===Xn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),L.format===$a&&Ce===n.DEPTH_COMPONENT&&L.type!==zu&&L.type!==ya&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),L.type=ya,_e=a.convert(L.type)),L.format===ks&&Ce===n.DEPTH_COMPONENT&&(Ce=n.DEPTH_STENCIL,L.type!==Ja&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),L.type=Ja,_e=a.convert(L.type))),Tt&&(tt?t.texStorage2D(n.TEXTURE_2D,1,Ce,be.width,be.height):t.texImage2D(n.TEXTURE_2D,0,Ce,be.width,be.height,0,B,_e,null));else if(L.isDataTexture)if(Ve.length>0&&dt){tt&&Tt&&t.texStorage2D(n.TEXTURE_2D,ut,Ce,Ve[0].width,Ve[0].height);for(let Le=0,W=Ve.length;Le<W;Le++)Re=Ve[Le],tt?t.texSubImage2D(n.TEXTURE_2D,Le,0,0,Re.width,Re.height,B,_e,Re.data):t.texImage2D(n.TEXTURE_2D,Le,Ce,Re.width,Re.height,0,B,_e,Re.data);L.generateMipmaps=!1}else tt?(Tt&&t.texStorage2D(n.TEXTURE_2D,ut,Ce,be.width,be.height),t.texSubImage2D(n.TEXTURE_2D,0,0,0,be.width,be.height,B,_e,be.data)):t.texImage2D(n.TEXTURE_2D,0,Ce,be.width,be.height,0,B,_e,be.data);else if(L.isCompressedTexture)if(L.isCompressedArrayTexture){tt&&Tt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ut,Ce,Ve[0].width,Ve[0].height,be.depth);for(let Le=0,W=Ve.length;Le<W;Le++)Re=Ve[Le],L.format!==Cr?B!==null?tt?t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,Le,0,0,0,Re.width,Re.height,be.depth,B,Re.data,0,0):t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,Le,Ce,Re.width,Re.height,be.depth,0,Re.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):tt?t.texSubImage3D(n.TEXTURE_2D_ARRAY,Le,0,0,0,Re.width,Re.height,be.depth,B,_e,Re.data):t.texImage3D(n.TEXTURE_2D_ARRAY,Le,Ce,Re.width,Re.height,be.depth,0,B,_e,Re.data)}else{tt&&Tt&&t.texStorage2D(n.TEXTURE_2D,ut,Ce,Ve[0].width,Ve[0].height);for(let Le=0,W=Ve.length;Le<W;Le++)Re=Ve[Le],L.format!==Cr?B!==null?tt?t.compressedTexSubImage2D(n.TEXTURE_2D,Le,0,0,Re.width,Re.height,B,Re.data):t.compressedTexImage2D(n.TEXTURE_2D,Le,Ce,Re.width,Re.height,0,Re.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):tt?t.texSubImage2D(n.TEXTURE_2D,Le,0,0,Re.width,Re.height,B,_e,Re.data):t.texImage2D(n.TEXTURE_2D,Le,Ce,Re.width,Re.height,0,B,_e,Re.data)}else if(L.isDataArrayTexture)tt?(Tt&&t.texStorage3D(n.TEXTURE_2D_ARRAY,ut,Ce,be.width,be.height,be.depth),t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,be.width,be.height,be.depth,B,_e,be.data)):t.texImage3D(n.TEXTURE_2D_ARRAY,0,Ce,be.width,be.height,be.depth,0,B,_e,be.data);else if(L.isData3DTexture)tt?(Tt&&t.texStorage3D(n.TEXTURE_3D,ut,Ce,be.width,be.height,be.depth),t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,be.width,be.height,be.depth,B,_e,be.data)):t.texImage3D(n.TEXTURE_3D,0,Ce,be.width,be.height,be.depth,0,B,_e,be.data);else if(L.isFramebufferTexture){if(Tt)if(tt)t.texStorage2D(n.TEXTURE_2D,ut,Ce,be.width,be.height);else{let Le=be.width,W=be.height;for(let we=0;we<ut;we++)t.texImage2D(n.TEXTURE_2D,we,Ce,Le,W,0,B,_e,null),Le>>=1,W>>=1}}else if(Ve.length>0&&dt){tt&&Tt&&t.texStorage2D(n.TEXTURE_2D,ut,Ce,Ve[0].width,Ve[0].height);for(let Le=0,W=Ve.length;Le<W;Le++)Re=Ve[Le],tt?t.texSubImage2D(n.TEXTURE_2D,Le,0,0,B,_e,Re):t.texImage2D(n.TEXTURE_2D,Le,Ce,B,_e,Re);L.generateMipmaps=!1}else tt?(Tt&&t.texStorage2D(n.TEXTURE_2D,ut,Ce,be.width,be.height),t.texSubImage2D(n.TEXTURE_2D,0,0,0,B,_e,be)):t.texImage2D(n.TEXTURE_2D,0,Ce,B,_e,be);M(L,dt)&&b(xe),He.__version=Se.version,L.onUpdate&&L.onUpdate(L)}N.__version=L.version}function Be(N,L,Z){if(L.image.length!==6)return;const xe=ce(N,L),fe=L.source;t.bindTexture(n.TEXTURE_CUBE_MAP,N.__webglTexture,n.TEXTURE0+Z);const Se=i.get(fe);if(fe.version!==Se.__version||xe===!0){t.activeTexture(n.TEXTURE0+Z);const He=Gt.getPrimaries(Gt.workingColorSpace),Ie=L.colorSpace===jr?null:Gt.getPrimaries(L.colorSpace),Ue=L.colorSpace===jr||He===Ie?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,L.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,L.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const Ge=L.isCompressedTexture||L.image[0].isCompressedTexture,Je=L.image[0]&&L.image[0].isDataTexture,be=[];for(let Le=0;Le<6;Le++)!Ge&&!Je?be[Le]=x(L.image[Le],!1,!0,r.maxCubemapSize):be[Le]=Je?L.image[Le].image:L.image[Le],be[Le]=ke(L,be[Le]);const dt=be[0],B=y(dt)||l,_e=a.convert(L.format,L.colorSpace),Ce=a.convert(L.type),Re=S(L.internalFormat,_e,Ce,L.colorSpace),Ve=l&&L.isVideoTexture!==!0,tt=Se.__version===void 0||xe===!0;let Tt=A(L,dt,B);ee(n.TEXTURE_CUBE_MAP,L,B);let ut;if(Ge){Ve&&tt&&t.texStorage2D(n.TEXTURE_CUBE_MAP,Tt,Re,dt.width,dt.height);for(let Le=0;Le<6;Le++){ut=be[Le].mipmaps;for(let W=0;W<ut.length;W++){const we=ut[W];L.format!==Cr?_e!==null?Ve?t.compressedTexSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W,0,0,we.width,we.height,_e,we.data):t.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W,Re,we.width,we.height,0,we.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ve?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W,0,0,we.width,we.height,_e,Ce,we.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W,Re,we.width,we.height,0,_e,Ce,we.data)}}}else{ut=L.mipmaps,Ve&&tt&&(ut.length>0&&Tt++,t.texStorage2D(n.TEXTURE_CUBE_MAP,Tt,Re,be[0].width,be[0].height));for(let Le=0;Le<6;Le++)if(Je){Ve?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0,0,0,be[Le].width,be[Le].height,_e,Ce,be[Le].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0,Re,be[Le].width,be[Le].height,0,_e,Ce,be[Le].data);for(let W=0;W<ut.length;W++){const we=ut[W].image[Le].image;Ve?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W+1,0,0,we.width,we.height,_e,Ce,we.data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W+1,Re,we.width,we.height,0,_e,Ce,we.data)}}else{Ve?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0,0,0,_e,Ce,be[Le]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0,Re,_e,Ce,be[Le]);for(let W=0;W<ut.length;W++){const we=ut[W];Ve?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W+1,0,0,_e,Ce,we.image[Le]):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Le,W+1,Re,_e,Ce,we.image[Le])}}}M(L,B)&&b(n.TEXTURE_CUBE_MAP),Se.__version=fe.version,L.onUpdate&&L.onUpdate(L)}N.__version=L.version}function je(N,L,Z,xe,fe,Se){const He=a.convert(Z.format,Z.colorSpace),Ie=a.convert(Z.type),Ue=S(Z.internalFormat,He,Ie,Z.colorSpace);if(!i.get(L).__hasExternalTextures){const Ge=Math.max(1,L.width>>Se),Je=Math.max(1,L.height>>Se);fe===n.TEXTURE_3D||fe===n.TEXTURE_2D_ARRAY?t.texImage3D(fe,Se,Ue,Ge,Je,L.depth,0,He,Ie,null):t.texImage2D(fe,Se,Ue,Ge,Je,0,He,Ie,null)}t.bindFramebuffer(n.FRAMEBUFFER,N),Ee(L)?h.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,xe,fe,i.get(Z).__webglTexture,0,de(L)):(fe===n.TEXTURE_2D||fe>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&fe<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,xe,fe,i.get(Z).__webglTexture,Se),t.bindFramebuffer(n.FRAMEBUFFER,null)}function $e(N,L,Z){if(n.bindRenderbuffer(n.RENDERBUFFER,N),L.depthBuffer&&!L.stencilBuffer){let xe=l===!0?n.DEPTH_COMPONENT24:n.DEPTH_COMPONENT16;if(Z||Ee(L)){const fe=L.depthTexture;fe&&fe.isDepthTexture&&(fe.type===Xn?xe=n.DEPTH_COMPONENT32F:fe.type===ya&&(xe=n.DEPTH_COMPONENT24));const Se=de(L);Ee(L)?h.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Se,xe,L.width,L.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,Se,xe,L.width,L.height)}else n.renderbufferStorage(n.RENDERBUFFER,xe,L.width,L.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,N)}else if(L.depthBuffer&&L.stencilBuffer){const xe=de(L);Z&&Ee(L)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,xe,n.DEPTH24_STENCIL8,L.width,L.height):Ee(L)?h.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,xe,n.DEPTH24_STENCIL8,L.width,L.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,L.width,L.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,N)}else{const xe=L.isWebGLMultipleRenderTargets===!0?L.texture:[L.texture];for(let fe=0;fe<xe.length;fe++){const Se=xe[fe],He=a.convert(Se.format,Se.colorSpace),Ie=a.convert(Se.type),Ue=S(Se.internalFormat,He,Ie,Se.colorSpace),Ge=de(L);Z&&Ee(L)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,Ge,Ue,L.width,L.height):Ee(L)?h.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,Ge,Ue,L.width,L.height):n.renderbufferStorage(n.RENDERBUFFER,Ue,L.width,L.height)}}n.bindRenderbuffer(n.RENDERBUFFER,null)}function qe(N,L){if(L&&L.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(n.FRAMEBUFFER,N),!(L.depthTexture&&L.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!i.get(L.depthTexture).__webglTexture||L.depthTexture.image.width!==L.width||L.depthTexture.image.height!==L.height)&&(L.depthTexture.image.width=L.width,L.depthTexture.image.height=L.height,L.depthTexture.needsUpdate=!0),V(L.depthTexture,0);const Z=i.get(L.depthTexture).__webglTexture,xe=de(L);if(L.depthTexture.format===$a)Ee(L)?h.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Z,0,xe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,Z,0);else if(L.depthTexture.format===ks)Ee(L)?h.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Z,0,xe):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function Xe(N){const L=i.get(N),Z=N.isWebGLCubeRenderTarget===!0;if(N.depthTexture&&!L.__autoAllocateDepthBuffer){if(Z)throw new Error("target.depthTexture not supported in Cube render targets");qe(L.__webglFramebuffer,N)}else if(Z){L.__webglDepthbuffer=[];for(let xe=0;xe<6;xe++)t.bindFramebuffer(n.FRAMEBUFFER,L.__webglFramebuffer[xe]),L.__webglDepthbuffer[xe]=n.createRenderbuffer(),$e(L.__webglDepthbuffer[xe],N,!1)}else t.bindFramebuffer(n.FRAMEBUFFER,L.__webglFramebuffer),L.__webglDepthbuffer=n.createRenderbuffer(),$e(L.__webglDepthbuffer,N,!1);t.bindFramebuffer(n.FRAMEBUFFER,null)}function ge(N,L,Z){const xe=i.get(N);L!==void 0&&je(xe.__webglFramebuffer,N,N.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),Z!==void 0&&Xe(N)}function G(N){const L=N.texture,Z=i.get(N),xe=i.get(L);N.addEventListener("dispose",I),N.isWebGLMultipleRenderTargets!==!0&&(xe.__webglTexture===void 0&&(xe.__webglTexture=n.createTexture()),xe.__version=L.version,s.memory.textures++);const fe=N.isWebGLCubeRenderTarget===!0,Se=N.isWebGLMultipleRenderTargets===!0,He=y(N)||l;if(fe){Z.__webglFramebuffer=[];for(let Ie=0;Ie<6;Ie++)if(l&&L.mipmaps&&L.mipmaps.length>0){Z.__webglFramebuffer[Ie]=[];for(let Ue=0;Ue<L.mipmaps.length;Ue++)Z.__webglFramebuffer[Ie][Ue]=n.createFramebuffer()}else Z.__webglFramebuffer[Ie]=n.createFramebuffer()}else{if(l&&L.mipmaps&&L.mipmaps.length>0){Z.__webglFramebuffer=[];for(let Ie=0;Ie<L.mipmaps.length;Ie++)Z.__webglFramebuffer[Ie]=n.createFramebuffer()}else Z.__webglFramebuffer=n.createFramebuffer();if(Se)if(r.drawBuffers){const Ie=N.texture;for(let Ue=0,Ge=Ie.length;Ue<Ge;Ue++){const Je=i.get(Ie[Ue]);Je.__webglTexture===void 0&&(Je.__webglTexture=n.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(l&&N.samples>0&&Ee(N)===!1){const Ie=Se?L:[L];Z.__webglMultisampledFramebuffer=n.createFramebuffer(),Z.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,Z.__webglMultisampledFramebuffer);for(let Ue=0;Ue<Ie.length;Ue++){const Ge=Ie[Ue];Z.__webglColorRenderbuffer[Ue]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,Z.__webglColorRenderbuffer[Ue]);const Je=a.convert(Ge.format,Ge.colorSpace),be=a.convert(Ge.type),dt=S(Ge.internalFormat,Je,be,Ge.colorSpace,N.isXRRenderTarget===!0),B=de(N);n.renderbufferStorageMultisample(n.RENDERBUFFER,B,dt,N.width,N.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ue,n.RENDERBUFFER,Z.__webglColorRenderbuffer[Ue])}n.bindRenderbuffer(n.RENDERBUFFER,null),N.depthBuffer&&(Z.__webglDepthRenderbuffer=n.createRenderbuffer(),$e(Z.__webglDepthRenderbuffer,N,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,xe.__webglTexture),ee(n.TEXTURE_CUBE_MAP,L,He);for(let Ie=0;Ie<6;Ie++)if(l&&L.mipmaps&&L.mipmaps.length>0)for(let Ue=0;Ue<L.mipmaps.length;Ue++)je(Z.__webglFramebuffer[Ie][Ue],N,L,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,Ue);else je(Z.__webglFramebuffer[Ie],N,L,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+Ie,0);M(L,He)&&b(n.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(Se){const Ie=N.texture;for(let Ue=0,Ge=Ie.length;Ue<Ge;Ue++){const Je=Ie[Ue],be=i.get(Je);t.bindTexture(n.TEXTURE_2D,be.__webglTexture),ee(n.TEXTURE_2D,Je,He),je(Z.__webglFramebuffer,N,Je,n.COLOR_ATTACHMENT0+Ue,n.TEXTURE_2D,0),M(Je,He)&&b(n.TEXTURE_2D)}t.unbindTexture()}else{let Ie=n.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(l?Ie=N.isWebGL3DRenderTarget?n.TEXTURE_3D:n.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),t.bindTexture(Ie,xe.__webglTexture),ee(Ie,L,He),l&&L.mipmaps&&L.mipmaps.length>0)for(let Ue=0;Ue<L.mipmaps.length;Ue++)je(Z.__webglFramebuffer[Ue],N,L,n.COLOR_ATTACHMENT0,Ie,Ue);else je(Z.__webglFramebuffer,N,L,n.COLOR_ATTACHMENT0,Ie,0);M(L,He)&&b(Ie),t.unbindTexture()}N.depthBuffer&&Xe(N)}function Ae(N){const L=y(N)||l,Z=N.isWebGLMultipleRenderTargets===!0?N.texture:[N.texture];for(let xe=0,fe=Z.length;xe<fe;xe++){const Se=Z[xe];if(M(Se,L)){const He=N.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,Ie=i.get(Se).__webglTexture;t.bindTexture(He,Ie),b(He),t.unbindTexture()}}}function ue(N){if(l&&N.samples>0&&Ee(N)===!1){const L=N.isWebGLMultipleRenderTargets?N.texture:[N.texture],Z=N.width,xe=N.height;let fe=n.COLOR_BUFFER_BIT;const Se=[],He=N.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ie=i.get(N),Ue=N.isWebGLMultipleRenderTargets===!0;if(Ue)for(let Ge=0;Ge<L.length;Ge++)t.bindFramebuffer(n.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ge,n.RENDERBUFFER,null),t.bindFramebuffer(n.FRAMEBUFFER,Ie.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ge,n.TEXTURE_2D,null,0);t.bindFramebuffer(n.READ_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ie.__webglFramebuffer);for(let Ge=0;Ge<L.length;Ge++){Se.push(n.COLOR_ATTACHMENT0+Ge),N.depthBuffer&&Se.push(He);const Je=Ie.__ignoreDepthValues!==void 0?Ie.__ignoreDepthValues:!1;if(Je===!1&&(N.depthBuffer&&(fe|=n.DEPTH_BUFFER_BIT),N.stencilBuffer&&(fe|=n.STENCIL_BUFFER_BIT)),Ue&&n.framebufferRenderbuffer(n.READ_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,Ie.__webglColorRenderbuffer[Ge]),Je===!0&&(n.invalidateFramebuffer(n.READ_FRAMEBUFFER,[He]),n.invalidateFramebuffer(n.DRAW_FRAMEBUFFER,[He])),Ue){const be=i.get(L[Ge]).__webglTexture;n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,be,0)}n.blitFramebuffer(0,0,Z,xe,0,0,Z,xe,fe,n.NEAREST),c&&n.invalidateFramebuffer(n.READ_FRAMEBUFFER,Se)}if(t.bindFramebuffer(n.READ_FRAMEBUFFER,null),t.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),Ue)for(let Ge=0;Ge<L.length;Ge++){t.bindFramebuffer(n.FRAMEBUFFER,Ie.__webglMultisampledFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ge,n.RENDERBUFFER,Ie.__webglColorRenderbuffer[Ge]);const Je=i.get(L[Ge]).__webglTexture;t.bindFramebuffer(n.FRAMEBUFFER,Ie.__webglFramebuffer),n.framebufferTexture2D(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0+Ge,n.TEXTURE_2D,Je,0)}t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ie.__webglMultisampledFramebuffer)}}function de(N){return Math.min(r.maxSamples,N.samples)}function Ee(N){const L=i.get(N);return l&&N.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&L.__useRenderToTexture!==!1}function Fe(N){const L=s.render.frame;d.get(N)!==L&&(d.set(N,L),N.update())}function ke(N,L){const Z=N.colorSpace,xe=N.format,fe=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||N.format===qu||Z!==Bi&&Z!==jr&&(Gt.getTransfer(Z)===ii?l===!1?e.has("EXT_sRGB")===!0&&xe===Cr?(N.format=qu,N.minFilter=fr,N.generateMipmaps=!1):L=ug.sRGBToLinear(L):(xe!==Cr||fe!==va)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",Z)),L}this.allocateTextureUnit=k,this.resetTextureUnits=te,this.setTexture2D=V,this.setTexture2DArray=J,this.setTexture3D=ie,this.setTextureCube=$,this.rebindTextures=ge,this.setupRenderTarget=G,this.updateRenderTargetMipmap=Ae,this.updateMultisampleRenderTarget=ue,this.setupDepthRenderbuffer=Xe,this.setupFrameBufferTexture=je,this.useMultisampledRTT=Ee}function vE(n,e,t){const i=t.isWebGL2;function r(a,s=jr){let l;const h=Gt.getTransfer(s);if(a===va)return n.UNSIGNED_BYTE;if(a===xm)return n.UNSIGNED_SHORT_4_4_4_4;if(a===bm)return n.UNSIGNED_SHORT_5_5_5_1;if(a===H1)return n.BYTE;if(a===G1)return n.SHORT;if(a===zu)return n.UNSIGNED_SHORT;if(a===ym)return n.INT;if(a===ya)return n.UNSIGNED_INT;if(a===Xn)return n.FLOAT;if(a===Rr)return i?n.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===V1)return n.ALPHA;if(a===Cr)return n.RGBA;if(a===W1)return n.LUMINANCE;if(a===j1)return n.LUMINANCE_ALPHA;if(a===$a)return n.DEPTH_COMPONENT;if(a===ks)return n.DEPTH_STENCIL;if(a===qu)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===X1)return n.RED;if(a===wm)return n.RED_INTEGER;if(a===q1)return n.RG;if(a===Mm)return n.RG_INTEGER;if(a===Tm)return n.RGBA_INTEGER;if(a===Bu||a===Fu||a===ku||a===Hu)if(h===ii)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===Bu)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===Fu)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===ku)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===Hu)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===Bu)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===Fu)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===ku)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===Hu)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===Sm||a===Em||a===Am||a===Rm)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===Sm)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===Em)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===Am)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===Rm)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===Cm)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===Lm||a===Pm)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===Lm)return h===ii?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===Pm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===Dm||a===Im||a===Om||a===Nm||a===Um||a===zm||a===Bm||a===Fm||a===km||a===Hm||a===Gm||a===Vm||a===Wm||a===jm)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===Dm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===Im)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===Om)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===Nm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===Um)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===zm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===Bm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===Fm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===km)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===Hm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===Gm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===Vm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===Wm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===jm)return h===ii?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===Gu||a===Xm||a===qm)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===Gu)return h===ii?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===Xm)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===qm)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===Y1||a===Ym||a===Km||a===Zm)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===Gu)return l.COMPRESSED_RED_RGTC1_EXT;if(a===Ym)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===Km)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===Zm)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===Ja?i?n.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):n[a]!==void 0?n[a]:null}return{convert:r}}class yE extends nr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class yn extends ei{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xE={type:"move"};class Md{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new yn,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 yn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new z),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new yn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new z),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 i of e.hand.values())this._getHandJoint(t,i)}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,i){let r=null,a=null,s=null;const l=this._targetRay,h=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){s=!0;for(const x of e.hand.values()){const y=t.getJointPose(x,i),v=this._getHandJoint(c,x);y!==null&&(v.matrix.fromArray(y.transform.matrix),v.matrix.decompose(v.position,v.rotation,v.scale),v.matrixWorldNeedsUpdate=!0,v.jointRadius=y.radius),v.visible=y!==null}const d=c.joints["index-finger-tip"],p=c.joints["thumb-tip"],f=d.position.distanceTo(p.position),m=.02,_=.005;c.inputState.pinching&&f>m+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=m-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else h!==null&&e.gripSpace&&(a=t.getPose(e.gripSpace,i),a!==null&&(h.matrix.fromArray(a.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,a.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(a.linearVelocity)):h.hasLinearVelocity=!1,a.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(a.angularVelocity)):h.hasAngularVelocity=!1));l!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&a!==null&&(r=a),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(xE)))}return l!==null&&(l.visible=r!==null),h!==null&&(h.visible=a!==null),c!==null&&(c.visible=s!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new yn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class bE extends Yn{constructor(e,t){super();const i=this;let r=null,a=1,s=null,l="local-floor",h=1,c=null,d=null,p=null,f=null,m=null,_=null;const x=t.getContextAttributes();let y=null,v=null;const M=[],b=[],S=new pe;let A=null;const T=new nr;T.layers.enable(1),T.viewport=new Zt;const E=new nr;E.layers.enable(2),E.viewport=new Zt;const I=[T,E],C=new yE;C.layers.enable(1),C.layers.enable(2);let P=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ee){let ce=M[ee];return ce===void 0&&(ce=new Md,M[ee]=ce),ce.getTargetRaySpace()},this.getControllerGrip=function(ee){let ce=M[ee];return ce===void 0&&(ce=new Md,M[ee]=ce),ce.getGripSpace()},this.getHand=function(ee){let ce=M[ee];return ce===void 0&&(ce=new Md,M[ee]=ce),ce.getHandSpace()};function q(ee){const ce=b.indexOf(ee.inputSource);if(ce===-1)return;const Te=M[ce];Te!==void 0&&(Te.update(ee.inputSource,ee.frame,c||s),Te.dispatchEvent({type:ee.type,data:ee.inputSource}))}function te(){r.removeEventListener("select",q),r.removeEventListener("selectstart",q),r.removeEventListener("selectend",q),r.removeEventListener("squeeze",q),r.removeEventListener("squeezestart",q),r.removeEventListener("squeezeend",q),r.removeEventListener("end",te),r.removeEventListener("inputsourceschange",k);for(let ee=0;ee<M.length;ee++){const ce=b[ee];ce!==null&&(b[ee]=null,M[ee].disconnect(ce))}P=null,X=null,e.setRenderTarget(y),m=null,f=null,p=null,r=null,v=null,De.stop(),i.isPresenting=!1,e.setPixelRatio(A),e.setSize(S.width,S.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ee){a=ee,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ee){l=ee,i.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||s},this.setReferenceSpace=function(ee){c=ee},this.getBaseLayer=function(){return f!==null?f:m},this.getBinding=function(){return p},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(ee){if(r=ee,r!==null){if(y=e.getRenderTarget(),r.addEventListener("select",q),r.addEventListener("selectstart",q),r.addEventListener("selectend",q),r.addEventListener("squeeze",q),r.addEventListener("squeezestart",q),r.addEventListener("squeezeend",q),r.addEventListener("end",te),r.addEventListener("inputsourceschange",k),x.xrCompatible!==!0&&await t.makeXRCompatible(),A=e.getPixelRatio(),e.getSize(S),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ce={antialias:r.renderState.layers===void 0?x.antialias:!0,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(r,t,ce),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),v=new Yi(m.framebufferWidth,m.framebufferHeight,{format:Cr,type:va,colorSpace:e.outputColorSpace,stencilBuffer:x.stencil})}else{let ce=null,Te=null,Be=null;x.depth&&(Be=x.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ce=x.stencil?ks:$a,Te=x.stencil?Ja:ya);const je={colorFormat:t.RGBA8,depthFormat:Be,scaleFactor:a};p=new XRWebGLBinding(r,t),f=p.createProjectionLayer(je),r.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),v=new Yi(f.textureWidth,f.textureHeight,{format:Cr,type:va,depthTexture:new Hg(f.textureWidth,f.textureHeight,Te,void 0,void 0,void 0,void 0,void 0,void 0,ce),stencilBuffer:x.stencil,colorSpace:e.outputColorSpace,samples:x.antialias?4:0});const $e=e.properties.get(v);$e.__ignoreDepthValues=f.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(h),c=null,s=await r.requestReferenceSpace(l),De.setContext(r),De.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function k(ee){for(let ce=0;ce<ee.removed.length;ce++){const Te=ee.removed[ce],Be=b.indexOf(Te);Be>=0&&(b[Be]=null,M[Be].disconnect(Te))}for(let ce=0;ce<ee.added.length;ce++){const Te=ee.added[ce];let Be=b.indexOf(Te);if(Be===-1){for(let $e=0;$e<M.length;$e++)if($e>=b.length){b.push(Te),Be=$e;break}else if(b[$e]===null){b[$e]=Te,Be=$e;break}if(Be===-1)break}const je=M[Be];je&&je.connect(Te)}}const H=new z,V=new z;function J(ee,ce,Te){H.setFromMatrixPosition(ce.matrixWorld),V.setFromMatrixPosition(Te.matrixWorld);const Be=H.distanceTo(V),je=ce.projectionMatrix.elements,$e=Te.projectionMatrix.elements,qe=je[14]/(je[10]-1),Xe=je[14]/(je[10]+1),ge=(je[9]+1)/je[5],G=(je[9]-1)/je[5],Ae=(je[8]-1)/je[0],ue=($e[8]+1)/$e[0],de=qe*Ae,Ee=qe*ue,Fe=Be/(-Ae+ue),ke=Fe*-Ae;ce.matrixWorld.decompose(ee.position,ee.quaternion,ee.scale),ee.translateX(ke),ee.translateZ(Fe),ee.matrixWorld.compose(ee.position,ee.quaternion,ee.scale),ee.matrixWorldInverse.copy(ee.matrixWorld).invert();const N=qe+Fe,L=Xe+Fe,Z=de-ke,xe=Ee+(Be-ke),fe=ge*Xe/L*N,Se=G*Xe/L*N;ee.projectionMatrix.makePerspective(Z,xe,fe,Se,N,L),ee.projectionMatrixInverse.copy(ee.projectionMatrix).invert()}function ie(ee,ce){ce===null?ee.matrixWorld.copy(ee.matrix):ee.matrixWorld.multiplyMatrices(ce.matrixWorld,ee.matrix),ee.matrixWorldInverse.copy(ee.matrixWorld).invert()}this.updateCamera=function(ee){if(r===null)return;C.near=E.near=T.near=ee.near,C.far=E.far=T.far=ee.far,(P!==C.near||X!==C.far)&&(r.updateRenderState({depthNear:C.near,depthFar:C.far}),P=C.near,X=C.far);const ce=ee.parent,Te=C.cameras;ie(C,ce);for(let Be=0;Be<Te.length;Be++)ie(Te[Be],ce);Te.length===2?J(C,T,E):C.projectionMatrix.copy(T.projectionMatrix),$(ee,C,ce)};function $(ee,ce,Te){Te===null?ee.matrix.copy(ce.matrixWorld):(ee.matrix.copy(Te.matrixWorld),ee.matrix.invert(),ee.matrix.multiply(ce.matrixWorld)),ee.matrix.decompose(ee.position,ee.quaternion,ee.scale),ee.updateMatrixWorld(!0),ee.projectionMatrix.copy(ce.projectionMatrix),ee.projectionMatrixInverse.copy(ce.projectionMatrixInverse),ee.isPerspectiveCamera&&(ee.fov=Vs*2*Math.atan(1/ee.projectionMatrix.elements[5]),ee.zoom=1)}this.getCamera=function(){return C},this.getFoveation=function(){if(!(f===null&&m===null))return h},this.setFoveation=function(ee){h=ee,f!==null&&(f.fixedFoveation=ee),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ee)};let ne=null;function he(ee,ce){if(d=ce.getViewerPose(c||s),_=ce,d!==null){const Te=d.views;m!==null&&(e.setRenderTargetFramebuffer(v,m.framebuffer),e.setRenderTarget(v));let Be=!1;Te.length!==C.cameras.length&&(C.cameras.length=0,Be=!0);for(let je=0;je<Te.length;je++){const $e=Te[je];let qe=null;if(m!==null)qe=m.getViewport($e);else{const ge=p.getViewSubImage(f,$e);qe=ge.viewport,je===0&&(e.setRenderTargetTextures(v,ge.colorTexture,f.ignoreDepthValues?void 0:ge.depthStencilTexture),e.setRenderTarget(v))}let Xe=I[je];Xe===void 0&&(Xe=new nr,Xe.layers.enable(je),Xe.viewport=new Zt,I[je]=Xe),Xe.matrix.fromArray($e.transform.matrix),Xe.matrix.decompose(Xe.position,Xe.quaternion,Xe.scale),Xe.projectionMatrix.fromArray($e.projectionMatrix),Xe.projectionMatrixInverse.copy(Xe.projectionMatrix).invert(),Xe.viewport.set(qe.x,qe.y,qe.width,qe.height),je===0&&(C.matrix.copy(Xe.matrix),C.matrix.decompose(C.position,C.quaternion,C.scale)),Be===!0&&C.cameras.push(Xe)}}for(let Te=0;Te<M.length;Te++){const Be=b[Te],je=M[Te];Be!==null&&je!==void 0&&je.update(Be,ce,c||s)}ne&&ne(ee,ce),ce.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:ce}),_=null}const De=new Ig;De.setAnimationLoop(he),this.setAnimationLoop=function(ee){ne=ee},this.dispose=function(){}}}function wE(n,e){function t(y,v){y.matrixAutoUpdate===!0&&y.updateMatrix(),v.value.copy(y.matrix)}function i(y,v){v.color.getRGB(y.fogColor.value,Lg(n)),v.isFog?(y.fogNear.value=v.near,y.fogFar.value=v.far):v.isFogExp2&&(y.fogDensity.value=v.density)}function r(y,v,M,b,S){v.isMeshBasicMaterial||v.isMeshLambertMaterial?a(y,v):v.isMeshToonMaterial?(a(y,v),p(y,v)):v.isMeshPhongMaterial?(a(y,v),d(y,v)):v.isMeshStandardMaterial?(a(y,v),f(y,v),v.isMeshPhysicalMaterial&&m(y,v,S)):v.isMeshMatcapMaterial?(a(y,v),_(y,v)):v.isMeshDepthMaterial?a(y,v):v.isMeshDistanceMaterial?(a(y,v),x(y,v)):v.isMeshNormalMaterial?a(y,v):v.isLineBasicMaterial?(s(y,v),v.isLineDashedMaterial&&l(y,v)):v.isPointsMaterial?h(y,v,M,b):v.isSpriteMaterial?c(y,v):v.isShadowMaterial?(y.color.value.copy(v.color),y.opacity.value=v.opacity):v.isShaderMaterial&&(v.uniformsNeedUpdate=!1)}function a(y,v){y.opacity.value=v.opacity,v.color&&y.diffuse.value.copy(v.color),v.emissive&&y.emissive.value.copy(v.emissive).multiplyScalar(v.emissiveIntensity),v.map&&(y.map.value=v.map,t(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,t(v.alphaMap,y.alphaMapTransform)),v.bumpMap&&(y.bumpMap.value=v.bumpMap,t(v.bumpMap,y.bumpMapTransform),y.bumpScale.value=v.bumpScale,v.side===dr&&(y.bumpScale.value*=-1)),v.normalMap&&(y.normalMap.value=v.normalMap,t(v.normalMap,y.normalMapTransform),y.normalScale.value.copy(v.normalScale),v.side===dr&&y.normalScale.value.negate()),v.displacementMap&&(y.displacementMap.value=v.displacementMap,t(v.displacementMap,y.displacementMapTransform),y.displacementScale.value=v.displacementScale,y.displacementBias.value=v.displacementBias),v.emissiveMap&&(y.emissiveMap.value=v.emissiveMap,t(v.emissiveMap,y.emissiveMapTransform)),v.specularMap&&(y.specularMap.value=v.specularMap,t(v.specularMap,y.specularMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest);const M=e.get(v).envMap;if(M&&(y.envMap.value=M,y.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=v.reflectivity,y.ior.value=v.ior,y.refractionRatio.value=v.refractionRatio),v.lightMap){y.lightMap.value=v.lightMap;const b=n._useLegacyLights===!0?Math.PI:1;y.lightMapIntensity.value=v.lightMapIntensity*b,t(v.lightMap,y.lightMapTransform)}v.aoMap&&(y.aoMap.value=v.aoMap,y.aoMapIntensity.value=v.aoMapIntensity,t(v.aoMap,y.aoMapTransform))}function s(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,v.map&&(y.map.value=v.map,t(v.map,y.mapTransform))}function l(y,v){y.dashSize.value=v.dashSize,y.totalSize.value=v.dashSize+v.gapSize,y.scale.value=v.scale}function h(y,v,M,b){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.size.value=v.size*M,y.scale.value=b*.5,v.map&&(y.map.value=v.map,t(v.map,y.uvTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,t(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function c(y,v){y.diffuse.value.copy(v.color),y.opacity.value=v.opacity,y.rotation.value=v.rotation,v.map&&(y.map.value=v.map,t(v.map,y.mapTransform)),v.alphaMap&&(y.alphaMap.value=v.alphaMap,t(v.alphaMap,y.alphaMapTransform)),v.alphaTest>0&&(y.alphaTest.value=v.alphaTest)}function d(y,v){y.specular.value.copy(v.specular),y.shininess.value=Math.max(v.shininess,1e-4)}function p(y,v){v.gradientMap&&(y.gradientMap.value=v.gradientMap)}function f(y,v){y.metalness.value=v.metalness,v.metalnessMap&&(y.metalnessMap.value=v.metalnessMap,t(v.metalnessMap,y.metalnessMapTransform)),y.roughness.value=v.roughness,v.roughnessMap&&(y.roughnessMap.value=v.roughnessMap,t(v.roughnessMap,y.roughnessMapTransform)),e.get(v).envMap&&(y.envMapIntensity.value=v.envMapIntensity)}function m(y,v,M){y.ior.value=v.ior,v.sheen>0&&(y.sheenColor.value.copy(v.sheenColor).multiplyScalar(v.sheen),y.sheenRoughness.value=v.sheenRoughness,v.sheenColorMap&&(y.sheenColorMap.value=v.sheenColorMap,t(v.sheenColorMap,y.sheenColorMapTransform)),v.sheenRoughnessMap&&(y.sheenRoughnessMap.value=v.sheenRoughnessMap,t(v.sheenRoughnessMap,y.sheenRoughnessMapTransform))),v.clearcoat>0&&(y.clearcoat.value=v.clearcoat,y.clearcoatRoughness.value=v.clearcoatRoughness,v.clearcoatMap&&(y.clearcoatMap.value=v.clearcoatMap,t(v.clearcoatMap,y.clearcoatMapTransform)),v.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=v.clearcoatRoughnessMap,t(v.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),v.clearcoatNormalMap&&(y.clearcoatNormalMap.value=v.clearcoatNormalMap,t(v.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(v.clearcoatNormalScale),v.side===dr&&y.clearcoatNormalScale.value.negate())),v.iridescence>0&&(y.iridescence.value=v.iridescence,y.iridescenceIOR.value=v.iridescenceIOR,y.iridescenceThicknessMinimum.value=v.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=v.iridescenceThicknessRange[1],v.iridescenceMap&&(y.iridescenceMap.value=v.iridescenceMap,t(v.iridescenceMap,y.iridescenceMapTransform)),v.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=v.iridescenceThicknessMap,t(v.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),v.transmission>0&&(y.transmission.value=v.transmission,y.transmissionSamplerMap.value=M.texture,y.transmissionSamplerSize.value.set(M.width,M.height),v.transmissionMap&&(y.transmissionMap.value=v.transmissionMap,t(v.transmissionMap,y.transmissionMapTransform)),y.thickness.value=v.thickness,v.thicknessMap&&(y.thicknessMap.value=v.thicknessMap,t(v.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=v.attenuationDistance,y.attenuationColor.value.copy(v.attenuationColor)),v.anisotropy>0&&(y.anisotropyVector.value.set(v.anisotropy*Math.cos(v.anisotropyRotation),v.anisotropy*Math.sin(v.anisotropyRotation)),v.anisotropyMap&&(y.anisotropyMap.value=v.anisotropyMap,t(v.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=v.specularIntensity,y.specularColor.value.copy(v.specularColor),v.specularColorMap&&(y.specularColorMap.value=v.specularColorMap,t(v.specularColorMap,y.specularColorMapTransform)),v.specularIntensityMap&&(y.specularIntensityMap.value=v.specularIntensityMap,t(v.specularIntensityMap,y.specularIntensityMapTransform))}function _(y,v){v.matcap&&(y.matcap.value=v.matcap)}function x(y,v){const M=e.get(v).light;y.referencePosition.value.setFromMatrixPosition(M.matrixWorld),y.nearDistance.value=M.shadow.camera.near,y.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function ME(n,e,t,i){let r={},a={},s=[];const l=t.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function h(M,b){const S=b.program;i.uniformBlockBinding(M,S)}function c(M,b){let S=r[M.id];S===void 0&&(_(M),S=d(M),r[M.id]=S,M.addEventListener("dispose",y));const A=b.program;i.updateUBOMapping(M,A);const T=e.render.frame;a[M.id]!==T&&(f(M),a[M.id]=T)}function d(M){const b=p();M.__bindingPointIndex=b;const S=n.createBuffer(),A=M.__size,T=M.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,A,T),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,b,S),S}function p(){for(let M=0;M<l;M++)if(s.indexOf(M)===-1)return s.push(M),M;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(M){const b=r[M.id],S=M.uniforms,A=M.__cache;n.bindBuffer(n.UNIFORM_BUFFER,b);for(let T=0,E=S.length;T<E;T++){const I=Array.isArray(S[T])?S[T]:[S[T]];for(let C=0,P=I.length;C<P;C++){const X=I[C];if(m(X,T,C,A)===!0){const q=X.__offset,te=Array.isArray(X.value)?X.value:[X.value];let k=0;for(let H=0;H<te.length;H++){const V=te[H],J=x(V);typeof V=="number"||typeof V=="boolean"?(X.__data[0]=V,n.bufferSubData(n.UNIFORM_BUFFER,q+k,X.__data)):V.isMatrix3?(X.__data[0]=V.elements[0],X.__data[1]=V.elements[1],X.__data[2]=V.elements[2],X.__data[3]=0,X.__data[4]=V.elements[3],X.__data[5]=V.elements[4],X.__data[6]=V.elements[5],X.__data[7]=0,X.__data[8]=V.elements[6],X.__data[9]=V.elements[7],X.__data[10]=V.elements[8],X.__data[11]=0):(V.toArray(X.__data,k),k+=J.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,q,X.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function m(M,b,S,A){const T=M.value,E=b+"_"+S;if(A[E]===void 0)return typeof T=="number"||typeof T=="boolean"?A[E]=T:A[E]=T.clone(),!0;{const I=A[E];if(typeof T=="number"||typeof T=="boolean"){if(I!==T)return A[E]=T,!0}else if(I.equals(T)===!1)return I.copy(T),!0}return!1}function _(M){const b=M.uniforms;let S=0;const A=16;for(let E=0,I=b.length;E<I;E++){const C=Array.isArray(b[E])?b[E]:[b[E]];for(let P=0,X=C.length;P<X;P++){const q=C[P],te=Array.isArray(q.value)?q.value:[q.value];for(let k=0,H=te.length;k<H;k++){const V=te[k],J=x(V),ie=S%A;ie!==0&&A-ie<J.boundary&&(S+=A-ie),q.__data=new Float32Array(J.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=S,S+=J.storage}}}const T=S%A;return T>0&&(S+=A-T),M.__size=S,M.__cache={},this}function x(M){const b={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(b.boundary=4,b.storage=4):M.isVector2?(b.boundary=8,b.storage=8):M.isVector3||M.isColor?(b.boundary=16,b.storage=12):M.isVector4?(b.boundary=16,b.storage=16):M.isMatrix3?(b.boundary=48,b.storage=48):M.isMatrix4?(b.boundary=64,b.storage=64):M.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",M),b}function y(M){const b=M.target;b.removeEventListener("dispose",y);const S=s.indexOf(b.__bindingPointIndex);s.splice(S,1),n.deleteBuffer(r[b.id]),delete r[b.id],delete a[b.id]}function v(){for(const M in r)n.deleteBuffer(r[M]);s=[],r={},a={}}return{bind:h,update:c,dispose:v}}class h_{constructor(e={}){const{canvas:t=bb(),context:i=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:l=!1,premultipliedAlpha:h=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:p=!1}=e;this.isWebGLRenderer=!0;let f;i!==null?f=i.getContextAttributes().alpha:f=s;const m=new Uint32Array(4),_=new Int32Array(4);let x=null,y=null;const v=[],M=[];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=Bt,this._useLegacyLights=!1,this.toneMapping=_a,this.toneMappingExposure=1;const b=this;let S=!1,A=0,T=0,E=null,I=-1,C=null;const P=new Zt,X=new Zt;let q=null;const te=new Ke(0);let k=0,H=t.width,V=t.height,J=1,ie=null,$=null;const ne=new Zt(0,0,H,V),he=new Zt(0,0,H,V);let De=!1;const ee=new md;let ce=!1,Te=!1,Be=null;const je=new Ze,$e=new pe,qe=new z,Xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ge(){return E===null?J:1}let G=i;function Ae(U,Q){for(let ae=0;ae<U.length;ae++){const oe=U[ae],re=t.getContext(oe,Q);if(re!==null)return re}return null}try{const U={alpha:!0,depth:r,stencil:a,antialias:l,premultipliedAlpha:h,preserveDrawingBuffer:c,powerPreference:d,failIfMajorPerformanceCaveat:p};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Wn}`),t.addEventListener("webglcontextlost",Le,!1),t.addEventListener("webglcontextrestored",W,!1),t.addEventListener("webglcontextcreationerror",we,!1),G===null){const Q=["webgl2","webgl","experimental-webgl"];if(b.isWebGL1Renderer===!0&&Q.shift(),G=Ae(Q,U),G===null)throw Ae(Q)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&G instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),G.getShaderPrecisionFormat===void 0&&(G.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(U){throw console.error("THREE.WebGLRenderer: "+U.message),U}let ue,de,Ee,Fe,ke,N,L,Z,xe,fe,Se,He,Ie,Ue,Ge,Je,be,dt,B,_e,Ce,Re,Ve,tt;function Tt(){ue=new OT(G),de=new RT(G,ue,e),ue.init(de),Re=new vE(G,ue,de),Ee=new gE(G,ue,de),Fe=new zT(G),ke=new rE,N=new _E(G,ue,Ee,ke,de,Re,Fe),L=new LT(b),Z=new IT(b),xe=new jb(G,de),Ve=new ET(G,ue,xe,de),fe=new NT(G,xe,Fe,Ve),Se=new HT(G,fe,xe,Fe),B=new kT(G,de,N),Je=new CT(ke),He=new iE(b,L,Z,ue,de,Ve,Je),Ie=new wE(b,ke),Ue=new aE,Ge=new uE(ue,de),dt=new ST(b,L,Z,Ee,Se,f,h),be=new mE(b,Se,de),tt=new ME(G,Fe,de,Ee),_e=new AT(G,ue,Fe,de),Ce=new UT(G,ue,Fe,de),Fe.programs=He.programs,b.capabilities=de,b.extensions=ue,b.properties=ke,b.renderLists=Ue,b.shadowMap=be,b.state=Ee,b.info=Fe}Tt();const ut=new bE(b,G);this.xr=ut,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){const U=ue.get("WEBGL_lose_context");U&&U.loseContext()},this.forceContextRestore=function(){const U=ue.get("WEBGL_lose_context");U&&U.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(U){U!==void 0&&(J=U,this.setSize(H,V,!1))},this.getSize=function(U){return U.set(H,V)},this.setSize=function(U,Q,ae=!0){if(ut.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=U,V=Q,t.width=Math.floor(U*J),t.height=Math.floor(Q*J),ae===!0&&(t.style.width=U+"px",t.style.height=Q+"px"),this.setViewport(0,0,U,Q)},this.getDrawingBufferSize=function(U){return U.set(H*J,V*J).floor()},this.setDrawingBufferSize=function(U,Q,ae){H=U,V=Q,J=ae,t.width=Math.floor(U*ae),t.height=Math.floor(Q*ae),this.setViewport(0,0,U,Q)},this.getCurrentViewport=function(U){return U.copy(P)},this.getViewport=function(U){return U.copy(ne)},this.setViewport=function(U,Q,ae,oe){U.isVector4?ne.set(U.x,U.y,U.z,U.w):ne.set(U,Q,ae,oe),Ee.viewport(P.copy(ne).multiplyScalar(J).floor())},this.getScissor=function(U){return U.copy(he)},this.setScissor=function(U,Q,ae,oe){U.isVector4?he.set(U.x,U.y,U.z,U.w):he.set(U,Q,ae,oe),Ee.scissor(X.copy(he).multiplyScalar(J).floor())},this.getScissorTest=function(){return De},this.setScissorTest=function(U){Ee.setScissorTest(De=U)},this.setOpaqueSort=function(U){ie=U},this.setTransparentSort=function(U){$=U},this.getClearColor=function(U){return U.copy(dt.getClearColor())},this.setClearColor=function(){dt.setClearColor.apply(dt,arguments)},this.getClearAlpha=function(){return dt.getClearAlpha()},this.setClearAlpha=function(){dt.setClearAlpha.apply(dt,arguments)},this.clear=function(U=!0,Q=!0,ae=!0){let oe=0;if(U){let re=!1;if(E!==null){const Ne=E.texture.format;re=Ne===Tm||Ne===Mm||Ne===wm}if(re){const Ne=E.texture.type,Qe=Ne===va||Ne===ya||Ne===zu||Ne===Ja||Ne===xm||Ne===bm,ot=dt.getClearColor(),ct=dt.getClearAlpha(),Rt=ot.r,xt=ot.g,bt=ot.b;Qe?(m[0]=Rt,m[1]=xt,m[2]=bt,m[3]=ct,G.clearBufferuiv(G.COLOR,0,m)):(_[0]=Rt,_[1]=xt,_[2]=bt,_[3]=ct,G.clearBufferiv(G.COLOR,0,_))}else oe|=G.COLOR_BUFFER_BIT}Q&&(oe|=G.DEPTH_BUFFER_BIT),ae&&(oe|=G.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G.clear(oe)},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",Le,!1),t.removeEventListener("webglcontextrestored",W,!1),t.removeEventListener("webglcontextcreationerror",we,!1),Ue.dispose(),Ge.dispose(),ke.dispose(),L.dispose(),Z.dispose(),Se.dispose(),Ve.dispose(),tt.dispose(),He.dispose(),ut.dispose(),ut.removeEventListener("sessionstart",er),ut.removeEventListener("sessionend",jt),Be&&(Be.dispose(),Be=null),Di.stop()};function Le(U){U.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function W(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const U=Fe.autoReset,Q=be.enabled,ae=be.autoUpdate,oe=be.needsUpdate,re=be.type;Tt(),Fe.autoReset=U,be.enabled=Q,be.autoUpdate=ae,be.needsUpdate=oe,be.type=re}function we(U){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",U.statusMessage)}function Pe(U){const Q=U.target;Q.removeEventListener("dispose",Pe),et(Q)}function et(U){ye(U),ke.remove(U)}function ye(U){const Q=ke.get(U).programs;Q!==void 0&&(Q.forEach(function(ae){He.releaseProgram(ae)}),U.isShaderMaterial&&He.releaseShaderCache(U))}this.renderBufferDirect=function(U,Q,ae,oe,re,Ne){Q===null&&(Q=Xe);const Qe=re.isMesh&&re.matrixWorld.determinant()<0,ot=$p(U,Q,ae,oe,re);Ee.setMaterial(oe,Qe);let ct=ae.index,Rt=1;if(oe.wireframe===!0){if(ct=fe.getWireframeAttribute(ae),ct===void 0)return;Rt=2}const xt=ae.drawRange,bt=ae.attributes.position;let Ii=xt.start*Rt,vi=(xt.start+xt.count)*Rt;Ne!==null&&(Ii=Math.max(Ii,Ne.start*Rt),vi=Math.min(vi,(Ne.start+Ne.count)*Rt)),ct!==null?(Ii=Math.max(Ii,0),vi=Math.min(vi,ct.count)):bt!=null&&(Ii=Math.max(Ii,0),vi=Math.min(vi,bt.count));const or=vi-Ii;if(or<0||or===1/0)return;Ve.setup(re,oe,ot,ae,ct);let bn,pi=_e;if(ct!==null&&(bn=xe.get(ct),pi=Ce,pi.setIndex(bn)),re.isMesh)oe.wireframe===!0?(Ee.setLineWidth(oe.wireframeLinewidth*ge()),pi.setMode(G.LINES)):pi.setMode(G.TRIANGLES);else if(re.isLine){let St=oe.linewidth;St===void 0&&(St=1),Ee.setLineWidth(St*ge()),re.isLineSegments?pi.setMode(G.LINES):re.isLineLoop?pi.setMode(G.LINE_LOOP):pi.setMode(G.LINE_STRIP)}else re.isPoints?pi.setMode(G.POINTS):re.isSprite&&pi.setMode(G.TRIANGLES);if(re.isBatchedMesh)pi.renderMultiDraw(re._multiDrawStarts,re._multiDrawCounts,re._multiDrawCount);else if(re.isInstancedMesh)pi.renderInstances(Ii,or,re.count);else if(ae.isInstancedBufferGeometry){const St=ae._maxInstanceCount!==void 0?ae._maxInstanceCount:1/0,Jl=Math.min(ae.instanceCount,St);pi.renderInstances(Ii,or,Jl)}else pi.render(Ii,or)};function it(U,Q,ae){U.transparent===!0&&U.side===xi&&U.forceSinglePass===!1?(U.side=dr,U.needsUpdate=!0,Wo(U,Q,ae),U.side=jn,U.needsUpdate=!0,Wo(U,Q,ae),U.side=xi):Wo(U,Q,ae)}this.compile=function(U,Q,ae=null){ae===null&&(ae=U),y=Ge.get(ae),y.init(),M.push(y),ae.traverseVisible(function(re){re.isLight&&re.layers.test(Q.layers)&&(y.pushLight(re),re.castShadow&&y.pushShadow(re))}),U!==ae&&U.traverseVisible(function(re){re.isLight&&re.layers.test(Q.layers)&&(y.pushLight(re),re.castShadow&&y.pushShadow(re))}),y.setupLights(b._useLegacyLights);const oe=new Set;return U.traverse(function(re){const Ne=re.material;if(Ne)if(Array.isArray(Ne))for(let Qe=0;Qe<Ne.length;Qe++){const ot=Ne[Qe];it(ot,ae,re),oe.add(ot)}else it(Ne,ae,re),oe.add(Ne)}),M.pop(),y=null,oe},this.compileAsync=function(U,Q,ae=null){const oe=this.compile(U,Q,ae);return new Promise(re=>{function Ne(){if(oe.forEach(function(Qe){ke.get(Qe).currentProgram.isReady()&&oe.delete(Qe)}),oe.size===0){re(U);return}setTimeout(Ne,10)}ue.get("KHR_parallel_shader_compile")!==null?Ne():setTimeout(Ne,10)})};let Ut=null;function oi(U){Ut&&Ut(U)}function er(){Di.stop()}function jt(){Di.start()}const Di=new Ig;Di.setAnimationLoop(oi),typeof self<"u"&&Di.setContext(self),this.setAnimationLoop=function(U){Ut=U,ut.setAnimationLoop(U),U===null?Di.stop():Di.start()},ut.addEventListener("sessionstart",er),ut.addEventListener("sessionend",jt),this.render=function(U,Q){if(Q!==void 0&&Q.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),Q.parent===null&&Q.matrixWorldAutoUpdate===!0&&Q.updateMatrixWorld(),ut.enabled===!0&&ut.isPresenting===!0&&(ut.cameraAutoUpdate===!0&&ut.updateCamera(Q),Q=ut.getCamera()),U.isScene===!0&&U.onBeforeRender(b,U,Q,E),y=Ge.get(U,M.length),y.init(),M.push(y),je.multiplyMatrices(Q.projectionMatrix,Q.matrixWorldInverse),ee.setFromProjectionMatrix(je),Te=this.localClippingEnabled,ce=Je.init(this.clippingPlanes,Te),x=Ue.get(U,v.length),x.init(),v.push(x),rn(U,Q,0,b.sortObjects),x.finish(),b.sortObjects===!0&&x.sort(ie,$),this.info.render.frame++,ce===!0&&Je.beginShadows();const ae=y.state.shadowsArray;if(be.render(ae,U,Q),ce===!0&&Je.endShadows(),this.info.autoReset===!0&&this.info.reset(),dt.render(x,U),y.setupLights(b._useLegacyLights),Q.isArrayCamera){const oe=Q.cameras;for(let re=0,Ne=oe.length;re<Ne;re++){const Qe=oe[re];Go(x,U,Qe,Qe.viewport)}}else Go(x,U,Q);E!==null&&(N.updateMultisampleRenderTarget(E),N.updateRenderTargetMipmap(E)),U.isScene===!0&&U.onAfterRender(b,U,Q),Ve.resetDefaultState(),I=-1,C=null,M.pop(),M.length>0?y=M[M.length-1]:y=null,v.pop(),v.length>0?x=v[v.length-1]:x=null};function rn(U,Q,ae,oe){if(U.visible===!1)return;if(U.layers.test(Q.layers)){if(U.isGroup)ae=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(Q);else if(U.isLight)y.pushLight(U),U.castShadow&&y.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||ee.intersectsSprite(U)){oe&&qe.setFromMatrixPosition(U.matrixWorld).applyMatrix4(je);const Ne=Se.update(U),Qe=U.material;Qe.visible&&x.push(U,Ne,Qe,ae,qe.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||ee.intersectsObject(U))){const Ne=Se.update(U),Qe=U.material;if(oe&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),qe.copy(U.boundingSphere.center)):(Ne.boundingSphere===null&&Ne.computeBoundingSphere(),qe.copy(Ne.boundingSphere.center)),qe.applyMatrix4(U.matrixWorld).applyMatrix4(je)),Array.isArray(Qe)){const ot=Ne.groups;for(let ct=0,Rt=ot.length;ct<Rt;ct++){const xt=ot[ct],bt=Qe[xt.materialIndex];bt&&bt.visible&&x.push(U,Ne,bt,ae,qe.z,xt)}}else Qe.visible&&x.push(U,Ne,Qe,ae,qe.z,null)}}const re=U.children;for(let Ne=0,Qe=re.length;Ne<Qe;Ne++)rn(re[Ne],Q,ae,oe)}function Go(U,Q,ae,oe){const re=U.opaque,Ne=U.transmissive,Qe=U.transparent;y.setupLightsView(ae),ce===!0&&Je.setGlobalState(b.clippingPlanes,ae),Ne.length>0&&Jp(re,Ne,Q,ae),oe&&Ee.viewport(P.copy(oe)),re.length>0&&Vo(re,Q,ae),Ne.length>0&&Vo(Ne,Q,ae),Qe.length>0&&Vo(Qe,Q,ae),Ee.buffers.depth.setTest(!0),Ee.buffers.depth.setMask(!0),Ee.buffers.color.setMask(!0),Ee.setPolygonOffset(!1)}function Jp(U,Q,ae,oe){if((ae.isScene===!0?ae.overrideMaterial:null)!==null)return;const re=de.isWebGL2;Be===null&&(Be=new Yi(1,1,{generateMipmaps:!0,type:ue.has("EXT_color_buffer_half_float")?Rr:va,minFilter:Za,samples:re?4:0})),b.getDrawingBufferSize($e),re?Be.setSize($e.x,$e.y):Be.setSize(Eh($e.x),Eh($e.y));const Ne=b.getRenderTarget();b.setRenderTarget(Be),b.getClearColor(te),k=b.getClearAlpha(),k<1&&b.setClearColor(16777215,.5),b.clear();const Qe=b.toneMapping;b.toneMapping=_a,Vo(U,ae,oe),N.updateMultisampleRenderTarget(Be),N.updateRenderTargetMipmap(Be);let ot=!1;for(let ct=0,Rt=Q.length;ct<Rt;ct++){const xt=Q[ct],bt=xt.object,Ii=xt.geometry,vi=xt.material,or=xt.group;if(vi.side===xi&&bt.layers.test(oe.layers)){const bn=vi.side;vi.side=dr,vi.needsUpdate=!0,kc(bt,ae,oe,Ii,vi,or),vi.side=bn,vi.needsUpdate=!0,ot=!0}}ot===!0&&(N.updateMultisampleRenderTarget(Be),N.updateRenderTargetMipmap(Be)),b.setRenderTarget(Ne),b.setClearColor(te,k),b.toneMapping=Qe}function Vo(U,Q,ae){const oe=Q.isScene===!0?Q.overrideMaterial:null;for(let re=0,Ne=U.length;re<Ne;re++){const Qe=U[re],ot=Qe.object,ct=Qe.geometry,Rt=oe===null?Qe.material:oe,xt=Qe.group;ot.layers.test(ae.layers)&&kc(ot,Q,ae,ct,Rt,xt)}}function kc(U,Q,ae,oe,re,Ne){U.onBeforeRender(b,Q,ae,oe,re,Ne),U.modelViewMatrix.multiplyMatrices(ae.matrixWorldInverse,U.matrixWorld),U.normalMatrix.getNormalMatrix(U.modelViewMatrix),re.onBeforeRender(b,Q,ae,oe,U,Ne),re.transparent===!0&&re.side===xi&&re.forceSinglePass===!1?(re.side=dr,re.needsUpdate=!0,b.renderBufferDirect(ae,Q,oe,re,U,Ne),re.side=jn,re.needsUpdate=!0,b.renderBufferDirect(ae,Q,oe,re,U,Ne),re.side=xi):b.renderBufferDirect(ae,Q,oe,re,U,Ne),U.onAfterRender(b,Q,ae,oe,re,Ne)}function Wo(U,Q,ae){Q.isScene!==!0&&(Q=Xe);const oe=ke.get(U),re=y.state.lights,Ne=y.state.shadowsArray,Qe=re.state.version,ot=He.getParameters(U,re.state,Ne,Q,ae),ct=He.getProgramCacheKey(ot);let Rt=oe.programs;oe.environment=U.isMeshStandardMaterial?Q.environment:null,oe.fog=Q.fog,oe.envMap=(U.isMeshStandardMaterial?Z:L).get(U.envMap||oe.environment),Rt===void 0&&(U.addEventListener("dispose",Pe),Rt=new Map,oe.programs=Rt);let xt=Rt.get(ct);if(xt!==void 0){if(oe.currentProgram===xt&&oe.lightsStateVersion===Qe)return Gc(U,ot),xt}else ot.uniforms=He.getUniforms(U),U.onBuild(ae,ot,b),U.onBeforeCompile(ot,b),xt=He.acquireProgram(ot,ct),Rt.set(ct,xt),oe.uniforms=ot.uniforms;const bt=oe.uniforms;return(!U.isShaderMaterial&&!U.isRawShaderMaterial||U.clipping===!0)&&(bt.clippingPlanes=Je.uniform),Gc(U,ot),oe.needsLights=Vc(U),oe.lightsStateVersion=Qe,oe.needsLights&&(bt.ambientLightColor.value=re.state.ambient,bt.lightProbe.value=re.state.probe,bt.directionalLights.value=re.state.directional,bt.directionalLightShadows.value=re.state.directionalShadow,bt.spotLights.value=re.state.spot,bt.spotLightShadows.value=re.state.spotShadow,bt.rectAreaLights.value=re.state.rectArea,bt.ltc_1.value=re.state.rectAreaLTC1,bt.ltc_2.value=re.state.rectAreaLTC2,bt.pointLights.value=re.state.point,bt.pointLightShadows.value=re.state.pointShadow,bt.hemisphereLights.value=re.state.hemi,bt.directionalShadowMap.value=re.state.directionalShadowMap,bt.directionalShadowMatrix.value=re.state.directionalShadowMatrix,bt.spotShadowMap.value=re.state.spotShadowMap,bt.spotLightMatrix.value=re.state.spotLightMatrix,bt.spotLightMap.value=re.state.spotLightMap,bt.pointShadowMap.value=re.state.pointShadowMap,bt.pointShadowMatrix.value=re.state.pointShadowMatrix),oe.currentProgram=xt,oe.uniformsList=null,xt}function Hc(U){if(U.uniformsList===null){const Q=U.currentProgram.getUniforms();U.uniformsList=Jh.seqWithValue(Q.seq,U.uniforms)}return U.uniformsList}function Gc(U,Q){const ae=ke.get(U);ae.outputColorSpace=Q.outputColorSpace,ae.batching=Q.batching,ae.instancing=Q.instancing,ae.instancingColor=Q.instancingColor,ae.skinning=Q.skinning,ae.morphTargets=Q.morphTargets,ae.morphNormals=Q.morphNormals,ae.morphColors=Q.morphColors,ae.morphTargetsCount=Q.morphTargetsCount,ae.numClippingPlanes=Q.numClippingPlanes,ae.numIntersection=Q.numClipIntersection,ae.vertexAlphas=Q.vertexAlphas,ae.vertexTangents=Q.vertexTangents,ae.toneMapping=Q.toneMapping}function $p(U,Q,ae,oe,re){Q.isScene!==!0&&(Q=Xe),N.resetTextureUnits();const Ne=Q.fog,Qe=oe.isMeshStandardMaterial?Q.environment:null,ot=E===null?b.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Bi,ct=(oe.isMeshStandardMaterial?Z:L).get(oe.envMap||Qe),Rt=oe.vertexColors===!0&&!!ae.attributes.color&&ae.attributes.color.itemSize===4,xt=!!ae.attributes.tangent&&(!!oe.normalMap||oe.anisotropy>0),bt=!!ae.morphAttributes.position,Ii=!!ae.morphAttributes.normal,vi=!!ae.morphAttributes.color;let or=_a;oe.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(or=b.toneMapping);const bn=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,pi=bn!==void 0?bn.length:0,St=ke.get(oe),Jl=y.state.lights;if(ce===!0&&(Te===!0||U!==C)){const Mr=U===C&&oe.id===I;Je.setState(oe,U,Mr)}let jo=!1;oe.version===St.__version?(St.needsLights&&St.lightsStateVersion!==Jl.state.version||St.outputColorSpace!==ot||re.isBatchedMesh&&St.batching===!1||!re.isBatchedMesh&&St.batching===!0||re.isInstancedMesh&&St.instancing===!1||!re.isInstancedMesh&&St.instancing===!0||re.isSkinnedMesh&&St.skinning===!1||!re.isSkinnedMesh&&St.skinning===!0||re.isInstancedMesh&&St.instancingColor===!0&&re.instanceColor===null||re.isInstancedMesh&&St.instancingColor===!1&&re.instanceColor!==null||St.envMap!==ct||oe.fog===!0&&St.fog!==Ne||St.numClippingPlanes!==void 0&&(St.numClippingPlanes!==Je.numPlanes||St.numIntersection!==Je.numIntersection)||St.vertexAlphas!==Rt||St.vertexTangents!==xt||St.morphTargets!==bt||St.morphNormals!==Ii||St.morphColors!==vi||St.toneMapping!==or||de.isWebGL2===!0&&St.morphTargetsCount!==pi)&&(jo=!0):(jo=!0,St.__version=oe.version);let kn=St.currentProgram;jo===!0&&(kn=Wo(oe,Q,re));let $l=!1,oa=!1,Ql=!1;const Oi=kn.getUniforms(),nn=St.uniforms;if(Ee.useProgram(kn.program)&&($l=!0,oa=!0,Ql=!0),oe.id!==I&&(I=oe.id,oa=!0),$l||C!==U){Oi.setValue(G,"projectionMatrix",U.projectionMatrix),Oi.setValue(G,"viewMatrix",U.matrixWorldInverse);const Mr=Oi.map.cameraPosition;Mr!==void 0&&Mr.setValue(G,qe.setFromMatrixPosition(U.matrixWorld)),de.logarithmicDepthBuffer&&Oi.setValue(G,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(oe.isMeshPhongMaterial||oe.isMeshToonMaterial||oe.isMeshLambertMaterial||oe.isMeshBasicMaterial||oe.isMeshStandardMaterial||oe.isShaderMaterial)&&Oi.setValue(G,"isOrthographic",U.isOrthographicCamera===!0),C!==U&&(C=U,oa=!0,Ql=!0)}if(re.isSkinnedMesh){Oi.setOptional(G,re,"bindMatrix"),Oi.setOptional(G,re,"bindMatrixInverse");const Mr=re.skeleton;Mr&&(de.floatVertexTextures?(Mr.boneTexture===null&&Mr.computeBoneTexture(),Oi.setValue(G,"boneTexture",Mr.boneTexture,N)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}re.isBatchedMesh&&(Oi.setOptional(G,re,"batchingTexture"),Oi.setValue(G,"batchingTexture",re._matricesTexture,N));const Xo=ae.morphAttributes;if((Xo.position!==void 0||Xo.normal!==void 0||Xo.color!==void 0&&de.isWebGL2===!0)&&B.update(re,ae,kn),(oa||St.receiveShadow!==re.receiveShadow)&&(St.receiveShadow=re.receiveShadow,Oi.setValue(G,"receiveShadow",re.receiveShadow)),oe.isMeshGouraudMaterial&&oe.envMap!==null&&(nn.envMap.value=ct,nn.flipEnvMap.value=ct.isCubeTexture&&ct.isRenderTargetTexture===!1?-1:1),oa&&(Oi.setValue(G,"toneMappingExposure",b.toneMappingExposure),St.needsLights&&Qp(nn,Ql),Ne&&oe.fog===!0&&Ie.refreshFogUniforms(nn,Ne),Ie.refreshMaterialUniforms(nn,oe,J,V,Be),Jh.upload(G,Hc(St),nn,N)),oe.isShaderMaterial&&oe.uniformsNeedUpdate===!0&&(Jh.upload(G,Hc(St),nn,N),oe.uniformsNeedUpdate=!1),oe.isSpriteMaterial&&Oi.setValue(G,"center",re.center),Oi.setValue(G,"modelViewMatrix",re.modelViewMatrix),Oi.setValue(G,"normalMatrix",re.normalMatrix),Oi.setValue(G,"modelMatrix",re.matrixWorld),oe.isShaderMaterial||oe.isRawShaderMaterial){const Mr=oe.uniformsGroups;for(let qo=0,Wc=Mr.length;qo<Wc;qo++)if(de.isWebGL2){const Yo=Mr[qo];tt.update(Yo,kn),tt.bind(Yo,kn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return kn}function Qp(U,Q){U.ambientLightColor.needsUpdate=Q,U.lightProbe.needsUpdate=Q,U.directionalLights.needsUpdate=Q,U.directionalLightShadows.needsUpdate=Q,U.pointLights.needsUpdate=Q,U.pointLightShadows.needsUpdate=Q,U.spotLights.needsUpdate=Q,U.spotLightShadows.needsUpdate=Q,U.rectAreaLights.needsUpdate=Q,U.hemisphereLights.needsUpdate=Q}function Vc(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return A},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(U,Q,ae){ke.get(U.texture).__webglTexture=Q,ke.get(U.depthTexture).__webglTexture=ae;const oe=ke.get(U);oe.__hasExternalTextures=!0,oe.__hasExternalTextures&&(oe.__autoAllocateDepthBuffer=ae===void 0,oe.__autoAllocateDepthBuffer||ue.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),oe.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(U,Q){const ae=ke.get(U);ae.__webglFramebuffer=Q,ae.__useDefaultFramebuffer=Q===void 0},this.setRenderTarget=function(U,Q=0,ae=0){E=U,A=Q,T=ae;let oe=!0,re=null,Ne=!1,Qe=!1;if(U){const ot=ke.get(U);ot.__useDefaultFramebuffer!==void 0?(Ee.bindFramebuffer(G.FRAMEBUFFER,null),oe=!1):ot.__webglFramebuffer===void 0?N.setupRenderTarget(U):ot.__hasExternalTextures&&N.rebindTextures(U,ke.get(U.texture).__webglTexture,ke.get(U.depthTexture).__webglTexture);const ct=U.texture;(ct.isData3DTexture||ct.isDataArrayTexture||ct.isCompressedArrayTexture)&&(Qe=!0);const Rt=ke.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(Rt[Q])?re=Rt[Q][ae]:re=Rt[Q],Ne=!0):de.isWebGL2&&U.samples>0&&N.useMultisampledRTT(U)===!1?re=ke.get(U).__webglMultisampledFramebuffer:Array.isArray(Rt)?re=Rt[ae]:re=Rt,P.copy(U.viewport),X.copy(U.scissor),q=U.scissorTest}else P.copy(ne).multiplyScalar(J).floor(),X.copy(he).multiplyScalar(J).floor(),q=De;if(Ee.bindFramebuffer(G.FRAMEBUFFER,re)&&de.drawBuffers&&oe&&Ee.drawBuffers(U,re),Ee.viewport(P),Ee.scissor(X),Ee.setScissorTest(q),Ne){const ot=ke.get(U.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+Q,ot.__webglTexture,ae)}else if(Qe){const ot=ke.get(U.texture),ct=Q||0;G.framebufferTextureLayer(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,ot.__webglTexture,ae||0,ct)}I=-1},this.readRenderTargetPixels=function(U,Q,ae,oe,re,Ne,Qe){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ot=ke.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&Qe!==void 0&&(ot=ot[Qe]),ot){Ee.bindFramebuffer(G.FRAMEBUFFER,ot);try{const ct=U.texture,Rt=ct.format,xt=ct.type;if(Rt!==Cr&&Re.convert(Rt)!==G.getParameter(G.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const bt=xt===Rr&&(ue.has("EXT_color_buffer_half_float")||de.isWebGL2&&ue.has("EXT_color_buffer_float"));if(xt!==va&&Re.convert(xt)!==G.getParameter(G.IMPLEMENTATION_COLOR_READ_TYPE)&&!(xt===Xn&&(de.isWebGL2||ue.has("OES_texture_float")||ue.has("WEBGL_color_buffer_float")))&&!bt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Q>=0&&Q<=U.width-oe&&ae>=0&&ae<=U.height-re&&G.readPixels(Q,ae,oe,re,Re.convert(Rt),Re.convert(xt),Ne)}finally{const ct=E!==null?ke.get(E).__webglFramebuffer:null;Ee.bindFramebuffer(G.FRAMEBUFFER,ct)}}},this.copyFramebufferToTexture=function(U,Q,ae=0){const oe=Math.pow(2,-ae),re=Math.floor(Q.image.width*oe),Ne=Math.floor(Q.image.height*oe);N.setTexture2D(Q,0),G.copyTexSubImage2D(G.TEXTURE_2D,ae,0,0,U.x,U.y,re,Ne),Ee.unbindTexture()},this.copyTextureToTexture=function(U,Q,ae,oe=0){const re=Q.image.width,Ne=Q.image.height,Qe=Re.convert(ae.format),ot=Re.convert(ae.type);N.setTexture2D(ae,0),G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,ae.flipY),G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ae.premultiplyAlpha),G.pixelStorei(G.UNPACK_ALIGNMENT,ae.unpackAlignment),Q.isDataTexture?G.texSubImage2D(G.TEXTURE_2D,oe,U.x,U.y,re,Ne,Qe,ot,Q.image.data):Q.isCompressedTexture?G.compressedTexSubImage2D(G.TEXTURE_2D,oe,U.x,U.y,Q.mipmaps[0].width,Q.mipmaps[0].height,Qe,Q.mipmaps[0].data):G.texSubImage2D(G.TEXTURE_2D,oe,U.x,U.y,Qe,ot,Q.image),oe===0&&ae.generateMipmaps&&G.generateMipmap(G.TEXTURE_2D),Ee.unbindTexture()},this.copyTextureToTexture3D=function(U,Q,ae,oe,re=0){if(b.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ne=U.max.x-U.min.x+1,Qe=U.max.y-U.min.y+1,ot=U.max.z-U.min.z+1,ct=Re.convert(oe.format),Rt=Re.convert(oe.type);let xt;if(oe.isData3DTexture)N.setTexture3D(oe,0),xt=G.TEXTURE_3D;else if(oe.isDataArrayTexture||oe.isCompressedArrayTexture)N.setTexture2DArray(oe,0),xt=G.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}G.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,oe.flipY),G.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,oe.premultiplyAlpha),G.pixelStorei(G.UNPACK_ALIGNMENT,oe.unpackAlignment);const bt=G.getParameter(G.UNPACK_ROW_LENGTH),Ii=G.getParameter(G.UNPACK_IMAGE_HEIGHT),vi=G.getParameter(G.UNPACK_SKIP_PIXELS),or=G.getParameter(G.UNPACK_SKIP_ROWS),bn=G.getParameter(G.UNPACK_SKIP_IMAGES),pi=ae.isCompressedTexture?ae.mipmaps[re]:ae.image;G.pixelStorei(G.UNPACK_ROW_LENGTH,pi.width),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,pi.height),G.pixelStorei(G.UNPACK_SKIP_PIXELS,U.min.x),G.pixelStorei(G.UNPACK_SKIP_ROWS,U.min.y),G.pixelStorei(G.UNPACK_SKIP_IMAGES,U.min.z),ae.isDataTexture||ae.isData3DTexture?G.texSubImage3D(xt,re,Q.x,Q.y,Q.z,Ne,Qe,ot,ct,Rt,pi.data):ae.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),G.compressedTexSubImage3D(xt,re,Q.x,Q.y,Q.z,Ne,Qe,ot,ct,pi.data)):G.texSubImage3D(xt,re,Q.x,Q.y,Q.z,Ne,Qe,ot,ct,Rt,pi),G.pixelStorei(G.UNPACK_ROW_LENGTH,bt),G.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Ii),G.pixelStorei(G.UNPACK_SKIP_PIXELS,vi),G.pixelStorei(G.UNPACK_SKIP_ROWS,or),G.pixelStorei(G.UNPACK_SKIP_IMAGES,bn),re===0&&oe.generateMipmaps&&G.generateMipmap(xt),Ee.unbindTexture()},this.initTexture=function(U){U.isCubeTexture?N.setTextureCube(U,0):U.isData3DTexture?N.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?N.setTexture2DArray(U,0):N.setTexture2D(U,0),Ee.unbindTexture()},this.resetState=function(){A=0,T=0,E=null,Ee.reset(),Ve.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return qn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===ju?"display-p3":"srgb",t.unpackColorSpace=Gt.workingColorSpace===bh?"display-p3":"srgb"}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Bt?Qa:tg}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Qa?Bt:Bi}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 TE extends h_{}TE.prototype.isWebGL1Renderer=!0;class Td{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ke(e),this.near=t,this.far=i}clone(){return new Td(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}let SE=class extends ei{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(n,e){return super.copy(n,e),n.background!==null&&(this.background=n.background.clone()),n.environment!==null&&(this.environment=n.environment.clone()),n.fog!==null&&(this.fog=n.fog.clone()),this.backgroundBlurriness=n.backgroundBlurriness,this.backgroundIntensity=n.backgroundIntensity,n.overrideMaterial!==null&&(this.overrideMaterial=n.overrideMaterial.clone()),this.matrixAutoUpdate=n.matrixAutoUpdate,this}toJSON(n){const e=super.toJSON(n);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e}};class EE{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Xu,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Xr()}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,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;r<a;r++)this.array[e+r]=t.array[i+r];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=Xr()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=Xr()),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 ar=new z;class Sd{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}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,i=this.data.count;t<i;t++)ar.fromBufferAttribute(this,t),ar.applyMatrix4(e),this.setXYZ(t,ar.x,ar.y,ar.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)ar.fromBufferAttribute(this,t),ar.applyNormalMatrix(e),this.setXYZ(t,ar.x,ar.y,ar.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)ar.fromBufferAttribute(this,t),ar.transformDirection(e),this.setXYZ(t,ar.x,ar.y,ar.z);return this}setX(e,t){return this.normalized&&(t=Kt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Kt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Kt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Kt(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=An(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=An(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=An(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=An(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,a){return e=e*this.data.stride+this.offset,this.normalized&&(t=Kt(t,this.array),i=Kt(i,this.array),r=Kt(r,this.array),a=Kt(a,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=a,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 i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}return new mi(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 Sd(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 i=0;i<this.count;i++){const r=i*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)t.push(this.data.array[r+a])}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}}}const c_=new z,u_=new Zt,d_=new Zt,AE=new z,p_=new Ze,$h=new z,Ed=new Cn,f_=new Ze,Ad=new is;class RE extends rt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=gm,this.bindMatrix=new Ze,this.bindMatrixInverse=new Ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Fi),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,$h),this.boundingBox.expandByPoint($h)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Cn),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let i=0;i<t.count;i++)this.getVertexPosition(i,$h),this.boundingSphere.expandByPoint($h)}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 i=this.material,r=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ed.copy(this.boundingSphere),Ed.applyMatrix4(r),e.ray.intersectsSphere(Ed)!==!1&&(f_.copy(r).invert(),Ad.copy(e.ray).applyMatrix4(f_),!(this.boundingBox!==null&&Ad.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Ad)))}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 Zt,t=this.geometry.attributes.skinWeight;for(let i=0,r=t.count;i<r;i++){e.fromBufferAttribute(t,i);const a=1/e.manhattanLength();a!==1/0?e.multiplyScalar(a):e.set(1,0,0,0),t.setXYZW(i,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===gm?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===k1?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const i=this.skeleton,r=this.geometry;u_.fromBufferAttribute(r.attributes.skinIndex,e),d_.fromBufferAttribute(r.attributes.skinWeight,e),c_.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let a=0;a<4;a++){const s=d_.getComponent(a);if(s!==0){const l=u_.getComponent(a);p_.multiplyMatrices(i.bones[l].matrixWorld,i.boneInverses[l]),t.addScaledVector(AE.copy(c_).applyMatrix4(p_),s)}}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 m_ extends ei{constructor(){super(),this.isBone=!0,this.type="Bone"}}class CE extends Wi{constructor(e=null,t=1,i=1,r,a,s,l,h,c=zi,d=zi,p,f){super(null,s,l,h,c,d,r,a,p,f),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const g_=new Ze,LE=new Ze;class Rd{constructor(e=[],t=[]){this.uuid=Xr(),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 i=0,r=this.bones.length;i<r;i++)this.boneInverses.push(new Ze)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const i=new Ze;this.bones[e]&&i.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&i.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const i=this.bones[e];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let a=0,s=e.length;a<s;a++){const l=e[a]?e[a].matrixWorld:LE;g_.multiplyMatrices(l,t[a]),g_.toArray(i,a*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new Rd(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 i=new CE(t,e,e,Cr,Xn);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,r=e.bones.length;i<r;i++){const a=e.bones[i];let s=t[a];s===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",a),s=new m_),this.bones.push(s),this.boneInverses.push(new Ze().fromArray(e.boneInverses[i]))}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,i=this.boneInverses;for(let r=0,a=t.length;r<a;r++){const s=t[r];e.bones.push(s.uuid);const l=i[r];e.boneInverses.push(l.toArray())}return e}}class Cd extends mi{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}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 co=new Ze,__=new Ze,Qh=[],v_=new Fi,PE=new Ze,yl=new rt,xl=new Cn;class uo extends rt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Cd(new Float32Array(i*16),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<i;r++)this.setMatrixAt(r,PE)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new Fi),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,co),v_.copy(e.boundingBox).applyMatrix4(co),this.boundingBox.union(v_)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Cn),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,co),xl.copy(e.boundingSphere).applyMatrix4(co),this.boundingSphere.union(xl)}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 i=this.matrixWorld,r=this.count;if(yl.geometry=this.geometry,yl.material=this.material,yl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xl.copy(this.boundingSphere),xl.applyMatrix4(i),e.ray.intersectsSphere(xl)!==!1))for(let a=0;a<r;a++){this.getMatrixAt(a,co),__.multiplyMatrices(i,co),yl.matrixWorld=__,yl.raycast(e,Qh);for(let s=0,l=Qh.length;s<l;s++){const h=Qh[s];h.instanceId=a,h.object=this,t.push(h)}Qh.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Cd(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"})}}class po extends qr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ke(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 y_=new z,x_=new z,b_=new Ze,Ld=new is,ec=new Cn;class tc extends ei{constructor(e=new si,t=new po){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,i=[0];for(let r=1,a=t.count;r<a;r++)y_.fromBufferAttribute(t,r-1),x_.fromBufferAttribute(t,r),i[r]=i[r-1],i[r]+=y_.distanceTo(x_);e.setAttribute("lineDistance",new bi(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const i=this.geometry,r=this.matrixWorld,a=e.params.Line.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),ec.copy(i.boundingSphere),ec.applyMatrix4(r),ec.radius+=a,e.ray.intersectsSphere(ec)===!1)return;b_.copy(r).invert(),Ld.copy(e.ray).applyMatrix4(b_);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),h=l*l,c=new z,d=new z,p=new z,f=new z,m=this.isLineSegments?2:1,_=i.index,x=i.attributes.position;if(_!==null){const y=Math.max(0,s.start),v=Math.min(_.count,s.start+s.count);for(let M=y,b=v-1;M<b;M+=m){const S=_.getX(M),A=_.getX(M+1);if(c.fromBufferAttribute(x,S),d.fromBufferAttribute(x,A),Ld.distanceSqToSegment(c,d,f,p)>h)continue;f.applyMatrix4(this.matrixWorld);const T=e.ray.origin.distanceTo(f);T<e.near||T>e.far||t.push({distance:T,point:p.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}else{const y=Math.max(0,s.start),v=Math.min(x.count,s.start+s.count);for(let M=y,b=v-1;M<b;M+=m){if(c.fromBufferAttribute(x,M),d.fromBufferAttribute(x,M+1),Ld.distanceSqToSegment(c,d,f,p)>h)continue;f.applyMatrix4(this.matrixWorld);const S=e.ray.origin.distanceTo(f);S<e.near||S>e.far||t.push({distance:S,point:p.clone().applyMatrix4(this.matrixWorld),index:M,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}}const w_=new z,M_=new z;class Pd extends tc{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,i=[];for(let r=0,a=t.count;r<a;r+=2)w_.fromBufferAttribute(t,r),M_.fromBufferAttribute(t,r+1),i[r]=r===0?0:i[r-1],i[r+1]=i[r]+w_.distanceTo(M_);e.setAttribute("lineDistance",new bi(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class DE extends tc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class T_ extends qr{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ke(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 S_=new Ze,Dd=new is,ic=new Cn,rc=new z;class IE extends ei{constructor(e=new si,t=new T_){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 i=this.geometry,r=this.matrixWorld,a=e.params.Points.threshold,s=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),ic.copy(i.boundingSphere),ic.applyMatrix4(r),ic.radius+=a,e.ray.intersectsSphere(ic)===!1)return;S_.copy(r).invert(),Dd.copy(e.ray).applyMatrix4(S_);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),h=l*l,c=i.index,d=i.attributes.position;if(c!==null){const p=Math.max(0,s.start),f=Math.min(c.count,s.start+s.count);for(let m=p,_=f;m<_;m++){const x=c.getX(m);rc.fromBufferAttribute(d,x),E_(rc,x,h,r,e,t,this)}}else{const p=Math.max(0,s.start),f=Math.min(d.count,s.start+s.count);for(let m=p,_=f;m<_;m++)rc.fromBufferAttribute(d,m),E_(rc,m,h,r,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const i=e[t[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const s=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[s]=r}}}}}function E_(n,e,t,i,r,a,s){const l=Dd.distanceSqToPoint(n);if(l<t){const h=new z;Dd.closestPointToPoint(n,h),h.applyMatrix4(i);const c=r.ray.origin.distanceTo(h);if(c<r.near||c>r.far)return;a.push({distance:c,distanceToRay:Math.sqrt(l),point:h,index:e,face:null,object:s})}}class Pn{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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 i,r=this.getPoint(0),a=0;t.push(0);for(let s=1;s<=e;s++)i=this.getPoint(s/e),a+=i.distanceTo(r),t.push(a),r=i;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const i=this.getLengths();let r=0;const a=i.length;let s;t?s=t:s=e*i[a-1];let l=0,h=a-1,c;for(;l<=h;)if(r=Math.floor(l+(h-l)/2),c=i[r]-s,c<0)l=r+1;else if(c>0)h=r-1;else{h=r;break}if(r=h,i[r]===s)return r/(a-1);const d=i[r],p=i[r+1]-d,f=(s-d)/p;return(r+f)/(a-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),s=this.getPoint(r),l=t||(a.isVector2?new pe:new z);return l.copy(s).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){const i=new z,r=[],a=[],s=[],l=new z,h=new Ze;for(let m=0;m<=e;m++){const _=m/e;r[m]=this.getTangentAt(_,new z)}a[0]=new z,s[0]=new z;let c=Number.MAX_VALUE;const d=Math.abs(r[0].x),p=Math.abs(r[0].y),f=Math.abs(r[0].z);d<=c&&(c=d,i.set(1,0,0)),p<=c&&(c=p,i.set(0,1,0)),f<=c&&i.set(0,0,1),l.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],l),s[0].crossVectors(r[0],a[0]);for(let m=1;m<=e;m++){if(a[m]=a[m-1].clone(),s[m]=s[m-1].clone(),l.crossVectors(r[m-1],r[m]),l.length()>Number.EPSILON){l.normalize();const _=Math.acos(Ri(r[m-1].dot(r[m]),-1,1));a[m].applyMatrix4(h.makeRotationAxis(l,_))}s[m].crossVectors(r[m],a[m])}if(t===!0){let m=Math.acos(Ri(a[0].dot(a[e]),-1,1));m/=e,r[0].dot(l.crossVectors(a[0],a[e]))>0&&(m=-m);for(let _=1;_<=e;_++)a[_].applyMatrix4(h.makeRotationAxis(r[_],m*_)),s[_].crossVectors(r[_],a[_])}return{tangents:r,normals:a,binormals:s}}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 Id extends Pn{constructor(e=0,t=0,i=1,r=1,a=0,s=Math.PI*2,l=!1,h=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=a,this.aEndAngle=s,this.aClockwise=l,this.aRotation=h}getPoint(e,t){const i=t||new pe,r=Math.PI*2;let a=this.aEndAngle-this.aStartAngle;const s=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=r;for(;a>r;)a-=r;a<Number.EPSILON&&(s?a=0:a=r),this.aClockwise===!0&&!s&&(a===r?a=-r:a=a-r);const l=this.aStartAngle+e*a;let h=this.aX+this.xRadius*Math.cos(l),c=this.aY+this.yRadius*Math.sin(l);if(this.aRotation!==0){const d=Math.cos(this.aRotation),p=Math.sin(this.aRotation),f=h-this.aX,m=c-this.aY;h=f*d-m*p+this.aX,c=f*p+m*d+this.aY}return i.set(h,c)}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 OE extends Id{constructor(e,t,i,r,a,s){super(e,t,i,i,r,a,s),this.isArcCurve=!0,this.type="ArcCurve"}}function Od(){let n=0,e=0,t=0,i=0;function r(a,s,l,h){n=a,e=l,t=-3*a+3*s-2*l-h,i=2*a-2*s+l+h}return{initCatmullRom:function(a,s,l,h,c){r(s,l,c*(l-a),c*(h-s))},initNonuniformCatmullRom:function(a,s,l,h,c,d,p){let f=(s-a)/c-(l-a)/(c+d)+(l-s)/d,m=(l-s)/d-(h-s)/(d+p)+(h-l)/p;f*=d,m*=d,r(s,l,f,m)},calc:function(a){const s=a*a,l=s*a;return n+e*a+t*s+i*l}}}const nc=new z,Nd=new Od,Ud=new Od,zd=new Od;class NE extends Pn{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new z){const i=t,r=this.points,a=r.length,s=(a-(this.closed?0:1))*e;let l=Math.floor(s),h=s-l;this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/a)+1)*a:h===0&&l===a-1&&(l=a-2,h=1);let c,d;this.closed||l>0?c=r[(l-1)%a]:(nc.subVectors(r[0],r[1]).add(r[0]),c=nc);const p=r[l%a],f=r[(l+1)%a];if(this.closed||l+2<a?d=r[(l+2)%a]:(nc.subVectors(r[a-1],r[a-2]).add(r[a-1]),d=nc),this.curveType==="centripetal"||this.curveType==="chordal"){const m=this.curveType==="chordal"?.5:.25;let _=Math.pow(c.distanceToSquared(p),m),x=Math.pow(p.distanceToSquared(f),m),y=Math.pow(f.distanceToSquared(d),m);x<1e-4&&(x=1),_<1e-4&&(_=x),y<1e-4&&(y=x),Nd.initNonuniformCatmullRom(c.x,p.x,f.x,d.x,_,x,y),Ud.initNonuniformCatmullRom(c.y,p.y,f.y,d.y,_,x,y),zd.initNonuniformCatmullRom(c.z,p.z,f.z,d.z,_,x,y)}else this.curveType==="catmullrom"&&(Nd.initCatmullRom(c.x,p.x,f.x,d.x,this.tension),Ud.initCatmullRom(c.y,p.y,f.y,d.y,this.tension),zd.initCatmullRom(c.z,p.z,f.z,d.z,this.tension));return i.set(Nd.calc(h),Ud.calc(h),zd.calc(h)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.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,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.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,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new z().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function A_(n,e,t,i,r){const a=(i-e)*.5,s=(r-t)*.5,l=n*n,h=n*l;return(2*t-2*i+a+s)*h+(-3*t+3*i-2*a-s)*l+a*n+t}function UE(n,e){const t=1-n;return t*t*e}function zE(n,e){return 2*(1-n)*n*e}function BE(n,e){return n*n*e}function bl(n,e,t,i){return UE(n,e)+zE(n,t)+BE(n,i)}function FE(n,e){const t=1-n;return t*t*t*e}function kE(n,e){const t=1-n;return 3*t*t*n*e}function HE(n,e){return 3*(1-n)*n*n*e}function GE(n,e){return n*n*n*e}function wl(n,e,t,i,r){return FE(n,e)+kE(n,t)+HE(n,i)+GE(n,r)}class R_ extends Pn{constructor(e=new pe,t=new pe,i=new pe,r=new pe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new pe){const i=t,r=this.v0,a=this.v1,s=this.v2,l=this.v3;return i.set(wl(e,r.x,a.x,s.x,l.x),wl(e,r.y,a.y,s.y,l.y)),i}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 VE extends Pn{constructor(e=new z,t=new z,i=new z,r=new z){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new z){const i=t,r=this.v0,a=this.v1,s=this.v2,l=this.v3;return i.set(wl(e,r.x,a.x,s.x,l.x),wl(e,r.y,a.y,s.y,l.y),wl(e,r.z,a.z,s.z,l.z)),i}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 C_ extends Pn{constructor(e=new pe,t=new pe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new pe){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new pe){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 WE extends Pn{constructor(e=new z,t=new z){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new z){const i=t;return e===1?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new z){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 L_ extends Pn{constructor(e=new pe,t=new pe,i=new pe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new pe){const i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(bl(e,r.x,a.x,s.x),bl(e,r.y,a.y,s.y)),i}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 jE extends Pn{constructor(e=new z,t=new z,i=new z){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new z){const i=t,r=this.v0,a=this.v1,s=this.v2;return i.set(bl(e,r.x,a.x,s.x),bl(e,r.y,a.y,s.y),bl(e,r.z,a.z,s.z)),i}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 P_ extends Pn{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new pe){const i=t,r=this.points,a=(r.length-1)*e,s=Math.floor(a),l=a-s,h=r[s===0?s:s-1],c=r[s],d=r[s>r.length-2?r.length-1:s+1],p=r[s>r.length-3?r.length-1:s+2];return i.set(A_(l,h.x,c.x,d.x,p.x),A_(l,h.y,c.y,d.y,p.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){const r=e.points[t];this.points.push(new pe().fromArray(r))}return this}}var Bd=Object.freeze({__proto__:null,ArcCurve:OE,CatmullRomCurve3:NE,CubicBezierCurve:R_,CubicBezierCurve3:VE,EllipseCurve:Id,LineCurve:C_,LineCurve3:WE,QuadraticBezierCurve:L_,QuadraticBezierCurve3:jE,SplineCurve:P_});class XE extends Pn{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 i=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Bd[i](t,e))}return this}getPoint(e,t){const i=e*this.getLength(),r=this.getCurveLengths();let a=0;for(;a<r.length;){if(r[a]>=i){const s=r[a]-i,l=this.curves[a],h=l.getLength(),c=h===0?0:1-s/h;return l.getPointAt(c,t)}a++}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 i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let i;for(let r=0,a=this.curves;r<a.length;r++){const s=a[r],l=s.isEllipseCurve?e*2:s.isLineCurve||s.isLineCurve3?1:s.isSplineCurve?e*s.points.length:e,h=s.getPoints(l);for(let c=0;c<h.length;c++){const d=h[c];i&&i.equals(d)||(t.push(d),i=d)}}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,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){const r=e.curves[t];this.curves.push(new Bd[r.type]().fromJSON(r))}return this}}class D_ extends XE{constructor(e){super(),this.type="Path",this.currentPoint=new pe,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;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 i=new C_(this.currentPoint.clone(),new pe(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){const a=new L_(this.currentPoint.clone(),new pe(e,t),new pe(i,r));return this.curves.push(a),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,a,s){const l=new R_(this.currentPoint.clone(),new pe(e,t),new pe(i,r),new pe(a,s));return this.curves.push(l),this.currentPoint.set(a,s),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),i=new P_(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,a,s){const l=this.currentPoint.x,h=this.currentPoint.y;return this.absarc(e+l,t+h,i,r,a,s),this}absarc(e,t,i,r,a,s){return this.absellipse(e,t,i,i,r,a,s),this}ellipse(e,t,i,r,a,s,l,h){const c=this.currentPoint.x,d=this.currentPoint.y;return this.absellipse(e+c,t+d,i,r,a,s,l,h),this}absellipse(e,t,i,r,a,s,l,h){const c=new Id(e,t,i,r,a,s,l,h);if(this.curves.length>0){const p=c.getPoint(0);p.equals(this.currentPoint)||this.lineTo(p.x,p.y)}this.curves.push(c);const d=c.getPoint(1);return this.currentPoint.copy(d),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 ac extends si{constructor(e=1,t=1,i=1,r=32,a=1,s=!1,l=0,h=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:a,openEnded:s,thetaStart:l,thetaLength:h};const c=this;r=Math.floor(r),a=Math.floor(a);const d=[],p=[],f=[],m=[];let _=0;const x=[],y=i/2;let v=0;M(),s===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(d),this.setAttribute("position",new bi(p,3)),this.setAttribute("normal",new bi(f,3)),this.setAttribute("uv",new bi(m,2));function M(){const S=new z,A=new z;let T=0;const E=(t-e)/i;for(let I=0;I<=a;I++){const C=[],P=I/a,X=P*(t-e)+e;for(let q=0;q<=r;q++){const te=q/r,k=te*h+l,H=Math.sin(k),V=Math.cos(k);A.x=X*H,A.y=-P*i+y,A.z=X*V,p.push(A.x,A.y,A.z),S.set(H,E,V).normalize(),f.push(S.x,S.y,S.z),m.push(te,1-P),C.push(_++)}x.push(C)}for(let I=0;I<r;I++)for(let C=0;C<a;C++){const P=x[C][I],X=x[C+1][I],q=x[C+1][I+1],te=x[C][I+1];d.push(P,X,te),d.push(X,q,te),T+=6}c.addGroup(v,T,0),v+=T}function b(S){const A=_,T=new pe,E=new z;let I=0;const C=S===!0?e:t,P=S===!0?1:-1;for(let q=1;q<=r;q++)p.push(0,y*P,0),f.push(0,P,0),m.push(.5,.5),_++;const X=_;for(let q=0;q<=r;q++){const te=q/r*h+l,k=Math.cos(te),H=Math.sin(te);E.x=C*H,E.y=y*P,E.z=C*k,p.push(E.x,E.y,E.z),f.push(0,P,0),T.x=k*.5+.5,T.y=H*.5*P+.5,m.push(T.x,T.y),_++}for(let q=0;q<r;q++){const te=A+q,k=X+q;S===!0?d.push(k,k+1,te):d.push(k+1,k,te),I+=3}c.addGroup(v,I,S===!0?1:2),v+=I}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ac(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fd extends ac{constructor(e=1,t=1,i=32,r=1,a=!1,s=0,l=Math.PI*2){super(0,e,t,i,r,a,s,l),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:l}}static fromJSON(e){return new Fd(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class fo extends D_{constructor(e){super(e),this.uuid=Xr(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].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,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){const r=e.holes[t];this.holes.push(new D_().fromJSON(r))}return this}}const qE={triangulate:function(n,e,t=2){const i=e&&e.length,r=i?e[0]*t:n.length;let a=I_(n,0,r,t,!0);const s=[];if(!a||a.next===a.prev)return s;let l,h,c,d,p,f,m;if(i&&(a=$E(n,e,a,t)),n.length>80*t){l=c=n[0],h=d=n[1];for(let _=t;_<r;_+=t)p=n[_],f=n[_+1],p<l&&(l=p),f<h&&(h=f),p>c&&(c=p),f>d&&(d=f);m=Math.max(c-l,d-h),m=m!==0?32767/m:0}return Ml(a,s,t,l,h,m,0),s}};function I_(n,e,t,i,r){let a,s;if(r===hA(n,e,t,i)>0)for(a=e;a<t;a+=i)s=U_(a,n[a],n[a+1],s);else for(a=t-i;a>=e;a-=i)s=U_(a,n[a],n[a+1],s);return s&&sc(s,s.next)&&(Sl(s),s=s.next),s}function ls(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(sc(t,t.next)||hi(t.prev,t,t.next)===0)){if(Sl(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Ml(n,e,t,i,r,a,s){if(!n)return;!s&&a&&rA(n,i,r,a);let l=n,h,c;for(;n.prev!==n.next;){if(h=n.prev,c=n.next,a?KE(n,i,r,a):YE(n)){e.push(h.i/t|0),e.push(n.i/t|0),e.push(c.i/t|0),Sl(n),n=c.next,l=c.next;continue}if(n=c,n===l){s?s===1?(n=ZE(ls(n),e,t),Ml(n,e,t,i,r,a,2)):s===2&&JE(n,e,t,i,r,a):Ml(ls(n),e,t,i,r,a,1);break}}}function YE(n){const e=n.prev,t=n,i=n.next;if(hi(e,t,i)>=0)return!1;const r=e.x,a=t.x,s=i.x,l=e.y,h=t.y,c=i.y,d=r<a?r<s?r:s:a<s?a:s,p=l<h?l<c?l:c:h<c?h:c,f=r>a?r>s?r:s:a>s?a:s,m=l>h?l>c?l:c:h>c?h:c;let _=i.next;for(;_!==e;){if(_.x>=d&&_.x<=f&&_.y>=p&&_.y<=m&&mo(r,l,a,h,s,c,_.x,_.y)&&hi(_.prev,_,_.next)>=0)return!1;_=_.next}return!0}function KE(n,e,t,i){const r=n.prev,a=n,s=n.next;if(hi(r,a,s)>=0)return!1;const l=r.x,h=a.x,c=s.x,d=r.y,p=a.y,f=s.y,m=l<h?l<c?l:c:h<c?h:c,_=d<p?d<f?d:f:p<f?p:f,x=l>h?l>c?l:c:h>c?h:c,y=d>p?d>f?d:f:p>f?p:f,v=kd(m,_,e,t,i),M=kd(x,y,e,t,i);let b=n.prevZ,S=n.nextZ;for(;b&&b.z>=v&&S&&S.z<=M;){if(b.x>=m&&b.x<=x&&b.y>=_&&b.y<=y&&b!==r&&b!==s&&mo(l,d,h,p,c,f,b.x,b.y)&&hi(b.prev,b,b.next)>=0||(b=b.prevZ,S.x>=m&&S.x<=x&&S.y>=_&&S.y<=y&&S!==r&&S!==s&&mo(l,d,h,p,c,f,S.x,S.y)&&hi(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;b&&b.z>=v;){if(b.x>=m&&b.x<=x&&b.y>=_&&b.y<=y&&b!==r&&b!==s&&mo(l,d,h,p,c,f,b.x,b.y)&&hi(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;S&&S.z<=M;){if(S.x>=m&&S.x<=x&&S.y>=_&&S.y<=y&&S!==r&&S!==s&&mo(l,d,h,p,c,f,S.x,S.y)&&hi(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function ZE(n,e,t){let i=n;do{const r=i.prev,a=i.next.next;!sc(r,a)&&O_(r,i,i.next,a)&&Tl(r,a)&&Tl(a,r)&&(e.push(r.i/t|0),e.push(i.i/t|0),e.push(a.i/t|0),Sl(i),Sl(i.next),i=n=a),i=i.next}while(i!==n);return ls(i)}function JE(n,e,t,i,r,a){let s=n;do{let l=s.next.next;for(;l!==s.prev;){if(s.i!==l.i&&sA(s,l)){let h=N_(s,l);s=ls(s,s.next),h=ls(h,h.next),Ml(s,e,t,i,r,a,0),Ml(h,e,t,i,r,a,0);return}l=l.next}s=s.next}while(s!==n)}function $E(n,e,t,i){const r=[];let a,s,l,h,c;for(a=0,s=e.length;a<s;a++)l=e[a]*i,h=a<s-1?e[a+1]*i:n.length,c=I_(n,l,h,i,!1),c===c.next&&(c.steiner=!0),r.push(aA(c));for(r.sort(QE),a=0;a<r.length;a++)t=eA(r[a],t);return t}function QE(n,e){return n.x-e.x}function eA(n,e){const t=tA(n,e);if(!t)return e;const i=N_(t,n);return ls(i,i.next),ls(t,t.next)}function tA(n,e){let t=e,i=-1/0,r;const a=n.x,s=n.y;do{if(s<=t.y&&s>=t.next.y&&t.next.y!==t.y){const f=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=a&&f>i&&(i=f,r=t.x<t.next.x?t:t.next,f===a))return r}t=t.next}while(t!==e);if(!r)return null;const l=r,h=r.x,c=r.y;let d=1/0,p;t=r;do a>=t.x&&t.x>=h&&a!==t.x&&mo(s<c?a:i,s,h,c,s<c?i:a,s,t.x,t.y)&&(p=Math.abs(s-t.y)/(a-t.x),Tl(t,n)&&(p<d||p===d&&(t.x>r.x||t.x===r.x&&iA(r,t)))&&(r=t,d=p)),t=t.next;while(t!==l);return r}function iA(n,e){return hi(n.prev,n,e.prev)<0&&hi(e.next,n,n.next)<0}function rA(n,e,t,i){let r=n;do r.z===0&&(r.z=kd(r.x,r.y,e,t,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==n);r.prevZ.nextZ=null,r.prevZ=null,nA(r)}function nA(n){let e,t,i,r,a,s,l,h,c=1;do{for(t=n,n=null,a=null,s=0;t;){for(s++,i=t,l=0,e=0;e<c&&(l++,i=i.nextZ,!!i);e++);for(h=c;l>0||h>0&&i;)l!==0&&(h===0||!i||t.z<=i.z)?(r=t,t=t.nextZ,l--):(r=i,i=i.nextZ,h--),a?a.nextZ=r:n=r,r.prevZ=a,a=r;t=i}a.nextZ=null,c*=2}while(s>1);return n}function kd(n,e,t,i,r){return n=(n-t)*r|0,e=(e-i)*r|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function aA(n){let e=n,t=n;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==n);return t}function mo(n,e,t,i,r,a,s,l){return(r-s)*(e-l)>=(n-s)*(a-l)&&(n-s)*(i-l)>=(t-s)*(e-l)&&(t-s)*(a-l)>=(r-s)*(i-l)}function sA(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!oA(n,e)&&(Tl(n,e)&&Tl(e,n)&&lA(n,e)&&(hi(n.prev,n,e.prev)||hi(n,e.prev,e))||sc(n,e)&&hi(n.prev,n,n.next)>0&&hi(e.prev,e,e.next)>0)}function hi(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function sc(n,e){return n.x===e.x&&n.y===e.y}function O_(n,e,t,i){const r=lc(hi(n,e,t)),a=lc(hi(n,e,i)),s=lc(hi(t,i,n)),l=lc(hi(t,i,e));return!!(r!==a&&s!==l||r===0&&oc(n,t,e)||a===0&&oc(n,i,e)||s===0&&oc(t,n,i)||l===0&&oc(t,e,i))}function oc(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function lc(n){return n>0?1:n<0?-1:0}function oA(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&O_(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Tl(n,e){return hi(n.prev,n,n.next)<0?hi(n,e,n.next)>=0&&hi(n,n.prev,e)>=0:hi(n,e,n.prev)<0||hi(n,n.next,e)<0}function lA(n,e){let t=n,i=!1;const r=(n.x+e.x)/2,a=(n.y+e.y)/2;do t.y>a!=t.next.y>a&&t.next.y!==t.y&&r<(t.next.x-t.x)*(a-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function N_(n,e){const t=new Hd(n.i,n.x,n.y),i=new Hd(e.i,e.x,e.y),r=n.next,a=e.prev;return n.next=e,e.prev=n,t.next=r,r.prev=t,i.next=t,t.prev=i,a.next=i,i.prev=a,i}function U_(n,e,t,i){const r=new Hd(n,e,t);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Sl(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Hd(n,e,t){this.i=n,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 hA(n,e,t,i){let r=0;for(let a=e,s=t-i;a<t;a+=i)r+=(n[s]-n[a])*(n[a+1]+n[s+1]),s=a;return r}class El{static area(e){const t=e.length;let i=0;for(let r=t-1,a=0;a<t;r=a++)i+=e[r].x*e[a].y-e[a].x*e[r].y;return i*.5}static isClockWise(e){return El.area(e)<0}static triangulateShape(e,t){const i=[],r=[],a=[];z_(e),B_(i,e);let s=e.length;t.forEach(z_);for(let h=0;h<t.length;h++)r.push(s),s+=t[h].length,B_(i,t[h]);const l=qE.triangulate(i,r);for(let h=0;h<l.length;h+=3)a.push(l.slice(h,h+3));return a}}function z_(n){const e=n.length;e>2&&n[e-1].equals(n[0])&&n.pop()}function B_(n,e){for(let t=0;t<e.length;t++)n.push(e[t].x),n.push(e[t].y)}class go extends si{constructor(e=new fo([new pe(.5,.5),new pe(-.5,.5),new pe(-.5,-.5),new pe(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],a=[];for(let l=0,h=e.length;l<h;l++){const c=e[l];s(c)}this.setAttribute("position",new bi(r,3)),this.setAttribute("uv",new bi(a,2)),this.computeVertexNormals();function s(l){const h=[],c=t.curveSegments!==void 0?t.curveSegments:12,d=t.steps!==void 0?t.steps:1,p=t.depth!==void 0?t.depth:1;let f=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,_=t.bevelSize!==void 0?t.bevelSize:m-.1,x=t.bevelOffset!==void 0?t.bevelOffset:0,y=t.bevelSegments!==void 0?t.bevelSegments:3;const v=t.extrudePath,M=t.UVGenerator!==void 0?t.UVGenerator:cA;let b,S=!1,A,T,E,I;v&&(b=v.getSpacedPoints(d),S=!0,f=!1,A=v.computeFrenetFrames(d,!1),T=new z,E=new z,I=new z),f||(y=0,m=0,_=0,x=0);const C=l.extractPoints(c);let P=C.shape;const X=C.holes;if(!El.isClockWise(P)){P=P.reverse();for(let ge=0,G=X.length;ge<G;ge++){const Ae=X[ge];El.isClockWise(Ae)&&(X[ge]=Ae.reverse())}}const q=El.triangulateShape(P,X),te=P;for(let ge=0,G=X.length;ge<G;ge++){const Ae=X[ge];P=P.concat(Ae)}function k(ge,G,Ae){return G||console.error("THREE.ExtrudeGeometry: vec does not exist"),ge.clone().addScaledVector(G,Ae)}const H=P.length,V=q.length;function J(ge,G,Ae){let ue,de,Ee;const Fe=ge.x-G.x,ke=ge.y-G.y,N=Ae.x-ge.x,L=Ae.y-ge.y,Z=Fe*Fe+ke*ke,xe=Fe*L-ke*N;if(Math.abs(xe)>Number.EPSILON){const fe=Math.sqrt(Z),Se=Math.sqrt(N*N+L*L),He=G.x-ke/fe,Ie=G.y+Fe/fe,Ue=Ae.x-L/Se,Ge=Ae.y+N/Se,Je=((Ue-He)*L-(Ge-Ie)*N)/(Fe*L-ke*N);ue=He+Fe*Je-ge.x,de=Ie+ke*Je-ge.y;const be=ue*ue+de*de;if(be<=2)return new pe(ue,de);Ee=Math.sqrt(be/2)}else{let fe=!1;Fe>Number.EPSILON?N>Number.EPSILON&&(fe=!0):Fe<-Number.EPSILON?N<-Number.EPSILON&&(fe=!0):Math.sign(ke)===Math.sign(L)&&(fe=!0),fe?(ue=-ke,de=Fe,Ee=Math.sqrt(Z)):(ue=Fe,de=ke,Ee=Math.sqrt(Z/2))}return new pe(ue/Ee,de/Ee)}const ie=[];for(let ge=0,G=te.length,Ae=G-1,ue=ge+1;ge<G;ge++,Ae++,ue++)Ae===G&&(Ae=0),ue===G&&(ue=0),ie[ge]=J(te[ge],te[Ae],te[ue]);const $=[];let ne,he=ie.concat();for(let ge=0,G=X.length;ge<G;ge++){const Ae=X[ge];ne=[];for(let ue=0,de=Ae.length,Ee=de-1,Fe=ue+1;ue<de;ue++,Ee++,Fe++)Ee===de&&(Ee=0),Fe===de&&(Fe=0),ne[ue]=J(Ae[ue],Ae[Ee],Ae[Fe]);$.push(ne),he=he.concat(ne)}for(let ge=0;ge<y;ge++){const G=ge/y,Ae=m*Math.cos(G*Math.PI/2),ue=_*Math.sin(G*Math.PI/2)+x;for(let de=0,Ee=te.length;de<Ee;de++){const Fe=k(te[de],ie[de],ue);Be(Fe.x,Fe.y,-Ae)}for(let de=0,Ee=X.length;de<Ee;de++){const Fe=X[de];ne=$[de];for(let ke=0,N=Fe.length;ke<N;ke++){const L=k(Fe[ke],ne[ke],ue);Be(L.x,L.y,-Ae)}}}const De=_+x;for(let ge=0;ge<H;ge++){const G=f?k(P[ge],he[ge],De):P[ge];S?(E.copy(A.normals[0]).multiplyScalar(G.x),T.copy(A.binormals[0]).multiplyScalar(G.y),I.copy(b[0]).add(E).add(T),Be(I.x,I.y,I.z)):Be(G.x,G.y,0)}for(let ge=1;ge<=d;ge++)for(let G=0;G<H;G++){const Ae=f?k(P[G],he[G],De):P[G];S?(E.copy(A.normals[ge]).multiplyScalar(Ae.x),T.copy(A.binormals[ge]).multiplyScalar(Ae.y),I.copy(b[ge]).add(E).add(T),Be(I.x,I.y,I.z)):Be(Ae.x,Ae.y,p/d*ge)}for(let ge=y-1;ge>=0;ge--){const G=ge/y,Ae=m*Math.cos(G*Math.PI/2),ue=_*Math.sin(G*Math.PI/2)+x;for(let de=0,Ee=te.length;de<Ee;de++){const Fe=k(te[de],ie[de],ue);Be(Fe.x,Fe.y,p+Ae)}for(let de=0,Ee=X.length;de<Ee;de++){const Fe=X[de];ne=$[de];for(let ke=0,N=Fe.length;ke<N;ke++){const L=k(Fe[ke],ne[ke],ue);S?Be(L.x,L.y+b[d-1].y,b[d-1].x+Ae):Be(L.x,L.y,p+Ae)}}}ee(),ce();function ee(){const ge=r.length/3;if(f){let G=0,Ae=H*G;for(let ue=0;ue<V;ue++){const de=q[ue];je(de[2]+Ae,de[1]+Ae,de[0]+Ae)}G=d+y*2,Ae=H*G;for(let ue=0;ue<V;ue++){const de=q[ue];je(de[0]+Ae,de[1]+Ae,de[2]+Ae)}}else{for(let G=0;G<V;G++){const Ae=q[G];je(Ae[2],Ae[1],Ae[0])}for(let G=0;G<V;G++){const Ae=q[G];je(Ae[0]+H*d,Ae[1]+H*d,Ae[2]+H*d)}}i.addGroup(ge,r.length/3-ge,0)}function ce(){const ge=r.length/3;let G=0;Te(te,G),G+=te.length;for(let Ae=0,ue=X.length;Ae<ue;Ae++){const de=X[Ae];Te(de,G),G+=de.length}i.addGroup(ge,r.length/3-ge,1)}function Te(ge,G){let Ae=ge.length;for(;--Ae>=0;){const ue=Ae;let de=Ae-1;de<0&&(de=ge.length-1);for(let Ee=0,Fe=d+y*2;Ee<Fe;Ee++){const ke=H*Ee,N=H*(Ee+1),L=G+ue+ke,Z=G+de+ke,xe=G+de+N,fe=G+ue+N;$e(L,Z,xe,fe)}}}function Be(ge,G,Ae){h.push(ge),h.push(G),h.push(Ae)}function je(ge,G,Ae){qe(ge),qe(G),qe(Ae);const ue=r.length/3,de=M.generateTopUV(i,r,ue-3,ue-2,ue-1);Xe(de[0]),Xe(de[1]),Xe(de[2])}function $e(ge,G,Ae,ue){qe(ge),qe(G),qe(ue),qe(G),qe(Ae),qe(ue);const de=r.length/3,Ee=M.generateSideWallUV(i,r,de-6,de-3,de-2,de-1);Xe(Ee[0]),Xe(Ee[1]),Xe(Ee[3]),Xe(Ee[1]),Xe(Ee[2]),Xe(Ee[3])}function qe(ge){r.push(h[ge*3+0]),r.push(h[ge*3+1]),r.push(h[ge*3+2])}function Xe(ge){a.push(ge.x),a.push(ge.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,i=this.parameters.options;return uA(t,i,e)}static fromJSON(e,t){const i=[];for(let a=0,s=e.shapes.length;a<s;a++){const l=t[e.shapes[a]];i.push(l)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Bd[r.type]().fromJSON(r)),new go(i,e.options)}}const cA={generateTopUV:function(n,e,t,i,r){const a=e[t*3],s=e[t*3+1],l=e[i*3],h=e[i*3+1],c=e[r*3],d=e[r*3+1];return[new pe(a,s),new pe(l,h),new pe(c,d)]},generateSideWallUV:function(n,e,t,i,r,a){const s=e[t*3],l=e[t*3+1],h=e[t*3+2],c=e[i*3],d=e[i*3+1],p=e[i*3+2],f=e[r*3],m=e[r*3+1],_=e[r*3+2],x=e[a*3],y=e[a*3+1],v=e[a*3+2];return Math.abs(l-d)<Math.abs(s-c)?[new pe(s,1-h),new pe(c,1-p),new pe(f,1-_),new pe(x,1-v)]:[new pe(l,1-h),new pe(d,1-p),new pe(m,1-_),new pe(y,1-v)]}};function uA(n,e,t){if(t.shapes=[],Array.isArray(n))for(let i=0,r=n.length;i<r;i++){const a=n[i];t.shapes.push(a.uuid)}else t.shapes.push(n.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class ta extends qr{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ke(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 Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xh,this.normalScale=new pe(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 Dn extends ta{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 pe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ri(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 Ke(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 Ke(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ke(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 Gd extends qr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ke(16777215),this.specular=new Ke(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xh,this.normalScale=new pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=gh,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 wi extends qr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ke(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ke(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=xh,this.normalScale=new pe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=gh,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}}function hc(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function dA(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function pA(n){function e(r,a){return n[r]-n[a]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function F_(n,e,t){const i=n.length,r=new n.constructor(i);for(let a=0,s=0;s!==i;++a){const l=t[a]*e;for(let h=0;h!==e;++h)r[s++]=n[l+h]}return r}function k_(n,e,t,i){let r=1,a=n[0];for(;a!==void 0&&a[i]===void 0;)a=n[r++];if(a===void 0)return;let s=a[i];if(s!==void 0)if(Array.isArray(s))do s=a[i],s!==void 0&&(e.push(a.time),t.push.apply(t,s)),a=n[r++];while(a!==void 0);else if(s.toArray!==void 0)do s=a[i],s!==void 0&&(e.push(a.time),s.toArray(t,t.length)),a=n[r++];while(a!==void 0);else do s=a[i],s!==void 0&&(e.push(a.time),t.push(s)),a=n[r++];while(a!==void 0)}class Al{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],a=t[i-1];e:{t:{let s;i:{r:if(!(e<r)){for(let l=i+2;;){if(r===void 0){if(e<a)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===l)break;if(a=r,r=t[++i],e<r)break t}s=t.length;break i}if(!(e>=a)){const l=t[1];e<l&&(i=2,a=l);for(let h=i-2;;){if(a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===h)break;if(r=a,a=t[--i-1],e>=a)break t}s=i,i=0;break i}break e}for(;i<s;){const l=i+s>>>1;e<t[l]?s=l:i=l+1}if(r=t[i],a=t[i-1],a===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,a,r)}return this.interpolate_(i,a,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r;for(let s=0;s!==r;++s)t[s]=i[a+s];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class fA extends Al{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Jm,endingEnd:Jm}}intervalChanged_(e,t,i){const r=this.parameterPositions;let a=e-2,s=e+1,l=r[a],h=r[s];if(l===void 0)switch(this.getSettings_().endingStart){case $m:a=e,l=2*t-i;break;case Qm:a=r.length-2,l=t+r[a]-r[a+1];break;default:a=e,l=i}if(h===void 0)switch(this.getSettings_().endingEnd){case $m:s=e,h=2*i-t;break;case Qm:s=1,h=i+r[1]-r[0];break;default:s=e-1,h=t}const c=(i-t)*.5,d=this.valueSize;this._weightPrev=c/(t-l),this._weightNext=c/(h-i),this._offsetPrev=a*d,this._offsetNext=s*d}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,l=this.valueSize,h=e*l,c=h-l,d=this._offsetPrev,p=this._offsetNext,f=this._weightPrev,m=this._weightNext,_=(i-t)/(r-t),x=_*_,y=x*_,v=-f*y+2*f*x-f*_,M=(1+f)*y+(-1.5-2*f)*x+(-.5+f)*_+1,b=(-1-m)*y+(1.5+m)*x+.5*_,S=m*y-m*x;for(let A=0;A!==l;++A)a[A]=v*s[d+A]+M*s[c+A]+b*s[h+A]+S*s[p+A];return a}}class mA extends Al{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,l=this.valueSize,h=e*l,c=h-l,d=(i-t)/(r-t),p=1-d;for(let f=0;f!==l;++f)a[f]=s[c+f]*p+s[h+f]*d;return a}}class gA extends Al{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class In{constructor(e,t,i,r){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=hc(t,this.TimeBufferType),this.values=hc(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let i;if(t.toJSON!==this.toJSON)i=t.toJSON(e);else{i={name:e.name,times:hc(e.times,Array),values:hc(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(i.interpolation=r)}return i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new gA(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new mA(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new fA(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case hl:t=this.InterpolantFactoryMethodDiscrete;break;case Hs:t=this.InterpolantFactoryMethodLinear;break;case Vu:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const i="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(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return hl;case this.InterpolantFactoryMethodLinear:return Hs;case this.InterpolantFactoryMethodSmooth:return Vu}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){const i=this.times,r=i.length;let a=0,s=r-1;for(;a!==r&&i[a]<e;)++a;for(;s!==-1&&i[s]>t;)--s;if(++s,a!==0||s!==r){a>=s&&(s=Math.max(s,1),a=s-1);const l=this.getValueSize();this.times=i.slice(a,s),this.values=this.values.slice(a*l,s*l)}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 i=this.times,r=this.values,a=i.length;a===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let l=0;l!==a;l++){const h=i[l];if(typeof h=="number"&&isNaN(h)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,l,h),e=!1;break}if(s!==null&&s>h){console.error("THREE.KeyframeTrack: Out of order keys.",this,l,h,s),e=!1;break}s=h}if(r!==void 0&&dA(r))for(let l=0,h=r.length;l!==h;++l){const c=r[l];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,l,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Vu,a=e.length-1;let s=1;for(let l=1;l<a;++l){let h=!1;const c=e[l],d=e[l+1];if(c!==d&&(l!==1||c!==e[0]))if(r)h=!0;else{const p=l*i,f=p-i,m=p+i;for(let _=0;_!==i;++_){const x=t[p+_];if(x!==t[f+_]||x!==t[m+_]){h=!0;break}}}if(h){if(l!==s){e[s]=e[l];const p=l*i,f=s*i;for(let m=0;m!==i;++m)t[f+m]=t[p+m]}++s}}if(a>0){e[s]=e[a];for(let l=a*i,h=s*i,c=0;c!==i;++c)t[h+c]=t[l+c];++s}return s!==e.length?(this.times=e.slice(0,s),this.values=t.slice(0,s*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}In.prototype.TimeBufferType=Float32Array,In.prototype.ValueBufferType=Float32Array,In.prototype.DefaultInterpolation=Hs;class _o extends In{}_o.prototype.ValueTypeName="bool",_o.prototype.ValueBufferType=Array,_o.prototype.DefaultInterpolation=hl,_o.prototype.InterpolantFactoryMethodLinear=void 0,_o.prototype.InterpolantFactoryMethodSmooth=void 0;class H_ extends In{}H_.prototype.ValueTypeName="color";class vo extends In{}vo.prototype.ValueTypeName="number";class _A extends Al{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,l=this.valueSize,h=(i-t)/(r-t);let c=e*l;for(let d=c+l;c!==d;c+=4)Rn.slerpFlat(a,0,s,c-l,s,c,h);return a}}class hs extends In{InterpolantFactoryMethodLinear(e){return new _A(this.times,this.values,this.getValueSize(),e)}}hs.prototype.ValueTypeName="quaternion",hs.prototype.DefaultInterpolation=Hs,hs.prototype.InterpolantFactoryMethodSmooth=void 0;class yo extends In{}yo.prototype.ValueTypeName="string",yo.prototype.ValueBufferType=Array,yo.prototype.DefaultInterpolation=hl,yo.prototype.InterpolantFactoryMethodLinear=void 0,yo.prototype.InterpolantFactoryMethodSmooth=void 0;class xo extends In{}xo.prototype.ValueTypeName="vector";class vA{constructor(e,t=-1,i,r=K1){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=Xr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let s=0,l=i.length;s!==l;++s)t.push(xA(i[s]).scale(r));const a=new this(e.name,e.duration,t,e.blendMode);return a.uuid=e.uuid,a}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let a=0,s=i.length;a!==s;++a)t.push(In.toJSON(i[a]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const a=t.length,s=[];for(let l=0;l<a;l++){let h=[],c=[];h.push((l+a-1)%a,l,(l+1)%a),c.push(0,1,0);const d=pA(h);h=F_(h,1,d),c=F_(c,1,d),!r&&h[0]===0&&(h.push(a),c.push(c[0])),s.push(new vo(".morphTargetInfluences["+t[l].name+"]",h,c).scale(1/i))}return new this(e,-1,s)}static findByName(e,t){let i=e;if(!Array.isArray(e)){const r=e;i=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<i.length;r++)if(i[r].name===t)return i[r];return null}static CreateClipsFromMorphTargetSequences(e,t,i){const r={},a=/^([\w-]*?)([\d]+)$/;for(let l=0,h=e.length;l<h;l++){const c=e[l],d=c.name.match(a);if(d&&d.length>1){const p=d[1];let f=r[p];f||(r[p]=f=[]),f.push(c)}}const s=[];for(const l in r)s.push(this.CreateFromMorphTargetSequence(l,r[l],t,i));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(d,p,f,m,_){if(f.length!==0){const x=[],y=[];k_(f,x,y,m),x.length!==0&&_.push(new d(p,x,y))}},r=[],a=e.name||"default",s=e.fps||30,l=e.blendMode;let h=e.length||-1;const c=e.hierarchy||[];for(let d=0;d<c.length;d++){const p=c[d].keys;if(!(!p||p.length===0))if(p[0].morphTargets){const f={};let m;for(m=0;m<p.length;m++)if(p[m].morphTargets)for(let _=0;_<p[m].morphTargets.length;_++)f[p[m].morphTargets[_]]=-1;for(const _ in f){const x=[],y=[];for(let v=0;v!==p[m].morphTargets.length;++v){const M=p[m];x.push(M.time),y.push(M.morphTarget===_?1:0)}r.push(new vo(".morphTargetInfluence["+_+"]",x,y))}h=f.length*s}else{const f=".bones["+t[d].name+"]";i(xo,f+".position",p,"pos",r),i(hs,f+".quaternion",p,"rot",r),i(xo,f+".scale",p,"scl",r)}}return r.length===0?null:new this(a,h,r,l)}resetDuration(){const e=this.tracks;let t=0;for(let i=0,r=e.length;i!==r;++i){const a=this.tracks[i];t=Math.max(t,a.times[a.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 yA(n){switch(n.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return vo;case"vector":case"vector2":case"vector3":case"vector4":return xo;case"color":return H_;case"quaternion":return hs;case"bool":case"boolean":return _o;case"string":return yo}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+n)}function xA(n){if(n.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=yA(n.type);if(n.times===void 0){const t=[],i=[];k_(n.keys,t,i,"value"),n.times=t,n.values=i}return e.parse!==void 0?e.parse(n):new e(n.name,n.times,n.values,n.interpolation)}const Ea={enabled:!1,files:{},add:function(n,e){this.enabled!==!1&&(this.files[n]=e)},get:function(n){if(this.enabled!==!1)return this.files[n]},remove:function(n){delete this.files[n]},clear:function(){this.files={}}};class bA{constructor(e,t,i){const r=this;let a=!1,s=0,l=0,h;const c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(d){l++,a===!1&&r.onStart!==void 0&&r.onStart(d,s,l),a=!0},this.itemEnd=function(d){s++,r.onProgress!==void 0&&r.onProgress(d,s,l),s===l&&(a=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(d){r.onError!==void 0&&r.onError(d)},this.resolveURL=function(d){return h?h(d):d},this.setURLModifier=function(d){return h=d,this},this.addHandler=function(d,p){return c.push(d,p),this},this.removeHandler=function(d){const p=c.indexOf(d);return p!==-1&&c.splice(p,2),this},this.getHandler=function(d){for(let p=0,f=c.length;p<f;p+=2){const m=c[p],_=c[p+1];if(m.global&&(m.lastIndex=0),m.test(d))return _}return null}}}const wA=new bA;class bo{constructor(e){this.manager=e!==void 0?e:wA,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,a){i.load(e,r,t,a)})}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}}bo.DEFAULT_MATERIAL_NAME="__DEFAULT";const ia={};class MA extends Error{constructor(e,t){super(e),this.response=t}}class G_ extends bo{constructor(e){super(e)}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=Ea.get(e);if(a!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(a),this.manager.itemEnd(e)},0),a;if(ia[e]!==void 0){ia[e].push({onLoad:t,onProgress:i,onError:r});return}ia[e]=[],ia[e].push({onLoad:t,onProgress:i,onError:r});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),l=this.mimeType,h=this.responseType;fetch(s).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const d=ia[e],p=c.body.getReader(),f=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),m=f?parseInt(f):0,_=m!==0;let x=0;const y=new ReadableStream({start(v){M();function M(){p.read().then(({done:b,value:S})=>{if(b)v.close();else{x+=S.byteLength;const A=new ProgressEvent("progress",{lengthComputable:_,loaded:x,total:m});for(let T=0,E=d.length;T<E;T++){const I=d[T];I.onProgress&&I.onProgress(A)}v.enqueue(S),M()}})}}});return new Response(y)}else throw new MA(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(h){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(d=>new DOMParser().parseFromString(d,l));case"json":return c.json();default:if(l===void 0)return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(l),p=d&&d[1]?d[1].toLowerCase():void 0,f=new TextDecoder(p);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{Ea.add(e,c);const d=ia[e];delete ia[e];for(let p=0,f=d.length;p<f;p++){const m=d[p];m.onLoad&&m.onLoad(c)}}).catch(c=>{const d=ia[e];if(d===void 0)throw this.manager.itemError(e),c;delete ia[e];for(let p=0,f=d.length;p<f;p++){const m=d[p];m.onError&&m.onError(c)}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 TA extends bo{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,s=Ea.get(e);if(s!==void 0)return a.manager.itemStart(e),setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0),s;const l=pl("img");function h(){d(),Ea.add(e,this),t&&t(this),a.manager.itemEnd(e)}function c(p){d(),r&&r(p),a.manager.itemError(e),a.manager.itemEnd(e)}function d(){l.removeEventListener("load",h,!1),l.removeEventListener("error",c,!1)}return l.addEventListener("load",h,!1),l.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(l.crossOrigin=this.crossOrigin),a.manager.itemStart(e),l.src=e,l}}class V_ extends bo{constructor(e){super(e)}load(e,t,i,r){const a=new Wi,s=new TA(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,function(l){a.image=l,a.needsUpdate=!0,t!==void 0&&t(a)},i,r),a}}let cc=class extends ei{constructor(n,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ke(n),this.intensity=e}dispose(){}copy(n,e){return super.copy(n,e),this.color.copy(n.color),this.intensity=n.intensity,this}toJSON(n){const e=super.toJSON(n);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}};const Vd=new Ze,W_=new z,j_=new z;class Wd{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new pe(512,512),this.map=null,this.mapPass=null,this.matrix=new Ze,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new md,this._frameExtents=new pe(1,1),this._viewportCount=1,this._viewports=[new Zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;W_.setFromMatrixPosition(e.matrixWorld),t.position.copy(W_),j_.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(j_),t.updateMatrixWorld(),Vd.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Vd),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Vd)}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 SA extends Wd{constructor(){super(new nr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=Vs*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,a=e.distance||t.far;(i!==t.fov||r!==t.aspect||a!==t.far)&&(t.fov=i,t.aspect=r,t.far=a,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class EA extends cc{constructor(e,t,i=0,r=Math.PI/3,a=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(ei.DEFAULT_UP),this.updateMatrix(),this.target=new ei,this.distance=i,this.angle=r,this.penumbra=a,this.decay=s,this.map=null,this.shadow=new SA}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 X_=new Ze,Rl=new z,jd=new z;class AA extends Wd{constructor(){super(new nr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new pe(4,2),this._viewportCount=6,this._viewports=[new Zt(2,1,1,1),new Zt(0,1,1,1),new Zt(3,1,1,1),new Zt(1,1,1,1),new Zt(3,0,1,1),new Zt(1,0,1,1)],this._cubeDirections=[new z(1,0,0),new z(-1,0,0),new z(0,0,1),new z(0,0,-1),new z(0,1,0),new z(0,-1,0)],this._cubeUps=[new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,1,0),new z(0,0,1),new z(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),Rl.setFromMatrixPosition(e.matrixWorld),i.position.copy(Rl),jd.copy(i.position),jd.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(jd),i.updateMatrixWorld(),r.makeTranslation(-Rl.x,-Rl.y,-Rl.z),X_.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(X_)}}class RA extends cc{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new AA}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 CA extends Wd{constructor(){super(new Yh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class q_ extends cc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(ei.DEFAULT_UP),this.updateMatrix(),this.target=new ei,this.shadow=new CA}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class LA extends cc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Cl{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);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 PA extends bo{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,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const a=this,s=Ea.get(e);if(s!==void 0){if(a.manager.itemStart(e),s.then){s.then(c=>{t&&t(c),a.manager.itemEnd(e)}).catch(c=>{r&&r(c)});return}return setTimeout(function(){t&&t(s),a.manager.itemEnd(e)},0),s}const l={};l.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",l.headers=this.requestHeader;const h=fetch(e,l).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(a.options,{colorSpaceConversion:"none"}))}).then(function(c){return Ea.add(e,c),t&&t(c),a.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Ea.remove(e),a.manager.itemError(e),a.manager.itemEnd(e)});Ea.add(e,h),a.manager.itemStart(e)}}class DA{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Y_(),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=Y_();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function Y_(){return(typeof performance>"u"?Date:performance).now()}const Xd="\\[\\]\\.:\\/",IA=new RegExp("["+Xd+"]","g"),qd="[^"+Xd+"]",OA="[^"+Xd.replace("\\.","")+"]",NA=/((?:WC+[\/:])*)/.source.replace("WC",qd),UA=/(WCOD+)?/.source.replace("WCOD",OA),zA=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",qd),BA=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",qd),FA=new RegExp("^"+NA+UA+zA+BA+"$"),kA=["material","materials","bones","map"];class HA{constructor(e,t,i){const r=i||qt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,a=i.length;r!==a;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class qt{constructor(e,t,i){this.path=t,this.parsedPath=i||qt.parseTrackName(t),this.node=qt.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new qt.Composite(e,t,i):new qt(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(IA,"")}static parseTrackName(e){const t=FA.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const a=i.nodeName.substring(r+1);kA.indexOf(a)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=a)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(a){for(let s=0;s<a.length;s++){const l=a[s];if(l.name===t||l.uuid===t)return l;const h=i(l.children);if(h)return h}return null},r=i(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)e[t++]=i[r]}_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 i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const i=this.resolvedProperty;for(let r=0,a=i.length;r!==a;++r)i[r]=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,i=t.objectName,r=t.propertyName;let a=t.propertyIndex;if(e||(e=qt.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(i){let c=t.objectIndex;switch(i){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 d=0;d<e.length;d++)if(e[d].name===c){c=d;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[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[i]}if(c!==void 0){if(e[c]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[c]}}const s=e[r];if(s===void 0){const c=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+c+"."+r+" but it wasn't found.",e);return}let l=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?l=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(l=this.Versioning.MatrixWorldNeedsUpdate);let h=this.BindingType.Direct;if(a!==void 0){if(r==="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[a]!==void 0&&(a=e.morphTargetDictionary[a])}h=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=a}else s.fromArray!==void 0&&s.toArray!==void 0?(h=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(h=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=r;this.getValue=this.GetterByBindingType[h],this.setValue=this.SetterByBindingTypeAndVersioning[h][l]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}qt.Composite=HA,qt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},qt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},qt.prototype.GetterByBindingType=[qt.prototype._getValue_direct,qt.prototype._getValue_array,qt.prototype._getValue_arrayElement,qt.prototype._getValue_toArray],qt.prototype.SetterByBindingTypeAndVersioning=[[qt.prototype._setValue_direct,qt.prototype._setValue_direct_setNeedsUpdate,qt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[qt.prototype._setValue_array,qt.prototype._setValue_array_setNeedsUpdate,qt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[qt.prototype._setValue_arrayElement,qt.prototype._setValue_arrayElement_setNeedsUpdate,qt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[qt.prototype._setValue_fromArray,qt.prototype._setValue_fromArray_setNeedsUpdate,qt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class K_{constructor(e,t,i=0,r=1/0){this.ray=new is(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new ad,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,i=[]){return Yd(e,this,i,t),i.sort(Z_),i}intersectObjects(e,t=!0,i=[]){for(let r=0,a=e.length;r<a;r++)Yd(e[r],this,i,t);return i.sort(Z_),i}}function Z_(n,e){return n.distance-e.distance}function Yd(n,e,t,i){if(n.layers.test(e.layers)&&n.raycast(e,t),i===!0){const r=n.children;for(let a=0,s=r.length;a<s;a++)Yd(r[a],e,t,!0)}}class J_{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,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,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Ri(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class GA extends Pd{constructor(e=10,t=10,i=4473924,r=8947848){i=new Ke(i),r=new Ke(r);const a=t/2,s=e/t,l=e/2,h=[],c=[];for(let f=0,m=0,_=-l;f<=t;f++,_+=s){h.push(-l,0,_,l,0,_),h.push(_,0,-l,_,0,l);const x=f===a?i:r;x.toArray(c,m),m+=3,x.toArray(c,m),m+=3,x.toArray(c,m),m+=3,x.toArray(c,m),m+=3}const d=new si;d.setAttribute("position",new bi(h,3)),d.setAttribute("color",new bi(c,3));const p=new po({vertexColors:!0,toneMapped:!1});super(d,p),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Wn}})),typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Wn);const VA=.1,WA=1e3;class jA{constructor(e){const t=document.getElementById(e.containerId),i=t.clientWidth/t.clientHeight;var r=new nr(75,i,VA,WA);return r.position.set(75,75,75),r.lookAt(0,0,0),r}}class XA{constructor(){vt(this,"source",[]);const e=new LA(16777215,.3);e.name="AmbientLight",this.source.push(e);const t=new q_(16777200,.65);t.castShadow=!0,t.position.set(150,200,150),t.shadow.camera.near=1,t.shadow.camera.far=500,t.shadow.camera.right=500,t.shadow.camera.left=-500,t.shadow.camera.top=500,t.shadow.camera.bottom=-500,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024;const i=t.clone();return i.color.set(16777200),i.castShadow=!1,i.position.set(-150,200,-150),this.source.push(t),this.source.push(i),this.source}setPosition(e,t,i){this.source.forEach(r=>{r.isDirectionalLight&&r.position.set(e,t,i)})}}class qA{constructor(){return this.scene=new SE,this.scene.background=new Ke("#EBEBEB"),this.scene.fog=new Td("#EBEBEB",400),this.scene}}class YA{constructor(e){let t=new h_({powerPreference:"high-performance",antialias:!0,alpha:!1});var i=document.getElementById(e.containerId);return t.setSize(i.clientWidth,i.clientHeight,!0),t.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.toneMapping=mm,t.outputColorSpace=Bt,t.useLegacyLights=!0,t.localClippingEnabled=!0,t.shadowMap.enabled=!0,t.shadowMap.type=En,t}}var Ll=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},uc={exports:{}};uc.exports,function(n,e){(function(){var t,i="4.17.21",r=200,a="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",l="Invalid `variable` option passed into `_.template`",h="__lodash_hash_undefined__",c=500,d="__lodash_placeholder__",p=1,f=2,m=4,_=1,x=2,y=1,v=2,M=4,b=8,S=16,A=32,T=64,E=128,I=256,C=512,P=30,X="...",q=800,te=16,k=1,H=2,V=3,J=1/0,ie=9007199254740991,$=17976931348623157e292,ne=0/0,he=4294967295,De=he-1,ee=he>>>1,ce=[["ary",E],["bind",y],["bindKey",v],["curry",b],["curryRight",S],["flip",C],["partial",A],["partialRight",T],["rearg",I]],Te="[object Arguments]",Be="[object Array]",je="[object AsyncFunction]",$e="[object Boolean]",qe="[object Date]",Xe="[object DOMException]",ge="[object Error]",G="[object Function]",Ae="[object GeneratorFunction]",ue="[object Map]",de="[object Number]",Ee="[object Null]",Fe="[object Object]",ke="[object Promise]",N="[object Proxy]",L="[object RegExp]",Z="[object Set]",xe="[object String]",fe="[object Symbol]",Se="[object Undefined]",He="[object WeakMap]",Ie="[object WeakSet]",Ue="[object ArrayBuffer]",Ge="[object DataView]",Je="[object Float32Array]",be="[object Float64Array]",dt="[object Int8Array]",B="[object Int16Array]",_e="[object Int32Array]",Ce="[object Uint8Array]",Re="[object Uint8ClampedArray]",Ve="[object Uint16Array]",tt="[object Uint32Array]",Tt=/\b__p \+= '';/g,ut=/\b(__p \+=) '' \+/g,Le=/(__e\(.*?\)|\b__t\)) \+\n'';/g,W=/&(?:amp|lt|gt|quot|#39);/g,we=/[&<>"']/g,Pe=RegExp(W.source),et=RegExp(we.source),ye=/<%-([\s\S]+?)%>/g,it=/<%([\s\S]+?)%>/g,Ut=/<%=([\s\S]+?)%>/g,oi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,er=/^\w*$/,jt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Di=/[\\^$.*+?()[\]{}|]/g,rn=RegExp(Di.source),Go=/^\s+/,Jp=/\s/,Vo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,kc=/\{\n\/\* \[wrapped with (.+)\] \*/,Wo=/,? & /,Hc=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Gc=/[()=,{}\[\]\/\s]/,$p=/\\(\\)?/g,Qp=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Vc=/\w*$/,U=/^[-+]0x[0-9a-f]+$/i,Q=/^0b[01]+$/i,ae=/^\[object .+?Constructor\]$/,oe=/^0o[0-7]+$/i,re=/^(?:0|[1-9]\d*)$/,Ne=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Qe=/($^)/,ot=/['\n\r\u2028\u2029\\]/g,ct="\uD800-\uDFFF",Rt="\\u0300-\\u036f",xt="\\ufe20-\\ufe2f",bt="\\u20d0-\\u20ff",Ii=Rt+xt+bt,vi="\\u2700-\\u27bf",or="a-z\\xdf-\\xf6\\xf8-\\xff",bn="\\xac\\xb1\\xd7\\xf7",pi="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",St="\\u2000-\\u206f",Jl=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",jo="A-Z\\xc0-\\xd6\\xd8-\\xde",kn="\\ufe0e\\ufe0f",$l=bn+pi+St+Jl,oa="['\u2019]",Ql="["+ct+"]",Oi="["+$l+"]",nn="["+Ii+"]",Xo="\\d+",Mr="["+vi+"]",qo="["+or+"]",Wc="[^"+ct+$l+Xo+vi+or+jo+"]",Yo="\uD83C[\uDFFB-\uDFFF]",pO="(?:"+nn+"|"+Yo+")",Xv="[^"+ct+"]",ef="(?:\uD83C[\uDDE6-\uDDFF]){2}",tf="[\uD800-\uDBFF][\uDC00-\uDFFF]",Ko="["+jo+"]",qv="\\u200d",Yv="(?:"+qo+"|"+Wc+")",fO="(?:"+Ko+"|"+Wc+")",Kv="(?:"+oa+"(?:d|ll|m|re|s|t|ve))?",Zv="(?:"+oa+"(?:D|LL|M|RE|S|T|VE))?",Jv=pO+"?",$v="["+kn+"]?",mO="(?:"+qv+"(?:"+[Xv,ef,tf].join("|")+")"+$v+Jv+")*",gO="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",_O="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Qv=$v+Jv+mO,vO="(?:"+[Mr,ef,tf].join("|")+")"+Qv,yO="(?:"+[Xv+nn+"?",nn,ef,tf,Ql].join("|")+")",xO=RegExp(oa,"g"),bO=RegExp(nn,"g"),rf=RegExp(Yo+"(?="+Yo+")|"+yO+Qv,"g"),wO=RegExp([Ko+"?"+qo+"+"+Kv+"(?="+[Oi,Ko,"$"].join("|")+")",fO+"+"+Zv+"(?="+[Oi,Ko+Yv,"$"].join("|")+")",Ko+"?"+Yv+"+"+Kv,Ko+"+"+Zv,_O,gO,Xo,vO].join("|"),"g"),MO=RegExp("["+qv+ct+Ii+kn+"]"),TO=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,SO=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],EO=-1,ai={};ai[Je]=ai[be]=ai[dt]=ai[B]=ai[_e]=ai[Ce]=ai[Re]=ai[Ve]=ai[tt]=!0,ai[Te]=ai[Be]=ai[Ue]=ai[$e]=ai[Ge]=ai[qe]=ai[ge]=ai[G]=ai[ue]=ai[de]=ai[Fe]=ai[L]=ai[Z]=ai[xe]=ai[He]=!1;var ti={};ti[Te]=ti[Be]=ti[Ue]=ti[Ge]=ti[$e]=ti[qe]=ti[Je]=ti[be]=ti[dt]=ti[B]=ti[_e]=ti[ue]=ti[de]=ti[Fe]=ti[L]=ti[Z]=ti[xe]=ti[fe]=ti[Ce]=ti[Re]=ti[Ve]=ti[tt]=!0,ti[ge]=ti[G]=ti[He]=!1;var AO={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},RO={"&":"&","<":"<",">":">",'"':""","'":"'"},CO={"&":"&","<":"<",">":">",""":'"',"'":"'"},LO={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},PO=parseFloat,DO=parseInt,ey=typeof Ll=="object"&&Ll&&Ll.Object===Object&&Ll,IO=typeof self=="object"&&self&&self.Object===Object&&self,ji=ey||IO||Function("return this")(),nf=e&&!e.nodeType&&e,Rs=nf&&!0&&n&&!n.nodeType&&n,ty=Rs&&Rs.exports===nf,af=ty&&ey.process,an=function(){try{var Y=Rs&&Rs.require&&Rs.require("util").types;return Y||af&&af.binding&&af.binding("util")}catch{}}(),iy=an&&an.isArrayBuffer,ry=an&&an.isDate,ny=an&&an.isMap,ay=an&&an.isRegExp,sy=an&&an.isSet,oy=an&&an.isTypedArray;function zr(Y,le,se){switch(se.length){case 0:return Y.call(le);case 1:return Y.call(le,se[0]);case 2:return Y.call(le,se[0],se[1]);case 3:return Y.call(le,se[0],se[1],se[2])}return Y.apply(le,se)}function OO(Y,le,se,We){for(var pt=-1,Ht=Y==null?0:Y.length;++pt<Ht;){var Ni=Y[pt];le(We,Ni,se(Ni),Y)}return We}function sn(Y,le){for(var se=-1,We=Y==null?0:Y.length;++se<We&&le(Y[se],se,Y)!==!1;);return Y}function NO(Y,le){for(var se=Y==null?0:Y.length;se--&&le(Y[se],se,Y)!==!1;);return Y}function ly(Y,le){for(var se=-1,We=Y==null?0:Y.length;++se<We;)if(!le(Y[se],se,Y))return!1;return!0}function ka(Y,le){for(var se=-1,We=Y==null?0:Y.length,pt=0,Ht=[];++se<We;){var Ni=Y[se];le(Ni,se,Y)&&(Ht[pt++]=Ni)}return Ht}function jc(Y,le){var se=Y==null?0:Y.length;return!!se&&Zo(Y,le,0)>-1}function sf(Y,le,se){for(var We=-1,pt=Y==null?0:Y.length;++We<pt;)if(se(le,Y[We]))return!0;return!1}function li(Y,le){for(var se=-1,We=Y==null?0:Y.length,pt=Array(We);++se<We;)pt[se]=le(Y[se],se,Y);return pt}function Ha(Y,le){for(var se=-1,We=le.length,pt=Y.length;++se<We;)Y[pt+se]=le[se];return Y}function of(Y,le,se,We){var pt=-1,Ht=Y==null?0:Y.length;for(We&&Ht&&(se=Y[++pt]);++pt<Ht;)se=le(se,Y[pt],pt,Y);return se}function UO(Y,le,se,We){var pt=Y==null?0:Y.length;for(We&&pt&&(se=Y[--pt]);pt--;)se=le(se,Y[pt],pt,Y);return se}function lf(Y,le){for(var se=-1,We=Y==null?0:Y.length;++se<We;)if(le(Y[se],se,Y))return!0;return!1}var zO=hf("length");function BO(Y){return Y.split("")}function FO(Y){return Y.match(Hc)||[]}function hy(Y,le,se){var We;return se(Y,function(pt,Ht,Ni){if(le(pt,Ht,Ni))return We=Ht,!1}),We}function Xc(Y,le,se,We){for(var pt=Y.length,Ht=se+(We?1:-1);We?Ht--:++Ht<pt;)if(le(Y[Ht],Ht,Y))return Ht;return-1}function Zo(Y,le,se){return le===le?JO(Y,le,se):Xc(Y,cy,se)}function kO(Y,le,se,We){for(var pt=se-1,Ht=Y.length;++pt<Ht;)if(We(Y[pt],le))return pt;return-1}function cy(Y){return Y!==Y}function uy(Y,le){var se=Y==null?0:Y.length;return se?uf(Y,le)/se:ne}function hf(Y){return function(le){return le==null?t:le[Y]}}function cf(Y){return function(le){return Y==null?t:Y[le]}}function dy(Y,le,se,We,pt){return pt(Y,function(Ht,Ni,Qt){se=We?(We=!1,Ht):le(se,Ht,Ni,Qt)}),se}function HO(Y,le){var se=Y.length;for(Y.sort(le);se--;)Y[se]=Y[se].value;return Y}function uf(Y,le){for(var se,We=-1,pt=Y.length;++We<pt;){var Ht=le(Y[We]);Ht!==t&&(se=se===t?Ht:se+Ht)}return se}function df(Y,le){for(var se=-1,We=Array(Y);++se<Y;)We[se]=le(se);return We}function GO(Y,le){return li(le,function(se){return[se,Y[se]]})}function py(Y){return Y&&Y.slice(0,_y(Y)+1).replace(Go,"")}function Br(Y){return function(le){return Y(le)}}function pf(Y,le){return li(le,function(se){return Y[se]})}function eh(Y,le){return Y.has(le)}function fy(Y,le){for(var se=-1,We=Y.length;++se<We&&Zo(le,Y[se],0)>-1;);return se}function my(Y,le){for(var se=Y.length;se--&&Zo(le,Y[se],0)>-1;);return se}function VO(Y,le){for(var se=Y.length,We=0;se--;)Y[se]===le&&++We;return We}var WO=cf(AO),jO=cf(RO);function XO(Y){return"\\"+LO[Y]}function qO(Y,le){return Y==null?t:Y[le]}function Jo(Y){return MO.test(Y)}function YO(Y){return TO.test(Y)}function KO(Y){for(var le,se=[];!(le=Y.next()).done;)se.push(le.value);return se}function ff(Y){var le=-1,se=Array(Y.size);return Y.forEach(function(We,pt){se[++le]=[pt,We]}),se}function gy(Y,le){return function(se){return Y(le(se))}}function Ga(Y,le){for(var se=-1,We=Y.length,pt=0,Ht=[];++se<We;){var Ni=Y[se];(Ni===le||Ni===d)&&(Y[se]=d,Ht[pt++]=se)}return Ht}function qc(Y){var le=-1,se=Array(Y.size);return Y.forEach(function(We){se[++le]=We}),se}function ZO(Y){var le=-1,se=Array(Y.size);return Y.forEach(function(We){se[++le]=[We,We]}),se}function JO(Y,le,se){for(var We=se-1,pt=Y.length;++We<pt;)if(Y[We]===le)return We;return-1}function $O(Y,le,se){for(var We=se+1;We--;)if(Y[We]===le)return We;return We}function $o(Y){return Jo(Y)?e3(Y):zO(Y)}function wn(Y){return Jo(Y)?t3(Y):BO(Y)}function _y(Y){for(var le=Y.length;le--&&Jp.test(Y.charAt(le)););return le}var QO=cf(CO);function e3(Y){for(var le=rf.lastIndex=0;rf.test(Y);)++le;return le}function t3(Y){return Y.match(rf)||[]}function i3(Y){return Y.match(wO)||[]}var r3=function Y(le){le=le==null?ji:Qo.defaults(ji.Object(),le,Qo.pick(ji,SO));var se=le.Array,We=le.Date,pt=le.Error,Ht=le.Function,Ni=le.Math,Qt=le.Object,mf=le.RegExp,n3=le.String,on=le.TypeError,Yc=se.prototype,a3=Ht.prototype,el=Qt.prototype,Kc=le["__core-js_shared__"],Zc=a3.toString,Yt=el.hasOwnProperty,s3=0,vy=function(){var o=/[^.]+$/.exec(Kc&&Kc.keys&&Kc.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),Jc=el.toString,o3=Zc.call(Qt),l3=ji._,h3=mf("^"+Zc.call(Yt).replace(Di,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),$c=ty?le.Buffer:t,Va=le.Symbol,Qc=le.Uint8Array,yy=$c?$c.allocUnsafe:t,eu=gy(Qt.getPrototypeOf,Qt),xy=Qt.create,by=el.propertyIsEnumerable,tu=Yc.splice,wy=Va?Va.isConcatSpreadable:t,th=Va?Va.iterator:t,Cs=Va?Va.toStringTag:t,iu=function(){try{var o=Os(Qt,"defineProperty");return o({},"",{}),o}catch{}}(),c3=le.clearTimeout!==ji.clearTimeout&&le.clearTimeout,u3=We&&We.now!==ji.Date.now&&We.now,d3=le.setTimeout!==ji.setTimeout&&le.setTimeout,ru=Ni.ceil,nu=Ni.floor,gf=Qt.getOwnPropertySymbols,p3=$c?$c.isBuffer:t,My=le.isFinite,f3=Yc.join,m3=gy(Qt.keys,Qt),Ui=Ni.max,tr=Ni.min,g3=We.now,_3=le.parseInt,Ty=Ni.random,v3=Yc.reverse,_f=Os(le,"DataView"),ih=Os(le,"Map"),vf=Os(le,"Promise"),tl=Os(le,"Set"),rh=Os(le,"WeakMap"),nh=Os(Qt,"create"),au=rh&&new rh,il={},y3=Ns(_f),x3=Ns(ih),b3=Ns(vf),w3=Ns(tl),M3=Ns(rh),su=Va?Va.prototype:t,ah=su?su.valueOf:t,Sy=su?su.toString:t;function D(o){if(yi(o)&&!_t(o)&&!(o instanceof Pt)){if(o instanceof ln)return o;if(Yt.call(o,"__wrapped__"))return Ex(o)}return new ln(o)}var rl=function(){function o(){}return function(u){if(!fi(u))return{};if(xy)return xy(u);o.prototype=u;var g=new o;return o.prototype=t,g}}();function ou(){}function ln(o,u){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=t}D.templateSettings={escape:ye,evaluate:it,interpolate:Ut,variable:"",imports:{_:D}},D.prototype=ou.prototype,D.prototype.constructor=D,ln.prototype=rl(ou.prototype),ln.prototype.constructor=ln;function Pt(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=he,this.__views__=[]}function T3(){var o=new Pt(this.__wrapped__);return o.__actions__=Tr(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=Tr(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=Tr(this.__views__),o}function S3(){if(this.__filtered__){var o=new Pt(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function E3(){var o=this.__wrapped__.value(),u=this.__dir__,g=_t(o),w=u<0,R=g?o.length:0,O=BN(0,R,this.__views__),F=O.start,j=O.end,K=j-F,me=w?j:F-1,ve=this.__iteratees__,Me=ve.length,ze=0,Ye=tr(K,this.__takeCount__);if(!g||!w&&R==K&&Ye==K)return Ky(o,this.__actions__);var lt=[];e:for(;K--&&ze<Ye;){me+=u;for(var Et=-1,ht=o[me];++Et<Me;){var Ct=ve[Et],Ot=Ct.iteratee,Hr=Ct.type,cr=Ot(ht);if(Hr==H)ht=cr;else if(!cr){if(Hr==k)continue e;break e}}lt[ze++]=ht}return lt}Pt.prototype=rl(ou.prototype),Pt.prototype.constructor=Pt;function Ls(o){var u=-1,g=o==null?0:o.length;for(this.clear();++u<g;){var w=o[u];this.set(w[0],w[1])}}function A3(){this.__data__=nh?nh(null):{},this.size=0}function R3(o){var u=this.has(o)&&delete this.__data__[o];return this.size-=u?1:0,u}function C3(o){var u=this.__data__;if(nh){var g=u[o];return g===h?t:g}return Yt.call(u,o)?u[o]:t}function L3(o){var u=this.__data__;return nh?u[o]!==t:Yt.call(u,o)}function P3(o,u){var g=this.__data__;return this.size+=this.has(o)?0:1,g[o]=nh&&u===t?h:u,this}Ls.prototype.clear=A3,Ls.prototype.delete=R3,Ls.prototype.get=C3,Ls.prototype.has=L3,Ls.prototype.set=P3;function la(o){var u=-1,g=o==null?0:o.length;for(this.clear();++u<g;){var w=o[u];this.set(w[0],w[1])}}function D3(){this.__data__=[],this.size=0}function I3(o){var u=this.__data__,g=lu(u,o);if(g<0)return!1;var w=u.length-1;return g==w?u.pop():tu.call(u,g,1),--this.size,!0}function O3(o){var u=this.__data__,g=lu(u,o);return g<0?t:u[g][1]}function N3(o){return lu(this.__data__,o)>-1}function U3(o,u){var g=this.__data__,w=lu(g,o);return w<0?(++this.size,g.push([o,u])):g[w][1]=u,this}la.prototype.clear=D3,la.prototype.delete=I3,la.prototype.get=O3,la.prototype.has=N3,la.prototype.set=U3;function ha(o){var u=-1,g=o==null?0:o.length;for(this.clear();++u<g;){var w=o[u];this.set(w[0],w[1])}}function z3(){this.size=0,this.__data__={hash:new Ls,map:new(ih||la),string:new Ls}}function B3(o){var u=xu(this,o).delete(o);return this.size-=u?1:0,u}function F3(o){return xu(this,o).get(o)}function k3(o){return xu(this,o).has(o)}function H3(o,u){var g=xu(this,o),w=g.size;return g.set(o,u),this.size+=g.size==w?0:1,this}ha.prototype.clear=z3,ha.prototype.delete=B3,ha.prototype.get=F3,ha.prototype.has=k3,ha.prototype.set=H3;function Ps(o){var u=-1,g=o==null?0:o.length;for(this.__data__=new ha;++u<g;)this.add(o[u])}function G3(o){return this.__data__.set(o,h),this}function V3(o){return this.__data__.has(o)}Ps.prototype.add=Ps.prototype.push=G3,Ps.prototype.has=V3;function Mn(o){var u=this.__data__=new la(o);this.size=u.size}function W3(){this.__data__=new la,this.size=0}function j3(o){var u=this.__data__,g=u.delete(o);return this.size=u.size,g}function X3(o){return this.__data__.get(o)}function q3(o){return this.__data__.has(o)}function Y3(o,u){var g=this.__data__;if(g instanceof la){var w=g.__data__;if(!ih||w.length<r-1)return w.push([o,u]),this.size=++g.size,this;g=this.__data__=new ha(w)}return g.set(o,u),this.size=g.size,this}Mn.prototype.clear=W3,Mn.prototype.delete=j3,Mn.prototype.get=X3,Mn.prototype.has=q3,Mn.prototype.set=Y3;function Ey(o,u){var g=_t(o),w=!g&&Us(o),R=!g&&!w&&Ya(o),O=!g&&!w&&!R&&ol(o),F=g||w||R||O,j=F?df(o.length,n3):[],K=j.length;for(var me in o)(u||Yt.call(o,me))&&!(F&&(me=="length"||R&&(me=="offset"||me=="parent")||O&&(me=="buffer"||me=="byteLength"||me=="byteOffset")||pa(me,K)))&&j.push(me);return j}function Ay(o){var u=o.length;return u?o[Cf(0,u-1)]:t}function K3(o,u){return bu(Tr(o),Ds(u,0,o.length))}function Z3(o){return bu(Tr(o))}function yf(o,u,g){(g!==t&&!Tn(o[u],g)||g===t&&!(u in o))&&ca(o,u,g)}function sh(o,u,g){var w=o[u];(!(Yt.call(o,u)&&Tn(w,g))||g===t&&!(u in o))&&ca(o,u,g)}function lu(o,u){for(var g=o.length;g--;)if(Tn(o[g][0],u))return g;return-1}function J3(o,u,g,w){return Wa(o,function(R,O,F){u(w,R,g(R),F)}),w}function Ry(o,u){return o&&Gn(u,Vi(u),o)}function $3(o,u){return o&&Gn(u,Er(u),o)}function ca(o,u,g){u=="__proto__"&&iu?iu(o,u,{configurable:!0,enumerable:!0,value:g,writable:!0}):o[u]=g}function xf(o,u){for(var g=-1,w=u.length,R=se(w),O=o==null;++g<w;)R[g]=O?t:em(o,u[g]);return R}function Ds(o,u,g){return o===o&&(g!==t&&(o=o<=g?o:g),u!==t&&(o=o>=u?o:u)),o}function hn(o,u,g,w,R,O){var F,j=u&p,K=u&f,me=u&m;if(g&&(F=R?g(o,w,R,O):g(o)),F!==t)return F;if(!fi(o))return o;var ve=_t(o);if(ve){if(F=kN(o),!j)return Tr(o,F)}else{var Me=ir(o),ze=Me==G||Me==Ae;if(Ya(o))return $y(o,j);if(Me==Fe||Me==Te||ze&&!R){if(F=K||ze?{}:_x(o),!j)return K?CN(o,$3(F,o)):RN(o,Ry(F,o))}else{if(!ti[Me])return R?o:{};F=HN(o,Me,j)}}O||(O=new Mn);var Ye=O.get(o);if(Ye)return Ye;O.set(o,F),Xx(o)?o.forEach(function(ht){F.add(hn(ht,u,g,ht,o,O))}):Wx(o)&&o.forEach(function(ht,Ct){F.set(Ct,hn(ht,u,g,Ct,o,O))});var lt=me?K?kf:Ff:K?Er:Vi,Et=ve?t:lt(o);return sn(Et||o,function(ht,Ct){Et&&(Ct=ht,ht=o[Ct]),sh(F,Ct,hn(ht,u,g,Ct,o,O))}),F}function Q3(o){var u=Vi(o);return function(g){return Cy(g,o,u)}}function Cy(o,u,g){var w=g.length;if(o==null)return!w;for(o=Qt(o);w--;){var R=g[w],O=u[R],F=o[R];if(F===t&&!(R in o)||!O(F))return!1}return!0}function Ly(o,u,g){if(typeof o!="function")throw new on(s);return ph(function(){o.apply(t,g)},u)}function oh(o,u,g,w){var R=-1,O=jc,F=!0,j=o.length,K=[],me=u.length;if(!j)return K;g&&(u=li(u,Br(g))),w?(O=sf,F=!1):u.length>=r&&(O=eh,F=!1,u=new Ps(u));e:for(;++R<j;){var ve=o[R],Me=g==null?ve:g(ve);if(ve=w||ve!==0?ve:0,F&&Me===Me){for(var ze=me;ze--;)if(u[ze]===Me)continue e;K.push(ve)}else O(u,Me,w)||K.push(ve)}return K}var Wa=rx(Hn),Py=rx(wf,!0);function eN(o,u){var g=!0;return Wa(o,function(w,R,O){return g=!!u(w,R,O),g}),g}function hu(o,u,g){for(var w=-1,R=o.length;++w<R;){var O=o[w],F=u(O);if(F!=null&&(j===t?F===F&&!kr(F):g(F,j)))var j=F,K=O}return K}function tN(o,u,g,w){var R=o.length;for(g=wt(g),g<0&&(g=-g>R?0:R+g),w=w===t||w>R?R:wt(w),w<0&&(w+=R),w=g>w?0:Yx(w);g<w;)o[g++]=u;return o}function Dy(o,u){var g=[];return Wa(o,function(w,R,O){u(w,R,O)&&g.push(w)}),g}function Xi(o,u,g,w,R){var O=-1,F=o.length;for(g||(g=VN),R||(R=[]);++O<F;){var j=o[O];u>0&&g(j)?u>1?Xi(j,u-1,g,w,R):Ha(R,j):w||(R[R.length]=j)}return R}var bf=nx(),Iy=nx(!0);function Hn(o,u){return o&&bf(o,u,Vi)}function wf(o,u){return o&&Iy(o,u,Vi)}function cu(o,u){return ka(u,function(g){return fa(o[g])})}function Is(o,u){u=Xa(u,o);for(var g=0,w=u.length;o!=null&&g<w;)o=o[Vn(u[g++])];return g&&g==w?o:t}function Oy(o,u,g){var w=u(o);return _t(o)?w:Ha(w,g(o))}function lr(o){return o==null?o===t?Se:Ee:Cs&&Cs in Qt(o)?zN(o):ZN(o)}function Mf(o,u){return o>u}function iN(o,u){return o!=null&&Yt.call(o,u)}function rN(o,u){return o!=null&&u in Qt(o)}function nN(o,u,g){return o>=tr(u,g)&&o<Ui(u,g)}function Tf(o,u,g){for(var w=g?sf:jc,R=o[0].length,O=o.length,F=O,j=se(O),K=1/0,me=[];F--;){var ve=o[F];F&&u&&(ve=li(ve,Br(u))),K=tr(ve.length,K),j[F]=!g&&(u||R>=120&&ve.length>=120)?new Ps(F&&ve):t}ve=o[0];var Me=-1,ze=j[0];e:for(;++Me<R&&me.length<K;){var Ye=ve[Me],lt=u?u(Ye):Ye;if(Ye=g||Ye!==0?Ye:0,!(ze?eh(ze,lt):w(me,lt,g))){for(F=O;--F;){var Et=j[F];if(!(Et?eh(Et,lt):w(o[F],lt,g)))continue e}ze&&ze.push(lt),me.push(Ye)}}return me}function aN(o,u,g,w){return Hn(o,function(R,O,F){u(w,g(R),O,F)}),w}function lh(o,u,g){u=Xa(u,o),o=bx(o,u);var w=o==null?o:o[Vn(un(u))];return w==null?t:zr(w,o,g)}function Ny(o){return yi(o)&&lr(o)==Te}function sN(o){return yi(o)&&lr(o)==Ue}function oN(o){return yi(o)&&lr(o)==qe}function hh(o,u,g,w,R){return o===u?!0:o==null||u==null||!yi(o)&&!yi(u)?o!==o&&u!==u:lN(o,u,g,w,hh,R)}function lN(o,u,g,w,R,O){var F=_t(o),j=_t(u),K=F?Be:ir(o),me=j?Be:ir(u);K=K==Te?Fe:K,me=me==Te?Fe:me;var ve=K==Fe,Me=me==Fe,ze=K==me;if(ze&&Ya(o)){if(!Ya(u))return!1;F=!0,ve=!1}if(ze&&!ve)return O||(O=new Mn),F||ol(o)?fx(o,u,g,w,R,O):NN(o,u,K,g,w,R,O);if(!(g&_)){var Ye=ve&&Yt.call(o,"__wrapped__"),lt=Me&&Yt.call(u,"__wrapped__");if(Ye||lt){var Et=Ye?o.value():o,ht=lt?u.value():u;return O||(O=new Mn),R(Et,ht,g,w,O)}}return ze?(O||(O=new Mn),UN(o,u,g,w,R,O)):!1}function hN(o){return yi(o)&&ir(o)==ue}function Sf(o,u,g,w){var R=g.length,O=R,F=!w;if(o==null)return!O;for(o=Qt(o);R--;){var j=g[R];if(F&&j[2]?j[1]!==o[j[0]]:!(j[0]in o))return!1}for(;++R<O;){j=g[R];var K=j[0],me=o[K],ve=j[1];if(F&&j[2]){if(me===t&&!(K in o))return!1}else{var Me=new Mn;if(w)var ze=w(me,ve,K,o,u,Me);if(!(ze===t?hh(ve,me,_|x,w,Me):ze))return!1}}return!0}function Uy(o){if(!fi(o)||jN(o))return!1;var u=fa(o)?h3:ae;return u.test(Ns(o))}function cN(o){return yi(o)&&lr(o)==L}function uN(o){return yi(o)&&ir(o)==Z}function dN(o){return yi(o)&&Au(o.length)&&!!ai[lr(o)]}function zy(o){return typeof o=="function"?o:o==null?Ar:typeof o=="object"?_t(o)?ky(o[0],o[1]):Fy(o):a1(o)}function Ef(o){if(!dh(o))return m3(o);var u=[];for(var g in Qt(o))Yt.call(o,g)&&g!="constructor"&&u.push(g);return u}function pN(o){if(!fi(o))return KN(o);var u=dh(o),g=[];for(var w in o)w=="constructor"&&(u||!Yt.call(o,w))||g.push(w);return g}function Af(o,u){return o<u}function By(o,u){var g=-1,w=Sr(o)?se(o.length):[];return Wa(o,function(R,O,F){w[++g]=u(R,O,F)}),w}function Fy(o){var u=Gf(o);return u.length==1&&u[0][2]?yx(u[0][0],u[0][1]):function(g){return g===o||Sf(g,o,u)}}function ky(o,u){return Wf(o)&&vx(u)?yx(Vn(o),u):function(g){var w=em(g,o);return w===t&&w===u?tm(g,o):hh(u,w,_|x)}}function uu(o,u,g,w,R){o!==u&&bf(u,function(O,F){if(R||(R=new Mn),fi(O))fN(o,u,F,g,uu,w,R);else{var j=w?w(Xf(o,F),O,F+"",o,u,R):t;j===t&&(j=O),yf(o,F,j)}},Er)}function fN(o,u,g,w,R,O,F){var j=Xf(o,g),K=Xf(u,g),me=F.get(K);if(me){yf(o,g,me);return}var ve=O?O(j,K,g+"",o,u,F):t,Me=ve===t;if(Me){var ze=_t(K),Ye=!ze&&Ya(K),lt=!ze&&!Ye&&ol(K);ve=K,ze||Ye||lt?_t(j)?ve=j:Ti(j)?ve=Tr(j):Ye?(Me=!1,ve=$y(K,!0)):lt?(Me=!1,ve=Qy(K,!0)):ve=[]:fh(K)||Us(K)?(ve=j,Us(j)?ve=Kx(j):(!fi(j)||fa(j))&&(ve=_x(K))):Me=!1}Me&&(F.set(K,ve),R(ve,K,w,O,F),F.delete(K)),yf(o,g,ve)}function Hy(o,u){var g=o.length;if(g)return u+=u<0?g:0,pa(u,g)?o[u]:t}function Gy(o,u,g){u.length?u=li(u,function(O){return _t(O)?function(F){return Is(F,O.length===1?O[0]:O)}:O}):u=[Ar];var w=-1;u=li(u,Br(at()));var R=By(o,function(O,F,j){var K=li(u,function(me){return me(O)});return{criteria:K,index:++w,value:O}});return HO(R,function(O,F){return AN(O,F,g)})}function mN(o,u){return Vy(o,u,function(g,w){return tm(o,w)})}function Vy(o,u,g){for(var w=-1,R=u.length,O={};++w<R;){var F=u[w],j=Is(o,F);g(j,F)&&ch(O,Xa(F,o),j)}return O}function gN(o){return function(u){return Is(u,o)}}function Rf(o,u,g,w){var R=w?kO:Zo,O=-1,F=u.length,j=o;for(o===u&&(u=Tr(u)),g&&(j=li(o,Br(g)));++O<F;)for(var K=0,me=u[O],ve=g?g(me):me;(K=R(j,ve,K,w))>-1;)j!==o&&tu.call(j,K,1),tu.call(o,K,1);return o}function Wy(o,u){for(var g=o?u.length:0,w=g-1;g--;){var R=u[g];if(g==w||R!==O){var O=R;pa(R)?tu.call(o,R,1):Df(o,R)}}return o}function Cf(o,u){return o+nu(Ty()*(u-o+1))}function _N(o,u,g,w){for(var R=-1,O=Ui(ru((u-o)/(g||1)),0),F=se(O);O--;)F[w?O:++R]=o,o+=g;return F}function Lf(o,u){var g="";if(!o||u<1||u>ie)return g;do u%2&&(g+=o),u=nu(u/2),u&&(o+=o);while(u);return g}function At(o,u){return qf(xx(o,u,Ar),o+"")}function vN(o){return Ay(ll(o))}function yN(o,u){var g=ll(o);return bu(g,Ds(u,0,g.length))}function ch(o,u,g,w){if(!fi(o))return o;u=Xa(u,o);for(var R=-1,O=u.length,F=O-1,j=o;j!=null&&++R<O;){var K=Vn(u[R]),me=g;if(K==="__proto__"||K==="constructor"||K==="prototype")return o;if(R!=F){var ve=j[K];me=w?w(ve,K,j):t,me===t&&(me=fi(ve)?ve:pa(u[R+1])?[]:{})}sh(j,K,me),j=j[K]}return o}var jy=au?function(o,u){return au.set(o,u),o}:Ar,xN=iu?function(o,u){return iu(o,"toString",{configurable:!0,enumerable:!1,value:rm(u),writable:!0})}:Ar;function bN(o){return bu(ll(o))}function cn(o,u,g){var w=-1,R=o.length;u<0&&(u=-u>R?0:R+u),g=g>R?R:g,g<0&&(g+=R),R=u>g?0:g-u>>>0,u>>>=0;for(var O=se(R);++w<R;)O[w]=o[w+u];return O}function wN(o,u){var g;return Wa(o,function(w,R,O){return g=u(w,R,O),!g}),!!g}function du(o,u,g){var w=0,R=o==null?w:o.length;if(typeof u=="number"&&u===u&&R<=ee){for(;w<R;){var O=w+R>>>1,F=o[O];F!==null&&!kr(F)&&(g?F<=u:F<u)?w=O+1:R=O}return R}return Pf(o,u,Ar,g)}function Pf(o,u,g,w){var R=0,O=o==null?0:o.length;if(O===0)return 0;u=g(u);for(var F=u!==u,j=u===null,K=kr(u),me=u===t;R<O;){var ve=nu((R+O)/2),Me=g(o[ve]),ze=Me!==t,Ye=Me===null,lt=Me===Me,Et=kr(Me);if(F)var ht=w||lt;else me?ht=lt&&(w||ze):j?ht=lt&&ze&&(w||!Ye):K?ht=lt&&ze&&!Ye&&(w||!Et):Ye||Et?ht=!1:ht=w?Me<=u:Me<u;ht?R=ve+1:O=ve}return tr(O,De)}function Xy(o,u){for(var g=-1,w=o.length,R=0,O=[];++g<w;){var F=o[g],j=u?u(F):F;if(!g||!Tn(j,K)){var K=j;O[R++]=F===0?0:F}}return O}function qy(o){return typeof o=="number"?o:kr(o)?ne:+o}function Fr(o){if(typeof o=="string")return o;if(_t(o))return li(o,Fr)+"";if(kr(o))return Sy?Sy.call(o):"";var u=o+"";return u=="0"&&1/o==-J?"-0":u}function ja(o,u,g){var w=-1,R=jc,O=o.length,F=!0,j=[],K=j;if(g)F=!1,R=sf;else if(O>=r){var me=u?null:IN(o);if(me)return qc(me);F=!1,R=eh,K=new Ps}else K=u?[]:j;e:for(;++w<O;){var ve=o[w],Me=u?u(ve):ve;if(ve=g||ve!==0?ve:0,F&&Me===Me){for(var ze=K.length;ze--;)if(K[ze]===Me)continue e;u&&K.push(Me),j.push(ve)}else R(K,Me,g)||(K!==j&&K.push(Me),j.push(ve))}return j}function Df(o,u){return u=Xa(u,o),o=bx(o,u),o==null||delete o[Vn(un(u))]}function Yy(o,u,g,w){return ch(o,u,g(Is(o,u)),w)}function pu(o,u,g,w){for(var R=o.length,O=w?R:-1;(w?O--:++O<R)&&u(o[O],O,o););return g?cn(o,w?0:O,w?O+1:R):cn(o,w?O+1:0,w?R:O)}function Ky(o,u){var g=o;return g instanceof Pt&&(g=g.value()),of(u,function(w,R){return R.func.apply(R.thisArg,Ha([w],R.args))},g)}function If(o,u,g){var w=o.length;if(w<2)return w?ja(o[0]):[];for(var R=-1,O=se(w);++R<w;)for(var F=o[R],j=-1;++j<w;)j!=R&&(O[R]=oh(O[R]||F,o[j],u,g));return ja(Xi(O,1),u,g)}function Zy(o,u,g){for(var w=-1,R=o.length,O=u.length,F={};++w<R;){var j=w<O?u[w]:t;g(F,o[w],j)}return F}function Of(o){return Ti(o)?o:[]}function Nf(o){return typeof o=="function"?o:Ar}function Xa(o,u){return _t(o)?o:Wf(o,u)?[o]:Sx(Xt(o))}var MN=At;function qa(o,u,g){var w=o.length;return g=g===t?w:g,!u&&g>=w?o:cn(o,u,g)}var Jy=c3||function(o){return ji.clearTimeout(o)};function $y(o,u){if(u)return o.slice();var g=o.length,w=yy?yy(g):new o.constructor(g);return o.copy(w),w}function Uf(o){var u=new o.constructor(o.byteLength);return new Qc(u).set(new Qc(o)),u}function TN(o,u){var g=u?Uf(o.buffer):o.buffer;return new o.constructor(g,o.byteOffset,o.byteLength)}function SN(o){var u=new o.constructor(o.source,Vc.exec(o));return u.lastIndex=o.lastIndex,u}function EN(o){return ah?Qt(ah.call(o)):{}}function Qy(o,u){var g=u?Uf(o.buffer):o.buffer;return new o.constructor(g,o.byteOffset,o.length)}function ex(o,u){if(o!==u){var g=o!==t,w=o===null,R=o===o,O=kr(o),F=u!==t,j=u===null,K=u===u,me=kr(u);if(!j&&!me&&!O&&o>u||O&&F&&K&&!j&&!me||w&&F&&K||!g&&K||!R)return 1;if(!w&&!O&&!me&&o<u||me&&g&&R&&!w&&!O||j&&g&&R||!F&&R||!K)return-1}return 0}function AN(o,u,g){for(var w=-1,R=o.criteria,O=u.criteria,F=R.length,j=g.length;++w<F;){var K=ex(R[w],O[w]);if(K){if(w>=j)return K;var me=g[w];return K*(me=="desc"?-1:1)}}return o.index-u.index}function tx(o,u,g,w){for(var R=-1,O=o.length,F=g.length,j=-1,K=u.length,me=Ui(O-F,0),ve=se(K+me),Me=!w;++j<K;)ve[j]=u[j];for(;++R<F;)(Me||R<O)&&(ve[g[R]]=o[R]);for(;me--;)ve[j++]=o[R++];return ve}function ix(o,u,g,w){for(var R=-1,O=o.length,F=-1,j=g.length,K=-1,me=u.length,ve=Ui(O-j,0),Me=se(ve+me),ze=!w;++R<ve;)Me[R]=o[R];for(var Ye=R;++K<me;)Me[Ye+K]=u[K];for(;++F<j;)(ze||R<O)&&(Me[Ye+g[F]]=o[R++]);return Me}function Tr(o,u){var g=-1,w=o.length;for(u||(u=se(w));++g<w;)u[g]=o[g];return u}function Gn(o,u,g,w){var R=!g;g||(g={});for(var O=-1,F=u.length;++O<F;){var j=u[O],K=w?w(g[j],o[j],j,g,o):t;K===t&&(K=o[j]),R?ca(g,j,K):sh(g,j,K)}return g}function RN(o,u){return Gn(o,Vf(o),u)}function CN(o,u){return Gn(o,mx(o),u)}function fu(o,u){return function(g,w){var R=_t(g)?OO:J3,O=u?u():{};return R(g,o,at(w,2),O)}}function nl(o){return At(function(u,g){var w=-1,R=g.length,O=R>1?g[R-1]:t,F=R>2?g[2]:t;for(O=o.length>3&&typeof O=="function"?(R--,O):t,F&&hr(g[0],g[1],F)&&(O=R<3?t:O,R=1),u=Qt(u);++w<R;){var j=g[w];j&&o(u,j,w,O)}return u})}function rx(o,u){return function(g,w){if(g==null)return g;if(!Sr(g))return o(g,w);for(var R=g.length,O=u?R:-1,F=Qt(g);(u?O--:++O<R)&&w(F[O],O,F)!==!1;);return g}}function nx(o){return function(u,g,w){for(var R=-1,O=Qt(u),F=w(u),j=F.length;j--;){var K=F[o?j:++R];if(g(O[K],K,O)===!1)break}return u}}function LN(o,u,g){var w=u&y,R=uh(o);function O(){var F=this&&this!==ji&&this instanceof O?R:o;return F.apply(w?g:this,arguments)}return O}function ax(o){return function(u){u=Xt(u);var g=Jo(u)?wn(u):t,w=g?g[0]:u.charAt(0),R=g?qa(g,1).join(""):u.slice(1);return w[o]()+R}}function al(o){return function(u){return of(r1(i1(u).replace(xO,"")),o,"")}}function uh(o){return function(){var u=arguments;switch(u.length){case 0:return new o;case 1:return new o(u[0]);case 2:return new o(u[0],u[1]);case 3:return new o(u[0],u[1],u[2]);case 4:return new o(u[0],u[1],u[2],u[3]);case 5:return new o(u[0],u[1],u[2],u[3],u[4]);case 6:return new o(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new o(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var g=rl(o.prototype),w=o.apply(g,u);return fi(w)?w:g}}function PN(o,u,g){var w=uh(o);function R(){for(var O=arguments.length,F=se(O),j=O,K=sl(R);j--;)F[j]=arguments[j];var me=O<3&&F[0]!==K&&F[O-1]!==K?[]:Ga(F,K);if(O-=me.length,O<g)return cx(o,u,mu,R.placeholder,t,F,me,t,t,g-O);var ve=this&&this!==ji&&this instanceof R?w:o;return zr(ve,this,F)}return R}function sx(o){return function(u,g,w){var R=Qt(u);if(!Sr(u)){var O=at(g,3);u=Vi(u),g=function(j){return O(R[j],j,R)}}var F=o(u,g,w);return F>-1?R[O?u[F]:F]:t}}function ox(o){return da(function(u){var g=u.length,w=g,R=ln.prototype.thru;for(o&&u.reverse();w--;){var O=u[w];if(typeof O!="function")throw new on(s);if(R&&!F&&yu(O)=="wrapper")var F=new ln([],!0)}for(w=F?w:g;++w<g;){O=u[w];var j=yu(O),K=j=="wrapper"?Hf(O):t;K&&jf(K[0])&&K[1]==(E|b|A|I)&&!K[4].length&&K[9]==1?F=F[yu(K[0])].apply(F,K[3]):F=O.length==1&&jf(O)?F[j]():F.thru(O)}return function(){var me=arguments,ve=me[0];if(F&&me.length==1&&_t(ve))return F.plant(ve).value();for(var Me=0,ze=g?u[Me].apply(this,me):ve;++Me<g;)ze=u[Me].call(this,ze);return ze}})}function mu(o,u,g,w,R,O,F,j,K,me){var ve=u&E,Me=u&y,ze=u&v,Ye=u&(b|S),lt=u&C,Et=ze?t:uh(o);function ht(){for(var Ct=arguments.length,Ot=se(Ct),Hr=Ct;Hr--;)Ot[Hr]=arguments[Hr];if(Ye)var cr=sl(ht),Gr=VO(Ot,cr);if(w&&(Ot=tx(Ot,w,R,Ye)),O&&(Ot=ix(Ot,O,F,Ye)),Ct-=Gr,Ye&&Ct<me){var Si=Ga(Ot,cr);return cx(o,u,mu,ht.placeholder,g,Ot,Si,j,K,me-Ct)}var Sn=Me?g:this,ga=ze?Sn[o]:o;return Ct=Ot.length,j?Ot=JN(Ot,j):lt&&Ct>1&&Ot.reverse(),ve&&K<Ct&&(Ot.length=K),this&&this!==ji&&this instanceof ht&&(ga=Et||uh(ga)),ga.apply(Sn,Ot)}return ht}function lx(o,u){return function(g,w){return aN(g,o,u(w),{})}}function gu(o,u){return function(g,w){var R;if(g===t&&w===t)return u;if(g!==t&&(R=g),w!==t){if(R===t)return w;typeof g=="string"||typeof w=="string"?(g=Fr(g),w=Fr(w)):(g=qy(g),w=qy(w)),R=o(g,w)}return R}}function zf(o){return da(function(u){return u=li(u,Br(at())),At(function(g){var w=this;return o(u,function(R){return zr(R,w,g)})})})}function _u(o,u){u=u===t?" ":Fr(u);var g=u.length;if(g<2)return g?Lf(u,o):u;var w=Lf(u,ru(o/$o(u)));return Jo(u)?qa(wn(w),0,o).join(""):w.slice(0,o)}function DN(o,u,g,w){var R=u&y,O=uh(o);function F(){for(var j=-1,K=arguments.length,me=-1,ve=w.length,Me=se(ve+K),ze=this&&this!==ji&&this instanceof F?O:o;++me<ve;)Me[me]=w[me];for(;K--;)Me[me++]=arguments[++j];return zr(ze,R?g:this,Me)}return F}function hx(o){return function(u,g,w){return w&&typeof w!="number"&&hr(u,g,w)&&(g=w=t),u=ma(u),g===t?(g=u,u=0):g=ma(g),w=w===t?u<g?1:-1:ma(w),_N(u,g,w,o)}}function vu(o){return function(u,g){return typeof u=="string"&&typeof g=="string"||(u=dn(u),g=dn(g)),o(u,g)}}function cx(o,u,g,w,R,O,F,j,K,me){var ve=u&b,Me=ve?F:t,ze=ve?t:F,Ye=ve?O:t,lt=ve?t:O;u|=ve?A:T,u&=~(ve?T:A),u&M||(u&=~(y|v));var Et=[o,u,R,Ye,Me,lt,ze,j,K,me],ht=g.apply(t,Et);return jf(o)&&wx(ht,Et),ht.placeholder=w,Mx(ht,o,u)}function Bf(o){var u=Ni[o];return function(g,w){if(g=dn(g),w=w==null?0:tr(wt(w),292),w&&My(g)){var R=(Xt(g)+"e").split("e"),O=u(R[0]+"e"+(+R[1]+w));return R=(Xt(O)+"e").split("e"),+(R[0]+"e"+(+R[1]-w))}return u(g)}}var IN=tl&&1/qc(new tl([,-0]))[1]==J?function(o){return new tl(o)}:sm;function ux(o){return function(u){var g=ir(u);return g==ue?ff(u):g==Z?ZO(u):GO(u,o(u))}}function ua(o,u,g,w,R,O,F,j){var K=u&v;if(!K&&typeof o!="function")throw new on(s);var me=w?w.length:0;if(me||(u&=~(A|T),w=R=t),F=F===t?F:Ui(wt(F),0),j=j===t?j:wt(j),me-=R?R.length:0,u&T){var ve=w,Me=R;w=R=t}var ze=K?t:Hf(o),Ye=[o,u,g,w,R,ve,Me,O,F,j];if(ze&&YN(Ye,ze),o=Ye[0],u=Ye[1],g=Ye[2],w=Ye[3],R=Ye[4],j=Ye[9]=Ye[9]===t?K?0:o.length:Ui(Ye[9]-me,0),!j&&u&(b|S)&&(u&=~(b|S)),!u||u==y)var lt=LN(o,u,g);else u==b||u==S?lt=PN(o,u,j):(u==A||u==(y|A))&&!R.length?lt=DN(o,u,g,w):lt=mu.apply(t,Ye);var Et=ze?jy:wx;return Mx(Et(lt,Ye),o,u)}function dx(o,u,g,w){return o===t||Tn(o,el[g])&&!Yt.call(w,g)?u:o}function px(o,u,g,w,R,O){return fi(o)&&fi(u)&&(O.set(u,o),uu(o,u,t,px,O),O.delete(u)),o}function ON(o){return fh(o)?t:o}function fx(o,u,g,w,R,O){var F=g&_,j=o.length,K=u.length;if(j!=K&&!(F&&K>j))return!1;var me=O.get(o),ve=O.get(u);if(me&&ve)return me==u&&ve==o;var Me=-1,ze=!0,Ye=g&x?new Ps:t;for(O.set(o,u),O.set(u,o);++Me<j;){var lt=o[Me],Et=u[Me];if(w)var ht=F?w(Et,lt,Me,u,o,O):w(lt,Et,Me,o,u,O);if(ht!==t){if(ht)continue;ze=!1;break}if(Ye){if(!lf(u,function(Ct,Ot){if(!eh(Ye,Ot)&&(lt===Ct||R(lt,Ct,g,w,O)))return Ye.push(Ot)})){ze=!1;break}}else if(!(lt===Et||R(lt,Et,g,w,O))){ze=!1;break}}return O.delete(o),O.delete(u),ze}function NN(o,u,g,w,R,O,F){switch(g){case Ge:if(o.byteLength!=u.byteLength||o.byteOffset!=u.byteOffset)return!1;o=o.buffer,u=u.buffer;case Ue:return!(o.byteLength!=u.byteLength||!O(new Qc(o),new Qc(u)));case $e:case qe:case de:return Tn(+o,+u);case ge:return o.name==u.name&&o.message==u.message;case L:case xe:return o==u+"";case ue:var j=ff;case Z:var K=w&_;if(j||(j=qc),o.size!=u.size&&!K)return!1;var me=F.get(o);if(me)return me==u;w|=x,F.set(o,u);var ve=fx(j(o),j(u),w,R,O,F);return F.delete(o),ve;case fe:if(ah)return ah.call(o)==ah.call(u)}return!1}function UN(o,u,g,w,R,O){var F=g&_,j=Ff(o),K=j.length,me=Ff(u),ve=me.length;if(K!=ve&&!F)return!1;for(var Me=K;Me--;){var ze=j[Me];if(!(F?ze in u:Yt.call(u,ze)))return!1}var Ye=O.get(o),lt=O.get(u);if(Ye&<)return Ye==u&<==o;var Et=!0;O.set(o,u),O.set(u,o);for(var ht=F;++Me<K;){ze=j[Me];var Ct=o[ze],Ot=u[ze];if(w)var Hr=F?w(Ot,Ct,ze,u,o,O):w(Ct,Ot,ze,o,u,O);if(!(Hr===t?Ct===Ot||R(Ct,Ot,g,w,O):Hr)){Et=!1;break}ht||(ht=ze=="constructor")}if(Et&&!ht){var cr=o.constructor,Gr=u.constructor;cr!=Gr&&"constructor"in o&&"constructor"in u&&!(typeof cr=="function"&&cr instanceof cr&&typeof Gr=="function"&&Gr instanceof Gr)&&(Et=!1)}return O.delete(o),O.delete(u),Et}function da(o){return qf(xx(o,t,Cx),o+"")}function Ff(o){return Oy(o,Vi,Vf)}function kf(o){return Oy(o,Er,mx)}var Hf=au?function(o){return au.get(o)}:sm;function yu(o){for(var u=o.name+"",g=il[u],w=Yt.call(il,u)?g.length:0;w--;){var R=g[w],O=R.func;if(O==null||O==o)return R.name}return u}function sl(o){var u=Yt.call(D,"placeholder")?D:o;return u.placeholder}function at(){var o=D.iteratee||nm;return o=o===nm?zy:o,arguments.length?o(arguments[0],arguments[1]):o}function xu(o,u){var g=o.__data__;return WN(u)?g[typeof u=="string"?"string":"hash"]:g.map}function Gf(o){for(var u=Vi(o),g=u.length;g--;){var w=u[g],R=o[w];u[g]=[w,R,vx(R)]}return u}function Os(o,u){var g=qO(o,u);return Uy(g)?g:t}function zN(o){var u=Yt.call(o,Cs),g=o[Cs];try{o[Cs]=t;var w=!0}catch{}var R=Jc.call(o);return w&&(u?o[Cs]=g:delete o[Cs]),R}var Vf=gf?function(o){return o==null?[]:(o=Qt(o),ka(gf(o),function(u){return by.call(o,u)}))}:om,mx=gf?function(o){for(var u=[];o;)Ha(u,Vf(o)),o=eu(o);return u}:om,ir=lr;(_f&&ir(new _f(new ArrayBuffer(1)))!=Ge||ih&&ir(new ih)!=ue||vf&&ir(vf.resolve())!=ke||tl&&ir(new tl)!=Z||rh&&ir(new rh)!=He)&&(ir=function(o){var u=lr(o),g=u==Fe?o.constructor:t,w=g?Ns(g):"";if(w)switch(w){case y3:return Ge;case x3:return ue;case b3:return ke;case w3:return Z;case M3:return He}return u});function BN(o,u,g){for(var w=-1,R=g.length;++w<R;){var O=g[w],F=O.size;switch(O.type){case"drop":o+=F;break;case"dropRight":u-=F;break;case"take":u=tr(u,o+F);break;case"takeRight":o=Ui(o,u-F);break}}return{start:o,end:u}}function FN(o){var u=o.match(kc);return u?u[1].split(Wo):[]}function gx(o,u,g){u=Xa(u,o);for(var w=-1,R=u.length,O=!1;++w<R;){var F=Vn(u[w]);if(!(O=o!=null&&g(o,F)))break;o=o[F]}return O||++w!=R?O:(R=o==null?0:o.length,!!R&&Au(R)&&pa(F,R)&&(_t(o)||Us(o)))}function kN(o){var u=o.length,g=new o.constructor(u);return u&&typeof o[0]=="string"&&Yt.call(o,"index")&&(g.index=o.index,g.input=o.input),g}function _x(o){return typeof o.constructor=="function"&&!dh(o)?rl(eu(o)):{}}function HN(o,u,g){var w=o.constructor;switch(u){case Ue:return Uf(o);case $e:case qe:return new w(+o);case Ge:return TN(o,g);case Je:case be:case dt:case B:case _e:case Ce:case Re:case Ve:case tt:return Qy(o,g);case ue:return new w;case de:case xe:return new w(o);case L:return SN(o);case Z:return new w;case fe:return EN(o)}}function GN(o,u){var g=u.length;if(!g)return o;var w=g-1;return u[w]=(g>1?"& ":"")+u[w],u=u.join(g>2?", ":" "),o.replace(Vo,`{ /* [wrapped with `+u+`] */ `)}function VN(o){return _t(o)||Us(o)||!!(wy&&o&&o[wy])}function pa(o,u){var g=typeof o;return u=u??ie,!!u&&(g=="number"||g!="symbol"&&re.test(o))&&o>-1&&o%1==0&&o<u}function hr(o,u,g){if(!fi(g))return!1;var w=typeof u;return(w=="number"?Sr(g)&&pa(u,g.length):w=="string"&&u in g)?Tn(g[u],o):!1}function Wf(o,u){if(_t(o))return!1;var g=typeof o;return g=="number"||g=="symbol"||g=="boolean"||o==null||kr(o)?!0:er.test(o)||!oi.test(o)||u!=null&&o in Qt(u)}function WN(o){var u=typeof o;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?o!=="__proto__":o===null}function jf(o){var u=yu(o),g=D[u];if(typeof g!="function"||!(u in Pt.prototype))return!1;if(o===g)return!0;var w=Hf(g);return!!w&&o===w[0]}function jN(o){return!!vy&&vy in o}var XN=Kc?fa:lm;function dh(o){var u=o&&o.constructor,g=typeof u=="function"&&u.prototype||el;return o===g}function vx(o){return o===o&&!fi(o)}function yx(o,u){return function(g){return g==null?!1:g[o]===u&&(u!==t||o in Qt(g))}}function qN(o){var u=Su(o,function(w){return g.size===c&&g.clear(),w}),g=u.cache;return u}function YN(o,u){var g=o[1],w=u[1],R=g|w,O=R<(y|v|E),F=w==E&&g==b||w==E&&g==I&&o[7].length<=u[8]||w==(E|I)&&u[7].length<=u[8]&&g==b;if(!(O||F))return o;w&y&&(o[2]=u[2],R|=g&y?0:M);var j=u[3];if(j){var K=o[3];o[3]=K?tx(K,j,u[4]):j,o[4]=K?Ga(o[3],d):u[4]}return j=u[5],j&&(K=o[5],o[5]=K?ix(K,j,u[6]):j,o[6]=K?Ga(o[5],d):u[6]),j=u[7],j&&(o[7]=j),w&E&&(o[8]=o[8]==null?u[8]:tr(o[8],u[8])),o[9]==null&&(o[9]=u[9]),o[0]=u[0],o[1]=R,o}function KN(o){var u=[];if(o!=null)for(var g in Qt(o))u.push(g);return u}function ZN(o){return Jc.call(o)}function xx(o,u,g){return u=Ui(u===t?o.length-1:u,0),function(){for(var w=arguments,R=-1,O=Ui(w.length-u,0),F=se(O);++R<O;)F[R]=w[u+R];R=-1;for(var j=se(u+1);++R<u;)j[R]=w[R];return j[u]=g(F),zr(o,this,j)}}function bx(o,u){return u.length<2?o:Is(o,cn(u,0,-1))}function JN(o,u){for(var g=o.length,w=tr(u.length,g),R=Tr(o);w--;){var O=u[w];o[w]=pa(O,g)?R[O]:t}return o}function Xf(o,u){if(!(u==="constructor"&&typeof o[u]=="function")&&u!="__proto__")return o[u]}var wx=Tx(jy),ph=d3||function(o,u){return ji.setTimeout(o,u)},qf=Tx(xN);function Mx(o,u,g){var w=u+"";return qf(o,GN(w,$N(FN(w),g)))}function Tx(o){var u=0,g=0;return function(){var w=g3(),R=te-(w-g);if(g=w,R>0){if(++u>=q)return arguments[0]}else u=0;return o.apply(t,arguments)}}function bu(o,u){var g=-1,w=o.length,R=w-1;for(u=u===t?w:u;++g<u;){var O=Cf(g,R),F=o[O];o[O]=o[g],o[g]=F}return o.length=u,o}var Sx=qN(function(o){var u=[];return o.charCodeAt(0)===46&&u.push(""),o.replace(jt,function(g,w,R,O){u.push(R?O.replace($p,"$1"):w||g)}),u});function Vn(o){if(typeof o=="string"||kr(o))return o;var u=o+"";return u=="0"&&1/o==-J?"-0":u}function Ns(o){if(o!=null){try{return Zc.call(o)}catch{}try{return o+""}catch{}}return""}function $N(o,u){return sn(ce,function(g){var w="_."+g[0];u&g[1]&&!jc(o,w)&&o.push(w)}),o.sort()}function Ex(o){if(o instanceof Pt)return o.clone();var u=new ln(o.__wrapped__,o.__chain__);return u.__actions__=Tr(o.__actions__),u.__index__=o.__index__,u.__values__=o.__values__,u}function QN(o,u,g){(g?hr(o,u,g):u===t)?u=1:u=Ui(wt(u),0);var w=o==null?0:o.length;if(!w||u<1)return[];for(var R=0,O=0,F=se(ru(w/u));R<w;)F[O++]=cn(o,R,R+=u);return F}function eU(o){for(var u=-1,g=o==null?0:o.length,w=0,R=[];++u<g;){var O=o[u];O&&(R[w++]=O)}return R}function tU(){var o=arguments.length;if(!o)return[];for(var u=se(o-1),g=arguments[0],w=o;w--;)u[w-1]=arguments[w];return Ha(_t(g)?Tr(g):[g],Xi(u,1))}var iU=At(function(o,u){return Ti(o)?oh(o,Xi(u,1,Ti,!0)):[]}),rU=At(function(o,u){var g=un(u);return Ti(g)&&(g=t),Ti(o)?oh(o,Xi(u,1,Ti,!0),at(g,2)):[]}),nU=At(function(o,u){var g=un(u);return Ti(g)&&(g=t),Ti(o)?oh(o,Xi(u,1,Ti,!0),t,g):[]});function aU(o,u,g){var w=o==null?0:o.length;return w?(u=g||u===t?1:wt(u),cn(o,u<0?0:u,w)):[]}function sU(o,u,g){var w=o==null?0:o.length;return w?(u=g||u===t?1:wt(u),u=w-u,cn(o,0,u<0?0:u)):[]}function oU(o,u){return o&&o.length?pu(o,at(u,3),!0,!0):[]}function lU(o,u){return o&&o.length?pu(o,at(u,3),!0):[]}function hU(o,u,g,w){var R=o==null?0:o.length;return R?(g&&typeof g!="number"&&hr(o,u,g)&&(g=0,w=R),tN(o,u,g,w)):[]}function Ax(o,u,g){var w=o==null?0:o.length;if(!w)return-1;var R=g==null?0:wt(g);return R<0&&(R=Ui(w+R,0)),Xc(o,at(u,3),R)}function Rx(o,u,g){var w=o==null?0:o.length;if(!w)return-1;var R=w-1;return g!==t&&(R=wt(g),R=g<0?Ui(w+R,0):tr(R,w-1)),Xc(o,at(u,3),R,!0)}function Cx(o){var u=o==null?0:o.length;return u?Xi(o,1):[]}function cU(o){var u=o==null?0:o.length;return u?Xi(o,J):[]}function uU(o,u){var g=o==null?0:o.length;return g?(u=u===t?1:wt(u),Xi(o,u)):[]}function dU(o){for(var u=-1,g=o==null?0:o.length,w={};++u<g;){var R=o[u];w[R[0]]=R[1]}return w}function Lx(o){return o&&o.length?o[0]:t}function pU(o,u,g){var w=o==null?0:o.length;if(!w)return-1;var R=g==null?0:wt(g);return R<0&&(R=Ui(w+R,0)),Zo(o,u,R)}function fU(o){var u=o==null?0:o.length;return u?cn(o,0,-1):[]}var mU=At(function(o){var u=li(o,Of);return u.length&&u[0]===o[0]?Tf(u):[]}),gU=At(function(o){var u=un(o),g=li(o,Of);return u===un(g)?u=t:g.pop(),g.length&&g[0]===o[0]?Tf(g,at(u,2)):[]}),_U=At(function(o){var u=un(o),g=li(o,Of);return u=typeof u=="function"?u:t,u&&g.pop(),g.length&&g[0]===o[0]?Tf(g,t,u):[]});function vU(o,u){return o==null?"":f3.call(o,u)}function un(o){var u=o==null?0:o.length;return u?o[u-1]:t}function yU(o,u,g){var w=o==null?0:o.length;if(!w)return-1;var R=w;return g!==t&&(R=wt(g),R=R<0?Ui(w+R,0):tr(R,w-1)),u===u?$O(o,u,R):Xc(o,cy,R,!0)}function xU(o,u){return o&&o.length?Hy(o,wt(u)):t}var bU=At(Px);function Px(o,u){return o&&o.length&&u&&u.length?Rf(o,u):o}function wU(o,u,g){return o&&o.length&&u&&u.length?Rf(o,u,at(g,2)):o}function MU(o,u,g){return o&&o.length&&u&&u.length?Rf(o,u,t,g):o}var TU=da(function(o,u){var g=o==null?0:o.length,w=xf(o,u);return Wy(o,li(u,function(R){return pa(R,g)?+R:R}).sort(ex)),w});function SU(o,u){var g=[];if(!(o&&o.length))return g;var w=-1,R=[],O=o.length;for(u=at(u,3);++w<O;){var F=o[w];u(F,w,o)&&(g.push(F),R.push(w))}return Wy(o,R),g}function Yf(o){return o==null?o:v3.call(o)}function EU(o,u,g){var w=o==null?0:o.length;return w?(g&&typeof g!="number"&&hr(o,u,g)?(u=0,g=w):(u=u==null?0:wt(u),g=g===t?w:wt(g)),cn(o,u,g)):[]}function AU(o,u){return du(o,u)}function RU(o,u,g){return Pf(o,u,at(g,2))}function CU(o,u){var g=o==null?0:o.length;if(g){var w=du(o,u);if(w<g&&Tn(o[w],u))return w}return-1}function LU(o,u){return du(o,u,!0)}function PU(o,u,g){return Pf(o,u,at(g,2),!0)}function DU(o,u){var g=o==null?0:o.length;if(g){var w=du(o,u,!0)-1;if(Tn(o[w],u))return w}return-1}function IU(o){return o&&o.length?Xy(o):[]}function OU(o,u){return o&&o.length?Xy(o,at(u,2)):[]}function NU(o){var u=o==null?0:o.length;return u?cn(o,1,u):[]}function UU(o,u,g){return o&&o.length?(u=g||u===t?1:wt(u),cn(o,0,u<0?0:u)):[]}function zU(o,u,g){var w=o==null?0:o.length;return w?(u=g||u===t?1:wt(u),u=w-u,cn(o,u<0?0:u,w)):[]}function BU(o,u){return o&&o.length?pu(o,at(u,3),!1,!0):[]}function FU(o,u){return o&&o.length?pu(o,at(u,3)):[]}var kU=At(function(o){return ja(Xi(o,1,Ti,!0))}),HU=At(function(o){var u=un(o);return Ti(u)&&(u=t),ja(Xi(o,1,Ti,!0),at(u,2))}),GU=At(function(o){var u=un(o);return u=typeof u=="function"?u:t,ja(Xi(o,1,Ti,!0),t,u)});function VU(o){return o&&o.length?ja(o):[]}function WU(o,u){return o&&o.length?ja(o,at(u,2)):[]}function jU(o,u){return u=typeof u=="function"?u:t,o&&o.length?ja(o,t,u):[]}function Kf(o){if(!(o&&o.length))return[];var u=0;return o=ka(o,function(g){if(Ti(g))return u=Ui(g.length,u),!0}),df(u,function(g){return li(o,hf(g))})}function Dx(o,u){if(!(o&&o.length))return[];var g=Kf(o);return u==null?g:li(g,function(w){return zr(u,t,w)})}var XU=At(function(o,u){return Ti(o)?oh(o,u):[]}),qU=At(function(o){return If(ka(o,Ti))}),YU=At(function(o){var u=un(o);return Ti(u)&&(u=t),If(ka(o,Ti),at(u,2))}),KU=At(function(o){var u=un(o);return u=typeof u=="function"?u:t,If(ka(o,Ti),t,u)}),ZU=At(Kf);function JU(o,u){return Zy(o||[],u||[],sh)}function $U(o,u){return Zy(o||[],u||[],ch)}var QU=At(function(o){var u=o.length,g=u>1?o[u-1]:t;return g=typeof g=="function"?(o.pop(),g):t,Dx(o,g)});function Ix(o){var u=D(o);return u.__chain__=!0,u}function ez(o,u){return u(o),o}function wu(o,u){return u(o)}var tz=da(function(o){var u=o.length,g=u?o[0]:0,w=this.__wrapped__,R=function(O){return xf(O,o)};return u>1||this.__actions__.length||!(w instanceof Pt)||!pa(g)?this.thru(R):(w=w.slice(g,+g+(u?1:0)),w.__actions__.push({func:wu,args:[R],thisArg:t}),new ln(w,this.__chain__).thru(function(O){return u&&!O.length&&O.push(t),O}))});function iz(){return Ix(this)}function rz(){return new ln(this.value(),this.__chain__)}function nz(){this.__values__===t&&(this.__values__=qx(this.value()));var o=this.__index__>=this.__values__.length,u=o?t:this.__values__[this.__index__++];return{done:o,value:u}}function az(){return this}function sz(o){for(var u,g=this;g instanceof ou;){var w=Ex(g);w.__index__=0,w.__values__=t,u?R.__wrapped__=w:u=w;var R=w;g=g.__wrapped__}return R.__wrapped__=o,u}function oz(){var o=this.__wrapped__;if(o instanceof Pt){var u=o;return this.__actions__.length&&(u=new Pt(this)),u=u.reverse(),u.__actions__.push({func:wu,args:[Yf],thisArg:t}),new ln(u,this.__chain__)}return this.thru(Yf)}function lz(){return Ky(this.__wrapped__,this.__actions__)}var hz=fu(function(o,u,g){Yt.call(o,g)?++o[g]:ca(o,g,1)});function cz(o,u,g){var w=_t(o)?ly:eN;return g&&hr(o,u,g)&&(u=t),w(o,at(u,3))}function uz(o,u){var g=_t(o)?ka:Dy;return g(o,at(u,3))}var dz=sx(Ax),pz=sx(Rx);function fz(o,u){return Xi(Mu(o,u),1)}function mz(o,u){return Xi(Mu(o,u),J)}function gz(o,u,g){return g=g===t?1:wt(g),Xi(Mu(o,u),g)}function Ox(o,u){var g=_t(o)?sn:Wa;return g(o,at(u,3))}function Nx(o,u){var g=_t(o)?NO:Py;return g(o,at(u,3))}var _z=fu(function(o,u,g){Yt.call(o,g)?o[g].push(u):ca(o,g,[u])});function vz(o,u,g,w){o=Sr(o)?o:ll(o),g=g&&!w?wt(g):0;var R=o.length;return g<0&&(g=Ui(R+g,0)),Ru(o)?g<=R&&o.indexOf(u,g)>-1:!!R&&Zo(o,u,g)>-1}var yz=At(function(o,u,g){var w=-1,R=typeof u=="function",O=Sr(o)?se(o.length):[];return Wa(o,function(F){O[++w]=R?zr(u,F,g):lh(F,u,g)}),O}),xz=fu(function(o,u,g){ca(o,g,u)});function Mu(o,u){var g=_t(o)?li:By;return g(o,at(u,3))}function bz(o,u,g,w){return o==null?[]:(_t(u)||(u=u==null?[]:[u]),g=w?t:g,_t(g)||(g=g==null?[]:[g]),Gy(o,u,g))}var wz=fu(function(o,u,g){o[g?0:1].push(u)},function(){return[[],[]]});function Mz(o,u,g){var w=_t(o)?of:dy,R=arguments.length<3;return w(o,at(u,4),g,R,Wa)}function Tz(o,u,g){var w=_t(o)?UO:dy,R=arguments.length<3;return w(o,at(u,4),g,R,Py)}function Sz(o,u){var g=_t(o)?ka:Dy;return g(o,Eu(at(u,3)))}function Ez(o){var u=_t(o)?Ay:vN;return u(o)}function Az(o,u,g){(g?hr(o,u,g):u===t)?u=1:u=wt(u);var w=_t(o)?K3:yN;return w(o,u)}function Rz(o){var u=_t(o)?Z3:bN;return u(o)}function Cz(o){if(o==null)return 0;if(Sr(o))return Ru(o)?$o(o):o.length;var u=ir(o);return u==ue||u==Z?o.size:Ef(o).length}function Lz(o,u,g){var w=_t(o)?lf:wN;return g&&hr(o,u,g)&&(u=t),w(o,at(u,3))}var Pz=At(function(o,u){if(o==null)return[];var g=u.length;return g>1&&hr(o,u[0],u[1])?u=[]:g>2&&hr(u[0],u[1],u[2])&&(u=[u[0]]),Gy(o,Xi(u,1),[])}),Tu=u3||function(){return ji.Date.now()};function Dz(o,u){if(typeof u!="function")throw new on(s);return o=wt(o),function(){if(--o<1)return u.apply(this,arguments)}}function Ux(o,u,g){return u=g?t:u,u=o&&u==null?o.length:u,ua(o,E,t,t,t,t,u)}function zx(o,u){var g;if(typeof u!="function")throw new on(s);return o=wt(o),function(){return--o>0&&(g=u.apply(this,arguments)),o<=1&&(u=t),g}}var Zf=At(function(o,u,g){var w=y;if(g.length){var R=Ga(g,sl(Zf));w|=A}return ua(o,w,u,g,R)}),Bx=At(function(o,u,g){var w=y|v;if(g.length){var R=Ga(g,sl(Bx));w|=A}return ua(u,w,o,g,R)});function Fx(o,u,g){u=g?t:u;var w=ua(o,b,t,t,t,t,t,u);return w.placeholder=Fx.placeholder,w}function kx(o,u,g){u=g?t:u;var w=ua(o,S,t,t,t,t,t,u);return w.placeholder=kx.placeholder,w}function Hx(o,u,g){var w,R,O,F,j,K,me=0,ve=!1,Me=!1,ze=!0;if(typeof o!="function")throw new on(s);u=dn(u)||0,fi(g)&&(ve=!!g.leading,Me="maxWait"in g,O=Me?Ui(dn(g.maxWait)||0,u):O,ze="trailing"in g?!!g.trailing:ze);function Ye(Si){var Sn=w,ga=R;return w=R=t,me=Si,F=o.apply(ga,Sn),F}function lt(Si){return me=Si,j=ph(Ct,u),ve?Ye(Si):F}function Et(Si){var Sn=Si-K,ga=Si-me,s1=u-Sn;return Me?tr(s1,O-ga):s1}function ht(Si){var Sn=Si-K,ga=Si-me;return K===t||Sn>=u||Sn<0||Me&&ga>=O}function Ct(){var Si=Tu();if(ht(Si))return Ot(Si);j=ph(Ct,Et(Si))}function Ot(Si){return j=t,ze&&w?Ye(Si):(w=R=t,F)}function Hr(){j!==t&&Jy(j),me=0,w=K=R=j=t}function cr(){return j===t?F:Ot(Tu())}function Gr(){var Si=Tu(),Sn=ht(Si);if(w=arguments,R=this,K=Si,Sn){if(j===t)return lt(K);if(Me)return Jy(j),j=ph(Ct,u),Ye(K)}return j===t&&(j=ph(Ct,u)),F}return Gr.cancel=Hr,Gr.flush=cr,Gr}var Iz=At(function(o,u){return Ly(o,1,u)}),Oz=At(function(o,u,g){return Ly(o,dn(u)||0,g)});function Nz(o){return ua(o,C)}function Su(o,u){if(typeof o!="function"||u!=null&&typeof u!="function")throw new on(s);var g=function(){var w=arguments,R=u?u.apply(this,w):w[0],O=g.cache;if(O.has(R))return O.get(R);var F=o.apply(this,w);return g.cache=O.set(R,F)||O,F};return g.cache=new(Su.Cache||ha),g}Su.Cache=ha;function Eu(o){if(typeof o!="function")throw new on(s);return function(){var u=arguments;switch(u.length){case 0:return!o.call(this);case 1:return!o.call(this,u[0]);case 2:return!o.call(this,u[0],u[1]);case 3:return!o.call(this,u[0],u[1],u[2])}return!o.apply(this,u)}}function Uz(o){return zx(2,o)}var zz=MN(function(o,u){u=u.length==1&&_t(u[0])?li(u[0],Br(at())):li(Xi(u,1),Br(at()));var g=u.length;return At(function(w){for(var R=-1,O=tr(w.length,g);++R<O;)w[R]=u[R].call(this,w[R]);return zr(o,this,w)})}),Jf=At(function(o,u){var g=Ga(u,sl(Jf));return ua(o,A,t,u,g)}),Gx=At(function(o,u){var g=Ga(u,sl(Gx));return ua(o,T,t,u,g)}),Bz=da(function(o,u){return ua(o,I,t,t,t,u)});function Fz(o,u){if(typeof o!="function")throw new on(s);return u=u===t?u:wt(u),At(o,u)}function kz(o,u){if(typeof o!="function")throw new on(s);return u=u==null?0:Ui(wt(u),0),At(function(g){var w=g[u],R=qa(g,0,u);return w&&Ha(R,w),zr(o,this,R)})}function Hz(o,u,g){var w=!0,R=!0;if(typeof o!="function")throw new on(s);return fi(g)&&(w="leading"in g?!!g.leading:w,R="trailing"in g?!!g.trailing:R),Hx(o,u,{leading:w,maxWait:u,trailing:R})}function Gz(o){return Ux(o,1)}function Vz(o,u){return Jf(Nf(u),o)}function Wz(){if(!arguments.length)return[];var o=arguments[0];return _t(o)?o:[o]}function jz(o){return hn(o,m)}function Xz(o,u){return u=typeof u=="function"?u:t,hn(o,m,u)}function qz(o){return hn(o,p|m)}function Yz(o,u){return u=typeof u=="function"?u:t,hn(o,p|m,u)}function Kz(o,u){return u==null||Cy(o,u,Vi(u))}function Tn(o,u){return o===u||o!==o&&u!==u}var Zz=vu(Mf),Jz=vu(function(o,u){return o>=u}),Us=Ny(function(){return arguments}())?Ny:function(o){return yi(o)&&Yt.call(o,"callee")&&!by.call(o,"callee")},_t=se.isArray,$z=iy?Br(iy):sN;function Sr(o){return o!=null&&Au(o.length)&&!fa(o)}function Ti(o){return yi(o)&&Sr(o)}function Qz(o){return o===!0||o===!1||yi(o)&&lr(o)==$e}var Ya=p3||lm,eB=ry?Br(ry):oN;function tB(o){return yi(o)&&o.nodeType===1&&!fh(o)}function iB(o){if(o==null)return!0;if(Sr(o)&&(_t(o)||typeof o=="string"||typeof o.splice=="function"||Ya(o)||ol(o)||Us(o)))return!o.length;var u=ir(o);if(u==ue||u==Z)return!o.size;if(dh(o))return!Ef(o).length;for(var g in o)if(Yt.call(o,g))return!1;return!0}function rB(o,u){return hh(o,u)}function nB(o,u,g){g=typeof g=="function"?g:t;var w=g?g(o,u):t;return w===t?hh(o,u,t,g):!!w}function $f(o){if(!yi(o))return!1;var u=lr(o);return u==ge||u==Xe||typeof o.message=="string"&&typeof o.name=="string"&&!fh(o)}function aB(o){return typeof o=="number"&&My(o)}function fa(o){if(!fi(o))return!1;var u=lr(o);return u==G||u==Ae||u==je||u==N}function Vx(o){return typeof o=="number"&&o==wt(o)}function Au(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=ie}function fi(o){var u=typeof o;return o!=null&&(u=="object"||u=="function")}function yi(o){return o!=null&&typeof o=="object"}var Wx=ny?Br(ny):hN;function sB(o,u){return o===u||Sf(o,u,Gf(u))}function oB(o,u,g){return g=typeof g=="function"?g:t,Sf(o,u,Gf(u),g)}function lB(o){return jx(o)&&o!=+o}function hB(o){if(XN(o))throw new pt(a);return Uy(o)}function cB(o){return o===null}function uB(o){return o==null}function jx(o){return typeof o=="number"||yi(o)&&lr(o)==de}function fh(o){if(!yi(o)||lr(o)!=Fe)return!1;var u=eu(o);if(u===null)return!0;var g=Yt.call(u,"constructor")&&u.constructor;return typeof g=="function"&&g instanceof g&&Zc.call(g)==o3}var Qf=ay?Br(ay):cN;function dB(o){return Vx(o)&&o>=-ie&&o<=ie}var Xx=sy?Br(sy):uN;function Ru(o){return typeof o=="string"||!_t(o)&&yi(o)&&lr(o)==xe}function kr(o){return typeof o=="symbol"||yi(o)&&lr(o)==fe}var ol=oy?Br(oy):dN;function pB(o){return o===t}function fB(o){return yi(o)&&ir(o)==He}function mB(o){return yi(o)&&lr(o)==Ie}var gB=vu(Af),_B=vu(function(o,u){return o<=u});function qx(o){if(!o)return[];if(Sr(o))return Ru(o)?wn(o):Tr(o);if(th&&o[th])return KO(o[th]());var u=ir(o),g=u==ue?ff:u==Z?qc:ll;return g(o)}function ma(o){if(!o)return o===0?o:0;if(o=dn(o),o===J||o===-J){var u=o<0?-1:1;return u*$}return o===o?o:0}function wt(o){var u=ma(o),g=u%1;return u===u?g?u-g:u:0}function Yx(o){return o?Ds(wt(o),0,he):0}function dn(o){if(typeof o=="number")return o;if(kr(o))return ne;if(fi(o)){var u=typeof o.valueOf=="function"?o.valueOf():o;o=fi(u)?u+"":u}if(typeof o!="string")return o===0?o:+o;o=py(o);var g=Q.test(o);return g||oe.test(o)?DO(o.slice(2),g?2:8):U.test(o)?ne:+o}function Kx(o){return Gn(o,Er(o))}function vB(o){return o?Ds(wt(o),-ie,ie):o===0?o:0}function Xt(o){return o==null?"":Fr(o)}var yB=nl(function(o,u){if(dh(u)||Sr(u)){Gn(u,Vi(u),o);return}for(var g in u)Yt.call(u,g)&&sh(o,g,u[g])}),Zx=nl(function(o,u){Gn(u,Er(u),o)}),Cu=nl(function(o,u,g,w){Gn(u,Er(u),o,w)}),xB=nl(function(o,u,g,w){Gn(u,Vi(u),o,w)}),bB=da(xf);function wB(o,u){var g=rl(o);return u==null?g:Ry(g,u)}var MB=At(function(o,u){o=Qt(o);var g=-1,w=u.length,R=w>2?u[2]:t;for(R&&hr(u[0],u[1],R)&&(w=1);++g<w;)for(var O=u[g],F=Er(O),j=-1,K=F.length;++j<K;){var me=F[j],ve=o[me];(ve===t||Tn(ve,el[me])&&!Yt.call(o,me))&&(o[me]=O[me])}return o}),TB=At(function(o){return o.push(t,px),zr(Jx,t,o)});function SB(o,u){return hy(o,at(u,3),Hn)}function EB(o,u){return hy(o,at(u,3),wf)}function AB(o,u){return o==null?o:bf(o,at(u,3),Er)}function RB(o,u){return o==null?o:Iy(o,at(u,3),Er)}function CB(o,u){return o&&Hn(o,at(u,3))}function LB(o,u){return o&&wf(o,at(u,3))}function PB(o){return o==null?[]:cu(o,Vi(o))}function DB(o){return o==null?[]:cu(o,Er(o))}function em(o,u,g){var w=o==null?t:Is(o,u);return w===t?g:w}function IB(o,u){return o!=null&&gx(o,u,iN)}function tm(o,u){return o!=null&&gx(o,u,rN)}var OB=lx(function(o,u,g){u!=null&&typeof u.toString!="function"&&(u=Jc.call(u)),o[u]=g},rm(Ar)),NB=lx(function(o,u,g){u!=null&&typeof u.toString!="function"&&(u=Jc.call(u)),Yt.call(o,u)?o[u].push(g):o[u]=[g]},at),UB=At(lh);function Vi(o){return Sr(o)?Ey(o):Ef(o)}function Er(o){return Sr(o)?Ey(o,!0):pN(o)}function zB(o,u){var g={};return u=at(u,3),Hn(o,function(w,R,O){ca(g,u(w,R,O),w)}),g}function BB(o,u){var g={};return u=at(u,3),Hn(o,function(w,R,O){ca(g,R,u(w,R,O))}),g}var FB=nl(function(o,u,g){uu(o,u,g)}),Jx=nl(function(o,u,g,w){uu(o,u,g,w)}),kB=da(function(o,u){var g={};if(o==null)return g;var w=!1;u=li(u,function(O){return O=Xa(O,o),w||(w=O.length>1),O}),Gn(o,kf(o),g),w&&(g=hn(g,p|f|m,ON));for(var R=u.length;R--;)Df(g,u[R]);return g});function HB(o,u){return $x(o,Eu(at(u)))}var GB=da(function(o,u){return o==null?{}:mN(o,u)});function $x(o,u){if(o==null)return{};var g=li(kf(o),function(w){return[w]});return u=at(u),Vy(o,g,function(w,R){return u(w,R[0])})}function VB(o,u,g){u=Xa(u,o);var w=-1,R=u.length;for(R||(R=1,o=t);++w<R;){var O=o==null?t:o[Vn(u[w])];O===t&&(w=R,O=g),o=fa(O)?O.call(o):O}return o}function WB(o,u,g){return o==null?o:ch(o,u,g)}function jB(o,u,g,w){return w=typeof w=="function"?w:t,o==null?o:ch(o,u,g,w)}var Qx=ux(Vi),e1=ux(Er);function XB(o,u,g){var w=_t(o),R=w||Ya(o)||ol(o);if(u=at(u,4),g==null){var O=o&&o.constructor;R?g=w?new O:[]:fi(o)?g=fa(O)?rl(eu(o)):{}:g={}}return(R?sn:Hn)(o,function(F,j,K){return u(g,F,j,K)}),g}function qB(o,u){return o==null?!0:Df(o,u)}function YB(o,u,g){return o==null?o:Yy(o,u,Nf(g))}function KB(o,u,g,w){return w=typeof w=="function"?w:t,o==null?o:Yy(o,u,Nf(g),w)}function ll(o){return o==null?[]:pf(o,Vi(o))}function ZB(o){return o==null?[]:pf(o,Er(o))}function JB(o,u,g){return g===t&&(g=u,u=t),g!==t&&(g=dn(g),g=g===g?g:0),u!==t&&(u=dn(u),u=u===u?u:0),Ds(dn(o),u,g)}function $B(o,u,g){return u=ma(u),g===t?(g=u,u=0):g=ma(g),o=dn(o),nN(o,u,g)}function QB(o,u,g){if(g&&typeof g!="boolean"&&hr(o,u,g)&&(u=g=t),g===t&&(typeof u=="boolean"?(g=u,u=t):typeof o=="boolean"&&(g=o,o=t)),o===t&&u===t?(o=0,u=1):(o=ma(o),u===t?(u=o,o=0):u=ma(u)),o>u){var w=o;o=u,u=w}if(g||o%1||u%1){var R=Ty();return tr(o+R*(u-o+PO("1e-"+((R+"").length-1))),u)}return Cf(o,u)}var eF=al(function(o,u,g){return u=u.toLowerCase(),o+(g?t1(u):u)});function t1(o){return im(Xt(o).toLowerCase())}function i1(o){return o=Xt(o),o&&o.replace(Ne,WO).replace(bO,"")}function tF(o,u,g){o=Xt(o),u=Fr(u);var w=o.length;g=g===t?w:Ds(wt(g),0,w);var R=g;return g-=u.length,g>=0&&o.slice(g,R)==u}function iF(o){return o=Xt(o),o&&et.test(o)?o.replace(we,jO):o}function rF(o){return o=Xt(o),o&&rn.test(o)?o.replace(Di,"\\$&"):o}var nF=al(function(o,u,g){return o+(g?"-":"")+u.toLowerCase()}),aF=al(function(o,u,g){return o+(g?" ":"")+u.toLowerCase()}),sF=ax("toLowerCase");function oF(o,u,g){o=Xt(o),u=wt(u);var w=u?$o(o):0;if(!u||w>=u)return o;var R=(u-w)/2;return _u(nu(R),g)+o+_u(ru(R),g)}function lF(o,u,g){o=Xt(o),u=wt(u);var w=u?$o(o):0;return u&&w<u?o+_u(u-w,g):o}function hF(o,u,g){o=Xt(o),u=wt(u);var w=u?$o(o):0;return u&&w<u?_u(u-w,g)+o:o}function cF(o,u,g){return g||u==null?u=0:u&&(u=+u),_3(Xt(o).replace(Go,""),u||0)}function uF(o,u,g){return(g?hr(o,u,g):u===t)?u=1:u=wt(u),Lf(Xt(o),u)}function dF(){var o=arguments,u=Xt(o[0]);return o.length<3?u:u.replace(o[1],o[2])}var pF=al(function(o,u,g){return o+(g?"_":"")+u.toLowerCase()});function fF(o,u,g){return g&&typeof g!="number"&&hr(o,u,g)&&(u=g=t),g=g===t?he:g>>>0,g?(o=Xt(o),o&&(typeof u=="string"||u!=null&&!Qf(u))&&(u=Fr(u),!u&&Jo(o))?qa(wn(o),0,g):o.split(u,g)):[]}var mF=al(function(o,u,g){return o+(g?" ":"")+im(u)});function gF(o,u,g){return o=Xt(o),g=g==null?0:Ds(wt(g),0,o.length),u=Fr(u),o.slice(g,g+u.length)==u}function _F(o,u,g){var w=D.templateSettings;g&&hr(o,u,g)&&(u=t),o=Xt(o),u=Cu({},u,w,dx);var R=Cu({},u.imports,w.imports,dx),O=Vi(R),F=pf(R,O),j,K,me=0,ve=u.interpolate||Qe,Me="__p += '",ze=mf((u.escape||Qe).source+"|"+ve.source+"|"+(ve===Ut?Qp:Qe).source+"|"+(u.evaluate||Qe).source+"|$","g"),Ye="//# sourceURL="+(Yt.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++EO+"]")+` `;o.replace(ze,function(ht,Ct,Ot,Hr,cr,Gr){return Ot||(Ot=Hr),Me+=o.slice(me,Gr).replace(ot,XO),Ct&&(j=!0,Me+=`' + __e(`+Ct+`) + '`),cr&&(K=!0,Me+=`'; `+cr+`; __p += '`),Ot&&(Me+=`' + ((__t = (`+Ot+`)) == null ? '' : __t) + '`),me=Gr+ht.length,ht}),Me+=`'; `;var lt=Yt.call(u,"variable")&&u.variable;if(!lt)Me=`with (obj) { `+Me+` } `;else if(Gc.test(lt))throw new pt(l);Me=(K?Me.replace(Tt,""):Me).replace(ut,"$1").replace(Le,"$1;"),Me="function("+(lt||"obj")+`) { `+(lt?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(j?", __e = _.escape":"")+(K?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+Me+`return __p }`;var Et=n1(function(){return Ht(O,Ye+"return "+Me).apply(t,F)});if(Et.source=Me,$f(Et))throw Et;return Et}function vF(o){return Xt(o).toLowerCase()}function yF(o){return Xt(o).toUpperCase()}function xF(o,u,g){if(o=Xt(o),o&&(g||u===t))return py(o);if(!o||!(u=Fr(u)))return o;var w=wn(o),R=wn(u),O=fy(w,R),F=my(w,R)+1;return qa(w,O,F).join("")}function bF(o,u,g){if(o=Xt(o),o&&(g||u===t))return o.slice(0,_y(o)+1);if(!o||!(u=Fr(u)))return o;var w=wn(o),R=my(w,wn(u))+1;return qa(w,0,R).join("")}function wF(o,u,g){if(o=Xt(o),o&&(g||u===t))return o.replace(Go,"");if(!o||!(u=Fr(u)))return o;var w=wn(o),R=fy(w,wn(u));return qa(w,R).join("")}function MF(o,u){var g=P,w=X;if(fi(u)){var R="separator"in u?u.separator:R;g="length"in u?wt(u.length):g,w="omission"in u?Fr(u.omission):w}o=Xt(o);var O=o.length;if(Jo(o)){var F=wn(o);O=F.length}if(g>=O)return o;var j=g-$o(w);if(j<1)return w;var K=F?qa(F,0,j).join(""):o.slice(0,j);if(R===t)return K+w;if(F&&(j+=K.length-j),Qf(R)){if(o.slice(j).search(R)){var me,ve=K;for(R.global||(R=mf(R.source,Xt(Vc.exec(R))+"g")),R.lastIndex=0;me=R.exec(ve);)var Me=me.index;K=K.slice(0,Me===t?j:Me)}}else if(o.indexOf(Fr(R),j)!=j){var ze=K.lastIndexOf(R);ze>-1&&(K=K.slice(0,ze))}return K+w}function TF(o){return o=Xt(o),o&&Pe.test(o)?o.replace(W,QO):o}var SF=al(function(o,u,g){return o+(g?" ":"")+u.toUpperCase()}),im=ax("toUpperCase");function r1(o,u,g){return o=Xt(o),u=g?t:u,u===t?YO(o)?i3(o):FO(o):o.match(u)||[]}var n1=At(function(o,u){try{return zr(o,t,u)}catch(g){return $f(g)?g:new pt(g)}}),EF=da(function(o,u){return sn(u,function(g){g=Vn(g),ca(o,g,Zf(o[g],o))}),o});function AF(o){var u=o==null?0:o.length,g=at();return o=u?li(o,function(w){if(typeof w[1]!="function")throw new on(s);return[g(w[0]),w[1]]}):[],At(function(w){for(var R=-1;++R<u;){var O=o[R];if(zr(O[0],this,w))return zr(O[1],this,w)}})}function RF(o){return Q3(hn(o,p))}function rm(o){return function(){return o}}function CF(o,u){return o==null||o!==o?u:o}var LF=ox(),PF=ox(!0);function Ar(o){return o}function nm(o){return zy(typeof o=="function"?o:hn(o,p))}function DF(o){return Fy(hn(o,p))}function IF(o,u){return ky(o,hn(u,p))}var OF=At(function(o,u){return function(g){return lh(g,o,u)}}),NF=At(function(o,u){return function(g){return lh(o,g,u)}});function am(o,u,g){var w=Vi(u),R=cu(u,w);g==null&&!(fi(u)&&(R.length||!w.length))&&(g=u,u=o,o=this,R=cu(u,Vi(u)));var O=!(fi(g)&&"chain"in g)||!!g.chain,F=fa(o);return sn(R,function(j){var K=u[j];o[j]=K,F&&(o.prototype[j]=function(){var me=this.__chain__;if(O||me){var ve=o(this.__wrapped__),Me=ve.__actions__=Tr(this.__actions__);return Me.push({func:K,args:arguments,thisArg:o}),ve.__chain__=me,ve}return K.apply(o,Ha([this.value()],arguments))})}),o}function UF(){return ji._===this&&(ji._=l3),this}function sm(){}function zF(o){return o=wt(o),At(function(u){return Hy(u,o)})}var BF=zf(li),FF=zf(ly),kF=zf(lf);function a1(o){return Wf(o)?hf(Vn(o)):gN(o)}function HF(o){return function(u){return o==null?t:Is(o,u)}}var GF=hx(),VF=hx(!0);function om(){return[]}function lm(){return!1}function WF(){return{}}function jF(){return""}function XF(){return!0}function qF(o,u){if(o=wt(o),o<1||o>ie)return[];var g=he,w=tr(o,he);u=at(u),o-=he;for(var R=df(w,u);++g<o;)u(g);return R}function YF(o){return _t(o)?li(o,Vn):kr(o)?[o]:Tr(Sx(Xt(o)))}function KF(o){var u=++s3;return Xt(o)+u}var ZF=gu(function(o,u){return o+u},0),JF=Bf("ceil"),$F=gu(function(o,u){return o/u},1),QF=Bf("floor");function ek(o){return o&&o.length?hu(o,Ar,Mf):t}function tk(o,u){return o&&o.length?hu(o,at(u,2),Mf):t}function ik(o){return uy(o,Ar)}function rk(o,u){return uy(o,at(u,2))}function nk(o){return o&&o.length?hu(o,Ar,Af):t}function ak(o,u){return o&&o.length?hu(o,at(u,2),Af):t}var sk=gu(function(o,u){return o*u},1),ok=Bf("round"),lk=gu(function(o,u){return o-u},0);function hk(o){return o&&o.length?uf(o,Ar):0}function ck(o,u){return o&&o.length?uf(o,at(u,2)):0}return D.after=Dz,D.ary=Ux,D.assign=yB,D.assignIn=Zx,D.assignInWith=Cu,D.assignWith=xB,D.at=bB,D.before=zx,D.bind=Zf,D.bindAll=EF,D.bindKey=Bx,D.castArray=Wz,D.chain=Ix,D.chunk=QN,D.compact=eU,D.concat=tU,D.cond=AF,D.conforms=RF,D.constant=rm,D.countBy=hz,D.create=wB,D.curry=Fx,D.curryRight=kx,D.debounce=Hx,D.defaults=MB,D.defaultsDeep=TB,D.defer=Iz,D.delay=Oz,D.difference=iU,D.differenceBy=rU,D.differenceWith=nU,D.drop=aU,D.dropRight=sU,D.dropRightWhile=oU,D.dropWhile=lU,D.fill=hU,D.filter=uz,D.flatMap=fz,D.flatMapDeep=mz,D.flatMapDepth=gz,D.flatten=Cx,D.flattenDeep=cU,D.flattenDepth=uU,D.flip=Nz,D.flow=LF,D.flowRight=PF,D.fromPairs=dU,D.functions=PB,D.functionsIn=DB,D.groupBy=_z,D.initial=fU,D.intersection=mU,D.intersectionBy=gU,D.intersectionWith=_U,D.invert=OB,D.invertBy=NB,D.invokeMap=yz,D.iteratee=nm,D.keyBy=xz,D.keys=Vi,D.keysIn=Er,D.map=Mu,D.mapKeys=zB,D.mapValues=BB,D.matches=DF,D.matchesProperty=IF,D.memoize=Su,D.merge=FB,D.mergeWith=Jx,D.method=OF,D.methodOf=NF,D.mixin=am,D.negate=Eu,D.nthArg=zF,D.omit=kB,D.omitBy=HB,D.once=Uz,D.orderBy=bz,D.over=BF,D.overArgs=zz,D.overEvery=FF,D.overSome=kF,D.partial=Jf,D.partialRight=Gx,D.partition=wz,D.pick=GB,D.pickBy=$x,D.property=a1,D.propertyOf=HF,D.pull=bU,D.pullAll=Px,D.pullAllBy=wU,D.pullAllWith=MU,D.pullAt=TU,D.range=GF,D.rangeRight=VF,D.rearg=Bz,D.reject=Sz,D.remove=SU,D.rest=Fz,D.reverse=Yf,D.sampleSize=Az,D.set=WB,D.setWith=jB,D.shuffle=Rz,D.slice=EU,D.sortBy=Pz,D.sortedUniq=IU,D.sortedUniqBy=OU,D.split=fF,D.spread=kz,D.tail=NU,D.take=UU,D.takeRight=zU,D.takeRightWhile=BU,D.takeWhile=FU,D.tap=ez,D.throttle=Hz,D.thru=wu,D.toArray=qx,D.toPairs=Qx,D.toPairsIn=e1,D.toPath=YF,D.toPlainObject=Kx,D.transform=XB,D.unary=Gz,D.union=kU,D.unionBy=HU,D.unionWith=GU,D.uniq=VU,D.uniqBy=WU,D.uniqWith=jU,D.unset=qB,D.unzip=Kf,D.unzipWith=Dx,D.update=YB,D.updateWith=KB,D.values=ll,D.valuesIn=ZB,D.without=XU,D.words=r1,D.wrap=Vz,D.xor=qU,D.xorBy=YU,D.xorWith=KU,D.zip=ZU,D.zipObject=JU,D.zipObjectDeep=$U,D.zipWith=QU,D.entries=Qx,D.entriesIn=e1,D.extend=Zx,D.extendWith=Cu,am(D,D),D.add=ZF,D.attempt=n1,D.camelCase=eF,D.capitalize=t1,D.ceil=JF,D.clamp=JB,D.clone=jz,D.cloneDeep=qz,D.cloneDeepWith=Yz,D.cloneWith=Xz,D.conformsTo=Kz,D.deburr=i1,D.defaultTo=CF,D.divide=$F,D.endsWith=tF,D.eq=Tn,D.escape=iF,D.escapeRegExp=rF,D.every=cz,D.find=dz,D.findIndex=Ax,D.findKey=SB,D.findLast=pz,D.findLastIndex=Rx,D.findLastKey=EB,D.floor=QF,D.forEach=Ox,D.forEachRight=Nx,D.forIn=AB,D.forInRight=RB,D.forOwn=CB,D.forOwnRight=LB,D.get=em,D.gt=Zz,D.gte=Jz,D.has=IB,D.hasIn=tm,D.head=Lx,D.identity=Ar,D.includes=vz,D.indexOf=pU,D.inRange=$B,D.invoke=UB,D.isArguments=Us,D.isArray=_t,D.isArrayBuffer=$z,D.isArrayLike=Sr,D.isArrayLikeObject=Ti,D.isBoolean=Qz,D.isBuffer=Ya,D.isDate=eB,D.isElement=tB,D.isEmpty=iB,D.isEqual=rB,D.isEqualWith=nB,D.isError=$f,D.isFinite=aB,D.isFunction=fa,D.isInteger=Vx,D.isLength=Au,D.isMap=Wx,D.isMatch=sB,D.isMatchWith=oB,D.isNaN=lB,D.isNative=hB,D.isNil=uB,D.isNull=cB,D.isNumber=jx,D.isObject=fi,D.isObjectLike=yi,D.isPlainObject=fh,D.isRegExp=Qf,D.isSafeInteger=dB,D.isSet=Xx,D.isString=Ru,D.isSymbol=kr,D.isTypedArray=ol,D.isUndefined=pB,D.isWeakMap=fB,D.isWeakSet=mB,D.join=vU,D.kebabCase=nF,D.last=un,D.lastIndexOf=yU,D.lowerCase=aF,D.lowerFirst=sF,D.lt=gB,D.lte=_B,D.max=ek,D.maxBy=tk,D.mean=ik,D.meanBy=rk,D.min=nk,D.minBy=ak,D.stubArray=om,D.stubFalse=lm,D.stubObject=WF,D.stubString=jF,D.stubTrue=XF,D.multiply=sk,D.nth=xU,D.noConflict=UF,D.noop=sm,D.now=Tu,D.pad=oF,D.padEnd=lF,D.padStart=hF,D.parseInt=cF,D.random=QB,D.reduce=Mz,D.reduceRight=Tz,D.repeat=uF,D.replace=dF,D.result=VB,D.round=ok,D.runInContext=Y,D.sample=Ez,D.size=Cz,D.snakeCase=pF,D.some=Lz,D.sortedIndex=AU,D.sortedIndexBy=RU,D.sortedIndexOf=CU,D.sortedLastIndex=LU,D.sortedLastIndexBy=PU,D.sortedLastIndexOf=DU,D.startCase=mF,D.startsWith=gF,D.subtract=lk,D.sum=hk,D.sumBy=ck,D.template=_F,D.times=qF,D.toFinite=ma,D.toInteger=wt,D.toLength=Yx,D.toLower=vF,D.toNumber=dn,D.toSafeInteger=vB,D.toString=Xt,D.toUpper=yF,D.trim=xF,D.trimEnd=bF,D.trimStart=wF,D.truncate=MF,D.unescape=TF,D.uniqueId=KF,D.upperCase=SF,D.upperFirst=im,D.each=Ox,D.eachRight=Nx,D.first=Lx,am(D,function(){var o={};return Hn(D,function(u,g){Yt.call(D.prototype,g)||(o[g]=u)}),o}(),{chain:!1}),D.VERSION=i,sn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){D[o].placeholder=D}),sn(["drop","take"],function(o,u){Pt.prototype[o]=function(g){g=g===t?1:Ui(wt(g),0);var w=this.__filtered__&&!u?new Pt(this):this.clone();return w.__filtered__?w.__takeCount__=tr(g,w.__takeCount__):w.__views__.push({size:tr(g,he),type:o+(w.__dir__<0?"Right":"")}),w},Pt.prototype[o+"Right"]=function(g){return this.reverse()[o](g).reverse()}}),sn(["filter","map","takeWhile"],function(o,u){var g=u+1,w=g==k||g==V;Pt.prototype[o]=function(R){var O=this.clone();return O.__iteratees__.push({iteratee:at(R,3),type:g}),O.__filtered__=O.__filtered__||w,O}}),sn(["head","last"],function(o,u){var g="take"+(u?"Right":"");Pt.prototype[o]=function(){return this[g](1).value()[0]}}),sn(["initial","tail"],function(o,u){var g="drop"+(u?"":"Right");Pt.prototype[o]=function(){return this.__filtered__?new Pt(this):this[g](1)}}),Pt.prototype.compact=function(){return this.filter(Ar)},Pt.prototype.find=function(o){return this.filter(o).head()},Pt.prototype.findLast=function(o){return this.reverse().find(o)},Pt.prototype.invokeMap=At(function(o,u){return typeof o=="function"?new Pt(this):this.map(function(g){return lh(g,o,u)})}),Pt.prototype.reject=function(o){return this.filter(Eu(at(o)))},Pt.prototype.slice=function(o,u){o=wt(o);var g=this;return g.__filtered__&&(o>0||u<0)?new Pt(g):(o<0?g=g.takeRight(-o):o&&(g=g.drop(o)),u!==t&&(u=wt(u),g=u<0?g.dropRight(-u):g.take(u-o)),g)},Pt.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},Pt.prototype.toArray=function(){return this.take(he)},Hn(Pt.prototype,function(o,u){var g=/^(?:filter|find|map|reject)|While$/.test(u),w=/^(?:head|last)$/.test(u),R=D[w?"take"+(u=="last"?"Right":""):u],O=w||/^find/.test(u);R&&(D.prototype[u]=function(){var F=this.__wrapped__,j=w?[1]:arguments,K=F instanceof Pt,me=j[0],ve=K||_t(F),Me=function(Ct){var Ot=R.apply(D,Ha([Ct],j));return w&&ze?Ot[0]:Ot};ve&&g&&typeof me=="function"&&me.length!=1&&(K=ve=!1);var ze=this.__chain__,Ye=!!this.__actions__.length,lt=O&&!ze,Et=K&&!Ye;if(!O&&ve){F=Et?F:new Pt(this);var ht=o.apply(F,j);return ht.__actions__.push({func:wu,args:[Me],thisArg:t}),new ln(ht,ze)}return lt&&Et?o.apply(this,j):(ht=this.thru(Me),lt?w?ht.value()[0]:ht.value():ht)})}),sn(["pop","push","shift","sort","splice","unshift"],function(o){var u=Yc[o],g=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",w=/^(?:pop|shift)$/.test(o);D.prototype[o]=function(){var R=arguments;if(w&&!this.__chain__){var O=this.value();return u.apply(_t(O)?O:[],R)}return this[g](function(F){return u.apply(_t(F)?F:[],R)})}}),Hn(Pt.prototype,function(o,u){var g=D[u];if(g){var w=g.name+"";Yt.call(il,w)||(il[w]=[]),il[w].push({name:u,func:g})}}),il[mu(t,v).name]=[{name:"wrapper",func:t}],Pt.prototype.clone=T3,Pt.prototype.reverse=S3,Pt.prototype.value=E3,D.prototype.at=tz,D.prototype.chain=iz,D.prototype.commit=rz,D.prototype.next=nz,D.prototype.plant=sz,D.prototype.reverse=oz,D.prototype.toJSON=D.prototype.valueOf=D.prototype.value=lz,D.prototype.first=D.prototype.head,th&&(D.prototype[th]=az),D},Qo=r3();Rs?((Rs.exports=Qo)._=Qo,nf._=Qo):ji._=Qo}).call(Ll)}(uc,uc.exports);var Vt=uc.exports;let wo=class Lu{constructor(e,t,i,r,a="div"){this.parent=e,this.object=t,this.property=i,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement("div"),this.domElement.classList.add("controller"),this.domElement.classList.add(r),this.$name=document.createElement("div"),this.$name.classList.add("name"),Lu.nextNameID=Lu.nextNameID||0,this.$name.id="lil-gui-name-"+ ++Lu.nextNameID,this.$widget=document.createElement(a),this.$widget.classList.add("widget"),this.$disable=this.$widget,this.domElement.appendChild(this.$name),this.domElement.appendChild(this.$widget),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(i)}name(e){return this._name=e,this.$name.innerHTML=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled||(this._disabled=e,this.domElement.classList.toggle("disabled",e),this.$disable.toggleAttribute("disabled",e)),this}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}options(e){const t=this.parent.add(this.object,this.property,e);return t.name(this._name),this.destroy(),t}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);const e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.object[this.property]=e,this._callOnChange(),this.updateDisplay(),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}};class KA extends wo{constructor(e,t,i){super(e,t,i,"boolean","label"),this.$input=document.createElement("input"),this.$input.setAttribute("type","checkbox"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener("change",()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function Kd(n){let e,t;return(e=n.match(/(#|0x)?([a-f0-9]{6})/i))?t=e[2]:(e=n.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?t=parseInt(e[1]).toString(16).padStart(2,0)+parseInt(e[2]).toString(16).padStart(2,0)+parseInt(e[3]).toString(16).padStart(2,0):(e=n.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(t=e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),!!t&&"#"+t}const ZA={isPrimitive:!0,match:n=>typeof n=="string",fromHexString:Kd,toHexString:Kd},Pl={isPrimitive:!0,match:n=>typeof n=="number",fromHexString:n=>parseInt(n.substring(1),16),toHexString:n=>"#"+n.toString(16).padStart(6,0)},JA={isPrimitive:!1,match:Array.isArray,fromHexString(n,e,t=1){const i=Pl.fromHexString(n);e[0]=(i>>16&255)/255*t,e[1]=(i>>8&255)/255*t,e[2]=(255&i)/255*t},toHexString:([n,e,t],i=1)=>Pl.toHexString(n*(i=255/i)<<16^e*i<<8^t*i<<0)},$A={isPrimitive:!1,match:n=>Object(n)===n,fromHexString(n,e,t=1){const i=Pl.fromHexString(n);e.r=(i>>16&255)/255*t,e.g=(i>>8&255)/255*t,e.b=(255&i)/255*t},toHexString:({r:n,g:e,b:t},i=1)=>Pl.toHexString(n*(i=255/i)<<16^e*i<<8^t*i<<0)},QA=[ZA,Pl,JA,$A];let e2=class extends wo{constructor(n,e,t,i){var r;super(n,e,t,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(r=this.initialValue,QA.find(a=>a.match(r))),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=Kd(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(n){if(this._format.isPrimitive){const e=this._format.fromHexString(n);this.setValue(e)}else this._format.fromHexString(n,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(n){return this._setValueFromHexString(n),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}};class Zd extends wo{constructor(e,t,i){super(e,t,i,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",r=>{r.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class t2 extends wo{constructor(e,t,i,r,a,s){super(e,t,i,"number"),this._initInput(),this.min(r),this.max(a);const l=s!==void 0;this.step(l?s:this._getImplicitStep(),l),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,t=!0){return this._step=e,this._stepExplicit=t,this}updateDisplay(){const e=this.getValue();if(this._hasSlider){let t=(e-this._min)/(this._max-this._min);t=Math.max(0,Math.min(t,1)),this.$fill.style.width=100*t+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const e=d=>{const p=parseFloat(this.$input.value);isNaN(p)||(this._snapClampSetValue(p+d),this.$input.value=this.getValue())};let t,i,r,a,s,l=!1;const h=d=>{if(l){const p=d.clientX-t,f=d.clientY-i;Math.abs(f)>5?(d.preventDefault(),this.$input.blur(),l=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(p)>5&&c()}if(!l){const p=d.clientY-r;s-=p*this._step*this._arrowKeyMultiplier(d),a+s>this._max?s=this._max-a:a+s<this._min&&(s=this._min-a),this._snapClampSetValue(a+s)}r=d.clientY},c=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",c)};this.$input.addEventListener("input",()=>{let d=parseFloat(this.$input.value);isNaN(d)||(this._stepExplicit&&(d=this._snap(d)),this.setValue(this._clamp(d)))}),this.$input.addEventListener("keydown",d=>{d.code==="Enter"&&this.$input.blur(),d.code==="ArrowUp"&&(d.preventDefault(),e(this._step*this._arrowKeyMultiplier(d))),d.code==="ArrowDown"&&(d.preventDefault(),e(this._step*this._arrowKeyMultiplier(d)*-1))}),this.$input.addEventListener("wheel",d=>{this._inputFocused&&(d.preventDefault(),e(this._step*this._normalizeMouseWheel(d)))},{passive:!1}),this.$input.addEventListener("mousedown",d=>{t=d.clientX,i=r=d.clientY,l=!0,a=this.getValue(),s=0,window.addEventListener("mousemove",h),window.addEventListener("mouseup",c)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=f=>{const m=this.$slider.getBoundingClientRect();let _=(x=f,y=m.left,v=m.right,M=this._min,b=this._max,(x-y)/(v-y)*(b-M)+M);var x,y,v,M,b;this._snapClampSetValue(_)},t=f=>{e(f.clientX)},i=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",t),window.removeEventListener("mouseup",i)};let r,a,s=!1;const l=f=>{f.preventDefault(),this._setDraggingStyle(!0),e(f.touches[0].clientX),s=!1},h=f=>{if(s){const m=f.touches[0].clientX-r,_=f.touches[0].clientY-a;Math.abs(m)>Math.abs(_)?l(f):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",c))}else f.preventDefault(),e(f.touches[0].clientX)},c=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",c)},d=this._callOnFinishChange.bind(this);let p;this.$slider.addEventListener("mousedown",f=>{this._setDraggingStyle(!0),e(f.clientX),window.addEventListener("mousemove",t),window.addEventListener("mouseup",i)}),this.$slider.addEventListener("touchstart",f=>{f.touches.length>1||(this._hasScrollBar?(r=f.touches[0].clientX,a=f.touches[0].clientY,s=!0):l(f),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",c))},{passive:!1}),this.$slider.addEventListener("wheel",f=>{if(Math.abs(f.deltaX)<Math.abs(f.deltaY)&&this._hasScrollBar)return;f.preventDefault();const m=this._normalizeMouseWheel(f)*this._step;this._snapClampSetValue(this.getValue()+m),this.$input.value=this.getValue(),clearTimeout(p),p=setTimeout(d,400)},{passive:!1})}_setDraggingStyle(e,t="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle("lil-gui-"+t,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:t,deltaY:i}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(t=0,i=-e.wheelDelta/120,i*=this._stepExplicit?1:10),t+-i}_arrowKeyMultiplier(e){let t=this._stepExplicit?1:10;return e.shiftKey?t*=10:e.altKey&&(t/=10),t}_snap(e){const t=Math.round(e/this._step)*this._step;return parseFloat(t.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class i2 extends wo{constructor(e,t,i,r){super(e,t,i,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(r)?r:Object.values(r),this._names=Array.isArray(r)?r:Object.keys(r),this._names.forEach(a=>{const s=document.createElement("option");s.innerHTML=a,this.$select.appendChild(s)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const e=this.getValue(),t=this._values.indexOf(e);return this.$select.selectedIndex=t,this.$display.innerHTML=t===-1?e:this._names[t],this}}class r2 extends wo{constructor(e,t,i){super(e,t,i,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",r=>{r.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let $_=!1;class Jd{constructor({parent:e,autoPlace:t=e===void 0,container:i,width:r,title:a="Controls",injectStyles:s=!0,touchStyles:l=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",h=>{h.code!=="Enter"&&h.code!=="Space"||(h.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(a),l&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!$_&&s&&(function(h){const c=document.createElement("style");c.innerHTML=h;const d=document.querySelector("head link[rel=stylesheet], head style");d?document.head.insertBefore(c,d):document.head.appendChild(c)}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"\u2195";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"\u25BE";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"\u25B8"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"\u2713";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),$_=!0),i?i.appendChild(this.domElement):t&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),r&&this.domElement.style.setProperty("--width",r+"px"),this.domElement.addEventListener("keydown",h=>h.stopPropagation()),this.domElement.addEventListener("keyup",h=>h.stopPropagation())}add(e,t,i,r,a){if(Object(i)===i)return new i2(this,e,t,i);const s=e[t];switch(typeof s){case"number":return new t2(this,e,t,i,r,a);case"boolean":return new KA(this,e,t);case"string":return new r2(this,e,t);case"function":return new Zd(this,e,t)}console.error(`gui.add failed property:`,t,` object:`,e,` value:`,s)}addColor(e,t,i=1){return new e2(this,e,t,i)}addFolder(e){return new Jd({parent:this,title:e})}load(e,t=!0){return e.controllers&&this.controllers.forEach(i=>{i instanceof Zd||i._name in e.controllers&&i.load(e.controllers[i._name])}),t&&e.folders&&this.folders.forEach(i=>{i._title in e.folders&&i.load(e.folders[i._title])}),this}save(e=!0){const t={controllers:{},folders:{}};return this.controllers.forEach(i=>{if(!(i instanceof Zd)){if(i._name in t.controllers)throw new Error(`Cannot save GUI with duplicate property "${i._name}"`);t.controllers[i._name]=i.save()}}),e&&this.folders.forEach(i=>{if(i._title in t.folders)throw new Error(`Cannot save GUI with duplicate folder "${i._title}"`);t.folders[i._title]=i.save()}),t}open(e=!0){return this._closed=!e,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._closed=!e,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const t=this.$children.clientHeight;this.$children.style.height=t+"px",this.domElement.classList.add("transition");const i=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",i))};this.$children.addEventListener("transitionend",i);const r=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=r+"px"})}),this}title(e){return this._title=e,this.$title.innerHTML=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(t=>t.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(t=>{e=e.concat(t.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(t=>{e=e.concat(t.foldersRecursive())}),e}}class n2 extends Yn{constructor(t){super();vt(this,"data",{});this.data=t,this.gui=new Jd;let i=this.gui.addFolder("Building");i.add(this.data.size,"width",50,500).step(20).name("Width"),i.add(this.data.size,"length",50,500).step(20).name("Length"),i.add(this.data.size,"height",50,100).step(10).name("Clear height"),i.open(),i=this.gui.addFolder("Elements"),i.add(this.data.floor,"enable").name("Floor"),i.add(this.data.wall,"enable").name("Wall"),i.add(this.data.frame,"enable").name("Frame"),i.add(this.data.roof,"enable").name("Roof"),i.add(this.data.trim,"enable").name("Trim"),i.add(this.data.logo,"enable").name("Logo"),i.open(),i=this.gui.addFolder("Roof"),i.add(this.data.roof,"raise",[4,5,6,7,8]).name("Roof slope (x/12)"),i.add(this.data.roof,"extend",3,9).step(1).name("Over hang"),i.open(),i=this.gui.addFolder("Doors"),i.add(this.data.door.main,"enable").name("Large Door"),i.add(this.data.door.entry,"enable").name("Entry Door"),i.add(this.data.door.window,"enable").name("Window"),i=this.gui.addFolder("LeanTos"),i.add(this.data.leanTos.wrap,"frontLeft").name("Front & Left"),i.add(this.data.leanTos.wrap,"frontRight").name("Front & Right"),i.add(this.data.leanTos.wrap,"backLeft").name("Back & Left"),i.add(this.data.leanTos.wrap,"backRight").name("Back & Right"),i=this.gui.addFolder("Options"),i.add(this.data.options.wainscotting,"enable").name("Wainscotting"),i.add(this.data.options,"snowBar").name("SnowBar"),i.add(this.data.options,"skirtBoardProtection").name("SkirtBoard"),i.add(this.data.options,"quality",["high","medium"]).name("Quality"),i=this.gui.addFolder("General"),i.add(this.data.general,"isTransparent").name("Transparent"),i.add(this.data.general,"isShadow").name("Shadow"),i.add(this.data.general,"isRender").name("Render"),i.add(this.data.general,"isEffect").name("Effect"),i.open(),i=this.gui.addFolder("Colors"),i.addColor(this.data.roof,"color").name("Roof"),i.addColor(this.data.wall,"color").name("Wall"),i.addColor(this.data.trim,"color").name("Trim"),i.addColor(this.data.door,"color").name("Door frame"),i.addColor(this.data.options.wainscotting,"color").name("Wainscotting"),i.close(),this.gui.onChange(this.changed.bind(this))}changed(t){this.dispatchEvent({type:"changed",event:t})}}class nt{static scaleToModel(e){return e?e*5:null}static scaleToFeet(e){return e?e/5:null}static mergeJson(e,t){var x,y,v,M,b,S,A;const i=t.selectedSide,r={name:"size",width:nt.scaleToModel((x=e.size)==null?void 0:x.width)||t.size.width,length:nt.scaleToModel(((y=e.size)==null?void 0:y.length)||t.size.length),height:nt.scaleToModel(((v=e.size)==null?void 0:v.height)||t.size.height)};let a={front:-r.width/2+2,back:-r.width/2+2,left:-r.length/2+2,right:-r.length/2+2};const s={...t,size:r},l=Vt.cloneDeep(e.doors||[]).map(T=>{const E=s.doors.find(q=>q._id===q.id),I=T.doorType==="entry_door"?{width:nt.scaleToModel(3),height:nt.scaleToModel(7),depth:1}:{width:nt.scaleToModel(T.size.width),height:nt.scaleToModel(T.size.height),depth:1},C=T.side||i;let P=0;T.position||(a[C]+=I.width/2,P=a[C],a[C]+=I.width/2+5);const X={_id:T.id,id:(E==null?void 0:E.id)||"",name:"door",type:T.doorType,door_type:T.type,size:I,side:C,position:T.position||{x:P,y:I.height/2,z:0}};return T.doorType==="large_door"&&(T.opening==="dutch_corner_overhead"&&T.type==="overhead"&&(X.door_type="dutch_corner_overhead"),X.opening=T.opening,X.insulated=T.insulated,X.windows=T.windows),X});this.assignNewId(l);const h=Vt.cloneDeep(e.windows||[]).map(T=>{const E=s.windows.find(X=>X._id===X.id),I=nt.convertWindowSize(T.size),C=T.side||i;let P=0;return T.position||(a[C]+=I.width/2,P=a[C],a[C]+=I.width/2+5),{_id:T.id,id:(E==null?void 0:E.id)||"",name:"window",type:"window",door_type:T.type,_size:T.size,side:C,size:I,position:T.position||{x:P,y:r.height/2+I.height/2,z:0}}});this.assignNewId(h);const c=r.length/((e.cupola||[]).length+1);let d=-r.length/2;const p=Vt.cloneDeep(e.cupola||[]).map(T=>(d+=c,{_id:T.id,id:T.id,type:"cupola",name:"cupola",enable:!0,roofTexture:{color:9079433},wallTexture:{},size:T.size===36?"medium":"small",eagleWeatherwave:T.eagleWeatherwave,position:{x:d,y:75,z:0}}));this.assignNewId(p);const f={wrap:Vt.cloneDeep(e.leanTos.wrap),roof:{raise:2,extend:3},list:[]},m=e.leanTos.list||[];let _=["front","back","left","right"];return m.filter(T=>T.side).forEach(T=>Vt.remove(_,E=>E===T.side)),f.list=m.map(T=>{const E=T.openType==="opening"?"open_bottom":"close";let I=T.side;return I||(_.indexOf(i)!==-1?(I=i,Vt.remove(_,C=>C===i)):I=_.pop()),{type:"leanTos",name:"leanTos",openType:{front:E,left:E,right:E},side:I,size:{width:nt.scaleToModel(T.size.width),length:Math.min(nt.scaleToModel(T.size.length),T.side==="left"||T.side==="right"?r.length:r.width),height:r.height}}}),{...s,project:e.project,floor:{...s.floor,enable:e.options.Concrete.enabled},wall:{...s.wall,color:((M=e.colors)==null?void 0:M.wall)||s.wall.color,enable:!e.Transparent},roof:{...s.roof,color:((b=e.colors)==null?void 0:b.roof)||s.roof.color},trim:{...s.trim,color:((S=e.colors)==null?void 0:S.trim)||s.trim.color},doors:l,windows:h,cupola:p,leanTos:f,options:{_wainscottingId:e.options.Wainscotting.id,_snowBarId:e.options.snowBar.id,_skirtBoardProtectionId:e.options.skirtBoardProtection.id,wainscotting:{enable:e.options.Wainscotting.enabled,height:15,color:((A=e.colors)==null?void 0:A.wainscotting)||s.options.wainscotting.color},snowBar:e.options.snowBar.enabled,skirtBoardProtection:e.options.skirtBoardProtection.enabled,overhang:e.options.overhang,gutter:e.options.Gutter.enable,quality:e.Quality||"medium"},barriersAndInsulation:e.barriersAndInsulation,interiorLiningPanel:e.interiorLiningPanel,certifiedStampedDrawing:e.certifiedStampedDrawing}}static exportUiJson(e){var t,i,r,a,s,l,h,c,d,p,f;return{project:e.project,size:{width:nt.scaleToFeet((t=e.size)==null?void 0:t.width)||0,length:nt.scaleToFeet((i=e.size)==null?void 0:i.length)||0,height:nt.scaleToFeet((r=e.size)==null?void 0:r.height)||0},doors:(e.doors||[]).map(m=>nt.exportDoor(m)),windows:(e.windows||[]).map(m=>nt.exportWindow(m)),cupola:(e.cupola||[]).map(m=>nt.exportCupola(m)),leanTos:{wrap:((a=e.leanTos)==null?void 0:a.wrap)||{frontLeft:!1,frontRight:!1,backLeft:!1,backRight:!1},list:(((s=e.leanTos)==null?void 0:s.list)||[]).map(m=>nt.exportLeanTo(m))},options:{snowBar:{enabled:((l=e.options)==null?void 0:l.snowBar)||!1},Wainscotting:{enabled:((h=e.options)==null?void 0:h.wainscotting.enable)||!1},skirtBoardProtection:{enabled:((c=e.options)==null?void 0:c.skirtBoardProtection)||!1},Gutter:{enabled:((d=e.options)==null?void 0:d.gutter)||!1},Concrete:{enabled:e.floor.enable||!1},overhang:((p=e.options)==null?void 0:p.overhang)||{eaveSide:!0,grableEnd:!0}},colors:{roof:e.roof.color.toLowerCase(),wall:e.wall.color.toLowerCase(),trim:e.trim.color.toLowerCase(),Wainscotting:e.options.wainscotting.color.toLowerCase()},Quality:e.options.quality||"medium",Transparent:!((f=e.wall)!=null&&f.enable),barriersAndInsulation:e.barriersAndInsulation,interiorLiningPanel:e.interiorLiningPanel,certifiedStampedDrawing:e.certifiedStampedDrawing,selectedSide:e.selectedSide}}static assignNewId(e){const t=[];e.forEach(i=>{if(t.indexOf(i._id)===-1){t.push(i._id);return}const r=Math.max(...e.map(a=>a._id||0))+1;i._id=r,t.push(r)})}static convertWindowSize(e){const[t,i]=e.split("x");return{width:nt.scaleToModel(t),height:nt.scaleToModel(i),depth:1}}static exportWindow(e){return{id:e._id,type:e.door_type,size:e._size,side:e.side,position:e.position}}static exportDoor(e){var t,i;return{id:e._id,doorType:e.type,type:e.door_type==="dutch_corner_overhead"?"overhead":e.door_type,size:{width:nt.scaleToFeet((t=e.size)==null?void 0:t.width)||0,height:nt.scaleToFeet((i=e.size)==null?void 0:i.height)||0},side:e.side,position:e.position,opening:e.opening,insulated:e.insulated,windows:e.windows}}static exportLeanTo(e){var t,i,r;return{side:e.side,openType:e.openType.front==="close"?"enclosed":"opening",size:{width:nt.scaleToFeet((t=e.size)==null?void 0:t.width)||0,length:nt.scaleToFeet((i=e.size)==null?void 0:i.length)||0,height:nt.scaleToFeet((r=e.size)==null?void 0:r.height)||0}}}static exportCupola(e){return{id:e._id,name:e.name,size:e.size==="medium"?36:24,eagleWeatherwave:e.eagleWeatherwave}}}const Dt={0:0,1:.07854,2:.16581,3:.24435,4:.32289,5:.3927,6:.46426,7:.52884,8:.58818,9:.64403,10:.69464,11:.74177,12:.7854},Mo=nt.scaleToModel(8),zt={0:0,45:Math.PI*.25,90:Math.PI*.5,180:Math.PI,270:Math.PI*1.5},Q_={small:{width:nt.scaleToModel(2)},medium:{width:nt.scaleToModel(3)},large:{width:5}},$d={weathervane:"models/cupolar/weathervane.gltf"},cs={x:110,y:110,z:110},Qd=2,e0=60,Ft={large:{overhead:"models/large/overhead.gltf",single_slide:"models/large/single_slide.gltf",double_slide:"models/large/double_slide.gltf",dutch_corner_overhead:"models/large/dutch_corner_overhead.gltf"},entry:{two_panels:"models/entry/two_panels.gltf",six_panels:"models/entry/six_panels.gltf",two_panels_half_glass:"models/entry/two_panels_half_glass.gltf",two_panels_with_grid:"models/entry/two_panels_with_grid.gltf"},window:{sliding_vinyl:"models/window/sliding_vinyl.gltf",double_hung_vinyl:"models/window/double_hung_vinyl.gltf",single_hung_vinyl:"models/window/single_hung_vinyl.gltf"}},ri={wall:{urlMapImage:"textures/wall_1_color.jpg",urlMapImageDisp:"textures/wall_1_disp.jpg",urlMapImageNormal:"textures/wall_1_normal.jpg"},wainscotting:{urlMapImage:"textures/wall_1_color.jpg",urlMapImageDisp:"textures/wall_1_disp.jpg",urlMapImageNormal:"textures/wall_1_normal.jpg"},frame:{urlMapImage:"textures/wood/plywood_diff.jpg",urlMapImageDisp:"textures/wood/plywood_ao.jpg"},floor:{urlMapImage:"textures/ground_2_color.jpg",urlMapImageDisp:"textures/ground_2_disp.png"},roof:{urlMapImage:"textures/roof_9_color.jpg",urlMapImageDisp:"textures/roof_9_disp.jpg",urlMapImageNormal:"textures/roof_9_normal.jpg"},door:{urlMapImage:"textures/wood/plywood_ao.jpg",urlMapImageDisp:"textures/wood/plywood_ao.jpg",urlMapImageNormal:"textures/wood/plywood_normal.jpg"},cupola:{wall:{urlMapImage:"textures/ground_2_color.jpg",urlMapImageDisp:"textures/ground_2_disp.png"},roof:{urlMapImage:"textures/tole_1_color.jpg",urlMapImageDisp:"textures/tole_1_disp.jpg",urlMapImageNormal:"textures/tole_1_normal.jpg"}},trim:{urlMapImage:"textures/tole_1_color.jpg",urlMapImageDisp:"textures/tole_1_disp.jpg",urlMapImageNormal:"textures/tole_1_normal.jpg"},logo:{urlMapImage:"logo.png"}};function ra(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function t0(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.__proto__=e}var Dr={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},To={duration:.5,overwrite:!1,delay:0},ep,Zi,gi,Kr=1e8,Jt=1/Kr,tp=Math.PI*2,a2=tp/4,s2=0,i0=Math.sqrt,o2=Math.cos,l2=Math.sin,Hi=function(n){return typeof n=="string"},_i=function(n){return typeof n=="function"},na=function(n){return typeof n=="number"},ip=function(n){return typeof n>"u"},On=function(n){return typeof n=="object"},gr=function(n){return n!==!1},rp=function(){return typeof window<"u"},dc=function(n){return _i(n)||Hi(n)},r0=typeof ArrayBuffer=="function"&&ArrayBuffer.isView||function(){},Ji=Array.isArray,np=/(?:-?\.?\d|\.)+/gi,n0=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,So=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,ap=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,a0=/[+-]=-?[.\d]+/,s0=/[^,'"\[\]\s]+/gi,h2=/^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i,ci,Zr,sp,op,Ir={},pc={},o0,l0=function(n){return(pc=ds(n,Ir))&&yr},lp=function(n,e){return console.warn("Invalid property",n,"set to",e,"Missing plugin? gsap.registerPlugin()")},Dl=function(n,e){return!e&&console.warn(n)},h0=function(n,e){return n&&(Ir[n]=e)&&pc&&(pc[n]=e)||Ir},Il=function(){return 0},c2={suppressEvents:!0,isStart:!0,kill:!1},fc={suppressEvents:!0,kill:!1},u2={suppressEvents:!0},hp={},Aa=[],cp={},c0,Or={},up={},u0=30,mc=[],dp="",pp=function(n){var e=n[0],t,i;if(On(e)||_i(e)||(n=[n]),!(t=(e._gsap||{}).harness)){for(i=mc.length;i--&&!mc[i].targetTest(e););t=mc[i]}for(i=n.length;i--;)n[i]&&(n[i]._gsap||(n[i]._gsap=new k0(n[i],t)))||n.splice(i,1);return n},us=function(n){return n._gsap||pp(Qr(n))[0]._gsap},d0=function(n,e,t){return(t=n[e])&&_i(t)?n[e]():ip(t)&&n.getAttribute&&n.getAttribute(e)||t},_r=function(n,e){return(n=n.split(",")).forEach(e)||n},Mi=function(n){return Math.round(n*1e5)/1e5||0},Gi=function(n){return Math.round(n*1e7)/1e7||0},Eo=function(n,e){var t=e.charAt(0),i=parseFloat(e.substr(2));return n=parseFloat(n),t==="+"?n+i:t==="-"?n-i:t==="*"?n*i:n/i},d2=function(n,e){for(var t=e.length,i=0;n.indexOf(e[i])<0&&++i<t;);return i<t},gc=function(){var n=Aa.length,e=Aa.slice(0),t,i;for(cp={},Aa.length=0,t=0;t<n;t++)i=e[t],i&&i._lazy&&(i.render(i._lazy[0],i._lazy[1],!0)._lazy=0)},p0=function(n,e,t,i){Aa.length&&!Zi&&gc(),n.render(e,t,i||Zi&&e<0&&(n._initted||n._startAt)),Aa.length&&!Zi&&gc()},f0=function(n){var e=parseFloat(n);return(e||e===0)&&(n+"").match(s0).length<2?e:Hi(n)?n.trim():n},m0=function(n){return n},Jr=function(n,e){for(var t in e)t in n||(n[t]=e[t]);return n},p2=function(n){return function(e,t){for(var i in t)i in e||i==="duration"&&n||i==="ease"||(e[i]=t[i])}},ds=function(n,e){for(var t in e)n[t]=e[t];return n},g0=function n(e,t){for(var i in t)i!=="__proto__"&&i!=="constructor"&&i!=="prototype"&&(e[i]=On(t[i])?n(e[i]||(e[i]={}),t[i]):t[i]);return e},_c=function(n,e){var t={},i;for(i in n)i in e||(t[i]=n[i]);return t},Ol=function(n){var e=n.parent||ci,t=n.keyframes?p2(Ji(n.keyframes)):Jr;if(gr(n.inherit))for(;e;)t(n,e.vars.defaults),e=e.parent||e._dp;return n},f2=function(n,e){for(var t=n.length,i=t===e.length;i&&t--&&n[t]===e[t];);return t<0},_0=function(n,e,t,i,r){t===void 0&&(t="_first"),i===void 0&&(i="_last");var a=n[i],s;if(r)for(s=e[r];a&&a[r]>s;)a=a._prev;return a?(e._next=a._next,a._next=e):(e._next=n[t],n[t]=e),e._next?e._next._prev=e:n[i]=e,e._prev=a,e.parent=e._dp=n,e},vc=function(n,e,t,i){t===void 0&&(t="_first"),i===void 0&&(i="_last");var r=e._prev,a=e._next;r?r._next=a:n[t]===e&&(n[t]=a),a?a._prev=r:n[i]===e&&(n[i]=r),e._next=e._prev=e.parent=null},Ra=function(n,e){n.parent&&(!e||n.parent.autoRemoveChildren)&&n.parent.remove&&n.parent.remove(n),n._act=0},ps=function(n,e){if(n&&(!e||e._end>n._dur||e._start<0))for(var t=n;t;)t._dirty=1,t=t.parent;return n},m2=function(n){for(var e=n.parent;e&&e.parent;)e._dirty=1,e.totalDuration(),e=e.parent;return n},fp=function(n,e,t,i){return n._startAt&&(Zi?n._startAt.revert(fc):n.vars.immediateRender&&!n.vars.autoRevert||n._startAt.render(e,!0,i))},g2=function n(e){return!e||e._ts&&n(e.parent)},v0=function(n){return n._repeat?Ao(n._tTime,n=n.duration()+n._rDelay)*n:0},Ao=function(n,e){var t=Math.floor(n/=e);return n&&t===n?t-1:t},yc=function(n,e){return(n-e._start)*e._ts+(e._ts>=0?0:e._dirty?e.totalDuration():e._tDur)},xc=function(n){return n._end=Gi(n._start+(n._tDur/Math.abs(n._ts||n._rts||Jt)||0))},bc=function(n,e){var t=n._dp;return t&&t.smoothChildTiming&&n._ts&&(n._start=Gi(t._time-(n._ts>0?e/n._ts:((n._dirty?n.totalDuration():n._tDur)-e)/-n._ts)),xc(n),t._dirty||ps(t,n)),n},y0=function(n,e){var t;if((e._time||!e._dur&&e._initted||e._start<n._time&&(e._dur||!e.add))&&(t=yc(n.rawTime(),e),(!e._dur||Ul(0,e.totalDuration(),t)-e._tTime>Jt)&&e.render(t,!0)),ps(n,e)._dp&&n._initted&&n._time>=n._dur&&n._ts){if(n._dur<n.duration())for(t=n;t._dp;)t.rawTime()>=0&&t.totalTime(t._tTime),t=t._dp;n._zTime=-Jt}},Nn=function(n,e,t,i){return e.parent&&Ra(e),e._start=Gi((na(t)?t:t||n!==ci?$r(n,t,e):n._time)+e._delay),e._end=Gi(e._start+(e.totalDuration()/Math.abs(e.timeScale())||0)),_0(n,e,"_first","_last",n._sort?"_start":0),mp(e)||(n._recent=e),i||y0(n,e),n._ts<0&&bc(n,n._tTime),n},x0=function(n,e){return(Ir.ScrollTrigger||lp("scrollTrigger",e))&&Ir.ScrollTrigger.create(e,n)},b0=function(n,e,t,i,r){if(Tp(n,e,r),!n._initted)return 1;if(!t&&n._pt&&!Zi&&(n._dur&&n.vars.lazy!==!1||!n._dur&&n.vars.lazy)&&c0!==Ur.frame)return Aa.push(n),n._lazy=[r,i],1},_2=function n(e){var t=e.parent;return t&&t._ts&&t._initted&&!t._lock&&(t.rawTime()<0||n(t))},mp=function(n){var e=n.data;return e==="isFromStart"||e==="isStart"},v2=function(n,e,t,i){var r=n.ratio,a=e<0||!e&&(!n._start&&_2(n)&&!(!n._initted&&mp(n))||(n._ts<0||n._dp._ts<0)&&!mp(n))?0:1,s=n._rDelay,l=0,h,c,d;if(s&&n._repeat&&(l=Ul(0,n._tDur,e),c=Ao(l,s),n._yoyo&&c&1&&(a=1-a),c!==Ao(n._tTime,s)&&(r=1-a,n.vars.repeatRefresh&&n._initted&&n.invalidate())),a!==r||Zi||i||n._zTime===Jt||!e&&n._zTime){if(!n._initted&&b0(n,e,i,t,l))return;for(d=n._zTime,n._zTime=e||(t?Jt:0),t||(t=e&&!d),n.ratio=a,n._from&&(a=1-a),n._time=0,n._tTime=l,h=n._pt;h;)h.r(a,h.d),h=h._next;e<0&&fp(n,e,t,!0),n._onUpdate&&!t&&Nr(n,"onUpdate"),l&&n._repeat&&!t&&n.parent&&Nr(n,"onRepeat"),(e>=n._tDur||e<0)&&n.ratio===a&&(a&&Ra(n,1),!t&&!Zi&&(Nr(n,a?"onComplete":"onReverseComplete",!0),n._prom&&n._prom()))}else n._zTime||(n._zTime=e)},y2=function(n,e,t){var i;if(t>e)for(i=n._first;i&&i._start<=t;){if(i.data==="isPause"&&i._start>e)return i;i=i._next}else for(i=n._last;i&&i._start>=t;){if(i.data==="isPause"&&i._start<e)return i;i=i._prev}},Ro=function(n,e,t,i){var r=n._repeat,a=Gi(e)||0,s=n._tTime/n._tDur;return s&&!i&&(n._time*=a/n._dur),n._dur=a,n._tDur=r?r<0?1e10:Gi(a*(r+1)+n._rDelay*r):a,s>0&&!i&&bc(n,n._tTime=n._tDur*s),n.parent&&xc(n),t||ps(n.parent,n),n},w0=function(n){return n instanceof sr?ps(n):Ro(n,n._dur)},x2={_start:0,endTime:Il,totalDuration:Il},$r=function n(e,t,i){var r=e.labels,a=e._recent||x2,s=e.duration()>=Kr?a.endTime(!1):e._dur,l,h,c;return Hi(t)&&(isNaN(t)||t in r)?(h=t.charAt(0),c=t.substr(-1)==="%",l=t.indexOf("="),h==="<"||h===">"?(l>=0&&(t=t.replace(/=/,"")),(h==="<"?a._start:a.endTime(a._repeat>=0))+(parseFloat(t.substr(1))||0)*(c?(l<0?a:i).totalDuration()/100:1)):l<0?(t in r||(r[t]=s),r[t]):(h=parseFloat(t.charAt(l-1)+t.substr(l+1)),c&&i&&(h=h/100*(Ji(i)?i[0]:i).totalDuration()),l>1?n(e,t.substr(0,l-1),i)+h:s+h)):t==null?s:+t},Nl=function(n,e,t){var i=na(e[1]),r=(i?2:1)+(n<2?0:1),a=e[r],s,l;if(i&&(a.duration=e[1]),a.parent=t,n){for(s=a,l=t;l&&!("immediateRender"in s);)s=l.vars.defaults||{},l=gr(l.vars.inherit)&&l.parent;a.immediateRender=gr(s.immediateRender),n<2?a.runBackwards=1:a.startAt=e[r-1]}return new Ai(e[0],a,e[r+1])},Ca=function(n,e){return n||n===0?e(n):e},Ul=function(n,e,t){return t<n?n:t>e?e:t},$i=function(n,e){return!Hi(n)||!(e=h2.exec(n))?"":e[1]},b2=function(n,e,t){return Ca(t,function(i){return Ul(n,e,i)})},gp=[].slice,M0=function(n,e){return n&&On(n)&&"length"in n&&(!e&&!n.length||n.length-1 in n&&On(n[0]))&&!n.nodeType&&n!==Zr},w2=function(n,e,t){return t===void 0&&(t=[]),n.forEach(function(i){var r;return Hi(i)&&!e||M0(i,1)?(r=t).push.apply(r,Qr(i)):t.push(i)})||t},Qr=function(n,e,t){return gi&&!e&&gi.selector?gi.selector(n):Hi(n)&&!t&&(sp||!Lo())?gp.call((e||op).querySelectorAll(n),0):Ji(n)?w2(n,t):M0(n)?gp.call(n,0):n?[n]:[]},_p=function(n){return n=Qr(n)[0]||Dl("Invalid scope")||{},function(e){var t=n.current||n.nativeElement||n;return Qr(e,t.querySelectorAll?t:t===n?Dl("Invalid scope")||op.createElement("div"):n)}},T0=function(n){return n.sort(function(){return .5-Math.random()})},S0=function(n){if(_i(n))return n;var e=On(n)?n:{each:n},t=fs(e.ease),i=e.from||0,r=parseFloat(e.base)||0,a={},s=i>0&&i<1,l=isNaN(i)||s,h=e.axis,c=i,d=i;return Hi(i)?c=d={center:.5,edges:.5,end:1}[i]||0:!s&&l&&(c=i[0],d=i[1]),function(p,f,m){var _=(m||e).length,x=a[_],y,v,M,b,S,A,T,E,I;if(!x){if(I=e.grid==="auto"?0:(e.grid||[1,Kr])[1],!I){for(T=-Kr;T<(T=m[I++].getBoundingClientRect().left)&&I<_;);I<_&&I--}for(x=a[_]=[],y=l?Math.min(I,_)*c-.5:i%I,v=I===Kr?0:l?_*d/I-.5:i/I|0,T=0,E=Kr,A=0;A<_;A++)M=A%I-y,b=v-(A/I|0),x[A]=S=h?Math.abs(h==="y"?b:M):i0(M*M+b*b),S>T&&(T=S),S<E&&(E=S);i==="random"&&T0(x),x.max=T-E,x.min=E,x.v=_=(parseFloat(e.amount)||parseFloat(e.each)*(I>_?_-1:h?h==="y"?_/I:I:Math.max(I,_/I))||0)*(i==="edges"?-1:1),x.b=_<0?r-_:r,x.u=$i(e.amount||e.each)||0,t=t&&_<0?z0(t):t}return _=(x[p]-x.min)/x.max||0,Gi(x.b+(t?t(_):_)*x.v)+x.u}},vp=function(n){var e=Math.pow(10,((n+"").split(".")[1]||"").length);return function(t){var i=Gi(Math.round(parseFloat(t)/n)*n*e);return(i-i%1)/e+(na(t)?0:$i(t))}},E0=function(n,e){var t=Ji(n),i,r;return!t&&On(n)&&(i=t=n.radius||Kr,n.values?(n=Qr(n.values),(r=!na(n[0]))&&(i*=i)):n=vp(n.increment)),Ca(e,t?_i(n)?function(a){return r=n(a),Math.abs(r-a)<=i?r:a}:function(a){for(var s=parseFloat(r?a.x:a),l=parseFloat(r?a.y:0),h=Kr,c=0,d=n.length,p,f;d--;)r?(p=n[d].x-s,f=n[d].y-l,p=p*p+f*f):p=Math.abs(n[d]-s),p<h&&(h=p,c=d);return c=!i||h<=i?n[c]:a,r||c===a||na(a)?c:c+$i(a)}:vp(n))},A0=function(n,e,t,i){return Ca(Ji(n)?!e:t===!0?!!(t=0):!i,function(){return Ji(n)?n[~~(Math.random()*n.length)]:(t=t||1e-5)&&(i=t<1?Math.pow(10,(t+"").length-2):1)&&Math.floor(Math.round((n-t/2+Math.random()*(e-n+t*.99))/t)*t*i)/i})},M2=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return function(i){return e.reduce(function(r,a){return a(r)},i)}},T2=function(n,e){return function(t){return n(parseFloat(t))+(e||$i(t))}},S2=function(n,e,t){return C0(n,e,0,1,t)},R0=function(n,e,t){return Ca(t,function(i){return n[~~e(i)]})},E2=function n(e,t,i){var r=t-e;return Ji(e)?R0(e,n(0,e.length),t):Ca(i,function(a){return(r+(a-e)%r)%r+e})},A2=function n(e,t,i){var r=t-e,a=r*2;return Ji(e)?R0(e,n(0,e.length-1),t):Ca(i,function(s){return s=(a+(s-e)%a)%a||0,e+(s>r?a-s:s)})},zl=function(n){for(var e=0,t="",i,r,a,s;~(i=n.indexOf("random(",e));)a=n.indexOf(")",i),s=n.charAt(i+7)==="[",r=n.substr(i+7,a-i-7).match(s?s0:np),t+=n.substr(e,i-e)+A0(s?r:+r[0],s?0:+r[1],+r[2]||1e-5),e=a+1;return t+n.substr(e,n.length-e)},C0=function(n,e,t,i,r){var a=e-n,s=i-t;return Ca(r,function(l){return t+((l-n)/a*s||0)})},R2=function n(e,t,i,r){var a=isNaN(e+t)?0:function(m){return(1-m)*e+m*t};if(!a){var s=Hi(e),l={},h,c,d,p,f;if(i===!0&&(r=1)&&(i=null),s)e={p:e},t={p:t};else if(Ji(e)&&!Ji(t)){for(d=[],p=e.length,f=p-2,c=1;c<p;c++)d.push(n(e[c-1],e[c]));p--,a=function(m){m*=p;var _=Math.min(f,~~m);return d[_](m-_)},i=t}else r||(e=ds(Ji(e)?[]:{},e));if(!d){for(h in t)wp.call(l,e,h,"get",t[h]);a=function(m){return Ap(m,l)||(s?e.p:e)}}}return Ca(i,a)},L0=function(n,e,t){var i=n.labels,r=Kr,a,s,l;for(a in i)s=i[a]-e,s<0==!!t&&s&&r>(s=Math.abs(s))&&(l=a,r=s);return l},Nr=function(n,e,t){var i=n.vars,r=i[e],a=gi,s=n._ctx,l,h,c;if(r)return l=i[e+"Params"],h=i.callbackScope||n,t&&Aa.length&&gc(),s&&(gi=s),c=l?r.apply(h,l):r.call(h),gi=a,c},Bl=function(n){return Ra(n),n.scrollTrigger&&n.scrollTrigger.kill(!!Zi),n.progress()<1&&Nr(n,"onInterrupt"),n},Co,P0=[],D0=function(n){if(rp()&&n){n=!n.name&&n.default||n;var e=n.name,t=_i(n),i=e&&!t&&n.init?function(){this._props=[]}:n,r={init:Il,render:Ap,add:wp,kill:W2,modifier:V2,rawVars:0},a={targetTest:0,get:0,getSetter:Ep,aliases:{},register:0};if(Lo(),n!==i){if(Or[e])return;Jr(i,Jr(_c(n,r),a)),ds(i.prototype,ds(r,_c(n,a))),Or[i.prop=e]=i,n.targetTest&&(mc.push(i),hp[e]=1),e=(e==="css"?"CSS":e.charAt(0).toUpperCase()+e.substr(1))+"Plugin"}h0(e,i),n.register&&n.register(yr,i,vr)}else n&&P0.push(n)},$t=255,Fl={aqua:[0,$t,$t],lime:[0,$t,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,$t],navy:[0,0,128],white:[$t,$t,$t],olive:[128,128,0],yellow:[$t,$t,0],orange:[$t,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[$t,0,0],pink:[$t,192,203],cyan:[0,$t,$t],transparent:[$t,$t,$t,0]},yp=function(n,e,t){return n+=n<0?1:n>1?-1:0,(n*6<1?e+(t-e)*n*6:n<.5?t:n*3<2?e+(t-e)*(2/3-n)*6:e)*$t+.5|0},I0=function(n,e,t){var i=n?na(n)?[n>>16,n>>8&$t,n&$t]:0:Fl.black,r,a,s,l,h,c,d,p,f,m;if(!i){if(n.substr(-1)===","&&(n=n.substr(0,n.length-1)),Fl[n])i=Fl[n];else if(n.charAt(0)==="#"){if(n.length<6&&(r=n.charAt(1),a=n.charAt(2),s=n.charAt(3),n="#"+r+r+a+a+s+s+(n.length===5?n.charAt(4)+n.charAt(4):"")),n.length===9)return i=parseInt(n.substr(1,6),16),[i>>16,i>>8&$t,i&$t,parseInt(n.substr(7),16)/255];n=parseInt(n.substr(1),16),i=[n>>16,n>>8&$t,n&$t]}else if(n.substr(0,3)==="hsl"){if(i=m=n.match(np),!e)l=+i[0]%360/360,h=+i[1]/100,c=+i[2]/100,a=c<=.5?c*(h+1):c+h-c*h,r=c*2-a,i.length>3&&(i[3]*=1),i[0]=yp(l+1/3,r,a),i[1]=yp(l,r,a),i[2]=yp(l-1/3,r,a);else if(~n.indexOf("="))return i=n.match(n0),t&&i.length<4&&(i[3]=1),i}else i=n.match(np)||Fl.transparent;i=i.map(Number)}return e&&!m&&(r=i[0]/$t,a=i[1]/$t,s=i[2]/$t,d=Math.max(r,a,s),p=Math.min(r,a,s),c=(d+p)/2,d===p?l=h=0:(f=d-p,h=c>.5?f/(2-d-p):f/(d+p),l=d===r?(a-s)/f+(a<s?6:0):d===a?(s-r)/f+2:(r-a)/f+4,l*=60),i[0]=~~(l+.5),i[1]=~~(h*100+.5),i[2]=~~(c*100+.5)),t&&i.length<4&&(i[3]=1),i},O0=function(n){var e=[],t=[],i=-1;return n.split(La).forEach(function(r){var a=r.match(So)||[];e.push.apply(e,a),t.push(i+=a.length+1)}),e.c=t,e},N0=function(n,e,t){var i="",r=(n+i).match(La),a=e?"hsla(":"rgba(",s=0,l,h,c,d;if(!r)return n;if(r=r.map(function(p){return(p=I0(p,e,1))&&a+(e?p[0]+","+p[1]+"%,"+p[2]+"%,"+p[3]:p.join(","))+")"}),t&&(c=O0(n),l=t.c,l.join(i)!==c.c.join(i)))for(h=n.replace(La,"1").split(So),d=h.length-1;s<d;s++)i+=h[s]+(~l.indexOf(s)?r.shift()||a+"0,0,0,0)":(c.length?c:r.length?r:t).shift());if(!h)for(h=n.split(La),d=h.length-1;s<d;s++)i+=h[s]+r[s];return i+h[d]},La=function(){var n="(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b",e;for(e in Fl)n+="|"+e+"\\b";return new RegExp(n+")","gi")}(),C2=/hsl[a]?\(/,U0=function(n){var e=n.join(" "),t;if(La.lastIndex=0,La.test(e))return t=C2.test(e),n[1]=N0(n[1],t),n[0]=N0(n[0],t,O0(n[1])),!0},kl,Ur=function(){var n=Date.now,e=500,t=33,i=n(),r=i,a=1e3/240,s=a,l=[],h,c,d,p,f,m,_=function x(y){var v=n()-r,M=y===!0,b,S,A,T;if(v>e&&(i+=v-t),r+=v,A=r-i,b=A-s,(b>0||M)&&(T=++p.frame,f=A-p.time*1e3,p.time=A=A/1e3,s+=b+(b>=a?4:a-b),S=1),M||(h=c(x)),S)for(m=0;m<l.length;m++)l[m](A,f,T,y)};return p={time:0,frame:0,tick:function(){_(!0)},deltaRatio:function(x){return f/(1e3/(x||60))},wake:function(){o0&&(!sp&&rp()&&(Zr=sp=window,op=Zr.document||{},Ir.gsap=yr,(Zr.gsapVersions||(Zr.gsapVersions=[])).push(yr.version),l0(pc||Zr.GreenSockGlobals||!Zr.gsap&&Zr||{}),d=Zr.requestAnimationFrame,P0.forEach(D0)),h&&p.sleep(),c=d||function(x){return setTimeout(x,s-p.time*1e3+1|0)},kl=1,_(2))},sleep:function(){(d?Zr.cancelAnimationFrame:clearTimeout)(h),kl=0,c=Il},lagSmoothing:function(x,y){e=x||1/0,t=Math.min(y||33,e)},fps:function(x){a=1e3/(x||240),s=p.time*1e3+a},add:function(x,y,v){var M=y?function(b,S,A,T){x(b,S,A,T),p.remove(M)}:x;return p.remove(x),l[v?"unshift":"push"](M),Lo(),M},remove:function(x,y){~(y=l.indexOf(x))&&l.splice(y,1)&&m>=y&&m--},_listeners:l},p}(),Lo=function(){return!kl&&Ur.wake()},It={},L2=/^[\d.\-M][\d.\-,\s]/,P2=/["']/g,D2=function(n){for(var e={},t=n.substr(1,n.length-3).split(":"),i=t[0],r=1,a=t.length,s,l,h;r<a;r++)l=t[r],s=r!==a-1?l.lastIndexOf(","):l.length,h=l.substr(0,s),e[i]=isNaN(h)?h.replace(P2,"").trim():+h,i=l.substr(s+1).trim();return e},I2=function(n){var e=n.indexOf("(")+1,t=n.indexOf(")"),i=n.indexOf("(",e);return n.substring(e,~i&&i<t?n.indexOf(")",t+1):t)},O2=function(n){var e=(n+"").split("("),t=It[e[0]];return t&&e.length>1&&t.config?t.config.apply(null,~n.indexOf("{")?[D2(e[1])]:I2(n).split(",").map(f0)):It._CE&&L2.test(n)?It._CE("",n):t},z0=function(n){return function(e){return 1-n(1-e)}},B0=function n(e,t){for(var i=e._first,r;i;)i instanceof sr?n(i,t):i.vars.yoyoEase&&(!i._yoyo||!i._repeat)&&i._yoyo!==t&&(i.timeline?n(i.timeline,t):(r=i._ease,i._ease=i._yEase,i._yEase=r,i._yoyo=t)),i=i._next},fs=function(n,e){return n&&(_i(n)?n:It[n]||O2(n))||e},ms=function(n,e,t,i){t===void 0&&(t=function(s){return 1-e(1-s)}),i===void 0&&(i=function(s){return s<.5?e(s*2)/2:1-e((1-s)*2)/2});var r={easeIn:e,easeOut:t,easeInOut:i},a;return _r(n,function(s){It[s]=Ir[s]=r,It[a=s.toLowerCase()]=t;for(var l in r)It[a+(l==="easeIn"?".in":l==="easeOut"?".out":".inOut")]=It[s+"."+l]=r[l]}),r},F0=function(n){return function(e){return e<.5?(1-n(1-e*2))/2:.5+n((e-.5)*2)/2}},xp=function n(e,t,i){var r=t>=1?t:1,a=(i||(e?.3:.45))/(t<1?t:1),s=a/tp*(Math.asin(1/r)||0),l=function(c){return c===1?1:r*Math.pow(2,-10*c)*l2((c-s)*a)+1},h=e==="out"?l:e==="in"?function(c){return 1-l(1-c)}:F0(l);return a=tp/a,h.config=function(c,d){return n(e,c,d)},h},bp=function n(e,t){t===void 0&&(t=1.70158);var i=function(a){return a?--a*a*((t+1)*a+t)+1:0},r=e==="out"?i:e==="in"?function(a){return 1-i(1-a)}:F0(i);return r.config=function(a){return n(e,a)},r};_r("Linear,Quad,Cubic,Quart,Quint,Strong",function(n,e){var t=e<5?e+1:e;ms(n+",Power"+(t-1),e?function(i){return Math.pow(i,t)}:function(i){return i},function(i){return 1-Math.pow(1-i,t)},function(i){return i<.5?Math.pow(i*2,t)/2:1-Math.pow((1-i)*2,t)/2})}),It.Linear.easeNone=It.none=It.Linear.easeIn,ms("Elastic",xp("in"),xp("out"),xp()),function(n,e){var t=1/e,i=2*t,r=2.5*t,a=function(s){return s<t?n*s*s:s<i?n*Math.pow(s-1.5/e,2)+.75:s<r?n*(s-=2.25/e)*s+.9375:n*Math.pow(s-2.625/e,2)+.984375};ms("Bounce",function(s){return 1-a(1-s)},a)}(7.5625,2.75),ms("Expo",function(n){return n?Math.pow(2,10*(n-1)):0}),ms("Circ",function(n){return-(i0(1-n*n)-1)}),ms("Sine",function(n){return n===1?1:-o2(n*a2)+1}),ms("Back",bp("in"),bp("out"),bp()),It.SteppedEase=It.steps=Ir.SteppedEase={config:function(n,e){n===void 0&&(n=1);var t=1/n,i=n+(e?0:1),r=e?1:0,a=1-Jt;return function(s){return((i*Ul(0,a,s)|0)+r)*t}}},To.ease=It["quad.out"],_r("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt",function(n){return dp+=n+","+n+"Params,"});var k0=function(n,e){this.id=s2++,n._gsap=this,this.target=n,this.harness=e,this.get=e?e.get:d0,this.set=e?e.getSetter:Ep},Hl=function(){function n(t){this.vars=t,this._delay=+t.delay||0,(this._repeat=t.repeat===1/0?-2:t.repeat||0)&&(this._rDelay=t.repeatDelay||0,this._yoyo=!!t.yoyo||!!t.yoyoEase),this._ts=1,Ro(this,+t.duration,1,1),this.data=t.data,gi&&(this._ctx=gi,gi.data.push(this)),kl||Ur.wake()}var e=n.prototype;return e.delay=function(t){return t||t===0?(this.parent&&this.parent.smoothChildTiming&&this.startTime(this._start+t-this._delay),this._delay=t,this):this._delay},e.duration=function(t){return arguments.length?this.totalDuration(this._repeat>0?t+(t+this._rDelay)*this._repeat:t):this.totalDuration()&&this._dur},e.totalDuration=function(t){return arguments.length?(this._dirty=0,Ro(this,this._repeat<0?t:(t-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur},e.totalTime=function(t,i){if(Lo(),!arguments.length)return this._tTime;var r=this._dp;if(r&&r.smoothChildTiming&&this._ts){for(bc(this,t),!r._dp||r.parent||y0(r,this);r&&r.parent;)r.parent._time!==r._start+(r._ts>=0?r._tTime/r._ts:(r.totalDuration()-r._tTime)/-r._ts)&&r.totalTime(r._tTime,!0),r=r.parent;!this.parent&&this._dp.autoRemoveChildren&&(this._ts>0&&t<this._tDur||this._ts<0&&t>0||!this._tDur&&!t)&&Nn(this._dp,this,this._start-this._delay)}return(this._tTime!==t||!this._dur&&!i||this._initted&&Math.abs(this._zTime)===Jt||!t&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=t),p0(this,t,i)),this},e.time=function(t,i){return arguments.length?this.totalTime(Math.min(this.totalDuration(),t+v0(this))%(this._dur+this._rDelay)||(t?this._dur:0),i):this._time},e.totalProgress=function(t,i){return arguments.length?this.totalTime(this.totalDuration()*t,i):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.rawTime()>0?1:0},e.progress=function(t,i){return arguments.length?this.totalTime(this.duration()*(this._yoyo&&!(this.iteration()&1)?1-t:t)+v0(this),i):this.duration()?Math.min(1,this._time/this._dur):this.rawTime()>0?1:0},e.iteration=function(t,i){var r=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(t-1)*r,i):this._repeat?Ao(this._tTime,r)+1:1},e.timeScale=function(t,i){if(!arguments.length)return this._rts===-Jt?0:this._rts;if(this._rts===t)return this;var r=this.parent&&this._ts?yc(this.parent._time,this):this._tTime;return this._rts=+t||0,this._ts=this._ps||t===-Jt?0:this._rts,this.totalTime(Ul(-Math.abs(this._delay),this._tDur,r),i!==!1),xc(this),m2(this)},e.paused=function(t){return arguments.length?(this._ps!==t&&(this._ps=t,t?(this._pTime=this._tTime||Math.max(-this._delay,this.rawTime()),this._ts=this._act=0):(Lo(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,this.progress()===1&&Math.abs(this._zTime)!==Jt&&(this._tTime-=Jt)))),this):this._ps},e.startTime=function(t){if(arguments.length){this._start=t;var i=this.parent||this._dp;return i&&(i._sort||!this.parent)&&Nn(i,this,t-this._delay),this}return this._start},e.endTime=function(t){return this._start+(gr(t)?this.totalDuration():this.duration())/Math.abs(this._ts||1)},e.rawTime=function(t){var i=this.parent||this._dp;return i?t&&(!this._ts||this._repeat&&this._time&&this.totalProgress()<1)?this._tTime%(this._dur+this._rDelay):this._ts?yc(i.rawTime(t),this):this._tTime:this._tTime},e.revert=function(t){t===void 0&&(t=u2);var i=Zi;return Zi=t,(this._initted||this._startAt)&&(this.timeline&&this.timeline.revert(t),this.totalTime(-.01,t.suppressEvents)),this.data!=="nested"&&t.kill!==!1&&this.kill(),Zi=i,this},e.globalTime=function(t){for(var i=this,r=arguments.length?t:i.rawTime();i;)r=i._start+r/(Math.abs(i._ts)||1),i=i._dp;return!this.parent&&this._sat?this._sat.globalTime(t):r},e.repeat=function(t){return arguments.length?(this._repeat=t===1/0?-2:t,w0(this)):this._repeat===-2?1/0:this._repeat},e.repeatDelay=function(t){if(arguments.length){var i=this._time;return this._rDelay=t,w0(this),i?this.time(i):this}return this._rDelay},e.yoyo=function(t){return arguments.length?(this._yoyo=t,this):this._yoyo},e.seek=function(t,i){return this.totalTime($r(this,t),gr(i))},e.restart=function(t,i){return this.play().totalTime(t?-this._delay:0,gr(i))},e.play=function(t,i){return t!=null&&this.seek(t,i),this.reversed(!1).paused(!1)},e.reverse=function(t,i){return t!=null&&this.seek(t||this.totalDuration(),i),this.reversed(!0).paused(!1)},e.pause=function(t,i){return t!=null&&this.seek(t,i),this.paused(!0)},e.resume=function(){return this.paused(!1)},e.reversed=function(t){return arguments.length?(!!t!==this.reversed()&&this.timeScale(-this._rts||(t?-Jt:0)),this):this._rts<0},e.invalidate=function(){return this._initted=this._act=0,this._zTime=-Jt,this},e.isActive=function(){var t=this.parent||this._dp,i=this._start,r;return!!(!t||this._ts&&this._initted&&t.isActive()&&(r=t.rawTime(!0))>=i&&r<this.endTime(!0)-Jt)},e.eventCallback=function(t,i,r){var a=this.vars;return arguments.length>1?(i?(a[t]=i,r&&(a[t+"Params"]=r),t==="onUpdate"&&(this._onUpdate=i)):delete a[t],this):a[t]},e.then=function(t){var i=this;return new Promise(function(r){var a=_i(t)?t:m0,s=function(){var l=i.then;i.then=null,_i(a)&&(a=a(i))&&(a.then||a===i)&&(i.then=l),r(a),i.then=l};i._initted&&i.totalProgress()===1&&i._ts>=0||!i._tTime&&i._ts<0?s():i._prom=s})},e.kill=function(){Bl(this)},n}();Jr(Hl.prototype,{_time:0,_start:0,_end:0,_tTime:0,_tDur:0,_dirty:0,_repeat:0,_yoyo:!1,parent:null,_initted:!1,_rDelay:0,_ts:1,_dp:0,ratio:0,_zTime:-Jt,_prom:0,_ps:!1,_rts:1});var sr=function(n){t0(e,n);function e(i,r){var a;return i===void 0&&(i={}),a=n.call(this,i)||this,a.labels={},a.smoothChildTiming=!!i.smoothChildTiming,a.autoRemoveChildren=!!i.autoRemoveChildren,a._sort=gr(i.sortChildren),ci&&Nn(i.parent||ci,ra(a),r),i.reversed&&a.reverse(),i.paused&&a.paused(!0),i.scrollTrigger&&x0(ra(a),i.scrollTrigger),a}var t=e.prototype;return t.to=function(i,r,a){return Nl(0,arguments,this),this},t.from=function(i,r,a){return Nl(1,arguments,this),this},t.fromTo=function(i,r,a,s){return Nl(2,arguments,this),this},t.set=function(i,r,a){return r.duration=0,r.parent=this,Ol(r).repeatDelay||(r.repeat=0),r.immediateRender=!!r.immediateRender,new Ai(i,r,$r(this,a),1),this},t.call=function(i,r,a){return Nn(this,Ai.delayedCall(0,i,r),a)},t.staggerTo=function(i,r,a,s,l,h,c){return a.duration=r,a.stagger=a.stagger||s,a.onComplete=h,a.onCompleteParams=c,a.parent=this,new Ai(i,a,$r(this,l)),this},t.staggerFrom=function(i,r,a,s,l,h,c){return a.runBackwards=1,Ol(a).immediateRender=gr(a.immediateRender),this.staggerTo(i,r,a,s,l,h,c)},t.staggerFromTo=function(i,r,a,s,l,h,c,d){return s.startAt=a,Ol(s).immediateRender=gr(s.immediateRender),this.staggerTo(i,r,s,l,h,c,d)},t.render=function(i,r,a){var s=this._time,l=this._dirty?this.totalDuration():this._tDur,h=this._dur,c=i<=0?0:Gi(i),d=this._zTime<0!=i<0&&(this._initted||!h),p,f,m,_,x,y,v,M,b,S,A,T;if(this!==ci&&c>l&&i>=0&&(c=l),c!==this._tTime||a||d){if(s!==this._time&&h&&(c+=this._time-s,i+=this._time-s),p=c,b=this._start,M=this._ts,y=!M,d&&(h||(s=this._zTime),(i||!r)&&(this._zTime=i)),this._repeat){if(A=this._yoyo,x=h+this._rDelay,this._repeat<-1&&i<0)return this.totalTime(x*100+i,r,a);if(p=Gi(c%x),c===l?(_=this._repeat,p=h):(_=~~(c/x),_&&_===c/x&&(p=h,_--),p>h&&(p=h)),S=Ao(this._tTime,x),!s&&this._tTime&&S!==_&&this._tTime-S*x-this._dur<=0&&(S=_),A&&_&1&&(p=h-p,T=1),_!==S&&!this._lock){var E=A&&S&1,I=E===(A&&_&1);if(_<S&&(E=!E),s=E?0:c%h?h:c,this._lock=1,this.render(s||(T?0:Gi(_*x)),r,!h)._lock=0,this._tTime=c,!r&&this.parent&&Nr(this,"onRepeat"),this.vars.repeatRefresh&&!T&&(this.invalidate()._lock=1),s&&s!==this._time||y!==!this._ts||this.vars.onRepeat&&!this.parent&&!this._act)return this;if(h=this._dur,l=this._tDur,I&&(this._lock=2,s=E?h:-1e-4,this.render(s,!0),this.vars.repeatRefresh&&!T&&this.invalidate()),this._lock=0,!this._ts&&!y)return this;B0(this,T)}}if(this._hasPause&&!this._forcing&&this._lock<2&&(v=y2(this,Gi(s),Gi(p)),v&&(c-=p-(p=v._start))),this._tTime=c,this._time=p,this._act=!M,this._initted||(this._onUpdate=this.vars.onUpdate,this._initted=1,this._zTime=i,s=0),!s&&p&&!r&&!_&&(Nr(this,"onStart"),this._tTime!==c))return this;if(p>=s&&i>=0)for(f=this._first;f;){if(m=f._next,(f._act||p>=f._start)&&f._ts&&v!==f){if(f.parent!==this)return this.render(i,r,a);if(f.render(f._ts>0?(p-f._start)*f._ts:(f._dirty?f.totalDuration():f._tDur)+(p-f._start)*f._ts,r,a),p!==this._time||!this._ts&&!y){v=0,m&&(c+=this._zTime=-Jt);break}}f=m}else{f=this._last;for(var C=i<0?i:p;f;){if(m=f._prev,(f._act||C<=f._end)&&f._ts&&v!==f){if(f.parent!==this)return this.render(i,r,a);if(f.render(f._ts>0?(C-f._start)*f._ts:(f._dirty?f.totalDuration():f._tDur)+(C-f._start)*f._ts,r,a||Zi&&(f._initted||f._startAt)),p!==this._time||!this._ts&&!y){v=0,m&&(c+=this._zTime=C?-Jt:Jt);break}}f=m}}if(v&&!r&&(this.pause(),v.render(p>=s?0:-Jt)._zTime=p>=s?1:-1,this._ts))return this._start=b,xc(this),this.render(i,r,a);this._onUpdate&&!r&&Nr(this,"onUpdate",!0),(c===l&&this._tTime>=this.totalDuration()||!c&&s)&&(b===this._start||Math.abs(M)!==Math.abs(this._ts))&&(this._lock||((i||!h)&&(c===l&&this._ts>0||!c&&this._ts<0)&&Ra(this,1),!r&&!(i<0&&!s)&&(c||s||!l)&&(Nr(this,c===l&&i>=0?"onComplete":"onReverseComplete",!0),this._prom&&!(c<l&&this.timeScale()>0)&&this._prom())))}return this},t.add=function(i,r){var a=this;if(na(r)||(r=$r(this,r,i)),!(i instanceof Hl)){if(Ji(i))return i.forEach(function(s){return a.add(s,r)}),this;if(Hi(i))return this.addLabel(i,r);if(_i(i))i=Ai.delayedCall(0,i);else return this}return this!==i?Nn(this,i,r):this},t.getChildren=function(i,r,a,s){i===void 0&&(i=!0),r===void 0&&(r=!0),a===void 0&&(a=!0),s===void 0&&(s=-Kr);for(var l=[],h=this._first;h;)h._start>=s&&(h instanceof Ai?r&&l.push(h):(a&&l.push(h),i&&l.push.apply(l,h.getChildren(!0,r,a)))),h=h._next;return l},t.getById=function(i){for(var r=this.getChildren(1,1,1),a=r.length;a--;)if(r[a].vars.id===i)return r[a]},t.remove=function(i){return Hi(i)?this.removeLabel(i):_i(i)?this.killTweensOf(i):(vc(this,i),i===this._recent&&(this._recent=this._last),ps(this))},t.totalTime=function(i,r){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=Gi(Ur.time-(this._ts>0?i/this._ts:(this.totalDuration()-i)/-this._ts))),n.prototype.totalTime.call(this,i,r),this._forcing=0,this):this._tTime},t.addLabel=function(i,r){return this.labels[i]=$r(this,r),this},t.removeLabel=function(i){return delete this.labels[i],this},t.addPause=function(i,r,a){var s=Ai.delayedCall(0,r||Il,a);return s.data="isPause",this._hasPause=1,Nn(this,s,$r(this,i))},t.removePause=function(i){var r=this._first;for(i=$r(this,i);r;)r._start===i&&r.data==="isPause"&&Ra(r),r=r._next},t.killTweensOf=function(i,r,a){for(var s=this.getTweensOf(i,a),l=s.length;l--;)Pa!==s[l]&&s[l].kill(i,r);return this},t.getTweensOf=function(i,r){for(var a=[],s=Qr(i),l=this._first,h=na(r),c;l;)l instanceof Ai?d2(l._targets,s)&&(h?(!Pa||l._initted&&l._ts)&&l.globalTime(0)<=r&&l.globalTime(l.totalDuration())>r:!r||l.isActive())&&a.push(l):(c=l.getTweensOf(s,r)).length&&a.push.apply(a,c),l=l._next;return a},t.tweenTo=function(i,r){r=r||{};var a=this,s=$r(a,i),l=r,h=l.startAt,c=l.onStart,d=l.onStartParams,p=l.immediateRender,f,m=Ai.to(a,Jr({ease:r.ease||"none",lazy:!1,immediateRender:!1,time:s,overwrite:"auto",duration:r.duration||Math.abs((s-(h&&"time"in h?h.time:a._time))/a.timeScale())||Jt,onStart:function(){if(a.pause(),!f){var _=r.duration||Math.abs((s-(h&&"time"in h?h.time:a._time))/a.timeScale());m._dur!==_&&Ro(m,_,0,1).render(m._time,!0,!0),f=1}c&&c.apply(m,d||[])}},r));return p?m.render(0):m},t.tweenFromTo=function(i,r,a){return this.tweenTo(r,Jr({startAt:{time:$r(this,i)}},a))},t.recent=function(){return this._recent},t.nextLabel=function(i){return i===void 0&&(i=this._time),L0(this,$r(this,i))},t.previousLabel=function(i){return i===void 0&&(i=this._time),L0(this,$r(this,i),1)},t.currentLabel=function(i){return arguments.length?this.seek(i,!0):this.previousLabel(this._time+Jt)},t.shiftChildren=function(i,r,a){a===void 0&&(a=0);for(var s=this._first,l=this.labels,h;s;)s._start>=a&&(s._start+=i,s._end+=i),s=s._next;if(r)for(h in l)l[h]>=a&&(l[h]+=i);return ps(this)},t.invalidate=function(i){var r=this._first;for(this._lock=0;r;)r.invalidate(i),r=r._next;return n.prototype.invalidate.call(this,i)},t.clear=function(i){i===void 0&&(i=!0);for(var r=this._first,a;r;)a=r._next,this.remove(r),r=a;return this._dp&&(this._time=this._tTime=this._pTime=0),i&&(this.labels={}),ps(this)},t.totalDuration=function(i){var r=0,a=this,s=a._last,l=Kr,h,c,d;if(arguments.length)return a.timeScale((a._repeat<0?a.duration():a.totalDuration())/(a.reversed()?-i:i));if(a._dirty){for(d=a.parent;s;)h=s._prev,s._dirty&&s.totalDuration(),c=s._start,c>l&&a._sort&&s._ts&&!a._lock?(a._lock=1,Nn(a,s,c-s._delay,1)._lock=0):l=c,c<0&&s._ts&&(r-=c,(!d&&!a._dp||d&&d.smoothChildTiming)&&(a._start+=c/a._ts,a._time-=c,a._tTime-=c),a.shiftChildren(-c,!1,-1/0),l=0),s._end>r&&s._ts&&(r=s._end),s=h;Ro(a,a===ci&&a._time>r?a._time:r,1,1),a._dirty=0}return a._tDur},e.updateRoot=function(i){if(ci._ts&&(p0(ci,yc(i,ci)),c0=Ur.frame),Ur.frame>=u0){u0+=Dr.autoSleep||120;var r=ci._first;if((!r||!r._ts)&&Dr.autoSleep&&Ur._listeners.length<2){for(;r&&!r._ts;)r=r._next;r||Ur.sleep()}}},e}(Hl);Jr(sr.prototype,{_lock:0,_hasPause:0,_forcing:0});var N2=function(n,e,t,i,r,a,s){var l=new vr(this._pt,n,e,0,1,X0,null,r),h=0,c=0,d,p,f,m,_,x,y,v;for(l.b=t,l.e=i,t+="",i+="",(y=~i.indexOf("random("))&&(i=zl(i)),a&&(v=[t,i],a(v,n,e),t=v[0],i=v[1]),p=t.match(ap)||[];d=ap.exec(i);)m=d[0],_=i.substring(h,d.index),f?f=(f+1)%5:_.substr(-5)==="rgba("&&(f=1),m!==p[c++]&&(x=parseFloat(p[c-1])||0,l._pt={_next:l._pt,p:_||c===1?_:",",s:x,c:m.charAt(1)==="="?Eo(x,m)-x:parseFloat(m)-x,m:f&&f<4?Math.round:0},h=ap.lastIndex);return l.c=h<i.length?i.substring(h,i.length):"",l.fp=s,(a0.test(i)||y)&&(l.e=0),this._pt=l,l},wp=function(n,e,t,i,r,a,s,l,h,c){_i(i)&&(i=i(r||0,n,a));var d=n[e],p=t!=="get"?t:_i(d)?h?n[e.indexOf("set")||!_i(n["get"+e.substr(3)])?e:"get"+e.substr(3)](h):n[e]():d,f=_i(d)?h?k2:W0:Sp,m;if(Hi(i)&&(~i.indexOf("random(")&&(i=zl(i)),i.charAt(1)==="="&&(m=Eo(p,i)+($i(p)||0),(m||m===0)&&(i=m))),!c||p!==i||Mp)return!isNaN(p*i)&&i!==""?(m=new vr(this._pt,n,e,+p||0,i-(p||0),typeof d=="boolean"?G2:j0,0,f),h&&(m.fp=h),s&&m.modifier(s,this,n),this._pt=m):(!d&&!(e in n)&&lp(e,i),N2.call(this,n,e,p,i,f,l||Dr.stringFilter,h))},U2=function(n,e,t,i,r){if(_i(n)&&(n=Gl(n,r,e,t,i)),!On(n)||n.style&&n.nodeType||Ji(n)||r0(n))return Hi(n)?Gl(n,r,e,t,i):n;var a={},s;for(s in n)a[s]=Gl(n[s],r,e,t,i);return a},H0=function(n,e,t,i,r,a){var s,l,h,c;if(Or[n]&&(s=new Or[n]).init(r,s.rawVars?e[n]:U2(e[n],i,r,a,t),t,i,a)!==!1&&(t._pt=l=new vr(t._pt,r,n,0,1,s.render,s,0,s.priority),t!==Co))for(h=t._ptLookup[t._targets.indexOf(r)],c=s._props.length;c--;)h[s._props[c]]=l;return s},Pa,Mp,Tp=function n(e,t,i){var r=e.vars,a=r.ease,s=r.startAt,l=r.immediateRender,h=r.lazy,c=r.onUpdate,d=r.runBackwards,p=r.yoyoEase,f=r.keyframes,m=r.autoRevert,_=e._dur,x=e._startAt,y=e._targets,v=e.parent,M=v&&v.data==="nested"?v.vars.targets:y,b=e._overwrite==="auto"&&!ep,S=e.timeline,A,T,E,I,C,P,X,q,te,k,H,V,J;if(S&&(!f||!a)&&(a="none"),e._ease=fs(a,To.ease),e._yEase=p?z0(fs(p===!0?a:p,To.ease)):0,p&&e._yoyo&&!e._repeat&&(p=e._yEase,e._yEase=e._ease,e._ease=p),e._from=!S&&!!r.runBackwards,!S||f&&!r.stagger){if(q=y[0]?us(y[0]).harness:0,V=q&&r[q.prop],A=_c(r,hp),x&&(x._zTime<0&&x.progress(1),t<0&&d&&l&&!m?x.render(-1,!0):x.revert(d&&_?fc:c2),x._lazy=0),s){if(Ra(e._startAt=Ai.set(y,Jr({data:"isStart",overwrite:!1,parent:v,immediateRender:!0,lazy:!x&&gr(h),startAt:null,delay:0,onUpdate:c&&function(){return Nr(e,"onUpdate")},stagger:0},s))),e._startAt._dp=0,e._startAt._sat=e,t<0&&(Zi||!l&&!m)&&e._startAt.revert(fc),l&&_&&t<=0&&i<=0){t&&(e._zTime=t);return}}else if(d&&_&&!x){if(t&&(l=!1),E=Jr({overwrite:!1,data:"isFromStart",lazy:l&&!x&&gr(h),immediateRender:l,stagger:0,parent:v},A),V&&(E[q.prop]=V),Ra(e._startAt=Ai.set(y,E)),e._startAt._dp=0,e._startAt._sat=e,t<0&&(Zi?e._startAt.revert(fc):e._startAt.render(-1,!0)),e._zTime=t,!l)n(e._startAt,Jt,Jt);else if(!t)return}for(e._pt=e._ptCache=0,h=_&&gr(h)||h&&!_,T=0;T<y.length;T++){if(C=y[T],X=C._gsap||pp(y)[T]._gsap,e._ptLookup[T]=k={},cp[X.id]&&Aa.length&&gc(),H=M===y?T:M.indexOf(C),q&&(te=new q).init(C,V||A,e,H,M)!==!1&&(e._pt=I=new vr(e._pt,C,te.name,0,1,te.render,te,0,te.priority),te._props.forEach(function(ie){k[ie]=I}),te.priority&&(P=1)),!q||V)for(E in A)Or[E]&&(te=H0(E,A,e,H,C,M))?te.priority&&(P=1):k[E]=I=wp.call(e,C,E,"get",A[E],H,M,0,r.stringFilter);e._op&&e._op[T]&&e.kill(C,e._op[T]),b&&e._pt&&(Pa=e,ci.killTweensOf(C,k,e.globalTime(t)),J=!e.parent,Pa=0),e._pt&&h&&(cp[X.id]=1)}P&&q0(e),e._onInit&&e._onInit(e)}e._onUpdate=c,e._initted=(!e._op||e._pt)&&!J,f&&t<=0&&S.render(Kr,!0,!0)},z2=function(n,e,t,i,r,a,s,l){var h=(n._pt&&n._ptCache||(n._ptCache={}))[e],c,d,p,f;if(!h)for(h=n._ptCache[e]=[],p=n._ptLookup,f=n._targets.length;f--;){if(c=p[f][e],c&&c.d&&c.d._pt)for(c=c.d._pt;c&&c.p!==e&&c.fp!==e;)c=c._next;if(!c)return Mp=1,n.vars[e]="+=0",Tp(n,s),Mp=0,l?Dl(e+" not eligible for reset"):1;h.push(c)}for(f=h.length;f--;)d=h[f],c=d._pt||d,c.s=(i||i===0)&&!r?i:c.s+(i||0)+a*c.c,c.c=t-c.s,d.e&&(d.e=Mi(t)+$i(d.e)),d.b&&(d.b=c.s+$i(d.b))},B2=function(n,e){var t=n[0]?us(n[0]).harness:0,i=t&&t.aliases,r,a,s,l;if(!i)return e;r=ds({},e);for(a in i)if(a in r)for(l=i[a].split(","),s=l.length;s--;)r[l[s]]=r[a];return r},F2=function(n,e,t,i){var r=e.ease||i||"power1.inOut",a,s;if(Ji(e))s=t[n]||(t[n]=[]),e.forEach(function(l,h){return s.push({t:h/(e.length-1)*100,v:l,e:r})});else for(a in e)s=t[a]||(t[a]=[]),a==="ease"||s.push({t:parseFloat(n),v:e[a],e:r})},Gl=function(n,e,t,i,r){return _i(n)?n.call(e,t,i,r):Hi(n)&&~n.indexOf("random(")?zl(n):n},G0=dp+"repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase,autoRevert",V0={};_r(G0+",id,stagger,delay,duration,paused,scrollTrigger",function(n){return V0[n]=1});var Ai=function(n){t0(e,n);function e(i,r,a,s){var l;typeof r=="number"&&(a.duration=r,r=a,a=null),l=n.call(this,s?r:Ol(r))||this;var h=l.vars,c=h.duration,d=h.delay,p=h.immediateRender,f=h.stagger,m=h.overwrite,_=h.keyframes,x=h.defaults,y=h.scrollTrigger,v=h.yoyoEase,M=r.parent||ci,b=(Ji(i)||r0(i)?na(i[0]):"length"in r)?[i]:Qr(i),S,A,T,E,I,C,P,X;if(l._targets=b.length?pp(b):Dl("GSAP target "+i+" not found. https://gsap.com",!Dr.nullTargetWarn)||[],l._ptLookup=[],l._overwrite=m,_||f||dc(c)||dc(d)){if(r=l.vars,S=l.timeline=new sr({data:"nested",defaults:x||{},targets:M&&M.data==="nested"?M.vars.targets:b}),S.kill(),S.parent=S._dp=ra(l),S._start=0,f||dc(c)||dc(d)){if(E=b.length,P=f&&S0(f),On(f))for(I in f)~G0.indexOf(I)&&(X||(X={}),X[I]=f[I]);for(A=0;A<E;A++)T=_c(r,V0),T.stagger=0,v&&(T.yoyoEase=v),X&&ds(T,X),C=b[A],T.duration=+Gl(c,ra(l),A,C,b),T.delay=(+Gl(d,ra(l),A,C,b)||0)-l._delay,!f&&E===1&&T.delay&&(l._delay=d=T.delay,l._start+=d,T.delay=0),S.to(C,T,P?P(A,C,b):0),S._ease=It.none;S.duration()?c=d=0:l.timeline=0}else if(_){Ol(Jr(S.vars.defaults,{ease:"none"})),S._ease=fs(_.ease||r.ease||"none");var q=0,te,k,H;if(Ji(_))_.forEach(function(V){return S.to(b,V,">")}),S.duration();else{T={};for(I in _)I==="ease"||I==="easeEach"||F2(I,_[I],T,_.easeEach);for(I in T)for(te=T[I].sort(function(V,J){return V.t-J.t}),q=0,A=0;A<te.length;A++)k=te[A],H={ease:k.e,duration:(k.t-(A?te[A-1].t:0))/100*c},H[I]=k.v,S.to(b,H,q),q+=H.duration;S.duration()<c&&S.to({},{duration:c-S.duration()})}}c||l.duration(c=S.duration())}else l.timeline=0;return m===!0&&!ep&&(Pa=ra(l),ci.killTweensOf(b),Pa=0),Nn(M,ra(l),a),r.reversed&&l.reverse(),r.paused&&l.paused(!0),(p||!c&&!_&&l._start===Gi(M._time)&&gr(p)&&g2(ra(l))&&M.data!=="nested")&&(l._tTime=-Jt,l.render(Math.max(0,-d)||0)),y&&x0(ra(l),y),l}var t=e.prototype;return t.render=function(i,r,a){var s=this._time,l=this._tDur,h=this._dur,c=i<0,d=i>l-Jt&&!c?l:i<Jt?0:i,p,f,m,_,x,y,v,M,b;if(!h)v2(this,i,r,a);else if(d!==this._tTime||!i||a||!this._initted&&this._tTime||this._startAt&&this._zTime<0!==c){if(p=d,M=this.timeline,this._repeat){if(_=h+this._rDelay,this._repeat<-1&&c)return this.totalTime(_*100+i,r,a);if(p=Gi(d%_),d===l?(m=this._repeat,p=h):(m=~~(d/_),m&&m===Gi(d/_)&&(p=h,m--),p>h&&(p=h)),y=this._yoyo&&m&1,y&&(b=this._yEase,p=h-p),x=Ao(this._tTime,_),p===s&&!a&&this._initted&&m===x)return this._tTime=d,this;m!==x&&(M&&this._yEase&&B0(M,y),this.vars.repeatRefresh&&!y&&!this._lock&&this._time!==h&&this._initted&&(this._lock=a=1,this.render(Gi(_*m),!0).invalidate()._lock=0))}if(!this._initted){if(b0(this,c?i:p,a,r,d))return this._tTime=0,this;if(s!==this._time&&!(a&&this.vars.repeatRefresh&&m!==x))return this;if(h!==this._dur)return this.render(i,r,a)}if(this._tTime=d,this._time=p,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=v=(b||this._ease)(p/h),this._from&&(this.ratio=v=1-v),p&&!s&&!r&&!m&&(Nr(this,"onStart"),this._tTime!==d))return this;for(f=this._pt;f;)f.r(v,f.d),f=f._next;M&&M.render(i<0?i:!p&&y?-Jt:M._dur*M._ease(p/this._dur),r,a)||this._startAt&&(this._zTime=i),this._onUpdate&&!r&&(c&&fp(this,i,r,a),Nr(this,"onUpdate")),this._repeat&&m!==x&&this.vars.onRepeat&&!r&&this.parent&&Nr(this,"onRepeat"),(d===this._tDur||!d)&&this._tTime===d&&(c&&!this._onUpdate&&fp(this,i,!0,!0),(i||!h)&&(d===this._tDur&&this._ts>0||!d&&this._ts<0)&&Ra(this,1),!r&&!(c&&!s)&&(d||s||y)&&(Nr(this,d===l?"onComplete":"onReverseComplete",!0),this._prom&&!(d<l&&this.timeScale()>0)&&this._prom()))}return this},t.targets=function(){return this._targets},t.invalidate=function(i){return(!i||!this.vars.runBackwards)&&(this._startAt=0),this._pt=this._op=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(i),n.prototype.invalidate.call(this,i)},t.resetTo=function(i,r,a,s,l){kl||Ur.wake(),this._ts||this.play();var h=Math.min(this._dur,(this._dp._time-this._start)*this._ts),c;return this._initted||Tp(this,h),c=this._ease(h/this._dur),z2(this,i,r,a,s,c,h,l)?this.resetTo(i,r,a,s,1):(bc(this,0),this.parent||_0(this._dp,this,"_first","_last",this._dp._sort?"_start":0),this.render(0))},t.kill=function(i,r){if(r===void 0&&(r="all"),!i&&(!r||r==="all"))return this._lazy=this._pt=0,this.parent?Bl(this):this;if(this.timeline){var a=this.timeline.totalDuration();return this.timeline.killTweensOf(i,r,Pa&&Pa.vars.overwrite!==!0)._first||Bl(this),this.parent&&a!==this.timeline.totalDuration()&&Ro(this,this._dur*this.timeline._tDur/a,0,1),this}var s=this._targets,l=i?Qr(i):s,h=this._ptLookup,c=this._pt,d,p,f,m,_,x,y;if((!r||r==="all")&&f2(s,l))return r==="all"&&(this._pt=0),Bl(this);for(d=this._op=this._op||[],r!=="all"&&(Hi(r)&&(_={},_r(r,function(v){return _[v]=1}),r=_),r=B2(s,r)),y=s.length;y--;)if(~l.indexOf(s[y])){p=h[y],r==="all"?(d[y]=r,m=p,f={}):(f=d[y]=d[y]||{},m=r);for(_ in m)x=p&&p[_],x&&((!("kill"in x.d)||x.d.kill(_)===!0)&&vc(this,x,"_pt"),delete p[_]),f!=="all"&&(f[_]=1)}return this._initted&&!this._pt&&c&&Bl(this),this},e.to=function(i,r){return new e(i,r,arguments[2])},e.from=function(i,r){return Nl(1,arguments)},e.delayedCall=function(i,r,a,s){return new e(r,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:i,onComplete:r,onReverseComplete:r,onCompleteParams:a,onReverseCompleteParams:a,callbackScope:s})},e.fromTo=function(i,r,a){return Nl(2,arguments)},e.set=function(i,r){return r.duration=0,r.repeatDelay||(r.repeat=0),new e(i,r)},e.killTweensOf=function(i,r,a){return ci.killTweensOf(i,r,a)},e}(Hl);Jr(Ai.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0}),_r("staggerTo,staggerFrom,staggerFromTo",function(n){Ai[n]=function(){var e=new sr,t=gp.call(arguments,0);return t.splice(n==="staggerFromTo"?5:4,0,0),e[n].apply(e,t)}});var Sp=function(n,e,t){return n[e]=t},W0=function(n,e,t){return n[e](t)},k2=function(n,e,t,i){return n[e](i.fp,t)},H2=function(n,e,t){return n.setAttribute(e,t)},Ep=function(n,e){return _i(n[e])?W0:ip(n[e])&&n.setAttribute?H2:Sp},j0=function(n,e){return e.set(e.t,e.p,Math.round((e.s+e.c*n)*1e6)/1e6,e)},G2=function(n,e){return e.set(e.t,e.p,!!(e.s+e.c*n),e)},X0=function(n,e){var t=e._pt,i="";if(!n&&e.b)i=e.b;else if(n===1&&e.e)i=e.e;else{for(;t;)i=t.p+(t.m?t.m(t.s+t.c*n):Math.round((t.s+t.c*n)*1e4)/1e4)+i,t=t._next;i+=e.c}e.set(e.t,e.p,i,e)},Ap=function(n,e){for(var t=e._pt;t;)t.r(n,t.d),t=t._next},V2=function(n,e,t,i){for(var r=this._pt,a;r;)a=r._next,r.p===i&&r.modifier(n,e,t),r=a},W2=function(n){for(var e=this._pt,t,i;e;)i=e._next,e.p===n&&!e.op||e.op===n?vc(this,e,"_pt"):e.dep||(t=1),e=i;return!t},j2=function(n,e,t,i){i.mSet(n,e,i.m.call(i.tween,t,i.mt),i)},q0=function(n){for(var e=n._pt,t,i,r,a;e;){for(t=e._next,i=r;i&&i.pr>e.pr;)i=i._next;(e._prev=i?i._prev:a)?e._prev._next=e:r=e,(e._next=i)?i._prev=e:a=e,e=t}n._pt=r},vr=function(){function n(t,i,r,a,s,l,h,c,d){this.t=i,this.s=a,this.c=s,this.p=r,this.r=l||j0,this.d=h||this,this.set=c||Sp,this.pr=d||0,this._next=t,t&&(t._prev=this)}var e=n.prototype;return e.modifier=function(t,i,r){this.mSet=this.mSet||this.set,this.set=j2,this.m=t,this.mt=r,this.tween=i},n}();_r(dp+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",function(n){return hp[n]=1}),Ir.TweenMax=Ir.TweenLite=Ai,Ir.TimelineLite=Ir.TimelineMax=sr,ci=new sr({sortChildren:!1,defaults:To,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0}),Dr.stringFilter=U0;var gs=[],wc={},X2=[],Y0=0,q2=0,Rp=function(n){return(wc[n]||X2).map(function(e){return e()})},Cp=function(){var n=Date.now(),e=[];n-Y0>2&&(Rp("matchMediaInit"),gs.forEach(function(t){var i=t.queries,r=t.conditions,a,s,l,h;for(s in i)a=Zr.matchMedia(i[s]).matches,a&&(l=1),a!==r[s]&&(r[s]=a,h=1);h&&(t.revert(),l&&e.push(t))}),Rp("matchMediaRevert"),e.forEach(function(t){return t.onMatch(t,function(i){return t.add(null,i)})}),Y0=n,Rp("matchMedia"))},K0=function(){function n(t,i){this.selector=i&&_p(i),this.data=[],this._r=[],this.isReverted=!1,this.id=q2++,t&&this.add(t)}var e=n.prototype;return e.add=function(t,i,r){_i(t)&&(r=i,i=t,t=_i);var a=this,s=function(){var l=gi,h=a.selector,c;return l&&l!==a&&l.data.push(a),r&&(a.selector=_p(r)),gi=a,c=i.apply(a,arguments),_i(c)&&a._r.push(c),gi=l,a.selector=h,a.isReverted=!1,c};return a.last=s,t===_i?s(a,function(l){return a.add(null,l)}):t?a[t]=s:s},e.ignore=function(t){var i=gi;gi=null,t(this),gi=i},e.getTweens=function(){var t=[];return this.data.forEach(function(i){return i instanceof n?t.push.apply(t,i.getTweens()):i instanceof Ai&&!(i.parent&&i.parent.data==="nested")&&t.push(i)}),t},e.clear=function(){this._r.length=this.data.length=0},e.kill=function(t,i){var r=this;if(t?function(){for(var s=r.getTweens(),l=r.data.length,h;l--;)h=r.data[l],h.data==="isFlip"&&(h.revert(),h.getChildren(!0,!0,!1).forEach(function(c){return s.splice(s.indexOf(c),1)}));for(s.map(function(c){return{g:c._dur||c._delay||c._sat&&!c._sat.vars.immediateRender?c.globalTime(0):-1/0,t:c}}).sort(function(c,d){return d.g-c.g||-1/0}).forEach(function(c){return c.t.revert(t)}),l=r.data.length;l--;)h=r.data[l],h instanceof sr?h.data!=="nested"&&(h.scrollTrigger&&h.scrollTrigger.revert(),h.kill()):!(h instanceof Ai)&&h.revert&&h.revert(t);r._r.forEach(function(c){return c(t,r)}),r.isReverted=!0}():this.data.forEach(function(s){return s.kill&&s.kill()}),this.clear(),i)for(var a=gs.length;a--;)gs[a].id===this.id&&gs.splice(a,1)},e.revert=function(t){this.kill(t||{})},n}(),Y2=function(){function n(t){this.contexts=[],this.scope=t}var e=n.prototype;return e.add=function(t,i,r){On(t)||(t={matches:t});var a=new K0(0,r||this.scope),s=a.conditions={},l,h,c;gi&&!a.selector&&(a.selector=gi.selector),this.contexts.push(a),i=a.add("onMatch",i),a.queries=t;for(h in t)h==="all"?c=1:(l=Zr.matchMedia(t[h]),l&&(gs.indexOf(a)<0&&gs.push(a),(s[h]=l.matches)&&(c=1),l.addListener?l.addListener(Cp):l.addEventListener("change",Cp)));return c&&i(a,function(d){return a.add(null,d)}),this},e.revert=function(t){this.kill(t||{})},e.kill=function(t){this.contexts.forEach(function(i){return i.kill(t,!0)})},n}(),Mc={registerPlugin:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];e.forEach(function(i){return D0(i)})},timeline:function(n){return new sr(n)},getTweensOf:function(n,e){return ci.getTweensOf(n,e)},getProperty:function(n,e,t,i){Hi(n)&&(n=Qr(n)[0]);var r=us(n||{}).get,a=t?m0:f0;return t==="native"&&(t=""),n&&(e?a((Or[e]&&Or[e].get||r)(n,e,t,i)):function(s,l,h){return a((Or[s]&&Or[s].get||r)(n,s,l,h))})},quickSetter:function(n,e,t){if(n=Qr(n),n.length>1){var i=n.map(function(c){return yr.quickSetter(c,e,t)}),r=i.length;return function(c){for(var d=r;d--;)i[d](c)}}n=n[0]||{};var a=Or[e],s=us(n),l=s.harness&&(s.harness.aliases||{})[e]||e,h=a?function(c){var d=new a;Co._pt=0,d.init(n,t?c+t:c,Co,0,[n]),d.render(1,d),Co._pt&&Ap(1,Co)}:s.set(n,l);return a?h:function(c){return h(n,l,t?c+t:c,s,1)}},quickTo:function(n,e,t){var i,r=yr.to(n,ds((i={},i[e]="+=0.1",i.paused=!0,i),t||{})),a=function(s,l,h){return r.resetTo(e,s,l,h)};return a.tween=r,a},isTweening:function(n){return ci.getTweensOf(n,!0).length>0},defaults:function(n){return n&&n.ease&&(n.ease=fs(n.ease,To.ease)),g0(To,n||{})},config:function(n){return g0(Dr,n||{})},registerEffect:function(n){var e=n.name,t=n.effect,i=n.plugins,r=n.defaults,a=n.extendTimeline;(i||"").split(",").forEach(function(s){return s&&!Or[s]&&!Ir[s]&&Dl(e+" effect requires "+s+" plugin.")}),up[e]=function(s,l,h){return t(Qr(s),Jr(l||{},r),h)},a&&(sr.prototype[e]=function(s,l,h){return this.add(up[e](s,On(l)?l:(h=l)&&{},this),h)})},registerEase:function(n,e){It[n]=fs(e)},parseEase:function(n,e){return arguments.length?fs(n,e):It},getById:function(n){return ci.getById(n)},exportRoot:function(n,e){n===void 0&&(n={});var t=new sr(n),i,r;for(t.smoothChildTiming=gr(n.smoothChildTiming),ci.remove(t),t._dp=0,t._time=t._tTime=ci._time,i=ci._first;i;)r=i._next,(e||!(!i._dur&&i instanceof Ai&&i.vars.onComplete===i._targets[0]))&&Nn(t,i,i._start-i._delay),i=r;return Nn(ci,t,0),t},context:function(n,e){return n?new K0(n,e):gi},matchMedia:function(n){return new Y2(n)},matchMediaRefresh:function(){return gs.forEach(function(n){var e=n.conditions,t,i;for(i in e)e[i]&&(e[i]=!1,t=1);t&&n.revert()})||Cp()},addEventListener:function(n,e){var t=wc[n]||(wc[n]=[]);~t.indexOf(e)||t.push(e)},removeEventListener:function(n,e){var t=wc[n],i=t&&t.indexOf(e);i>=0&&t.splice(i,1)},utils:{wrap:E2,wrapYoyo:A2,distribute:S0,random:A0,snap:E0,normalize:S2,getUnit:$i,clamp:b2,splitColor:I0,toArray:Qr,selector:_p,mapRange:C0,pipe:M2,unitize:T2,interpolate:R2,shuffle:T0},install:l0,effects:up,ticker:Ur,updateRoot:sr.updateRoot,plugins:Or,globalTimeline:ci,core:{PropTween:vr,globals:h0,Tween:Ai,Timeline:sr,Animation:Hl,getCache:us,_removeLinkedListItem:vc,reverting:function(){return Zi},context:function(n){return n&&gi&&(gi.data.push(n),n._ctx=gi),gi},suppressOverwrites:function(n){return ep=n}}};_r("to,from,fromTo,delayedCall,set,killTweensOf",function(n){return Mc[n]=Ai[n]}),Ur.add(sr.updateRoot),Co=Mc.to({},{duration:0});var K2=function(n,e){for(var t=n._pt;t&&t.p!==e&&t.op!==e&&t.fp!==e;)t=t._next;return t},Z2=function(n,e){var t=n._targets,i,r,a;for(i in e)for(r=t.length;r--;)a=n._ptLookup[r][i],a&&(a=a.d)&&(a._pt&&(a=K2(a,i)),a&&a.modifier&&a.modifier(e[i],n,t[r],i))},Lp=function(n,e){return{name:n,rawVars:1,init:function(t,i,r){r._onInit=function(a){var s,l;if(Hi(i)&&(s={},_r(i,function(h){return s[h]=1}),i=s),e){s={};for(l in i)s[l]=e(i[l]);i=s}Z2(a,i)}}}},yr=Mc.registerPlugin({name:"attr",init:function(n,e,t,i,r){var a,s,l;this.tween=t;for(a in e)l=n.getAttribute(a)||"",s=this.add(n,"setAttribute",(l||0)+"",e[a],i,r,0,0,a),s.op=a,s.b=l,this._props.push(a)},render:function(n,e){for(var t=e._pt;t;)Zi?t.set(t.t,t.p,t.b,t):t.r(n,t.d),t=t._next}},{name:"endArray",init:function(n,e){for(var t=e.length;t--;)this.add(n,t,n[t]||0,e[t],0,0,0,0,0,1)}},Lp("roundProps",vp),Lp("modifiers"),Lp("snap",E0))||Mc;Ai.version=sr.version=yr.version="3.12.4",o0=1,rp()&&Lo(),It.Power0,It.Power1,It.Power2,It.Power3,It.Power4,It.Linear,It.Quad,It.Cubic,It.Quart,It.Quint,It.Strong,It.Elastic,It.Back,It.SteppedEase,It.Bounce,It.Sine,It.Expo,It.Circ;var Z0,Da,Po,Pp,_s,J0,Dp,J2=function(){return typeof window<"u"},aa={},vs=180/Math.PI,Do=Math.PI/180,Io=Math.atan2,$0=1e8,Ip=/([A-Z])/g,$2=/(left|right|width|margin|padding|x)/i,Q2=/[\s,\(]\S/,Un={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},Op=function(n,e){return e.set(e.t,e.p,Math.round((e.s+e.c*n)*1e4)/1e4+e.u,e)},eR=function(n,e){return e.set(e.t,e.p,n===1?e.e:Math.round((e.s+e.c*n)*1e4)/1e4+e.u,e)},tR=function(n,e){return e.set(e.t,e.p,n?Math.round((e.s+e.c*n)*1e4)/1e4+e.u:e.b,e)},iR=function(n,e){var t=e.s+e.c*n;e.set(e.t,e.p,~~(t+(t<0?-.5:.5))+e.u,e)},Q0=function(n,e){return e.set(e.t,e.p,n?e.e:e.b,e)},ev=function(n,e){return e.set(e.t,e.p,n!==1?e.b:e.e,e)},rR=function(n,e,t){return n.style[e]=t},nR=function(n,e,t){return n.style.setProperty(e,t)},aR=function(n,e,t){return n._gsap[e]=t},sR=function(n,e,t){return n._gsap.scaleX=n._gsap.scaleY=t},oR=function(n,e,t,i,r){var a=n._gsap;a.scaleX=a.scaleY=t,a.renderTransform(r,a)},lR=function(n,e,t,i,r){var a=n._gsap;a[e]=t,a.renderTransform(r,a)},ui="transform",xr=ui+"Origin",hR=function n(e,t){var i=this,r=this.target,a=r.style,s=r._gsap;if(e in aa&&a){if(this.tfm=this.tfm||{},e!=="transform")e=Un[e]||e,~e.indexOf(",")?e.split(",").forEach(function(l){return i.tfm[l]=sa(r,l)}):this.tfm[e]=s.x?s[e]:sa(r,e),e===xr&&(this.tfm.zOrigin=s.zOrigin);else return Un.transform.split(",").forEach(function(l){return n.call(i,l,t)});if(this.props.indexOf(ui)>=0)return;s.svg&&(this.svgo=r.getAttribute("data-svg-origin"),this.props.push(xr,t,"")),e=ui}(a||t)&&this.props.push(e,t,a[e])},tv=function(n){n.translate&&(n.removeProperty("translate"),n.removeProperty("scale"),n.removeProperty("rotate"))},cR=function(){var n=this.props,e=this.target,t=e.style,i=e._gsap,r,a;for(r=0;r<n.length;r+=3)n[r+1]?e[n[r]]=n[r+2]:n[r+2]?t[n[r]]=n[r+2]:t.removeProperty(n[r].substr(0,2)==="--"?n[r]:n[r].replace(Ip,"-$1").toLowerCase());if(this.tfm){for(a in this.tfm)i[a]=this.tfm[a];i.svg&&(i.renderTransform(),e.setAttribute("data-svg-origin",this.svgo||"")),r=Dp(),(!r||!r.isStart)&&!t[ui]&&(tv(t),i.zOrigin&&t[xr]&&(t[xr]+=" "+i.zOrigin+"px",i.zOrigin=0,i.renderTransform()),i.uncache=1)}},iv=function(n,e){var t={target:n,props:[],revert:cR,save:hR};return n._gsap||yr.core.getCache(n),e&&e.split(",").forEach(function(i){return t.save(i)}),t},rv,Np=function(n,e){var t=Da.createElementNS?Da.createElementNS((e||"http://www.w3.org/1999/xhtml").replace(/^https/,"http"),n):Da.createElement(n);return t&&t.style?t:Da.createElement(n)},zn=function n(e,t,i){var r=getComputedStyle(e);return r[t]||r.getPropertyValue(t.replace(Ip,"-$1").toLowerCase())||r.getPropertyValue(t)||!i&&n(e,Oo(t)||t,1)||""},nv="O,Moz,ms,Ms,Webkit".split(","),Oo=function(n,e,t){var i=e||_s,r=i.style,a=5;if(n in r&&!t)return n;for(n=n.charAt(0).toUpperCase()+n.substr(1);a--&&!(nv[a]+n in r););return a<0?null:(a===3?"ms":a>=0?nv[a]:"")+n},Up=function(){J2()&&window.document&&(Z0=window,Da=Z0.document,Po=Da.documentElement,_s=Np("div")||{style:{}},Np("div"),ui=Oo(ui),xr=ui+"Origin",_s.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",rv=!!Oo("perspective"),Dp=yr.core.reverting,Pp=1)},zp=function n(e){var t=Np("svg",this.ownerSVGElement&&this.ownerSVGElement.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),i=this.parentNode,r=this.nextSibling,a=this.style.cssText,s;if(Po.appendChild(t),t.appendChild(this),this.style.display="block",e)try{s=this.getBBox(),this._gsapBBox=this.getBBox,this.getBBox=n}catch{}else this._gsapBBox&&(s=this._gsapBBox());return i&&(r?i.insertBefore(this,r):i.appendChild(this)),Po.removeChild(t),this.style.cssText=a,s},av=function(n,e){for(var t=e.length;t--;)if(n.hasAttribute(e[t]))return n.getAttribute(e[t])},sv=function(n){var e;try{e=n.getBBox()}catch{e=zp.call(n,!0)}return e&&(e.width||e.height)||n.getBBox===zp||(e=zp.call(n,!0)),e&&!e.width&&!e.x&&!e.y?{x:+av(n,["x","cx","x1"])||0,y:+av(n,["y","cy","y1"])||0,width:0,height:0}:e},ov=function(n){return!!(n.getCTM&&(!n.parentNode||n.ownerSVGElement)&&sv(n))},ys=function(n,e){if(e){var t=n.style,i;e in aa&&e!==xr&&(e=ui),t.removeProperty?(i=e.substr(0,2),(i==="ms"||e.substr(0,6)==="webkit")&&(e="-"+e),t.removeProperty(i==="--"?e:e.replace(Ip,"-$1").toLowerCase())):t.removeAttribute(e)}},Ia=function(n,e,t,i,r,a){var s=new vr(n._pt,e,t,0,1,a?ev:Q0);return n._pt=s,s.b=i,s.e=r,n._props.push(t),s},lv={deg:1,rad:1,turn:1},uR={grid:1,flex:1},Oa=function n(e,t,i,r){var a=parseFloat(i)||0,s=(i+"").trim().substr((a+"").length)||"px",l=_s.style,h=$2.test(t),c=e.tagName.toLowerCase()==="svg",d=(c?"client":"offset")+(h?"Width":"Height"),p=100,f=r==="px",m=r==="%",_,x,y,v;if(r===s||!a||lv[r]||lv[s])return a;if(s!=="px"&&!f&&(a=n(e,t,i,"px")),v=e.getCTM&&ov(e),(m||s==="%")&&(aa[t]||~t.indexOf("adius")))return _=v?e.getBBox()[h?"width":"height"]:e[d],Mi(m?a/_*p:a/100*_);if(l[h?"width":"height"]=p+(f?s:r),x=~t.indexOf("adius")||r==="em"&&e.appendChild&&!c?e:e.parentNode,v&&(x=(e.ownerSVGElement||{}).parentNode),(!x||x===Da||!x.appendChild)&&(x=Da.body),y=x._gsap,y&&m&&y.width&&h&&y.time===Ur.time&&!y.uncache)return Mi(a/y.width*p);if(m&&(t==="height"||t==="width")){var M=e.style[t];e.style[t]=p+r,_=e[d],M?e.style[t]=M:ys(e,t)}else(m||s==="%")&&!uR[zn(x,"display")]&&(l.position=zn(e,"position")),x===e&&(l.position="static"),x.appendChild(_s),_=_s[d],x.removeChild(_s),l.position="absolute";return h&&m&&(y=us(x),y.time=Ur.time,y.width=x[d]),Mi(f?_*a/p:_&&a?p/_*a:0)},sa=function(n,e,t,i){var r;return Pp||Up(),e in Un&&e!=="transform"&&(e=Un[e],~e.indexOf(",")&&(e=e.split(",")[0])),aa[e]&&e!=="transform"?(r=Wl(n,i),r=e!=="transformOrigin"?r[e]:r.svg?r.origin:Sc(zn(n,xr))+" "+r.zOrigin+"px"):(r=n.style[e],(!r||r==="auto"||i||~(r+"").indexOf("calc("))&&(r=Tc[e]&&Tc[e](n,e,t)||zn(n,e)||d0(n,e)||(e==="opacity"?1:0))),t&&!~(r+"").trim().indexOf(" ")?Oa(n,e,r,t)+t:r},dR=function(n,e,t,i){if(!t||t==="none"){var r=Oo(e,n,1),a=r&&zn(n,r,1);a&&a!==t?(e=r,t=a):e==="borderColor"&&(t=zn(n,"borderTopColor"))}var s=new vr(this._pt,n.style,e,0,1,X0),l=0,h=0,c,d,p,f,m,_,x,y,v,M,b,S;if(s.b=t,s.e=i,t+="",i+="",i==="auto"&&(_=n.style[e],n.style[e]=i,i=zn(n,e)||i,_?n.style[e]=_:ys(n,e)),c=[t,i],U0(c),t=c[0],i=c[1],p=t.match(So)||[],S=i.match(So)||[],S.length){for(;d=So.exec(i);)x=d[0],v=i.substring(l,d.index),m?m=(m+1)%5:(v.substr(-5)==="rgba("||v.substr(-5)==="hsla(")&&(m=1),x!==(_=p[h++]||"")&&(f=parseFloat(_)||0,b=_.substr((f+"").length),x.charAt(1)==="="&&(x=Eo(f,x)+b),y=parseFloat(x),M=x.substr((y+"").length),l=So.lastIndex-M.length,M||(M=M||Dr.units[e]||b,l===i.length&&(i+=M,s.e+=M)),b!==M&&(f=Oa(n,e,_,M)||0),s._pt={_next:s._pt,p:v||h===1?v:",",s:f,c:y-f,m:m&&m<4||e==="zIndex"?Math.round:0});s.c=l<i.length?i.substring(l,i.length):""}else s.r=e==="display"&&i==="none"?ev:Q0;return a0.test(i)&&(s.e=0),this._pt=s,s},hv={top:"0%",bottom:"100%",left:"0%",right:"100%",center:"50%"},pR=function(n){var e=n.split(" "),t=e[0],i=e[1]||"50%";return(t==="top"||t==="bottom"||i==="left"||i==="right")&&(n=t,t=i,i=n),e[0]=hv[t]||t,e[1]=hv[i]||i,e.join(" ")},fR=function(n,e){if(e.tween&&e.tween._time===e.tween._dur){var t=e.t,i=t.style,r=e.u,a=t._gsap,s,l,h;if(r==="all"||r===!0)i.cssText="",l=1;else for(r=r.split(","),h=r.length;--h>-1;)s=r[h],aa[s]&&(l=1,s=s==="transformOrigin"?xr:ui),ys(t,s);l&&(ys(t,ui),a&&(a.svg&&t.removeAttribute("transform"),Wl(t,1),a.uncache=1,tv(i)))}},Tc={clearProps:function(n,e,t,i,r){if(r.data!=="isFromStart"){var a=n._pt=new vr(n._pt,e,t,0,0,fR);return a.u=i,a.pr=-10,a.tween=r,n._props.push(t),1}}},Vl=[1,0,0,1,0,0],cv={},uv=function(n){return n==="matrix(1, 0, 0, 1, 0, 0)"||n==="none"||!n},dv=function(n){var e=zn(n,ui);return uv(e)?Vl:e.substr(7).match(n0).map(Mi)},Bp=function(n,e){var t=n._gsap||us(n),i=n.style,r=dv(n),a,s,l,h;return t.svg&&n.getAttribute("transform")?(l=n.transform.baseVal.consolidate().matrix,r=[l.a,l.b,l.c,l.d,l.e,l.f],r.join(",")==="1,0,0,1,0,0"?Vl:r):(r===Vl&&!n.offsetParent&&n!==Po&&!t.svg&&(l=i.display,i.display="block",a=n.parentNode,(!a||!n.offsetParent)&&(h=1,s=n.nextElementSibling,Po.appendChild(n)),r=dv(n),l?i.display=l:ys(n,"display"),h&&(s?a.insertBefore(n,s):a?a.appendChild(n):Po.removeChild(n))),e&&r.length>6?[r[0],r[1],r[4],r[5],r[12],r[13]]:r)},Fp=function(n,e,t,i,r,a){var s=n._gsap,l=r||Bp(n,!0),h=s.xOrigin||0,c=s.yOrigin||0,d=s.xOffset||0,p=s.yOffset||0,f=l[0],m=l[1],_=l[2],x=l[3],y=l[4],v=l[5],M=e.split(" "),b=parseFloat(M[0])||0,S=parseFloat(M[1])||0,A,T,E,I;t?l!==Vl&&(T=f*x-m*_)&&(E=b*(x/T)+S*(-_/T)+(_*v-x*y)/T,I=b*(-m/T)+S*(f/T)-(f*v-m*y)/T,b=E,S=I):(A=sv(n),b=A.x+(~M[0].indexOf("%")?b/100*A.width:b),S=A.y+(~(M[1]||M[0]).indexOf("%")?S/100*A.height:S)),i||i!==!1&&s.smooth?(y=b-h,v=S-c,s.xOffset=d+(y*f+v*_)-y,s.yOffset=p+(y*m+v*x)-v):s.xOffset=s.yOffset=0,s.xOrigin=b,s.yOrigin=S,s.smooth=!!i,s.origin=e,s.originIsAbsolute=!!t,n.style[xr]="0px 0px",a&&(Ia(a,s,"xOrigin",h,b),Ia(a,s,"yOrigin",c,S),Ia(a,s,"xOffset",d,s.xOffset),Ia(a,s,"yOffset",p,s.yOffset)),n.setAttribute("data-svg-origin",b+" "+S)},Wl=function(n,e){var t=n._gsap||new k0(n);if("x"in t&&!e&&!t.uncache)return t;var i=n.style,r=t.scaleX<0,a="px",s="deg",l=getComputedStyle(n),h=zn(n,xr)||"0",c,d,p,f,m,_,x,y,v,M,b,S,A,T,E,I,C,P,X,q,te,k,H,V,J,ie,$,ne,he,De,ee,ce;return c=d=p=_=x=y=v=M=b=0,f=m=1,t.svg=!!(n.getCTM&&ov(n)),l.translate&&((l.translate!=="none"||l.scale!=="none"||l.rotate!=="none")&&(i[ui]=(l.translate!=="none"?"translate3d("+(l.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(l.rotate!=="none"?"rotate("+l.rotate+") ":"")+(l.scale!=="none"?"scale("+l.scale.split(" ").join(",")+") ":"")+(l[ui]!=="none"?l[ui]:"")),i.scale=i.rotate=i.translate="none"),T=Bp(n,t.svg),t.svg&&(t.uncache?(J=n.getBBox(),h=t.xOrigin-J.x+"px "+(t.yOrigin-J.y)+"px",V=""):V=!e&&n.getAttribute("data-svg-origin"),Fp(n,V||h,!!V||t.originIsAbsolute,t.smooth!==!1,T)),S=t.xOrigin||0,A=t.yOrigin||0,T!==Vl&&(P=T[0],X=T[1],q=T[2],te=T[3],c=k=T[4],d=H=T[5],T.length===6?(f=Math.sqrt(P*P+X*X),m=Math.sqrt(te*te+q*q),_=P||X?Io(X,P)*vs:0,v=q||te?Io(q,te)*vs+_:0,v&&(m*=Math.abs(Math.cos(v*Do))),t.svg&&(c-=S-(S*P+A*q),d-=A-(S*X+A*te))):(ce=T[6],De=T[7],$=T[8],ne=T[9],he=T[10],ee=T[11],c=T[12],d=T[13],p=T[14],E=Io(ce,he),x=E*vs,E&&(I=Math.cos(-E),C=Math.sin(-E),V=k*I+$*C,J=H*I+ne*C,ie=ce*I+he*C,$=k*-C+$*I,ne=H*-C+ne*I,he=ce*-C+he*I,ee=De*-C+ee*I,k=V,H=J,ce=ie),E=Io(-q,he),y=E*vs,E&&(I=Math.cos(-E),C=Math.sin(-E),V=P*I-$*C,J=X*I-ne*C,ie=q*I-he*C,ee=te*C+ee*I,P=V,X=J,q=ie),E=Io(X,P),_=E*vs,E&&(I=Math.cos(E),C=Math.sin(E),V=P*I+X*C,J=k*I+H*C,X=X*I-P*C,H=H*I-k*C,P=V,k=J),x&&Math.abs(x)+Math.abs(_)>359.9&&(x=_=0,y=180-y),f=Mi(Math.sqrt(P*P+X*X+q*q)),m=Mi(Math.sqrt(H*H+ce*ce)),E=Io(k,H),v=Math.abs(E)>2e-4?E*vs:0,b=ee?1/(ee<0?-ee:ee):0),t.svg&&(V=n.getAttribute("transform"),t.forceCSS=n.setAttribute("transform","")||!uv(zn(n,ui)),V&&n.setAttribute("transform",V))),Math.abs(v)>90&&Math.abs(v)<270&&(r?(f*=-1,v+=_<=0?180:-180,_+=_<=0?180:-180):(m*=-1,v+=v<=0?180:-180)),e=e||t.uncache,t.x=c-((t.xPercent=c&&(!e&&t.xPercent||(Math.round(n.offsetWidth/2)===Math.round(-c)?-50:0)))?n.offsetWidth*t.xPercent/100:0)+a,t.y=d-((t.yPercent=d&&(!e&&t.yPercent||(Math.round(n.offsetHeight/2)===Math.round(-d)?-50:0)))?n.offsetHeight*t.yPercent/100:0)+a,t.z=p+a,t.scaleX=Mi(f),t.scaleY=Mi(m),t.rotation=Mi(_)+s,t.rotationX=Mi(x)+s,t.rotationY=Mi(y)+s,t.skewX=v+s,t.skewY=M+s,t.transformPerspective=b+a,(t.zOrigin=parseFloat(h.split(" ")[2])||!e&&t.zOrigin||0)&&(i[xr]=Sc(h)),t.xOffset=t.yOffset=0,t.force3D=Dr.force3D,t.renderTransform=t.svg?gR:rv?pv:mR,t.uncache=0,t},Sc=function(n){return(n=n.split(" "))[0]+" "+n[1]},kp=function(n,e,t){var i=$i(e);return Mi(parseFloat(e)+parseFloat(Oa(n,"x",t+"px",i)))+i},mR=function(n,e){e.z="0px",e.rotationY=e.rotationX="0deg",e.force3D=0,pv(n,e)},xs="0deg",jl="0px",bs=") ",pv=function(n,e){var t=e||this,i=t.xPercent,r=t.yPercent,a=t.x,s=t.y,l=t.z,h=t.rotation,c=t.rotationY,d=t.rotationX,p=t.skewX,f=t.skewY,m=t.scaleX,_=t.scaleY,x=t.transformPerspective,y=t.force3D,v=t.target,M=t.zOrigin,b="",S=y==="auto"&&n&&n!==1||y===!0;if(M&&(d!==xs||c!==xs)){var A=parseFloat(c)*Do,T=Math.sin(A),E=Math.cos(A),I;A=parseFloat(d)*Do,I=Math.cos(A),a=kp(v,a,T*I*-M),s=kp(v,s,-Math.sin(A)*-M),l=kp(v,l,E*I*-M+M)}x!==jl&&(b+="perspective("+x+bs),(i||r)&&(b+="translate("+i+"%, "+r+"%) "),(S||a!==jl||s!==jl||l!==jl)&&(b+=l!==jl||S?"translate3d("+a+", "+s+", "+l+") ":"translate("+a+", "+s+bs),h!==xs&&(b+="rotate("+h+bs),c!==xs&&(b+="rotateY("+c+bs),d!==xs&&(b+="rotateX("+d+bs),(p!==xs||f!==xs)&&(b+="skew("+p+", "+f+bs),(m!==1||_!==1)&&(b+="scale("+m+", "+_+bs),v.style[ui]=b||"translate(0, 0)"},gR=function(n,e){var t=e||this,i=t.xPercent,r=t.yPercent,a=t.x,s=t.y,l=t.rotation,h=t.skewX,c=t.skewY,d=t.scaleX,p=t.scaleY,f=t.target,m=t.xOrigin,_=t.yOrigin,x=t.xOffset,y=t.yOffset,v=t.forceCSS,M=parseFloat(a),b=parseFloat(s),S,A,T,E,I;l=parseFloat(l),h=parseFloat(h),c=parseFloat(c),c&&(c=parseFloat(c),h+=c,l+=c),l||h?(l*=Do,h*=Do,S=Math.cos(l)*d,A=Math.sin(l)*d,T=Math.sin(l-h)*-p,E=Math.cos(l-h)*p,h&&(c*=Do,I=Math.tan(h-c),I=Math.sqrt(1+I*I),T*=I,E*=I,c&&(I=Math.tan(c),I=Math.sqrt(1+I*I),S*=I,A*=I)),S=Mi(S),A=Mi(A),T=Mi(T),E=Mi(E)):(S=d,E=p,A=T=0),(M&&!~(a+"").indexOf("px")||b&&!~(s+"").indexOf("px"))&&(M=Oa(f,"x",a,"px"),b=Oa(f,"y",s,"px")),(m||_||x||y)&&(M=Mi(M+m-(m*S+_*T)+x),b=Mi(b+_-(m*A+_*E)+y)),(i||r)&&(I=f.getBBox(),M=Mi(M+i/100*I.width),b=Mi(b+r/100*I.height)),I="matrix("+S+","+A+","+T+","+E+","+M+","+b+")",f.setAttribute("transform",I),v&&(f.style[ui]=I)},_R=function(n,e,t,i,r){var a=360,s=Hi(r),l=parseFloat(r)*(s&&~r.indexOf("rad")?vs:1),h=l-i,c=i+h+"deg",d,p;return s&&(d=r.split("_")[1],d==="short"&&(h%=a,h!==h%(a/2)&&(h+=h<0?a:-a)),d==="cw"&&h<0?h=(h+a*$0)%a-~~(h/a)*a:d==="ccw"&&h>0&&(h=(h-a*$0)%a-~~(h/a)*a)),n._pt=p=new vr(n._pt,e,t,i,h,eR),p.e=c,p.u="deg",n._props.push(t),p},fv=function(n,e){for(var t in e)n[t]=e[t];return n},vR=function(n,e,t){var i=fv({},t._gsap),r="perspective,force3D,transformOrigin,svgOrigin",a=t.style,s,l,h,c,d,p,f,m;i.svg?(h=t.getAttribute("transform"),t.setAttribute("transform",""),a[ui]=e,s=Wl(t,1),ys(t,ui),t.setAttribute("transform",h)):(h=getComputedStyle(t)[ui],a[ui]=e,s=Wl(t,1),a[ui]=h);for(l in aa)h=i[l],c=s[l],h!==c&&r.indexOf(l)<0&&(f=$i(h),m=$i(c),d=f!==m?Oa(t,l,h,m):parseFloat(h),p=parseFloat(c),n._pt=new vr(n._pt,s,l,d,p-d,Op),n._pt.u=m||0,n._props.push(l));fv(s,i)};_r("padding,margin,Width,Radius",function(n,e){var t="Top",i="Right",r="Bottom",a="Left",s=(e<3?[t,i,r,a]:[t+a,t+i,r+i,r+a]).map(function(l){return e<2?n+l:"border"+l+n});Tc[e>1?"border"+n:n]=function(l,h,c,d,p){var f,m;if(arguments.length<4)return f=s.map(function(_){return sa(l,_,c)}),m=f.join(" "),m.split(f[0]).length===5?f[0]:m;f=(d+"").split(" "),m={},s.forEach(function(_,x){return m[_]=f[x]=f[x]||f[(x-1)/2|0]}),l.init(h,m,p)}});var mv={name:"css",register:Up,targetTest:function(n){return n.style&&n.nodeType},init:function(n,e,t,i,r){var a=this._props,s=n.style,l=t.vars.startAt,h,c,d,p,f,m,_,x,y,v,M,b,S,A,T,E;Pp||Up(),this.styles=this.styles||iv(n),E=this.styles.props,this.tween=t;for(_ in e)if(_!=="autoRound"&&(c=e[_],!(Or[_]&&H0(_,e,t,i,n,r)))){if(f=typeof c,m=Tc[_],f==="function"&&(c=c.call(t,i,n,r),f=typeof c),f==="string"&&~c.indexOf("random(")&&(c=zl(c)),m)m(this,n,_,c,t)&&(T=1);else if(_.substr(0,2)==="--")h=(getComputedStyle(n).getPropertyValue(_)+"").trim(),c+="",La.lastIndex=0,La.test(h)||(x=$i(h),y=$i(c)),y?x!==y&&(h=Oa(n,_,h,y)+y):x&&(c+=x),this.add(s,"setProperty",h,c,i,r,0,0,_),a.push(_),E.push(_,0,s[_]);else if(f!=="undefined"){if(l&&_ in l?(h=typeof l[_]=="function"?l[_].call(t,i,n,r):l[_],Hi(h)&&~h.indexOf("random(")&&(h=zl(h)),$i(h+"")||h==="auto"||(h+=Dr.units[_]||$i(sa(n,_))||""),(h+"").charAt(1)==="="&&(h=sa(n,_))):h=sa(n,_),p=parseFloat(h),v=f==="string"&&c.charAt(1)==="="&&c.substr(0,2),v&&(c=c.substr(2)),d=parseFloat(c),_ in Un&&(_==="autoAlpha"&&(p===1&&sa(n,"visibility")==="hidden"&&d&&(p=0),E.push("visibility",0,s.visibility),Ia(this,s,"visibility",p?"inherit":"hidden",d?"inherit":"hidden",!d)),_!=="scale"&&_!=="transform"&&(_=Un[_],~_.indexOf(",")&&(_=_.split(",")[0]))),M=_ in aa,M){if(this.styles.save(_),b||(S=n._gsap,S.renderTransform&&!e.parseTransform||Wl(n,e.parseTransform),A=e.smoothOrigin!==!1&&S.smooth,b=this._pt=new vr(this._pt,s,ui,0,1,S.renderTransform,S,0,-1),b.dep=1),_==="scale")this._pt=new vr(this._pt,S,"scaleY",S.scaleY,(v?Eo(S.scaleY,v+d):d)-S.scaleY||0,Op),this._pt.u=0,a.push("scaleY",_),_+="X";else if(_==="transformOrigin"){E.push(xr,0,s[xr]),c=pR(c),S.svg?Fp(n,c,0,A,0,this):(y=parseFloat(c.split(" ")[2])||0,y!==S.zOrigin&&Ia(this,S,"zOrigin",S.zOrigin,y),Ia(this,s,_,Sc(h),Sc(c)));continue}else if(_==="svgOrigin"){Fp(n,c,1,A,0,this);continue}else if(_ in cv){_R(this,S,_,p,v?Eo(p,v+c):c);continue}else if(_==="smoothOrigin"){Ia(this,S,"smooth",S.smooth,c);continue}else if(_==="force3D"){S[_]=c;continue}else if(_==="transform"){vR(this,c,n);continue}}else _ in s||(_=Oo(_)||_);if(M||(d||d===0)&&(p||p===0)&&!Q2.test(c)&&_ in s)x=(h+"").substr((p+"").length),d||(d=0),y=$i(c)||(_ in Dr.units?Dr.units[_]:x),x!==y&&(p=Oa(n,_,h,y)),this._pt=new vr(this._pt,M?S:s,_,p,(v?Eo(p,v+d):d)-p,!M&&(y==="px"||_==="zIndex")&&e.autoRound!==!1?iR:Op),this._pt.u=y||0,x!==y&&y!=="%"&&(this._pt.b=h,this._pt.r=tR);else if(_ in s)dR.call(this,n,_,h,v?v+c:c);else if(_ in n)this.add(n,_,h||n[_],v?v+c:c,i,r);else if(_!=="parseTransform"){lp(_,c);continue}M||(_ in s?E.push(_,0,s[_]):E.push(_,1,h||n[_])),a.push(_)}}T&&q0(this)},render:function(n,e){if(e.tween._time||!Dp())for(var t=e._pt;t;)t.r(n,t.d),t=t._next;else e.styles.revert()},get:sa,aliases:Un,getSetter:function(n,e,t){var i=Un[e];return i&&i.indexOf(",")<0&&(e=i),e in aa&&e!==xr&&(n._gsap.x||sa(n,"x"))?t&&J0===t?e==="scale"?sR:aR:(J0=t||{})&&(e==="scale"?oR:lR):n.style&&!ip(n.style[e])?rR:~e.indexOf("-")?nR:Ep(n,e)},core:{_removeProperty:ys,_getMatrix:Bp}};yr.utils.checkPrefix=Oo,yr.core.getStyleSaver=iv,function(n,e,t,i){var r=_r(n+","+e+","+t,function(a){aa[a]=1});_r(e,function(a){Dr.units[a]="deg",cv[a]=1}),Un[r[13]]=n+","+e,_r(i,function(a){var s=a.split(":");Un[s[1]]=r[s[0]]})}("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY"),_r("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(n){Dr.units[n]="px"}),yr.registerPlugin(mv);var Xl=yr.registerPlugin(mv)||yr;Xl.core.Tween;let en=!1;class yR{constructor(e){this.sketch=e,this.addEvents(e),this.addGsapEvent(e)}gsapRotateCameraAroundY(e,t,i,r=Qd){if(!en&&e){let a=e.camera;t||(t=a.rotation),en=!0,Xl.to(t,{y:i,duration:r,onUpdate:()=>{a.position.x=cs.x*Math.sin(t.y),a.position.z=cs.z*Math.cos(t.y),a.position.y=e0,e.requestRenderIfNotRequested()},onComplete:()=>{en=!1}})}}addGsapEvent(e){r(e,cs,3);let t={y:Math.PI/2};function i(v,M="OUT",b=Qd,S=30,A=1){if(!en&&v){en=!0;let T=0,E=v.camera;M=="IN"&&(A=-1),Xl.to(E,{duration:b,onUpdate:()=>{T+=1,T<S&&(E.translateZ(A),v.requestRenderIfNotRequested())},onComplete:()=>{en=!1}})}}function r(v,M,b){en||v&&(en=!0,Xl.to(v.camera.position,{x:M.x,y:M.y,z:M.z,duration:b,onUpdate:()=>{v.requestRenderIfNotRequested()},onComplete:()=>{v.camera.lookAt(v.camera.position),t.y=Math.PI/2,en=!1}}))}function a(v,M,b,S=Qd){if(!en&&v){let A=v.camera;en=!0,Xl.to(M,{y:b,duration:S,onUpdate:()=>{A.position.x=cs.x*Math.sin(M.y),A.position.z=cs.z*Math.cos(M.y),A.position.y=e0,v.requestRenderIfNotRequested()},onComplete:()=>{en=!1}})}}function s(v){let M=v.data.selected.side;if(M){const b=v.object.getObjectByName(M+"_side");if(b){const S=b.userData.data.doorData.doorList;let A=S.reduce((E,I)=>E+I.size.width,0);const T=b.userData.data.wallData.dimensions.width-v.data.trim.width*2;if(S.length>0&&A<T){let E=(T-A)/(S.length+1);if(E>0){S.sort((C,P)=>C.position.x-P.position.x);let I=-T/2;S.forEach(C=>{let P=C.size.width/2;I=I+P+E,C.position.x=I,I=I+P}),v.changeData(v.data)}}}}}function l(v,M){switch(v){case"zoomIn":i(e,"IN",M);break;case"home":r(e,cs,M);break;case"zoomOut":i(e,"OUT",M);break;case"left":h(v);break;case"right":h(v);break}}function h(v){let M=0;v=="left"?M=t.y-zt[90]:M=t.y+zt[90],a(e,t,M)}const c=document.getElementById("zoom_in");c&&c.addEventListener("click",()=>{l("zoomIn",.5)});const d=document.getElementById("zoom_out");d&&d.addEventListener("click",()=>{l("zoomOut",.5)});const p=document.getElementById("rotate_home");p&&p.addEventListener("click",()=>{l("home",2)});const f=document.getElementById("rotate_left");f&&f.addEventListener("click",()=>{l("left",1)});const m=document.getElementById("rotate_right");m&&m.addEventListener("click",()=>{l("right",1)}),e.history[0];const _=document.getElementById("reset");_&&_.addEventListener("click",Vt.debounce(()=>{r(e,cs,3)},300));const x=document.getElementById("undo");x&&x.addEventListener("click",Vt.debounce(async()=>{if(e.history.length>1){e.history.pop();const v=e.history[e.history.length-1];e.data=v,window.renderModelElementOnPanel&&(console.debug("[EXPORT][undo]",nt.exportUiJson(e.data)),window.renderModelElementOnPanel(nt.exportUiJson(e.data)))}}),500);const y=document.getElementById("center");y&&y.addEventListener("click",Vt.debounce(async()=>{s(e)}),500)}addEvents(e){window.addEventListener("resize",this.onWindowResize.bind(this),!1);function t(){e&&globalThis.selectedObject&&e.duplicateObject(globalThis.selectedObject),contextMenu.style.display="none"}function i(){e&&globalThis.selectedObject&&(globalThis.selectedObject.type==="leanTos"?e.deleteObject(globalThis.selectedObject.side):e.deleteObject(globalThis.selectedObject.id)),contextMenu.style.display="none"}function r(){e&&globalThis.selectedObject&&e.toggleWeathervane(globalThis.selectedObject.id),contextMenu.style.display="none"}function a(x){e&&globalThis.selectedObject&&e.changeLeanToWidth(globalThis.selectedObject.side,x),contextMenu.style.display="none"}function s(x){e&&globalThis.selectedObject&&e.changeLeanToOpenType(globalThis.selectedObject.side,x),contextMenu.style.display="none"}function l(x,y){console.log(x,y),e&&globalThis.selectedObject&&e.changeWrapAround(globalThis.selectedObject.side,x,y),contextMenu.style.display="none"}const h=document.getElementById("duplicate_object");h&&h.addEventListener("click",()=>{t()});const c=document.getElementById("delete_object");c&&c.addEventListener("click",()=>{i()});const d=document.getElementById("weathervane");d&&d.addEventListener("click",()=>{r()});const p=document.getElementById("lean_to_width");p&&p.addEventListener("change",()=>{a(p.value)});const f=document.getElementById("lean_to_open_type");f&&f.addEventListener("change",()=>{s(f.value)});const m=document.getElementById("lean_to_wrap_left");m&&m.addEventListener("change",()=>{l("left",m.checked)});const _=document.getElementById("lean_to_wrap_right");_&&_.addEventListener("change",()=>{l("right",_.checked)})}onWindowResize(){var e=document.getElementById(this.sketch.config.containerId);this.sketch.renderer.setSize(e.clientWidth,e.clientHeight,!0),this.sketch.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),this.sketch.camera.aspect=e.clientWidth/e.clientHeight,this.sketch.camera.updateProjectionMatrix(),this.sketch.CSS2DRenderer.setSize(e.clientWidth,e.clientHeight)}}const gv={type:"change"},Hp={type:"start"},_v={type:"end"},Ec=new is,vv=new ea,xR=Math.cos(70*dl.DEG2RAD);class bR extends Yn{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new z,this.cursor=new z,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:ur.ROTATE,MIDDLE:ur.DOLLY,RIGHT:ur.PAN},this.touches={ONE:Vr.ROTATE,TWO:Vr.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 l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(B){B.addEventListener("keydown",Se),this._domElementKeyEvents=B},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Se),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(gv),i.update(),a=r.NONE},this.update=function(){const B=new z,_e=new Rn().setFromUnitVectors(e.up,new z(0,1,0)),Ce=_e.clone().invert(),Re=new z,Ve=new Rn,tt=new z,Tt=2*Math.PI;return function(ut=null){const Le=i.object.position;B.copy(Le).sub(i.target),B.applyQuaternion(_e),l.setFromVector3(B),i.autoRotate&&a===r.NONE&&X(C(ut)),i.enableDamping?(l.theta+=h.theta*i.dampingFactor,l.phi+=h.phi*i.dampingFactor):(l.theta+=h.theta,l.phi+=h.phi);let W=i.minAzimuthAngle,we=i.maxAzimuthAngle;isFinite(W)&&isFinite(we)&&(W<-Math.PI?W+=Tt:W>Math.PI&&(W-=Tt),we<-Math.PI?we+=Tt:we>Math.PI&&(we-=Tt),W<=we?l.theta=Math.max(W,Math.min(we,l.theta)):l.theta=l.theta>(W+we)/2?Math.max(W,l.theta):Math.min(we,l.theta)),l.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,l.phi)),l.makeSafe(),i.enableDamping===!0?i.target.addScaledVector(d,i.dampingFactor):i.target.add(d),i.target.sub(i.cursor),i.target.clampLength(i.minTargetRadius,i.maxTargetRadius),i.target.add(i.cursor),i.zoomToCursor&&T||i.object.isOrthographicCamera?l.radius=$(l.radius):l.radius=$(l.radius*c),B.setFromSpherical(l),B.applyQuaternion(Ce),Le.copy(i.target).add(B),i.object.lookAt(i.target),i.enableDamping===!0?(h.theta*=1-i.dampingFactor,h.phi*=1-i.dampingFactor,d.multiplyScalar(1-i.dampingFactor)):(h.set(0,0,0),d.set(0,0,0));let Pe=!1;if(i.zoomToCursor&&T){let et=null;if(i.object.isPerspectiveCamera){const ye=B.length();et=$(ye*c);const it=ye-et;i.object.position.addScaledVector(S,it),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){const ye=new z(A.x,A.y,0);ye.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),Pe=!0;const it=new z(A.x,A.y,0);it.unproject(i.object),i.object.position.sub(it).add(ye),i.object.updateMatrixWorld(),et=B.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;et!==null&&(this.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(et).add(i.object.position):(Ec.origin.copy(i.object.position),Ec.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(Ec.direction))<xR?e.lookAt(i.target):(vv.setFromNormalAndCoplanarPoint(i.object.up,i.target),Ec.intersectPlane(vv,i.target))))}else i.object.isOrthographicCamera&&(i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),Pe=!0);return c=1,T=!1,Pe||Re.distanceToSquared(i.object.position)>s||8*(1-Ve.dot(i.object.quaternion))>s||tt.distanceToSquared(i.target)>0?(i.dispatchEvent(gv),Re.copy(i.object.position),Ve.copy(i.object.quaternion),tt.copy(i.target),!0):!1}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",Ue),i.domElement.removeEventListener("pointerdown",ke),i.domElement.removeEventListener("pointercancel",L),i.domElement.removeEventListener("wheel",fe),i.domElement.removeEventListener("pointermove",N),i.domElement.removeEventListener("pointerup",L),i._domElementKeyEvents!==null&&(i._domElementKeyEvents.removeEventListener("keydown",Se),i._domElementKeyEvents=null)};const i=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=r.NONE;const s=1e-6,l=new J_,h=new J_;let c=1;const d=new z,p=new pe,f=new pe,m=new pe,_=new pe,x=new pe,y=new pe,v=new pe,M=new pe,b=new pe,S=new z,A=new pe;let T=!1;const E=[],I={};function C(B){return B!==null?2*Math.PI/60*i.autoRotateSpeed*B:2*Math.PI/60/60*i.autoRotateSpeed}function P(B){const _e=Math.abs(B)/(100*(window.devicePixelRatio|0));return Math.pow(.95,i.zoomSpeed*_e)}function X(B){h.theta-=B}function q(B){h.phi-=B}const te=function(){const B=new z;return function(_e,Ce){B.setFromMatrixColumn(Ce,0),B.multiplyScalar(-_e),d.add(B)}}(),k=function(){const B=new z;return function(_e,Ce){i.screenSpacePanning===!0?B.setFromMatrixColumn(Ce,1):(B.setFromMatrixColumn(Ce,0),B.crossVectors(i.object.up,B)),B.multiplyScalar(_e),d.add(B)}}(),H=function(){const B=new z;return function(_e,Ce){const Re=i.domElement;if(i.object.isPerspectiveCamera){const Ve=i.object.position;B.copy(Ve).sub(i.target);let tt=B.length();tt*=Math.tan(i.object.fov/2*Math.PI/180),te(2*_e*tt/Re.clientHeight,i.object.matrix),k(2*Ce*tt/Re.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(te(_e*(i.object.right-i.object.left)/i.object.zoom/Re.clientWidth,i.object.matrix),k(Ce*(i.object.top-i.object.bottom)/i.object.zoom/Re.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function V(B){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c/=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function J(B){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c*=B:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function ie(B,_e){if(!i.zoomToCursor)return;T=!0;const Ce=i.domElement.getBoundingClientRect(),Re=B-Ce.left,Ve=_e-Ce.top,tt=Ce.width,Tt=Ce.height;A.x=Re/tt*2-1,A.y=-(Ve/Tt)*2+1,S.set(A.x,A.y,1).unproject(i.object).sub(i.object.position).normalize()}function $(B){return Math.max(i.minDistance,Math.min(i.maxDistance,B))}function ne(B){p.set(B.clientX,B.clientY)}function he(B){ie(B.clientX,B.clientX),v.set(B.clientX,B.clientY)}function De(B){_.set(B.clientX,B.clientY)}function ee(B){f.set(B.clientX,B.clientY),m.subVectors(f,p).multiplyScalar(i.rotateSpeed);const _e=i.domElement;X(2*Math.PI*m.x/_e.clientHeight),q(2*Math.PI*m.y/_e.clientHeight),p.copy(f),i.update()}function ce(B){M.set(B.clientX,B.clientY),b.subVectors(M,v),b.y>0?V(P(b.y)):b.y<0&&J(P(b.y)),v.copy(M),i.update()}function Te(B){x.set(B.clientX,B.clientY),y.subVectors(x,_).multiplyScalar(i.panSpeed),H(y.x,y.y),_.copy(x),i.update()}function Be(B){ie(B.clientX,B.clientY),B.deltaY<0?J(P(B.deltaY)):B.deltaY>0&&V(P(B.deltaY)),i.update()}function je(B){let _e=!1;switch(B.code){case i.keys.UP:B.ctrlKey||B.metaKey||B.shiftKey?q(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):H(0,i.keyPanSpeed),_e=!0;break;case i.keys.BOTTOM:B.ctrlKey||B.metaKey||B.shiftKey?q(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):H(0,-i.keyPanSpeed),_e=!0;break;case i.keys.LEFT:B.ctrlKey||B.metaKey||B.shiftKey?X(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):H(i.keyPanSpeed,0),_e=!0;break;case i.keys.RIGHT:B.ctrlKey||B.metaKey||B.shiftKey?X(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):H(-i.keyPanSpeed,0),_e=!0;break}_e&&(B.preventDefault(),i.update())}function $e(B){if(E.length===1)p.set(B.pageX,B.pageY);else{const _e=dt(B),Ce=.5*(B.pageX+_e.x),Re=.5*(B.pageY+_e.y);p.set(Ce,Re)}}function qe(B){if(E.length===1)_.set(B.pageX,B.pageY);else{const _e=dt(B),Ce=.5*(B.pageX+_e.x),Re=.5*(B.pageY+_e.y);_.set(Ce,Re)}}function Xe(B){const _e=dt(B),Ce=B.pageX-_e.x,Re=B.pageY-_e.y,Ve=Math.sqrt(Ce*Ce+Re*Re);v.set(0,Ve)}function ge(B){i.enableZoom&&Xe(B),i.enablePan&&qe(B)}function G(B){i.enableZoom&&Xe(B),i.enableRotate&&$e(B)}function Ae(B){if(E.length==1)f.set(B.pageX,B.pageY);else{const Ce=dt(B),Re=.5*(B.pageX+Ce.x),Ve=.5*(B.pageY+Ce.y);f.set(Re,Ve)}m.subVectors(f,p).multiplyScalar(i.rotateSpeed);const _e=i.domElement;X(2*Math.PI*m.x/_e.clientHeight),q(2*Math.PI*m.y/_e.clientHeight),p.copy(f)}function ue(B){if(E.length===1)x.set(B.pageX,B.pageY);else{const _e=dt(B),Ce=.5*(B.pageX+_e.x),Re=.5*(B.pageY+_e.y);x.set(Ce,Re)}y.subVectors(x,_).multiplyScalar(i.panSpeed),H(y.x,y.y),_.copy(x)}function de(B){const _e=dt(B),Ce=B.pageX-_e.x,Re=B.pageY-_e.y,Ve=Math.sqrt(Ce*Ce+Re*Re);M.set(0,Ve),b.set(0,Math.pow(M.y/v.y,i.zoomSpeed)),V(b.y),v.copy(M);const tt=(B.pageX+_e.x)*.5,Tt=(B.pageY+_e.y)*.5;ie(tt,Tt)}function Ee(B){i.enableZoom&&de(B),i.enablePan&&ue(B)}function Fe(B){i.enableZoom&&de(B),i.enableRotate&&Ae(B)}function ke(B){i.enabled!==!1&&(E.length===0&&(i.domElement.setPointerCapture(B.pointerId),i.domElement.addEventListener("pointermove",N),i.domElement.addEventListener("pointerup",L)),Ge(B),B.pointerType==="touch"?He(B):Z(B))}function N(B){i.enabled!==!1&&(B.pointerType==="touch"?Ie(B):xe(B))}function L(B){Je(B),E.length===0&&(i.domElement.releasePointerCapture(B.pointerId),i.domElement.removeEventListener("pointermove",N),i.domElement.removeEventListener("pointerup",L)),i.dispatchEvent(_v),a=r.NONE}function Z(B){let _e;switch(B.button){case 0:_e=i.mouseButtons.LEFT;break;case 1:_e=i.mouseButtons.MIDDLE;break;case 2:_e=i.mouseButtons.RIGHT;break;default:_e=-1}switch(_e){case ur.DOLLY:if(i.enableZoom===!1)return;he(B),a=r.DOLLY;break;case ur.ROTATE:if(B.ctrlKey||B.metaKey||B.shiftKey){if(i.enablePan===!1)return;De(B),a=r.PAN}else{if(i.enableRotate===!1)return;ne(B),a=r.ROTATE}break;case ur.PAN:if(B.ctrlKey||B.metaKey||B.shiftKey){if(i.enableRotate===!1)return;ne(B),a=r.ROTATE}else{if(i.enablePan===!1)return;De(B),a=r.PAN}break;default:a=r.NONE}a!==r.NONE&&i.dispatchEvent(Hp)}function xe(B){switch(a){case r.ROTATE:if(i.enableRotate===!1)return;ee(B);break;case r.DOLLY:if(i.enableZoom===!1)return;ce(B);break;case r.PAN:if(i.enablePan===!1)return;Te(B);break}}function fe(B){i.enabled===!1||i.enableZoom===!1||a!==r.NONE||(B.preventDefault(),i.dispatchEvent(Hp),Be(B),i.dispatchEvent(_v))}function Se(B){i.enabled===!1||i.enablePan===!1||je(B)}function He(B){switch(be(B),E.length){case 1:switch(i.touches.ONE){case Vr.ROTATE:if(i.enableRotate===!1)return;$e(B),a=r.TOUCH_ROTATE;break;case Vr.PAN:if(i.enablePan===!1)return;qe(B),a=r.TOUCH_PAN;break;default:a=r.NONE}break;case 2:switch(i.touches.TWO){case Vr.DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;ge(B),a=r.TOUCH_DOLLY_PAN;break;case Vr.DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;G(B),a=r.TOUCH_DOLLY_ROTATE;break;default:a=r.NONE}break;default:a=r.NONE}a!==r.NONE&&i.dispatchEvent(Hp)}function Ie(B){switch(be(B),a){case r.TOUCH_ROTATE:if(i.enableRotate===!1)return;Ae(B),i.update();break;case r.TOUCH_PAN:if(i.enablePan===!1)return;ue(B),i.update();break;case r.TOUCH_DOLLY_PAN:if(i.enableZoom===!1&&i.enablePan===!1)return;Ee(B),i.update();break;case r.TOUCH_DOLLY_ROTATE:if(i.enableZoom===!1&&i.enableRotate===!1)return;Fe(B),i.update();break;default:a=r.NONE}}function Ue(B){i.enabled!==!1&&B.preventDefault()}function Ge(B){E.push(B.pointerId)}function Je(B){delete I[B.pointerId];for(let _e=0;_e<E.length;_e++)if(E[_e]==B.pointerId){E.splice(_e,1);return}}function be(B){let _e=I[B.pointerId];_e===void 0&&(_e=new pe,I[B.pointerId]=_e),_e.set(B.pageX,B.pageY)}function dt(B){const _e=B.pointerId===E[0]?E[1]:E[0];return I[_e]}i.domElement.addEventListener("contextmenu",Ue),i.domElement.addEventListener("pointerdown",ke),i.domElement.addEventListener("pointercancel",L),i.domElement.addEventListener("wheel",fe,{passive:!1}),this.update()}}const No=new ea,Bn=new K_,Uo=new pe,yv=new z,Ac=new z,Gp=new z,xv=new Ze;class wR extends Yn{constructor(e,t,i){super(),i.style.touchAction="none";let r=null,a=null,s=null,l=null,h=!1,c=!1,d=!1,p=!1;const f=this;function m(){i.addEventListener("pointermove",M),i.addEventListener("pointerdown",b),i.addEventListener("pointerup",S),i.addEventListener("pointerleave",S)}function _(){i.removeEventListener("pointermove",M),i.removeEventListener("pointerdown",b),i.removeEventListener("pointerup",S),i.removeEventListener("pointerleave",S),i.style.cursor=""}function x(){_()}function y(){return e}function v(){return Bn}function M(E){if(f.enabled!==!1){if(A(E),Bn.setFromCamera(Uo,t),(c||h&&!r)&&(d=!0),r)if(p){if(Bn.ray.intersectPlane(No,Ac)){let C=Ac.sub(yv).applyMatrix4(xv);C=C.divideScalar(1).floor().multiplyScalar(1).addScalar(1),r.position.x=C.x,r.position.y=C.y}i.style.cursor="move",f.dispatchEvent({type:"drag",object:r});return}else{let C=[];Bn.setFromCamera(Uo,t),Bn.intersectObjects(e,!0,C),No.setFromNormalAndCoplanarPoint(t.getWorldDirection(No.normal),Gp.setFromMatrixPosition(r.matrixWorld)),Bn.ray.intersectPlane(No,Ac)&&(xv.copy(r.parent.matrixWorld).invert(),yv.copy(Ac).sub(Gp.setFromMatrixPosition(r.matrixWorld))),p=!0,f.dispatchEvent({type:"dragstart",object:r}),f.dispatchEvent({type:"objectslected",object:r})}if(E.pointerType==="mouse"||E.pointerType==="pen"){let C=[];if(Bn.setFromCamera(Uo,t),Bn.intersectObjects(e,!0,C),C.length>0){var I;C[0].object.userData.draggable&&(I=C[0].object),I?(No.setFromNormalAndCoplanarPoint(t.getWorldDirection(No.normal),Gp.setFromMatrixPosition(I.matrixWorld)),l!==I&&l!==null&&(f.dispatchEvent({type:"hoveroff",object:l}),i.style.cursor="auto",l=null),l!==I&&(f.dispatchEvent({type:"hoveron",object:I}),i.style.cursor="pointer",l=I)):l!==null&&(f.dispatchEvent({type:"hoveroff",object:l}),i.style.cursor="auto",l=null)}else l!==null&&(f.dispatchEvent({type:"hoveroff",object:l}),i.style.cursor="auto",l=null)}}}function b(E){if(f.enabled===!1)return;A(E),contextMenu.style.display="none";let I=[];if(Bn.setFromCamera(Uo,t),Bn.intersectObjects(e,!0,I),I.length>0){if(!E)var E=window.event;if(E.button===2){let P=I[0].object;const X=document.getElementById("weathervane_div"),q=document.getElementById("weathervane"),te=document.getElementById("contextMenuLabel"),k=document.getElementById("duplicate_object"),H=document.getElementById("lean_to_div");if(k.style.display="",H.style.display="none",X.style.display="none",P.userData.draggable&&P.userData.data)switch(r=P,globalThis.selectedObject=P.userData.data,contextMenu.style.left=E.clientX+"px",contextMenu.style.top=E.clientY+"px",contextMenu.style.display="",P.userData.data.type){case"window":te.innerText="Window";break;case"large_door":te.innerText="Large Door";break;case"entry_door":te.innerText="Entry Door";break}else if(P.parent.userData.type==="cupola"&&P.parent.userData.data)a=P.parent,globalThis.selectedObject=P.parent.userData.data,contextMenu.style.left=E.clientX+"px",contextMenu.style.top=E.clientY+"px",contextMenu.style.display="",X.style.display="",q.checked=P.parent.userData.data.eagleWeatherwave,te.innerText="Cupola";else if(P.parent.userData.type==="lean_to"&&P.parent.userData.data){a=P.parent;const V=P.parent.userData.data;globalThis.selectedObject=P.parent.userData.data,contextMenu.style.left=E.clientX+"px",contextMenu.style.top=E.clientY+"px",console.log(a);const J=document.getElementById("lean_to_wrap_left"),ie=document.getElementById("lean_to_wrap_right"),$=document.getElementById("lean_to_width"),ne=document.getElementById("lean_to_open_type");V.canWrapLeft?(J.disabled=!1,J.checked=!!V.connected.leftExtend):(J.disabled=!0,J.checked=!1),V.canWrapRight?(ie.disabled=!1,ie.checked=!!V.connected.leftExtend):(ie.disabled=!0,ie.checked=!1),ie.checked=!!V.connected.rightExtend,$.value=nt.scaleToFeet(V.size.width),ne.value=V.openType.front,contextMenu.style.display="",k.style.display="none",H.style.display="",te.innerText="Learn to"}}else{let P=I[0].object;P.userData.draggable?r=P:P.userData.side?s=P.userData.side:(P.parent.userData.type==="cupola"||P.parent.userData.type==="lean_to")&&(a=P.parent)}h=!0}else c=!0}function S(){if(f.enabled!==!1){if(r){p?f.dispatchEvent({type:"dragend",object:r}):f.dispatchEvent({type:"objectslected",object:r}),T();return}if(a){f.dispatchEvent({type:"objectslected",object:a}),T();return}if(c&&!d){f.dispatchEvent({type:"sideslected",object:"none"}),f.dispatchEvent({type:"objectslected",object:"none"}),T();return}if(h&&!d&&s){f.dispatchEvent({type:"sideslected",object:s}),T();return}T()}}function A(E){const I=i.getBoundingClientRect();Uo.x=(E.clientX-I.left)/I.width*2-1,Uo.y=-(E.clientY-I.top)/I.height*2+1}function T(){i.style.cursor=l?"pointer":"auto",r=null,a=null,s=null,c=!1,h=!1,d=!1,p=!1}m(),this.enabled=!0,this.activate=m,this.deactivate=_,this.dispose=x,this.getObjects=y,this.getRaycaster=v}}var Rc=[],Cc=[];class MR{constructor(e){this.oControls=new bR(e.camera,e.renderer.domElement),this.oControls.target.set(0,0,0),this.oControls.enableDamping=!0,this.oControls.dampingFactor=.1,this.oControls.screenSpacePanning=!1,this.oControls.minDistance=10,this.oControls.maxDistance=500,this.addDragControl(e)}addDragControl(e){this.dControls=new wR(Cc,e.camera,e.renderer.domElement),this.dControls.addEventListener("dragstart",E.bind(this)),this.dControls.addEventListener("dragend",C.bind(this)),this.dControls.addEventListener("drag",I.bind(this)),this.dControls.addEventListener("sideslected",te.bind(this)),this.dControls.addEventListener("objectslected",k.bind(this));let t=0,i=0,r={},a={},s={},l=0,h=0,c,d,p=[],f=!1,m=[];const _=e.data.trim;let x,y,v,M,b,S,A,T;function E(H){const{object:V}=H,J=V.parent;y=J.getObjectByName("left-text"),x=J.getObjectByName("right-text"),v=J.getObjectByName("top-text"),M=J.getObjectByName("bottom-text"),S=J.getObjectByName("left-line"),b=J.getObjectByName("right-line"),A=J.getObjectByName("top-line"),T=J.getObjectByName("bottom-line"),c=X(V),d=q(V),this.oControls.enabled=!1,r=V.userData.data.size,a=V.userData.wallSize,V.userData.initialPosition||(V.userData.initialPosition=V.position.clone()),i=a.width/2-r.width/2-_.width,t=-i,h=a.height-r.height/2,l=r.height/2,s=e.data.doors.find(ie=>ie.id===V.userData.data.id),s||(s=e.data.windows.find(ie=>ie.id===V.userData.data.id)),m=[V.userData.initialPosition]}function I(H){const{object:V}=H;let J=V.position.x-V.userData.initialPosition.x,ie=V.position.y-V.userData.initialPosition.y,$=V.userData.initialPosition.x+J,ne=V.userData.initialPosition.y+ie;$>0&&$>i&&($=i),$<0&&$<t&&($=t),V.userData.data.type=="large_door"||V.userData.data.type=="entry_door"?ne=V.userData.initialPosition.y:(ne>h&&(ne=h),ne<l&&(ne=l)),P(V),f?c.opacity=.8:(c.opacity=0,m.push({x:$,y:ne})),V.position.set($,ne,V.userData.initialPosition.z);const he=Math.abs($-r.width/2- -a.width/2),De=Math.abs(a.width/2-$-r.width/2),ee=a.height-ne-r.height/2,ce=ne-r.height/2;if(x.element.firstChild.innerText=De/5+"\u2032",y.element.firstChild.innerText=he/5+"\u2032",v.element.firstChild.innerText=ee/5+"\u2032",M.element.firstChild.innerText=ce/5+"\u2032",y.position.set($-r.width/2-3,ne+2,0),x.position.set($+r.width/2+3,ne+2,0),v.position.set($+2,ne+r.height/2+3,0),M.position.set($+2,ne-r.height/2-3,0),he>0){const Te=[];Te.push(new z(-a.width/2,ne,1)),Te.push(new z(-a.width/2+1,ne+.3,1)),Te.push(new z(-a.width/2+1,ne-.3,1)),Te.push(new z(-a.width/2,ne,1)),Te.push(new z($-r.width/2,ne,1)),S.updateLine(Te)}else S.updateLine();if(De>0){const Te=[];Te.push(new z(a.width/2,ne,1)),Te.push(new z(a.width/2-1,ne+.3,1)),Te.push(new z(a.width/2-1,ne-.3,1)),Te.push(new z(a.width/2,ne,1)),Te.push(new z($+r.width/2,ne,1)),b.updateLine(Te)}else b.updateLine();if(ee>0){const Te=[];Te.push(new z($,a.height,1)),Te.push(new z($+.3,a.height-1,1)),Te.push(new z($-.3,a.height-1,1)),Te.push(new z($,a.height,1)),Te.push(new z($,ne+r.height/2,1)),A.updateLine(Te)}else A.updateLine();if(ce>0){const Te=[];Te.push(new z($,0,1)),Te.push(new z($+.3,1,1)),Te.push(new z($-.3,1,1)),Te.push(new z($,0,1)),Te.push(new z($,ne-r.height/2,1)),T.updateLine(Te)}else T.updateLine()}function C(H){const{object:V}=H;if(c.opacity=0,f){const ie=m.length>1?m[m.length-2]:m[m.length-1];V.position.x=ie.x,V.position.y=ie.y}s&&(s.is_valid=!0,s.position.x=V.position.x,s.position.y=V.position.y,s.position.z=V.position.z);let J=e.data;J.options.quality="medium",J.options.roofQuality="medium",e.changeData(J),V.updateMatrixWorld(),this.oControls.enabled=!0,x.element.firstChild.innerText="",y.element.firstChild.innerText="",v.element.firstChild.innerText="",M.element.firstChild.innerText="",S.updateLine(),b.updateLine(),A.updateLine(),T.updateLine()}function P(H){f=!1,p=[],d.length>0&&d.forEach(V=>{if(H.geometry.userData.obb&&V.geometry.userData.obb){H.userData.obb.copy(H.geometry.userData.obb),H.userData.obb.applyMatrix4(H.matrixWorld),V.userData.obb.copy(V.geometry.userData.obb),V.userData.obb.applyMatrix4(V.matrixWorld);const J=X(V);H.userData.obb.intersectsOBB(V.userData.obb)?(f=!0,p.push(V),J&&(J.opacity=.8)):J&&(J.opacity=0)}})}function X(H){let V;return H&&H.material.length>0&&H.material.forEach(J=>{(J.userData.name==="glass"||J.userData.name==="drag")&&(V=J)}),V}function q(H){let V=[];return Rc.forEach(J=>{H!=J&&J.userData.data.side===H.userData.data.side&&V.push(J)}),V}function te(H){e.selectSide(H.object)}function k(H){e.selectObject(H.object)}}setDraggableObjects(e){for(;Cc.length;)Cc.pop();for(;Rc.length;)Rc.pop();e.traverseVisible(function(t){t.userData.draggable&&Rc.push(t),(t.userData.draggable||t.userData.type==="cupola"||t.name.slice(-4)==="roof"||t.name.slice(-4)==="wall")&&Cc.push(t)})}get orbitControls(){return this.oControls}get dragControls(){return this.dControls}}const bv={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform float opacity; uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); gl_FragColor = opacity * texel; }`};class ql{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const TR=new Yh(-1,1,1,-1,0,1);class SR extends si{constructor(){super(),this.setAttribute("position",new bi([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new bi([0,2,0,0,2,0],2))}}const ER=new SR;class wv{constructor(e){this._mesh=new rt(ER,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,TR)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Vp extends ql{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof mr?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=pd.clone(e.uniforms),this.material=new mr({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new wv(this.material)}render(e,t,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class Mv extends ql{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,i){const r=e.getContext(),a=e.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0);let s,l;this.inverse?(s=0,l=1):(s=1,l=0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),a.buffers.stencil.setFunc(r.ALWAYS,s,4294967295),a.buffers.stencil.setClear(l),a.buffers.stencil.setLocked(!0),e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.color.setMask(!0),a.buffers.depth.setMask(!0),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(r.EQUAL,1,4294967295),a.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),a.buffers.stencil.setLocked(!0)}}class AR extends ql{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class RR{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const i=e.getSize(new pe);this._width=i.width,this._height=i.height,t=new Yi(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Rr}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Vp(bv),this.copyPass.material.blending=pn,this.clock=new DA}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let i=!1;for(let r=0,a=this.passes.length;r<a;r++){const s=this.passes[r];if(s.enabled!==!1){if(s.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),s.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),s.needsSwap){if(i){const l=this.renderer.getContext(),h=this.renderer.state.buffers.stencil;h.setFunc(l.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),h.setFunc(l.EQUAL,1,4294967295)}this.swapBuffers()}Mv!==void 0&&(s instanceof Mv?i=!0:s instanceof AR&&(i=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new pe);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const i=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(i,r),this.renderTarget2.setSize(i,r);for(let a=0;a<this.passes.length;a++)this.passes[a].setSize(i,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}const CR={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new pe(1/1024,1/512)}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` precision highp float; uniform sampler2D tDiffuse; uniform vec2 resolution; varying vec2 vUv; // FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com) //---------------------------------------------------------------------------------- // File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag // SDK Version: v3.00 // Email: gameworks@nvidia.com // Site: http://developer.nvidia.com/ // // Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------------- #ifndef FXAA_DISCARD // // Only valid for PC OpenGL currently. // Probably will not work when FXAA_GREEN_AS_LUMA = 1. // // 1 = Use discard on pixels which don't need AA. // For APIs which enable concurrent TEX+ROP from same surface. // 0 = Return unchanged color on pixels which don't need AA. // #define FXAA_DISCARD 0 #endif /*--------------------------------------------------------------------------*/ #define FxaaTexTop(t, p) texture2D(t, p, -100.0) #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0) /*--------------------------------------------------------------------------*/ #define NUM_SAMPLES 5 // assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha float contrast( vec4 a, vec4 b ) { vec4 diff = abs( a - b ); return max( max( max( diff.r, diff.g ), diff.b ), diff.a ); } /*============================================================================ FXAA3 QUALITY - PC ============================================================================*/ /*--------------------------------------------------------------------------*/ vec4 FxaaPixelShader( vec2 posM, sampler2D tex, vec2 fxaaQualityRcpFrame, float fxaaQualityEdgeThreshold, float fxaaQualityinvEdgeThreshold ) { vec4 rgbaM = FxaaTexTop(tex, posM); vec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy); vec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy); vec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy); vec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy); // . S . // W M E // . N . bool earlyExit = max( max( max( contrast( rgbaM, rgbaN ), contrast( rgbaM, rgbaS ) ), contrast( rgbaM, rgbaE ) ), contrast( rgbaM, rgbaW ) ) < fxaaQualityEdgeThreshold; // . 0 . // 0 0 0 // . 0 . #if (FXAA_DISCARD == 1) if(earlyExit) FxaaDiscard; #else if(earlyExit) return rgbaM; #endif float contrastN = contrast( rgbaM, rgbaN ); float contrastS = contrast( rgbaM, rgbaS ); float contrastE = contrast( rgbaM, rgbaE ); float contrastW = contrast( rgbaM, rgbaW ); float relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW ); relativeVContrast *= fxaaQualityinvEdgeThreshold; bool horzSpan = relativeVContrast > 0.; // . 1 . // 0 0 0 // . 1 . // 45 deg edge detection and corners of objects, aka V/H contrast is too similar if( abs( relativeVContrast ) < .3 ) { // locate the edge vec2 dirToEdge; dirToEdge.x = contrastE > contrastW ? 1. : -1.; dirToEdge.y = contrastS > contrastN ? 1. : -1.; // . 2 . . 1 . // 1 0 2 ~= 0 0 1 // . 1 . . 0 . // tap 2 pixels and see which ones are "outside" the edge, to // determine if the edge is vertical or horizontal vec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy); float matchAlongH = contrast( rgbaM, rgbaAlongH ); // . 1 . // 0 0 1 // . 0 H vec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy); float matchAlongV = contrast( rgbaM, rgbaAlongV ); // V 1 . // 0 0 1 // . 0 . relativeVContrast = matchAlongV - matchAlongH; relativeVContrast *= fxaaQualityinvEdgeThreshold; if( abs( relativeVContrast ) < .3 ) { // 45 deg edge // 1 1 . // 0 0 1 // . 0 1 // do a simple blur return mix( rgbaM, (rgbaN + rgbaS + rgbaE + rgbaW) * .25, .4 ); } horzSpan = relativeVContrast > 0.; } if(!horzSpan) rgbaN = rgbaW; if(!horzSpan) rgbaS = rgbaE; // . 0 . 1 // 1 0 1 -> 0 // . 0 . 1 bool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS ); if(!pairN) rgbaN = rgbaS; vec2 offNP; offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x; offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y; bool doneN = false; bool doneP = false; float nDist = 0.; float pDist = 0.; vec2 posN = posM; vec2 posP = posM; int iterationsUsed = 0; int iterationsUsedN = 0; int iterationsUsedP = 0; for( int i = 0; i < NUM_SAMPLES; i++ ) { iterationsUsed = i; float increment = float(i + 1); if(!doneN) { nDist += increment; posN = posM + offNP * nDist; vec4 rgbaEndN = FxaaTexTop(tex, posN.xy); doneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN ); iterationsUsedN = i; } if(!doneP) { pDist += increment; posP = posM - offNP * pDist; vec4 rgbaEndP = FxaaTexTop(tex, posP.xy); doneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN ); iterationsUsedP = i; } if(doneN || doneP) break; } if ( !doneP && !doneN ) return rgbaM; // failed to find end of edge float dist = min( doneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1., doneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1. ); // hacky way of reduces blurriness of mostly diagonal edges // but reduces AA quality dist = pow(dist, .5); dist = 1. - dist; return mix( rgbaM, rgbaN, dist * .5 ); } void main() { const float edgeDetectionQuality = .2; const float invEdgeDetectionQuality = 1. / edgeDetectionQuality; gl_FragColor = FxaaPixelShader( vUv, tDiffuse, resolution, edgeDetectionQuality, // [0,1] contrast needed, otherwise early discard invEdgeDetectionQuality ); } `};class LR extends ql{constructor(e,t,i=null,r=null,a=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=i,this.clearColor=r,this.clearAlpha=a,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Ke}render(e,t,i){const r=e.autoClear;e.autoClear=!1;let a,s;this.overrideMaterial!==null&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor)),this.clearAlpha!==null&&(a=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:i),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(a),this.overrideMaterial!==null&&(this.scene.overrideMaterial=s),e.autoClear=r}}class Na extends ql{constructor(e,t,i,r){super(),this.renderScene=t,this.renderCamera=i,this.selectedObjects=r!==void 0?r:[],this.visibleEdgeColor=new Ke(1,1,1),this.hiddenEdgeColor=new Ke(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this._visibilityCache=new Map,this.resolution=e!==void 0?new pe(e.x,e.y):new pe(256,256);const a=Math.round(this.resolution.x/this.downSampleRatio),s=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Yi(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new l_,this.depthMaterial.side=xi,this.depthMaterial.depthPacking=ig,this.depthMaterial.blending=pn,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=xi,this.prepareMaskMaterial.fragmentShader=d(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new Yi(this.resolution.x,this.resolution.y,{type:Rr}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new Yi(a,s,{type:Rr}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Yi(a,s,{type:Rr}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Yi(Math.round(a/2),Math.round(s/2),{type:Rr}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Yi(a,s,{type:Rr}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Yi(Math.round(a/2),Math.round(s/2),{type:Rr}),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;const l=4,h=4;this.separableBlurMaterial1=this.getSeperableBlurMaterial(l),this.separableBlurMaterial1.uniforms.texSize.value.set(a,s),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeperableBlurMaterial(h),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(a/2),Math.round(s/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=h,this.overlayMaterial=this.getOverlayMaterial();const c=bv;this.copyUniforms=pd.clone(c.uniforms),this.materialCopy=new mr({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:pn,depthTest:!1,depthWrite:!1}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new Ke,this.oldClearAlpha=1,this.fsQuad=new wv(null),this.tempPulseColor1=new Ke,this.tempPulseColor2=new Ke,this.textureMatrix=new Ze;function d(p,f){const m=f.isPerspectiveCamera?"perspective":"orthographic";return p.replace(/DEPTH_TO_VIEW_Z/g,m+"DepthToViewZ")}}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.depthMaterial.dispose(),this.prepareMaskMaterial.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t),this.renderTargetDepthBuffer.setSize(e,t);let i=Math.round(e/this.downSampleRatio),r=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(i,r),this.renderTargetBlurBuffer1.setSize(i,r),this.renderTargetEdgeBuffer1.setSize(i,r),this.separableBlurMaterial1.uniforms.texSize.value.set(i,r),i=Math.round(i/2),r=Math.round(r/2),this.renderTargetBlurBuffer2.setSize(i,r),this.renderTargetEdgeBuffer2.setSize(i,r),this.separableBlurMaterial2.uniforms.texSize.value.set(i,r)}changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;function i(r){r.isMesh&&(e===!0?r.visible=t.get(r):(t.set(r,r.visible),r.visible=e))}for(let r=0;r<this.selectedObjects.length;r++)this.selectedObjects[r].traverse(i)}changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,i=[];function r(s){s.isMesh&&i.push(s)}for(let s=0;s<this.selectedObjects.length;s++)this.selectedObjects[s].traverse(r);function a(s){if(s.isMesh||s.isSprite){let l=!1;for(let h=0;h<i.length;h++)if(i[h].id===s.id){l=!0;break}if(l===!1){const h=s.visible;(e===!1||t.get(s)===!0)&&(s.visible=e),t.set(s,h)}}else(s.isPoints||s.isLine)&&(e===!0?s.visible=t.get(s):(t.set(s,s.visible),s.visible=e))}this.renderScene.traverse(a)}updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,i,r,a){if(this.selectedObjects.length>0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const s=e.autoClear;e.autoClear=!1,a&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);const l=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=l,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const h=.625+Math.cos(performance.now()*.01/this.pulsePeriod)*.75/2;this.tempPulseColor1.multiplyScalar(h),this.tempPulseColor2.multiplyScalar(h)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Na.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Na.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Na.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Na.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,a&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(i),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=s}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=i.texture,e.setRenderTarget(null),this.fsQuad.render(e))}getPrepareMaskMaterial(){return new mr({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new pe(.5,.5)},textureMatrix:{value:null}},vertexShader:`#include <morphtarget_pars_vertex> #include <skinning_pars_vertex> varying vec4 projTexCoord; varying vec4 vPosition; uniform mat4 textureMatrix; void main() { #include <skinbase_vertex> #include <begin_vertex> #include <morphtarget_vertex> #include <skinning_vertex> #include <project_vertex> vPosition = mvPosition; vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; projTexCoord = textureMatrix * worldPosition; }`,fragmentShader:`#include <packing> varying vec4 vPosition; varying vec4 projTexCoord; uniform sampler2D depthTexture; uniform vec2 cameraNearFar; void main() { float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord )); float viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y ); float depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0; gl_FragColor = vec4(0.0, depthTest, 1.0, 1.0); }`})}getEdgeDetectionMaterial(){return new mr({uniforms:{maskTexture:{value:null},texSize:{value:new pe(.5,.5)},visibleEdgeColor:{value:new z(1,1,1)},hiddenEdgeColor:{value:new z(1,1,1)}},vertexShader:`varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:`varying vec2 vUv; uniform sampler2D maskTexture; uniform vec2 texSize; uniform vec3 visibleEdgeColor; uniform vec3 hiddenEdgeColor; void main() { vec2 invSize = 1.0 / texSize; vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize); vec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy); vec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy); vec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw); vec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw); float diff1 = (c1.r - c2.r)*0.5; float diff2 = (c3.r - c4.r)*0.5; float d = length( vec2(diff1, diff2) ); float a1 = min(c1.g, c2.g); float a2 = min(c3.g, c4.g); float visibilityFactor = min(a1, a2); vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor; gl_FragColor = vec4(edgeColor, 1.0) * vec4(d); }`})}getSeperableBlurMaterial(e){return new mr({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new pe(.5,.5)},direction:{value:new pe(.5,.5)},kernelRadius:{value:1}},vertexShader:`varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:`#include <common> varying vec2 vUv; uniform sampler2D colorTexture; uniform vec2 texSize; uniform vec2 direction; uniform float kernelRadius; float gaussianPdf(in float x, in float sigma) { return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma; } void main() { vec2 invSize = 1.0 / texSize; float sigma = kernelRadius/2.0; float weightSum = gaussianPdf(0.0, sigma); vec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum; vec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS); vec2 uvOffset = delta; for( int i = 1; i <= MAX_RADIUS; i ++ ) { float x = kernelRadius * float(i) / float(MAX_RADIUS); float w = gaussianPdf(x, sigma); vec4 sample1 = texture2D( colorTexture, vUv + uvOffset); vec4 sample2 = texture2D( colorTexture, vUv - uvOffset); diffuseSum += ((sample1 + sample2) * w); weightSum += (2.0 * w); uvOffset += delta; } gl_FragColor = diffuseSum/weightSum; }`})}getOverlayMaterial(){return new mr({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:`varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:`varying vec2 vUv; uniform sampler2D maskTexture; uniform sampler2D edgeTexture1; uniform sampler2D edgeTexture2; uniform sampler2D patternTexture; uniform float edgeStrength; uniform float edgeGlow; uniform bool usePatternTexture; void main() { vec4 edgeValue1 = texture2D(edgeTexture1, vUv); vec4 edgeValue2 = texture2D(edgeTexture2, vUv); vec4 maskColor = texture2D(maskTexture, vUv); vec4 patternColor = texture2D(patternTexture, 6.0 * vUv); float visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5; vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow; vec4 finalColor = edgeStrength * maskColor.r * edgeValue; if(usePatternTexture) finalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r); gl_FragColor = finalColor; }`,blending:Pu,depthTest:!1,depthWrite:!1,transparent:!0})}}Na.BlurDirectionX=new pe(1,0),Na.BlurDirectionY=new pe(0,1);const PR={name:"GammaCorrectionShader",uniforms:{tDiffuse:{value:null}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 tex = texture2D( tDiffuse, vUv ); gl_FragColor = sRGBTransferOETF( tex ); }`};class DR{static isWebGLAvailable(){try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}static isWebGL2Available(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}static isColorSpaceAvailable(e){try{const t=document.createElement("canvas"),i=window.WebGL2RenderingContext&&t.getContext("webgl2");return i.drawingBufferColorSpace=e,i.drawingBufferColorSpace===e}catch{return!1}}static getWebGLErrorMessage(){return this.getErrorMessage(1)}static getWebGL2ErrorMessage(){return this.getErrorMessage(2)}static getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},i={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let r='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';const a=document.createElement("div");return a.id="webglmessage",a.style.fontFamily="monospace",a.style.fontSize="13px",a.style.fontWeight="normal",a.style.textAlign="center",a.style.background="#fff",a.style.color="#000",a.style.padding="1.5em",a.style.width="400px",a.style.margin="5em auto 0",i[e]?r=r.replace("$0","graphics card"):r=r.replace("$0","browser"),r=r.replace("$1",t[e]),a.innerHTML=r,a}}const IR=DR;function ft(n,e=!1){const t=n[0].index!==null,i=new Set(Object.keys(n[0].attributes)),r=new Set(Object.keys(n[0].morphAttributes)),a={},s={},l=n[0].morphTargetsRelative,h=new si;let c=0;for(let d=0;d<n.length;++d){const p=n[d];let f=0;if(t!==(p.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in p.attributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(p.attributes[m]),f++}if(f!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". Make sure all geometries have the same number of attributes."),null;if(l!==p.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in p.morphAttributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;s[m]===void 0&&(s[m]=[]),s[m].push(p.morphAttributes[m])}if(e){let m;if(t)m=p.index.count;else if(p.attributes.position!==void 0)m=p.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;h.addGroup(c,m,d),c+=m}}if(t){let d=0;const p=[];for(let f=0;f<n.length;++f){const m=n[f].index;for(let _=0;_<m.count;++_)p.push(m.getX(_)+d);d+=n[f].attributes.position.count}h.setIndex(p)}for(const d in a){const p=Tv(a[d]);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;h.setAttribute(d,p)}for(const d in s){const p=s[d][0].length;if(p===0)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[d]=[];for(let f=0;f<p;++f){const m=[];for(let x=0;x<s[d].length;++x)m.push(s[d][x][f]);const _=Tv(m);if(!_)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" morphAttribute."),null;h.morphAttributes[d].push(_)}}return h}function Tv(n){let e,t,i,r=-1,a=0;for(let c=0;c<n.length;++c){const d=n[c];if(d.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(e===void 0&&(e=d.array.constructor),e!==d.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=d.itemSize),t!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(i===void 0&&(i=d.normalized),i!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(r===-1&&(r=d.gpuType),r!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.array.length}const s=new e(a);let l=0;for(let c=0;c<n.length;++c)s.set(n[c].array,l),l+=n[c].array.length;const h=new mi(s,t,i);return r!==void 0&&(h.gpuType=r),h}function Sv(n,e){if(e===Z1)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(e===Wu||e===eg){let t=n.getIndex();if(t===null){const s=[],l=n.getAttribute("position");if(l!==void 0){for(let h=0;h<l.count;h++)s.push(h);n.setIndex(s),t=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const i=t.count-2,r=[];if(e===Wu)for(let s=1;s<=i;s++)r.push(t.getX(0)),r.push(t.getX(s)),r.push(t.getX(s+1));else for(let s=0;s<i;s++)s%2===0?(r.push(t.getX(s)),r.push(t.getX(s+1)),r.push(t.getX(s+2))):(r.push(t.getX(s+2)),r.push(t.getX(s+1)),r.push(t.getX(s)));r.length/3!==i&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=n.clone();return a.setIndex(r),a.clearGroups(),a}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),n}class Yl extends bo{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new BR(t)}),this.register(function(t){return new qR(t)}),this.register(function(t){return new YR(t)}),this.register(function(t){return new KR(t)}),this.register(function(t){return new kR(t)}),this.register(function(t){return new HR(t)}),this.register(function(t){return new GR(t)}),this.register(function(t){return new VR(t)}),this.register(function(t){return new zR(t)}),this.register(function(t){return new WR(t)}),this.register(function(t){return new FR(t)}),this.register(function(t){return new XR(t)}),this.register(function(t){return new jR(t)}),this.register(function(t){return new NR(t)}),this.register(function(t){return new ZR(t)}),this.register(function(t){return new JR(t)})}load(e,t,i,r){const a=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const c=Cl.extractUrlBase(e);s=Cl.resolveURL(c,this.path)}else s=Cl.extractUrlBase(e);this.manager.itemStart(e);const l=function(c){r?r(c):console.error(c),a.manager.itemError(e),a.manager.itemEnd(e)},h=new G_(this.manager);h.setPath(this.path),h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setWithCredentials(this.withCredentials),h.load(e,function(c){try{a.parse(c,s,function(d){t(d),a.manager.itemEnd(e)},l)}catch(d){l(d)}},i,l)}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,i,r){let a;const s={},l={},h=new TextDecoder;if(typeof e=="string")a=JSON.parse(e);else if(e instanceof ArrayBuffer)if(h.decode(new Uint8Array(e,0,4))===Ev){try{s[Lt.KHR_BINARY_GLTF]=new $R(e)}catch(d){r&&r(d);return}a=JSON.parse(s[Lt.KHR_BINARY_GLTF].content)}else a=JSON.parse(h.decode(e));else a=e;if(a.asset===void 0||a.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new uC(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const p=this.pluginCallbacks[d](c);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[p.name]=p,s[p.name]=!0}if(a.extensionsUsed)for(let d=0;d<a.extensionsUsed.length;++d){const p=a.extensionsUsed[d],f=a.extensionsRequired||[];switch(p){case Lt.KHR_MATERIALS_UNLIT:s[p]=new UR;break;case Lt.KHR_DRACO_MESH_COMPRESSION:s[p]=new QR(a,this.dracoLoader);break;case Lt.KHR_TEXTURE_TRANSFORM:s[p]=new eC;break;case Lt.KHR_MESH_QUANTIZATION:s[p]=new tC;break;default:f.indexOf(p)>=0&&l[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}c.setExtensions(s),c.setPlugins(l),c.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,a){i.parse(e,t,r,a)})}}function OR(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const Lt={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 NR{constructor(e){this.parser=e,this.name=Lt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i<r;i++){const a=t[i];a.extensions&&a.extensions[this.name]&&a.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,a.extensions[this.name].light)}}_loadLight(e){const t=this.parser,i="light:"+e;let r=t.cache.get(i);if(r)return r;const a=t.json,s=((a.extensions&&a.extensions[this.name]||{}).lights||[])[e];let l;const h=new Ke(16777215);s.color!==void 0&&h.setRGB(s.color[0],s.color[1],s.color[2],Bi);const c=s.range!==void 0?s.range:0;switch(s.type){case"directional":l=new q_(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new RA(h),l.distance=c;break;case"spot":l=new EA(h),l.distance=c,s.spot=s.spot||{},s.spot.innerConeAngle=s.spot.innerConeAngle!==void 0?s.spot.innerConeAngle:0,s.spot.outerConeAngle=s.spot.outerConeAngle!==void 0?s.spot.outerConeAngle:Math.PI/4,l.angle=s.spot.outerConeAngle,l.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return l.position.set(0,0,0),l.decay=2,za(l,s),s.intensity!==void 0&&(l.intensity=s.intensity),l.name=t.createUniqueName(s.name||"light_"+e),r=Promise.resolve(l),t.cache.add(i,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,i=this.parser,r=i.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(s){return i._getNodeRef(t.cache,a,s)})}}class UR{constructor(){this.name=Lt.KHR_MATERIALS_UNLIT}getMaterialType(){return vn}extendParams(e,t,i){const r=[];e.color=new Ke(1,1,1),e.opacity=1;const a=t.pbrMetallicRoughness;if(a){if(Array.isArray(a.baseColorFactor)){const s=a.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],Bi),e.opacity=s[3]}a.baseColorTexture!==void 0&&r.push(i.assignTexture(e,"map",a.baseColorTexture,Bt))}return Promise.all(r)}}class zR{constructor(e){this.parser=e,this.name=Lt.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 BR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(a.push(i.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const l=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new pe(l,l)}return Promise.all(a)}}class FR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&a.push(i.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(a)}}class kR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[];t.sheenColor=new Ke(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];if(s.sheenColorFactor!==void 0){const l=s.sheenColorFactor;t.sheenColor.setRGB(l[0],l[1],l[2],Bi)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&a.push(i.assignTexture(t,"sheenColorMap",s.sheenColorTexture,Bt)),s.sheenRoughnessTexture!==void 0&&a.push(i.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(a)}}class HR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&a.push(i.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(a)}}class GR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&a.push(i.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const l=s.attenuationColor||[1,1,1];return t.attenuationColor=new Ke().setRGB(l[0],l[1],l[2],Bi),Promise.all(a)}}class VR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}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 WR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&a.push(i.assignTexture(t,"specularIntensityMap",s.specularTexture));const l=s.specularColorFactor||[1,1,1];return t.specularColor=new Ke().setRGB(l[0],l[1],l[2],Bi),s.specularColorTexture!==void 0&&a.push(i.assignTexture(t,"specularColorMap",s.specularColorTexture,Bt)),Promise.all(a)}}class jR{constructor(e){this.parser=e,this.name=Lt.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&a.push(i.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(a)}}class XR{constructor(e){this.parser=e,this.name=Lt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:Dn}extendMaterialParams(e,t){const i=this.parser,r=i.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const a=[],s=r.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&a.push(i.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(a)}}class qR{constructor(e){this.parser=e,this.name=Lt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,i=t.json,r=i.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const a=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a.source,s)}}class YR{constructor(e){this.parser=e,this.name=Lt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const s=a.extensions[t],l=r.images[s.source];let h=i.textureLoader;if(l.uri){const c=i.options.manager.getHandler(l.uri);c!==null&&(h=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,s.source,h);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.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 KR{constructor(e){this.parser=e,this.name=Lt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,a=r.textures[e];if(!a.extensions||!a.extensions[t])return null;const s=a.extensions[t],l=r.images[s.source];let h=i.textureLoader;if(l.uri){const c=i.options.manager.getHandler(l.uri);c!==null&&(h=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,s.source,h);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.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 ZR{constructor(e){this.name=Lt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],a=this.parser.getDependency("buffer",r.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 a.then(function(l){const h=r.byteOffset||0,c=r.byteLength||0,d=r.count,p=r.byteStride,f=new Uint8Array(l,h,c);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(d,p,f,r.mode,r.filter).then(function(m){return m.buffer}):s.ready.then(function(){const m=new ArrayBuffer(d*p);return s.decodeGltfBuffer(new Uint8Array(m),d,p,f,r.mode,r.filter),m})})}else return null}}class JR{constructor(e){this.name=Lt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const h of r.primitives)if(h.mode!==tn.TRIANGLES&&h.mode!==tn.TRIANGLE_STRIP&&h.mode!==tn.TRIANGLE_FAN&&h.mode!==void 0)return null;const a=i.extensions[this.name].attributes,s=[],l={};for(const h in a)s.push(this.parser.getDependency("accessor",a[h]).then(c=>(l[h]=c,l[h])));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then(h=>{const c=h.pop(),d=c.isGroup?c.children:[c],p=h[0].count,f=[];for(const m of d){const _=new Ze,x=new z,y=new Rn,v=new z(1,1,1),M=new uo(m.geometry,m.material,p);for(let b=0;b<p;b++)l.TRANSLATION&&x.fromBufferAttribute(l.TRANSLATION,b),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,b),l.SCALE&&v.fromBufferAttribute(l.SCALE,b),M.setMatrixAt(b,_.compose(x,y,v));for(const b in l)if(b==="_COLOR_0"){const S=l[b];M.instanceColor=new Cd(S.array,S.itemSize,S.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&m.geometry.setAttribute(b,l[b]);ei.prototype.copy.call(M,m),this.parser.assignFinalMaterial(M),f.push(M)}return c.isGroup?(c.clear(),c.add(...f),c):f[0]}))}}const Ev="glTF",Kl=12,Av={JSON:1313821514,BIN:5130562};class $R{constructor(e){this.name=Lt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Kl),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ev)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Kl,a=new DataView(e,Kl);let s=0;for(;s<r;){const l=a.getUint32(s,!0);s+=4;const h=a.getUint32(s,!0);if(s+=4,h===Av.JSON){const c=new Uint8Array(e,Kl+s,l);this.content=i.decode(c)}else if(h===Av.BIN){const c=Kl+s;this.body=e.slice(c,c+l)}s+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class QR{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Lt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const i=this.json,r=this.dracoLoader,a=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,l={},h={},c={};for(const d in s){const p=jp[d]||d.toLowerCase();l[p]=s[d]}for(const d in e.attributes){const p=jp[d]||d.toLowerCase();if(s[d]!==void 0){const f=i.accessors[e.attributes[d]],m=zo[f.componentType];c[p]=m.name,h[p]=f.normalized===!0}}return t.getDependency("bufferView",a).then(function(d){return new Promise(function(p,f){r.decodeDracoFile(d,function(m){for(const _ in m.attributes){const x=m.attributes[_],y=h[_];y!==void 0&&(x.normalized=y)}p(m)},l,c,Bi,f)})})}}class eC{constructor(){this.name=Lt.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 tC{constructor(){this.name=Lt.KHR_MESH_QUANTIZATION}}class Rv extends Al{constructor(e,t,i,r){super(e,t,i,r)}copySampleValue_(e){const t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,a=e*r*3+r;for(let s=0;s!==r;s++)t[s]=i[a+s];return t}interpolate_(e,t,i,r){const a=this.resultBuffer,s=this.sampleValues,l=this.valueSize,h=l*2,c=l*3,d=r-t,p=(i-t)/d,f=p*p,m=f*p,_=e*c,x=_-c,y=-2*m+3*f,v=m-f,M=1-y,b=v-f+p;for(let S=0;S!==l;S++){const A=s[x+S+l],T=s[x+S+h]*d,E=s[_+S+l],I=s[_+S]*d;a[S]=M*A+b*T+y*E+v*I}return a}}const iC=new Rn;class rC extends Rv{interpolate_(e,t,i,r){const a=super.interpolate_(e,t,i,r);return iC.fromArray(a).normalize().toArray(a),a}}const tn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},zo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Cv={9728:zi,9729:fr,9984:Uu,9985:vm,9986:yh,9987:Za},Lv={33071:Wr,33648:vh,10497:pr},Wp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jp={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"},Ua={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},nC={CUBICSPLINE:void 0,LINEAR:Hs,STEP:hl},Xp={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function aC(n){return n.DefaultMaterial===void 0&&(n.DefaultMaterial=new ta({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:jn})),n.DefaultMaterial}function ws(n,e,t){for(const i in t.extensions)n[i]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=t.extensions[i])}function za(n,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(n.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function sC(n,e,t){let i=!1,r=!1,a=!1;for(let c=0,d=e.length;c<d;c++){const p=e[c];if(p.POSITION!==void 0&&(i=!0),p.NORMAL!==void 0&&(r=!0),p.COLOR_0!==void 0&&(a=!0),i&&r&&a)break}if(!i&&!r&&!a)return Promise.resolve(n);const s=[],l=[],h=[];for(let c=0,d=e.length;c<d;c++){const p=e[c];if(i){const f=p.POSITION!==void 0?t.getDependency("accessor",p.POSITION):n.attributes.position;s.push(f)}if(r){const f=p.NORMAL!==void 0?t.getDependency("accessor",p.NORMAL):n.attributes.normal;l.push(f)}if(a){const f=p.COLOR_0!==void 0?t.getDependency("accessor",p.COLOR_0):n.attributes.color;h.push(f)}}return Promise.all([Promise.all(s),Promise.all(l),Promise.all(h)]).then(function(c){const d=c[0],p=c[1],f=c[2];return i&&(n.morphAttributes.position=d),r&&(n.morphAttributes.normal=p),a&&(n.morphAttributes.color=f),n.morphTargetsRelative=!0,n})}function oC(n,e){if(n.updateMorphTargets(),e.weights!==void 0)for(let t=0,i=e.weights.length;t<i;t++)n.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(n.morphTargetInfluences.length===t.length){n.morphTargetDictionary={};for(let i=0,r=t.length;i<r;i++)n.morphTargetDictionary[t[i]]=i}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function lC(n){let e;const t=n.extensions&&n.extensions[Lt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+qp(t.attributes):e=n.indices+":"+qp(n.attributes)+":"+n.mode,n.targets!==void 0)for(let i=0,r=n.targets.length;i<r;i++)e+=":"+qp(n.targets[i]);return e}function qp(n){let e="";const t=Object.keys(n).sort();for(let i=0,r=t.length;i<r;i++)e+=t[i]+":"+n[t[i]]+";";return e}function Yp(n){switch(n){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 hC(n){return n.search(/\.jpe?g($|\?)/i)>0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const cC=new Ze;class uC{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new OR,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 i=!1,r=!1,a=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,a=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&a<98?this.textureLoader=new V_(this.options.manager):this.textureLoader=new PA(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new G_(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 i=this,r=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(s){const l={scene:s[0][r.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:r.asset,parser:i,userData:{}};return ws(a,l,r),za(l,r),Promise.all(i._invokeAll(function(h){return h.afterRoot&&h.afterRoot(l)})).then(function(){e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,a=t.length;r<a;r++){const s=t[r].joints;for(let l=0,h=s.length;l<h;l++)e[s[l]].isBone=!0}for(let r=0,a=e.length;r<a;r++){const s=e[r];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(i[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.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,i){if(e.refs[t]<=1)return i;const r=i.clone(),a=(s,l)=>{const h=this.associations.get(s);h!=null&&this.associations.set(l,h);for(const[c,d]of s.children.entries())a(d,l.children[c])};return a(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){const r=e(t[i]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const i=[];for(let r=0;r<t.length;r++){const a=e(t[r]);a&&i.push(a)}return i}getDependency(e,t){const i=e+":"+t;let r=this.cache.get(i);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(a){return a.loadNode&&a.loadNode(t)});break;case"mesh":r=this._invokeOne(function(a){return a.loadMesh&&a.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(a){return a.loadBufferView&&a.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(a){return a.loadMaterial&&a.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(a){return a.loadTexture&&a.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(a){return a.loadAnimation&&a.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(a){return a!=this&&a.getDependency&&a.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(i,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const i=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(a,s){return i.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],i=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[Lt.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(a,s){i.load(Cl.resolveURL(t.uri,r.path),a,void 0,function(){s(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(i){const r=t.byteLength||0,a=t.byteOffset||0;return i.slice(a,a+r)})}loadAccessor(e){const t=this,i=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const s=Wp[r.type],l=zo[r.componentType],h=r.normalized===!0,c=new l(r.count*s);return Promise.resolve(new mi(c,s,h))}const a=[];return r.bufferView!==void 0?a.push(this.getDependency("bufferView",r.bufferView)):a.push(null),r.sparse!==void 0&&(a.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),a.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(a).then(function(s){const l=s[0],h=Wp[r.type],c=zo[r.componentType],d=c.BYTES_PER_ELEMENT,p=d*h,f=r.byteOffset||0,m=r.bufferView!==void 0?i.bufferViews[r.bufferView].byteStride:void 0,_=r.normalized===!0;let x,y;if(m&&m!==p){const v=Math.floor(f/m),M="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+v+":"+r.count;let b=t.cache.get(M);b||(x=new c(l,v*m,r.count*m/d),b=new EE(x,m/d),t.cache.add(M,b)),y=new Sd(b,h,f%m/d,_)}else l===null?x=new c(r.count*h):x=new c(l,f,r.count*h),y=new mi(x,h,_);if(r.sparse!==void 0){const v=Wp.SCALAR,M=zo[r.sparse.indices.componentType],b=r.sparse.indices.byteOffset||0,S=r.sparse.values.byteOffset||0,A=new M(s[1],b,r.sparse.count*v),T=new c(s[2],S,r.sparse.count*h);l!==null&&(y=new mi(y.array.slice(),y.itemSize,y.normalized));for(let E=0,I=A.length;E<I;E++){const C=A[E];if(y.setX(C,T[E*h]),h>=2&&y.setY(C,T[E*h+1]),h>=3&&y.setZ(C,T[E*h+2]),h>=4&&y.setW(C,T[E*h+3]),h>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const t=this.json,i=this.options,r=t.textures[e].source,a=t.images[r];let s=this.textureLoader;if(a.uri){const l=i.manager.getHandler(a.uri);l!==null&&(s=l)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,i){const r=this,a=this.json,s=a.textures[e],l=a.images[t],h=(l.uri||l.bufferView)+":"+s.sampler;if(this.textureCache[h])return this.textureCache[h];const c=this.loadImageSource(t,i).then(function(d){d.flipY=!1,d.name=s.name||l.name||"",d.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(d.name=l.uri);const p=(a.samplers||{})[s.sampler]||{};return d.magFilter=Cv[p.magFilter]||fr,d.minFilter=Cv[p.minFilter]||Za,d.wrapS=Lv[p.wrapS]||pr,d.wrapT=Lv[p.wrapT]||pr,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[h]=c,c}loadImageSource(e,t){const i=this,r=this.json,a=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(p=>p.clone());const s=r.images[e],l=self.URL||self.webkitURL;let h=s.uri||"",c=!1;if(s.bufferView!==void 0)h=i.getDependency("bufferView",s.bufferView).then(function(p){c=!0;const f=new Blob([p],{type:s.mimeType});return h=l.createObjectURL(f),h});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(h).then(function(p){return new Promise(function(f,m){let _=f;t.isImageBitmapLoader===!0&&(_=function(x){const y=new Wi(x);y.needsUpdate=!0,f(y)}),t.load(Cl.resolveURL(p,a.path),_,void 0,m)})}).then(function(p){return c===!0&&l.revokeObjectURL(h),p.userData.mimeType=s.mimeType||hC(s.uri),p}).catch(function(p){throw console.error("THREE.GLTFLoader: Couldn't load texture",h),p});return this.sourceCache[e]=d,d}assignTexture(e,t,i,r){const a=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(s=s.clone(),s.channel=i.texCoord),a.extensions[Lt.KHR_TEXTURE_TRANSFORM]){const l=i.extensions!==void 0?i.extensions[Lt.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const h=a.associations.get(s);s=a.extensions[Lt.KHR_TEXTURE_TRANSFORM].extendTexture(s,l),a.associations.set(s,h)}}return r!==void 0&&(s.colorSpace=r),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,a=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+i.uuid;let h=this.cache.get(l);h||(h=new T_,qr.prototype.copy.call(h,i),h.color.copy(i.color),h.map=i.map,h.sizeAttenuation=!1,this.cache.add(l,h)),i=h}else if(e.isLine){const l="LineBasicMaterial:"+i.uuid;let h=this.cache.get(l);h||(h=new po,qr.prototype.copy.call(h,i),h.color.copy(i.color),h.map=i.map,this.cache.add(l,h)),i=h}if(r||a||s){let l="ClonedMaterial:"+i.uuid+":";r&&(l+="derivative-tangents:"),a&&(l+="vertex-colors:"),s&&(l+="flat-shading:");let h=this.cache.get(l);h||(h=i.clone(),a&&(h.vertexColors=!0),s&&(h.flatShading=!0),r&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),this.cache.add(l,h),this.associations.set(h,this.associations.get(i))),i=h}e.material=i}getMaterialType(){return ta}loadMaterial(e){const t=this,i=this.json,r=this.extensions,a=i.materials[e];let s;const l={},h=a.extensions||{},c=[];if(h[Lt.KHR_MATERIALS_UNLIT]){const p=r[Lt.KHR_MATERIALS_UNLIT];s=p.getMaterialType(),c.push(p.extendParams(l,a,t))}else{const p=a.pbrMetallicRoughness||{};if(l.color=new Ke(1,1,1),l.opacity=1,Array.isArray(p.baseColorFactor)){const f=p.baseColorFactor;l.color.setRGB(f[0],f[1],f[2],Bi),l.opacity=f[3]}p.baseColorTexture!==void 0&&c.push(t.assignTexture(l,"map",p.baseColorTexture,Bt)),l.metalness=p.metallicFactor!==void 0?p.metallicFactor:1,l.roughness=p.roughnessFactor!==void 0?p.roughnessFactor:1,p.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(l,"metalnessMap",p.metallicRoughnessTexture)),c.push(t.assignTexture(l,"roughnessMap",p.metallicRoughnessTexture))),s=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,l)})))}a.doubleSided===!0&&(l.side=xi);const d=a.alphaMode||Xp.OPAQUE;if(d===Xp.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,d===Xp.MASK&&(l.alphaTest=a.alphaCutoff!==void 0?a.alphaCutoff:.5)),a.normalTexture!==void 0&&s!==vn&&(c.push(t.assignTexture(l,"normalMap",a.normalTexture)),l.normalScale=new pe(1,1),a.normalTexture.scale!==void 0)){const p=a.normalTexture.scale;l.normalScale.set(p,p)}if(a.occlusionTexture!==void 0&&s!==vn&&(c.push(t.assignTexture(l,"aoMap",a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&s!==vn){const p=a.emissiveFactor;l.emissive=new Ke().setRGB(p[0],p[1],p[2],Bi)}return a.emissiveTexture!==void 0&&s!==vn&&c.push(t.assignTexture(l,"emissiveMap",a.emissiveTexture,Bt)),Promise.all(c).then(function(){const p=new s(l);return a.name&&(p.name=a.name),za(p,a),t.associations.set(p,{materials:e}),a.extensions&&ws(r,p,a),p})}createUniqueName(e){const t=qt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function a(l){return i[Lt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(h){return Pv(h,l,t)})}const s=[];for(let l=0,h=e.length;l<h;l++){const c=e[l],d=lC(c),p=r[d];if(p)s.push(p.promise);else{let f;c.extensions&&c.extensions[Lt.KHR_DRACO_MESH_COMPRESSION]?f=a(c):f=Pv(new si,c,t),r[d]={primitive:c,promise:f},s.push(f)}}return Promise.all(s)}loadMesh(e){const t=this,i=this.json,r=this.extensions,a=i.meshes[e],s=a.primitives,l=[];for(let h=0,c=s.length;h<c;h++){const d=s[h].material===void 0?aC(this.cache):this.getDependency("material",s[h].material);l.push(d)}return l.push(t.loadGeometries(s)),Promise.all(l).then(function(h){const c=h.slice(0,h.length-1),d=h[h.length-1],p=[];for(let m=0,_=d.length;m<_;m++){const x=d[m],y=s[m];let v;const M=c[m];if(y.mode===tn.TRIANGLES||y.mode===tn.TRIANGLE_STRIP||y.mode===tn.TRIANGLE_FAN||y.mode===void 0)v=a.isSkinnedMesh===!0?new RE(x,M):new rt(x,M),v.isSkinnedMesh===!0&&v.normalizeSkinWeights(),y.mode===tn.TRIANGLE_STRIP?v.geometry=Sv(v.geometry,eg):y.mode===tn.TRIANGLE_FAN&&(v.geometry=Sv(v.geometry,Wu));else if(y.mode===tn.LINES)v=new Pd(x,M);else if(y.mode===tn.LINE_STRIP)v=new tc(x,M);else if(y.mode===tn.LINE_LOOP)v=new DE(x,M);else if(y.mode===tn.POINTS)v=new IE(x,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(v.geometry.morphAttributes).length>0&&oC(v,a),v.name=t.createUniqueName(a.name||"mesh_"+e),za(v,a),y.extensions&&ws(r,v,y),t.assignFinalMaterial(v),p.push(v)}for(let m=0,_=p.length;m<_;m++)t.associations.set(p[m],{meshes:e,primitives:m});if(p.length===1)return a.extensions&&ws(r,p[0],a),p[0];const f=new yn;a.extensions&&ws(r,f,a),t.associations.set(f,{meshes:e});for(let m=0,_=p.length;m<_;m++)f.add(p[m]);return f})}loadCamera(e){let t;const i=this.json.cameras[e],r=i[i.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return i.type==="perspective"?t=new nr(dl.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):i.type==="orthographic"&&(t=new Yh(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),za(t,i),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],i=[];for(let r=0,a=t.joints.length;r<a;r++)i.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then(function(r){const a=r.pop(),s=r,l=[],h=[];for(let c=0,d=s.length;c<d;c++){const p=s[c];if(p){l.push(p);const f=new Ze;a!==null&&f.fromArray(a.array,c*16),h.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Rd(l,h)})}loadAnimation(e){const t=this.json,i=this,r=t.animations[e],a=r.name?r.name:"animation_"+e,s=[],l=[],h=[],c=[],d=[];for(let p=0,f=r.channels.length;p<f;p++){const m=r.channels[p],_=r.samplers[m.sampler],x=m.target,y=x.node,v=r.parameters!==void 0?r.parameters[_.input]:_.input,M=r.parameters!==void 0?r.parameters[_.output]:_.output;x.node!==void 0&&(s.push(this.getDependency("node",y)),l.push(this.getDependency("accessor",v)),h.push(this.getDependency("accessor",M)),c.push(_),d.push(x))}return Promise.all([Promise.all(s),Promise.all(l),Promise.all(h),Promise.all(c),Promise.all(d)]).then(function(p){const f=p[0],m=p[1],_=p[2],x=p[3],y=p[4],v=[];for(let M=0,b=f.length;M<b;M++){const S=f[M],A=m[M],T=_[M],E=x[M],I=y[M];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const C=i._createAnimationTracks(S,A,T,E,I);if(C)for(let P=0;P<C.length;P++)v.push(C[P])}return new vA(a,void 0,v)})}createNodeMesh(e){const t=this.json,i=this,r=t.nodes[e];return r.mesh===void 0?null:i.getDependency("mesh",r.mesh).then(function(a){const s=i._getNodeRef(i.meshCache,r.mesh,a);return r.weights!==void 0&&s.traverse(function(l){if(l.isMesh)for(let h=0,c=r.weights.length;h<c;h++)l.morphTargetInfluences[h]=r.weights[h]}),s})}loadNode(e){const t=this.json,i=this,r=t.nodes[e],a=i._loadNodeShallow(e),s=[],l=r.children||[];for(let c=0,d=l.length;c<d;c++)s.push(i.getDependency("node",l[c]));const h=r.skin===void 0?Promise.resolve(null):i.getDependency("skin",r.skin);return Promise.all([a,Promise.all(s),h]).then(function(c){const d=c[0],p=c[1],f=c[2];f!==null&&d.traverse(function(m){m.isSkinnedMesh&&m.bind(f,cC)});for(let m=0,_=p.length;m<_;m++)d.add(p[m]);return d})}_loadNodeShallow(e){const t=this.json,i=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const a=t.nodes[e],s=a.name?r.createUniqueName(a.name):"",l=[],h=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return h&&l.push(h),a.camera!==void 0&&l.push(r.getDependency("camera",a.camera).then(function(c){return r._getNodeRef(r.cameraCache,a.camera,c)})),r._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){l.push(c)}),this.nodeCache[e]=Promise.all(l).then(function(c){let d;if(a.isBone===!0?d=new m_:c.length>1?d=new yn:c.length===1?d=c[0]:d=new ei,d!==c[0])for(let p=0,f=c.length;p<f;p++)d.add(c[p]);if(a.name&&(d.userData.name=a.name,d.name=s),za(d,a),a.extensions&&ws(i,d,a),a.matrix!==void 0){const p=new Ze;p.fromArray(a.matrix),d.applyMatrix4(p)}else a.translation!==void 0&&d.position.fromArray(a.translation),a.rotation!==void 0&&d.quaternion.fromArray(a.rotation),a.scale!==void 0&&d.scale.fromArray(a.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,a=new yn;i.name&&(a.name=r.createUniqueName(i.name)),za(a,i),i.extensions&&ws(t,a,i);const s=i.nodes||[],l=[];for(let h=0,c=s.length;h<c;h++)l.push(r.getDependency("node",s[h]));return Promise.all(l).then(function(h){for(let d=0,p=h.length;d<p;d++)a.add(h[d]);const c=d=>{const p=new Map;for(const[f,m]of r.associations)(f instanceof qr||f instanceof Wi)&&p.set(f,m);return d.traverse(f=>{const m=r.associations.get(f);m!=null&&p.set(f,m)}),p};return r.associations=c(a),a})}_createAnimationTracks(e,t,i,r,a){const s=[],l=e.name?e.name:e.uuid,h=[];Ua[a.path]===Ua.weights?e.traverse(function(f){f.morphTargetInfluences&&h.push(f.name?f.name:f.uuid)}):h.push(l);let c;switch(Ua[a.path]){case Ua.weights:c=vo;break;case Ua.rotation:c=hs;break;case Ua.position:case Ua.scale:c=xo;break;default:switch(i.itemSize){case 1:c=vo;break;case 2:case 3:default:c=xo;break}break}const d=r.interpolation!==void 0?nC[r.interpolation]:Hs,p=this._getArrayFromAccessor(i);for(let f=0,m=h.length;f<m;f++){const _=new c(h[f]+"."+Ua[a.path],t.array,p,d);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),s.push(_)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const i=Yp(t.constructor),r=new Float32Array(t.length);for(let a=0,s=t.length;a<s;a++)r[a]=t[a]*i;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const i=this instanceof hs?rC:Rv;return new i(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function dC(n,e,t){const i=e.attributes,r=new Fi;if(i.POSITION!==void 0){const l=t.json.accessors[i.POSITION],h=l.min,c=l.max;if(h!==void 0&&c!==void 0){if(r.set(new z(h[0],h[1],h[2]),new z(c[0],c[1],c[2])),l.normalized){const d=Yp(zo[l.componentType]);r.min.multiplyScalar(d),r.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const a=e.targets;if(a!==void 0){const l=new z,h=new z;for(let c=0,d=a.length;c<d;c++){const p=a[c];if(p.POSITION!==void 0){const f=t.json.accessors[p.POSITION],m=f.min,_=f.max;if(m!==void 0&&_!==void 0){if(h.setX(Math.max(Math.abs(m[0]),Math.abs(_[0]))),h.setY(Math.max(Math.abs(m[1]),Math.abs(_[1]))),h.setZ(Math.max(Math.abs(m[2]),Math.abs(_[2]))),f.normalized){const x=Yp(zo[f.componentType]);h.multiplyScalar(x)}l.max(h)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(l)}n.boundingBox=r;const s=new Cn;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,n.boundingSphere=s}function Pv(n,e,t){const i=e.attributes,r=[];function a(s,l){return t.getDependency("accessor",s).then(function(h){n.setAttribute(l,h)})}for(const s in i){const l=jp[s]||s.toLowerCase();l in n.attributes||r.push(a(i[s],l))}if(e.indices!==void 0&&!n.index){const s=t.getDependency("accessor",e.indices).then(function(l){n.setIndex(l)});r.push(s)}return Gt.workingColorSpace!==Bi&&"COLOR_0"in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Gt.workingColorSpace}" not supported.`),za(n,e),dC(n,e,t),Promise.all(r).then(function(){return e.targets!==void 0?sC(n,e.targets,t):n})}class Kp{constructor(e){this.top=0,this.array=new Float32Array(e)}write(e){this.array[this.top++]=e.x,this.array[this.top++]=e.y,this.array[this.top++]=e.z}}class pC{constructor(e){this.top=0,this.array=new Float32Array(e)}write(e){this.array[this.top++]=e.x,this.array[this.top++]=e.y}}class Fn{constructor(e){this.plane=null,this.front=null,this.back=null,this.polygons=[],e&&this.build(e)}clone(){const e=new Fn;return e.plane=this.plane&&this.plane.clone(),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone(),e.polygons=this.polygons.map(t=>t.clone()),e}invert(){for(let t=0;t<this.polygons.length;t++)this.polygons[t].flip();this.plane&&this.plane.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();const e=this.front;this.front=this.back,this.back=e}clipPolygons(e){if(!this.plane)return e.slice();let t=new Array,i=new Array;for(let r=0;r<e.length;r++)this.plane.splitPolygon(e[r],t,i,t,i);return this.front&&(t=this.front.clipPolygons(t)),this.back?i=this.back.clipPolygons(i):i=[],t.concat(i)}clipTo(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)}allPolygons(){let e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e}build(e){if(!e.length)return;this.plane||(this.plane=e[0].plane.clone());const t=[],i=[];for(let r=0;r<e.length;r++)this.plane.splitPolygon(e[r],this.polygons,this.polygons,t,i);t.length&&(this.front||(this.front=new Fn),this.front.build(t)),i.length&&(this.back||(this.back=new Fn),this.back.build(i))}}class br{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}clone(){return new br(this.x,this.y,this.z)}negate(){return this.x*=-1,this.y*=-1,this.z*=-1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}times(e){return this.x*=e,this.y*=e,this.z*=e,this}dividedBy(e){return this.x/=e,this.y/=e,this.z/=e,this}lerp(e,t){return this.add(new br().copy(e).sub(this).times(t))}unit(){return this.dividedBy(this.length())}length(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2)+Math.pow(this.z,2))}normalize(){return this.unit()}cross(e){const t=this.clone(),i=t.x,r=t.y,a=t.z,s=e.x,l=e.y,h=e.z;return this.x=r*h-a*l,this.y=a*s-i*h,this.z=i*l-r*s,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}toVector3(){return new z(this.x,this.y,this.z)}}class Ms{constructor(e,t){this.normal=e,this.w=t,this.normal=e,this.w=t}clone(){return new Ms(this.normal.clone(),this.w)}flip(){this.normal.negate(),this.w=-this.w}splitPolygon(e,t,i,r,a){let s=0;const l=[];for(let h=0;h<e.vertices.length;h++){const c=this.normal.dot(e.vertices[h].pos)-this.w,d=c<-Ms.EPSILON?2:c>Ms.EPSILON?1:0;s|=d,l.push(d)}switch(s){case 0:(this.normal.dot(e.plane.normal)>0?t:i).push(e);break;case 1:r.push(e);break;case 2:a.push(e);break;case 3:{const h=[],c=[];for(let d=0;d<e.vertices.length;d++){const p=(d+1)%e.vertices.length,f=l[d],m=l[p],_=e.vertices[d],x=e.vertices[p];if(f!=2&&h.push(_),f!=1&&c.push(f!=2?_.clone():_),(f|m)==3){const y=(this.w-this.normal.dot(_.pos))/this.normal.dot(new br().copy(x.pos).sub(_.pos)),v=_.interpolate(x,y);h.push(v),c.push(v.clone())}}h.length>=3&&r.push(new Bo(h,e.shared)),c.length>=3&&a.push(new Bo(c,e.shared));break}}}static fromPoints(e,t,i){const r=new br().copy(t).sub(e).cross(new br().copy(i).sub(e)).normalize();return new Ms(r.clone(),r.dot(e))}}Ms.EPSILON=1e-5;class Bo{constructor(e,t){this.vertices=e,this.shared=t,this.plane=Ms.fromPoints(e[0].pos,e[1].pos,e[2].pos)}clone(){return new Bo(this.vertices.map(e=>e.clone()),this.shared)}flip(){this.vertices.reverse().map(e=>e.flip()),this.plane.flip()}}class Lc{constructor(e,t,i,r){this.pos=new br().copy(e),this.normal=new br().copy(t),this.uv=new br().copy(i),this.uv.z=0,r&&(this.color=new br().copy(r))}clone(){return new Lc(this.pos,this.normal,this.uv,this.color)}flip(){this.normal.negate()}interpolate(e,t){return new Lc(this.pos.clone().lerp(e.pos,t),this.normal.clone().lerp(e.normal,t),this.uv.clone().lerp(e.uv,t),this.color&&e.color&&this.color.clone().lerp(e.color,t))}}class mt{constructor(){this.polygons=[]}static fromPolygons(e){const t=new mt;return t.polygons=e,t}static fromGeometry(e,t){let i=[];const r=e.attributes.position,a=e.attributes.normal,s=e.attributes.uv,l=e.attributes.color,h=e.groups;let c;if(e.index)c=e.index.array;else{c=new Array(r.array.length/r.itemSize|0);for(let p=0;p<c.length;p++)c[p]=p}const d=c.length/3|0;i=new Array(d);for(let p=0,f=0,m=c.length;p<m;p+=3,f++){const _=new Array(3);for(let x=0;x<3;x++){const y=c[p+x],v=y*3,M=y*2,b=r.array[v],S=r.array[v+1],A=r.array[v+2],T=a.array[v],E=a.array[v+1],I=a.array[v+2],C=s==null?void 0:s.array[M],P=s==null?void 0:s.array[M+1];_[x]=new Lc(new br(b,S,A),new br(T,E,I),new br(C,P,0),l&&new br(l.array[v],l.array[v+1],l.array[v+2]))}if(t===void 0&&h&&h.length>0)for(const x of h)p>=x.start&&p<x.start+x.count&&(i[f]=new Bo(_,x.materialIndex));else i[f]=new Bo(_,t)}return mt.fromPolygons(i.filter(p=>!Number.isNaN(p.plane.normal.x)))}static toGeometry(e,t){let i=0;const r=e.polygons;for(const m of r)i+=m.vertices.length-2;const a=new si,s=new Kp(i*3*3),l=new Kp(i*3*3),h=new pC(i*2*3);let c;const d=[],p=[];for(const m of r){const _=m.vertices,x=_.length;m.shared!==void 0&&(d[m.shared]||(d[m.shared]=[])),x&&_[0].color!==void 0&&(c||(c=new Kp(i*3*3)));for(let y=3;y<=x;y++)(m.shared===void 0?p:d[m.shared]).push(s.top/3,s.top/3+1,s.top/3+2),s.write(_[0].pos),s.write(_[y-2].pos),s.write(_[y-1].pos),l.write(_[0].normal),l.write(_[y-2].normal),l.write(_[y-1].normal),h&&(h.write(_[0].uv),h.write(_[y-2].uv),h.write(_[y-1].uv)),c&&(c.write(_[0].color),c.write(_[y-2].color),c.write(_[y-1].color))}a.setAttribute("position",new mi(s.array,3)),a.setAttribute("normal",new mi(l.array,3)),h&&a.setAttribute("uv",new mi(h.array,2)),c&&a.setAttribute("color",new mi(c.array,3));for(let m=0;m<d.length;m++)d[m]===void 0&&(d[m]=[]);if(d.length){let m=[],_=0;for(let x=0;x<d.length;x++)a.addGroup(_,d[x].length,x),_+=d[x].length,m=m.concat(d[x]);a.addGroup(_,p.length,d.length),m=m.concat(p),a.setIndex(m)}const f=new Ze().copy(t).invert();return a.applyMatrix4(f),a.computeBoundingSphere(),a.computeBoundingBox(),a}static fromMesh(e,t){const i=mt.fromGeometry(e.geometry,t),r=new z,a=new yt;a.getNormalMatrix(e.matrix);for(let s=0;s<i.polygons.length;s++){const l=i.polygons[s];for(let h=0;h<l.vertices.length;h++){const c=l.vertices[h];c.pos.copy(r.copy(c.pos.toVector3()).applyMatrix4(e.matrix)),c.normal.copy(r.copy(c.normal.toVector3()).applyMatrix3(a))}}return i}static toMesh(e,t,i){const r=mt.toGeometry(e,t),a=new rt(r,i);return a.matrix.copy(t),a.matrix.decompose(a.position,a.quaternion,a.scale),a.rotation.setFromQuaternion(a.quaternion),a.updateMatrixWorld(),a.castShadow=a.receiveShadow=!0,a}static union(e,t){const i=mt.fromMesh(e),r=mt.fromMesh(t);return mt.toMesh(i.union(r),e.matrix,e.material)}static subtract(e,t){const i=mt.fromMesh(e),r=mt.fromMesh(t);return mt.toMesh(i.subtract(r),e.matrix,e.material)}static intersect(e,t){const i=mt.fromMesh(e),r=mt.fromMesh(t);return mt.toMesh(i.intersect(r),e.matrix,e.material)}clone(){const e=new mt;return e.polygons=this.polygons.map(t=>t.clone()).filter(t=>Number.isFinite(t.plane.w)),e}toPolygons(){return this.polygons}union(e){const t=new Fn(this.clone().polygons),i=new Fn(e.clone().polygons);return t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),mt.fromPolygons(t.allPolygons())}subtract(e){const t=new Fn(this.clone().polygons),i=new Fn(e.clone().polygons);return t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),mt.fromPolygons(t.allPolygons())}intersect(e){const t=new Fn(this.clone().polygons),i=new Fn(e.clone().polygons);return t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),mt.fromPolygons(t.allPolygons())}inverse(){const e=this.clone();for(const t of e.polygons)t.flip();return e}toMesh(e,t){return mt.toMesh(this,e,t)}toGeometry(e){return mt.toGeometry(this,e)}}function Ba(n,e,t,i){t=t!==void 0?t:!0,i=i!==void 0?t===!0?!0:i:!0,t&&e.push(e[0],e[1]);const r=(ye,it,Ut)=>Math.sqrt(ye*ye+it*it+Ut*Ut),a=(ye,it,Ut,oi,er,jt)=>ye*oi+it*er+Ut*jt,s=e.length/2,l=n.length/2,h=s-1,c=l-1;let d=[],p=[],f=[];for(let ye=0;ye<c;ye++)d.push([]),p.push([]),f.push([]);d.push([]),i||(p.push([],[]),f.push([],[]));let m=[],_,x,y,v,M,b,S,A,T,E,I,C,P,X,q,te,k,H,V,J,ie,$,ne,he,De,ee,ce,Te,Be,je,$e,qe,Xe,ge,G,Ae,ue,de,Ee,Fe,ke,N,L,Z,xe,fe,Se,He,Ie,Ue,Ge,Je,be,dt,B,_e,Ce,Re,Ve,tt,Tt,ut,Le,W,we,Pe;const et=1e-6;if(Ge=1/0,Je=1/0,be=-1/0,dt=-1/0,!i)for(let ye=0;ye<l;ye++)M=2*ye,n[M]<Ge&&(Ge=n[M]),n[M+1]<Je&&(Je=n[M+1]),n[M]>be&&(be=n[M]),n[M+1]>dt&&(dt=n[M+1]);for(let ye=0;ye<l;ye++)for(let it=0;it<s;it++)_=2*it,A=e[_],T=e[_+1],it===0?(b=e[(h-1)*2],S=e[(h-1)*2+1]):(b=e[_-2],S=e[_-1]),it===h?(E=e[2],I=e[3]):(E=e[_+2],I=e[_+3]),t||(it===0&&(H=E-A,V=I-T,De=Math.sqrt(H*H+V*V),ne=H/De,he=V/De,ee=he,ce=-ne),it===h&&(te=A-b,k=T-S,$=Math.sqrt(te*te+k*k),J=te/$,ie=k/$,ee=ie,ce=-J),P=1,$e=1),(it>0&&it<h||t)&&(te=b-A,k=S-T,H=E-A,V=I-T,Math.abs(V/H-k/te)<et&&(k+=et),Math.abs(H/V-te/k)<et&&(te+=et),$=Math.sqrt(te*te+k*k),J=te/$,ie=k/$,De=Math.sqrt(H*H+V*V),ne=H/De,he=V/De,ee=J+ne,ce=ie+he,Te=Math.sqrt(ee*ee+ce*ce),ee=ee/Te,ce=ce/Te,je=Math.acos(ne*J+he*ie)/2,$e=Math.sign(te*V-k*H),P=Math.sin(je)),C=n[ye*2],Be=C/P,X=Be*$e*ee,q=Be*$e*ce,qe=A+X,Xe=T+q,ge=n[ye*2+1],d[ye].push(qe,Xe,ge),ye===0&&it===h&&!i&&(Se=A,He=T),ye===0&&it===0&&!i&&(Ie=A,Ue=T);for(let ye=0;ye<c;ye++){v=ye+1;for(let it=0;it<h;it++)x=3*it,y=x+3,G=d[ye][x],Ae=d[ye][x+1],ue=d[ye][x+2],de=d[v][x],Ee=d[v][x+1],Fe=d[v][x+2],ke=d[v][y],N=d[v][y+1],L=d[v][y+2],Z=d[ye][y],xe=d[ye][y+1],fe=d[ye][y+2],p[ye].push(G,Ae,ue,de,Ee,Fe,Z,xe,fe,de,Ee,Fe,ke,N,L,Z,xe,fe),B=r(Z-G,xe-Ae,fe-ue),we=a(Z-G,xe-Ae,fe-ue,de-G,Ee-Ae,Fe-ue)/B,Pe=a(G-Z,Ae-xe,ue-fe,ke-Z,N-xe,L-fe)/B,we>=0&&Pe>=0&&(_e=0,Ve=we/B,tt=1-Pe/B,Tt=1),we>=0&&Pe<0&&(_e=0,Ve=we/(B-Pe),tt=1,Tt=1+Pe/(B-Pe)),we<0&&Pe<0&&(_e=-we/(B-we-Pe),Ve=0,tt=1,Tt=1+Pe/(B-we-Pe)),we<0&&Pe>=0&&(_e=-we/(B-we),Ve=0,tt=1-Pe/(B-we),Tt=1),f[ye].push(_e,1,Ve,0,Tt,1,Ve,0,tt,0,Tt,1)}if(!i){X=be-Ge,q=dt-Je,ut=-Je/q,Ce=-Ge/X,Re=1-Ce,x=3*h;for(let ye=0;ye<c;ye++)v=ye+1,M=2*ye,G=d[ye][0],Ae=d[ye][1],ue=d[ye][2],de=d[v][0],Ee=d[v][1],Fe=d[v][2],p[c].push(Ie,Ue,0,G,Ae,ue,de,Ee,Fe),Ve=(n[M]-Ge)/X,Le=(n[M+1]-Je)/q,tt=(n[M+2]-Ge)/X,W=(n[M+3]-Je)/q,f[c].push(Ce,ut,Ve,Le,tt,W),G=d[v][x],Ae=d[v][x+1],ue=d[v][x+2],de=d[ye][x],Ee=d[ye][x+1],Fe=d[ye][x+2],p[l].push(Se,He,0,G,Ae,ue,de,Ee,Fe),Ve=1-(n[M+2]-Ge)/X,Le=(n[M+3]-Je)/q,tt=1-(n[M]-Ge)/X,W=(n[M+1]-Je)/q,f[l].push(Re,ut,Ve,Le,tt,W)}for(let ye=0;ye<(i?c:c+2);ye++)m[ye]=new si,m[ye].setAttribute("position",new mi(new Float32Array(p[ye]),3)),m[ye].setAttribute("uv",new mi(new Float32Array(f[ye]),2)),m[ye].computeVertexNormals();return m}function Pc(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16))}function Dv(n,e){return Math.random()*(e-n)+n}class Dc extends si{constructor(e=null){const t=e.width,i=e.length,r=e.type??"low",a=e.slopeHeight,s=.02;super();var l=[0,0,0,t,s,t,s,0,0,0],h=this.generateContours(a,i,r);if(h.length>0){let c=Ba(l,h,!1,!1);this.copy(ft(c))}}generateContours(e,t,i){let r,a,s;if(i==="low"?(r=[1,1,2,1,2,.5,2,.5,2,.5,2,.5,1],a=[0,1,1,0,0,.3,.3,0,0,.3,.3,0,0],s=13):(r=[.5,1,1,1,1,.2,.5,.2,1,.2,.5,.2,.5],a=[0,1,1,0,0,.3,.3,0,0,.3,.3,0,0],s=13),r.length<s||a.length<s)return[];let l=[0,0],h=0,c=0;for(;c<t;)c+=r[h%s]*e,l.push(c),l.push(e*a[h%s]),h+=1;return l.pop(),l.push(0),l}}class wr{constructor(e,t,i,r,a=6,s=2,l=0){let h=t.clone();h.rotation=l,h.colorSpace=Bt,h.wrapS=h.wrapT=pr,h.repeat.set(a,s);let c=i.clone();c.rotation=l,c.colorSpace=Bt,c.wrapS=c.wrapT=pr,c.repeat.set(a,s);let d=r.clone();return d.rotation=l,d.colorSpace=Bt,d.wrapS=d.wrapT=pr,d.repeat.set(a,s),new ta({color:e,map:h,bumpMap:c,normalMap:d,normalScale:new pe(1,1),roughness:.4,side:xi})}}class Zp extends si{constructor(e,t,i,r){super();const a=[],s=[],l=[],h=new z,c=new Ze;c.makeRotationFromEuler(i),c.setPosition(t);const d=new Ze;d.copy(c).invert(),p(),this.setAttribute("position",new bi(a,3)),this.setAttribute("normal",new bi(s,3)),this.setAttribute("uv",new bi(l,2));function p(){let x=[];const y=new z,v=new z,M=e.geometry,b=M.attributes.position,S=M.attributes.normal;if(M.index!==null){const A=M.index;for(let T=0;T<A.count;T++)y.fromBufferAttribute(b,A.getX(T)),v.fromBufferAttribute(S,A.getX(T)),f(x,y,v)}else for(let A=0;A<b.count;A++)y.fromBufferAttribute(b,A),v.fromBufferAttribute(S,A),f(x,y,v);x=m(x,h.set(1,0,0)),x=m(x,h.set(-1,0,0)),x=m(x,h.set(0,1,0)),x=m(x,h.set(0,-1,0)),x=m(x,h.set(0,0,1)),x=m(x,h.set(0,0,-1));for(let A=0;A<x.length;A++){const T=x[A];l.push(.5+T.position.x/r.x,.5+T.position.y/r.y),T.position.applyMatrix4(c),a.push(T.position.x,T.position.y,T.position.z),s.push(T.normal.x,T.normal.y,T.normal.z)}}function f(x,y,v){y.applyMatrix4(e.matrixWorld),y.applyMatrix4(d),v.transformDirection(e.matrixWorld),x.push(new Iv(y.clone(),v.clone()))}function m(x,y){const v=[],M=.5*Math.abs(r.dot(y));for(let b=0;b<x.length;b+=3){let S=0,A,T,E,I;const C=x[b+0].position.dot(y)-M,P=x[b+1].position.dot(y)-M,X=x[b+2].position.dot(y)-M,q=C>0,te=P>0,k=X>0;switch(S=(q?1:0)+(te?1:0)+(k?1:0),S){case 0:{v.push(x[b]),v.push(x[b+1]),v.push(x[b+2]);break}case 1:{if(q&&(A=x[b+1],T=x[b+2],E=_(x[b],A,y,M),I=_(x[b],T,y,M)),te){A=x[b],T=x[b+2],E=_(x[b+1],A,y,M),I=_(x[b+1],T,y,M),v.push(E),v.push(T.clone()),v.push(A.clone()),v.push(T.clone()),v.push(E.clone()),v.push(I);break}k&&(A=x[b],T=x[b+1],E=_(x[b+2],A,y,M),I=_(x[b+2],T,y,M)),v.push(A.clone()),v.push(T.clone()),v.push(E),v.push(I),v.push(E.clone()),v.push(T.clone());break}case 2:{q||(A=x[b].clone(),T=_(A,x[b+1],y,M),E=_(A,x[b+2],y,M),v.push(A),v.push(T),v.push(E)),te||(A=x[b+1].clone(),T=_(A,x[b+2],y,M),E=_(A,x[b],y,M),v.push(A),v.push(T),v.push(E)),k||(A=x[b+2].clone(),T=_(A,x[b],y,M),E=_(A,x[b+1],y,M),v.push(A),v.push(T),v.push(E));break}}}return v}function _(x,y,v,M){const b=x.position.dot(v)-M,S=y.position.dot(v)-M,A=b/(b-S);return new Iv(new z(x.position.x+A*(y.position.x-x.position.x),x.position.y+A*(y.position.y-x.position.y),x.position.z+A*(y.position.z-x.position.z)),new z(x.normal.x+A*(y.normal.x-x.normal.x),x.normal.y+A*(y.normal.y-x.normal.y),x.normal.z+A*(y.normal.z-x.normal.z)))}}}class Iv{constructor(e,t){this.position=e,this.normal=t}clone(){return new this.constructor(this.position.clone(),this.normal.clone())}}class Ic extends rt{constructor(e,t){super(),this.name=t+"_wall",this.generateObj(e)}generateObj(e){const t=e.position,i=e.dimensions;e.depth,new fo;let r=i.height,a=0;e.openType=="open_bottom"?a=r-5:e.openType=="open_top"?r=r-5:e.openType=="open"&&(r=a);let s=r;if(i.raise&&i.raise>0){let l=Math.abs(Math.tan(Dt[i.raise]))*i.width;e.isFullWidth&&(l=l/2),s+=l}if(globalThis.options.wallQuality==="high"){const l={width:s-a,length:i.width,slopeHeight:e.depth,type:"low"};this.geometry=new Dc(l),this.geometry.rotateX(Math.PI/2),this.geometry.translate(0,s,0),this.material=new ta({color:e.color,roughness:.4,side:xi})}else{let l,h;h=i.height/6,l=i.width/i.height*h;const c=globalThis.textureImage;c&&c.wall&&c.wall.mapImage?this.material=new wr(e.color,c.wall.mapImage,c.wall.mapImageDisp,c.wall.mapImageNormal,l,h):this.material=new wi({color:65535,flatShading:!0}),this.geometry=new st(i.width,s-a,e.depth),e.isFullWidth?this.geometry.translate(0,(s+a)/2,0):this.geometry.translate(-i.width/2,(s+a)/2,0)}if(s>r){const l=s-r;if(this.updateMatrix(),e.isFullWidth){const h=new st(i.width*2,l,e.depth*4),c=new st(i.width*2,l,e.depth*4);h.rotateZ(Dt[i.raise]),c.rotateZ(-Dt[i.raise]),globalThis.options.wallQuality==="high"?(h.translate(-t.x,s+.5*l/Math.cos(Dt[i.raise]),0),c.translate(-t.x,s+.5*l/Math.cos(Dt[i.raise]),0)):(h.translate(0,s+.5*l/Math.cos(Dt[i.raise]),0),c.translate(0,s+.5*l/Math.cos(Dt[i.raise]),0)),this.geometry=mt.fromGeometry(this.geometry).subtract(mt.fromGeometry(h)),this.geometry=this.geometry.subtract(mt.fromGeometry(c)).toGeometry(new Ze)}else{const h=new st(i.width*4,l,e.depth*4);h.rotateZ(Dt[i.raise]),globalThis.options.wallQuality==="high"?h.translate(0,r+.5*l/Math.cos(Dt[i.raise]),0):h.translate(0,s+.5*l/Math.cos(Dt[i.raise]),0),this.geometry=mt.fromGeometry(this.geometry).subtract(mt.fromGeometry(h)).toGeometry(new Ze)}}if(this.position.set(t.x,t.y,t.z),globalThis.options.wainscotting.enable){let l,h,c=new st(i.width,e.depth*3,e.depth*1.5);if(a>globalThis.options.wainscotting.height&&(c=new st(0,0,0)),globalThis.options.wallQuality==="high")h=new ta({color:globalThis.options.wainscotting.color,transparent:!0,depthTest:!0,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-.75}),l=new Zp(this,new z(i.width/2,globalThis.options.wainscotting.height/2,e.depth/2),new rs,new z(i.width,globalThis.options.wainscotting.height,e.depth*2)),c.translate(i.width/2,globalThis.options.wainscotting.height,e.depth/2);else{let d,p;p=i.height/6,d=i.width/i.height*p;const f=globalThis.textureImage;f&&f.wainscotting&&f.wainscotting.mapImage?h=new wr(globalThis.options.wainscotting.color,f.wainscotting.mapImage,f.wainscotting.mapImageDisp,f.wainscotting.mapImageNormal,d,p):this.material=new wi({color:65535,flatShading:!0}),h.depthWrite=!1,h.polygonOffset=!0,h.polygonOffsetFactor=-.75,e.isFullWidth?(l=new Zp(this,new z(0,globalThis.options.wainscotting.height/2,0),new rs,new z(i.width,globalThis.options.wainscotting.height,e.depth*2)),c.translate(0,globalThis.options.wainscotting.height,0)):(l=new Zp(this,new z(-i.width/2,globalThis.options.wainscotting.height/2,0),new rs,new z(i.width,globalThis.options.wainscotting.height,e.depth*2)),e.side==="left"&&(l.rotateY(Math.PI),l.translate(-i.width,0,0)),c.translate(-i.width/2,globalThis.options.wainscotting.height,0))}this.geometry=ft([this.geometry.toNonIndexed(),l,c.toNonIndexed()],!0),this.material=[this.material,h,h]}}}const Nt={c:null,u:[new z,new z,new z],e:[]},kt={c:null,u:[new z,new z,new z],e:[]},di=[[],[],[]],gt=[[],[],[]],ni=[],Ts=new z,Ss=new z,Es=new z,Pi=new z,Ov=new z,Nv=new z,xn=new yt,Uv=new Fi,Oc=new Ze,zv=new Ze,Bv=new is;class As{constructor(e=new z,t=new z,i=new yt){this.center=e,this.halfSize=t,this.rotation=i}set(e,t,i){return this.center=e,this.halfSize=t,this.rotation=i,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return new this.constructor().copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(e,t){const i=this.halfSize;Pi.subVectors(e,this.center),this.rotation.extractBasis(Ts,Ss,Es),t.copy(this.center);const r=dl.clamp(Pi.dot(Ts),-i.x,i.x);t.add(Ts.multiplyScalar(r));const a=dl.clamp(Pi.dot(Ss),-i.y,i.y);t.add(Ss.multiplyScalar(a));const s=dl.clamp(Pi.dot(Es),-i.z,i.z);return t.add(Es.multiplyScalar(s)),t}containsPoint(e){return Pi.subVectors(e,this.center),this.rotation.extractBasis(Ts,Ss,Es),Math.abs(Pi.dot(Ts))<=this.halfSize.x&&Math.abs(Pi.dot(Ss))<=this.halfSize.y&&Math.abs(Pi.dot(Es))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(fC.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,Nv),Nv.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=Number.EPSILON){Nt.c=this.center,Nt.e[0]=this.halfSize.x,Nt.e[1]=this.halfSize.y,Nt.e[2]=this.halfSize.z,this.rotation.extractBasis(Nt.u[0],Nt.u[1],Nt.u[2]),kt.c=e.center,kt.e[0]=e.halfSize.x,kt.e[1]=e.halfSize.y,kt.e[2]=e.halfSize.z,e.rotation.extractBasis(kt.u[0],kt.u[1],kt.u[2]);for(let a=0;a<3;a++)for(let s=0;s<3;s++)di[a][s]=Nt.u[a].dot(kt.u[s]);Pi.subVectors(kt.c,Nt.c),ni[0]=Pi.dot(Nt.u[0]),ni[1]=Pi.dot(Nt.u[1]),ni[2]=Pi.dot(Nt.u[2]);for(let a=0;a<3;a++)for(let s=0;s<3;s++)gt[a][s]=Math.abs(di[a][s])+t;let i,r;for(let a=0;a<3;a++)if(i=Nt.e[a],r=kt.e[0]*gt[a][0]+kt.e[1]*gt[a][1]+kt.e[2]*gt[a][2],Math.abs(ni[a])>i+r)return!1;for(let a=0;a<3;a++)if(i=Nt.e[0]*gt[0][a]+Nt.e[1]*gt[1][a]+Nt.e[2]*gt[2][a],r=kt.e[a],Math.abs(ni[0]*di[0][a]+ni[1]*di[1][a]+ni[2]*di[2][a])>i+r)return!1;return i=Nt.e[1]*gt[2][0]+Nt.e[2]*gt[1][0],r=kt.e[1]*gt[0][2]+kt.e[2]*gt[0][1],!(Math.abs(ni[2]*di[1][0]-ni[1]*di[2][0])>i+r||(i=Nt.e[1]*gt[2][1]+Nt.e[2]*gt[1][1],r=kt.e[0]*gt[0][2]+kt.e[2]*gt[0][0],Math.abs(ni[2]*di[1][1]-ni[1]*di[2][1])>i+r)||(i=Nt.e[1]*gt[2][2]+Nt.e[2]*gt[1][2],r=kt.e[0]*gt[0][1]+kt.e[1]*gt[0][0],Math.abs(ni[2]*di[1][2]-ni[1]*di[2][2])>i+r)||(i=Nt.e[0]*gt[2][0]+Nt.e[2]*gt[0][0],r=kt.e[1]*gt[1][2]+kt.e[2]*gt[1][1],Math.abs(ni[0]*di[2][0]-ni[2]*di[0][0])>i+r)||(i=Nt.e[0]*gt[2][1]+Nt.e[2]*gt[0][1],r=kt.e[0]*gt[1][2]+kt.e[2]*gt[1][0],Math.abs(ni[0]*di[2][1]-ni[2]*di[0][1])>i+r)||(i=Nt.e[0]*gt[2][2]+Nt.e[2]*gt[0][2],r=kt.e[0]*gt[1][1]+kt.e[1]*gt[1][0],Math.abs(ni[0]*di[2][2]-ni[2]*di[0][2])>i+r)||(i=Nt.e[0]*gt[1][0]+Nt.e[1]*gt[0][0],r=kt.e[1]*gt[2][2]+kt.e[2]*gt[2][1],Math.abs(ni[1]*di[0][0]-ni[0]*di[1][0])>i+r)||(i=Nt.e[0]*gt[1][1]+Nt.e[1]*gt[0][1],r=kt.e[0]*gt[2][2]+kt.e[2]*gt[2][0],Math.abs(ni[1]*di[0][1]-ni[0]*di[1][1])>i+r)||(i=Nt.e[0]*gt[1][2]+Nt.e[1]*gt[0][2],r=kt.e[0]*gt[2][1]+kt.e[1]*gt[2][0],Math.abs(ni[1]*di[0][2]-ni[0]*di[1][2])>i+r))}intersectsPlane(e){this.rotation.extractBasis(Ts,Ss,Es);const t=this.halfSize.x*Math.abs(e.normal.dot(Ts))+this.halfSize.y*Math.abs(e.normal.dot(Ss))+this.halfSize.z*Math.abs(e.normal.dot(Es)),i=e.normal.dot(this.center)-e.constant;return Math.abs(i)<=t}intersectRay(e,t){return this.getSize(Ov),Uv.setFromCenterAndSize(Pi.set(0,0,0),Ov),Oc.setFromMatrix3(this.rotation),Oc.setPosition(this.center),zv.copy(Oc).invert(),Bv.copy(e).applyMatrix4(zv),Bv.intersectBox(Uv,t)?t.applyMatrix4(Oc):null}intersectsRay(e){return this.intersectRay(e,Pi)!==null}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){const t=e.elements;let i=Pi.set(t[0],t[1],t[2]).length();const r=Pi.set(t[4],t[5],t[6]).length(),a=Pi.set(t[8],t[9],t[10]).length();e.determinant()<0&&(i=-i),xn.setFromMatrix4(e);const s=1/i,l=1/r,h=1/a;return xn.elements[0]*=s,xn.elements[1]*=s,xn.elements[2]*=s,xn.elements[3]*=l,xn.elements[4]*=l,xn.elements[5]*=l,xn.elements[6]*=h,xn.elements[7]*=h,xn.elements[8]*=h,this.rotation.multiply(xn),this.halfSize.x*=i,this.halfSize.y*=r,this.halfSize.z*=a,Pi.setFromMatrixPosition(e),this.center.add(Pi),this}}const fC=new As;class mC{constructor(e,t,i){const r=e.size,a=e.position,s=new st(r.width+1,r.height+1,r.depth+.4),l=new st(r.width,r.height,r.depth+6),h=new st(r.width+1,r.height+1,r.depth+6),c=new st(r.width,r.height,r.depth+1);s.computeBoundingBox();const d=mt.fromGeometry(s).subtract(mt.fromGeometry(l)).toGeometry(new Ze),p=new si;p.userData.obb=new As().fromBox3(s.boundingBox);const f=new rt(p,t);this.generateInteriorGeometry(r,e.door_type,f,[d,c],i),f.name=e.name,f.position.set(a.x,a.y,a.z),f.userData.obb=new As,f.userData.data=e,f.userData.draggable=!0,this.hole=new rt(h),this.hole.position.set(a.x,a.y,a.z),this.object=f}generateInteriorGeometry(e,t,i,r,a){const s=new Yl,l=i.geometry.userData;if(t in Ft.entry)if(t in a){let h={x:1,y:1,z:1},c={x:0,y:0,z:0},d,p;if(a[t].children.length>0){d=a[t].children[0].geometry;let f=new Fi;d.computeBoundingBox(),f.copy(d.boundingBox),h.x=e.width/(f.max.x-f.min.x),h.y=e.height/(f.max.y-f.min.y),h.z=e.depth/(f.max.z-f.min.z),d.scale(h.x,h.y,h.z),f.copy(d.boundingBox),c.x=-(f.max.x-(f.max.x-f.min.x)/2),c.y=-(f.max.y-(f.max.y-f.min.y)/2),c.z=0,d.translate(c.x,c.y,c.z),d.needsUpdate=!0,r.push(d)}a[t].children.length>1&&(p=a[t].children[1].geometry,p.scale(h.x,h.y,h.z),p.translate(c.x,c.y,c.z),p.needsUpdate=!0,r.push(p)),i.geometry=ft(r,!0)}else s.load(Ft.entry[t],function(h){a[t]=h.scene;let c={x:1,y:1,z:1},d={x:0,y:0,z:0},p,f;if(h.scene.children.length>0){p=h.scene.children[0].geometry;let m=new Fi;p.computeBoundingBox(),m.copy(p.boundingBox),c.x=e.width/(m.max.x-m.min.x),c.y=e.height/(m.max.y-m.min.y),c.z=e.depth/(m.max.z-m.min.z),p.scale(c.x,c.y,c.z),m.copy(p.boundingBox),d.x=-(m.max.x-(m.max.x-m.min.x)/2),d.y=-(m.max.y-(m.max.y-m.min.y)/2),d.z=0,p.translate(d.x,d.y,d.z),p.needsUpdate=!0,r.push(p)}h.scene.children.length>1&&(f=h.scene.children[1].geometry,f.scale(c.x,c.y,c.z),f.translate(d.x,d.y,d.z),f.needsUpdate=!0,r.push(f)),i.geometry=ft(r,!0),i.geometry.userData=l},function(h){},function(h){console.log("An error happened when loading model entry door")});else i.geometry=ft(r,!0);i.geometry.userData=l}}class gC{constructor(e,t,i){const r=e.size,a=e.position;let s=new st(r.width+1,r.height+1,r.depth+.4),l=new st(r.width,r.height,r.depth+6),h=new st(r.width+1,r.height+1,r.depth+6);const c=new st(r.width,r.height,r.depth+1);if(e.door_type==="dutch_corner_overhead"){const m=new fo,_=r.width,x=r.height,y=r.width+1,v=r.height+1,M=.7,b=.68;m.moveTo(-_/2,-x/2),m.lineTo(-_/2,x*b/2),m.lineTo(-_*M/2,x/2),m.lineTo(_*M/2,x/2),m.lineTo(_/2,x*b/2),m.lineTo(_/2,-x/2),m.lineTo(_/2,-x/2),m.lineTo(-_/2,-x/2);const S=new fo;S.moveTo(-y/2,-v/2),S.lineTo(-y/2,v*b/2),S.lineTo(-y*M/2,v/2),S.lineTo(y*M/2,v/2),S.lineTo(y/2,v*b/2),S.lineTo(y/2,-v/2),S.lineTo(y/2,-v/2),S.lineTo(-y/2,-v/2),s=new go(S,{depth:r.depth+.4,bevelEnabled:!1}),l=new go(m,{depth:r.depth+6,bevelEnabled:!1}),h=new go(S,{depth:r.depth+6,bevelEnabled:!1})}s.computeBoundingBox();const d=mt.fromGeometry(s).subtract(mt.fromGeometry(l)).toGeometry(new Ze);e.door_type==="dutch_corner_overhead"?d.translate(0,0,-1/2):d.translate(0,0,-a.z);const p=new si;p.userData.obb=new As().fromBox3(s.boundingBox);const f=new rt(p,t);this.generateInteriorGeometry(r,e.door_type,f,[d,c],i),f.name=e.name,f.position.set(a.x,a.y,a.z),f.userData.obb=new As,f.userData.data=e,f.userData.draggable=!0,this.hole=new rt(h),e.door_type==="dutch_corner_overhead"?this.hole.position.set(a.x,a.y,a.z-1):this.hole.position.set(a.x,a.y,a.z),this.object=f}generateInteriorGeometry(e,t,i,r,a){const s=new Yl,l=i.geometry.userData;if(t in Ft.large)if(t in a){let h={x:1,y:1,z:1},c={x:0,y:0,z:0},d,p;if(a[t].children.length>0){d=a[t].children[0].geometry;let f=new Fi;d.computeBoundingBox(),f.copy(d.boundingBox),h.x=e.width/(f.max.x-f.min.x),h.y=e.height/(f.max.y-f.min.y),h.z=e.depth/(f.max.z-f.min.z),d.scale(h.x,h.y,h.z),f.copy(d.boundingBox),c.x=-(f.max.x-(f.max.x-f.min.x)/2),c.y=-(f.max.y-(f.max.y-f.min.y)/2),c.z=0,d.translate(c.x,c.y,c.z),r.push(d)}a[t].children.length>1&&(p=a[t].children[1].geometry,p.scale(h.x,h.y,h.z),p.translate(c.x,c.y,c.z),r.push(p)),i.geometry=ft(r,!0)}else s.load(Ft.large[t],function(h){a[t]=h.scene;let c={x:1,y:1,z:1},d={x:0,y:0,z:0},p,f;if(h.scene.children.length>0){p=h.scene.children[0].geometry;let m=new Fi;p.computeBoundingBox(),m.copy(p.boundingBox),c.x=e.width/(m.max.x-m.min.x),c.y=e.height/(m.max.y-m.min.y),c.z=e.depth/(m.max.z-m.min.z),p.scale(c.x,c.y,c.z),m.copy(p.boundingBox),d.x=-(m.max.x-(m.max.x-m.min.x)/2),d.y=-(m.max.y-(m.max.y-m.min.y)/2),t==="dutch_corner_overhead"?d.z=.4:d.z=0,p.translate(d.x,d.y,d.z),r.push(p)}h.scene.children.length>1&&(f=h.scene.children[1].geometry,f.scale(c.x,c.y,c.z),f.translate(d.x,d.y,d.z),r.push(f)),i.geometry=ft(r,!0),i.geometry.userData=l},function(h){},function(h){console.log("An error happened when loading model large door")});else i.geometry=ft(r,!0);i.geometry.userData=l}}class _C{constructor(e,t,i){const r={width:e.size.width-1,height:e.size.height-1,depth:e.size.depth},a=e.position,s=new st(r.width+1,r.height+1,r.depth+.4),l=new st(r.width,r.height,r.depth+6),h=new st(r.width+1,r.height+1,r.depth+6),c=new st(r.width,r.height,r.depth+1);s.computeBoundingBox();const d=mt.fromGeometry(s).subtract(mt.fromGeometry(l)).toGeometry(new Ze),p=new si;p.userData.obb=new As().fromBox3(s.boundingBox);const f=new rt(p,t);this.generateInteriorGeometry(r,e.door_type,f,[d,c],i),f.name=e.name,f.position.set(a.x,a.y,a.z),f.userData.obb=new As,f.userData.data=e,f.userData.draggable=!0,this.hole=new rt(h),this.hole.position.set(a.x,a.y,a.z),this.object=f}generateInteriorGeometry(e,t,i,r,a){const s=new Yl,l=i.geometry.userData;if(t in Ft.window)if(t in a){let h={x:1,y:1,z:1},c={x:0,y:0,z:0},d,p;if(a[t].children.length>0){d=a[t].children[0].geometry;let f=new Fi;d.computeBoundingBox(),f.copy(d.boundingBox),h.x=e.width/(f.max.x-f.min.x),h.y=e.height/(f.max.y-f.min.y),h.z=e.depth/(f.max.z-f.min.z),d.scale(h.x,h.y,h.z),f.copy(d.boundingBox),c.x=-(f.max.x-(f.max.x-f.min.x)/2),c.y=-(f.max.y-(f.max.y-f.min.y)/2),c.z=0,d.translate(c.x,c.y,c.z),d.needsUpdate=!0,r.push(d)}a[t].children.length>1&&(p=a[t].children[1].geometry,p.scale(h.x,h.y,h.z),p.translate(c.x,c.y,c.z),p.needsUpdate=!0,r.push(p)),i.geometry=ft(r,!0)}else s.load(Ft.window[t],function(h){a[t]=h.scene;let c={x:1,y:1,z:1},d={x:0,y:0,z:0},p,f;if(h.scene.children.length>0){p=h.scene.children[0].geometry;let m=new Fi;p.computeBoundingBox(),m.copy(p.boundingBox),c.x=e.width/(m.max.x-m.min.x),c.y=e.height/(m.max.y-m.min.y),c.z=e.depth/(m.max.z-m.min.z),p.scale(c.x,c.y,c.z),m.copy(p.boundingBox),d.x=-(m.max.x-(m.max.x-m.min.x)/2),d.y=-(m.max.y-(m.max.y-m.min.y)/2),d.z=0,p.translate(d.x,d.y,d.z),p.needsUpdate=!0,r.push(p)}h.scene.children.length>1&&(f=h.scene.children[1].geometry,f.scale(c.x,c.y,c.z),f.translate(d.x,d.y,d.z),f.needsUpdate=!0,r.push(f)),i.geometry=ft(r,!0),i.geometry.userData=l},function(h){},function(h){console.log("An error happened when loading model window")});else{let h=r.pop();const c=new st(e.width,e.depth/2,e.depth/2);c.translate(0,0,-e.depth/2),r.push(c);const d=new st(e.height,e.depth/2,e.depth/2);d.translate(0,0,-e.depth/2),d.rotateZ(zt[90]),r.push(d),r=ft(r),i.geometry=ft([r,h],!0)}i.geometry.userData=l}}function vC(n,e,t){const i=n.type;let r=[];const a=new vn({color:"red",transparent:!0,opacity:0});a.userData.name="drag";const s=new Dn({color:39321,transparent:!0,opacity:.3,transmission:1,side:xi}),l=new Gd({color:15988468,flatShading:!0,side:xi}),h=new Gd({color:9079433,flatShading:!0,side:xi}),c=e.clone();n.is_valid!==void 0&&!n.is_valid&&(a.opacity=.8);let d=[c,a,l,s,s];switch(i){case"large_door":d=[c,a,l,h,h],r=new gC(n,d,t.large);break;case"window":r=new _C(n,d,t.window);break;case"entry_door":r=new mC(n,d,t.entry);break}return r}class Nc extends rt{constructor(e,t){super(),this.name=t+"_girt",this.generateObj(e)}generateObj(e){const t=e.position,i=new st(e.length,e.width,e.depth),r=new st(e.length+e.depth*2,e.width*2,e.depth*3),a=e.material.clone();a.color.set("grey");let s=i;for(let l=1;l<e.nbGirt;l++){let h=i.clone();h.translate(0,l*e.distance,0),s=ft([s,h])}e.skirtBoardProtection?(this.geometry=ft([s,r],!0),this.material=[e.material,a]):(this.geometry=s,this.material=e.material),this.position.set(t.x,t.y,t.z)}}class Uc extends rt{constructor(e,t){super(),this.name=t+"_pillar",this.generateObj(e)}generateObj(e){const t=e.position,i=new st(e.height,e.width,e.depth).rotateZ(zt[90]);let r=new si;r=i;for(let a=1;a<e.nbPillar;a++){let s=i.clone();s.translate(a*e.distance,0,0),r=ft([r,s])}this.geometry=r,this.material=e.material,this.position.set(t.x,t.y,t.z)}}class zc extends uo{constructor(e,t){const i=new ac(4,4,17),r=new wi({color:39321,transparent:!0,opacity:.5,depthWrite:!0}),a=new st(16,e.depth,e.depth).rotateZ(zt[90]),s=e.material.clone();s.color.set(16777215),i.translate(0,-1,0);const l=ft([a,i],!0),h=[s,r];super(l,h,e.nbPillar),this.instanceMatrix.setUsage(sb),this.name=t+"_wood_rot_protection";let c=new Ze;for(let d=0;d<e.nbPillar;d++)c.setPosition(d*e.distance,0,0),this.setMatrixAt(d,c);this.position.set(e.position.x,-16/2,e.position.z)}}class yC extends rt{constructor(t){super();vt(this,"width",0);vt(this,"length",0);vt(this,"depth",.6);this.name="roof";let i=t.size,r=t.roof,a=Math.abs(Math.sin(Dt[r.raise])),s=Math.abs(Math.cos(Dt[r.raise])),l=Math.abs(Math.tan(Dt[r.raise]));const h={width:i.width/s+r.extend,length:i.length,slopeHeight:r.depth,type:"hight"};if(globalThis.options.roofQuality==="high"){let c={x:-i.length/2,y:i.height+s*r.depth/2,z:0};if(this.geometry=new Dc(h),globalThis.options.snowBar){let d=new st(h.length,h.slopeHeight,h.slopeHeight/2).toNonIndexed();d.translate(h.length/2,h.slopeHeight+h.slopeHeight/2,h.width*.75),this.geometry=ft([this.geometry,d])}this.geometry.rotateX(Dt[r.raise]),this.geometry.translate(c.x,c.y,c.z),this.material=new ta({color:r.color,roughness:.4})}else{let c={x:0,y:i.height-l*i.width/2+s*r.depth/2-r.extend/2*a+.05,z:i.width/2+r.extend/2*s};if(this.geometry=new st(h.length+.1,h.slopeHeight,h.width),globalThis.options.snowBar){let p=new st(h.length,h.slopeHeight,h.slopeHeight/2);p.translate(0,h.slopeHeight,h.width*.75*.5),this.geometry=ft([this.geometry,p])}this.geometry.rotateX(Dt[r.raise]),this.geometry.translate(c.x,c.y,c.z);const d=globalThis.textureImage;d&&d.roof&&d.roof.mapImage?this.material=new wr(r.color,d.roof.mapImage,d.roof.mapImageDisp,d.roof.mapImageNormal,h.length/10,h.width/10):this.material=new wi({color:65535,flatShading:!0})}}}class xC extends uo{constructor(e,t){const i=e.wall,r=e.trim,a=.1,s=new st(e.size.height,r.width,r.width).rotateZ(zt[90]),l=s.clone();l.translate(a,0,a);const h=mt.fromGeometry(s).subtract(mt.fromGeometry(l));let c;const d=globalThis.textureImage;d&&d.trim&&d.trim.mapImage?c=new wr(r.color,d.trim.mapImage,d.trim.mapImageDisp,d.trim.mapImageNormal):c=new wi({color:65535,flatShading:!0}),super(h.toGeometry(new Ze),c,4),this.instanceMatrix.needsUpdate=!0,this.name=t;let p=new ei,f=(e.size.length-r.width)/2,m=(e.size.width-r.width)/2;p.position.set(-f-i.depth-a,0,-m-i.depth-a),p.updateMatrix(),this.setMatrixAt(0,p.matrix),p.position.set(-f-i.depth-a,0,m+i.depth+a),p.rotateY(zt[90]),p.updateMatrix(),this.setMatrixAt(1,p.matrix),p.position.set(f+i.depth+a,0,-m-i.depth-a),p.rotateY(zt[180]),p.updateMatrix(),this.setMatrixAt(2,p.matrix),p.position.set(f+i.depth+a,0,m+i.depth+a),p.rotateY(zt[270]),p.updateMatrix(),this.setMatrixAt(3,p.matrix),this.position.set(0,e.size.height/2,0)}}class bC extends uo{constructor(e,t){const i=e.wall,r=e.trim,a=e.size.height-e.size.roofHeight,s=.1,l=new st(a,r.width,r.width).rotateZ(zt[90]),h=l.clone();h.translate(s,0,s);const c=mt.fromGeometry(l).subtract(mt.fromGeometry(h));let d;const p=globalThis.textureImage;p&&p.trim&&p.trim.mapImage?d=new wr(r.color,p.trim.mapImage,p.trim.mapImageDisp,p.trim.mapImageNormal):d=new wi({color:65535,flatShading:!0}),super(c.toGeometry(new Ze),d,2),this.instanceMatrix.needsUpdate=!0,this.name=t;let f=new ei,m=(e.size.length-r.width)/2,_=e.size.width-r.width/2;f.position.set(-m-i.depth-s,0,_+i.depth+s),globalThis.options.wallQuality==="high"&&f.position.set(-m-i.depth-s,0,_+i.depth*2+s),f.rotateY(zt[90]),f.updateMatrix(),this.setMatrixAt(0,f.matrix),f.position.set(m+i.depth+s,0,_+i.depth+s),globalThis.options.wallQuality==="high"&&f.position.set(m+i.depth+s,0,_+i.depth*2+s),f.rotateY(zt[90]),f.updateMatrix(),this.setMatrixAt(1,f.matrix),this.position.set(0,a/2,0)}}class Fo{constructor(e,t,i=6,r=2,a=0){let s=e.clone();s.rotation=a,s.colorSpace=Bt,s.wrapS=s.wrapT=pr,s.repeat.set(i,r);let l=t.clone();return l.rotation=a,l.colorSpace=Bt,l.wrapS=l.wrapT=pr,l.repeat.set(i,r),new Gd({map:s,bumpMap:l,bumpScale:.005,flatShading:!0})}}new po({color:11184810,transparent:!0,opacity:.8});class Fv{constructor(e){vt(this,"width",0);vt(this,"length",0);vt(this,"depth",.6);vt(this,"material",null);vt(this,"name","");this.name="floor",e.floor,this.width=e.size.width,this.length=e.size.length;const t=globalThis.textureImage;return t&&t.floor&&t.floor.mapImage?this.material=new Fo(t.floor.mapImage,t.floor.mapImageDisp,this.length/50,this.width/50):this.material=new wi({color:65535}),this.generateObject()}generateObject(){let e=new rt(new Sa(this.length+10,this.width+10),this.material);return e.rotateX(-zt[90]),e.position.set(0,.1,0),e.updateMatrix(),e.name=this.name,e}}class kv extends uo{constructor(e,t){const i=e.dimensions,r=e.width/2,a=e.depth/2;e.material.map.repeat.set(i.width/e.depth,1),e.material.bumpMap.repeat.set(i.width/e.depth,1);const s=e.nbPurlin,l=e.distance;let h=i.pitch;const c=Math.abs(Math.tan(h));let d=c*i.width,p=[-r-.01,a+.01,r+.01,a+.01,r+.01,-a-.01,-r-.01,-a-.01,-r-.01,a+.01],f=[-r,a,r,a,r,-a,-r,-a,-r,a];e.isFullWidth&&(d=d/2);let m=[],_=[],x=!1;e.isFullWidth?(m.push(-i.width/2),m.push(0),m.push(i.width/2),m.push(0),m.push(i.width/2),m.push(r/2),m.push(0),m.push(d+r/2),m.push(-i.width/2),m.push(r/2),x=!0,_.push(-i.width*.4),_.push(c*.1*i.width+c*r/2),_.push(-i.width*.3-r/2),_.push(0),_.push(-i.width*.3+r/2),_.push(0),_.push(-i.width*.2-r/2),_.push(c*.3*i.width-c*r/2),_.push(-i.width*.2+r/2),_.push(c*.3*i.width+c*r/2),_.push(-i.width*.1-r/2),_.push(0),_.push(-i.width*.1+r/2),_.push(0),_.push(-r/2),_.push(d),_.push(r/2),_.push(d),_.push(i.width*.1-r/2),_.push(0),_.push(i.width*.1+r/2),_.push(0),_.push(i.width*.2-r/2),_.push(c*.3*i.width+c*r/2),_.push(i.width*.2+r/2),_.push(c*.3*i.width-c*r/2),_.push(i.width*.3-r/2),_.push(0),_.push(i.width*.3+r/2),_.push(0),_.push(i.width*.4),_.push(c*.1*i.width+c*r/2)):(m.push(0),m.push(0),m.push(i.width),m.push(0),m.push(i.width),m.push(r/2),m.push(0),m.push(d+r/2),x=!0);let y=[];_.length>0&&(y=Ba(f,_,!1,!1));let v=Ba(p,m,x,!1),M=ft(v);if(y.length>0){let S=ft(y);M=ft([M,S])}super(M,e.material,s);let b=new Ze;this.updateMatrix();for(let S=0;S<s;S++)b.setPosition(0,0,S*l),this.setMatrixAt(S,b);this.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),this.position.set(e.position.x,e.position.y,e.position.z),this.name=t+"_purlin"}}class wC extends rt{constructor(t){super();vt(this,"width",1.2);vt(this,"length",0);vt(this,"raise",0);vt(this,"height",0);vt(this,"material",null);const i=t.size,r=t.roof,a=t.trim,s=t.wall,l=t.position;this.raise=r.raise;const h=globalThis.textureImage;h&&h.trim&&h.trim.mapImage?this.material=new wr(a.color,h.trim.mapImage,h.trim.mapImageDisp,h.trim.mapImageNormal,this.length/this.width,1,1.57):this.material=new wi({color:65535,flatShading:!0}),this.material.side=xi,this.material.flatShading=!0;let c,d,p={x:l.x,y:l.y+r.depth,z:s.depth/2+.05};globalThis.options.roofQuality==="high"&&(p.y+=r.depth/2,p.z+=r.depth/2,l.y=l.y+r.depth/2),c=this.generateTop(p,i),i.leftExtend&&i.leftExtend>0&&(l.x=-i.length/2,d=this.generateCorner(l,i,r.extend)),d?this.geometry=ft([c,d]):this.geometry=c}generateTop(t,i){const r=Dt[this.raise]+Math.PI/2,a=Math.abs(Math.sin(r)),s=Math.abs(Math.cos(r)),l=this.width/2;let h=[];h.push(new pe(0,l)),h.push(new pe(0,0)),h.push(new pe(-l*a,-l*s));let c=h.length,d;d=new Sa(1,i.length,c-1,2),d.rotateX(Math.PI*.5);let p=d.getAttribute("position");for(let f=0;f<p.count;f++){let m=f%c;p.setXY(f,h[m].x,h[m].y)}return d.computeVertexNormals(),d.rotateY(Math.PI/2),d.translate(0,t.y,t.z),d}generateCorner(t,i,r){const a=Math.abs(Math.cos(Dt[this.raise])),s=Math.atan(i.roofHeight/(i.width*1.41421)),l=(i.width/a+r-.5)*1.41421,h=Math.tan(s)*this.width,c=this.width;let d=[];d.push(new pe(c,0)),d.push(new pe(0,h)),d.push(new pe(-c,0));let p=d.length,f=new Sa(1,l,p-1,2);f.rotateX(Math.PI/2);let m=f.getAttribute("position");for(let y=0;y<m.count;y++){let v=y%p;m.setXY(y,d[v].x,d[v].y)}f.rotateX(s),f.rotateY(-Math.PI/4),f.computeBoundingBox();const _=f.boundingBox.min,x=f.boundingBox.max;return f.translate(t.x-(x.x-_.x)/2+this.width,t.y-(x.y-_.y)/2+h+.5-.08*this.raise,(x.z-_.z)/2-this.width),f}}class MC extends rt{constructor(e,t){super();const i=e.size;e.wall;const r=e.roof,a=e.trim,s=Dt[r.raise],l=Math.abs(Math.cos(s));Math.abs(Math.tan(s))*i.width;const h=r.extend,c=a.roofDepth,d=i.leftExtend??0,p=i.rightExtend??0,f=1,m=h,_=i.width/l+m,x=d?h:0,y=p?h:0,v=f+d+p+(x+y);var M=[-c*.72,c,c/2,c,c/2,-c*.75,-c*.39,-c,-c*.72,c];let b=[-(i.length+v)/2,0,-(i.length+v)/2,_,(i.length+v)/2,_,(i.length+v)/2,0];p&&d?b=[-(i.length+v)/2,_,(i.length+v)/2,_]:d?b=[-(i.length+v)/2,_,(i.length+v)/2,_,(i.length+v)/2,0]:p&&(b=[-(i.length+v)/2,0,-(i.length+v)/2,_,(i.length+v)/2,_]),(i.length+v)/2-.05,-(i.length+v)/2+.05;const S=globalThis.textureImage;let A,T=new wi({color:65535});S&&S.trim&&S.trim.mapImage&&(A=new wr(a.color,S.wall.mapImage,S.wall.mapImageDisp,S.wall.mapImageNormal,i.length/4/m,.5),A.flatShading=!0,T=new wr(a.color,S.trim.mapImage,S.trim.mapImageDisp,S.trim.mapImageNormal),T.flatShading=!0),this.material=[T,A];const E=ft(Ba(M,b,!1,!1));E.rotateX(Math.PI/2+s),E.translate(0,c/4/l,0),this.geometry=ft([E],!0),this.name=t,this.position.set((p-d+(y-x))/2,i.height,0)}}class TC extends yn{constructor(e,t,i){super(),e.position&&this.translateX(e.position.x);const r=t.pillar,a=t.purlin,s=t.girt,l=t.trim,h=t.floor,c=t.roof,d=t.wall;t.options;const p=Dt[c.raise],f=Math.abs(Math.tan(p))*e.size.width,m=(e.connected.rightExtend-e.connected.leftExtend)/2,_=e.size.height-l.roofDepth,x=e.size.length,y=e.size.width;let v=Math.floor(x/Mo)+1;const M=(x-d.depth-s.depth-r.width)/(v-1);if(r.enable){let b={nbPillar:v,distance:M,width:r.width,depth:r.width,height:_-r.width/2,position:{x:(-x+r.width+s.depth+d.depth)/2,y:(_-r.width)/2+r.width/4,z:r.width/2+d.depth},rotation:{x:0,y:0,z:0},material:r.material};b.height=_-f,b.position.z=y-r.width/2-s.depth,b.position.y=(_-f)/2,this.add(new Uc(b,"outer_lean_to")),this.add(new zc(b,"outer_lean_to")),b.nbPillar=1,e.connected.leftExtend&&(b.position.x=(-x+r.width+s.depth+d.depth)/2-e.connected.leftExtend,this.add(new Uc(b,"outer_lean_to")),this.add(new zc(b,"outer_lean_to"))),e.connected.rightExtend&&(b.position.x=-(-x+r.width+s.depth+d.depth)/2+e.connected.rightExtend,this.add(new Uc(b,"outer_lean_to")),this.add(new zc(b,"outer_lean_to")))}if(s.enable){const b=Math.floor((_-f)/10);let S={nbGirt:b,skirtBoardProtection:s.skirtBoardProtection,distance:10,width:s.width,depth:s.depth,length:x-d.depth+e.connected.leftExtend+e.connected.rightExtend,position:{x:0,y:0,z:y-(s.depth+d.depth)/2},material:s.material};e.openType.front!=="open"&&e.openType.front!=="open_bottom"&&(S.nbGirt=b,this.add(new Nc(S,"front_lean_to").translateX(m))),S.length=y-d.depth,S.position.z=y/2,S.nbGirt=b,!e.connected.leftExtend&&e.openType.left!=="open"&&e.openType.left!=="open_bottom"&&(S.position.x=-x/2+(s.depth+d.depth)/2,this.add(new Nc(S,"left_lean_to").rotateY(Math.PI/2))),!e.connected.rightExtend&&e.openType.right!=="open"&&e.openType.right!=="open_bottom"&&(S.position.x=x/2-(s.depth+d.depth)/2,this.add(new Nc(S,"right_lean_to").rotateY(Math.PI/2)))}if(a.enable){let b={dimensions:{width:y-(a.depth+s.depth+d.depth),pitch:p},isFullWidth:!1,nbPurlin:v,distance:M,width:a.width,depth:a.depth,rotation:{x:0,y:zt[270],z:0},position:{x:(x-a.width-d.depth-s.depth)/2,y:_-f-(a.depth+c.depth)/2,z:(a.depth+s.depth)/2},material:a.material};this.add(new kv(b,"lean_to"))}if(d.enable){let b={isFullWidth:!0,side:"",openType:"",dimensions:{width:0,height:0,raise:0},color:d.color,depth:d.depth,position:{x:0,y:0,z:0}};b.openType=e.openType.front,b.dimensions.width=x+e.connected.leftExtend+e.connected.rightExtend,b.dimensions.height=_-f,b.position.z=y,b.side="front",globalThis.options.wallQuality==="high"&&(b.position.x=-b.dimensions.width/2,b.position.z=y+b.depth);const S=new Ic(b,"front_lean_to");if(S.translateX(m),this.add(S),b.openType=e.openType.left,b.isFullWidth=!1,b.dimensions.width=y,b.dimensions.raise=c.raise,b.position.x=-x/2,b.position.z=0,b.side="left",globalThis.options.wallQuality==="high"&&(b.position.x=-x/2-b.depth/2,b.position.z=b.dimensions.width),!e.connected.leftExtend){const A=new Ic(b,"left_lean_to");A.rotateY(Math.PI/2),this.add(A)}if(!e.connected.rightExtend){b.openType=e.openType.right,b.position.x=x/2,b.side="right",globalThis.options.wallQuality==="high"&&(b.position.x=x/2,b.position.z=b.dimensions.width);const A=new Ic(b,"right_lean_to");A.rotateY(Math.PI/2),this.add(A)}}if(c.enable){c.leftExtend=e.connected.leftExtend,c.rightExtend=e.connected.rightExtend;const b=e.connected.leftExtend?c.extend:0,S=e.connected.rightExtend?c.extend:0;let A={size:{length:x+e.connected.leftExtend+e.connected.rightExtend+b+S,width:y,height:_},roof:c,girt:{depth:s.depth}},T=new yC(A);const E=y*1.41421*1.2;if(e.connected.leftExtend){let I=new rt(new st(E,E,E,4,4,4),new wi({color:"red",wireframe:!0}));I.rotateY(zt[45]),I.position.set(-A.size.length/2-1.41421*E/2+b+e.connected.leftExtend,A.size.height,0),I.updateMatrix(),T=mt.subtract(T,I)}if(e.connected.rightExtend){let I=new rt(new st(E,E,E,4,4,4),new wi({color:"white",wireframe:!0}));I.rotateY(-zt[45]),I.position.set(A.size.length/2+1.41421*E/2-S-e.connected.rightExtend,A.size.height,0),I.updateMatrix(),T=mt.subtract(T,I)}T.name="leanto_roof",this.add(T.translateX(m+(S-b)/2))}if(l.enable){let b={size:{length:x+e.connected.leftExtend+e.connected.rightExtend,width:y,height:_,roofHeight:f},trim:l,wall:d};if(this.add(new bC(b,"lean_to").translateX(m)),c.enable){let S={size:{leftExtend:e.connected.leftExtend,rightExtend:e.connected.rightExtend,width:y,height:_,length:x,roofHeight:f},position:{x:x/2,y:_+Dv(.01,.05),z:0},trim:l,roof:c,wall:d};this.add(new wC(S)),this.add(new MC(Vt.cloneDeep(S),"lean_to_roof_trim"))}}if(h.enable){let b={size:{length:x+e.connected.leftExtend+e.connected.rightExtend,width:y-10},floor:h,wall:d};const S=new Fv(b,"lean_to");S.position.set(m,.1+Dv(.01,.05),(y+10)/2),this.add(S)}this.userData.type="lean_to",this.userData.data=e,this.userData.roofConfig=c}}class SC extends ei{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new pe(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof Element&&t.element.parentNode!==null&&t.element.parentNode.removeChild(t.element)})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const ko=new z,Hv=new Ze,Gv=new Ze,Vv=new z,Wv=new z;class EC{constructor(e={}){const t=this;let i,r,a,s;const l={objects:new WeakMap},h=e.element!==void 0?e.element:document.createElement("div");h.style.overflow="hidden",this.domElement=h,this.getSize=function(){return{width:i,height:r}},this.render=function(m,_){m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),_.parent===null&&_.matrixWorldAutoUpdate===!0&&_.updateMatrixWorld(),Hv.copy(_.matrixWorldInverse),Gv.multiplyMatrices(_.projectionMatrix,Hv),c(m,m,_),f(m)},this.setSize=function(m,_){i=m,r=_,a=i/2,s=r/2,h.style.width=m+"px",h.style.height=_+"px"};function c(m,_,x){if(m.isCSS2DObject){ko.setFromMatrixPosition(m.matrixWorld),ko.applyMatrix4(Gv);const y=m.visible===!0&&ko.z>=-1&&ko.z<=1&&m.layers.test(x.layers)===!0;if(m.element.style.display=y===!0?"":"none",y===!0){m.onBeforeRender(t,_,x);const M=m.element;M.style.transform="translate("+-100*m.center.x+"%,"+-100*m.center.y+"%)translate("+(ko.x*a+a)+"px,"+(-ko.y*s+s)+"px)",M.parentNode!==h&&h.appendChild(M),m.onAfterRender(t,_,x)}const v={distanceToCameraSquared:d(x,m)};l.objects.set(m,v)}for(let y=0,v=m.children.length;y<v;y++)c(m.children[y],_,x)}function d(m,_){return Vv.setFromMatrixPosition(m.matrixWorld),Wv.setFromMatrixPosition(_.matrixWorld),Vv.distanceToSquared(Wv)}function p(m){const _=[];return m.traverse(function(x){x.isCSS2DObject&&_.push(x)}),_}function f(m){const _=p(m).sort(function(y,v){if(y.renderOrder!==v.renderOrder)return v.renderOrder-y.renderOrder;const M=l.objects.get(y).distanceToCameraSquared,b=l.objects.get(v).distanceToCameraSquared;return M-b}),x=_.length;for(let y=0,v=_.length;y<v;y++)_[y].element.style.zIndex=x-y}}}class Bc extends tc{constructor(e){super();const t=new po({color:"#fff"});this.material=t,this.name=e}updateLine(e=[]){this.geometry.dispose(),this.geometry=new si().setFromPoints(e)}}class Fc extends SC{constructor(e){var r,a;super();const t=`distance-${e}`;this.name=e,(a=(r=document.getElementById(t))==null?void 0:r.parentElement)==null||a.remove();const i=document.createElement("span");i.id=`distance-${e}`,this.element.style.backgroundColor="#4682b4",this.element.style.borderRadis="2px",this.element.style.fontSize="12px",this.element.style.minWidth="24px",this.element.style.textAlign="center",this.element.appendChild(i)}}class AC extends yn{constructor(e,t){super(),this.name=t+"_side",this.initData(e,t)}initData(e,t){this.userData.data=e;const i=[];let r,a,s,l,h;const c=e.wallData.dimensions,d=e.doorData.material;for(e.doorData.doorList.length>0&&e.doorData.doorList.forEach(b=>{const S=vC(b,d,e.doorData.models);S.object&&(S.object.userData.wallSize=c,S.object.name=b.name+"_"+b.id,this.add(S.object),i.push(S.hole))}),e.wallData.enable&&(r=new Ic(e.wallData,t)),e.frame.enable&&(a=new Nc(e.girtData,t),s=new Uc(e.pillarData,t),l=new zc(e.pillarData,t)),e.leanToData.list.length>0&&e.leanToData.list.forEach(b=>{h=new TC(b,e.leanToData.config,i)}),e.general.isRender&&i.length>0&&i.forEach(b=>{b.updateMatrix(),r instanceof rt&&(r.updateMatrix(),r=mt.subtract(r,b)),a instanceof rt&&(a.updateMatrix(),a=mt.subtract(a,b)),s instanceof rt&&(s.updateMatrix(),s=mt.subtract(s,b))});i.length>0;)i.pop();s&&this.add(s),l&&this.add(l),a&&this.add(a),r&&(r.name=t+"_wall",r.userData.side=t,this.add(r)),h&&this.add(h);const p=new Bc("left-line");this.add(p);const f=new Bc("right-line");this.add(f);const m=new Bc("top-line");this.add(m);const _=new Bc("bottom-line");this.add(_);const x=new Fc("left-text");this.add(x);const y=new Fc("right-text");this.add(y);const v=new Fc("top-text");this.add(v);const M=new Fc("bottom-text");this.add(M)}}class RC extends rt{constructor(t){super();vt(this,"width",0);vt(this,"length",0);vt(this,"depth",.6);vt(this,"raise",0);vt(this,"extend",0);vt(this,"material",null);this.name="roof";let i=t.size,r=t.roof;this.raise=r.raise;let a=1,s=1;globalThis.options.overhang.eaveSide&&(s=r.extend),globalThis.options.overhang.grableEnd&&(a=r.extend*2);let l=Math.abs(Math.sin(Dt[this.raise])),h=Math.abs(Math.cos(Dt[this.raise])),c=Math.abs(Math.tan(Dt[this.raise]));this.width=i.width/2/h+s,this.length=i.length+a,this.depth=r.depth;const d={width:this.width,length:this.length,slopeHeight:this.depth,type:"hight"};if(globalThis.options.roofQuality==="high"){let p={x:-this.length/2,y:i.height+c*i.width/2+h*t.frame.girt.depth+h*this.depth+.05,z:0},f=new Dc(d),m=new Dc(d);if(t.options.snowBar){let _=new st(this.length,this.depth,this.depth).toNonIndexed();_.translate(this.length/2,this.depth*2,this.width*.75),f=ft([f,_]),m=ft([m,_])}f.rotateX(Dt[r.raise]),f.translate(p.x,p.y,p.z),m.rotateX(Dt[r.raise]),m.rotateY(zt[180]),m.translate(-p.x,p.y,-p.z),this.geometry=ft([f,m]),this.material=new ta({color:r.color,roughness:.4,side:xi,flatShading:!0})}else{let p={x:0,y:i.height+c*i.width/4+h*t.frame.girt.depth+h*this.depth/2-s/2*l+.05,z:i.width/4+s/2*h},f=new st(this.length+.1,this.depth,this.width),m=new st(this.length+.1,this.depth,this.width);if(t.options.snowBar){let x=new st(this.length,this.depth,this.depth);x.translate(0,this.depth,this.width*.75*.5),f=ft([f,x]),x.translate(0,0,-this.width*.75),m=ft([m,x])}f.rotateX(Dt[r.raise]),f.translate(p.x,p.y,p.z),m.rotateX(-Dt[r.raise]),m.translate(-p.x,p.y,-p.z),this.geometry=ft([f,m]);const _=globalThis.textureImage;_&&_.roof&&_.roof.mapImage?this.material=new wr(r.color,_.roof.mapImage,_.roof.mapImageDisp,_.roof.mapImageNormal,this.length/10,this.width/10):this.material=new wi({color:65535,flatShading:!0})}}}class CC{constructor(e){vt(this,"size","");this.width=Q_[e.size].width,this.height=Q_[e.size].width*1;const t=globalThis.textureImage;t&&t.cupola&&t.cupola.roof&&t.cupola.roof.mapImage?this.roofMaterial=new wr(e.roofTexture.color,t.cupola.roof.mapImage,t.cupola.roof.mapImageDisp,t.cupola.roof.mapImageNormal,this.width,this.width):this.roofMaterial=new wi({color:65535}),t&&t.cupola&&t.cupola.wall&&t.cupola.wall.mapImage?this.wallMaterial=new Fo(t.cupola.wall.mapImage,t.cupola.wall.mapImageDisp,this.width/this.height,1):this.wallMaterial=new wi({color:65535});const i=this.generateObject(e.position,e.eagleWeatherwave);return i.userData.data=e,i.userData.type="cupola",i}generateObject(e,t){const i=new rt,r={depth:this.height,bevelEnabled:!1},a=this.width*.75,s=a*.75,l=this.width/2,h=new fo().moveTo(-l-.2,-l-.2).lineTo(-l+1.2,-l-.2).lineTo(-l+1.2,-l).lineTo(l-1.2,-l).lineTo(l-1.2,-l-.2).lineTo(l+.2,-l-.2).lineTo(l+.2,-l+1.2).lineTo(l,-l+1.2).lineTo(l,l-1.2).lineTo(l+.2,l-1.2).lineTo(l+.2,l+.2).lineTo(l-1.2,l+.2).lineTo(l-1.2,l).lineTo(-l+1.2,l).lineTo(-l+1.2,l+.2).lineTo(-l-.2,l+.2).lineTo(-l-.2,l-1.2).lineTo(-l,l-1.2).lineTo(-l,-l+1.2).lineTo(-l-.2,-l+1.2).lineTo(-l-.2,-l-.2),c=new fo().moveTo(-l+1,-l+1).lineTo(l-1,-l+1).lineTo(l-1,l-1).lineTo(-l+1,l-1).lineTo(-l+1,-l+1);h.holes.push(c);const d=new go(h,r),p=new rt(new st(this.width+.75,this.width+1,.75),this.wallMaterial),f=new rt(new st(this.width+1.5,this.width+2,.75),this.wallMaterial);p.translateZ(this.height-s-.75),f.translateZ(this.height-s);let m=new rt(d,this.wallMaterial);const _=new rt(new st(this.width+2,a,s)),x=new rt(new st(a,this.width+2,s));_.translateZ(this.height-4*s/8),x.translateZ(this.height-4*s/8);let y=new rt(new Fd(this.width,this.width*.7,4,1,!1,zt[45]),this.roofMaterial);const v=new rt(new st(this.width*1.3,this.width*.7,this.width*1.3),this.roofMaterial),M=new st(a,.1,.1),b=M.clone();b.translate(0,a/4,0);const S=M.clone();S.translate(0,-a/4,0);let A=ft([M,b,S]);A.translate(0,0,-.2),A=ft([A,A.clone().rotateZ(zt[90])]);const T=new st(a,s,.2);A=ft([A,T],!0);const E=new uo(A,[this.wallMaterial,new wi({color:39321,transparent:!0,opacity:.5,depthWrite:!0})],4);E.rotateX(zt[90]);const I=new Ze;if(I.setPosition(0,this.height-4*s/8,this.width/2),E.setMatrixAt(0,I),I.makeRotationX(zt[180]),I.setPosition(0,this.height-4*s/8,-this.width/2),E.setMatrixAt(1,I),I.makeRotationY(zt[90]),I.setPosition(this.width/2,this.height-4*s/8,0),E.setMatrixAt(2,I),I.makeRotationY(-zt[90]),I.setPosition(-this.width/2,this.height-4*s/8,0),E.setMatrixAt(3,I),E.updateMatrix(),v.updateMatrix(),v.translateY(-.5),v.updateMatrix(),_.updateMatrix(),x.updateMatrix(),m=mt.subtract(m,_),m=mt.subtract(m,x),y=mt.intersect(y,v),y.rotateX(zt[90]),y.translateY(this.height+this.width*.7/2),t){let C=this.generateWeatherVane();i.add(C)}return i.add(m),i.add(E),i.add(y),i.add(p),i.add(f),i.rotateX(-zt[90]),i.translateX(e.x),i.translateY(e.z),i.translateZ(e.y-1),i.updateMatrix(),i}generateWeatherVane(){let e=new rt,t=this.height+this.width*.7/2-.5;this.width;const i=new Yl;if(globalThis.extraModel.eagleWeatherwave){e.geometry=globalThis.extraModel.eagleWeatherwave.clone();let r={x:0,y:0,z:0},a=new Fi;e.geometry.computeBoundingBox(),a.copy(e.geometry.boundingBox);let s=15,l={x:s,y:s,z:s};e.geometry.scale(l.x,l.y,l.z),a.copy(e.geometry.boundingBox),r.y=t+(a.max.z-a.min.z)/2,e.geometry.translate(r.x,r.y,r.z),e.geometry.rotateX(zt[90]),e.geometry.needsUpdate=!0}else i.load($d.weathervane,function(r){if(r.scene.children.length>0){globalThis.extraModel.eagleWeatherwave=r.scene.children[0].geometry.clone(),e.geometry=r.scene.children[0].geometry;let a={x:0,y:0,z:0};e.geometry=r.scene.children[0].geometry;let s=new Fi;e.geometry.computeBoundingBox(),s.copy(e.geometry.boundingBox);let l=15,h={x:l,y:l,z:l};e.geometry.scale(h.x,h.y,h.z),s.copy(e.geometry.boundingBox),a.y=t+(s.max.z-s.min.z)/2,e.geometry.translate(a.x,a.y,a.z),e.geometry.rotateX(zt[90]),e.geometry.needsUpdate=!0}},function(r){},function(r){console.log("An error happened when loading weather vane model")});return e.material=new wi({color:9079433}),e}}new po({color:11184810,transparent:!0,opacity:.8});class LC{constructor(e,t,i,r){vt(this,"width",0);vt(this,"length",0);vt(this,"depth",.6);vt(this,"offset",2);vt(this,"distance",0);vt(this,"material",null);vt(this,"name","");vt(this,"isTransparent",!1);this.name=e,this.type=i;let a=t.size,s=t.frame;this.width=s.girt.width,this.depth=s.girt.depth;let l=t.wall.depth;this.isTransparent=t.general.isTransparent;let h={x:0,y:0,z:0},c={x:0,y:0,z:0};const d=Math.abs(Math.cos(Dt[t.roof.raise]));this.length=a.length-l*2;let p=a.width/2/d-this.offset*2;this.nbGirt=p/10,this.distance=p/this.nbGirt,h.y=a.height,h.z=a.width/2,c.x=-(zt[90]-Dt[t.roof.raise]);const f=globalThis.textureImage;return f&&f.frame&&f.frame.mapImage?this.material=new Fo(f.frame.mapImage,f.frame.mapImageDisp,this.length/this.depth,1):this.material=new wi({color:65535}),this.generateObject(h,c,r)}generateObject(e,t,i){const r=new st(this.length,this.width,this.depth);r.translate(0,this.offset,0);let a=r;for(let c=1;c<this.nbGirt;c++){let d=r.clone();d.translate(0,c*this.distance,0),a=ft([a,d])}let s=a.clone();a.rotateX(t.x),a.rotateY(t.y),a.rotateZ(t.z),a.translate(e.x,e.y,e.z),s.rotateX(-t.x),s.rotateY(-t.y),s.rotateZ(-t.z),s.translate(-e.x,e.y,-e.z);let l=ft([a,s]),h=new rt(l,this.material);return h.name=this.name,h.updateMatrix(),h}}class PC extends rt{constructor(e,t){super();const i=e.size;e.wall;const r=e.roof,a=e.trim,s=Dt[r.raise],l=Math.abs(Math.sin(s)),h=Math.abs(Math.cos(s)),c=Math.abs(Math.tan(s))*i.width/2,d=r.extend,p=a.roofDepth;let f=1,m=1;globalThis.options.overhang.eaveSide&&(m=d),globalThis.options.overhang.grableEnd&&(f=d*2);var _=[-p,p/2,p,p/2,p,-p/2,-p,-p/2,-p,p/2],x=[-p/2,m/2,p/2,m/2,p/2,-m/2,-p/2,-m/2,-p/2,m/2],y=[-p/2,f/4,p/2,f/4,p/2,-f/4,-p/2,-f/4,-p/2,f/4];let v=[-(i.width+p)/2-m*h,0,0,c+l*m,(i.width+p)/2+m*h,0],M=[-(i.length+f+p)/2+.05,0,(i.length+f+p)/2-.05,0],b=[-i.width/2,0,0,c-p/4,i.width/2,0],S=[(i.length+f)/2-.05,0,-(i.length+f)/2+.05,0];const A=globalThis.textureImage;let T,E,I=new wi({color:65535});A&&A.trim&&A.trim.mapImage&&(T=new wr(a.color,A.wall.mapImage,A.wall.mapImageDisp,A.wall.mapImageNormal,i.length/m,1),T.flatShading=!0,E=new wr(a.color,A.wall.mapImage,A.wall.mapImageDisp,A.wall.mapImageNormal,i.width/2/h/f,1),E.flatShading=!0,I=new wr(a.color,A.trim.mapImage,A.trim.mapImageDisp,A.trim.mapImageNormal),I.flatShading=!0),this.material=[T,E,I];const C=ft(Ba(_,v,!1,!1));C.rotateY(zt[90]),C.computeBoundingBox(),C.translate(i.length/2+f/2,c-C.boundingBox.max.y,0);const P=C.clone();P.rotateY(Math.PI);const X=ft(Ba(y,b,!1,!1));X.rotateY(zt[90]),X.computeBoundingBox(),X.translate(i.length/2+f/4,c-X.boundingBox.max.y-p/h,0);const q=X.clone();q.rotateY(Math.PI);const te=ft(Ba(_,M,!1,!1));te.rotateX(s),te.computeBoundingBox(),te.translate(0,C.boundingBox.min.y-te.boundingBox.min.y-.01,-(te.boundingBox.max.z-te.boundingBox.min.z)/2-C.boundingBox.min.z-.01);const k=te.clone();k.rotateY(Math.PI);const H=ft(Ba(x,S,!1,!1));H.rotateX(s),H.computeBoundingBox(),H.translate(0,-(H.boundingBox.max.y-H.boundingBox.min.y)/2-p/h+.1,i.width/2+(H.boundingBox.max.z-H.boundingBox.min.z)/2-.1);const V=H.clone();V.rotateY(Math.PI);const J=ft([H,V]),ie=ft([X,q]),$=ft([C,P,te,k]);this.geometry=ft([J,ie,$],!0),this.name=t,this.position.set(0,i.height+1.7,0)}}class DC extends rt{constructor(t){super();vt(this,"width",1.2);vt(this,"length",0);vt(this,"raise",0);vt(this,"height",0);vt(this,"material",null);let i=t.size,r=t.roof,a=t.trim;this.raise=r.raise,Math.abs(Math.sin(Dt[this.raise]));let s=Math.abs(Math.cos(Dt[this.raise])),l=Math.abs(Math.tan(Dt[this.raise]));globalThis.options.overhang.grableEnd?this.length=i.length+r.extend*2:this.length=i.length,this.height=l*this.width;const h=globalThis.textureImage;h&&h.trim&&h.trim.mapImage?this.material=new wr(a.color,h.trim.mapImage,h.trim.mapImageDisp,h.trim.mapImageNormal,this.length/this.width,1,1.57):this.material=new wi({color:65535,flatShading:!0}),this.material.side=xi,this.material.flatShading=!0;let c=s*t.frame.girt.depth-this.height+s*r.depth*1.5;globalThis.options.roofQuality==="high"&&(c=s*t.frame.girt.depth-this.height+s*r.depth*3);let d={x:0,y:i.height+l*i.width/2+c,z:0},p={x:0,y:0,z:0};return this.generateObject(d,p)}generateObject(t,i){var r=[];r.push(new pe(this.width,0)),r.push(new pe(0,this.height)),r.push(new pe(-this.width,0));var a=r.length;this.geometry=new Sa(1,this.length,a-1,2),this.geometry.rotateX(Math.PI*.5);var s=this.geometry.getAttribute("position");for(let l=0;l<s.count;l++){let h=l%a,c=r[h].x,d=r[h].y;s.setXY(l,c,d)}this.geometry.computeVertexNormals(),this.geometry.rotateY(Math.PI/2),this.geometry.translate(0,t.y,0)}}class IC{constructor(e,t,i,r,a=6,s=2,l=0){let h=t.clone();h.rotation=l,h.colorSpace=Bt,h.wrapS=h.wrapT=pr,h.repeat.set(a,s);let c=i.clone();c.rotation=l,c.colorSpace=Bt,c.wrapS=c.wrapT=pr,c.repeat.set(a,s);let d=r.clone();return d.rotation=l,d.colorSpace=Bt,d.wrapS=d.wrapT=pr,d.repeat.set(a,s),new ta({color:e,bumpScale:.005,flatShading:!0,map:h,bumpMap:c,normalMap:d,normalScale:new pe(1,1)})}}class OC extends yn{constructor(e){super(),this.init(e)}init(e){if(this.textureImage=globalThis.textureImage,this.generateWallSide(e,"front"),this.generateWallSide(e,"left"),this.generateWallSide(e,"right"),this.generateWallSide(e,"back"),e.roof.enable){const t=new RC(e);this.add(t)}if(e.trim.enable){if(e.roof.enable){const i=new DC(e);this.add(i);const r=new PC(e,"roof_trim");this.add(r)}const t=new xC(e,"coner");this.add(t)}if(e.frame.enable){const t=new LC("roofGirt",e,"roof");this.add(t);let i=e.frame.purlin.depth+e.frame.girt.depth+e.wall.depth,r=(Math.floor(e.size.length/Mo)+1)*2-1,a=(e.size.length-i)/(r-1),s=new wi({color:65535,side:xi,wireframe:!1});this.textureImage.frame.mapImage&&(s=new Fo(this.textureImage.frame.mapImage,this.textureImage.frame.mapImageDisp));let l={dimensions:{width:e.size.width-(e.wall.depth+e.frame.girt.depth)*4,pitch:Dt[e.roof.raise]},isFullWidth:!0,nbPurlin:r,distance:a,width:e.frame.purlin.width,depth:e.frame.purlin.depth,rotation:{x:0,y:zt[90],z:0},position:{x:-(e.size.length-i)/2,y:e.size.height-e.frame.purlin.depth/2,z:0},material:s};const h=new kv(l,"purlin");this.add(h)}if(e.cupola.length>0){let t=Math.abs(Math.tan(Dt[e.roof.raise]))*e.size.width/2+e.size.height,i=e.size.length/(e.cupola.length+1);e.cupola.forEach((r,a)=>{r.id===""&&(r.id=Pc()),r.position.x=-(e.cupola.length-1)*.5*i+a*i,r.position.y=t,this.add(new CC(r))})}if(e.floor.enable){const t=new Fv(e);this.add(t)}this.objectCastShadow(e.general.isShadow),e.general.isTransparent&&this.traverse(function(t){t instanceof rt&&t.material&&t.position&&(t.material.depthTest=!1,t.material.opacity=.25,t.material.transparent=!0)})}generateWallSide(e,t){const i=new wi({color:65535}),r={x:0,y:0,z:0},a={x:0,y:0,z:0},s=e.size.height/10,l=e.size.height/s;let h={nbPillar:0,width:e.frame.pillar.width,depth:e.frame.pillar.depth,distance:0,height:e.size.height,position:{x:0,y:e.size.height/2,z:-(e.frame.pillar.width+e.frame.girt.depth+e.wall.depth)/2},rotation:{x:0,y:0,z:0},material:i},c={nbGirt:s,skirtBoardProtection:e.options.skirtBoardProtection,distance:l,width:e.frame.girt.width,depth:e.frame.girt.depth,length:0,position:{x:0,y:0,z:-(e.frame.girt.depth+e.wall.depth)/2},material:i};e.wall.openType[t]==="open"&&(c.nbGirt=0);let d={enable:e.wall.enable,isFullWidth:e.wall.isFullWidth,openType:e.wall.openType[t],dimensions:{width:0,height:0,raise:0},color:e.wall.color,depth:e.wall.depth,position:{x:0,y:0,z:0}};const p={material:i,models:e.door.models,doorList:[]};p.models.texturePath=e.general.texturePath,p.doorList=e.doors.filter(v=>{if(v.side==t&&e.wall.openType[t]!=="open"&&(e.door.main.enable&&v.type==="large_door"||e.door.entry.enable&&v.type==="entry_door"))return v.position.z=d.position.z+v.position.z,v.id===""&&(v.id=Pc()),v});let f=e.windows.filter(v=>{if(v.side==t&&e.wall.openType[t]!=="open"&&e.door.window.enable&&v.type==="window")return v.position.z=d.position.z+v.position.z,v.id===""&&(v.id=Pc()),v});Array.prototype.push.apply(p.doorList,f),p.doorList.sort((v,M)=>v.position.x-M.position.x);const m={enable:e.frame.enable};let _;switch(t){case"front":d.dimensions.width=e.size.width,d.dimensions.height=e.size.height,d.dimensions.raise=e.roof.raise,a.x=e.size.length/2,r.y=Math.PI/2;const v=Math.abs(Math.tan(Dt[e.roof.raise]))*e.size.width/2;e.logo.enable&&(_=this.addLogo(e.logo,e.size.height+v/2,e.wall.depth)),c.length=e.size.width-d.depth,h.nbPillar=Math.floor(e.size.width/Mo)+1,h.distance=(e.size.width-e.wall.depth-e.frame.girt.depth-e.frame.pillar.width)/(h.nbPillar+1),h.position.x=(-e.size.width+h.width+c.depth+e.wall.depth)/2+h.distance,h.position.z=h.position.z;break;case"back":d.dimensions.width=e.size.width,d.dimensions.height=e.size.height,d.dimensions.raise=e.roof.raise,a.x=-e.size.length/2,r.y=-Math.PI/2,c.length=e.size.width-d.depth,h.nbPillar=Math.floor(e.size.width/Mo)+1,h.distance=(e.size.width-e.wall.depth-e.frame.girt.depth-e.frame.pillar.width)/(h.nbPillar+1),h.position.x=(-e.size.width+h.width+c.depth+e.wall.depth)/2+h.distance;break;case"left":d.dimensions.width=e.size.length,d.dimensions.height=e.size.height,a.z=e.size.width/2,c.length=e.size.length-d.depth,h.nbPillar=Math.floor(e.size.length/Mo)+1,h.distance=(e.size.length-e.wall.depth-e.frame.girt.depth-e.frame.pillar.width)/(h.nbPillar-1),h.position.x=(-e.size.length+h.width+c.depth+e.wall.depth)/2;break;case"right":d.dimensions.width=e.size.length,d.dimensions.height=e.size.height,a.z=-e.size.width/2,r.y=Math.PI,c.length=e.size.length-d.depth,h.nbPillar=Math.floor(e.size.length/Mo)+1,h.distance=(e.size.length-e.wall.depth-e.frame.girt.depth-e.frame.pillar.width)/(h.nbPillar-1),h.position.x=(-e.size.length+h.width+c.depth+e.wall.depth)/2;break}globalThis.options.wallQuality==="high"&&(d.position.x=-d.dimensions.width/2),this.textureImage.frame.mapImage&&(h.material=new Fo(this.textureImage.frame.mapImage,this.textureImage.frame.mapImageDisp,h.height/h.width,1),c.material=new Fo(this.textureImage.frame.mapImage,this.textureImage.frame.mapImageDisp,c.length/c.width,1)),this.textureImage.door.mapImage&&(p.material=new IC(e.door.color,this.textureImage.door.mapImage,this.textureImage.door.mapImageDisp,this.textureImage.door.mapImageNormal));const x={config:{pillar:{enable:e.frame.enable,material:h.material.clone(),width:e.frame.pillar.width,depth:e.frame.pillar.depth},purlin:{enable:e.frame.enable,material:h.material.clone(),width:e.frame.pillar.width,depth:e.frame.pillar.depth},girt:{enable:e.frame.enable,skirtBoardProtection:e.options.skirtBoardProtection,material:c.material.clone(),width:e.frame.girt.width,depth:e.frame.girt.depth},floor:e.floor,roof:Vt.cloneDeep(e.roof),trim:e.trim,options:e.options,wall:{enable:e.wall.enable,color:e.wall.color,raise:e.roof.raise,height:e.size.height,depth:e.wall.depth}},list:[]};x.config.roof.raise=e.leanTos.roof.raise,x.config.roof.extend=e.leanTos.roof.extend,e.leanTos&&(x.list=e.leanTos.list.filter(v=>{if(v.side==t)return v.id===""&&(v.id=Pc()),v}));const y=new AC({wallData:d,girtData:c,pillarData:h,frame:m,doorData:p,general:e.general,leanToData:x},t);y.position.set(a.x,a.y,a.z),y.rotation.set(r.x,r.y,r.z),_&&y.add(_),this.add(y)}addLogo(e,t,i){let r;this.textureImage.logo.mapImage&&(r=this.textureImage.logo.mapImage);const a=new vn({map:r,transparent:!0}),s=new vn({opacity:0,transparent:!0}),l=new st(8,8,.1),h=new rt(l,[s,s,s,s,a,s]);return h.name="logo",h.position.y=t,h.position.z=i,h}objectCastShadow(e=!0){this.traverseVisible(function(t){t instanceof rt&&(t.castShadow=e,t.receiveShadow=e)})}dispose(){this.traverse((function(e){if(e instanceof rt&&e.material&&e.geometry)if(e.geometry.dispose(),e.material.isMaterial)this.cleanMaterial(e.material);else for(const t of e.material)this.cleanMaterial(t)}).bind(this))}cleanMaterial(e){e.dispose();for(const t of Object.keys(e)){const i=e[t];i&&typeof i=="object"&&"minFilter"in i&&i.dispose()}}}class jv extends OC{}class NC{constructor(e=""){let t=new Sa(3e3,3e3),i=new vn({color:"#EBEBEB"});const r=new rt(t,i);return r.rotateX(-zt[90]),r.position.set(0,-.2,0),r.updateMatrix(),r.userData.ground=!0,r}}class UC{constructor(e){this.init(e)}init(e){const t=new V_,i={mapImage:t.load(e+"/"+ri.wall.urlMapImage),mapImageDisp:t.load(e+"/"+ri.wall.urlMapImageDisp),mapImageNormal:t.load(e+"/"+ri.wall.urlMapImageNormal)};this.wall=i;const r={mapImage:t.load(e+"/"+ri.wainscotting.urlMapImage),mapImageDisp:t.load(e+"/"+ri.wainscotting.urlMapImageDisp),mapImageNormal:t.load(e+"/"+ri.wainscotting.urlMapImageNormal)};this.wainscotting=r;const a={mapImage:t.load(e+"/"+ri.roof.urlMapImage),mapImageDisp:t.load(e+"/"+ri.roof.urlMapImageDisp),mapImageNormal:t.load(e+"/"+ri.roof.urlMapImageNormal)};this.roof=a;const s={mapImage:t.load(e+"/"+ri.frame.urlMapImage),mapImageDisp:t.load(e+"/"+ri.frame.urlMapImageDisp)};this.frame=s;const l={mapImage:t.load(e+"/"+ri.floor.urlMapImage),mapImageDisp:t.load(e+"/"+ri.floor.urlMapImageDisp)};this.floor=l;const h={mapImage:t.load(e+"/"+ri.trim.urlMapImage),mapImageDisp:t.load(e+"/"+ri.trim.urlMapImageDisp),mapImageNormal:t.load(e+"/"+ri.trim.urlMapImageNormal)};this.trim=h;const c={mapImage:t.load(e+"/"+ri.door.urlMapImage),mapImageDisp:t.load(e+"/"+ri.door.urlMapImageDisp),mapImageNormal:t.load(e+"/"+ri.door.urlMapImageNormal)};this.door=c,this.cupola={wall:null,roof:null};const d={mapImage:t.load(e+"/"+ri.cupola.wall.urlMapImage),mapImageDisp:t.load(e+"/"+ri.cupola.wall.urlMapImageDisp)};this.cupola.wall=d;const p={mapImage:t.load(e+"/"+ri.cupola.roof.urlMapImage),mapImageDisp:t.load(e+"/"+ri.cupola.roof.urlMapImageDisp),mapImageNormal:t.load(e+"/"+ri.cupola.roof.urlMapImageNormal)};this.cupola.roof=p;const f={mapImage:t.load(e+"/"+ri.logo.urlMapImage)};this.logo=f}}class zC{constructor(e){this.init(e)}init(e){Ft.large.overhead=e+"/"+Ft.large.overhead,Ft.large.single_slide=e+"/"+Ft.large.single_slide,Ft.large.double_slide=e+"/"+Ft.large.double_slide,Ft.large.dutch_corner_overhead=e+"/"+Ft.large.dutch_corner_overhead,Ft.entry.two_panels=e+"/"+Ft.entry.two_panels,Ft.entry.six_panels=e+"/"+Ft.entry.six_panels,Ft.entry.two_panels_half_glass=e+"/"+Ft.entry.two_panels_half_glass,Ft.entry.two_panels_with_grid=e+"/"+Ft.entry.two_panels_with_grid,Ft.window.sliding_vinyl=e+"/"+Ft.window.sliding_vinyl,Ft.window.double_hung_vinyl=e+"/"+Ft.window.double_hung_vinyl,Ft.window.single_hung_vinyl=e+"/"+Ft.window.single_hung_vinyl,$d.weathervane=e+"/"+$d.weathervane}}const BC="_spinner_xfhuc_1",FC="_spin_xfhuc_1",kC="_loadingContainer_xfhuc_11",HC="_hidden_xfhuc_24",Zl={spinner:BC,spin:FC,loadingContainer:kC,hidden:HC};class GC{constructor(e){vt(this,"loadingContainer",null);this.init(e)}init(e){const t=[{transform:"rotate(360deg)"}],i={duration:1e3,iterations:1/0},r=document.createElement("p");r.className=Zl.spinner,r.animate(t,i),this.loadingContainer=document.createElement("div"),this.loadingContainer.className=Zl.loadingContainer,this.loadingContainer.classList.add(Zl.hidden),this.loadingContainer.append(r),e.append(this.loadingContainer)}show(){this.loadingContainer.classList.remove(Zl.hidden)}hide(){this.loadingContainer.classList.add(Zl.hidden)}}const VC="_tglContainer_biqf5_1",WC="_tgl_biqf5_1",jC="_tglBtn_biqf5_9",XC="_tglBtnActive_biqf5_69",qC="_neumorphism_biqf5_88",Fa={tglContainer:VC,tgl:WC,tglBtn:jC,tglBtnActive:XC,neumorphism:qC};class YC{constructor(e,t){this.init(e,t)}init(e,t){const i=document.createElement("div");i.className=Fa.tglContainer,this.qualityToggler=document.createElement("input"),this.qualityToggler.type="checkbox",this.qualityToggler.id="quality-toggler",this.qualityToggler.className=Fa.tgl,this.qualityTogglerLabel=document.createElement("label"),this.qualityTogglerLabel.setAttribute("data-tg-off","Medium"),this.qualityTogglerLabel.setAttribute("data-tg-on","High"),this.qualityTogglerLabel.setAttribute("for","quality-toggler"),this.qualityTogglerLabel.className=Fa.tglBtn,this.qualityTogglerLabel.classList.add(Fa.neumorphism);const r=this;this.qualityToggler.addEventListener("change",function(){this.checked?(r.qualityTogglerLabel.classList.add(Fa.tglBtnActive),t("high")):(r.qualityTogglerLabel.classList.remove(Fa.tglBtnActive),t("medium"))}),i.append(this.qualityToggler),i.append(this.qualityTogglerLabel),e.append(i)}updateGuiData(e){e==="high"?(this.qualityToggler.checked=!0,this.qualityTogglerLabel.classList.add(Fa.tglBtnActive)):(this.qualityToggler.checked=!1,this.qualityTogglerLabel.classList.remove(Fa.tglBtnActive))}}const KC="_animate__animated_1sh88_100",ZC="_animate__infinite_1sh88_1",JC="_animate__faster_1sh88_1",$C="_animate__fast_1sh88_1",QC="_animate__slow_1sh88_1",eL="_animate__slower_1sh88_1",tL="_animate__bounce_1sh88_1",iL="_bounce_1sh88_1",rL="_animate__flash_1sh88_1",nL="_flash_1sh88_1",aL="_animate__pulse_1sh88_1",sL="_pulse_1sh88_1",oL="_animate__rubberBand_1sh88_1",lL="_rubberBand_1sh88_1",hL="_animate__shakeX_1sh88_1",cL="_shakeX_1sh88_1",uL="_animate__shakeY_1sh88_1",dL="_shakeY_1sh88_1",pL="_animate__headShake_1sh88_1",fL="_headShake_1sh88_1",mL="_animate__swing_1sh88_1",gL="_swing_1sh88_1",_L="_animate__tada_1sh88_1",vL="_tada_1sh88_1",yL="_animate__wobble_1sh88_1",xL="_wobble_1sh88_1",bL="_animate__jello_1sh88_1",wL="_jello_1sh88_1",ML="_animate__heartBeat_1sh88_1",TL="_heartBeat_1sh88_1",SL="_animate__backInDown_1sh88_1",EL="_backInDown_1sh88_1",AL="_animate__backInLeft_1sh88_1",RL="_backInLeft_1sh88_1",CL="_animate__backInRight_1sh88_1",LL="_backInRight_1sh88_1",PL="_animate__backInUp_1sh88_1",DL="_backInUp_1sh88_1",IL="_animate__backOutDown_1sh88_1",OL="_backOutDown_1sh88_1",NL="_animate__backOutLeft_1sh88_1",UL="_backOutLeft_1sh88_1",zL="_animate__backOutRight_1sh88_1",BL="_backOutRight_1sh88_1",FL="_animate__backOutUp_1sh88_1",kL="_backOutUp_1sh88_1",HL="_animate__bounceIn_1sh88_1",GL="_bounceIn_1sh88_1",VL="_animate__bounceInDown_1sh88_1",WL="_bounceInDown_1sh88_1",jL="_animate__bounceInLeft_1sh88_1",XL="_bounceInLeft_1sh88_1",qL="_animate__bounceInRight_1sh88_1",YL="_bounceInRight_1sh88_1",KL="_animate__bounceInUp_1sh88_1",ZL="_bounceInUp_1sh88_1",JL="_animate__bounceOut_1sh88_1",$L="_bounceOut_1sh88_1",QL="_animate__bounceOutDown_1sh88_1",eP="_bounceOutDown_1sh88_1",tP="_animate__bounceOutLeft_1sh88_1",iP="_bounceOutLeft_1sh88_1",rP="_animate__bounceOutRight_1sh88_1",nP="_bounceOutRight_1sh88_1",aP="_animate__bounceOutUp_1sh88_1",sP="_bounceOutUp_1sh88_1",oP="_animate__fadeIn_1sh88_1",lP="_fadeIn_1sh88_1",hP="_animate__fadeInDown_1sh88_1",cP="_fadeInDown_1sh88_1",uP="_animate__fadeInDownBig_1sh88_1",dP="_fadeInDownBig_1sh88_1",pP="_animate__fadeInLeft_1sh88_1",fP="_fadeInLeft_1sh88_1",mP="_animate__fadeInLeftBig_1sh88_1",gP="_fadeInLeftBig_1sh88_1",_P="_animate__fadeInRight_1sh88_1",vP="_fadeInRight_1sh88_1",yP="_animate__fadeInRightBig_1sh88_1",xP="_fadeInRightBig_1sh88_1",bP="_animate__fadeInUp_1sh88_1",wP="_fadeInUp_1sh88_1",MP="_animate__fadeInUpBig_1sh88_1",TP="_fadeInUpBig_1sh88_1",SP="_animate__fadeInTopLeft_1sh88_1",EP="_fadeInTopLeft_1sh88_1",AP="_animate__fadeInTopRight_1sh88_1",RP="_fadeInTopRight_1sh88_1",CP="_animate__fadeInBottomLeft_1sh88_1",LP="_fadeInBottomLeft_1sh88_1",PP="_animate__fadeInBottomRight_1sh88_1",DP="_fadeInBottomRight_1sh88_1",IP="_animate__fadeOut_1sh88_1",OP="_fadeOut_1sh88_1",NP="_animate__fadeOutDown_1sh88_1",UP="_fadeOutDown_1sh88_1",zP="_animate__fadeOutDownBig_1sh88_1",BP="_fadeOutDownBig_1sh88_1",FP="_animate__fadeOutLeft_1sh88_1",kP="_fadeOutLeft_1sh88_1",HP="_animate__fadeOutLeftBig_1sh88_1",GP="_fadeOutLeftBig_1sh88_1",VP="_animate__fadeOutRight_1sh88_1",WP="_fadeOutRight_1sh88_1",jP="_animate__fadeOutRightBig_1sh88_1",XP="_fadeOutRightBig_1sh88_1",qP="_animate__fadeOutUp_1sh88_1",YP="_fadeOutUp_1sh88_1",KP="_animate__fadeOutUpBig_1sh88_1",ZP="_fadeOutUpBig_1sh88_1",JP="_animate__fadeOutTopLeft_1sh88_1",$P="_fadeOutTopLeft_1sh88_1",QP="_animate__fadeOutTopRight_1sh88_1",eD="_fadeOutTopRight_1sh88_1",tD="_animate__fadeOutBottomRight_1sh88_1",iD="_fadeOutBottomRight_1sh88_1",rD="_animate__fadeOutBottomLeft_1sh88_1",nD="_fadeOutBottomLeft_1sh88_1",aD="_animate__flip_1sh88_1",sD="_flip_1sh88_1",oD="_animate__flipInX_1sh88_1",lD="_flipInX_1sh88_1",hD="_animate__flipInY_1sh88_1",cD="_flipInY_1sh88_1",uD="_animate__flipOutX_1sh88_1",dD="_flipOutX_1sh88_1",pD="_animate__flipOutY_1sh88_1",fD="_flipOutY_1sh88_1",mD="_animate__lightSpeedInRight_1sh88_1",gD="_lightSpeedInRight_1sh88_1",_D="_animate__lightSpeedInLeft_1sh88_1",vD="_lightSpeedInLeft_1sh88_1",yD="_animate__lightSpeedOutRight_1sh88_1",xD="_lightSpeedOutRight_1sh88_1",bD="_animate__lightSpeedOutLeft_1sh88_1",wD="_lightSpeedOutLeft_1sh88_1",MD="_animate__rotateIn_1sh88_1",TD="_rotateIn_1sh88_1",SD="_animate__rotateInDownLeft_1sh88_1",ED="_rotateInDownLeft_1sh88_1",AD="_animate__rotateInDownRight_1sh88_1",RD="_rotateInDownRight_1sh88_1",CD="_animate__rotateInUpLeft_1sh88_1",LD="_rotateInUpLeft_1sh88_1",PD="_animate__rotateInUpRight_1sh88_1",DD="_rotateInUpRight_1sh88_1",ID="_animate__rotateOut_1sh88_1",OD="_rotateOut_1sh88_1",ND="_animate__rotateOutDownLeft_1sh88_1",UD="_rotateOutDownLeft_1sh88_1",zD="_animate__rotateOutDownRight_1sh88_1",BD="_rotateOutDownRight_1sh88_1",FD="_animate__rotateOutUpLeft_1sh88_1",kD="_rotateOutUpLeft_1sh88_1",HD="_animate__rotateOutUpRight_1sh88_1",GD="_rotateOutUpRight_1sh88_1",VD="_animate__hinge_1sh88_1",WD="_hinge_1sh88_1",jD="_animate__jackInTheBox_1sh88_1",XD="_jackInTheBox_1sh88_1",qD="_animate__rollIn_1sh88_1",YD="_rollIn_1sh88_1",KD="_animate__rollOut_1sh88_1",ZD="_rollOut_1sh88_1",JD="_animate__zoomIn_1sh88_1",$D="_zoomIn_1sh88_1",QD="_animate__zoomInDown_1sh88_1",eI="_zoomInDown_1sh88_1",tI="_animate__zoomInLeft_1sh88_1",iI="_zoomInLeft_1sh88_1",rI="_animate__zoomInRight_1sh88_1",nI="_zoomInRight_1sh88_1",aI="_animate__zoomInUp_1sh88_1",sI="_zoomInUp_1sh88_1",oI="_animate__zoomOut_1sh88_1",lI="_zoomOut_1sh88_1",hI="_animate__zoomOutDown_1sh88_1",cI="_zoomOutDown_1sh88_1",uI="_animate__zoomOutLeft_1sh88_1",dI="_zoomOutLeft_1sh88_1",pI="_animate__zoomOutRight_1sh88_1",fI="_zoomOutRight_1sh88_1",mI="_animate__zoomOutUp_1sh88_1",gI="_zoomOutUp_1sh88_1",_I="_animate__slideInDown_1sh88_1",vI="_slideInDown_1sh88_1",yI="_animate__slideInLeft_1sh88_1",xI="_slideInLeft_1sh88_1",bI="_animate__slideInRight_1sh88_1",wI="_slideInRight_1sh88_1",MI="_animate__slideInUp_1sh88_1",TI="_slideInUp_1sh88_1",SI="_animate__slideOutDown_1sh88_1",EI="_slideOutDown_1sh88_1",AI="_animate__slideOutLeft_1sh88_1",RI="_slideOutLeft_1sh88_1",CI="_animate__slideOutRight_1sh88_1",LI="_slideOutRight_1sh88_1",PI="_animate__slideOutUp_1sh88_1",DI="_slideOutUp_1sh88_1",II="_colorPanel_1sh88_3",OI="_colorPanelHeader_1sh88_26",NI="_colorPanelBody_1sh88_29",UI="_collapsing_1sh88_33",zI="_expanded_1sh88_43",BI="_colorPalettes_1sh88_47",FI="_colorPanelTitle_1sh88_51",kI="_colorPalette_1sh88_47",HI="_colorTile_1sh88_118",GI="_colorTileInner_1sh88_126",VI="_segmentedControl_1sh88_161",WI="_segmentedControl__1_1sh88_183",jI="_segmentedControl__2_1sh88_184",XI="_segmentedControl__3_1sh88_185",qI="_segmentedControl__4_1sh88_186",YI="_segmentedControlColor_1sh88_214",KI="_segmentedControlInput__1_1sh88_227",ZI="_segmentedControlInput__2_1sh88_232",JI="_segmentedControlInput__3_1sh88_237",$I="_segmentedControlInput__4_1sh88_242",Wt={animate__animated:KC,animate__infinite:ZC,"animate__repeat-1":"_animate__repeat-1_1sh88_1","animate__repeat-2":"_animate__repeat-2_1sh88_1","animate__repeat-3":"_animate__repeat-3_1sh88_1","animate__delay-1s":"_animate__delay-1s_1sh88_1","animate__delay-2s":"_animate__delay-2s_1sh88_1","animate__delay-3s":"_animate__delay-3s_1sh88_1","animate__delay-4s":"_animate__delay-4s_1sh88_1","animate__delay-5s":"_animate__delay-5s_1sh88_1",animate__faster:JC,animate__fast:$C,animate__slow:QC,animate__slower:eL,animate__bounce:tL,bounce:iL,animate__flash:rL,flash:nL,animate__pulse:aL,pulse:sL,animate__rubberBand:oL,rubberBand:lL,animate__shakeX:hL,shakeX:cL,animate__shakeY:uL,shakeY:dL,animate__headShake:pL,headShake:fL,animate__swing:mL,swing:gL,animate__tada:_L,tada:vL,animate__wobble:yL,wobble:xL,animate__jello:bL,jello:wL,animate__heartBeat:ML,heartBeat:TL,animate__backInDown:SL,backInDown:EL,animate__backInLeft:AL,backInLeft:RL,animate__backInRight:CL,backInRight:LL,animate__backInUp:PL,backInUp:DL,animate__backOutDown:IL,backOutDown:OL,animate__backOutLeft:NL,backOutLeft:UL,animate__backOutRight:zL,backOutRight:BL,animate__backOutUp:FL,backOutUp:kL,animate__bounceIn:HL,bounceIn:GL,animate__bounceInDown:VL,bounceInDown:WL,animate__bounceInLeft:jL,bounceInLeft:XL,animate__bounceInRight:qL,bounceInRight:YL,animate__bounceInUp:KL,bounceInUp:ZL,animate__bounceOut:JL,bounceOut:$L,animate__bounceOutDown:QL,bounceOutDown:eP,animate__bounceOutLeft:tP,bounceOutLeft:iP,animate__bounceOutRight:rP,bounceOutRight:nP,animate__bounceOutUp:aP,bounceOutUp:sP,animate__fadeIn:oP,fadeIn:lP,animate__fadeInDown:hP,fadeInDown:cP,animate__fadeInDownBig:uP,fadeInDownBig:dP,animate__fadeInLeft:pP,fadeInLeft:fP,animate__fadeInLeftBig:mP,fadeInLeftBig:gP,animate__fadeInRight:_P,fadeInRight:vP,animate__fadeInRightBig:yP,fadeInRightBig:xP,animate__fadeInUp:bP,fadeInUp:wP,animate__fadeInUpBig:MP,fadeInUpBig:TP,animate__fadeInTopLeft:SP,fadeInTopLeft:EP,animate__fadeInTopRight:AP,fadeInTopRight:RP,animate__fadeInBottomLeft:CP,fadeInBottomLeft:LP,animate__fadeInBottomRight:PP,fadeInBottomRight:DP,animate__fadeOut:IP,fadeOut:OP,animate__fadeOutDown:NP,fadeOutDown:UP,animate__fadeOutDownBig:zP,fadeOutDownBig:BP,animate__fadeOutLeft:FP,fadeOutLeft:kP,animate__fadeOutLeftBig:HP,fadeOutLeftBig:GP,animate__fadeOutRight:VP,fadeOutRight:WP,animate__fadeOutRightBig:jP,fadeOutRightBig:XP,animate__fadeOutUp:qP,fadeOutUp:YP,animate__fadeOutUpBig:KP,fadeOutUpBig:ZP,animate__fadeOutTopLeft:JP,fadeOutTopLeft:$P,animate__fadeOutTopRight:QP,fadeOutTopRight:eD,animate__fadeOutBottomRight:tD,fadeOutBottomRight:iD,animate__fadeOutBottomLeft:rD,fadeOutBottomLeft:nD,animate__flip:aD,flip:sD,animate__flipInX:oD,flipInX:lD,animate__flipInY:hD,flipInY:cD,animate__flipOutX:uD,flipOutX:dD,animate__flipOutY:pD,flipOutY:fD,animate__lightSpeedInRight:mD,lightSpeedInRight:gD,animate__lightSpeedInLeft:_D,lightSpeedInLeft:vD,animate__lightSpeedOutRight:yD,lightSpeedOutRight:xD,animate__lightSpeedOutLeft:bD,lightSpeedOutLeft:wD,animate__rotateIn:MD,rotateIn:TD,animate__rotateInDownLeft:SD,rotateInDownLeft:ED,animate__rotateInDownRight:AD,rotateInDownRight:RD,animate__rotateInUpLeft:CD,rotateInUpLeft:LD,animate__rotateInUpRight:PD,rotateInUpRight:DD,animate__rotateOut:ID,rotateOut:OD,animate__rotateOutDownLeft:ND,rotateOutDownLeft:UD,animate__rotateOutDownRight:zD,rotateOutDownRight:BD,animate__rotateOutUpLeft:FD,rotateOutUpLeft:kD,animate__rotateOutUpRight:HD,rotateOutUpRight:GD,animate__hinge:VD,hinge:WD,animate__jackInTheBox:jD,jackInTheBox:XD,animate__rollIn:qD,rollIn:YD,animate__rollOut:KD,rollOut:ZD,animate__zoomIn:JD,zoomIn:$D,animate__zoomInDown:QD,zoomInDown:eI,animate__zoomInLeft:tI,zoomInLeft:iI,animate__zoomInRight:rI,zoomInRight:nI,animate__zoomInUp:aI,zoomInUp:sI,animate__zoomOut:oI,zoomOut:lI,animate__zoomOutDown:hI,zoomOutDown:cI,animate__zoomOutLeft:uI,zoomOutLeft:dI,animate__zoomOutRight:pI,zoomOutRight:fI,animate__zoomOutUp:mI,zoomOutUp:gI,animate__slideInDown:_I,slideInDown:vI,animate__slideInLeft:yI,slideInLeft:xI,animate__slideInRight:bI,slideInRight:wI,animate__slideInUp:MI,slideInUp:TI,animate__slideOutDown:SI,slideOutDown:EI,animate__slideOutLeft:AI,slideOutLeft:RI,animate__slideOutRight:CI,slideOutRight:LI,animate__slideOutUp:PI,slideOutUp:DI,colorPanel:II,colorPanelHeader:OI,colorPanelBody:NI,collapsing:UI,expanded:zI,colorPalettes:BI,colorPanelTitle:FI,colorPalette:kI,colorTile:HI,colorTileInner:GI,segmentedControl:VI,segmentedControl__1:WI,segmentedControl__2:jI,segmentedControl__3:XI,segmentedControl__4:qI,segmentedControlColor:YI,segmentedControlInput__1:KI,segmentedControlInput__2:ZI,segmentedControlInput__3:JI,segmentedControlInput__4:$I,"fade-in":"_fade-in_1sh88_1"};class QI{constructor(e,t,i){vt(this,"tabHeaders",[{name:"Roof"},{name:"Wall"},{name:"Trim"},{name:"Wainscotting"}]);vt(this,"colors",[{name:"Bright White",color:"#f7fcfe",isFavorite:!0},{name:"Alamo White",color:"#f1efeb",isFavorite:!0},{name:"Ash Gray",color:"#aba7a0",isFavorite:!0},{name:"Pewter Gray",color:"#939a94",isFavorite:!1},{name:"Charcoal",color:"#495050",isFavorite:!0},{name:"Taupe",color:"#8d837b",isFavorite:!1},{name:"Burnished Slate",color:"#342d2d",isFavorite:!0},{name:"Light Stone",color:"#ebdebf",isFavorite:!0},{name:"Ivory",color:"#faead9",isFavorite:!1},{name:"Tan",color:"#ca9978",isFavorite:!1},{name:"Brown",color:"#3f2316",isFavorite:!0},{name:"Dark Brown",color:"#221513",isFavorite:!1},{name:"Pine Green",color:"#184934",isFavorite:!1},{name:"Hunter Green",color:"#2c4f3b",isFavorite:!0},{name:"Fern Green",color:"#19291c",isFavorite:!1},{name:"Gallery Blue",color:"#0f2e93",isFavorite:!1},{name:"Bright Red",color:"#ed2c1f",isFavorite:!1},{name:"Rustic Red",color:"#881b25",isFavorite:!0},{name:"Burgundy",color:"#471825",isFavorite:!1},{name:"Black",color:"#111",isFavorite:!0}]);vt(this,"_data",{roof:null,wall:null,trim:null,wainscotting:null});this.onColorChange=i,this.init(e,t)}init(e,t){const i=document.createElement("div");i.className=Wt.colorPanel;const r=document.createElement("div");r.className=Wt.colorPanelHeader;const a=document.createElement("label");a.className=Wt.colorPanelTitle,r.append(a);const s=document.createElement("a");s.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M21.143 9.667c-.733-1.392-1.914-3.05-3.617-4.753-2.977-2.978-5.478-3.914-6.785-3.914-.414 0-.708.094-.86.246l-1.361 1.36c-1.899-.236-3.42.106-4.294.983-.876.875-1.164 2.159-.792 3.523.492 1.806 2.305 4.049 5.905 5.375.038.323.157.638.405.885.588.588 1.535.586 2.121 0s.588-1.533.002-2.119c-.588-.587-1.537-.588-2.123-.001l-.17.256c-2.031-.765-3.395-1.828-4.232-2.9l3.879-3.875c.496 2.73 6.432 8.676 9.178 9.178l-7.115 7.107c-.234.153-2.798-.316-6.156-3.675-3.393-3.393-3.175-5.271-3.027-5.498l1.859-1.856c-.439-.359-.925-1.103-1.141-1.689l-2.134 2.131c-.445.446-.685 1.064-.685 1.82 0 1.634 1.121 3.915 3.713 6.506 2.764 2.764 5.58 4.243 7.432 4.243.648 0 1.18-.195 1.547-.562l8.086-8.078c.91.874-.778 3.538-.778 4.648 0 1.104.896 1.999 2 1.999 1.105 0 2-.896 2-2 0-3.184-1.425-6.81-2.857-9.34zm-16.209-5.371c.527-.53 1.471-.791 2.656-.761l-3.209 3.206c-.236-.978-.049-1.845.553-2.445zm9.292 4.079l-.03-.029c-1.292-1.292-3.803-4.356-3.096-5.063.715-.715 3.488 1.521 5.062 3.096.862.862 2.088 2.247 2.937 3.458-1.717-1.074-3.491-1.469-4.873-1.462z"/></svg>',s.setAttribute("role","button"),s.setAttribute("data-toggle","collapsed");const l=document.createElement("span");l.innerText="Color Customization",s.append(l),a.append(s);const h=document.createElement("div");h.className=Wt.colorPanelBody;const c=document.createElement("div");c.className=Wt.colorPalettes,c.setAttribute("active-index",1);const d=document.createElement("div");d.className=Wt.segmentedControl;for(let f=0;f<this.tabHeaders.length;f++){const m=this.tabHeaders[f],_=document.createElement("input");_.className=Wt["segmentedControlInput__"+(f+1)],_.setAttribute("type","radio"),_.setAttribute("value",f),_.setAttribute("name","color"),_.setAttribute("id","color-tab-"+(f+1)),_.setAttribute("aria-controls",m.name.toLowerCase()+"-color-control"),_.addEventListener("change",function(){if(this.checked){const v=c.getAttribute("active-index"),M=c.children.item(v-1),b=f+1,S=c.children.item(f);c.setAttribute("active-index",b),M.classList.add(Wt.animate__animated),S.classList.add(Wt.animate__animated),v>b?(M.classList.add(Wt.animate__fadeOutDown),S.classList.add(Wt.animate__fadeInDown)):v<b&&(M.classList.add(Wt.animate__fadeOutUp),S.classList.add(Wt.animate__fadeInUp)),setTimeout(()=>{M.classList.remove(Wt.animate__animated),M.classList.remove(Wt.animate__fadeOutUp),M.classList.remove(Wt.animate__fadeOutDown),S.classList.remove(Wt.animate__fadeInUp),S.classList.remove(Wt.animate__fadeInDown),S.classList.remove(Wt.animate__animated)},300)}}),f===0&&_.setAttribute("checked","true");const x=document.createElement("label");x.setAttribute("for","color-tab-"+(f+1)),x.className=Wt["segmentedControl__"+(f+1)];const y=document.createElement("p");y.innerText=m.name,x.append(y),d.append(_),d.append(x)}const p=document.createElement("div");p.className=Wt.segmentedControlColor,d.append(p),h.append(d);for(let f=0;f<this.tabHeaders.length;f++){const m=this.tabHeaders[f],_=document.createElement("div");_.className=Wt.colorPalette,_.id=m.name.toLowerCase()+"-color-control";for(let x=0;x<this.colors.length;x++){const y=this.colors[x],v=document.createElement("div");v.className=Wt.colorTile,v.setAttribute("color",y.color);const M=document.createElement("div");M.className=Wt.colorTileInner,M.style.backgroundColor=y.color,M.setAttribute("hover-tooltip",y.name),x<=2&&M.setAttribute("tooltip-position","bottom"),M.addEventListener("click",()=>{this.selectColor(m.name.toLowerCase(),y.color)}),v.append(M),_.append(v)}c.append(_)}h.append(c),s.addEventListener("click",()=>{s.getAttribute("data-toggle")==="collapsed"?(s.setAttribute("data-toggle","expanded"),h.classList.add(Wt.collapsing),setTimeout(()=>h.style.height="430px",10),setTimeout(()=>{s.getAttribute("data-toggle")==="expanded"&&(h.classList.add(Wt.expanded),h.classList.remove(Wt.collapsing))},350)):(s.setAttribute("data-toggle","collapsed"),h.classList.add(Wt.collapsing),h.style.height=0,setTimeout(()=>{s.getAttribute("data-toggle")==="collapsed"&&(h.classList.remove(Wt.expanded),h.classList.remove(Wt.collapsing))},350))}),i.append(r),i.append(h),e.append(i),Object.defineProperty(this,"data",{get:function(){return this._data},set:(function(f){this._data=f,this.mapSelectedColors()}).bind(this)}),this.updateGuiData(t.data)}mapSelectedColors(){Object.keys(this.data).forEach(e=>{const t=document.getElementById(e+"-color-control");for(let i of t.children)i.getAttribute("color")===this.data[e]?i.setAttribute("active",!0):i.setAttribute("active",!1)})}updateGuiData(e){this.data={roof:e.roof.color.toLowerCase(),wall:e.wall.color.toLowerCase(),trim:e.trim.color.toLowerCase(),wainscotting:e.options.wainscotting.color.toLowerCase()}}selectColor(e,t){this.data={...this.data,[e]:t},this.onColorChange(e,t)}}const eO="_contextMenu_1ba8v_1",tO="_contextMenuHeader_1ba8v_22",iO="_contextMenuTitle_1ba8v_27",rO="_contextMenuLabel_1ba8v_32",nO="_contextMenuButton_1ba8v_35",aO="_contextMenuBody_1ba8v_57",sO="_contextMenuGroup_1ba8v_60",oO="_contextMenuCheckboxGroup_1ba8v_63",lO="_contextMenuButtonGroup_1ba8v_64",Qi={contextMenu:eO,contextMenuHeader:tO,contextMenuTitle:iO,contextMenuLabel:rO,contextMenuButton:nO,contextMenuBody:aO,contextMenuGroup:sO,contextMenuCheckboxGroup:oO,contextMenuButtonGroup:lO};class hO{constructor(e){const t=document.createElement("div"),i='<label id="contextMenuLabel" class=fw-semibold>OBJ</label>',r=` <span class=${Qi.contextMenuButton} id=duplicate_object> <svg class="bi bi-copy"fill=currentColor height=16 viewBox="0 0 16 16"width=16 xmlns=http://www.w3.org/2000/svg><path d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z"fill-rule=evenodd /></svg> </span> `,a=` <span class=${Qi.contextMenuButton} id=delete_object> <svg class="bi bi-trash"fill=#D9272E height=16 viewBox="0 0 16 16"width=16 xmlns=http://www.w3.org/2000/svg><path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z"/><path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z"/></svg> </span> `,s=` <div id=weathervane_div class="card-body ${Qi.contextMenuBody}"> <div class="${Qi.contextMenuGroup} ${Qi.contextMenuCheckboxGroup}"> <input type=checkbox id=weathervane checked> <label for=weathervane>Weathervane</label> </div> </div> `,l=` <div id=lean_to_div class="card-body ${Qi.contextMenuBody}"> <div class="${Qi.contextMenuGroup}"> <label for="lean_to_open_type">Type</label> <select id=lean_to_open_type class="custom-select"> <option value=close>Close</option><option value=open_bottom>Open</option> </select> </div> <div class="${Qi.contextMenuGroup}"> <label for="lean_to_width">Width</label> <select id=lean_to_width class="custom-select"> <option value=8>8</option><option value=10>10</option><option value=12>12</option> </select> </div> <div class="${Qi.contextMenuGroup} ${Qi.contextMenuCheckboxGroup}"> <input type=checkbox id=lean_to_wrap_left checked> <label for=lean_to_wrap_left>Wrap left</label> </div> <div class="${Qi.contextMenuGroup} ${Qi.contextMenuCheckboxGroup}"> <input type=checkbox id=lean_to_wrap_right checked> <label for=lean_to_wrap_right>Wrap right</label> </div> </div> `;t.innerHTML=` <div class="card ${Qi.contextMenu}" id=contextMenu style=display:none> <div class="card-header ${Qi.contextMenuHeader}"> <div class="${Qi.contextMenuTitle}">${i}</div> <div class="${Qi.contextMenuButtonGroup}">${r} ${a}</div> </div> ${s} ${l} </div> `,e.append(t)}}class cO{constructor(e){vt(this,"config",{});vt(this,"data",{gui:{enable:!1},general:{name:"general",isShadow:!1,isRender:!0,isEffect:!0,isTransparent:!1,texturePath:""},size:{name:"size",width:nt.scaleToModel(24),height:nt.scaleToModel(10),length:nt.scaleToModel(24)},frame:{name:"frame",enable:!0,pillar:{width:nt.scaleToModel(.5),depth:nt.scaleToModel(.5)},purlin:{isFullWidth:!0,width:nt.scaleToModel(.33),depth:nt.scaleToModel(.167)},girt:{width:nt.scaleToModel(.33),depth:nt.scaleToModel(.167)}},floor:{name:"floor",enable:!1,depth:nt.scaleToModel(.5)},wall:{name:"wall",enable:!0,isFullWidth:!0,openType:{front:"close",back:"close",left:"close",right:"close"},depth:.2,color:"#2c4f3b"},roof:{name:"roof",enable:!0,depth:.4,raise:5,extend:5,color:"#faead9"},windows:[{id:"",name:"window",type:"window",door_type:"sliding_vinyl",side:"left",size:{width:20,height:15,depth:1},position:{x:0,y:32,z:0}},{id:"",name:"window",type:"window",door_type:"double_hung_vinyl",side:"left",size:{width:15,height:20,depth:1},position:{x:-24,y:32,z:0}},{id:"",name:"window",type:"window",door_type:"sliding_vinyl",side:"left",size:{width:15,height:20,depth:1},position:{x:24,y:32,z:0}},{id:"",name:"window",type:"window",door_type:"sliding_vinyl",side:"right",size:{width:15,height:15,depth:1},position:{x:0,y:36,z:0}},{id:"",name:"window",type:"window",door_type:"sliding_vinyl",side:"right",size:{width:15,height:15,depth:1},position:{x:-30,y:36,z:0}},{id:"",name:"window",type:"window",door_type:"sliding_vinyl",side:"right",size:{width:15,height:15,depth:1},position:{x:30,y:30,z:0}},{id:"",name:"window",type:"window",door_type:"sliding_vinyl",side:"back",size:{width:20,height:15,depth:1},position:{x:-20,y:30,z:0}},{id:"",name:"window",type:"window",door_type:"sliding_vinyl",side:"back",size:{width:20,height:15,depth:1},position:{x:20,y:30,z:0}}],doors:[{id:"",name:"door",type:"large_door",door_type:"dutch_corner_overhead",side:"front",windows:"no",size:{width:50,height:40,depth:1},position:{x:0,y:30,z:0}},{id:"",name:"door",type:"entry_door",door_type:"two_panels_with_grid",side:"left",windows:"no",size:{width:15,height:30,depth:1},position:{x:-48,y:15,z:0}},{id:"",name:"entry_door",type:"entry_door",door_type:"two_panels_half_glass",side:"left",windows:"no",size:{width:20,height:35,depth:1},position:{x:48,y:15,z:0}}],door:{name:"door",color:"#495050",main:{enable:!0},entry:{enable:!0},window:{enable:!0},models:{large:{},entry:{},window:{}}},cupola:[{id:"",type:"cupola",name:"cupola",enable:!0,size:"small",roofTexture:{color:9079433},wallTexture:{},eagleWeatherwave:!1,position:{x:0,y:75,z:0}},{id:"",type:"cupola",name:"cupola",enable:!0,size:"medium",roofTexture:{color:9079433},wallTexture:{},eagleWeatherwave:!0,position:{x:-40,y:75,z:0}},{id:"",type:"cupola",name:"cupola",enable:!0,size:"small",roofTexture:{color:9079433},wallTexture:{},eagleWeatherwave:!1,position:{x:-40,y:75,z:0}}],trim:{name:"trim",enable:!0,width:2,depth:.8,roofDepth:1,color:"#495050"},logo:{enable:!1},leanTos:{wrap:{frontLeft:!1,frontRight:!1,backLeft:!1,backRight:!1},roof:{raise:2,extend:3},list:[]},options:{quality:"medium",roofQuality:"medium",wallQuality:"medium",wainscotting:{enable:!0,height:15,color:"#8d837b"},snowBar:!0,overhang:{eaveSide:!1,grableEnd:!0},skirtBoardProtection:!0},selectedSide:null});vt(this,"highlightedObject",null);this.config=e,e.shouldOverrideTexturePath&&(this.data.general.texturePath=e.texturePath),globalThis.textureImage=new UC(this.data.general.texturePath),globalThis.extraModel=new zC(this.data.general.texturePath),globalThis.options=this.data.options,this.preLoadModels(),this.raycaster=new K_,this.mouseClick=new pe,this.mouseMove=new pe,this.shift=new z,this.draggable=null,this.renderRequested=!1,this.camera=new jA(e),this.scene=new qA,this.renderer=new YA(e);const t=window.performance.now();this.data=this.preprocessingData(this.data),this.object=new jv(this.data),this.lineHelper=new Pd(new st(0,0,0),this.lineMaterial),this.lineHelper.visible=!1,this.scene.add(this.lineHelper),this.gridHelper=new GA(2500,500,8947848,4473924),this.gridHelper.visible=!1,this.scene.add(this.gridHelper),this.lights=new XA,this.lights.forEach(a=>{this.scene.add(a)}),this.ground=new NC(this.data.general.texturePath),this.scene.add(this.ground),this.ground.receiveShadow=this.data.general.isShadow,this.controls=new MR(this),this.controls.setDraggableObjects(this.object),this.controls.orbitControls.addEventListener("change",this.requestRenderIfNotRequested.bind(this)),this.controls.dragControls.addEventListener("drag",this.requestRenderIfNotRequested.bind(this)),window.addEventListener("resize",this.requestRenderIfNotRequested.bind(this)),this.history=[],this.oldData=this.cloneData(this.data),this.data.gui.enable&&(this.gui=new n2(this.data),this.gui.addEventListener("changed",Vt.debounce(()=>{this.changeData(this.gui.data)},300))),this.scene.add(this.object);const i=window.performance.now()-t;this.outputContainer=document.getElementById("output"),this.outputContainer&&(this.outputContainer.innerText=`${i.toFixed(3)}ms`),this.init(),this.event=new yR(this),setTimeout(()=>{window.firstJsonRendering&&window.firstJsonRendering()},500);let r=this.data;Object.defineProperty(this,"data",{get:function(){return r},set:(function(a){r=a,this.generateObject(),this.qualityToggler.updateGuiData(a.options.quality),this.colorPalette.updateGuiData(a),this.hideLoading()}).bind(this)})}preLoadModels(){const e=new Yl;Object.keys(Ft).forEach(t=>{Object.keys(Ft[t]).forEach(async i=>{const r=Ft[t][i],a=await e.loadAsync(r);this.data.door.models[t][i]=a.scene})})}render(){this.renderRequested=!1,this.controls.orbitControls.update(),this.data.general.isEffect&&this.composer?this.composer.render():this.renderer.render(this.scene,this.camera),this.CSS2DRenderer&&this.CSS2DRenderer.render(this.scene,this.camera)}requestRenderIfNotRequested(){this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(this.render.bind(this)))}init(){var e=document.getElementById(this.config.containerId);this.renderer.setSize(e.clientWidth,e.clientHeight),e.appendChild(this.renderer.domElement);let t;IR.isWebGL2Available()&&(t=new Yi(e.clientWidth,e.clientHeight,{type:Rr,format:Cr,colorSpace:this.renderer.outputColorSpace}),t.samples=8),this.composer=new RR(this.renderer,t);const i=new LR(this.scene,this.camera,null,new Ke().setHex(16777215),0);this.composer.addPass(i);const r=new Vp(PR);this.composer.addPass(r),this.outlinePass=new Na(new pe(e.clientWidth,e.clientHeight),this.scene,this.camera),this.outlinePass.visibleEdgeColor.set("#fff"),this.outlinePass.hiddenEdgeColor.set("#fff"),this.composer.addPass(this.outlinePass);const a=new Vp(CR),s=this.renderer.getPixelRatio();a.material.uniforms.resolution.value.x=1/(e.clientWidth*s),a.material.uniforms.resolution.value.y=1/(e.clientHeight*s),this.composer.addPass(a),this.composer.addPass(this.outlinePass),this.CSS2DRenderer=new EC,this.CSS2DRenderer.setSize(e.clientWidth,e.clientHeight),this.CSS2DRenderer.domElement.style.top="0",this.CSS2DRenderer.domElement.style.position="absolute",this.CSS2DRenderer.domElement.style.pointerEvents="none",e.appendChild(this.CSS2DRenderer.domElement),this.initUi()}generateObject(e){const t=window.performance.now();this.object.dispose(),this.scene.remove(this.object),this.object=new jv(this.data),this.ground.receiveShadow=this.data.general.isShadow,this.scene.add(this.object),this.outlinePass.selectedObjects=[],this.controls.setDraggableObjects(this.object),this.reHighlightObjects(),this.requestRenderIfNotRequested();const i=window.performance.now()-t;this.outputContainer&&(this.outputContainer.innerText=`${i.toFixed(3)}ms`)}cloneData(e){let t=Vt.cloneDeep(e);return this.history.push(t),t}changeData(e){globalThis.options=e.options;const t=this.preprocessingData(e);t!==!1&&(this.cloneData(t),this.showLoading(),console.debug("[EXPORT][onUpdateData]",nt.exportUiJson(t)),window.renderModelElementOnPanel&&window.renderModelElementOnPanel(nt.exportUiJson(t)),setTimeout(()=>this.data=t,0))}updateNewData(e){const t=nt.mergeJson(e,this.data);t.options.quality="medium",this.changeData(t)}preprocessingData(e){const t=(s,l,h)=>{let c=l;for(let d=h.length-1;d>=0&&(h[d].is_valid=!1,c-=h[d].size.width,!(c<=s));d--);return h},i=()=>{if(!this.history)return;const s=["front","back","left","right"],l=this.history[this.history.length-1];if(!Vt.isEqual(e.size,l.size)||e.doors.length!==l.doors.length||e.windows.length!==l.windows.length){const h=s.flatMap(c=>{let d=0,p=e.doors.filter(x=>{if(x.side===c)return x.is_valid=!0,d+=x.size.width,x}),f=e.windows.filter(x=>{if(x.side===c)return x.is_valid=!0,d+=x.size.width,x});if(d===0)return[];Array.prototype.push.apply(p,f),p.sort((x,y)=>x.position.x-y.position.x);const m=["left","right"].includes(c)?e.size.length:e.size.width,_=["left","right"].includes(c)?l.size.length:l.size.width;if(m!=_||e.doors.length!==l.doors.length||e.windows.length!==l.windows.length){const x=m-e.trim.width*2;_-l.trim.width*2;let y=1;d>x?p=t(x,d,p):y=(x-d)/(p.length+1);let v=-x/2;p.forEach(M=>{const b=M.size.width/2;v=v+b+y,M.position.x=v,v=v+b})}if(!Vt.isEqual(e.size.height,l.size.height)||e.doors.length!==l.doors.length||e.windows.length!==l.windows.length){const x=e.size.height,y=l.size.height,v=x/y;p.reduce((b,S)=>b>S.size.height?b:S.size.height,0);const M=p.filter(b=>b.type!="window");p=p.filter((b,S)=>{if(b.type==="window"){let A=!0;return b.position.y*=v,b.position.y=Math.min(b.position.y,x-b.size.height),M.length&&M.forEach(T=>{const E=[T.position.x-T.size.width/2,T.position.x+T.size.width/2],I=b.position.x<=E[1]&&b.position.x>=E[0],C=b.size.height+T.size.height>=x;if(I&&C)A=!1;else if(I){const P=T.size.height+b.size.height/2;b.position.y=Math.max(b.position.y,P)}}),A}else return b.size.height<=x})}return p});h.length&&(e.doors=h.filter(c=>!!c&&c.type!="window"),e.windows=h.filter(c=>!!c&&c.type==="window"))}},r=()=>{e.doors.forEach((s,l)=>{s.position||(s.position={x:0,y:0,z:0}),s.position.y!==s.size.height/2&&(s.position.y=s.size.height/2)}),e.windows.forEach((s,l)=>{s.position||(s.position={x:0,y:0,z:0}),s.position.y<s.size.height/2&&(s.position.y=e.size.height/2)})},a=()=>{const s=e.size.width,l=e.size.length,h={name:"leanTos",type:"leanTos",openType:{front:"close",left:"close",right:"close"},connected:{leftExtend:0,rightExtend:0},side:"",size:{width:nt.scaleToModel(8),length:0,height:nt.scaleToModel(10)}};var c,d,p,f=0,m,_,x,y=0;let v=e.leanTos.wrap.frontLeft,M=e.leanTos.wrap.frontRight,b=e.leanTos.wrap.backLeft,S=e.leanTos.wrap.backRight,A,T,E,I;e.leanTos.list.forEach(C=>{switch(C.size.height>e.size.height&&(C.size.height=e.size.height),C.connected={leftExtend:0,rightExtend:0},C.side){case"front":A=C;break;case"back":T=C;break;case"left":E=C;break;case"right":I=C;break}}),e.leanTos.list.forEach(C=>{switch(C.side){case"front":C.canWrapLeft=!!E,C.canWrapRight=!!I;break;case"back":C.canWrapLeft=!!I,C.canWrapRight=!!E;break;case"left":C.canWrapLeft=!!T,C.canWrapRight=!!A;break;case"right":C.canWrapLeft=!!A,C.canWrapRight=!!T;break}}),v?(A?A.position={x:-(s-A.size.length)/2,y:0,z:0}:(A=Vt.cloneDeep(h),A.side="front",A.size.length=s,e.leanTos.list.push(A)),E?E.position={x:(l-E.size.length)/2,y:0,z:0}:(E=Vt.cloneDeep(h),E.side="left",E.size.length=l,e.leanTos.list.push(E)),c=A.size.width>E.size.width?E.size.width:A.size.width,m=A.size.height>E.size.height?E.size.height:A.size.height,A.size.width=c,E.size.width=c,A.size.height=m,E.size.height=m,A.connected.leftExtend=c,E.connected.rightExtend=c):(A&&(A.connected.leftExtend=0),E&&(E.connected.rightExtend=0)),M?(A?v?(A.size.length=s,A.position=null):A.position={x:(s-A.size.length)/2,y:0,z:0}:(A=Vt.cloneDeep(h),A.side="front",A.size.length=s,e.leanTos.list.push(A)),I?I.position={x:-(l-I.size.length)/2,y:0,z:0}:(I=Vt.cloneDeep(h),I.side="right",I.size.length=l,e.leanTos.list.push(I)),d=A.size.width>I.size.width?I.size.width:A.size.width,_=A.size.height>I.size.height?I.size.height:A.size.height,v&&(c>d?c=d:d=c,m>_?m=_:_=m),A.size.width=d,I.size.width=d,A.size.height=_,I.size.height=_,A.connected.rightExtend=d,I.connected.leftExtend=d):(A&&(A.connected.rightExtend=0),I&&(I.connected.leftExtend=0)),b?(T?T.position={x:(s-T.size.length)/2,y:0,z:0}:(T=Vt.cloneDeep(h),T.side="back",T.size.length=s,e.leanTos.list.push(T)),E?v?(E.size.length=l,E.position=null):E.position={x:-(l-E.size.length)/2,y:0,z:0}:(E=Vt.cloneDeep(h),E.side="left",E.size.length=l,e.leanTos.list.push(E)),p=T.size.width>E.size.width?E.size.width:T.size.width,x=T.size.height>E.size.height?E.size.height:T.size.height,v&&(c<p?c=p:p=c,m<x?m=x:x=m),E.size.width=p,T.size.width=p,E.size.height=x,T.size.height=x,E.connected.leftExtend=p,T.connected.rightExtend=p):(T&&(T.connected.rightExtend=0),E&&(E.connected.leftExtend=0)),S?(T?b?(T.size.length=s,T.position=null):T.position={x:-(s-T.size.length)/2,y:0,z:0}:(T=Vt.cloneDeep(h),T.side="back",T.size.length=s,e.leanTos.list.push(T)),I?M?(I.size.length=l,I.position=null):I.position={x:(l-I.size.length)/2,y:0,z:0}:(I=Vt.cloneDeep(h),I.side="right",I.size.length=l,e.leanTos.list.push(I)),f=T.size.width>I.size.width?I.size.width:T.size.width,y=T.size.height>I.size.height?I.size.height:T.size.height,v&&(c<f?c=f:f=c,m<y?m=y:y=m),b&&(p<f?p=f:f=p,x<y?x=y:y=x),T.size.width=f,I.size.width=f,T.size.height=y,I.size.height=y,T.connected.leftExtend=f,I.connected.rightExtend=f):(T&&(T.connected.leftExtend=0),I&&(I.connected.rightExtend=0))};return r(),i(),a(),e}initUi(){const e=document.getElementById(this.config.containerId);this.loadingIndicator=new GC(e),this.qualityToggler=new YC(e,t=>{this.data.options.quality=t,this.data.options.roofQuality=t,this.data.options.wallQuality="medium",setTimeout(()=>this.changeData(this.data),200)}),this.colorPalette=new QI(e,this,(t,i)=>{switch(t){case"roof":this.data.roof.color=i;break;case"wall":this.data.wall.color=i;break;case"trim":this.data.trim.color=i,this.data.door.color=i;break;case"wainscotting":this.data.options.wainscotting.color=i;break;default:return}this.changeData(this.data)}),this.contextMenu=new hO(e)}showLoading(){this.loadingIndicator.show()}hideLoading(){this.loadingIndicator.hide()}deleteObject(e){let t=Vt.cloneDeep(this.data);for(let i=0;i<t.doors.length;i++)if(t.doors[i].id===e){t.doors.splice(i,1),t.options.quality="medium",t.options.roofQuality="medium",this.changeData(t);return}for(let i=0;i<t.windows.length;i++)if(t.windows[i].id===e){t.windows.splice(i,1),t.options.quality="medium",t.options.roofQuality="medium",this.changeData(t);return}for(let i=0;i<t.cupola.length;i++)if(t.cupola[i].id===e){t.cupola.splice(i,1),t.options.quality="medium",t.options.roofQuality="medium",this.changeData(t);return}for(let i=0;i<t.leanTos.list.length;i++)if(console.log(e),t.leanTos.list[i].side===e){switch(t.leanTos.list.splice(i,1),e){case"front":t.leanTos.wrap.frontLeft=!1,t.leanTos.wrap.frontRight=!1;break;case"back":t.leanTos.wrap.backLeft=!1,t.leanTos.wrap.backRight=!1;break;case"left":t.leanTos.wrap.frontLeft=!1,t.leanTos.wrap.backLeft=!1;break;case"right":t.leanTos.wrap.backRight=!1,t.leanTos.wrap.frontRight=!1;break}t.options.quality="medium",t.options.roofQuality="medium",this.changeData(t);return}}duplicateObject(e){e.id!==""&&(e.id="");let t=Vt.cloneDeep(this.data);e.type==="window"?(e._id=Math.max(...t.windows.map(i=>i._id||0))+1,t.windows.push(e)):e.type==="large_door"||e.type==="entry_door"?(e._id=Math.max(...t.doors.map(i=>i._id||0))+1,t.doors.push(e)):e.type==="cupola"&&(e._id=Math.max(...t.cupola.map(i=>i._id||0))+1,t.cupola.push(e)),t.options.quality="medium",t.options.roofQuality="medium",this.changeData(t)}toggleWeathervane(e){let t=Vt.cloneDeep(this.data);for(let i=0;i<t.cupola.length;i++)if(t.cupola[i].id===e){t.cupola[i].eagleWeatherwave=!t.cupola[i].eagleWeatherwave,t.options.quality="medium",t.options.roofQuality="medium",this.changeData(t);return}}changeLeanToWidth(e,t){if(t&&t>1){const i=nt.scaleToModel(t*1);let r=Vt.cloneDeep(this.data);for(let a=0;a<r.leanTos.list.length;a++){const s=r.leanTos.list[a];if(s.side===e){s.size.width=i,r.options.quality="medium",r.options.roofQuality="medium",r=this.applyWidthForConnectedSide(r,s,i),this.changeData(r);return}}}}applyWidthForConnectedSide(e,t,i){let r,a,s,l;switch(e.leanTos.list.forEach(h=>{switch(h.side){case"front":r=h;break;case"back":a=h;break;case"left":s=h;break;case"right":l=h;break}}),t.side){case"front":t.connected.leftExtend&&(s.size.width=i),t.connected.rightExtend&&(l.size.width=i);break;case"back":t.connected.leftExtend&&(l.size.width=i),t.connected.rightExtend&&(s.size.width=i);break;case"left":t.connected.leftExtend&&(a.size.width=i),t.connected.rightExtend&&(r.size.width=i);break;case"right":t.connected.leftExtend&&(r.size.width=i),t.connected.rightExtend&&(a.size.width=i);break}return e}changeLeanToOverhang(e,t){if(t&&t>0){let i=Vt.cloneDeep(this.data);i.leanTos.roof.extend=t*1,i.options.quality="medium",i.options.roofQuality="medium",this.changeData(i)}}changeLeanToOpenType(e,t){if(t&&["open_bottom","close"].includes(t)){let i=Vt.cloneDeep(this.data);for(let r=0;r<i.leanTos.list.length;r++)if(i.leanTos.list[r].side===e){i.leanTos.list[r].openType.front=t,i.leanTos.list[r].openType.left=t,i.leanTos.list[r].openType.right=t,i.options.quality="medium",i.options.roofQuality="medium",this.changeData(i);return}}}changeWrapAround(e,t,i){if(e&&t&&["front","back","left","right"].includes(e)&&["left","right"].includes(t)){let r=Vt.cloneDeep(this.data);switch(e){case"front":t==="left"?r.leanTos.wrap.frontLeft=i:t==="right"&&(r.leanTos.wrap.frontRight=i);break;case"back":t==="left"?r.leanTos.wrap.backRight=i:t==="right"&&(r.leanTos.wrap.backLeft=i);break;case"left":t==="left"?r.leanTos.wrap.backLeft=i:t==="right"&&(r.leanTos.wrap.frontLeft=i);break;case"right":t==="left"?r.leanTos.wrap.frontRight=i:t==="right"&&(r.leanTos.wrap.backRight=i);break}r.options.quality="medium",r.options.roofQuality="medium",this.changeData(r)}}selectSide(e){for(;this.outlinePass.selectedObjects.length;)this.outlinePass.selectedObjects.pop();let t;e!=="none"?(t=e,this.highlightedObject=this.object.getObjectByName(e+"_wall"),this.outlinePass.selectedObjects.push(this.highlightedObject),window.onModelSelectObject&&window.onModelSelectObject({})):(t=null,this.highlightedObject=null);const i=this.data.selectedSide;this.data.selectedSide=t,i!==this.data.selectedSide&&(console.debug("[SIDE CHANGED] - ",i,"-->",this.data.selectedSide),console.debug("[EXPORT][selectSide]",nt.exportUiJson(this.data)),window.renderModelElementOnPanel&&window.renderModelElementOnPanel(nt.exportUiJson(this.data))),this.requestRenderIfNotRequested()}selectObject(e){var r,a,s,l;for(;this.outlinePass.selectedObjects.length;)this.outlinePass.selectedObjects.pop();let t;if(e!=="none"){t=null;const h=this.highlightedObject;if(this.highlightedObject=e,this.highlightObject(),h===null||((a=(r=h==null?void 0:h.userData)==null?void 0:r.data)==null?void 0:a.id)!==this.highlightedObject.userData.data.id||((l=(s=h==null?void 0:h.userData)==null?void 0:s.data)==null?void 0:l.side)!==this.highlightedObject.userData.data.side)try{let c=this.highlightedObject.userData.data.type||this.highlightedObject.userData.data.name;c==="window"&&(c="windows");const d={type:c};c==="leanTos"?d.side=this.highlightedObject.userData.data.side:d.id=this.highlightedObject.userData.data._id,console.log(d),window.onModelSelectObject&&window.onModelSelectObject(d)}catch{}}else t=this.data.selectedSide,this.highlightedObject=null,window.onModelSelectObject&&window.onModelSelectObject({});const i=this.data.selectedSide;this.data.selectedSide=t,i!==this.data.selectedSide&&(console.debug("[SIDE CHANGED] - ",i,"-->",this.data.selectedSide),console.debug("[EXPORT][selectObject]",nt.exportUiJson(this.data)),window.renderModelElementOnPanel&&window.renderModelElementOnPanel(nt.exportUiJson(this.data))),this.requestRenderIfNotRequested()}highlightObject(){this.highlightedObject instanceof rt?this.outlinePass.selectedObjects.push(this.highlightedObject):this.highlightedObject instanceof yn&&this.highlightedObject.traverseVisible((function(e){(e.name.slice(-4)==="roof"||e.name.slice(-4)==="wall")&&this.outlinePass.selectedObjects.push(e)}).bind(this))}reHighlightObjects(){let e=!1;for(;this.outlinePass.selectedObjects.length;)this.outlinePass.selectedObjects.pop();this.highlightedObject&&this.object.traverse(t=>{var i,r,a,s,l,h,c,d,p,f,m,_,x,y,v,M;if(!e&&(console.log((i=t.userData)==null?void 0:i.data),((s=(a=(r=this.highlightedObject)==null?void 0:r.userData)==null?void 0:a.data)==null?void 0:s.type)&&this.highlightedObject.userData.data.type===((h=(l=t.userData)==null?void 0:l.data)==null?void 0:h.type)&&(this.highlightedObject.name&&this.highlightedObject.name===t.name||((p=(d=(c=this.highlightedObject)==null?void 0:c.userData)==null?void 0:d.data)==null?void 0:p.id)&&this.highlightedObject.userData.data.id===((m=(f=t.userData)==null?void 0:f.data)==null?void 0:m.id)||((y=(x=(_=this.highlightedObject)==null?void 0:_.userData)==null?void 0:x.data)==null?void 0:y._id)&&this.highlightedObject.userData.data._id===((M=(v=t.userData)==null?void 0:v.data)==null?void 0:M._id)))){console.log("found"),e=!0,this.highlightedObject=t,this.highlightObject();return}})}onUiSelectObject(e){let t=e.type;t==="windows"&&(t="window");let i=!1;for(;this.outlinePass.selectedObjects.length;)this.outlinePass.selectedObjects.pop();this.object.traverse(r=>{if(!(i||!r.userData.data)&&r.userData.data.type===t&&(t!=="leanTos"&&r.userData.data._id===e.id||t==="leanTos"&&r.userData.data.side===e.side)){i=!0,this.highlightedObject=r,this.highlightObject();return}}),this.requestRenderIfNotRequested()}}const uO=await fetch("../3d-config.json"),dO=await uO.json();console.log({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1});var Ho=new cO(dO);Ho.requestRenderIfNotRequested(),window.updateData=function(n){Ho.updateNewData(n),Ho.requestRenderIfNotRequested()},window.onUiSelectObject=function(n){Ho.onUiSelectObject(n)},Ho.controls.dragControls.addEventListener("sideslected",n=>{}),Ho.controls.dragControls.addEventListener("objectslected",n=>{})})();
Leave a Comment