(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(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 n(i){if(i.ep)return;i.ep=!0;const r=t(i);fetch(i.href,r)}})();/** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */const zf="175",Ra={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Sa={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},a0=0,zp=1,l0=2,uM=3,hM=0,xm=1,c0=2,ps=3,bs=0,$i=1,Qr=2,Xs=0,Pa=1,Hp=2,Vp=3,Gp=4,u0=5,vo=100,h0=101,f0=102,d0=103,p0=104,m0=200,g0=201,_0=202,y0=203,$h=204,Yh=205,v0=206,x0=207,b0=208,M0=209,S0=210,T0=211,w0=212,E0=213,A0=214,jh=0,Zh=1,Kh=2,Fa=3,Jh=4,Qh=5,ef=6,tf=7,fu=0,C0=1,R0=2,qs=0,P0=1,I0=2,L0=3,D0=4,N0=5,O0=6,U0=7,Wp="attached",F0="detached",Hf=300,Ys=301,Ao=302,$c=303,Yc=304,Jl=306,Co=1e3,vr=1001,Ol=1002,ui=1003,Vf=1004,fM=1004,Ta=1005,dM=1005,qn=1006,Rl=1007,pM=1007,Fr=1008,mM=1008,Ms=1009,bm=1010,Mm=1011,Ul=1012,Gf=1013,js=1014,nr=1015,Ql=1016,Wf=1017,Xf=1018,Fl=1020,Sm=35902,Tm=1021,wm=1022,qi=1023,Em=1024,Am=1025,Bl=1026,kl=1027,qf=1028,du=1029,Cm=1030,$f=1031,gM=1032,Yf=1033,Uc=33776,Fc=33777,Bc=33778,kc=33779,nf=35840,rf=35841,sf=35842,of=35843,af=36196,lf=37492,cf=37496,uf=37808,hf=37809,ff=37810,df=37811,pf=37812,mf=37813,gf=37814,_f=37815,yf=37816,vf=37817,xf=37818,bf=37819,Mf=37820,Sf=37821,zc=36492,Tf=36494,wf=36495,Rm=36283,Ef=36284,Af=36285,Cf=36286,B0=2200,k0=2201,z0=2202,zl=2300,Hl=2301,Fh=2302,wa=2400,Ea=2401,jc=2402,jf=2500,Pm=2501,H0=0,Im=1,Rf=2,V0=3200,G0=3201,_M=3202,yM=3203,Lo=0,W0=1,Hs="",ci="srgb",Ni="srgb-linear",Zc="linear",bn="srgb",vM=0,va=7680,xM=7681,bM=7682,MM=7683,SM=34055,TM=34056,wM=5386,EM=512,AM=513,CM=514,RM=515,PM=516,IM=517,LM=518,Xp=519,X0=512,q0=513,$0=514,Lm=515,Y0=516,j0=517,Z0=518,K0=519,Kc=35044,DM=35048,NM=35040,OM=35045,UM=35049,FM=35041,BM=35046,kM=35050,zM=35042,HM="100",qp="300 es",ts=2e3,Jc=2001,VM={COMPUTE:"compute",RENDER:"render"};class ws{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const i=n[e];if(i!==void 0){const r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const i=n.slice(0);for(let r=0,o=i.length;r>8&255]+Ai[s>>16&255]+Ai[s>>24&255]+"-"+Ai[e&255]+Ai[e>>8&255]+"-"+Ai[e>>16&15|64]+Ai[e>>24&255]+"-"+Ai[t&63|128]+Ai[t>>8&255]+"-"+Ai[t>>16&255]+Ai[t>>24&255]+Ai[n&255]+Ai[n>>8&255]+Ai[n>>16&255]+Ai[n>>24&255]).toLowerCase()}function Lt(s,e,t){return Math.max(e,Math.min(t,s))}function Dm(s,e){return(s%e+e)%e}function GM(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function WM(s,e,t){return s!==e?(t-s)/(e-s):0}function Hc(s,e,t){return(1-t)*s+t*e}function XM(s,e,t,n){return Hc(s,e,1-Math.exp(-t*n))}function qM(s,e=1){return e-Math.abs(Dm(s,e*2)-e)}function $M(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function YM(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function jM(s,e){return s+Math.floor(Math.random()*(e-s+1))}function ZM(s,e){return s+Math.random()*(e-s)}function KM(s){return s*(.5-Math.random())}function JM(s){s!==void 0&&(n_=s);let e=n_+=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 QM(s){return s*Ia}function eS(s){return s*Vl}function tS(s){return(s&s-1)===0&&s!==0}function nS(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function iS(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function rS(s,e,t,n,i){const r=Math.cos,o=Math.sin,a=r(t/2),l=o(t/2),c=r((e+n)/2),u=o((e+n)/2),f=r((e-n)/2),d=o((e-n)/2),p=r((n-e)/2),v=o((n-e)/2);switch(i){case"XYX":s.set(a*u,l*f,l*d,a*c);break;case"YZY":s.set(l*d,a*u,l*f,a*c);break;case"ZXZ":s.set(l*f,l*d,a*u,a*c);break;case"XZX":s.set(a*u,l*v,l*p,a*c);break;case"YXY":s.set(l*p,a*u,l*v,a*c);break;case"ZYZ":s.set(l*v,l*p,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Wi(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Ut(s,e){switch(e.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}const Nm={DEG2RAD:Ia,RAD2DEG:Vl,generateUUID:Mr,clamp:Lt,euclideanModulo:Dm,mapLinear:GM,inverseLerp:WM,lerp:Hc,damp:XM,pingpong:qM,smoothstep:$M,smootherstep:YM,randInt:jM,randFloat:ZM,randFloatSpread:KM,seededRandom:JM,degToRad:QM,radToDeg:eS,isPowerOfTwo:tS,ceilPowerOfTwo:nS,floorPowerOfTwo:iS,setQuaternionFromProperEuler:rS,normalize:Ut,denormalize:Wi};class Ae{constructor(e=0,t=0){Ae.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Lt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Lt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*n-o*i+e.x,this.y=r*i+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Dt{constructor(e,t,n,i,r,o,a,l,c){Dt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,l,c)}set(e,t,n,i,r,o,a,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=a,u[3]=t,u[4]=r,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],f=n[7],d=n[2],p=n[5],v=n[8],x=i[0],b=i[3],y=i[6],w=i[1],E=i[4],S=i[7],I=i[2],L=i[5],g=i[8];return r[0]=o*x+a*w+l*I,r[3]=o*b+a*E+l*L,r[6]=o*y+a*S+l*g,r[1]=c*x+u*w+f*I,r[4]=c*b+u*E+f*L,r[7]=c*y+u*S+f*g,r[2]=d*x+p*w+v*I,r[5]=d*b+p*E+v*L,r[8]=d*y+p*S+v*g,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*r*u+n*a*l+i*r*c-i*o*l}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],f=u*o-a*c,d=a*l-u*r,p=c*r-o*l,v=t*f+n*d+i*p;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/v;return e[0]=f*x,e[1]=(i*c-u*n)*x,e[2]=(a*n-i*o)*x,e[3]=d*x,e[4]=(u*t-i*l)*x,e[5]=(i*r-a*t)*x,e[6]=p*x,e[7]=(n*l-c*t)*x,e[8]=(o*t-n*r)*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,n,i,r,o,a){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-i*c,i*l,-i*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(zd.makeScale(e,t)),this}rotate(e){return this.premultiply(zd.makeRotation(-e)),this}translate(e,t){return this.premultiply(zd.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const zd=new Dt;function J0(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}const sS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function wl(s,e){return new sS[s](e)}function Qc(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function Q0(){const s=Qc("canvas");return s.style.display="block",s}const i_={};function Bh(s){s in i_||(i_[s]=!0,console.warn(s))}function oS(s,e,t){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(e,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}function aS(s){const e=s.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function lS(s){const e=s.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}const r_=new Dt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),s_=new Dt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function cS(){const s={enabled:!0,workingColorSpace:Ni,spaces:{},convert:function(i,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===bn&&(i.r=$s(i.r),i.g=$s(i.g),i.b=$s(i.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===bn&&(i.r=Pl(i.r),i.g=Pl(i.g),i.b=Pl(i.b))),i},fromWorkingColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},toWorkingColorSpace:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Hs?Zc:this.spaces[i].transfer},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,o){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[Ni]:{primaries:e,whitePoint:n,transfer:Zc,toXYZ:r_,fromXYZ:s_,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:ci},outputColorSpaceConfig:{drawingBufferColorSpace:ci}},[ci]:{primaries:e,whitePoint:n,transfer:bn,toXYZ:r_,fromXYZ:s_,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:ci}}}),s}const en=cS();function $s(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Pl(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let ol;class ev{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{ol===void 0&&(ol=Qc("canvas")),ol.width=e.width,ol.height=e.height;const i=ol.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),n=ol}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Qc("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Hf)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Co:e.x=e.x-Math.floor(e.x);break;case vr:e.x=e.x<0?0:1;break;case Ol: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 Co:e.y=e.y-Math.floor(e.y);break;case vr:e.y=e.y<0?0:1;break;case Ol:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}On.DEFAULT_IMAGE=null;On.DEFAULT_MAPPING=Hf;On.DEFAULT_ANISOTROPY=1;class un{constructor(e=0,t=0,n=0,i=1){un.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*t+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*t+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*t+o[7]*n+o[11]*i+o[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const l=e.elements,c=l[0],u=l[4],f=l[8],d=l[1],p=l[5],v=l[9],x=l[2],b=l[6],y=l[10];if(Math.abs(u-d)<.01&&Math.abs(f-x)<.01&&Math.abs(v-b)<.01){if(Math.abs(u+d)<.1&&Math.abs(f+x)<.1&&Math.abs(v+b)<.1&&Math.abs(c+p+y-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,S=(p+1)/2,I=(y+1)/2,L=(u+d)/4,g=(f+x)/4,F=(v+b)/4;return E>S&&E>I?E<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(E),i=L/n,r=g/n):S>I?S<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(S),n=L/i,r=F/i):I<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(I),n=g/r,i=F/r),this.set(n,i,r,t),this}let w=Math.sqrt((b-v)*(b-v)+(f-x)*(f-x)+(d-u)*(d-u));return Math.abs(w)<.001&&(w=1),this.x=(b-v)/w,this.y=(f-x)/w,this.z=(d-u)/w,this.w=Math.acos((c+p+y-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this.z=Lt(this.z,e.z,t.z),this.w=Lt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this.z=Lt(this.z,e,t),this.w=Lt(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Lt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Zf extends ws{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new un(0,0,e,t),this.scissorTest=!1,this.viewport=new un(0,0,e,t);const i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:qn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new On(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a=0?1:-1,E=1-y*y;if(E>Number.EPSILON){const I=Math.sqrt(E),L=Math.atan2(I,y*w);b=Math.sin(b*L)/I,a=Math.sin(a*L)/I}const S=a*w;if(l=l*b+d*S,c=c*b+p*S,u=u*b+v*S,f=f*b+x*S,b===1-a){const I=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=I,c*=I,u*=I,f*=I}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=f}static multiplyQuaternionsFlat(e,t,n,i,r,o){const a=n[i],l=n[i+1],c=n[i+2],u=n[i+3],f=r[o],d=r[o+1],p=r[o+2],v=r[o+3];return e[t]=a*v+u*f+l*p-c*d,e[t+1]=l*v+u*d+c*f-a*p,e[t+2]=c*v+u*p+a*d-l*f,e[t+3]=u*v-a*f-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(i/2),f=a(r/2),d=l(n/2),p=l(i/2),v=l(r/2);switch(o){case"XYZ":this._x=d*u*f+c*p*v,this._y=c*p*f-d*u*v,this._z=c*u*v+d*p*f,this._w=c*u*f-d*p*v;break;case"YXZ":this._x=d*u*f+c*p*v,this._y=c*p*f-d*u*v,this._z=c*u*v-d*p*f,this._w=c*u*f+d*p*v;break;case"ZXY":this._x=d*u*f-c*p*v,this._y=c*p*f+d*u*v,this._z=c*u*v+d*p*f,this._w=c*u*f-d*p*v;break;case"ZYX":this._x=d*u*f-c*p*v,this._y=c*p*f+d*u*v,this._z=c*u*v-d*p*f,this._w=c*u*f+d*p*v;break;case"YZX":this._x=d*u*f+c*p*v,this._y=c*p*f+d*u*v,this._z=c*u*v-d*p*f,this._w=c*u*f-d*p*v;break;case"XZY":this._x=d*u*f-c*p*v,this._y=c*p*f-d*u*v,this._z=c*u*v+d*p*f,this._w=c*u*f+d*p*v;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],f=t[10],d=n+a+f;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(u-l)*p,this._y=(r-c)*p,this._z=(o-i)*p}else if(n>a&&n>f){const p=2*Math.sqrt(1+n-a-f);this._w=(u-l)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+c)/p}else if(a>f){const p=2*Math.sqrt(1+a-n-f);this._w=(r-c)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+f-n-a);this._w=(o-i)/p,this._x=(r+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Lt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+i*c-r*l,this._y=i*u+o*l+r*a-n*c,this._z=r*u+o*c+n*l-i*a,this._w=o*u-n*a-i*l-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const n=this._x,i=this._y,r=this._z,o=this._w;let a=o*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;const l=1-a*a;if(l<=Number.EPSILON){const p=1-t;return this._w=p*o+t*this._w,this._x=p*n+t*this._x,this._y=p*i+t*this._y,this._z=p*r+t*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),f=Math.sin((1-t)*u)/c,d=Math.sin(t*u)/c;return this._w=o*f+this._w*d,this._x=n*f+this._x*d,this._y=i*f+this._y*d,this._z=r*f+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class H{constructor(e=0,t=0,n=0){H.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(o_.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(o_.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,o=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*i-a*n),u=2*(a*t-r*i),f=2*(r*n-o*t);return this.x=t+l*c+o*f-a*u,this.y=n+l*u+a*c-r*f,this.z=i+l*f+r*u-o*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,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Lt(this.x,e.x,t.x),this.y=Lt(this.y,e.y,t.y),this.z=Lt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Lt(this.x,e,t),this.y=Lt(this.y,e,t),this.z=Lt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Lt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,l=t.z;return this.x=i*l-r*a,this.y=r*o-n*l,this.z=n*a-i*o,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Vd.copy(this).projectOnVector(e),this.sub(Vd)}reflect(e){return this.sub(Vd.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Lt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Vd=new H,o_=new xi;class Li{constructor(e=new H(1/0,1/0,1/0),t=new H(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=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,jr),jr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_c),Xu.subVectors(this.max,_c),al.subVectors(e.a,_c),ll.subVectors(e.b,_c),cl.subVectors(e.c,_c),lo.subVectors(ll,al),co.subVectors(cl,ll),ia.subVectors(al,cl);let t=[0,-lo.z,lo.y,0,-co.z,co.y,0,-ia.z,ia.y,lo.z,0,-lo.x,co.z,0,-co.x,ia.z,0,-ia.x,-lo.y,lo.x,0,-co.y,co.x,0,-ia.y,ia.x,0];return!Gd(t,al,ll,cl,Xu)||(t=[1,0,0,0,1,0,0,0,1],!Gd(t,al,ll,cl,Xu))?!1:(qu.crossVectors(lo,co),t=[qu.x,qu.y,qu.z],Gd(t,al,ll,cl,Xu))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,jr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(jr).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:(Ps[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ps[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ps[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ps[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ps[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ps[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ps[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ps[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ps),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 Ps=[new H,new H,new H,new H,new H,new H,new H,new H],jr=new H,Wu=new Li,al=new H,ll=new H,cl=new H,lo=new H,co=new H,ia=new H,_c=new H,Xu=new H,qu=new H,ra=new H;function Gd(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){ra.fromArray(s,r);const a=i.x*Math.abs(ra.x)+i.y*Math.abs(ra.y)+i.z*Math.abs(ra.z),l=e.dot(ra),c=t.dot(ra),u=n.dot(ra);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const pS=new Li,yc=new H,Wd=new H;class Si{constructor(e=new H,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):pS.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;rthis.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;yc.subVectors(e,this.center);const t=yc.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(yc,i/n),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Wd.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yc.copy(e.center).add(Wd)),this.expandByPoint(yc.copy(e.center).sub(Wd))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Is=new H,Xd=new H,$u=new H,uo=new H,qd=new H,Yu=new H,$d=new H;class Wa{constructor(e=new H,t=new H(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,Is)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Is.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Is.copy(this.origin).addScaledVector(this.direction,t),Is.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Xd.copy(e).add(t).multiplyScalar(.5),$u.copy(t).sub(e).normalize(),uo.copy(this.origin).sub(Xd);const r=e.distanceTo(t)*.5,o=-this.direction.dot($u),a=uo.dot(this.direction),l=-uo.dot($u),c=uo.lengthSq(),u=Math.abs(1-o*o);let f,d,p,v;if(u>0)if(f=o*l-a,d=o*a-l,v=r*u,f>=0)if(d>=-v)if(d<=v){const x=1/u;f*=x,d*=x,p=f*(f+o*d+2*a)+d*(o*f+d+2*l)+c}else d=r,f=Math.max(0,-(o*d+a)),p=-f*f+d*(d+2*l)+c;else d=-r,f=Math.max(0,-(o*d+a)),p=-f*f+d*(d+2*l)+c;else d<=-v?(f=Math.max(0,-(-o*r+a)),d=f>0?-r:Math.min(Math.max(-r,-l),r),p=-f*f+d*(d+2*l)+c):d<=v?(f=0,d=Math.min(Math.max(-r,-l),r),p=d*(d+2*l)+c):(f=Math.max(0,-(o*r+a)),d=f>0?r:Math.min(Math.max(-r,-l),r),p=-f*f+d*(d+2*l)+c);else d=o>0?-r:r,f=Math.max(0,-(o*d+a)),p=-f*f+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(Xd).addScaledVector($u,d),p}intersectSphere(e,t){Is.subVectors(e.center,this.origin);const n=Is.dot(this.direction),i=Is.dot(Is)-n*n,r=e.radius*e.radius;if(i>r)return null;const o=Math.sqrt(r-i),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,i=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,i=(e.min.x-d.x)*c),u>=0?(r=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(r=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o=0?(a=(e.min.z-d.z)*f,l=(e.max.z-d.z)*f):(a=(e.max.z-d.z)*f,l=(e.min.z-d.z)*f),n>l||a>i)||((a>n||n!==n)&&(n=a),(l=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,Is)!==null}intersectTriangle(e,t,n,i,r){qd.subVectors(t,e),Yu.subVectors(n,e),$d.crossVectors(qd,Yu);let o=this.direction.dot($d),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;uo.subVectors(this.origin,e);const l=a*this.direction.dot(Yu.crossVectors(uo,Yu));if(l<0)return null;const c=a*this.direction.dot(qd.cross(uo));if(c<0||l+c>o)return null;const u=-a*uo.dot($d);return u<0?null:this.at(u/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class _t{constructor(e,t,n,i,r,o,a,l,c,u,f,d,p,v,x,b){_t.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,l,c,u,f,d,p,v,x,b)}set(e,t,n,i,r,o,a,l,c,u,f,d,p,v,x,b){const y=this.elements;return y[0]=e,y[4]=t,y[8]=n,y[12]=i,y[1]=r,y[5]=o,y[9]=a,y[13]=l,y[2]=c,y[6]=u,y[10]=f,y[14]=d,y[3]=p,y[7]=v,y[11]=x,y[15]=b,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 _t().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/ul.setFromMatrixColumn(e,0).length(),r=1/ul.setFromMatrixColumn(e,1).length(),o=1/ul.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(i),c=Math.sin(i),u=Math.cos(r),f=Math.sin(r);if(e.order==="XYZ"){const d=o*u,p=o*f,v=a*u,x=a*f;t[0]=l*u,t[4]=-l*f,t[8]=c,t[1]=p+v*c,t[5]=d-x*c,t[9]=-a*l,t[2]=x-d*c,t[6]=v+p*c,t[10]=o*l}else if(e.order==="YXZ"){const d=l*u,p=l*f,v=c*u,x=c*f;t[0]=d+x*a,t[4]=v*a-p,t[8]=o*c,t[1]=o*f,t[5]=o*u,t[9]=-a,t[2]=p*a-v,t[6]=x+d*a,t[10]=o*l}else if(e.order==="ZXY"){const d=l*u,p=l*f,v=c*u,x=c*f;t[0]=d-x*a,t[4]=-o*f,t[8]=v+p*a,t[1]=p+v*a,t[5]=o*u,t[9]=x-d*a,t[2]=-o*c,t[6]=a,t[10]=o*l}else if(e.order==="ZYX"){const d=o*u,p=o*f,v=a*u,x=a*f;t[0]=l*u,t[4]=v*c-p,t[8]=d*c+x,t[1]=l*f,t[5]=x*c+d,t[9]=p*c-v,t[2]=-c,t[6]=a*l,t[10]=o*l}else if(e.order==="YZX"){const d=o*l,p=o*c,v=a*l,x=a*c;t[0]=l*u,t[4]=x-d*f,t[8]=v*f+p,t[1]=f,t[5]=o*u,t[9]=-a*u,t[2]=-c*u,t[6]=p*f+v,t[10]=d-x*f}else if(e.order==="XZY"){const d=o*l,p=o*c,v=a*l,x=a*c;t[0]=l*u,t[4]=-f,t[8]=c*u,t[1]=d*f+x,t[5]=o*u,t[9]=p*f-v,t[2]=v*f-p,t[6]=a*u,t[10]=x*f+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(mS,e,gS)}lookAt(e,t,n){const i=this.elements;return pr.subVectors(e,t),pr.lengthSq()===0&&(pr.z=1),pr.normalize(),ho.crossVectors(n,pr),ho.lengthSq()===0&&(Math.abs(n.z)===1?pr.x+=1e-4:pr.z+=1e-4,pr.normalize(),ho.crossVectors(n,pr)),ho.normalize(),ju.crossVectors(pr,ho),i[0]=ho.x,i[4]=ju.x,i[8]=pr.x,i[1]=ho.y,i[5]=ju.y,i[9]=pr.y,i[2]=ho.z,i[6]=ju.z,i[10]=pr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],f=n[5],d=n[9],p=n[13],v=n[2],x=n[6],b=n[10],y=n[14],w=n[3],E=n[7],S=n[11],I=n[15],L=i[0],g=i[4],F=i[8],R=i[12],N=i[1],G=i[5],se=i[9],Y=i[13],he=i[2],pe=i[6],ce=i[10],ge=i[14],fe=i[3],Ue=i[7],ne=i[11],Ye=i[15];return r[0]=o*L+a*N+l*he+c*fe,r[4]=o*g+a*G+l*pe+c*Ue,r[8]=o*F+a*se+l*ce+c*ne,r[12]=o*R+a*Y+l*ge+c*Ye,r[1]=u*L+f*N+d*he+p*fe,r[5]=u*g+f*G+d*pe+p*Ue,r[9]=u*F+f*se+d*ce+p*ne,r[13]=u*R+f*Y+d*ge+p*Ye,r[2]=v*L+x*N+b*he+y*fe,r[6]=v*g+x*G+b*pe+y*Ue,r[10]=v*F+x*se+b*ce+y*ne,r[14]=v*R+x*Y+b*ge+y*Ye,r[3]=w*L+E*N+S*he+I*fe,r[7]=w*g+E*G+S*pe+I*Ue,r[11]=w*F+E*se+S*ce+I*ne,r[15]=w*R+E*Y+S*ge+I*Ye,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],l=e[9],c=e[13],u=e[2],f=e[6],d=e[10],p=e[14],v=e[3],x=e[7],b=e[11],y=e[15];return v*(+r*l*f-i*c*f-r*a*d+n*c*d+i*a*p-n*l*p)+x*(+t*l*p-t*c*d+r*o*d-i*o*p+i*c*u-r*l*u)+b*(+t*c*f-t*a*p-r*o*f+n*o*p+r*a*u-n*c*u)+y*(-i*a*u-t*l*f+t*a*d+i*o*f-n*o*d+n*l*u)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],f=e[9],d=e[10],p=e[11],v=e[12],x=e[13],b=e[14],y=e[15],w=f*b*c-x*d*c+x*l*p-a*b*p-f*l*y+a*d*y,E=v*d*c-u*b*c-v*l*p+o*b*p+u*l*y-o*d*y,S=u*x*c-v*f*c+v*a*p-o*x*p-u*a*y+o*f*y,I=v*f*l-u*x*l-v*a*d+o*x*d+u*a*b-o*f*b,L=t*w+n*E+i*S+r*I;if(L===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const g=1/L;return e[0]=w*g,e[1]=(x*d*r-f*b*r-x*i*p+n*b*p+f*i*y-n*d*y)*g,e[2]=(a*b*r-x*l*r+x*i*c-n*b*c-a*i*y+n*l*y)*g,e[3]=(f*l*r-a*d*r-f*i*c+n*d*c+a*i*p-n*l*p)*g,e[4]=E*g,e[5]=(u*b*r-v*d*r+v*i*p-t*b*p-u*i*y+t*d*y)*g,e[6]=(v*l*r-o*b*r-v*i*c+t*b*c+o*i*y-t*l*y)*g,e[7]=(o*d*r-u*l*r+u*i*c-t*d*c-o*i*p+t*l*p)*g,e[8]=S*g,e[9]=(v*f*r-u*x*r-v*n*p+t*x*p+u*n*y-t*f*y)*g,e[10]=(o*x*r-v*a*r+v*n*c-t*x*c-o*n*y+t*a*y)*g,e[11]=(u*a*r-o*f*r-u*n*c+t*f*c+o*n*p-t*a*p)*g,e[12]=I*g,e[13]=(u*x*i-v*f*i+v*n*d-t*x*d-u*n*b+t*f*b)*g,e[14]=(v*a*i-o*x*i-v*n*l+t*x*l+o*n*b-t*a*b)*g,e[15]=(o*f*i-u*a*i+u*n*l-t*f*l-o*n*d+t*a*d)*g,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,l=e.z,c=r*o,u=r*a;return this.set(c*o+n,c*a-i*l,c*l+i*a,0,c*a+i*l,u*a+n,u*l-i*o,0,c*l-i*a,u*l+i*o,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,o=t._y,a=t._z,l=t._w,c=r+r,u=o+o,f=a+a,d=r*c,p=r*u,v=r*f,x=o*u,b=o*f,y=a*f,w=l*c,E=l*u,S=l*f,I=n.x,L=n.y,g=n.z;return i[0]=(1-(x+y))*I,i[1]=(p+S)*I,i[2]=(v-E)*I,i[3]=0,i[4]=(p-S)*L,i[5]=(1-(d+y))*L,i[6]=(b+w)*L,i[7]=0,i[8]=(v+E)*g,i[9]=(b-w)*g,i[10]=(1-(d+x))*g,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=ul.set(i[0],i[1],i[2]).length();const o=ul.set(i[4],i[5],i[6]).length(),a=ul.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Zr.copy(this);const c=1/r,u=1/o,f=1/a;return Zr.elements[0]*=c,Zr.elements[1]*=c,Zr.elements[2]*=c,Zr.elements[4]*=u,Zr.elements[5]*=u,Zr.elements[6]*=u,Zr.elements[8]*=f,Zr.elements[9]*=f,Zr.elements[10]*=f,t.setFromRotationMatrix(Zr),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o,a=ts){const l=this.elements,c=2*r/(t-e),u=2*r/(n-i),f=(t+e)/(t-e),d=(n+i)/(n-i);let p,v;if(a===ts)p=-(o+r)/(o-r),v=-2*o*r/(o-r);else if(a===Jc)p=-o/(o-r),v=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=u,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,n,i,r,o,a=ts){const l=this.elements,c=1/(t-e),u=1/(n-i),f=1/(o-r),d=(t+e)*c,p=(n+i)*u;let v,x;if(a===ts)v=(o+r)*f,x=-2*f;else if(a===Jc)v=r*f,x=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=x,l[14]=-v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const ul=new H,Zr=new _t,mS=new H(0,0,0),gS=new H(1,1,1),ho=new H,ju=new H,pr=new H,a_=new _t,l_=new xi;class Tr{constructor(e=0,t=0,n=0,i=Tr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],o=i[4],a=i[8],l=i[1],c=i[5],u=i[9],f=i[2],d=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(Lt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Lt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,r),this._z=0);break;case"ZXY":this._x=Math.asin(Lt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Lt(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(Lt(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Lt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return a_.makeRotationFromQuaternion(e),this.setFromRotationMatrix(a_,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return l_.setFromEuler(this),this.setFromQuaternion(l_,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}}Tr.DEFAULT_ORDER="XYZ";class Jf{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function r(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){i.children=[];for(let a=0;a0){i.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),v.length>0&&(n.nodes=v)}return n.object=i,n;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Kr.subVectors(i,t),Ds.subVectors(n,t),jd.subVectors(e,t);const o=Kr.dot(Kr),a=Kr.dot(Ds),l=Kr.dot(jd),c=Ds.dot(Ds),u=Ds.dot(jd),f=o*c-a*a;if(f===0)return r.set(0,0,0),null;const d=1/f,p=(c*l-a*u)*d,v=(o*u-a*l)*d;return r.set(1-p-v,v,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ns)===null?!1:Ns.x>=0&&Ns.y>=0&&Ns.x+Ns.y<=1}static getInterpolation(e,t,n,i,r,o,a,l){return this.getBarycoord(e,t,n,i,Ns)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Ns.x),l.addScaledVector(o,Ns.y),l.addScaledVector(a,Ns.z),l)}static getInterpolatedAttribute(e,t,n,i,r,o){return Qd.setScalar(0),ep.setScalar(0),tp.setScalar(0),Qd.fromBufferAttribute(e,t),ep.fromBufferAttribute(e,n),tp.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(Qd,r.x),o.addScaledVector(ep,r.y),o.addScaledVector(tp,r.z),o}static isFrontFacing(e,t,n,i){return Kr.subVectors(n,t),Ds.subVectors(e,t),Kr.cross(Ds).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Kr.subVectors(this.c,this.b),Ds.subVectors(this.a,this.b),Kr.cross(Ds).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tr.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return tr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return tr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let o,a;dl.subVectors(i,n),pl.subVectors(r,n),Zd.subVectors(e,n);const l=dl.dot(Zd),c=pl.dot(Zd);if(l<=0&&c<=0)return t.copy(n);Kd.subVectors(e,i);const u=dl.dot(Kd),f=pl.dot(Kd);if(u>=0&&f<=u)return t.copy(i);const d=l*f-u*c;if(d<=0&&l>=0&&u<=0)return o=l/(l-u),t.copy(n).addScaledVector(dl,o);Jd.subVectors(e,r);const p=dl.dot(Jd),v=pl.dot(Jd);if(v>=0&&p<=v)return t.copy(r);const x=p*c-l*v;if(x<=0&&c>=0&&v<=0)return a=c/(c-v),t.copy(n).addScaledVector(pl,a);const b=u*v-p*f;if(b<=0&&f-u>=0&&p-v>=0)return p_.subVectors(r,i),a=(f-u)/(f-u+(p-v)),t.copy(i).addScaledVector(p_,a);const y=1/(b+x+d);return o=x*y,a=d*y,t.copy(n).addScaledVector(dl,o).addScaledVector(pl,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const tv={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},fo={h:0,s:0,l:0},Ku={h:0,s:0,l:0};function np(s,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?s+(e-s)*6*t:t<1/2?e:t<2/3?s+(e-s)*6*(2/3-t):s}class $e{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ci){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,en.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=en.workingColorSpace){return this.r=e,this.g=t,this.b=n,en.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=en.workingColorSpace){if(e=Dm(e,1),t=Lt(t,0,1),n=Lt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=np(o,r,e+1/3),this.g=np(o,r,e),this.b=np(o,r,e-1/3)}return en.toWorkingColorSpace(this,i),this}setStyle(e,t=ci){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ci){const n=tv[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=$s(e.r),this.g=$s(e.g),this.b=$s(e.b),this}copyLinearToSRGB(e){return this.r=Pl(e.r),this.g=Pl(e.g),this.b=Pl(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ci){return en.fromWorkingColorSpace(Ci.copy(this),e),Math.round(Lt(Ci.r*255,0,255))*65536+Math.round(Lt(Ci.g*255,0,255))*256+Math.round(Lt(Ci.b*255,0,255))}getHexString(e=ci){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=en.workingColorSpace){en.fromWorkingColorSpace(Ci.copy(this),t);const n=Ci.r,i=Ci.g,r=Ci.b,o=Math.max(n,i,r),a=Math.min(n,i,r);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=u<=.5?f/(o+a):f/(2-o-a),o){case n:l=(i-r)/f+(i0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Pa&&(n.blending=this.blending),this.side!==bs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==$h&&(n.blendSrc=this.blendSrc),this.blendDst!==Yh&&(n.blendDst=this.blendDst),this.blendEquation!==vo&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Fa&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Xp&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==va&&(n.stencilFail=this.stencilFail),this.stencilZFail!==va&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==va&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const o=[];for(const a in r){const l=r[a];delete l.metadata,o.push(l)}return o}if(t){const r=i(e.textures),o=i(e.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const i=t.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class xr extends hi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new $e(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Tr,this.combine=fu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Vs=MS();function MS(){const s=new ArrayBuffer(4),e=new Float32Array(s),t=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;(c&8388608)===0;)c<<=1,u-=8388608;c&=-8388609,u+=947912704,r[l]=c|u}for(let l=1024;l<2048;++l)r[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)o[l]=l<<23;o[31]=1199570944,o[32]=2147483648;for(let l=33;l<63;++l)o[l]=2147483648+(l-32<<23);o[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(a[l]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:o,offsetTable:a}}function er(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=Lt(s,-65504,65504),Vs.floatView[0]=s;const e=Vs.uint32View[0],t=e>>23&511;return Vs.baseTable[t]+((e&8388607)>>Vs.shiftTable[t])}function Ic(s){const e=s>>10;return Vs.uint32View[0]=Vs.mantissaTable[Vs.offsetTable[e]+(s&1023)]+Vs.exponentTable[e],Vs.floatView[0]}class SS{static toHalfFloat(e){return er(e)}static fromHalfFloat(e){return Ic(e)}}const ti=new H,Ju=new Ae;let TS=0;class pn{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:TS++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Kc,this.updateRanges=[],this.gpuType=nr,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;it.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Li);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[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 n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let f=0,d=c.length;f0&&(i[l]=u,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],f=r[c];for(let d=0,p=f.length;d0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r(e.far-e.near)**2))&&(m_.copy(r).invert(),sa.copy(e.ray).applyMatrix4(m_),!(n.boundingBox!==null&&sa.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,sa)))}_computeIntersections(e,t,n){let i;const r=this.geometry,o=this.material,a=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,f=r.attributes.normal,d=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let v=0,x=d.length;vt.far?null:{distance:c,point:rh.clone(),object:s}}function sh(s,e,t,n,i,r,o,a,l,c){s.getVertexPosition(a,eh),s.getVertexPosition(l,th),s.getVertexPosition(c,nh);const u=LS(s,e,t,n,eh,th,nh,__);if(u){const f=new H;tr.getBarycoord(__,eh,th,nh,f),i&&(u.uv=tr.getInterpolatedAttribute(i,a,l,c,f,new Ae)),r&&(u.uv1=tr.getInterpolatedAttribute(r,a,l,c,f,new Ae)),o&&(u.normal=tr.getInterpolatedAttribute(o,a,l,c,f,new H),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const d={a,b:l,c,normal:new H,materialIndex:0};tr.getNormal(eh,th,nh,d.normal),u.face=d,u.barycoord=f}return u}class Xa extends Ft{constructor(e=1,t=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};const a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);const l=[],c=[],u=[],f=[];let d=0,p=0;v("z","y","x",-1,-1,n,t,e,o,r,0),v("z","y","x",1,-1,n,t,-e,o,r,1),v("x","z","y",1,1,e,n,t,i,o,2),v("x","z","y",1,-1,e,n,-t,i,o,3),v("x","y","z",1,-1,e,t,n,i,r,4),v("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(l),this.setAttribute("position",new ht(c,3)),this.setAttribute("normal",new ht(u,3)),this.setAttribute("uv",new ht(f,2));function v(x,b,y,w,E,S,I,L,g,F,R){const N=S/g,G=I/F,se=S/2,Y=I/2,he=L/2,pe=g+1,ce=F+1;let ge=0,fe=0;const Ue=new H;for(let ne=0;ne0?1:-1,u.push(Ue.x,Ue.y,Ue.z),f.push(mt/g),f.push(1-ne/F),ge+=1}}for(let ne=0;ne0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class Qf extends an{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new _t,this.projectionMatrix=new _t,this.projectionMatrixInverse=new _t,this.coordinateSystem=ts}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const po=new H,y_=new Ae,v_=new Ae;class vi extends Qf{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Vl*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ia*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Vl*2*Math.atan(Math.tan(Ia*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){po.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(po.x,po.y).multiplyScalar(-e/po.z),po.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(po.x,po.y).multiplyScalar(-e/po.z)}getViewSize(e,t){return this.getViewBounds(e,y_,v_),t.subVectors(v_,y_)}setViewOffset(e,t,n,i,r,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ia*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;r+=o.offsetX*i/l,t-=o.offsetY*n/c,i*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const gl=-90,_l=1;class rv extends an{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new vi(gl,_l,e,t);i.layers=this.layers,this.add(i);const r=new vi(gl,_l,e,t);r.layers=this.layers,this.add(r);const o=new vi(gl,_l,e,t);o.layers=this.layers,this.add(o);const a=new vi(gl,_l,e,t);a.layers=this.layers,this.add(a);const l=new vi(gl,_l,e,t);l.layers=this.layers,this.add(l);const c=new vi(gl,_l,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,o,a,l]=t;for(const c of t)this.remove(c);if(e===ts)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Jc)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.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:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,o,a,l,c,u]=this.children,f=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,l),e.setRenderTarget(n,4,i),e.render(t,c),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(f,d,p),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class mu extends On{constructor(e=[],t=Ys,n,i,r,o,a,l,c,u){super(e,t,n,i,r,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class sv extends Ss{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new mu(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:qn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},i=new Xa(5,5,5),r=new ns({name:"CubemapFromEquirect",uniforms:Gl(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:$i,blending:Xs});r.uniforms.tEquirect.value=t;const o=new Qn(i,r),a=t.minFilter;return t.minFilter===Fr&&(t.minFilter=qn),new rv(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){const r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}}class Gs extends an{constructor(){super(),this.isGroup=!0,this.type="Group"}}const US={type:"move"};class kh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Gs,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 Gs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new H,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new H),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Gs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new H,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new H),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const x of e.hand.values()){const b=t.getJointPose(x,n),y=this._getHandJoint(c,x);b!==null&&(y.matrix.fromArray(b.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=b.radius),y.visible=b!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],d=u.position.distanceTo(f.position),p=.02,v=.005;c.inputState.pinching&&d>p+v?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-v&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),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));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(US)))}return a!==null&&(a.visible=i!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Gs;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class ed{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new $e(e),this.density=t}clone(){return new ed(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class td{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new $e(e),this.near=t,this.far=n}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}}}class ov extends an{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Tr,this.environmentIntensity=1,this.environmentRotation=new Tr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class gu{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Kc,this.updateRanges=[],this.version=0,this.uuid=Mr()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:l,point:bc.clone(),uv:tr.getInterpolation(bc,oh,Sc,ah,x_,sp,b_,new Ae),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function lh(s,e,t,n,i,r){bl.subVectors(s,t).addScalar(.5).multiply(n),i!==void 0?(Mc.x=r*bl.x-i*bl.y,Mc.y=i*bl.x+r*bl.y):Mc.copy(bl),s.copy(e),s.x+=Mc.x,s.y+=Mc.y,s.applyMatrix4(av)}const ch=new H,M_=new H;class cv extends an{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){ch.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(ch);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){ch.setFromMatrixPosition(e.matrixWorld),M_.setFromMatrixPosition(this.matrixWorld);const n=ch.distanceTo(M_)/e.zoom;t[0].object.visible=!0;let i,r;for(i=1,r=t.length;i=o)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||HS.getNormalMatrix(e),i=this.coplanarPoint(lp).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const oa=new Si,fh=new H;class yu{constructor(e=new ks,t=new ks,n=new ks,i=new ks,r=new ks,o=new ks){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ts){const n=this.planes,i=e.elements,r=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],f=i[6],d=i[7],p=i[8],v=i[9],x=i[10],b=i[11],y=i[12],w=i[13],E=i[14],S=i[15];if(n[0].setComponents(l-r,d-c,b-p,S-y).normalize(),n[1].setComponents(l+r,d+c,b+p,S+y).normalize(),n[2].setComponents(l+o,d+u,b+v,S+w).normalize(),n[3].setComponents(l-o,d-u,b-v,S-w).normalize(),n[4].setComponents(l-a,d-f,b-x,S-E).normalize(),t===ts)n[5].setComponents(l+a,d+f,b+x,S+E).normalize();else if(t===Jc)n[5].setComponents(a,f,x,E).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(),oa.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),oa.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(oa)}intersectsSprite(e){return oa.center.set(0,0,0),oa.radius=.7071067811865476,oa.applyMatrix4(e.matrixWorld),this.intersectsSphere(oa)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,fh.y=i.normal.y>0?e.max.y:e.min.y,fh.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(fh)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function cp(s,e){return s-e}function VS(s,e){return s.z-e.z}function GS(s,e){return e.z-s.z}class WS{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,i){const r=this.pool,o=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});const a=r[this.index];o.push(a),this.index++,a.start=e,a.count=t,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}}const Ji=new _t,XS=new $e(1,1,1),up=new yu,dh=new Li,aa=new Si,Ec=new H,I_=new H,qS=new H,hp=new WS,Ri=new Qn,ph=[];function $S(s,e,t=0){const n=e.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==e.array.constructor){const i=s.count;for(let r=0;r65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new pn(r,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Li);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(cp),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));const r=this._matricesTexture;Ji.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;const o=this._colorsTexture;return o&&(XS.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const o=e.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(cp),l=this._availableGeometryIds.shift(),r[l]=i):(l=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(l,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(i&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=a.vertexStart,c=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(const u in n.attributes){const f=t.getAttribute(u),d=n.getAttribute(u);$S(f,d,l);const p=f.itemSize;for(let v=f.count,x=c;v=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let i=0,r=n.length;ia).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),r=this.geometry;for(let o=0,a=n.length;o=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const r=new Li,o=n.index,a=n.attributes.position;for(let l=i.start,c=i.start+i.count;l=this._geometryCount)return null;const n=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const r=new Si;this.getBoundingBoxAt(e,dh),dh.getCenter(r.center);const o=n.index,a=n.attributes.position;let l=0;for(let c=i.start,u=i.start+i.count;ca.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const r=this.geometry;r.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Ft,this._initializeGeometry(r));const o=this.geometry;r.index&&la(r.index.array,o.index.array);for(const a in r.attributes)la(r.attributes[a].array,o.attributes[a].array)}raycast(e,t){const n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,o=this.geometry;Ri.material=this.material,Ri.geometry.index=o.index,Ri.geometry.attributes=o.attributes,Ri.geometry.boundingBox===null&&(Ri.geometry.boundingBox=new Li),Ri.geometry.boundingSphere===null&&(Ri.geometry.boundingSphere=new Si);for(let a=0,l=n.length;a({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,l=this._instanceInfo,c=this._multiDrawStarts,u=this._multiDrawCounts,f=this._geometryInfo,d=this.perObjectFrustumCulled,p=this._indirectTexture,v=p.image.data;d&&(Ji.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),up.setFromProjectionMatrix(Ji,e.coordinateSystem));let x=0;if(this.sortObjects){Ji.copy(this.matrixWorld).invert(),Ec.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Ji),I_.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Ji);for(let w=0,E=l.length;w0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;rn)return;fp.applyMatrix4(s.matrixWorld);const c=e.ray.origin.distanceTo(fp);if(!(ce.far))return{distance:c,point:D_.clone().applyMatrix4(s.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:s}}const N_=new H,O_=new H;class is extends Zs{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let i=0,r=t.count;i0){const i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;ri.far)return;r.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}class hv extends On{constructor(e,t,n,i,r=qn,o=qn,a,l,c){super(e,t,n,i,r,o,a,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1;const u=this;function f(){u.needsUpdate=!0,e.requestVideoFrameCallback(f)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(f)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class YS extends hv{constructor(e,t,n,i,r,o,a,l){super({},e,t,n,i,r,o,a,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class jS extends On{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=ui,this.minFilter=ui,this.generateMipmaps=!1,this.needsUpdate=!0}}class rd extends On{constructor(e,t,n,i,r,o,a,l,c,u,f,d){super(null,o,a,l,c,u,i,r,f,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class ZS extends rd{constructor(e,t,n,i,r,o){super(e,t,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=vr,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class KS extends rd{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Ys),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class JS extends On{constructor(e,t,n,i,r,o,a,l,c){super(e,t,n,i,r,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Vm extends On{constructor(e,t,n=js,i,r,o,a=ui,l=ui,c,u=Bl){if(u!==Bl&&u!==kl)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,i,r,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:e,height:t},this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new xo(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class rs{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let i=0;const r=n.length;let o;t?o=t:o=e*n[r-1];let a=0,l=r-1,c;for(;a<=l;)if(i=Math.floor(a+(l-a)/2),c=n[i]-o,c<0)a=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===o)return i/(r-1);const u=n[i],d=n[i+1]-u,p=(o-u)/d;return(i+p)/(r-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),r>1&&(r=1);const o=this.getPoint(i),a=this.getPoint(r),l=t||(o.isVector2?new Ae:new H);return l.copy(a).sub(o).normalize(),l}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new H,i=[],r=[],o=[],a=new H,l=new _t;for(let p=0;p<=e;p++){const v=p/e;i[p]=this.getTangentAt(v,new H)}r[0]=new H,o[0]=new H;let c=Number.MAX_VALUE;const u=Math.abs(i[0].x),f=Math.abs(i[0].y),d=Math.abs(i[0].z);u<=c&&(c=u,n.set(1,0,0)),f<=c&&(c=f,n.set(0,1,0)),d<=c&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let p=1;p<=e;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();const v=Math.acos(Lt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(l.makeRotationAxis(a,v))}o[p].crossVectors(i[p],r[p])}if(t===!0){let p=Math.acos(Lt(r[0].dot(r[e]),-1,1));p/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(p=-p);for(let v=1;v<=e;v++)r[v].applyMatrix4(l.makeRotationAxis(i[v],p*v)),o[v].crossVectors(i[v],r[v])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class sd extends rs{constructor(e=0,t=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=l}getPoint(e,t=new Ae){const n=t,i=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(a)/r)+1)*r:l===0&&a===r-1&&(a=r-2,l=1);let c,u;this.closed||a>0?c=i[(a-1)%r]:(vh.subVectors(i[0],i[1]).add(i[0]),c=vh);const f=i[a%r],d=i[(a+1)%r];if(this.closed||a+2i.length-2?i.length-1:o+1],f=i[o>i.length-3?i.length-1:o+2];return n.set(B_(a,l.x,c.x,u.x,f.x),B_(a,l.y,c.y,u.y,f.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const o=i[r]-n,a=this.curves[r],l=a.getLength(),c=l===0?0:1-o/l;return a.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const f=c.getPoint(0);f.equals(this.currentPoint)||this.lineTo(f.x,f.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),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 vu extends Ft{constructor(e=[new Ae(0,-.5),new Ae(.5,0),new Ae(0,.5)],t=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=Lt(i,0,Math.PI*2);const r=[],o=[],a=[],l=[],c=[],u=1/t,f=new H,d=new Ae,p=new H,v=new H,x=new H;let b=0,y=0;for(let w=0;w<=e.length-1;w++)switch(w){case 0:b=e[w+1].x-e[w].x,y=e[w+1].y-e[w].y,p.x=y*1,p.y=-b,p.z=y*0,x.copy(p),p.normalize(),l.push(p.x,p.y,p.z);break;case e.length-1:l.push(x.x,x.y,x.z);break;default:b=e[w+1].x-e[w].x,y=e[w+1].y-e[w].y,p.x=y*1,p.y=-b,p.z=y*0,v.copy(p),p.x+=x.x,p.y+=x.y,p.z+=x.z,p.normalize(),l.push(p.x,p.y,p.z),x.copy(v)}for(let w=0;w<=t;w++){const E=n+w*u*i,S=Math.sin(E),I=Math.cos(E);for(let L=0;L<=e.length-1;L++){f.x=e[L].x*S,f.y=e[L].y,f.z=e[L].x*I,o.push(f.x,f.y,f.z),d.x=w/t,d.y=L/(e.length-1),a.push(d.x,d.y);const g=l[3*L+0]*S,F=l[3*L+1],R=l[3*L+0]*I;c.push(g,F,R)}}for(let w=0;w0&&E(!0),t>0&&E(!1)),this.setIndex(u),this.setAttribute("position",new ht(f,3)),this.setAttribute("normal",new ht(d,3)),this.setAttribute("uv",new ht(p,2));function w(){const S=new H,I=new H;let L=0;const g=(t-e)/n;for(let F=0;F<=r;F++){const R=[],N=F/r,G=N*(t-e)+e;for(let se=0;se<=i;se++){const Y=se/i,he=Y*l+a,pe=Math.sin(he),ce=Math.cos(he);I.x=G*pe,I.y=-N*n+b,I.z=G*ce,f.push(I.x,I.y,I.z),S.set(pe,g,ce).normalize(),d.push(S.x,S.y,S.z),p.push(Y,1-N),R.push(v++)}x.push(R)}for(let F=0;F0||R!==0)&&(u.push(N,G,Y),L+=3),(t>0||R!==r-1)&&(u.push(G,se,Y),L+=3)}c.addGroup(y,L,0),y+=L}function E(S){const I=v,L=new Ae,g=new H;let F=0;const R=S===!0?e:t,N=S===!0?1:-1;for(let se=1;se<=i;se++)f.push(0,b*N,0),d.push(0,N,0),p.push(.5,.5),v++;const G=v;for(let se=0;se<=i;se++){const he=se/i*l+a,pe=Math.cos(he),ce=Math.sin(he);g.x=R*ce,g.y=b*N,g.z=R*pe,f.push(g.x,g.y,g.z),d.push(0,N,0),L.x=pe*.5+.5,L.y=ce*.5*N+.5,p.push(L.x,L.y),v++}for(let se=0;se.9&&g<.1&&(E<.2&&(o[w+0]+=1),S<.2&&(o[w+2]+=1),I<.2&&(o[w+4]+=1))}}function d(w){r.push(w.x,w.y,w.z)}function p(w,E){const S=w*3;E.x=e[S+0],E.y=e[S+1],E.z=e[S+2]}function v(){const w=new H,E=new H,S=new H,I=new H,L=new Ae,g=new Ae,F=new Ae;for(let R=0,N=0;R80*t){a=1/0,l=1/0;let u=-1/0,f=-1/0;for(let d=t;du&&(u=p),v>f&&(f=v)}c=Math.max(u-a,f-l),c=c!==0?32767/c:0}return tu(r,o,t,a,l,c,0),o}function yv(s,e,t,n,i){let r;if(i===MT(s,e,t,n)>0)for(let o=e;o=e;o-=n)r=k_(o/n|0,s[o],s[o+1],r);return r&&Wl(r,r.next)&&(iu(r),r=r.next),r}function ka(s,e){if(!s)return s;e||(e=s);let t=s,n;do if(n=!1,!t.steiner&&(Wl(t,t.next)||Bn(t.prev,t,t.next)===0)){if(iu(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function tu(s,e,t,n,i,r,o){if(!s)return;!o&&r&&gT(s,n,i,r);let a=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(r?lT(s,n,i,r):aT(s)){e.push(l.i,s.i,c.i),iu(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=cT(ka(s),e),tu(s,e,t,n,i,r,2)):o===2&&uT(s,e,t,n,i,r):tu(ka(s),e,t,n,i,r,1);break}}}function aT(s){const e=s.prev,t=s,n=s.next;if(Bn(e,t,n)>=0)return!1;const i=e.x,r=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=Math.min(i,r,o),f=Math.min(a,l,c),d=Math.max(i,r,o),p=Math.max(a,l,c);let v=n.next;for(;v!==e;){if(v.x>=u&&v.x<=d&&v.y>=f&&v.y<=p&&Lc(i,a,r,l,o,c,v.x,v.y)&&Bn(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function lT(s,e,t,n){const i=s.prev,r=s,o=s.next;if(Bn(i,r,o)>=0)return!1;const a=i.x,l=r.x,c=o.x,u=i.y,f=r.y,d=o.y,p=Math.min(a,l,c),v=Math.min(u,f,d),x=Math.max(a,l,c),b=Math.max(u,f,d),y=Yp(p,v,e,t,n),w=Yp(x,b,e,t,n);let E=s.prevZ,S=s.nextZ;for(;E&&E.z>=y&&S&&S.z<=w;){if(E.x>=p&&E.x<=x&&E.y>=v&&E.y<=b&&E!==i&&E!==o&&Lc(a,u,l,f,c,d,E.x,E.y)&&Bn(E.prev,E,E.next)>=0||(E=E.prevZ,S.x>=p&&S.x<=x&&S.y>=v&&S.y<=b&&S!==i&&S!==o&&Lc(a,u,l,f,c,d,S.x,S.y)&&Bn(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;E&&E.z>=y;){if(E.x>=p&&E.x<=x&&E.y>=v&&E.y<=b&&E!==i&&E!==o&&Lc(a,u,l,f,c,d,E.x,E.y)&&Bn(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;S&&S.z<=w;){if(S.x>=p&&S.x<=x&&S.y>=v&&S.y<=b&&S!==i&&S!==o&&Lc(a,u,l,f,c,d,S.x,S.y)&&Bn(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function cT(s,e){let t=s;do{const n=t.prev,i=t.next.next;!Wl(n,i)&&xv(n,t,t.next,i)&&nu(n,i)&&nu(i,n)&&(e.push(n.i,t.i,i.i),iu(t),iu(t.next),t=s=i),t=t.next}while(t!==s);return ka(t)}function uT(s,e,t,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&vT(o,a)){let l=bv(o,a);o=ka(o,o.next),l=ka(l,l.next),tu(o,e,t,n,i,r,0),tu(l,e,t,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function hT(s,e,t,n){const i=[];for(let r=0,o=e.length;r=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>r&&(r=f,o=t.x=t.x&&t.x>=l&&n!==t.x&&vv(io.x||t.x===o.x&&mT(o,t)))&&(o=t,u=f)}t=t.next}while(t!==a);return o}function mT(s,e){return Bn(s.prev,s,e.prev)<0&&Bn(e.next,s,s.next)<0}function gT(s,e,t,n){let i=s;do i.z===0&&(i.z=Yp(i.x,i.y,e,t,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,_T(i)}function _T(s){let e,t=1;do{let n=s,i;s=null;let r=null;for(e=0;n;){e++;let o=n,a=0;for(let c=0;c0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(i=n,n=n.nextZ,a--):(i=o,o=o.nextZ,l--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=o}r.nextZ=null,t*=2}while(e>1);return s}function Yp(s,e,t,n,i){return s=(s-t)*i|0,e=(e-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function yT(s){let e=s,t=s;do(e.x=(s-o)*(r-a)&&(s-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(r-a)>=(i-o)*(n-a)}function Lc(s,e,t,n,i,r,o,a){return!(s===o&&e===a)&&vv(s,e,t,n,i,r,o,a)}function vT(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!xT(s,e)&&(nu(s,e)&&nu(e,s)&&bT(s,e)&&(Bn(s.prev,s,e.prev)||Bn(s,e.prev,e))||Wl(s,e)&&Bn(s.prev,s,s.next)>0&&Bn(e.prev,e,e.next)>0)}function Bn(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function Wl(s,e){return s.x===e.x&&s.y===e.y}function xv(s,e,t,n){const i=Th(Bn(s,e,t)),r=Th(Bn(s,e,n)),o=Th(Bn(t,n,s)),a=Th(Bn(t,n,e));return!!(i!==r&&o!==a||i===0&&Sh(s,t,e)||r===0&&Sh(s,n,e)||o===0&&Sh(t,s,n)||a===0&&Sh(t,e,n))}function Sh(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function Th(s){return s>0?1:s<0?-1:0}function xT(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&xv(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function nu(s,e){return Bn(s.prev,s,s.next)<0?Bn(s,e,s.next)>=0&&Bn(s,s.prev,e)>=0:Bn(s,e,s.prev)<0||Bn(s,s.next,e)<0}function bT(s,e){let t=s,n=!1;const i=(s.x+e.x)/2,r=(s.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&i<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==s);return n}function bv(s,e){const t=jp(s.i,s.x,s.y),n=jp(e.i,e.x,e.y),i=s.next,r=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,n.next=t,t.prev=n,r.next=n,n.prev=r,n}function k_(s,e,t,n){const i=jp(s,e,t);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function iu(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function jp(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function MT(s,e,t,n){let i=0;for(let r=e,o=t-n;r2&&s[e-1].equals(s[0])&&s.pop()}function H_(s,e){for(let t=0;tNumber.EPSILON){const Fe=Math.sqrt(me),je=Math.sqrt(_e*_e+J*J),Et=Re.x-te/Fe,De=Re.y+O/Fe,Xe=Me.x-J/je,ut=Me.y+_e/je,ft=((Xe-Et)*J-(ut-De)*_e)/(O*J-te*_e);Ve=Et+O*ft-we.x,Ee=De+te*ft-we.y;const Ze=Ve*Ve+Ee*Ee;if(Ze<=2)return new Ae(Ve,Ee);z=Math.sqrt(Ze/2)}else{let Fe=!1;O>Number.EPSILON?_e>Number.EPSILON&&(Fe=!0):O<-Number.EPSILON?_e<-Number.EPSILON&&(Fe=!0):Math.sign(te)===Math.sign(J)&&(Fe=!0),Fe?(Ve=-te,Ee=O,z=Math.sqrt(me)):(Ve=O,Ee=te,z=Math.sqrt(me/2))}return new Ae(Ve/z,Ee/z)}const Ue=[];for(let we=0,Re=pe.length,Me=Re-1,Ve=we+1;we=0;we--){const Re=we/b,Me=p*Math.cos(Re*Math.PI/2),Ve=v*Math.sin(Re*Math.PI/2)+x;for(let Ee=0,z=pe.length;Ee=0;){const Ve=Me;let Ee=Me-1;Ee<0&&(Ee=we.length-1);for(let z=0,O=u+b*2;z0)&&p.push(E,S,L),(y!==n-1||l0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class wv extends hi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new $e(16777215),this.specular=new $e(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new $e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lo,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Tr,this.combine=fu,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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Ev extends hi{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new $e(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new $e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lo,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Av extends hi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lo,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Cv extends hi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new $e(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new $e(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lo,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Tr,this.combine=fu,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.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jm extends hi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=V0,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 Zm extends hi{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}}class Rv extends hi{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new $e(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Lo,this.normalScale=new Ae(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pv extends Oi{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Aa(s,e){return!s||s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function Iv(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Lv(s){function e(i,r){return s[i]-s[r]}const t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function Zp(s,e,t){const n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){const a=t[r]*e;for(let l=0;l!==e;++l)i[o++]=s[a+l]}return i}function Km(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push(...o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)}function AT(s,e,t,n,i=30){const r=s.clone();r.name=e;const o=[];for(let l=0;l=n)){f.push(c.times[p]);for(let x=0;xr.tracks[l].times[0]&&(a=r.tracks[l].times[0]);for(let l=0;l=a.times[v]){const y=v*f+u,w=y+f-u;x=a.values.slice(y,w)}else{const y=a.createInterpolant(),w=u,E=f-u;y.evaluate(r),x=y.resultBuffer.slice(w,E)}l==="quaternion"&&new xi().fromArray(x).normalize().conjugate().toArray(x);const b=c.times.length;for(let y=0;y=r)){const a=t[1];e=r)break t}o=n,n=0;break n}break e}for(;n>>1;et;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);const a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==r;a++){const l=n[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(i!==void 0&&Iv(i))for(let a=0,l=i.length;a!==l;++a){const c=i[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Fh,r=e.length-1;let o=1;for(let a=1;a0){e[o]=e[r];for(let a=r*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}Vr.prototype.ValueTypeName="";Vr.prototype.TimeBufferType=Float32Array;Vr.prototype.ValueBufferType=Float32Array;Vr.prototype.DefaultInterpolation=Hl;class qa extends Vr{constructor(e,t,n){super(e,t,n)}}qa.prototype.ValueTypeName="bool";qa.prototype.ValueBufferType=Array;qa.prototype.DefaultInterpolation=zl;qa.prototype.InterpolantFactoryMethodLinear=void 0;qa.prototype.InterpolantFactoryMethodSmooth=void 0;class Qm extends Vr{constructor(e,t,n,i){super(e,t,n,i)}}Qm.prototype.ValueTypeName="color";class za extends Vr{constructor(e,t,n,i){super(e,t,n,i)}}za.prototype.ValueTypeName="number";class Ov extends nc{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(i-t);let c=e*a;for(let u=c+a;c!==u;c+=4)xi.slerpFlat(r,0,o,c-a,o,c,l);return r}}class Ha extends Vr{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new Ov(this.times,this.values,this.getValueSize(),e)}}Ha.prototype.ValueTypeName="quaternion";Ha.prototype.InterpolantFactoryMethodSmooth=void 0;class $a extends Vr{constructor(e,t,n){super(e,t,n)}}$a.prototype.ValueTypeName="string";$a.prototype.ValueBufferType=Array;$a.prototype.DefaultInterpolation=zl;$a.prototype.InterpolantFactoryMethodLinear=void 0;$a.prototype.InterpolantFactoryMethodSmooth=void 0;class Va extends Vr{constructor(e,t,n,i){super(e,t,n,i)}}Va.prototype.ValueTypeName="vector";class Xl{constructor(e="",t=-1,n=[],i=jf){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Mr(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(IT(n[o]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,o=n.length;r!==o;++r)t.push(Vr.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,o=[];for(let a=0;a1){const f=u[1];let d=i[f];d||(i[f]=d=[]),d.push(c)}}const o=[];for(const a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(f,d,p,v,x){if(p.length!==0){const b=[],y=[];Km(p,b,y,v),b.length!==0&&x.push(new f(d,b,y))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let f=0;f{t&&t(r),this.manager.itemEnd(e)},0),r;if(Os[e]!==void 0){Os[e].push({onLoad:t,onProgress:n,onError:i});return}Os[e]=[],Os[e].push({onLoad:t,onProgress:n,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).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 u=Os[e],f=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=d?parseInt(d):0,v=p!==0;let x=0;const b=new ReadableStream({start(y){w();function w(){f.read().then(({done:E,value:S})=>{if(E)y.close();else{x+=S.byteLength;const I=new ProgressEvent("progress",{lengthComputable:v,loaded:x,total:p});for(let L=0,g=u.length;L{y.error(E)})}}});return new Response(b)}else throw new LT(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a==="")return c.text();{const f=/charset="?([^;"\s]*)"?/i.exec(a),d=f&&f[1]?f[1].toLowerCase():void 0,p=new TextDecoder(d);return c.arrayBuffer().then(v=>p.decode(v))}}}).then(c=>{Ws.add(e,c);const u=Os[e];delete Os[e];for(let f=0,d=u.length;f{const u=Os[e];if(u===void 0)throw this.manager.itemError(e),c;delete Os[e];for(let f=0,d=u.length;f{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class DT extends Yi{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new zr(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){const t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const r in e.uniforms){const o=e.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new $e().setHex(o.value);break;case"v2":i.uniforms[r].value=new Ae().fromArray(o.value);break;case"v3":i.uniforms[r].value=new H().fromArray(o.value);break;case"v4":i.uniforms[r].value=new un().fromArray(o.value);break;case"m3":i.uniforms[r].value=new Dt().fromArray(o.value);break;case"m4":i.uniforms[r].value=new _t().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(e.defines!==void 0&&(i.defines=e.defines),e.vertexShader!==void 0&&(i.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(i.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(i.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)i.extensions[r]=e.extensions[r];if(e.lights!==void 0&&(i.lights=e.lights),e.clipping!==void 0&&(i.clipping=e.clipping),e.size!==void 0&&(i.size=e.size),e.sizeAttenuation!==void 0&&(i.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(i.map=n(e.map)),e.matcap!==void 0&&(i.matcap=n(e.matcap)),e.alphaMap!==void 0&&(i.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(i.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(i.bumpScale=e.bumpScale),e.normalMap!==void 0&&(i.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(i.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new Ae().fromArray(r)}return e.displacementMap!==void 0&&(i.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(i.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(i.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(i.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(i.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(i.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(i.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(i.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(i.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(i.envMap=n(e.envMap)),e.envMapRotation!==void 0&&i.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(i.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(i.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(i.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(i.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(i.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(i.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(i.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(i.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(i.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new Ae().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(i.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(i.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(i.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(i.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(i.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return yd.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:Sv,SpriteMaterial:Fm,RawShaderMaterial:Tv,ShaderMaterial:ns,PointsMaterial:id,MeshPhysicalMaterial:Hr,MeshStandardMaterial:Mu,MeshPhongMaterial:wv,MeshToonMaterial:Ev,MeshNormalMaterial:Av,MeshLambertMaterial:Cv,MeshDepthMaterial:jm,MeshDistanceMaterial:Zm,MeshBasicMaterial:xr,MeshMatcapMaterial:Rv,LineDashedMaterial:Pv,LineBasicMaterial:Oi,Material:hi};return new t[e]}}class To{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 Gv extends Ft{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class Wv extends Yi{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new zr(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(JSON.parse(a)))}catch(l){i?i(l):console.error(l),r.manager.itemError(e)}},n,i)}parse(e){const t={},n={};function i(p,v){if(t[v]!==void 0)return t[v];const b=p.interleavedBuffers[v],y=r(p,b.buffer),w=wl(b.type,y),E=new gu(w,b.stride);return E.uuid=b.uuid,t[v]=E,E}function r(p,v){if(n[v]!==void 0)return n[v];const b=p.arrayBuffers[v],y=new Uint32Array(b).buffer;return n[v]=y,y}const o=e.isInstancedBufferGeometry?new Gv:new Ft,a=e.data.index;if(a!==void 0){const p=wl(a.type,a.array);o.setIndex(new pn(p,1))}const l=e.data.attributes;for(const p in l){const v=l[p];let x;if(v.isInterleavedBufferAttribute){const b=i(e.data,v.data);x=new Ro(b,v.itemSize,v.offset,v.normalized)}else{const b=wl(v.type,v.array),y=v.isInstancedBufferAttribute?Ba:pn;x=new y(b,v.itemSize,v.normalized)}v.name!==void 0&&(x.name=v.name),v.usage!==void 0&&x.setUsage(v.usage),o.setAttribute(p,x)}const c=e.data.morphAttributes;if(c)for(const p in c){const v=c[p],x=[];for(let b=0,y=v.length;b0){const l=new eg(t);r=new ru(l),r.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c0){i=new ru(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o{const b=new Li;b.min.fromArray(x.boxMin),b.max.fromArray(x.boxMax);const y=new Si;return y.radius=x.sphereRadius,y.center.fromArray(x.sphereCenter),{boxInitialized:x.boxInitialized,box:b,sphereInitialized:x.sphereInitialized,sphere:y}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=c(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=c(e.colorsTexture.uuid));break;case"LOD":o=new cv;break;case"Line":o=new Zs(a(e.geometry),l(e.material));break;case"LineLoop":o=new zm(a(e.geometry),l(e.material));break;case"LineSegments":o=new is(a(e.geometry),l(e.material));break;case"PointCloud":case"Points":o=new Hm(a(e.geometry),l(e.material));break;case"Sprite":o=new lv(l(e.material));break;case"Group":o=new Gs;break;case"Bone":o=new nd;break;default:o=new an}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){const d=e.children;for(let p=0;p"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,o=Ws.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(c=>{t&&t(c),r.manager.itemEnd(e)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;const l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(c){return Ws.add(e,c),t&&t(c),r.manager.itemEnd(e),c}).catch(function(c){i&&i(c),Ws.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Ws.add(e,l),r.manager.itemStart(e)}}let wh;class sg{static getContext(){return wh===void 0&&(wh=new(window.AudioContext||window.webkitAudioContext)),wh}static setContext(e){wh=e}}class VT extends Yi{constructor(e){super(e)}load(e,t,n,i){const r=this,o=new zr(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{const c=l.slice(0);sg.getContext().decodeAudioData(c,function(f){t(f)}).catch(a)}catch(c){a(c)}},n,i);function a(l){i?i(l):console.error(l),r.manager.itemError(e)}}}const j_=new _t,Z_=new _t,ca=new _t;class GT{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new vi,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new vi,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,ca.copy(e.projectionMatrix);const i=t.eyeSep/2,r=i*t.near/t.focus,o=t.near*Math.tan(Ia*t.fov*.5)/t.zoom;let a,l;Z_.elements[12]=-i,j_.elements[12]=i,a=-o*t.aspect+r,l=o*t.aspect+r,ca.elements[0]=2*t.near/(l-a),ca.elements[8]=(l+a)/(l-a),this.cameraL.projectionMatrix.copy(ca),a=-o*t.aspect-r,l=o*t.aspect-r,ca.elements[0]=2*t.near/(l-a),ca.elements[8]=(l+a)/(l-a),this.cameraR.projectionMatrix.copy(ca)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Z_),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(j_)}}class qv extends vi{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e,this.index=0}}class $v{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=K_(),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=K_();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function K_(){return performance.now()}const ua=new H,J_=new xi,WT=new H,ha=new H;class XT extends an{constructor(){super(),this.type="AudioListener",this.context=sg.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new $v}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(ua,J_,WT),ha.set(0,0,-1).applyQuaternion(J_),t.positionX){const i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(ua.x,i),t.positionY.linearRampToValueAtTime(ua.y,i),t.positionZ.linearRampToValueAtTime(ua.z,i),t.forwardX.linearRampToValueAtTime(ha.x,i),t.forwardY.linearRampToValueAtTime(ha.y,i),t.forwardZ.linearRampToValueAtTime(ha.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(ua.x,ua.y,ua.z),t.setOrientation(ha.x,ha.y,ha.z,n.x,n.y,n.z)}}class Yv extends an{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(n[l]!==n[l+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,o=i;r!==o;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){xi.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const o=this._workIndex*r;xi.multiplyQuaternionsFlat(e,o,e,t,e,n),xi.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){const o=1-i;for(let a=0;a!==r;++a){const l=t+a;e[l]=e[l]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){const a=t+o;e[a]=e[a]+e[n+o]*i}}}const og="\\[\\]\\.:\\/",jT=new RegExp("["+og+"]","g"),ag="[^"+og+"]",ZT="[^"+og.replace("\\.","")+"]",KT=/((?:WC+[\/:])*)/.source.replace("WC",ag),JT=/(WCOD+)?/.source.replace("WCOD",ZT),QT=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ag),ew=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ag),tw=new RegExp("^"+KT+JT+QT+ew+"$"),nw=["material","materials","bones","map"];class iw{constructor(e,t,n){const i=n||ln.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class ln{constructor(e,t,n){this.path=t,this.parsedPath=n||ln.parseTrackName(t),this.node=ln.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ln.Composite(e,t,n):new ln(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(jT,"")}static parseTrackName(e){const t=tw.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);nw.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(r){for(let o=0;o=r){const f=r++,d=e[f];t[d.uuid]=u,e[u]=d,t[c]=f,e[f]=l;for(let p=0,v=i;p!==v;++p){const x=n[p],b=x[f],y=x[u];x[u]=b,x[f]=y}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,o=e.length;for(let a=0,l=arguments.length;a!==l;++a){const c=arguments[a],u=c.uuid,f=t[u];if(f!==void 0)if(delete t[u],f0&&(t[p.uuid]=f),e[f]=p,e.pop();for(let v=0,x=i;v!==x;++v){const b=n[v];b[f]=b[d],b.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(i!==void 0)return r[i];const o=this._paths,a=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,f=new Array(c);i=r.length,n[e]=i,o.push(e),a.push(t),r.push(f);for(let d=u,p=l.length;d!==p;++d){const v=l[d];f[d]=new ln(v,e,t)}return f}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,l=o[a],c=e[a];t[c]=n,o[n]=l,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}class Zv{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,o=r.length,a=new Array(o),l={endingStart:wa,endingEnd:wa};for(let c=0;c!==o;++c){const u=r[c].createInterpolant(null);a[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=k0,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const i=this._clip.duration,r=e._clip.duration,o=r/i,a=i/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,o=this.timeScale;let a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const l=a.parameterPositions,c=a.sampleValues;return l[0]=r,l[1]=r+n,c[0]=e/o,c[1]=t/o,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled){this._updateWeight(e);return}const r=this._startTime;if(r!==null){const l=(e-r)*n;l<0||n===0?t=0:(this._startTime=null,t=n*l)}t*=this._updateTimeScale(e);const o=this._updateTime(t),a=this._updateWeight(e);if(a>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case Pm:for(let u=0,f=l.length;u!==f;++u)l[u].evaluate(o),c[u].accumulateAdditive(a);break;case jf:default:for(let u=0,f=l.length;u!==f;++u)l[u].evaluate(o),c[u].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const o=n===z0;if(e===0)return r===-1?i:o&&(r&1)===1?t-i:i;if(n===B0){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(r===-1&&(e>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=t||i<0){const a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Ea,i.endingEnd=Ea):(e?i.endingStart=this.zeroSlopeAtStart?Ea:wa:i.endingStart=jc,t?i.endingEnd=this.zeroSlopeAtEnd?Ea:wa:i.endingEnd=jc)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);const a=o.parameterPositions,l=o.sampleValues;return a[0]=r,l[0]=t,a[1]=r+e,l[1]=n,this}}const sw=new Float32Array(1);class ow extends ws{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let f=0;f!==r;++f){const d=i[f],p=d.name;let v=u[p];if(v!==void 0)++v.referenceCount,o[f]=v;else{if(v=o[f],v!==void 0){v._cacheIndex===null&&(++v.referenceCount,this._addInactiveBinding(v,l,p));continue}const x=t&&t._propertyBindings[f].binding.parsedPath;v=new jv(ln.create(n,p,x),d.ValueTypeName,d.getValueSize()),++v.referenceCount,this._addInactiveBinding(v,l,p),o[f]=v}a[f].resultBuffer=v.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,n)}const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){const r=t[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let c=0;c!==n;++c)t[c]._update(i,e,r,o);const a=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)a[c].apply(o);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ny).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const iy=new H,Eh=new H;class gw{constructor(e=new H,t=new H){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){iy.subVectors(e,this.start),Eh.subVectors(this.end,this.start);const n=Eh.dot(Eh);let r=Eh.dot(iy)/n;return t&&(r=Lt(r,0,1)),r}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const ry=new H;class _w extends an{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Ft,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,l=32;o1)for(let f=0;f.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{cy.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(cy,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Pw extends is{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ft;i.setAttribute("position",new ht(t,3)),i.setAttribute("color",new ht(n,3));const r=new Oi({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(e,t,n){const i=new $e,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Iw{constructor(){this.type="ShapePath",this.color=new $e,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new eu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,o){return this.currentPath.bezierCurveTo(e,t,n,i,r,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(y){const w=[];for(let E=0,S=y.length;ENumber.EPSILON){if(N<0&&(g=w[L],R=-R,F=w[I],N=-N),y.yF.y)continue;if(y.y===g.y){if(y.x===g.x)return!0}else{const G=N*(y.x-g.x)-R*(y.y-g.y);if(G===0)return!0;if(G<0)continue;S=!S}}else{if(y.y!==g.y)continue;if(F.x<=y.x&&y.x<=g.x||g.x<=y.x&&y.x<=F.x)return!0}}return S}const i=vs.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,l;const c=[];if(r.length===1)return a=r[0],l=new La,l.curves=a.curves,c.push(l),c;let u=!i(r[0].getPoints());u=e?!u:u;const f=[],d=[];let p=[],v=0,x;d[v]=void 0,p[v]=[];for(let y=0,w=r.length;y1){let y=!1,w=0;for(let E=0,S=d.length;E0&&y===!1&&(p=f)}let b;for(let y=0,w=d.length;ye?(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function Dw(s,e){const t=s.image&&s.image.width?s.image.width/s.image.height:1;return t>e?(s.repeat.x=e/t,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=t/e,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function Nw(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function Qp(s,e,t,n){const i=Ow(n);switch(t){case Tm:return s*e;case Em:return s*e;case Am:return s*e*2;case qf:return s*e/i.components*i.byteLength;case du:return s*e/i.components*i.byteLength;case Cm:return s*e*2/i.components*i.byteLength;case $f:return s*e*2/i.components*i.byteLength;case wm:return s*e*3/i.components*i.byteLength;case qi:return s*e*4/i.components*i.byteLength;case Yf:return s*e*4/i.components*i.byteLength;case Uc:case Fc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Bc:case kc:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case rf:case of:return Math.max(s,16)*Math.max(e,8)/4;case nf:case sf:return Math.max(s,8)*Math.max(e,8)/2;case af:case lf:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case cf:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case uf:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case hf:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case ff:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case df:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case pf:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case mf:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case gf:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case _f:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case yf:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case vf:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case xf:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case bf:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case Mf:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case Sf:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case zc:case Tf:case wf:return Math.ceil(s/4)*Math.ceil(e/4)*16;case Rm:case Ef:return Math.ceil(s/4)*Math.ceil(e/4)*8;case Af:case Cf:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Ow(s){switch(s){case Ms:case bm:return{byteLength:1,components:1};case Ul:case Mm:case Ql:return{byteLength:2,components:1};case Wf:case Xf:return{byteLength:2,components:4};case js:case Gf:case nr:return{byteLength:4,components:1};case Sm:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}class Uw{static contain(e,t){return Lw(e,t)}static cover(e,t){return Dw(e,t)}static fill(e){return Nw(e)}static getByteLength(e,t,n,i){return Qp(e,t,n,i)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zf}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zf);/** * @license * Copyright 2010-2025 Three.js Authors * SPDX-License-Identifier: MIT */function Qv(){let s=null,e=!1,t=null,n=null;function i(r,o){t(r,o),n=s.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&(n=s.requestAnimationFrame(i),e=!0)},stop:function(){s.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){s=r}}}function Fw(s){const e=new WeakMap;function t(a,l){const c=a.array,u=a.usage,f=c.byteLength,d=s.createBuffer();s.bindBuffer(l,d),s.bufferData(l,c,u),a.onUploadCallback();let p;if(c instanceof Float32Array)p=s.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=s.SHORT;else if(c instanceof Uint32Array)p=s.UNSIGNED_INT;else if(c instanceof Int32Array)p=s.INT;else if(c instanceof Int8Array)p=s.BYTE;else if(c instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:f}}function n(a,l,c){const u=l.array,f=l.updateRanges;if(s.bindBuffer(c,a),f.length===0)s.bufferSubData(c,0,u);else{f.sort((p,v)=>p.start-v.start);let d=0;for(let p=1;p 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #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 #endif`,eE=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,tE=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,nE=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,iE=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,rE=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,sE=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec3 vColor; #endif`,oE=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif #ifdef USE_BATCHING_COLOR vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); vColor.xyz *= batchingColor.xyz; #endif`,aE=`#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; } 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`,lE=`#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`,cE=`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`,uE=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,hE=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,fE=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,dE=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,pE="gl_FragColor = linearToOutputTexel( gl_FragColor );",mE=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } 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 ); }`,gE=`#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, envMapRotation * 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`,_E=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,yE=`#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`,vE=`#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`,xE=`#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`,bE=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,ME=`#ifdef USE_FOG varying float vFogDepth; #endif`,SE=`#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`,TE=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,wE=`#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 }`,EE=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,AE=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,CE=`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`,RE=`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 ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } 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`,PE=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * 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, envMapRotation * 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`,IE=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,LE=`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`,DE=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,NE=`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`,OE=`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_DISPERSION material.dispersion = dispersion; #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`,UE=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; float dispersion; #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 ); }`,FE=` 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.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, 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`,BE=`#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`,kE=`#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`,zE=`#if defined( USE_LOGDEPTHBUF ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,HE=`#if defined( USE_LOGDEPTHBUF ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,VE=`#ifdef USE_LOGDEPTHBUF varying float vFragDepth; varying float vIsPerspective; #endif`,GE=`#ifdef USE_LOGDEPTHBUF vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,WE=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,XE=`#ifdef USE_MAP uniform sampler2D map; #endif`,qE=`#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`,$E=`#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`,YE=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,jE=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,ZE=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`,KE=`#if defined( USE_MORPHCOLORS ) 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`,JE=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`,QE=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif 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 ); } #endif`,eA=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`,tA=`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;`,nA=`#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`,iA=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,rA=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,sA=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,oA=`#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`,aA=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,lA=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,cA=`#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`,uA=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,hA=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,fA=`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 float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in 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( const in 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 ); }`,dA=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,pA=`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;`,mA=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,gA=`#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`,_A=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,yA=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,vA=`#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 shadowIntensity; 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 shadowIntensity; 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 shadowIntensity; 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 shadowIntensity, 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 mix( 1.0, shadow, shadowIntensity ); } 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 shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; float lightToPositionLength = length( lightToPosition ); if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; shadow = ( 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 shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif`,xA=`#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 shadowIntensity; 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 shadowIntensity; 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 shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,bA=`#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`,MA=`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.shadowIntensity, 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.shadowIntensity, 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.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,SA=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,TA=`#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`,wA=`#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`,EA=`#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`,AA=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,CA=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,RA=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,PA=`#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 CineonToneMapping( 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 *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; 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; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,IA=`#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.dispersion, 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`,LA=`#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 dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], 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 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else 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; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif 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`,DA=`#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`,NA=`#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`,OA=`#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`,UA=`#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 FA=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,BA=`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 #include }`,kA=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,zA=`#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; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,HA=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,VA=`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 #include }`,GA=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,WA=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include 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 ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,XA=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,qA=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,$A=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,YA=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,jA=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,ZA=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,KA=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,JA=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include 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 reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,QA=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,e1=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,t1=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,n1=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include 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 #include #include #include #include #include }`,i1=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,r1=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,s1=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,o1=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,a1=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,l1=`#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_DISPERSION uniform float dispersion; #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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include 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 #include #include #include #include #include }`,c1=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,u1=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,h1=`uniform float size; uniform float scale; #include #include #include #include #include #include #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 #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,f1=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,d1=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,p1=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,m1=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #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 #include #include }`,g1=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,Vt={alphahash_fragment:Bw,alphahash_pars_fragment:kw,alphamap_fragment:zw,alphamap_pars_fragment:Hw,alphatest_fragment:Vw,alphatest_pars_fragment:Gw,aomap_fragment:Ww,aomap_pars_fragment:Xw,batching_pars_vertex:qw,batching_vertex:$w,begin_vertex:Yw,beginnormal_vertex:jw,bsdfs:Zw,iridescence_fragment:Kw,bumpmap_pars_fragment:Jw,clipping_planes_fragment:Qw,clipping_planes_pars_fragment:eE,clipping_planes_pars_vertex:tE,clipping_planes_vertex:nE,color_fragment:iE,color_pars_fragment:rE,color_pars_vertex:sE,color_vertex:oE,common:aE,cube_uv_reflection_fragment:lE,defaultnormal_vertex:cE,displacementmap_pars_vertex:uE,displacementmap_vertex:hE,emissivemap_fragment:fE,emissivemap_pars_fragment:dE,colorspace_fragment:pE,colorspace_pars_fragment:mE,envmap_fragment:gE,envmap_common_pars_fragment:_E,envmap_pars_fragment:yE,envmap_pars_vertex:vE,envmap_physical_pars_fragment:PE,envmap_vertex:xE,fog_vertex:bE,fog_pars_vertex:ME,fog_fragment:SE,fog_pars_fragment:TE,gradientmap_pars_fragment:wE,lightmap_pars_fragment:EE,lights_lambert_fragment:AE,lights_lambert_pars_fragment:CE,lights_pars_begin:RE,lights_toon_fragment:IE,lights_toon_pars_fragment:LE,lights_phong_fragment:DE,lights_phong_pars_fragment:NE,lights_physical_fragment:OE,lights_physical_pars_fragment:UE,lights_fragment_begin:FE,lights_fragment_maps:BE,lights_fragment_end:kE,logdepthbuf_fragment:zE,logdepthbuf_pars_fragment:HE,logdepthbuf_pars_vertex:VE,logdepthbuf_vertex:GE,map_fragment:WE,map_pars_fragment:XE,map_particle_fragment:qE,map_particle_pars_fragment:$E,metalnessmap_fragment:YE,metalnessmap_pars_fragment:jE,morphinstance_vertex:ZE,morphcolor_vertex:KE,morphnormal_vertex:JE,morphtarget_pars_vertex:QE,morphtarget_vertex:eA,normal_fragment_begin:tA,normal_fragment_maps:nA,normal_pars_fragment:iA,normal_pars_vertex:rA,normal_vertex:sA,normalmap_pars_fragment:oA,clearcoat_normal_fragment_begin:aA,clearcoat_normal_fragment_maps:lA,clearcoat_pars_fragment:cA,iridescence_pars_fragment:uA,opaque_fragment:hA,packing:fA,premultiplied_alpha_fragment:dA,project_vertex:pA,dithering_fragment:mA,dithering_pars_fragment:gA,roughnessmap_fragment:_A,roughnessmap_pars_fragment:yA,shadowmap_pars_fragment:vA,shadowmap_pars_vertex:xA,shadowmap_vertex:bA,shadowmask_pars_fragment:MA,skinbase_vertex:SA,skinning_pars_vertex:TA,skinning_vertex:wA,skinnormal_vertex:EA,specularmap_fragment:AA,specularmap_pars_fragment:CA,tonemapping_fragment:RA,tonemapping_pars_fragment:PA,transmission_fragment:IA,transmission_pars_fragment:LA,uv_pars_fragment:DA,uv_pars_vertex:NA,uv_vertex:OA,worldpos_vertex:UA,background_vert:FA,background_frag:BA,backgroundCube_vert:kA,backgroundCube_frag:zA,cube_vert:HA,cube_frag:VA,depth_vert:GA,depth_frag:WA,distanceRGBA_vert:XA,distanceRGBA_frag:qA,equirect_vert:$A,equirect_frag:YA,linedashed_vert:jA,linedashed_frag:ZA,meshbasic_vert:KA,meshbasic_frag:JA,meshlambert_vert:QA,meshlambert_frag:e1,meshmatcap_vert:t1,meshmatcap_frag:n1,meshnormal_vert:i1,meshnormal_frag:r1,meshphong_vert:s1,meshphong_frag:o1,meshphysical_vert:a1,meshphysical_frag:l1,meshtoon_vert:c1,meshtoon_frag:u1,points_vert:h1,points_frag:f1,shadow_vert:d1,shadow_frag:p1,sprite_vert:m1,sprite_frag:g1},qe={common:{diffuse:{value:new $e(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Dt},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Dt}},envmap:{envMap:{value:null},envMapRotation:{value:new Dt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Dt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Dt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Dt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Dt},normalScale:{value:new Ae(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Dt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Dt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Dt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Dt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new $e(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 $e(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0},uvTransform:{value:new Dt}},sprite:{diffuse:{value:new $e(16777215)},opacity:{value:1},center:{value:new Ae(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Dt},alphaMap:{value:null},alphaMapTransform:{value:new Dt},alphaTest:{value:0}}},Jr={basic:{uniforms:Gi([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.fog]),vertexShader:Vt.meshbasic_vert,fragmentShader:Vt.meshbasic_frag},lambert:{uniforms:Gi([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new $e(0)}}]),vertexShader:Vt.meshlambert_vert,fragmentShader:Vt.meshlambert_frag},phong:{uniforms:Gi([qe.common,qe.specularmap,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,qe.lights,{emissive:{value:new $e(0)},specular:{value:new $e(1118481)},shininess:{value:30}}]),vertexShader:Vt.meshphong_vert,fragmentShader:Vt.meshphong_frag},standard:{uniforms:Gi([qe.common,qe.envmap,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.roughnessmap,qe.metalnessmap,qe.fog,qe.lights,{emissive:{value:new $e(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag},toon:{uniforms:Gi([qe.common,qe.aomap,qe.lightmap,qe.emissivemap,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.gradientmap,qe.fog,qe.lights,{emissive:{value:new $e(0)}}]),vertexShader:Vt.meshtoon_vert,fragmentShader:Vt.meshtoon_frag},matcap:{uniforms:Gi([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,qe.fog,{matcap:{value:null}}]),vertexShader:Vt.meshmatcap_vert,fragmentShader:Vt.meshmatcap_frag},points:{uniforms:Gi([qe.points,qe.fog]),vertexShader:Vt.points_vert,fragmentShader:Vt.points_frag},dashed:{uniforms:Gi([qe.common,qe.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vt.linedashed_vert,fragmentShader:Vt.linedashed_frag},depth:{uniforms:Gi([qe.common,qe.displacementmap]),vertexShader:Vt.depth_vert,fragmentShader:Vt.depth_frag},normal:{uniforms:Gi([qe.common,qe.bumpmap,qe.normalmap,qe.displacementmap,{opacity:{value:1}}]),vertexShader:Vt.meshnormal_vert,fragmentShader:Vt.meshnormal_frag},sprite:{uniforms:Gi([qe.sprite,qe.fog]),vertexShader:Vt.sprite_vert,fragmentShader:Vt.sprite_frag},background:{uniforms:{uvTransform:{value:new Dt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vt.background_vert,fragmentShader:Vt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Dt}},vertexShader:Vt.backgroundCube_vert,fragmentShader:Vt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vt.cube_vert,fragmentShader:Vt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vt.equirect_vert,fragmentShader:Vt.equirect_frag},distanceRGBA:{uniforms:Gi([qe.common,qe.displacementmap,{referencePosition:{value:new H},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vt.distanceRGBA_vert,fragmentShader:Vt.distanceRGBA_frag},shadow:{uniforms:Gi([qe.lights,qe.fog,{color:{value:new $e(0)},opacity:{value:1}}]),vertexShader:Vt.shadow_vert,fragmentShader:Vt.shadow_frag}};Jr.physical={uniforms:Gi([Jr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Dt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Dt},clearcoatNormalScale:{value:new Ae(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Dt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Dt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Dt},sheen:{value:0},sheenColor:{value:new $e(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Dt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Dt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Dt},transmissionSamplerSize:{value:new Ae},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Dt},attenuationDistance:{value:0},attenuationColor:{value:new $e(0)},specularColor:{value:new $e(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Dt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Dt},anisotropyVector:{value:new Ae},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Dt}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag};const Lh={r:0,b:0,g:0},pa=new Tr,_1=new _t;function y1(s,e,t,n,i,r,o){const a=new $e(0);let l=r===!0?0:1,c,u,f=null,d=0,p=null;function v(E){let S=E.isScene===!0?E.background:null;return S&&S.isTexture&&(S=(E.backgroundBlurriness>0?t:e).get(S)),S}function x(E){let S=!1;const I=v(E);I===null?y(a,l):I&&I.isColor&&(y(I,1),S=!0);const L=s.xr.getEnvironmentBlendMode();L==="additive"?n.buffers.color.setClear(0,0,0,1,o):L==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||S)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function b(E,S){const I=v(S);I&&(I.isCubeTexture||I.mapping===Jl)?(u===void 0&&(u=new Qn(new Xa(1,1,1),new ns({name:"BackgroundCubeMaterial",uniforms:Gl(Jr.backgroundCube.uniforms),vertexShader:Jr.backgroundCube.vertexShader,fragmentShader:Jr.backgroundCube.fragmentShader,side:$i,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(L,g,F){this.matrixWorld.copyPosition(F.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),pa.copy(S.backgroundRotation),pa.x*=-1,pa.y*=-1,pa.z*=-1,I.isCubeTexture&&I.isRenderTargetTexture===!1&&(pa.y*=-1,pa.z*=-1),u.material.uniforms.envMap.value=I,u.material.uniforms.flipEnvMap.value=I.isCubeTexture&&I.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(_1.makeRotationFromEuler(pa)),u.material.toneMapped=en.getTransfer(I.colorSpace)!==bn,(f!==I||d!==I.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,f=I,d=I.version,p=s.toneMapping),u.layers.enableAll(),E.unshift(u,u.geometry,u.material,0,0,null)):I&&I.isTexture&&(c===void 0&&(c=new Qn(new tc(2,2),new ns({name:"BackgroundMaterial",uniforms:Gl(Jr.background.uniforms),vertexShader:Jr.background.vertexShader,fragmentShader:Jr.background.fragmentShader,side:bs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=I,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=en.getTransfer(I.colorSpace)!==bn,I.matrixAutoUpdate===!0&&I.updateMatrix(),c.material.uniforms.uvTransform.value.copy(I.matrix),(f!==I||d!==I.version||p!==s.toneMapping)&&(c.material.needsUpdate=!0,f=I,d=I.version,p=s.toneMapping),c.layers.enableAll(),E.unshift(c,c.geometry,c.material,0,0,null))}function y(E,S){E.getRGB(Lh,nv(s)),n.buffers.color.setClear(Lh.r,Lh.g,Lh.b,S,o)}function w(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(E,S=1){a.set(E),l=S,y(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(E){l=E,y(a,l)},render:x,addToRenderList:b,dispose:w}}function v1(s,e){const t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,o=!1;function a(N,G,se,Y,he){let pe=!1;const ce=f(Y,se,G);r!==ce&&(r=ce,c(r.object)),pe=p(N,Y,se,he),pe&&v(N,Y,se,he),he!==null&&e.update(he,s.ELEMENT_ARRAY_BUFFER),(pe||o)&&(o=!1,S(N,G,se,Y),he!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(he).buffer))}function l(){return s.createVertexArray()}function c(N){return s.bindVertexArray(N)}function u(N){return s.deleteVertexArray(N)}function f(N,G,se){const Y=se.wireframe===!0;let he=n[N.id];he===void 0&&(he={},n[N.id]=he);let pe=he[G.id];pe===void 0&&(pe={},he[G.id]=pe);let ce=pe[Y];return ce===void 0&&(ce=d(l()),pe[Y]=ce),ce}function d(N){const G=[],se=[],Y=[];for(let he=0;he=0){const ne=he[fe];let Ye=pe[fe];if(Ye===void 0&&(fe==="instanceMatrix"&&N.instanceMatrix&&(Ye=N.instanceMatrix),fe==="instanceColor"&&N.instanceColor&&(Ye=N.instanceColor)),ne===void 0||ne.attribute!==Ye||Ye&&ne.data!==Ye.data)return!0;ce++}return r.attributesNum!==ce||r.index!==Y}function v(N,G,se,Y){const he={},pe=G.attributes;let ce=0;const ge=se.getAttributes();for(const fe in ge)if(ge[fe].location>=0){let ne=pe[fe];ne===void 0&&(fe==="instanceMatrix"&&N.instanceMatrix&&(ne=N.instanceMatrix),fe==="instanceColor"&&N.instanceColor&&(ne=N.instanceColor));const Ye={};Ye.attribute=ne,ne&&ne.data&&(Ye.data=ne.data),he[fe]=Ye,ce++}r.attributes=he,r.attributesNum=ce,r.index=Y}function x(){const N=r.newAttributes;for(let G=0,se=N.length;G=0){let Ue=he[ge];if(Ue===void 0&&(ge==="instanceMatrix"&&N.instanceMatrix&&(Ue=N.instanceMatrix),ge==="instanceColor"&&N.instanceColor&&(Ue=N.instanceColor)),Ue!==void 0){const ne=Ue.normalized,Ye=Ue.itemSize,mt=e.get(Ue);if(mt===void 0)continue;const Bt=mt.buffer,ye=mt.type,Le=mt.bytesPerElement,Ge=ye===s.INT||ye===s.UNSIGNED_INT||Ue.gpuType===Gf;if(Ue.isInterleavedBufferAttribute){const He=Ue.data,Ie=He.stride,kt=Ue.offset;if(He.isInstancedInterleavedBuffer){for(let at=0;at0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";g="mediump"}return g==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const f=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=s.getParameter(s.MAX_TEXTURE_SIZE),b=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),y=s.getParameter(s.MAX_VERTEX_ATTRIBS),w=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),E=s.getParameter(s.MAX_VARYING_VECTORS),S=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),I=v>0,L=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:v,maxTextureSize:x,maxCubemapSize:b,maxAttributes:y,maxVertexUniforms:w,maxVaryings:E,maxFragmentUniforms:S,vertexTextures:I,maxSamples:L}}function M1(s){const e=this;let t=null,n=0,i=!1,r=!1;const o=new ks,a=new Dt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,d){const p=f.length!==0||d||n!==0||i;return i=d,n=f.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(f,d){t=u(f,d,0)},this.setState=function(f,d,p){const v=f.clippingPlanes,x=f.clipIntersection,b=f.clipShadows,y=s.get(f);if(!i||v===null||v.length===0||r&&!b)r?u(null):c();else{const w=r?0:n,E=w*4;let S=y.clippingState||null;l.value=S,S=u(v,d,E,p);for(let I=0;I!==E;++I)S[I]=t[I];y.clippingState=S,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(f,d,p,v){const x=f!==null?f.length:0;let b=null;if(x!==0){if(b=l.value,v!==!0||b===null){const y=p+x*4,w=d.matrixWorldInverse;a.getNormalMatrix(w),(b===null||b.length0){const c=new sv(l.height);return c.fromEquirectangularTexture(s,o),e.set(o,c),o.addEventListener("dispose",i),t(c.texture,o.mapping)}else return null}}return o}function i(o){const a=o.target;a.removeEventListener("dispose",i);const l=e.get(a);l!==void 0&&(e.delete(a),l.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}const El=4,uy=[.125,.215,.35,.446,.526,.582],Ma=20,bp=new Su,hy=new $e;let Mp=null,Sp=0,Tp=0,wp=!1;const xa=(1+Math.sqrt(5))/2,Sl=1/xa,fy=[new H(-xa,Sl,0),new H(xa,Sl,0),new H(-Sl,0,xa),new H(Sl,0,xa),new H(0,xa,-Sl),new H(0,xa,Sl),new H(-1,1,-1),new H(1,1,-1),new H(-1,1,1),new H(1,1,1)],T1=new H;class em{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100,r={}){const{size:o=256,position:a=T1}=r;Mp=this._renderer.getRenderTarget(),Sp=this._renderer.getActiveCubeFace(),Tp=this._renderer.getActiveMipmapLevel(),wp=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,i,l,a),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=my(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=py(),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;e2?S:0,S,S),f.setRenderTarget(i),b&&f.render(x,l),f.render(e,l)}x.geometry.dispose(),x.material.dispose(),f.toneMapping=p,f.autoClear=d,e.background=y}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Ys||e.mapping===Ao;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=my()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=py());const r=i?this._cubemapMaterial:this._equirectMaterial,o=new Qn(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;const l=this._cubeSize;Dh(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(o,bp)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let r=1;rMa&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${b} samples when the maximum is set to ${Ma}`);const y=[];let w=0;for(let g=0;gE-El?i-E+El:0),L=4*(this._cubeSize-S);Dh(t,I,L,3*S,2*S),l.setRenderTarget(t),l.render(f,bp)}}function w1(s){const e=[],t=[],n=[];let i=s;const r=s-El+1+uy.length;for(let o=0;os-El?l=uy[o-s+El-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,f=1+c,d=[u,u,f,u,f,f,u,u,f,f,u,f],p=6,v=6,x=3,b=2,y=1,w=new Float32Array(x*v*p),E=new Float32Array(b*v*p),S=new Float32Array(y*v*p);for(let L=0;L2?0:-1,R=[g,F,0,g+2/3,F,0,g+2/3,F+1,0,g,F,0,g+2/3,F+1,0,g,F+1,0];w.set(R,x*v*L),E.set(d,b*v*L);const N=[L,L,L,L,L,L];S.set(N,y*v*L)}const I=new Ft;I.setAttribute("position",new pn(w,x)),I.setAttribute("uv",new pn(E,b)),I.setAttribute("faceIndex",new pn(S,y)),e.push(I),i>El&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function dy(s,e,t){const n=new Ss(s,e,t);return n.texture.mapping=Jl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Dh(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function E1(s,e,t){const n=new Float32Array(Ma),i=new H(0,1,0);return new ns({name:"SphericalGaussianBlur",defines:{n:Ma,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:ug(),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 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:Xs,depthTest:!1,depthWrite:!1})}function py(){return new ns({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ug(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:Xs,depthTest:!1,depthWrite:!1})}function my(){return new ns({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ug(),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:Xs,depthTest:!1,depthWrite:!1})}function ug(){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 A1(s){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){const l=a.mapping,c=l===$c||l===Yc,u=l===Ys||l===Ao;if(c||u){let f=e.get(a);const d=f!==void 0?f.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new em(s)),f=c?t.fromEquirectangular(a,f):t.fromCubemap(a,f),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),f.texture;if(f!==void 0)return f.texture;{const p=a.image;return c&&p&&p.height>0||u&&p&&i(p)?(t===null&&(t=new em(s)),f=c?t.fromEquirectangular(a):t.fromCubemap(a),f.texture.pmremVersion=a.pmremVersion,e.set(a,f),a.addEventListener("dispose",r),f.texture):null}}}return a}function i(a){let l=0;const c=6;for(let u=0;ue.maxTextureSize&&(L=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const g=new Float32Array(I*L*4*f),F=new pu(g,I,L,f);F.type=nr,F.needsUpdate=!0;const R=S*4;for(let G=0;G0)return s;const i=e*t;let r=_y[i];if(r===void 0&&(r=new Float32Array(i),_y[i]=r),e!==0){n.toArray(r,0);for(let o=1,a=0;o!==e;++o)a+=t,s[o].toArray(r,a)}return r}function fi(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t":" "} ${a}: ${t[o]}`)}return n.join(` `)}const Ty=new Dt;function AC(s){en._getMatrix(Ty,en.workingColorSpace,s);const e=`mat3( ${Ty.elements.map(t=>t.toFixed(4))} )`;switch(en.getTransfer(s)){case Zc:return[e,"LinearTransferOETF"];case bn:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function wy(s,e,t){const n=s.getShaderParameter(e,s.COMPILE_STATUS),i=s.getShaderInfoLog(e).trim();if(n&&i==="")return"";const r=/ERROR: 0:(\d+)/.exec(i);if(r){const o=parseInt(r[1]);return t.toUpperCase()+` `+i+` `+EC(s.getShaderSource(e),o)}else return i}function CC(s,e){const t=AC(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}function RC(s,e){let t;switch(e){case P0:t="Linear";break;case I0:t="Reinhard";break;case L0:t="Cineon";break;case D0:t="ACESFilmic";break;case O0:t="AgX";break;case U0:t="Neutral";break;case N0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Nh=new H;function PC(){en.getLuminanceCoefficients(Nh);const s=Nh.x.toFixed(4),e=Nh.y.toFixed(4),t=Nh.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function IC(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Dc).join(` `)}function LC(s){const e=[];for(const t in s){const n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` `)}function DC(s,e){const t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function tm(s){return s.replace(NC,UC)}const OC=new Map;function UC(s,e){let t=Vt[e];if(t===void 0){const n=OC.get(e);if(n!==void 0)t=Vt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return tm(t)}const FC=/#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 Cy(s){return s.replace(FC,BC)}function BC(s,e,t,n){let i="";for(let r=parseInt(e);r0&&(b+=` `),y=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Dc).join(` `),y.length>0&&(y+=` `)):(b=[Ry(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",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?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(Dc).join(` `),y=[Ry(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+f:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.dispersion?"#define USE_DISPERSION":"",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||t.batchingColor?"#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 "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==qs?"#define TONE_MAPPING":"",t.toneMapping!==qs?Vt.tonemapping_pars_fragment:"",t.toneMapping!==qs?RC("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Vt.colorspace_pars_fragment,CC("linearToOutputTexel",t.outputColorSpace),PC(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(Dc).join(` `)),o=tm(o),o=Ey(o,t),o=Ay(o,t),a=tm(a),a=Ey(a,t),a=Ay(a,t),o=Cy(o),a=Cy(a),t.isRawShaderMaterial!==!0&&(w=`#version 300 es `,b=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+b,y=["#define varying in",t.glslVersion===qp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===qp?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` `+y);const E=w+b+o,S=w+y+a,I=Sy(i,i.VERTEX_SHADER,E),L=Sy(i,i.FRAGMENT_SHADER,S);i.attachShader(x,I),i.attachShader(x,L),t.index0AttributeName!==void 0?i.bindAttribLocation(x,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(x,0,"position"),i.linkProgram(x);function g(G){if(s.debug.checkShaderErrors){const se=i.getProgramInfoLog(x).trim(),Y=i.getShaderInfoLog(I).trim(),he=i.getShaderInfoLog(L).trim();let pe=!0,ce=!0;if(i.getProgramParameter(x,i.LINK_STATUS)===!1)if(pe=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,x,I,L);else{const ge=wy(i,I,"vertex"),fe=wy(i,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(x,i.VALIDATE_STATUS)+` Material Name: `+G.name+` Material Type: `+G.type+` Program Info Log: `+se+` `+ge+` `+fe)}else se!==""?console.warn("THREE.WebGLProgram: Program Info Log:",se):(Y===""||he==="")&&(ce=!1);ce&&(G.diagnostics={runnable:pe,programLog:se,vertexShader:{log:Y,prefix:b},fragmentShader:{log:he,prefix:y}})}i.deleteShader(I),i.deleteShader(L),F=new zh(i,x),R=DC(i,x)}let F;this.getUniforms=function(){return F===void 0&&g(this),F};let R;this.getAttributes=function(){return R===void 0&&g(this),R};let N=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return N===!1&&(N=i.getProgramParameter(x,TC)),N},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=wC++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=I,this.fragmentShader=L,this}let XC=0;class qC{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new $C(e),t.set(e,n)),n}}class $C{constructor(e){this.id=XC++,this.code=e,this.usedTimes=0}}function YC(s,e,t,n,i,r,o){const a=new Jf,l=new qC,c=new Set,u=[],f=i.logarithmicDepthBuffer,d=i.vertexTextures;let p=i.precision;const v={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(R){return c.add(R),R===0?"uv":`uv${R}`}function b(R,N,G,se,Y){const he=se.fog,pe=Y.geometry,ce=R.isMeshStandardMaterial?se.environment:null,ge=(R.isMeshStandardMaterial?t:e).get(R.envMap||ce),fe=ge&&ge.mapping===Jl?ge.image.height:null,Ue=v[R.type];R.precision!==null&&(p=i.getMaxPrecision(R.precision),p!==R.precision&&console.warn("THREE.WebGLProgram.getParameters:",R.precision,"not supported, using",p,"instead."));const ne=pe.morphAttributes.position||pe.morphAttributes.normal||pe.morphAttributes.color,Ye=ne!==void 0?ne.length:0;let mt=0;pe.morphAttributes.position!==void 0&&(mt=1),pe.morphAttributes.normal!==void 0&&(mt=2),pe.morphAttributes.color!==void 0&&(mt=3);let Bt,ye,Le,Ge;if(Ue){const cn=Jr[Ue];Bt=cn.vertexShader,ye=cn.fragmentShader}else Bt=R.vertexShader,ye=R.fragmentShader,l.update(R),Le=l.getVertexShaderID(R),Ge=l.getFragmentShaderID(R);const He=s.getRenderTarget(),Ie=s.state.buffers.depth.getReversed(),kt=Y.isInstancedMesh===!0,at=Y.isBatchedMesh===!0,tn=!!R.map,Zt=!!R.matcap,St=!!ge,q=!!R.aoMap,mn=!!R.lightMap,we=!!R.bumpMap,Re=!!R.normalMap,Me=!!R.displacementMap,Ve=!!R.emissiveMap,Ee=!!R.metalnessMap,z=!!R.roughnessMap,O=R.anisotropy>0,te=R.clearcoat>0,_e=R.dispersion>0,J=R.iridescence>0,me=R.sheen>0,rt=R.transmission>0,Fe=O&&!!R.anisotropyMap,je=te&&!!R.clearcoatMap,Et=te&&!!R.clearcoatNormalMap,De=te&&!!R.clearcoatRoughnessMap,Xe=J&&!!R.iridescenceMap,ut=J&&!!R.iridescenceThicknessMap,ft=me&&!!R.sheenColorMap,Ze=me&&!!R.sheenRoughnessMap,$t=!!R.specularMap,Tt=!!R.specularColorMap,fn=!!R.specularIntensityMap,K=rt&&!!R.transmissionMap,Ke=rt&&!!R.thicknessMap,xe=!!R.gradientMap,Ce=!!R.alphaMap,Je=R.alphaTest>0,We=!!R.alphaHash,gt=!!R.extensions;let Xt=qs;R.toneMapped&&(He===null||He.isXRRenderTarget===!0)&&(Xt=s.toneMapping);const zn={shaderID:Ue,shaderType:R.type,shaderName:R.name,vertexShader:Bt,fragmentShader:ye,defines:R.defines,customVertexShaderID:Le,customFragmentShaderID:Ge,isRawShaderMaterial:R.isRawShaderMaterial===!0,glslVersion:R.glslVersion,precision:p,batching:at,batchingColor:at&&Y._colorsTexture!==null,instancing:kt,instancingColor:kt&&Y.instanceColor!==null,instancingMorph:kt&&Y.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:He===null?s.outputColorSpace:He.isXRRenderTarget===!0?He.texture.colorSpace:Ni,alphaToCoverage:!!R.alphaToCoverage,map:tn,matcap:Zt,envMap:St,envMapMode:St&&ge.mapping,envMapCubeUVHeight:fe,aoMap:q,lightMap:mn,bumpMap:we,normalMap:Re,displacementMap:d&&Me,emissiveMap:Ve,normalMapObjectSpace:Re&&R.normalMapType===W0,normalMapTangentSpace:Re&&R.normalMapType===Lo,metalnessMap:Ee,roughnessMap:z,anisotropy:O,anisotropyMap:Fe,clearcoat:te,clearcoatMap:je,clearcoatNormalMap:Et,clearcoatRoughnessMap:De,dispersion:_e,iridescence:J,iridescenceMap:Xe,iridescenceThicknessMap:ut,sheen:me,sheenColorMap:ft,sheenRoughnessMap:Ze,specularMap:$t,specularColorMap:Tt,specularIntensityMap:fn,transmission:rt,transmissionMap:K,thicknessMap:Ke,gradientMap:xe,opaque:R.transparent===!1&&R.blending===Pa&&R.alphaToCoverage===!1,alphaMap:Ce,alphaTest:Je,alphaHash:We,combine:R.combine,mapUv:tn&&x(R.map.channel),aoMapUv:q&&x(R.aoMap.channel),lightMapUv:mn&&x(R.lightMap.channel),bumpMapUv:we&&x(R.bumpMap.channel),normalMapUv:Re&&x(R.normalMap.channel),displacementMapUv:Me&&x(R.displacementMap.channel),emissiveMapUv:Ve&&x(R.emissiveMap.channel),metalnessMapUv:Ee&&x(R.metalnessMap.channel),roughnessMapUv:z&&x(R.roughnessMap.channel),anisotropyMapUv:Fe&&x(R.anisotropyMap.channel),clearcoatMapUv:je&&x(R.clearcoatMap.channel),clearcoatNormalMapUv:Et&&x(R.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:De&&x(R.clearcoatRoughnessMap.channel),iridescenceMapUv:Xe&&x(R.iridescenceMap.channel),iridescenceThicknessMapUv:ut&&x(R.iridescenceThicknessMap.channel),sheenColorMapUv:ft&&x(R.sheenColorMap.channel),sheenRoughnessMapUv:Ze&&x(R.sheenRoughnessMap.channel),specularMapUv:$t&&x(R.specularMap.channel),specularColorMapUv:Tt&&x(R.specularColorMap.channel),specularIntensityMapUv:fn&&x(R.specularIntensityMap.channel),transmissionMapUv:K&&x(R.transmissionMap.channel),thicknessMapUv:Ke&&x(R.thicknessMap.channel),alphaMapUv:Ce&&x(R.alphaMap.channel),vertexTangents:!!pe.attributes.tangent&&(Re||O),vertexColors:R.vertexColors,vertexAlphas:R.vertexColors===!0&&!!pe.attributes.color&&pe.attributes.color.itemSize===4,pointsUvs:Y.isPoints===!0&&!!pe.attributes.uv&&(tn||Ce),fog:!!he,useFog:R.fog===!0,fogExp2:!!he&&he.isFogExp2,flatShading:R.flatShading===!0,sizeAttenuation:R.sizeAttenuation===!0,logarithmicDepthBuffer:f,reverseDepthBuffer:Ie,skinning:Y.isSkinnedMesh===!0,morphTargets:pe.morphAttributes.position!==void 0,morphNormals:pe.morphAttributes.normal!==void 0,morphColors:pe.morphAttributes.color!==void 0,morphTargetsCount:Ye,morphTextureStride:mt,numDirLights:N.directional.length,numPointLights:N.point.length,numSpotLights:N.spot.length,numSpotLightMaps:N.spotLightMap.length,numRectAreaLights:N.rectArea.length,numHemiLights:N.hemi.length,numDirLightShadows:N.directionalShadowMap.length,numPointLightShadows:N.pointShadowMap.length,numSpotLightShadows:N.spotShadowMap.length,numSpotLightShadowsWithMaps:N.numSpotLightShadowsWithMaps,numLightProbes:N.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:R.dithering,shadowMapEnabled:s.shadowMap.enabled&&G.length>0,shadowMapType:s.shadowMap.type,toneMapping:Xt,decodeVideoTexture:tn&&R.map.isVideoTexture===!0&&en.getTransfer(R.map.colorSpace)===bn,decodeVideoTextureEmissive:Ve&&R.emissiveMap.isVideoTexture===!0&&en.getTransfer(R.emissiveMap.colorSpace)===bn,premultipliedAlpha:R.premultipliedAlpha,doubleSided:R.side===Qr,flipSided:R.side===$i,useDepthPacking:R.depthPacking>=0,depthPacking:R.depthPacking||0,index0AttributeName:R.index0AttributeName,extensionClipCullDistance:gt&&R.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&R.extensions.multiDraw===!0||at)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:R.customProgramCacheKey()};return zn.vertexUv1s=c.has(1),zn.vertexUv2s=c.has(2),zn.vertexUv3s=c.has(3),c.clear(),zn}function y(R){const N=[];if(R.shaderID?N.push(R.shaderID):(N.push(R.customVertexShaderID),N.push(R.customFragmentShaderID)),R.defines!==void 0)for(const G in R.defines)N.push(G),N.push(R.defines[G]);return R.isRawShaderMaterial===!1&&(w(N,R),E(N,R),N.push(s.outputColorSpace)),N.push(R.customProgramCacheKey),N.join()}function w(R,N){R.push(N.precision),R.push(N.outputColorSpace),R.push(N.envMapMode),R.push(N.envMapCubeUVHeight),R.push(N.mapUv),R.push(N.alphaMapUv),R.push(N.lightMapUv),R.push(N.aoMapUv),R.push(N.bumpMapUv),R.push(N.normalMapUv),R.push(N.displacementMapUv),R.push(N.emissiveMapUv),R.push(N.metalnessMapUv),R.push(N.roughnessMapUv),R.push(N.anisotropyMapUv),R.push(N.clearcoatMapUv),R.push(N.clearcoatNormalMapUv),R.push(N.clearcoatRoughnessMapUv),R.push(N.iridescenceMapUv),R.push(N.iridescenceThicknessMapUv),R.push(N.sheenColorMapUv),R.push(N.sheenRoughnessMapUv),R.push(N.specularMapUv),R.push(N.specularColorMapUv),R.push(N.specularIntensityMapUv),R.push(N.transmissionMapUv),R.push(N.thicknessMapUv),R.push(N.combine),R.push(N.fogExp2),R.push(N.sizeAttenuation),R.push(N.morphTargetsCount),R.push(N.morphAttributeCount),R.push(N.numDirLights),R.push(N.numPointLights),R.push(N.numSpotLights),R.push(N.numSpotLightMaps),R.push(N.numHemiLights),R.push(N.numRectAreaLights),R.push(N.numDirLightShadows),R.push(N.numPointLightShadows),R.push(N.numSpotLightShadows),R.push(N.numSpotLightShadowsWithMaps),R.push(N.numLightProbes),R.push(N.shadowMapType),R.push(N.toneMapping),R.push(N.numClippingPlanes),R.push(N.numClipIntersection),R.push(N.depthPacking)}function E(R,N){a.disableAll(),N.supportsVertexTextures&&a.enable(0),N.instancing&&a.enable(1),N.instancingColor&&a.enable(2),N.instancingMorph&&a.enable(3),N.matcap&&a.enable(4),N.envMap&&a.enable(5),N.normalMapObjectSpace&&a.enable(6),N.normalMapTangentSpace&&a.enable(7),N.clearcoat&&a.enable(8),N.iridescence&&a.enable(9),N.alphaTest&&a.enable(10),N.vertexColors&&a.enable(11),N.vertexAlphas&&a.enable(12),N.vertexUv1s&&a.enable(13),N.vertexUv2s&&a.enable(14),N.vertexUv3s&&a.enable(15),N.vertexTangents&&a.enable(16),N.anisotropy&&a.enable(17),N.alphaHash&&a.enable(18),N.batching&&a.enable(19),N.dispersion&&a.enable(20),N.batchingColor&&a.enable(21),R.push(a.mask),a.disableAll(),N.fog&&a.enable(0),N.useFog&&a.enable(1),N.flatShading&&a.enable(2),N.logarithmicDepthBuffer&&a.enable(3),N.reverseDepthBuffer&&a.enable(4),N.skinning&&a.enable(5),N.morphTargets&&a.enable(6),N.morphNormals&&a.enable(7),N.morphColors&&a.enable(8),N.premultipliedAlpha&&a.enable(9),N.shadowMapEnabled&&a.enable(10),N.doubleSided&&a.enable(11),N.flipSided&&a.enable(12),N.useDepthPacking&&a.enable(13),N.dithering&&a.enable(14),N.transmission&&a.enable(15),N.sheen&&a.enable(16),N.opaque&&a.enable(17),N.pointsUvs&&a.enable(18),N.decodeVideoTexture&&a.enable(19),N.decodeVideoTextureEmissive&&a.enable(20),N.alphaToCoverage&&a.enable(21),R.push(a.mask)}function S(R){const N=v[R.type];let G;if(N){const se=Jr[N];G=iv.clone(se.uniforms)}else G=R.uniforms;return G}function I(R,N){let G;for(let se=0,Y=u.length;se0?n.push(y):p.transparent===!0?i.push(y):t.push(y)}function l(f,d,p,v,x,b){const y=o(f,d,p,v,x,b);p.transmission>0?n.unshift(y):p.transparent===!0?i.unshift(y):t.unshift(y)}function c(f,d){t.length>1&&t.sort(f||ZC),n.length>1&&n.sort(d||Py),i.length>1&&i.sort(d||Py)}function u(){for(let f=e,d=s.length;f=r.length?(o=new Iy,r.push(o)):o=r[i],o}function t(){s=new WeakMap}return{get:e,dispose:t}}function JC(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new H,color:new $e};break;case"SpotLight":t={position:new H,direction:new H,color:new $e,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new H,color:new $e,distance:0,decay:0};break;case"HemisphereLight":t={direction:new H,skyColor:new $e,groundColor:new $e};break;case"RectAreaLight":t={color:new $e,position:new H,halfWidth:new H,halfHeight:new H};break}return s[e.id]=t,t}}}function QC(){const s={};return{get:function(e){if(s[e.id]!==void 0)return s[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ae,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}let eR=0;function tR(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function nR(s){const e=new JC,t=QC(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new H);const i=new H,r=new _t,o=new _t;function a(c){let u=0,f=0,d=0;for(let R=0;R<9;R++)n.probe[R].set(0,0,0);let p=0,v=0,x=0,b=0,y=0,w=0,E=0,S=0,I=0,L=0,g=0;c.sort(tR);for(let R=0,N=c.length;R0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=qe.LTC_FLOAT_1,n.rectAreaLTC2=qe.LTC_FLOAT_2):(n.rectAreaLTC1=qe.LTC_HALF_1,n.rectAreaLTC2=qe.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=f,n.ambient[2]=d;const F=n.hash;(F.directionalLength!==p||F.pointLength!==v||F.spotLength!==x||F.rectAreaLength!==b||F.hemiLength!==y||F.numDirectionalShadows!==w||F.numPointShadows!==E||F.numSpotShadows!==S||F.numSpotMaps!==I||F.numLightProbes!==g)&&(n.directional.length=p,n.spot.length=x,n.rectArea.length=b,n.point.length=v,n.hemi.length=y,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=S+I-L,n.spotLightMap.length=I,n.numSpotLightShadowsWithMaps=L,n.numLightProbes=g,F.directionalLength=p,F.pointLength=v,F.spotLength=x,F.rectAreaLength=b,F.hemiLength=y,F.numDirectionalShadows=w,F.numPointShadows=E,F.numSpotShadows=S,F.numSpotMaps=I,F.numLightProbes=g,n.version=eR++)}function l(c,u){let f=0,d=0,p=0,v=0,x=0;const b=u.matrixWorldInverse;for(let y=0,w=c.length;y=o.length?(a=new Ly(s),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}const rR=`void main() { gl_Position = vec4( position, 1.0 ); }`,sR=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include 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 oR(s,e,t){let n=new yu;const i=new Ae,r=new Ae,o=new un,a=new jm({depthPacking:G0}),l=new Zm,c={},u=t.maxTextureSize,f={[bs]:$i,[$i]:bs,[Qr]:Qr},d=new ns({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ae},radius:{value:4}},vertexShader:rR,fragmentShader:sR}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const v=new Ft;v.setAttribute("position",new pn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Qn(v,d),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xm;let y=this.type;this.render=function(L,g,F){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||L.length===0)return;const R=s.getRenderTarget(),N=s.getActiveCubeFace(),G=s.getActiveMipmapLevel(),se=s.state;se.setBlending(Xs),se.buffers.color.setClear(1,1,1,1),se.buffers.depth.setTest(!0),se.setScissorTest(!1);const Y=y!==ps&&this.type===ps,he=y===ps&&this.type!==ps;for(let pe=0,ce=L.length;peu||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/Ue.x),i.x=r.x*Ue.x,fe.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/Ue.y),i.y=r.y*Ue.y,fe.mapSize.y=r.y)),fe.map===null||Y===!0||he===!0){const Ye=this.type!==ps?{minFilter:ui,magFilter:ui}:{};fe.map!==null&&fe.map.dispose(),fe.map=new Ss(i.x,i.y,Ye),fe.map.texture.name=ge.name+".shadowMap",fe.camera.updateProjectionMatrix()}s.setRenderTarget(fe.map),s.clear();const ne=fe.getViewportCount();for(let Ye=0;Ye0||g.map&&g.alphaTest>0){const se=N.uuid,Y=g.uuid;let he=c[se];he===void 0&&(he={},c[se]=he);let pe=he[Y];pe===void 0&&(pe=N.clone(),he[Y]=pe,g.addEventListener("dispose",I)),N=pe}if(N.visible=g.visible,N.wireframe=g.wireframe,R===ps?N.side=g.shadowSide!==null?g.shadowSide:g.side:N.side=g.shadowSide!==null?g.shadowSide:f[g.side],N.alphaMap=g.alphaMap,N.alphaTest=g.alphaTest,N.map=g.map,N.clipShadows=g.clipShadows,N.clippingPlanes=g.clippingPlanes,N.clipIntersection=g.clipIntersection,N.displacementMap=g.displacementMap,N.displacementScale=g.displacementScale,N.displacementBias=g.displacementBias,N.wireframeLinewidth=g.wireframeLinewidth,N.linewidth=g.linewidth,F.isPointLight===!0&&N.isMeshDistanceMaterial===!0){const se=s.properties.get(N);se.light=F}return N}function S(L,g,F,R,N){if(L.visible===!1)return;if(L.layers.test(g.layers)&&(L.isMesh||L.isLine||L.isPoints)&&(L.castShadow||L.receiveShadow&&N===ps)&&(!L.frustumCulled||n.intersectsObject(L))){L.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,L.matrixWorld);const Y=e.update(L),he=L.material;if(Array.isArray(he)){const pe=Y.groups;for(let ce=0,ge=pe.length;ce=1):fe.indexOf("OpenGL ES")!==-1&&(ge=parseFloat(/^OpenGL ES (\d)/.exec(fe)[1]),ce=ge>=2);let Ue=null,ne={};const Ye=s.getParameter(s.SCISSOR_BOX),mt=s.getParameter(s.VIEWPORT),Bt=new un().fromArray(Ye),ye=new un().fromArray(mt);function Le(K,Ke,xe,Ce){const Je=new Uint8Array(4),We=s.createTexture();s.bindTexture(K,We),s.texParameteri(K,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(K,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let gt=0;gt"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ae,u=new WeakMap;let f;const d=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(z,O){return p?new OffscreenCanvas(z,O):Qc("canvas")}function x(z,O,te){let _e=1;const J=Ee(z);if((J.width>te||J.height>te)&&(_e=te/Math.max(J.width,J.height)),_e<1)if(typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&z instanceof ImageBitmap||typeof VideoFrame<"u"&&z instanceof VideoFrame){const me=Math.floor(_e*J.width),rt=Math.floor(_e*J.height);f===void 0&&(f=v(me,rt));const Fe=O?v(me,rt):f;return Fe.width=me,Fe.height=rt,Fe.getContext("2d").drawImage(z,0,0,me,rt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+J.width+"x"+J.height+") to ("+me+"x"+rt+")."),Fe}else return"data"in z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+J.width+"x"+J.height+")."),z;return z}function b(z){return z.generateMipmaps}function y(z){s.generateMipmap(z)}function w(z){return z.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:z.isWebGL3DRenderTarget?s.TEXTURE_3D:z.isWebGLArrayRenderTarget||z.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function E(z,O,te,_e,J=!1){if(z!==null){if(s[z]!==void 0)return s[z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+z+"'")}let me=O;if(O===s.RED&&(te===s.FLOAT&&(me=s.R32F),te===s.HALF_FLOAT&&(me=s.R16F),te===s.UNSIGNED_BYTE&&(me=s.R8)),O===s.RED_INTEGER&&(te===s.UNSIGNED_BYTE&&(me=s.R8UI),te===s.UNSIGNED_SHORT&&(me=s.R16UI),te===s.UNSIGNED_INT&&(me=s.R32UI),te===s.BYTE&&(me=s.R8I),te===s.SHORT&&(me=s.R16I),te===s.INT&&(me=s.R32I)),O===s.RG&&(te===s.FLOAT&&(me=s.RG32F),te===s.HALF_FLOAT&&(me=s.RG16F),te===s.UNSIGNED_BYTE&&(me=s.RG8)),O===s.RG_INTEGER&&(te===s.UNSIGNED_BYTE&&(me=s.RG8UI),te===s.UNSIGNED_SHORT&&(me=s.RG16UI),te===s.UNSIGNED_INT&&(me=s.RG32UI),te===s.BYTE&&(me=s.RG8I),te===s.SHORT&&(me=s.RG16I),te===s.INT&&(me=s.RG32I)),O===s.RGB_INTEGER&&(te===s.UNSIGNED_BYTE&&(me=s.RGB8UI),te===s.UNSIGNED_SHORT&&(me=s.RGB16UI),te===s.UNSIGNED_INT&&(me=s.RGB32UI),te===s.BYTE&&(me=s.RGB8I),te===s.SHORT&&(me=s.RGB16I),te===s.INT&&(me=s.RGB32I)),O===s.RGBA_INTEGER&&(te===s.UNSIGNED_BYTE&&(me=s.RGBA8UI),te===s.UNSIGNED_SHORT&&(me=s.RGBA16UI),te===s.UNSIGNED_INT&&(me=s.RGBA32UI),te===s.BYTE&&(me=s.RGBA8I),te===s.SHORT&&(me=s.RGBA16I),te===s.INT&&(me=s.RGBA32I)),O===s.RGB&&te===s.UNSIGNED_INT_5_9_9_9_REV&&(me=s.RGB9_E5),O===s.RGBA){const rt=J?Zc:en.getTransfer(_e);te===s.FLOAT&&(me=s.RGBA32F),te===s.HALF_FLOAT&&(me=s.RGBA16F),te===s.UNSIGNED_BYTE&&(me=rt===bn?s.SRGB8_ALPHA8:s.RGBA8),te===s.UNSIGNED_SHORT_4_4_4_4&&(me=s.RGBA4),te===s.UNSIGNED_SHORT_5_5_5_1&&(me=s.RGB5_A1)}return(me===s.R16F||me===s.R32F||me===s.RG16F||me===s.RG32F||me===s.RGBA16F||me===s.RGBA32F)&&e.get("EXT_color_buffer_float"),me}function S(z,O){let te;return z?O===null||O===js||O===Fl?te=s.DEPTH24_STENCIL8:O===nr?te=s.DEPTH32F_STENCIL8:O===Ul&&(te=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===js||O===Fl?te=s.DEPTH_COMPONENT24:O===nr?te=s.DEPTH_COMPONENT32F:O===Ul&&(te=s.DEPTH_COMPONENT16),te}function I(z,O){return b(z)===!0||z.isFramebufferTexture&&z.minFilter!==ui&&z.minFilter!==qn?Math.log2(Math.max(O.width,O.height))+1:z.mipmaps!==void 0&&z.mipmaps.length>0?z.mipmaps.length:z.isCompressedTexture&&Array.isArray(z.image)?O.mipmaps.length:1}function L(z){const O=z.target;O.removeEventListener("dispose",L),F(O),O.isVideoTexture&&u.delete(O)}function g(z){const O=z.target;O.removeEventListener("dispose",g),N(O)}function F(z){const O=n.get(z);if(O.__webglInit===void 0)return;const te=z.source,_e=d.get(te);if(_e){const J=_e[O.__cacheKey];J.usedTimes--,J.usedTimes===0&&R(z),Object.keys(_e).length===0&&d.delete(te)}n.remove(z)}function R(z){const O=n.get(z);s.deleteTexture(O.__webglTexture);const te=z.source,_e=d.get(te);delete _e[O.__cacheKey],o.memory.textures--}function N(z){const O=n.get(z);if(z.depthTexture&&(z.depthTexture.dispose(),n.remove(z.depthTexture)),z.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(O.__webglFramebuffer[_e]))for(let J=0;J=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+z+" texture units while this GPU supports only "+i.maxTextures),G+=1,z}function he(z){const O=[];return O.push(z.wrapS),O.push(z.wrapT),O.push(z.wrapR||0),O.push(z.magFilter),O.push(z.minFilter),O.push(z.anisotropy),O.push(z.internalFormat),O.push(z.format),O.push(z.type),O.push(z.generateMipmaps),O.push(z.premultiplyAlpha),O.push(z.flipY),O.push(z.unpackAlignment),O.push(z.colorSpace),O.join()}function pe(z,O){const te=n.get(z);if(z.isVideoTexture&&Me(z),z.isRenderTargetTexture===!1&&z.version>0&&te.__version!==z.version){const _e=z.image;if(_e===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(_e.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ye(te,z,O);return}}t.bindTexture(s.TEXTURE_2D,te.__webglTexture,s.TEXTURE0+O)}function ce(z,O){const te=n.get(z);if(z.version>0&&te.__version!==z.version){ye(te,z,O);return}t.bindTexture(s.TEXTURE_2D_ARRAY,te.__webglTexture,s.TEXTURE0+O)}function ge(z,O){const te=n.get(z);if(z.version>0&&te.__version!==z.version){ye(te,z,O);return}t.bindTexture(s.TEXTURE_3D,te.__webglTexture,s.TEXTURE0+O)}function fe(z,O){const te=n.get(z);if(z.version>0&&te.__version!==z.version){Le(te,z,O);return}t.bindTexture(s.TEXTURE_CUBE_MAP,te.__webglTexture,s.TEXTURE0+O)}const Ue={[Co]:s.REPEAT,[vr]:s.CLAMP_TO_EDGE,[Ol]:s.MIRRORED_REPEAT},ne={[ui]:s.NEAREST,[Vf]:s.NEAREST_MIPMAP_NEAREST,[Ta]:s.NEAREST_MIPMAP_LINEAR,[qn]:s.LINEAR,[Rl]:s.LINEAR_MIPMAP_NEAREST,[Fr]:s.LINEAR_MIPMAP_LINEAR},Ye={[X0]:s.NEVER,[K0]:s.ALWAYS,[q0]:s.LESS,[Lm]:s.LEQUAL,[$0]:s.EQUAL,[Z0]:s.GEQUAL,[Y0]:s.GREATER,[j0]:s.NOTEQUAL};function mt(z,O){if(O.type===nr&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===qn||O.magFilter===Rl||O.magFilter===Ta||O.magFilter===Fr||O.minFilter===qn||O.minFilter===Rl||O.minFilter===Ta||O.minFilter===Fr)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(z,s.TEXTURE_WRAP_S,Ue[O.wrapS]),s.texParameteri(z,s.TEXTURE_WRAP_T,Ue[O.wrapT]),(z===s.TEXTURE_3D||z===s.TEXTURE_2D_ARRAY)&&s.texParameteri(z,s.TEXTURE_WRAP_R,Ue[O.wrapR]),s.texParameteri(z,s.TEXTURE_MAG_FILTER,ne[O.magFilter]),s.texParameteri(z,s.TEXTURE_MIN_FILTER,ne[O.minFilter]),O.compareFunction&&(s.texParameteri(z,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(z,s.TEXTURE_COMPARE_FUNC,Ye[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===ui||O.minFilter!==Ta&&O.minFilter!==Fr||O.type===nr&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||n.get(O).__currentAnisotropy){const te=e.get("EXT_texture_filter_anisotropic");s.texParameterf(z,te.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),n.get(O).__currentAnisotropy=O.anisotropy}}}function Bt(z,O){let te=!1;z.__webglInit===void 0&&(z.__webglInit=!0,O.addEventListener("dispose",L));const _e=O.source;let J=d.get(_e);J===void 0&&(J={},d.set(_e,J));const me=he(O);if(me!==z.__cacheKey){J[me]===void 0&&(J[me]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,te=!0),J[me].usedTimes++;const rt=J[z.__cacheKey];rt!==void 0&&(J[z.__cacheKey].usedTimes--,rt.usedTimes===0&&R(O)),z.__cacheKey=me,z.__webglTexture=J[me].texture}return te}function ye(z,O,te){let _e=s.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(_e=s.TEXTURE_2D_ARRAY),O.isData3DTexture&&(_e=s.TEXTURE_3D);const J=Bt(z,O),me=O.source;t.bindTexture(_e,z.__webglTexture,s.TEXTURE0+te);const rt=n.get(me);if(me.version!==rt.__version||J===!0){t.activeTexture(s.TEXTURE0+te);const Fe=en.getPrimaries(en.workingColorSpace),je=O.colorSpace===Hs?null:en.getPrimaries(O.colorSpace),Et=O.colorSpace===Hs||Fe===je?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,O.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,O.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Et);let De=x(O.image,!1,i.maxTextureSize);De=Ve(O,De);const Xe=r.convert(O.format,O.colorSpace),ut=r.convert(O.type);let ft=E(O.internalFormat,Xe,ut,O.colorSpace,O.isVideoTexture);mt(_e,O);let Ze;const $t=O.mipmaps,Tt=O.isVideoTexture!==!0,fn=rt.__version===void 0||J===!0,K=me.dataReady,Ke=I(O,De);if(O.isDepthTexture)ft=S(O.format===kl,O.type),fn&&(Tt?t.texStorage2D(s.TEXTURE_2D,1,ft,De.width,De.height):t.texImage2D(s.TEXTURE_2D,0,ft,De.width,De.height,0,Xe,ut,null));else if(O.isDataTexture)if($t.length>0){Tt&&fn&&t.texStorage2D(s.TEXTURE_2D,Ke,ft,$t[0].width,$t[0].height);for(let xe=0,Ce=$t.length;xe0){const Je=Qp(Ze.width,Ze.height,O.format,O.type);for(const We of O.layerUpdates){const gt=Ze.data.subarray(We*Je/Ze.data.BYTES_PER_ELEMENT,(We+1)*Je/Ze.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,xe,0,0,We,Ze.width,Ze.height,1,Xe,gt)}O.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,xe,0,0,0,Ze.width,Ze.height,De.depth,Xe,Ze.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,xe,ft,Ze.width,Ze.height,De.depth,0,Ze.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Tt?K&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,xe,0,0,0,Ze.width,Ze.height,De.depth,Xe,ut,Ze.data):t.texImage3D(s.TEXTURE_2D_ARRAY,xe,ft,Ze.width,Ze.height,De.depth,0,Xe,ut,Ze.data)}else{Tt&&fn&&t.texStorage2D(s.TEXTURE_2D,Ke,ft,$t[0].width,$t[0].height);for(let xe=0,Ce=$t.length;xe0){const xe=Qp(De.width,De.height,O.format,O.type);for(const Ce of O.layerUpdates){const Je=De.data.subarray(Ce*xe/De.data.BYTES_PER_ELEMENT,(Ce+1)*xe/De.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Ce,De.width,De.height,1,Xe,ut,Je)}O.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,De.width,De.height,De.depth,Xe,ut,De.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,ft,De.width,De.height,De.depth,0,Xe,ut,De.data);else if(O.isData3DTexture)Tt?(fn&&t.texStorage3D(s.TEXTURE_3D,Ke,ft,De.width,De.height,De.depth),K&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,De.width,De.height,De.depth,Xe,ut,De.data)):t.texImage3D(s.TEXTURE_3D,0,ft,De.width,De.height,De.depth,0,Xe,ut,De.data);else if(O.isFramebufferTexture){if(fn)if(Tt)t.texStorage2D(s.TEXTURE_2D,Ke,ft,De.width,De.height);else{let xe=De.width,Ce=De.height;for(let Je=0;Je>=1,Ce>>=1}}else if($t.length>0){if(Tt&&fn){const xe=Ee($t[0]);t.texStorage2D(s.TEXTURE_2D,Ke,ft,xe.width,xe.height)}for(let xe=0,Ce=$t.length;xe0&&Ke++;const Ce=Ee(Xe[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,Ke,$t,Ce.width,Ce.height)}for(let Ce=0;Ce<6;Ce++)if(De){Tt?K&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Xe[Ce].width,Xe[Ce].height,ft,Ze,Xe[Ce].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,$t,Xe[Ce].width,Xe[Ce].height,0,ft,Ze,Xe[Ce].data);for(let Je=0;Je>me),ut=Math.max(1,O.height>>me);J===s.TEXTURE_3D||J===s.TEXTURE_2D_ARRAY?t.texImage3D(J,me,je,Xe,ut,O.depth,0,rt,Fe,null):t.texImage2D(J,me,je,Xe,ut,0,rt,Fe,null)}t.bindFramebuffer(s.FRAMEBUFFER,z),Re(O)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,_e,J,De.__webglTexture,0,we(O)):(J===s.TEXTURE_2D||J>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&J<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,_e,J,De.__webglTexture,me),t.bindFramebuffer(s.FRAMEBUFFER,null)}function He(z,O,te){if(s.bindRenderbuffer(s.RENDERBUFFER,z),O.depthBuffer){const _e=O.depthTexture,J=_e&&_e.isDepthTexture?_e.type:null,me=S(O.stencilBuffer,J),rt=O.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Fe=we(O);Re(O)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Fe,me,O.width,O.height):te?s.renderbufferStorageMultisample(s.RENDERBUFFER,Fe,me,O.width,O.height):s.renderbufferStorage(s.RENDERBUFFER,me,O.width,O.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,rt,s.RENDERBUFFER,z)}else{const _e=O.textures;for(let J=0;J<_e.length;J++){const me=_e[J],rt=r.convert(me.format,me.colorSpace),Fe=r.convert(me.type),je=E(me.internalFormat,rt,Fe,me.colorSpace),Et=we(O);te&&Re(O)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Et,je,O.width,O.height):Re(O)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Et,je,O.width,O.height):s.renderbufferStorage(s.RENDERBUFFER,je,O.width,O.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Ie(z,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,z),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const _e=n.get(O.depthTexture);_e.__renderTarget=O,(!_e.__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),pe(O.depthTexture,0);const J=_e.__webglTexture,me=we(O);if(O.depthTexture.format===Bl)Re(O)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,J,0,me):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,J,0);else if(O.depthTexture.format===kl)Re(O)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,J,0,me):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,J,0);else throw new Error("Unknown depthTexture format")}function kt(z){const O=n.get(z),te=z.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==z.depthTexture){const _e=z.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),_e){const J=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,_e.removeEventListener("dispose",J)};_e.addEventListener("dispose",J),O.__depthDisposeCallback=J}O.__boundDepthTexture=_e}if(z.depthTexture&&!O.__autoAllocateDepthBuffer){if(te)throw new Error("target.depthTexture not supported in Cube render targets");Ie(O.__webglFramebuffer,z)}else if(te){O.__webglDepthbuffer=[];for(let _e=0;_e<6;_e++)if(t.bindFramebuffer(s.FRAMEBUFFER,O.__webglFramebuffer[_e]),O.__webglDepthbuffer[_e]===void 0)O.__webglDepthbuffer[_e]=s.createRenderbuffer(),He(O.__webglDepthbuffer[_e],z,!1);else{const J=z.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,me=O.__webglDepthbuffer[_e];s.bindRenderbuffer(s.RENDERBUFFER,me),s.framebufferRenderbuffer(s.FRAMEBUFFER,J,s.RENDERBUFFER,me)}}else if(t.bindFramebuffer(s.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=s.createRenderbuffer(),He(O.__webglDepthbuffer,z,!1);else{const _e=z.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,J=O.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,J),s.framebufferRenderbuffer(s.FRAMEBUFFER,_e,s.RENDERBUFFER,J)}t.bindFramebuffer(s.FRAMEBUFFER,null)}function at(z,O,te){const _e=n.get(z);O!==void 0&&Ge(_e.__webglFramebuffer,z,z.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),te!==void 0&&kt(z)}function tn(z){const O=z.texture,te=n.get(z),_e=n.get(O);z.addEventListener("dispose",g);const J=z.textures,me=z.isWebGLCubeRenderTarget===!0,rt=J.length>1;if(rt||(_e.__webglTexture===void 0&&(_e.__webglTexture=s.createTexture()),_e.__version=O.version,o.memory.textures++),me){te.__webglFramebuffer=[];for(let Fe=0;Fe<6;Fe++)if(O.mipmaps&&O.mipmaps.length>0){te.__webglFramebuffer[Fe]=[];for(let je=0;je0){te.__webglFramebuffer=[];for(let Fe=0;Fe0&&Re(z)===!1){te.__webglMultisampledFramebuffer=s.createFramebuffer(),te.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,te.__webglMultisampledFramebuffer);for(let Fe=0;Fe0)for(let je=0;je0)for(let je=0;je0){if(Re(z)===!1){const O=z.textures,te=z.width,_e=z.height;let J=s.COLOR_BUFFER_BIT;const me=z.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,rt=n.get(z),Fe=O.length>1;if(Fe)for(let je=0;je0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Me(z){const O=o.render.frame;u.get(z)!==O&&(u.set(z,O),z.update())}function Ve(z,O){const te=z.colorSpace,_e=z.format,J=z.type;return z.isCompressedTexture===!0||z.isVideoTexture===!0||te!==Ni&&te!==Hs&&(en.getTransfer(te)===bn?(_e!==qi||J!==Ms)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",te)),O}function Ee(z){return typeof HTMLImageElement<"u"&&z instanceof HTMLImageElement?(c.width=z.naturalWidth||z.width,c.height=z.naturalHeight||z.height):typeof VideoFrame<"u"&&z instanceof VideoFrame?(c.width=z.displayWidth,c.height=z.displayHeight):(c.width=z.width,c.height=z.height),c}this.allocateTextureUnit=Y,this.resetTextureUnits=se,this.setTexture2D=pe,this.setTexture2DArray=ce,this.setTexture3D=ge,this.setTextureCube=fe,this.rebindTextures=at,this.setupRenderTarget=tn,this.updateRenderTargetMipmap=Zt,this.updateMultisampleRenderTarget=mn,this.setupDepthRenderbuffer=kt,this.setupFrameBufferTexture=Ge,this.useMultisampledRTT=Re}function rx(s,e){function t(n,i=Hs){let r;const o=en.getTransfer(i);if(n===Ms)return s.UNSIGNED_BYTE;if(n===Wf)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Xf)return s.UNSIGNED_SHORT_5_5_5_1;if(n===Sm)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===bm)return s.BYTE;if(n===Mm)return s.SHORT;if(n===Ul)return s.UNSIGNED_SHORT;if(n===Gf)return s.INT;if(n===js)return s.UNSIGNED_INT;if(n===nr)return s.FLOAT;if(n===Ql)return s.HALF_FLOAT;if(n===Tm)return s.ALPHA;if(n===wm)return s.RGB;if(n===qi)return s.RGBA;if(n===Em)return s.LUMINANCE;if(n===Am)return s.LUMINANCE_ALPHA;if(n===Bl)return s.DEPTH_COMPONENT;if(n===kl)return s.DEPTH_STENCIL;if(n===qf)return s.RED;if(n===du)return s.RED_INTEGER;if(n===Cm)return s.RG;if(n===$f)return s.RG_INTEGER;if(n===Yf)return s.RGBA_INTEGER;if(n===Uc||n===Fc||n===Bc||n===kc)if(o===bn)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Uc)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Fc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Bc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===kc)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Uc)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Fc)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Bc)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===kc)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===nf||n===rf||n===sf||n===of)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===nf)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===rf)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===sf)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===of)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===af||n===lf||n===cf)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===af||n===lf)return o===bn?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===cf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===uf||n===hf||n===ff||n===df||n===pf||n===mf||n===gf||n===_f||n===yf||n===vf||n===xf||n===bf||n===Mf||n===Sf)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===uf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===hf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ff)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===df)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===pf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===mf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===gf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===_f)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===yf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===vf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===xf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===bf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Mf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Sf)return o===bn?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===zc||n===Tf||n===wf)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===zc)return o===bn?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Tf)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===wf)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Rm||n===Ef||n===Af||n===Cf)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===zc)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ef)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Af)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Cf)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Fl?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}const uR=` void main() { gl_Position = vec4( position, 1.0 ); }`,hR=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`;class fR{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){const i=new On,r=e.properties.get(i);r.__webglTexture=t.texture,(t.depthNear!==n.depthNear||t.depthFar!==n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new ns({vertexShader:uR,fragmentShader:hR,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Qn(new tc(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class dR extends ws{constructor(e,t){super();const n=this;let i=null,r=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,d=null,p=null,v=null;const x=new fR,b=t.getContextAttributes();let y=null,w=null;const E=[],S=[],I=new Ae;let L=null;const g=new vi;g.viewport=new un;const F=new vi;F.viewport=new un;const R=[g,F],N=new qv;let G=null,se=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ye){let Le=E[ye];return Le===void 0&&(Le=new kh,E[ye]=Le),Le.getTargetRaySpace()},this.getControllerGrip=function(ye){let Le=E[ye];return Le===void 0&&(Le=new kh,E[ye]=Le),Le.getGripSpace()},this.getHand=function(ye){let Le=E[ye];return Le===void 0&&(Le=new kh,E[ye]=Le),Le.getHandSpace()};function Y(ye){const Le=S.indexOf(ye.inputSource);if(Le===-1)return;const Ge=E[Le];Ge!==void 0&&(Ge.update(ye.inputSource,ye.frame,c||o),Ge.dispatchEvent({type:ye.type,data:ye.inputSource}))}function he(){i.removeEventListener("select",Y),i.removeEventListener("selectstart",Y),i.removeEventListener("selectend",Y),i.removeEventListener("squeeze",Y),i.removeEventListener("squeezestart",Y),i.removeEventListener("squeezeend",Y),i.removeEventListener("end",he),i.removeEventListener("inputsourceschange",pe);for(let ye=0;ye=0&&(S[He]=null,E[He].disconnect(Ge))}for(let Le=0;Le=S.length){S.push(Ge),He=kt;break}else if(S[kt]===null){S[kt]=Ge,He=kt;break}if(He===-1)break}const Ie=E[He];Ie&&Ie.connect(Ge)}}const ce=new H,ge=new H;function fe(ye,Le,Ge){ce.setFromMatrixPosition(Le.matrixWorld),ge.setFromMatrixPosition(Ge.matrixWorld);const He=ce.distanceTo(ge),Ie=Le.projectionMatrix.elements,kt=Ge.projectionMatrix.elements,at=Ie[14]/(Ie[10]-1),tn=Ie[14]/(Ie[10]+1),Zt=(Ie[9]+1)/Ie[5],St=(Ie[9]-1)/Ie[5],q=(Ie[8]-1)/Ie[0],mn=(kt[8]+1)/kt[0],we=at*q,Re=at*mn,Me=He/(-q+mn),Ve=Me*-q;if(Le.matrixWorld.decompose(ye.position,ye.quaternion,ye.scale),ye.translateX(Ve),ye.translateZ(Me),ye.matrixWorld.compose(ye.position,ye.quaternion,ye.scale),ye.matrixWorldInverse.copy(ye.matrixWorld).invert(),Ie[10]===-1)ye.projectionMatrix.copy(Le.projectionMatrix),ye.projectionMatrixInverse.copy(Le.projectionMatrixInverse);else{const Ee=at+Me,z=tn+Me,O=we-Ve,te=Re+(He-Ve),_e=Zt*tn/z*Ee,J=St*tn/z*Ee;ye.projectionMatrix.makePerspective(O,te,_e,J,Ee,z),ye.projectionMatrixInverse.copy(ye.projectionMatrix).invert()}}function Ue(ye,Le){Le===null?ye.matrixWorld.copy(ye.matrix):ye.matrixWorld.multiplyMatrices(Le.matrixWorld,ye.matrix),ye.matrixWorldInverse.copy(ye.matrixWorld).invert()}this.updateCamera=function(ye){if(i===null)return;let Le=ye.near,Ge=ye.far;x.texture!==null&&(x.depthNear>0&&(Le=x.depthNear),x.depthFar>0&&(Ge=x.depthFar)),N.near=F.near=g.near=Le,N.far=F.far=g.far=Ge,(G!==N.near||se!==N.far)&&(i.updateRenderState({depthNear:N.near,depthFar:N.far}),G=N.near,se=N.far),g.layers.mask=ye.layers.mask|2,F.layers.mask=ye.layers.mask|4,N.layers.mask=g.layers.mask|F.layers.mask;const He=ye.parent,Ie=N.cameras;Ue(N,He);for(let kt=0;kt0&&(b.alphaTest.value=y.alphaTest);const w=e.get(y),E=w.envMap,S=w.envMapRotation;E&&(b.envMap.value=E,ma.copy(S),ma.x*=-1,ma.y*=-1,ma.z*=-1,E.isCubeTexture&&E.isRenderTargetTexture===!1&&(ma.y*=-1,ma.z*=-1),b.envMapRotation.value.setFromMatrix4(pR.makeRotationFromEuler(ma)),b.flipEnvMap.value=E.isCubeTexture&&E.isRenderTargetTexture===!1?-1:1,b.reflectivity.value=y.reflectivity,b.ior.value=y.ior,b.refractionRatio.value=y.refractionRatio),y.lightMap&&(b.lightMap.value=y.lightMap,b.lightMapIntensity.value=y.lightMapIntensity,t(y.lightMap,b.lightMapTransform)),y.aoMap&&(b.aoMap.value=y.aoMap,b.aoMapIntensity.value=y.aoMapIntensity,t(y.aoMap,b.aoMapTransform))}function o(b,y){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,y.map&&(b.map.value=y.map,t(y.map,b.mapTransform))}function a(b,y){b.dashSize.value=y.dashSize,b.totalSize.value=y.dashSize+y.gapSize,b.scale.value=y.scale}function l(b,y,w,E){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,b.size.value=y.size*w,b.scale.value=E*.5,y.map&&(b.map.value=y.map,t(y.map,b.uvTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,t(y.alphaMap,b.alphaMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest)}function c(b,y){b.diffuse.value.copy(y.color),b.opacity.value=y.opacity,b.rotation.value=y.rotation,y.map&&(b.map.value=y.map,t(y.map,b.mapTransform)),y.alphaMap&&(b.alphaMap.value=y.alphaMap,t(y.alphaMap,b.alphaMapTransform)),y.alphaTest>0&&(b.alphaTest.value=y.alphaTest)}function u(b,y){b.specular.value.copy(y.specular),b.shininess.value=Math.max(y.shininess,1e-4)}function f(b,y){y.gradientMap&&(b.gradientMap.value=y.gradientMap)}function d(b,y){b.metalness.value=y.metalness,y.metalnessMap&&(b.metalnessMap.value=y.metalnessMap,t(y.metalnessMap,b.metalnessMapTransform)),b.roughness.value=y.roughness,y.roughnessMap&&(b.roughnessMap.value=y.roughnessMap,t(y.roughnessMap,b.roughnessMapTransform)),y.envMap&&(b.envMapIntensity.value=y.envMapIntensity)}function p(b,y,w){b.ior.value=y.ior,y.sheen>0&&(b.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),b.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(b.sheenColorMap.value=y.sheenColorMap,t(y.sheenColorMap,b.sheenColorMapTransform)),y.sheenRoughnessMap&&(b.sheenRoughnessMap.value=y.sheenRoughnessMap,t(y.sheenRoughnessMap,b.sheenRoughnessMapTransform))),y.clearcoat>0&&(b.clearcoat.value=y.clearcoat,b.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(b.clearcoatMap.value=y.clearcoatMap,t(y.clearcoatMap,b.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(b.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,t(y.clearcoatRoughnessMap,b.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(b.clearcoatNormalMap.value=y.clearcoatNormalMap,t(y.clearcoatNormalMap,b.clearcoatNormalMapTransform),b.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===$i&&b.clearcoatNormalScale.value.negate())),y.dispersion>0&&(b.dispersion.value=y.dispersion),y.iridescence>0&&(b.iridescence.value=y.iridescence,b.iridescenceIOR.value=y.iridescenceIOR,b.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],b.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(b.iridescenceMap.value=y.iridescenceMap,t(y.iridescenceMap,b.iridescenceMapTransform)),y.iridescenceThicknessMap&&(b.iridescenceThicknessMap.value=y.iridescenceThicknessMap,t(y.iridescenceThicknessMap,b.iridescenceThicknessMapTransform))),y.transmission>0&&(b.transmission.value=y.transmission,b.transmissionSamplerMap.value=w.texture,b.transmissionSamplerSize.value.set(w.width,w.height),y.transmissionMap&&(b.transmissionMap.value=y.transmissionMap,t(y.transmissionMap,b.transmissionMapTransform)),b.thickness.value=y.thickness,y.thicknessMap&&(b.thicknessMap.value=y.thicknessMap,t(y.thicknessMap,b.thicknessMapTransform)),b.attenuationDistance.value=y.attenuationDistance,b.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(b.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(b.anisotropyMap.value=y.anisotropyMap,t(y.anisotropyMap,b.anisotropyMapTransform))),b.specularIntensity.value=y.specularIntensity,b.specularColor.value.copy(y.specularColor),y.specularColorMap&&(b.specularColorMap.value=y.specularColorMap,t(y.specularColorMap,b.specularColorMapTransform)),y.specularIntensityMap&&(b.specularIntensityMap.value=y.specularIntensityMap,t(y.specularIntensityMap,b.specularIntensityMapTransform))}function v(b,y){y.matcap&&(b.matcap.value=y.matcap)}function x(b,y){const w=e.get(y).light;b.referencePosition.value.setFromMatrixPosition(w.matrixWorld),b.nearDistance.value=w.shadow.camera.near,b.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function gR(s,e,t,n){let i={},r={},o=[];const a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function l(w,E){const S=E.program;n.uniformBlockBinding(w,S)}function c(w,E){let S=i[w.id];S===void 0&&(v(w),S=u(w),i[w.id]=S,w.addEventListener("dispose",b));const I=E.program;n.updateUBOMapping(w,I);const L=e.render.frame;r[w.id]!==L&&(d(w),r[w.id]=L)}function u(w){const E=f();w.__bindingPointIndex=E;const S=s.createBuffer(),I=w.__size,L=w.usage;return s.bindBuffer(s.UNIFORM_BUFFER,S),s.bufferData(s.UNIFORM_BUFFER,I,L),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,E,S),S}function f(){for(let w=0;w0&&(S+=I-L),w.__size=S,w.__cache={},this}function x(w){const E={boundary:0,storage:0};return typeof w=="number"||typeof w=="boolean"?(E.boundary=4,E.storage=4):w.isVector2?(E.boundary=8,E.storage=8):w.isVector3||w.isColor?(E.boundary=16,E.storage=12):w.isVector4?(E.boundary=16,E.storage=16):w.isMatrix3?(E.boundary=48,E.storage=48):w.isMatrix4?(E.boundary=64,E.storage=64):w.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",w),E}function b(w){const E=w.target;E.removeEventListener("dispose",b);const S=o.indexOf(E.__bindingPointIndex);o.splice(S,1),s.deleteBuffer(i[E.id]),delete i[E.id],delete r[E.id]}function y(){for(const w in i)s.deleteBuffer(i[w]);o=[],i={},r={}}return{bind:l,update:c,dispose:y}}class _R{constructor(e={}){const{canvas:t=Q0(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;const v=new Uint32Array(4),x=new Int32Array(4);let b=null,y=null;const w=[],E=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=qs,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const S=this;let I=!1;this._outputColorSpace=ci;let L=0,g=0,F=null,R=-1,N=null;const G=new un,se=new un;let Y=null;const he=new $e(0);let pe=0,ce=t.width,ge=t.height,fe=1,Ue=null,ne=null;const Ye=new un(0,0,ce,ge),mt=new un(0,0,ce,ge);let Bt=!1;const ye=new yu;let Le=!1,Ge=!1;const He=new _t,Ie=new _t,kt=new H,at=new un,tn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Zt=!1;function St(){return F===null?fe:1}let q=n;function mn(B,ee){return t.getContext(B,ee)}try{const B={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${zf}`),t.addEventListener("webglcontextlost",Ce,!1),t.addEventListener("webglcontextrestored",Je,!1),t.addEventListener("webglcontextcreationerror",We,!1),q===null){const ee="webgl2";if(q=mn(ee,B),q===null)throw mn(ee)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(B){throw console.error("THREE.WebGLRenderer: "+B.message),B}let we,Re,Me,Ve,Ee,z,O,te,_e,J,me,rt,Fe,je,Et,De,Xe,ut,ft,Ze,$t,Tt,fn,K;function Ke(){we=new C1(q),we.init(),Tt=new rx(q,we),Re=new b1(q,we,e,Tt),Me=new lR(q,we),Re.reverseDepthBuffer&&d&&Me.buffers.depth.setReversed(!0),Ve=new I1(q),Ee=new jC,z=new cR(q,we,Me,Ee,Re,Tt,Ve),O=new S1(S),te=new A1(S),_e=new Fw(q),fn=new v1(q,_e),J=new R1(q,_e,Ve,fn),me=new D1(q,J,_e,Ve),ft=new L1(q,Re,z),De=new M1(Ee),rt=new YC(S,O,te,we,Re,fn,De),Fe=new mR(S,Ee),je=new KC,Et=new iR(we),ut=new y1(S,O,te,Me,me,p,l),Xe=new oR(S,me,Re),K=new gR(q,Ve,Re,Me),Ze=new x1(q,we,Ve),$t=new P1(q,we,Ve),Ve.programs=rt.programs,S.capabilities=Re,S.extensions=we,S.properties=Ee,S.renderLists=je,S.shadowMap=Xe,S.state=Me,S.info=Ve}Ke();const xe=new dR(S,q);this.xr=xe,this.getContext=function(){return q},this.getContextAttributes=function(){return q.getContextAttributes()},this.forceContextLoss=function(){const B=we.get("WEBGL_lose_context");B&&B.loseContext()},this.forceContextRestore=function(){const B=we.get("WEBGL_lose_context");B&&B.restoreContext()},this.getPixelRatio=function(){return fe},this.setPixelRatio=function(B){B!==void 0&&(fe=B,this.setSize(ce,ge,!1))},this.getSize=function(B){return B.set(ce,ge)},this.setSize=function(B,ee,ae=!0){if(xe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ce=B,ge=ee,t.width=Math.floor(B*fe),t.height=Math.floor(ee*fe),ae===!0&&(t.style.width=B+"px",t.style.height=ee+"px"),this.setViewport(0,0,B,ee)},this.getDrawingBufferSize=function(B){return B.set(ce*fe,ge*fe).floor()},this.setDrawingBufferSize=function(B,ee,ae){ce=B,ge=ee,fe=ae,t.width=Math.floor(B*ae),t.height=Math.floor(ee*ae),this.setViewport(0,0,B,ee)},this.getCurrentViewport=function(B){return B.copy(G)},this.getViewport=function(B){return B.copy(Ye)},this.setViewport=function(B,ee,ae,ue){B.isVector4?Ye.set(B.x,B.y,B.z,B.w):Ye.set(B,ee,ae,ue),Me.viewport(G.copy(Ye).multiplyScalar(fe).round())},this.getScissor=function(B){return B.copy(mt)},this.setScissor=function(B,ee,ae,ue){B.isVector4?mt.set(B.x,B.y,B.z,B.w):mt.set(B,ee,ae,ue),Me.scissor(se.copy(mt).multiplyScalar(fe).round())},this.getScissorTest=function(){return Bt},this.setScissorTest=function(B){Me.setScissorTest(Bt=B)},this.setOpaqueSort=function(B){Ue=B},this.setTransparentSort=function(B){ne=B},this.getClearColor=function(B){return B.copy(ut.getClearColor())},this.setClearColor=function(){ut.setClearColor(...arguments)},this.getClearAlpha=function(){return ut.getClearAlpha()},this.setClearAlpha=function(){ut.setClearAlpha(...arguments)},this.clear=function(B=!0,ee=!0,ae=!0){let ue=0;if(B){let ie=!1;if(F!==null){const Oe=F.texture.format;ie=Oe===Yf||Oe===$f||Oe===du}if(ie){const Oe=F.texture.type,ke=Oe===Ms||Oe===js||Oe===Ul||Oe===Fl||Oe===Wf||Oe===Xf,it=ut.getClearColor(),nt=ut.getClearAlpha(),yt=it.r,vt=it.g,pt=it.b;ke?(v[0]=yt,v[1]=vt,v[2]=pt,v[3]=nt,q.clearBufferuiv(q.COLOR,0,v)):(x[0]=yt,x[1]=vt,x[2]=pt,x[3]=nt,q.clearBufferiv(q.COLOR,0,x))}else ue|=q.COLOR_BUFFER_BIT}ee&&(ue|=q.DEPTH_BUFFER_BIT),ae&&(ue|=q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),q.clear(ue)},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",Ce,!1),t.removeEventListener("webglcontextrestored",Je,!1),t.removeEventListener("webglcontextcreationerror",We,!1),ut.dispose(),je.dispose(),Et.dispose(),Ee.dispose(),O.dispose(),te.dispose(),me.dispose(),fn.dispose(),K.dispose(),rt.dispose(),xe.dispose(),xe.removeEventListener("sessionstart",Gr),xe.removeEventListener("sessionend",Wr),lr.stop()};function Ce(B){B.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),I=!0}function Je(){console.log("THREE.WebGLRenderer: Context Restored."),I=!1;const B=Ve.autoReset,ee=Xe.enabled,ae=Xe.autoUpdate,ue=Xe.needsUpdate,ie=Xe.type;Ke(),Ve.autoReset=B,Xe.enabled=ee,Xe.autoUpdate=ae,Xe.needsUpdate=ue,Xe.type=ie}function We(B){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",B.statusMessage)}function gt(B){const ee=B.target;ee.removeEventListener("dispose",gt),Xt(ee)}function Xt(B){zn(B),Ee.remove(B)}function zn(B){const ee=Ee.get(B).programs;ee!==void 0&&(ee.forEach(function(ae){rt.releaseProgram(ae)}),B.isShaderMaterial&&rt.releaseShaderCache(B))}this.renderBufferDirect=function(B,ee,ae,ue,ie,Oe){ee===null&&(ee=tn);const ke=ie.isMesh&&ie.matrixWorld.determinant()<0,it=rc(B,ee,ae,ue,ie);Me.setMaterial(ue,ke);let nt=ae.index,yt=1;if(ue.wireframe===!0){if(nt=J.getWireframeAttribute(ae),nt===void 0)return;yt=2}const vt=ae.drawRange,pt=ae.attributes.position;let qt=vt.start*yt,Kt=(vt.start+vt.count)*yt;Oe!==null&&(qt=Math.max(qt,Oe.start*yt),Kt=Math.min(Kt,(Oe.start+Oe.count)*yt)),nt!==null?(qt=Math.max(qt,0),Kt=Math.min(Kt,nt.count)):pt!=null&&(qt=Math.max(qt,0),Kt=Math.min(Kt,pt.count));const An=Kt-qt;if(An<0||An===1/0)return;fn.setup(ie,ue,it,ae,nt);let Gt,Nt=Ze;if(nt!==null&&(Gt=_e.get(nt),Nt=$t,Nt.setIndex(Gt)),ie.isMesh)ue.wireframe===!0?(Me.setLineWidth(ue.wireframeLinewidth*St()),Nt.setMode(q.LINES)):Nt.setMode(q.TRIANGLES);else if(ie.isLine){let dt=ue.linewidth;dt===void 0&&(dt=1),Me.setLineWidth(dt*St()),ie.isLineSegments?Nt.setMode(q.LINES):ie.isLineLoop?Nt.setMode(q.LINE_LOOP):Nt.setMode(q.LINE_STRIP)}else ie.isPoints?Nt.setMode(q.POINTS):ie.isSprite&&Nt.setMode(q.TRIANGLES);if(ie.isBatchedMesh)if(ie._multiDrawInstances!==null)Bh("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Nt.renderMultiDrawInstances(ie._multiDrawStarts,ie._multiDrawCounts,ie._multiDrawCount,ie._multiDrawInstances);else if(we.get("WEBGL_multi_draw"))Nt.renderMultiDraw(ie._multiDrawStarts,ie._multiDrawCounts,ie._multiDrawCount);else{const dt=ie._multiDrawStarts,Vn=ie._multiDrawCounts,nn=ie._multiDrawCount,Cn=nt?_e.get(nt).bytesPerElement:1,Un=Ee.get(ue).currentProgram.getUniforms();for(let Rn=0;Rn{function Oe(){if(ue.forEach(function(ke){Ee.get(ke).currentProgram.isReady()&&ue.delete(ke)}),ue.size===0){ie(B);return}setTimeout(Oe,10)}we.get("KHR_parallel_shader_compile")!==null?Oe():setTimeout(Oe,10)})};let Yn=null;function pi(B){Yn&&Yn(B)}function Gr(){lr.stop()}function Wr(){lr.start()}const lr=new Qv;lr.setAnimationLoop(pi),typeof self<"u"&&lr.setContext(self),this.setAnimationLoop=function(B){Yn=B,xe.setAnimationLoop(B),B===null?lr.stop():lr.start()},xe.addEventListener("sessionstart",Gr),xe.addEventListener("sessionend",Wr),this.render=function(B,ee){if(ee!==void 0&&ee.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(I===!0)return;if(B.matrixWorldAutoUpdate===!0&&B.updateMatrixWorld(),ee.parent===null&&ee.matrixWorldAutoUpdate===!0&&ee.updateMatrixWorld(),xe.enabled===!0&&xe.isPresenting===!0&&(xe.cameraAutoUpdate===!0&&xe.updateCamera(ee),ee=xe.getCamera()),B.isScene===!0&&B.onBeforeRender(S,B,ee,F),y=Et.get(B,E.length),y.init(ee),E.push(y),Ie.multiplyMatrices(ee.projectionMatrix,ee.matrixWorldInverse),ye.setFromProjectionMatrix(Ie),Ge=this.localClippingEnabled,Le=De.init(this.clippingPlanes,Ge),b=je.get(B,w.length),b.init(),w.push(b),xe.enabled===!0&&xe.isPresenting===!0){const Oe=S.xr.getDepthSensingMesh();Oe!==null&&ss(Oe,ee,-1/0,S.sortObjects)}ss(B,ee,0,S.sortObjects),b.finish(),S.sortObjects===!0&&b.sort(Ue,ne),Zt=xe.enabled===!1||xe.isPresenting===!1||xe.hasDepthSensing()===!1,Zt&&ut.addToRenderList(b,B),this.info.render.frame++,Le===!0&&De.beginShadows();const ae=y.state.shadowsArray;Xe.render(ae,B,ee),Le===!0&&De.endShadows(),this.info.autoReset===!0&&this.info.reset();const ue=b.opaque,ie=b.transmissive;if(y.setupLights(),ee.isArrayCamera){const Oe=ee.cameras;if(ie.length>0)for(let ke=0,it=Oe.length;ke0&&Qs(ue,ie,B,ee),Zt&&ut.render(B),ja(b,B,ee);F!==null&&g===0&&(z.updateMultisampleRenderTarget(F),z.updateRenderTargetMipmap(F)),B.isScene===!0&&B.onAfterRender(S,B,ee),fn.resetDefaultState(),R=-1,N=null,E.pop(),E.length>0?(y=E[E.length-1],Le===!0&&De.setGlobalState(S.clippingPlanes,y.state.camera)):y=null,w.pop(),w.length>0?b=w[w.length-1]:b=null};function ss(B,ee,ae,ue){if(B.visible===!1)return;if(B.layers.test(ee.layers)){if(B.isGroup)ae=B.renderOrder;else if(B.isLOD)B.autoUpdate===!0&&B.update(ee);else if(B.isLight)y.pushLight(B),B.castShadow&&y.pushShadow(B);else if(B.isSprite){if(!B.frustumCulled||ye.intersectsSprite(B)){ue&&at.setFromMatrixPosition(B.matrixWorld).applyMatrix4(Ie);const ke=me.update(B),it=B.material;it.visible&&b.push(B,ke,it,ae,at.z,null)}}else if((B.isMesh||B.isLine||B.isPoints)&&(!B.frustumCulled||ye.intersectsObject(B))){const ke=me.update(B),it=B.material;if(ue&&(B.boundingSphere!==void 0?(B.boundingSphere===null&&B.computeBoundingSphere(),at.copy(B.boundingSphere.center)):(ke.boundingSphere===null&&ke.computeBoundingSphere(),at.copy(ke.boundingSphere.center)),at.applyMatrix4(B.matrixWorld).applyMatrix4(Ie)),Array.isArray(it)){const nt=ke.groups;for(let yt=0,vt=nt.length;yt0&&cr(ie,ee,ae),Oe.length>0&&cr(Oe,ee,ae),ke.length>0&&cr(ke,ee,ae),Me.buffers.depth.setTest(!0),Me.buffers.depth.setMask(!0),Me.buffers.color.setMask(!0),Me.setPolygonOffset(!1)}function Qs(B,ee,ae,ue){if((ae.isScene===!0?ae.overrideMaterial:null)!==null)return;y.state.transmissionRenderTarget[ue.id]===void 0&&(y.state.transmissionRenderTarget[ue.id]=new Ss(1,1,{generateMipmaps:!0,type:we.has("EXT_color_buffer_half_float")||we.has("EXT_color_buffer_float")?Ql:Ms,minFilter:Fr,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:en.workingColorSpace}));const Oe=y.state.transmissionRenderTarget[ue.id],ke=ue.viewport||G;Oe.setSize(ke.z*S.transmissionResolutionScale,ke.w*S.transmissionResolutionScale);const it=S.getRenderTarget();S.setRenderTarget(Oe),S.getClearColor(he),pe=S.getClearAlpha(),pe<1&&S.setClearColor(16777215,.5),S.clear(),Zt&&ut.render(ae);const nt=S.toneMapping;S.toneMapping=qs;const yt=ue.viewport;if(ue.viewport!==void 0&&(ue.viewport=void 0),y.setupLightsView(ue),Le===!0&&De.setGlobalState(S.clippingPlanes,ue),cr(B,ae,ue),z.updateMultisampleRenderTarget(Oe),z.updateRenderTargetMipmap(Oe),we.has("WEBGL_multisampled_render_to_texture")===!1){let vt=!1;for(let pt=0,qt=ee.length;pt0),pt=!!ae.morphAttributes.position,qt=!!ae.morphAttributes.normal,Kt=!!ae.morphAttributes.color;let An=qs;ue.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(An=S.toneMapping);const Gt=ae.morphAttributes.position||ae.morphAttributes.normal||ae.morphAttributes.color,Nt=Gt!==void 0?Gt.length:0,dt=Ee.get(ue),Vn=y.state.lights;if(Le===!0&&(Ge===!0||B!==N)){const Pn=B===N&&ue.id===R;De.setState(ue,B,Pn)}let nn=!1;ue.version===dt.__version?(dt.needsLights&&dt.lightsStateVersion!==Vn.state.version||dt.outputColorSpace!==it||ie.isBatchedMesh&&dt.batching===!1||!ie.isBatchedMesh&&dt.batching===!0||ie.isBatchedMesh&&dt.batchingColor===!0&&ie.colorTexture===null||ie.isBatchedMesh&&dt.batchingColor===!1&&ie.colorTexture!==null||ie.isInstancedMesh&&dt.instancing===!1||!ie.isInstancedMesh&&dt.instancing===!0||ie.isSkinnedMesh&&dt.skinning===!1||!ie.isSkinnedMesh&&dt.skinning===!0||ie.isInstancedMesh&&dt.instancingColor===!0&&ie.instanceColor===null||ie.isInstancedMesh&&dt.instancingColor===!1&&ie.instanceColor!==null||ie.isInstancedMesh&&dt.instancingMorph===!0&&ie.morphTexture===null||ie.isInstancedMesh&&dt.instancingMorph===!1&&ie.morphTexture!==null||dt.envMap!==nt||ue.fog===!0&&dt.fog!==Oe||dt.numClippingPlanes!==void 0&&(dt.numClippingPlanes!==De.numPlanes||dt.numIntersection!==De.numIntersection)||dt.vertexAlphas!==yt||dt.vertexTangents!==vt||dt.morphTargets!==pt||dt.morphNormals!==qt||dt.morphColors!==Kt||dt.toneMapping!==An||dt.morphTargetsCount!==Nt)&&(nn=!0):(nn=!0,dt.__version=ue.version);let Cn=dt.currentProgram;nn===!0&&(Cn=eo(ue,ee,ie));let Un=!1,Rn=!1,jn=!1;const gn=Cn.getUniforms(),mi=dt.uniforms;if(Me.useProgram(Cn.program)&&(Un=!0,Rn=!0,jn=!0),ue.id!==R&&(R=ue.id,Rn=!0),Un||N!==B){Me.buffers.depth.getReversed()?(He.copy(B.projectionMatrix),aS(He),lS(He),gn.setValue(q,"projectionMatrix",He)):gn.setValue(q,"projectionMatrix",B.projectionMatrix),gn.setValue(q,"viewMatrix",B.matrixWorldInverse);const Ln=gn.map.cameraPosition;Ln!==void 0&&Ln.setValue(q,kt.setFromMatrixPosition(B.matrixWorld)),Re.logarithmicDepthBuffer&&gn.setValue(q,"logDepthBufFC",2/(Math.log(B.far+1)/Math.LN2)),(ue.isMeshPhongMaterial||ue.isMeshToonMaterial||ue.isMeshLambertMaterial||ue.isMeshBasicMaterial||ue.isMeshStandardMaterial||ue.isShaderMaterial)&&gn.setValue(q,"isOrthographic",B.isOrthographicCamera===!0),N!==B&&(N=B,Rn=!0,jn=!0)}if(ie.isSkinnedMesh){gn.setOptional(q,ie,"bindMatrix"),gn.setOptional(q,ie,"bindMatrixInverse");const Pn=ie.skeleton;Pn&&(Pn.boneTexture===null&&Pn.computeBoneTexture(),gn.setValue(q,"boneTexture",Pn.boneTexture,z))}ie.isBatchedMesh&&(gn.setOptional(q,ie,"batchingTexture"),gn.setValue(q,"batchingTexture",ie._matricesTexture,z),gn.setOptional(q,ie,"batchingIdTexture"),gn.setValue(q,"batchingIdTexture",ie._indirectTexture,z),gn.setOptional(q,ie,"batchingColorTexture"),ie._colorsTexture!==null&&gn.setValue(q,"batchingColorTexture",ie._colorsTexture,z));const rn=ae.morphAttributes;if((rn.position!==void 0||rn.normal!==void 0||rn.color!==void 0)&&ft.update(ie,ae,Cn),(Rn||dt.receiveShadow!==ie.receiveShadow)&&(dt.receiveShadow=ie.receiveShadow,gn.setValue(q,"receiveShadow",ie.receiveShadow)),ue.isMeshGouraudMaterial&&ue.envMap!==null&&(mi.envMap.value=nt,mi.flipEnvMap.value=nt.isCubeTexture&&nt.isRenderTargetTexture===!1?-1:1),ue.isMeshStandardMaterial&&ue.envMap===null&&ee.environment!==null&&(mi.envMapIntensity.value=ee.environmentIntensity),Rn&&(gn.setValue(q,"toneMappingExposure",S.toneMappingExposure),dt.needsLights&&Ui(mi,jn),Oe&&ue.fog===!0&&Fe.refreshFogUniforms(mi,Oe),Fe.refreshMaterialUniforms(mi,ue,fe,ge,y.state.transmissionRenderTarget[B.id]),zh.upload(q,to(dt),mi,z)),ue.isShaderMaterial&&ue.uniformsNeedUpdate===!0&&(zh.upload(q,to(dt),mi,z),ue.uniformsNeedUpdate=!1),ue.isSpriteMaterial&&gn.setValue(q,"center",ie.center),gn.setValue(q,"modelViewMatrix",ie.modelViewMatrix),gn.setValue(q,"normalMatrix",ie.normalMatrix),gn.setValue(q,"modelMatrix",ie.matrixWorld),ue.isShaderMaterial||ue.isRawShaderMaterial){const Pn=ue.uniformsGroups;for(let Ln=0,Ar=Pn.length;Ln0&&z.useMultisampledRTT(B)===!1?ie=Ee.get(B).__webglMultisampledFramebuffer:Array.isArray(vt)?ie=vt[ae]:ie=vt,G.copy(B.viewport),se.copy(B.scissor),Y=B.scissorTest}else G.copy(Ye).multiplyScalar(fe).floor(),se.copy(mt).multiplyScalar(fe).floor(),Y=Bt;if(ae!==0&&(ie=ri),Me.bindFramebuffer(q.FRAMEBUFFER,ie)&&ue&&Me.drawBuffers(B,ie),Me.viewport(G),Me.scissor(se),Me.setScissorTest(Y),Oe){const nt=Ee.get(B.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_CUBE_MAP_POSITIVE_X+ee,nt.__webglTexture,ae)}else if(ke){const nt=Ee.get(B.texture),yt=ee;q.framebufferTextureLayer(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,nt.__webglTexture,ae,yt)}else if(B!==null&&ae!==0){const nt=Ee.get(B.texture);q.framebufferTexture2D(q.FRAMEBUFFER,q.COLOR_ATTACHMENT0,q.TEXTURE_2D,nt.__webglTexture,ae)}R=-1},this.readRenderTargetPixels=function(B,ee,ae,ue,ie,Oe,ke){if(!(B&&B.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let it=Ee.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&ke!==void 0&&(it=it[ke]),it){Me.bindFramebuffer(q.FRAMEBUFFER,it);try{const nt=B.texture,yt=nt.format,vt=nt.type;if(!Re.textureFormatReadable(yt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Re.textureTypeReadable(vt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ee>=0&&ee<=B.width-ue&&ae>=0&&ae<=B.height-ie&&q.readPixels(ee,ae,ue,ie,Tt.convert(yt),Tt.convert(vt),Oe)}finally{const nt=F!==null?Ee.get(F).__webglFramebuffer:null;Me.bindFramebuffer(q.FRAMEBUFFER,nt)}}},this.readRenderTargetPixelsAsync=async function(B,ee,ae,ue,ie,Oe,ke){if(!(B&&B.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let it=Ee.get(B).__webglFramebuffer;if(B.isWebGLCubeRenderTarget&&ke!==void 0&&(it=it[ke]),it)if(ee>=0&&ee<=B.width-ue&&ae>=0&&ae<=B.height-ie){Me.bindFramebuffer(q.FRAMEBUFFER,it);const nt=B.texture,yt=nt.format,vt=nt.type;if(!Re.textureFormatReadable(yt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Re.textureTypeReadable(vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const pt=q.createBuffer();q.bindBuffer(q.PIXEL_PACK_BUFFER,pt),q.bufferData(q.PIXEL_PACK_BUFFER,Oe.byteLength,q.STREAM_READ),q.readPixels(ee,ae,ue,ie,Tt.convert(yt),Tt.convert(vt),0);const qt=F!==null?Ee.get(F).__webglFramebuffer:null;Me.bindFramebuffer(q.FRAMEBUFFER,qt);const Kt=q.fenceSync(q.SYNC_GPU_COMMANDS_COMPLETE,0);return q.flush(),await oS(q,Kt,4),q.bindBuffer(q.PIXEL_PACK_BUFFER,pt),q.getBufferSubData(q.PIXEL_PACK_BUFFER,0,Oe),q.deleteBuffer(pt),q.deleteSync(Kt),Oe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(B,ee=null,ae=0){const ue=Math.pow(2,-ae),ie=Math.floor(B.image.width*ue),Oe=Math.floor(B.image.height*ue),ke=ee!==null?ee.x:0,it=ee!==null?ee.y:0;z.setTexture2D(B,0),q.copyTexSubImage2D(q.TEXTURE_2D,ae,0,0,ke,it,ie,Oe),Me.unbindTexture()};const si=q.createFramebuffer(),Hn=q.createFramebuffer();this.copyTextureToTexture=function(B,ee,ae=null,ue=null,ie=0,Oe=null){Oe===null&&(ie!==0?(Bh("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Oe=ie,ie=0):Oe=0);let ke,it,nt,yt,vt,pt,qt,Kt,An;const Gt=B.isCompressedTexture?B.mipmaps[Oe]:B.image;if(ae!==null)ke=ae.max.x-ae.min.x,it=ae.max.y-ae.min.y,nt=ae.isBox3?ae.max.z-ae.min.z:1,yt=ae.min.x,vt=ae.min.y,pt=ae.isBox3?ae.min.z:0;else{const rn=Math.pow(2,-ie);ke=Math.floor(Gt.width*rn),it=Math.floor(Gt.height*rn),B.isDataArrayTexture?nt=Gt.depth:B.isData3DTexture?nt=Math.floor(Gt.depth*rn):nt=1,yt=0,vt=0,pt=0}ue!==null?(qt=ue.x,Kt=ue.y,An=ue.z):(qt=0,Kt=0,An=0);const Nt=Tt.convert(ee.format),dt=Tt.convert(ee.type);let Vn;ee.isData3DTexture?(z.setTexture3D(ee,0),Vn=q.TEXTURE_3D):ee.isDataArrayTexture||ee.isCompressedArrayTexture?(z.setTexture2DArray(ee,0),Vn=q.TEXTURE_2D_ARRAY):(z.setTexture2D(ee,0),Vn=q.TEXTURE_2D),q.pixelStorei(q.UNPACK_FLIP_Y_WEBGL,ee.flipY),q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ee.premultiplyAlpha),q.pixelStorei(q.UNPACK_ALIGNMENT,ee.unpackAlignment);const nn=q.getParameter(q.UNPACK_ROW_LENGTH),Cn=q.getParameter(q.UNPACK_IMAGE_HEIGHT),Un=q.getParameter(q.UNPACK_SKIP_PIXELS),Rn=q.getParameter(q.UNPACK_SKIP_ROWS),jn=q.getParameter(q.UNPACK_SKIP_IMAGES);q.pixelStorei(q.UNPACK_ROW_LENGTH,Gt.width),q.pixelStorei(q.UNPACK_IMAGE_HEIGHT,Gt.height),q.pixelStorei(q.UNPACK_SKIP_PIXELS,yt),q.pixelStorei(q.UNPACK_SKIP_ROWS,vt),q.pixelStorei(q.UNPACK_SKIP_IMAGES,pt);const gn=B.isDataArrayTexture||B.isData3DTexture,mi=ee.isDataArrayTexture||ee.isData3DTexture;if(B.isDepthTexture){const rn=Ee.get(B),Pn=Ee.get(ee),Ln=Ee.get(rn.__renderTarget),Ar=Ee.get(Pn.__renderTarget);Me.bindFramebuffer(q.READ_FRAMEBUFFER,Ln.__webglFramebuffer),Me.bindFramebuffer(q.DRAW_FRAMEBUFFER,Ar.__webglFramebuffer);for(let ur=0;urMath.PI&&(n-=Qi),i<-Math.PI?i+=Qi:i>Math.PI&&(i-=Qi),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(li.setFromSpherical(this._spherical),li.applyQuaternion(this._quatInverse),t.copy(this.target).add(li),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=li.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new H(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new H(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=li.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Oh.origin.copy(this.object.position),Oh.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Oh.direction))Ap||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ap||this._lastTargetPosition.distanceToSquared(this.target)>Ap?(this.dispatchEvent(Dy),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Qi/60*this.autoRotateSpeed*e:Qi/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){li.setFromMatrixColumn(t,0),li.multiplyScalar(-e),this._panOffset.add(li)}_panUp(e,t){this.screenSpacePanning===!0?li.setFromMatrixColumn(t,1):(li.setFromMatrixColumn(t,0),li.crossVectors(this.object.up,li)),li.multiplyScalar(e),this._panOffset.add(li)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;li.copy(i).sub(this.target);let r=li.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qi*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qi*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Qi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Qi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Qi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Qi*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qi*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qi*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=2.0 are supported."));return}const c=new hP(r,{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 u=0;u=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function DR(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const Jt={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_DISPERSION:"KHR_materials_dispersion",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=Jt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}}class YR{constructor(e){this.parser=e,this.name=Jt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class jR{constructor(e){this.parser=e,this.name=Jt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,o.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ZR{constructor(e){this.name=Jt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,u=i.count,f=i.byteStride,d=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,f,d,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(u*f);return o.decodeGltfBuffer(new Uint8Array(p),u,f,d,i.mode,i.filter),p})})}else return null}}class KR{constructor(e){this.name=Jt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==Ur.TRIANGLES&&c.mode!==Ur.TRIANGLE_STRIP&&c.mode!==Ur.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const u=c.pop(),f=u.isGroup?u.children:[u],d=c[0].count,p=[];for(const v of f){const x=new _t,b=new H,y=new xi,w=new H(1,1,1),E=new km(v.geometry,v.material,d);for(let S=0;S0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const uP=new _t;class hP{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new DR,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new Fv(this.options.manager):this.textureLoader=new Xv(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new zr(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return ga(r,a,i),Fs(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())r(u,a.children[c])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&b.setY(R,L[g*l+1]),l>=3&&b.setZ(R,L[g*l+2]),l>=4&&b.setW(R,L[g*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}b.normalized=v}return b})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const d=(r.samplers||{})[o.sampler]||{};return u.magFilter=Fy[d.magFilter]||qn,u.minFilter=Fy[d.minFilter]||Fr,u.wrapS=By[d.wrapS]||Co,u.wrapT=By[d.wrapT]||Co,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==ui&&u.minFilter!==qn,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(f){c=!0;const d=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(d),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(f){return new Promise(function(d,p){let v=d;t.isImageBitmapLoader===!0&&(v=function(x){const b=new On(x);b.needsUpdate=!0,d(b)}),t.load(To.resolveURL(f,r.path),v,void 0,p)})}).then(function(f){return c===!0&&a.revokeObjectURL(l),Fs(f,o),f.userData.mimeType=o.mimeType||cP(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[Jt.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[Jt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[Jt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new id,hi.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new Oi,hi.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return Mu}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[Jt.KHR_MATERIALS_UNLIT]){const f=i[Jt.KHR_MATERIALS_UNLIT];o=f.getMaterialType(),c.push(f.extendParams(a,r,t))}else{const f=r.pbrMetallicRoughness||{};if(a.color=new $e(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const d=f.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],Ni),a.opacity=d[3]}f.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",f.baseColorTexture,ci)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Qr);const u=r.alphaMode||Rp.OPAQUE;if(u===Rp.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Rp.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==xr&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Ae(1,1),r.normalTexture.scale!==void 0)){const f=r.normalTexture.scale;a.normalScale.set(f,f)}if(r.occlusionTexture!==void 0&&o!==xr&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==xr){const f=r.emissiveFactor;a.emissive=new $e().setRGB(f[0],f[1],f[2],Ni)}return r.emissiveTexture!==void 0&&o!==xr&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,ci)),Promise.all(c).then(function(){const f=new o(a);return r.name&&(f.name=r.name),Fs(f,r),t.associations.set(f,{materials:e}),r.extensions&&ga(i,f,r),f})}createUniqueName(e){const t=ln.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[Jt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return ky(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&aP(y,r),y.name=t.createUniqueName(r.name||"mesh_"+e),Fs(y,r),b.extensions&&ga(i,y,b),t.assignFinalMaterial(y),f.push(y)}for(let p=0,v=f.length;p1?u=new Gs:c.length===1?u=c[0]:u=new an,u!==c[0])for(let f=0,d=c.length;f{const f=new Map;for(const[d,p]of i.associations)(d instanceof hi||d instanceof On)&&f.set(d,p);return u.traverse(d=>{const p=i.associations.get(d);p!=null&&f.set(d,p)}),f};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,l=[];go[r.path]===go.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(a);let c;switch(go[r.path]){case go.weights:c=za;break;case go.rotation:c=Ha;break;case go.translation:case go.scale:c=Va;break;default:switch(n.itemSize){case 1:c=za;break;case 2:case 3:default:c=Va;break}break}const u=i.interpolation!==void 0?rP[i.interpolation]:Hl,f=this._getArrayFromAccessor(n);for(let d=0,p=l.length;d=0&&M0&&m-1 in h}function R(h,m){return h.nodeName&&h.nodeName.toLowerCase()===m.toLowerCase()}var N=n.pop,G=n.sort,se=n.splice,Y="[\\x20\\t\\r\\n\\f]",he=new RegExp("^"+Y+"+|((?:^|[^\\\\])(?:\\\\.)*)"+Y+"+$","g");g.contains=function(h,m){var M=m&&m.parentNode;return h===M||!!(M&&M.nodeType===1&&(h.contains?h.contains(M):h.compareDocumentPosition&&h.compareDocumentPosition(M)&16))};var pe=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function ce(h,m){return m?h==="\0"?"�":h.slice(0,-1)+"\\"+h.charCodeAt(h.length-1).toString(16)+" ":"\\"+h}g.escapeSelector=function(h){return(h+"").replace(pe,ce)};var ge=y,fe=a;(function(){var h,m,M,T,C,P=fe,U,X,W,Z,ve,Te=g.expando,le=0,Ne=0,bt=Xo(),Ot=Xo(),Rt=Xo(),oi=Xo(),Gn=function(V,j){return V===j&&(C=!0),0},Rr="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",Pr="(?:\\\\[\\da-fA-F]{1,6}"+Y+"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",Yt="\\["+Y+"*("+Pr+")(?:"+Y+"*([*^$|!~]?=)"+Y+`*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(`+Pr+"))|)"+Y+"*\\]",Es=":("+Pr+`)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|`+Yt+")*)|.*)\\)|)",Qt=new RegExp(Y+"+","g"),Dn=new RegExp("^"+Y+"*,"+Y+"*"),Go=new RegExp("^"+Y+"*([>+~]|"+Y+")"+Y+"*"),cs=new RegExp(Y+"|>"),gi=new RegExp(Es),Wo=new RegExp("^"+Pr+"$"),Bi={ID:new RegExp("^#("+Pr+")"),CLASS:new RegExp("^\\.("+Pr+")"),TAG:new RegExp("^("+Pr+"|[*])"),ATTR:new RegExp("^"+Yt),PSEUDO:new RegExp("^"+Es),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+Y+"*(even|odd|(([+-]|)(\\d*)n|)"+Y+"*(?:([+-]|)"+Y+"*(\\d+)|))"+Y+"*\\)|)","i"),bool:new RegExp("^(?:"+Rr+")$","i"),needsContext:new RegExp("^"+Y+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+Y+"*((?:-\\d)?\\d*)"+Y+"*\\)|)(?=[^-]|$)","i")},us=/^(?:input|select|textarea|button)$/i,hs=/^h\d$/i,Zi=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,uc=/[+~]/,Xr=new RegExp("\\\\[\\da-fA-F]{1,6}"+Y+"?|\\\\([^\\r\\n\\f])","g"),qr=function(V,j){var oe="0x"+V.slice(1)-65536;return j||(oe<0?String.fromCharCode(oe+65536):String.fromCharCode(oe>>10|55296,oe&1023|56320))},wd=function(){$r()},Ed=jo(function(V){return V.disabled===!0&&R(V,"fieldset")},{dir:"parentNode",next:"legend"});function hr(){try{return U.activeElement}catch{}}try{P.apply(n=r.call(ge.childNodes),ge.childNodes),n[ge.childNodes.length].nodeType}catch{P={apply:function(j,oe){fe.apply(j,r.call(oe))},call:function(j){fe.apply(j,r.call(arguments,1))}}}function hn(V,j,oe,de){var Se,Be,et,lt,Qe,zt,xt,wt=j&&j.ownerDocument,Ct=j?j.nodeType:9;if(oe=oe||[],typeof V!="string"||!V||Ct!==1&&Ct!==9&&Ct!==11)return oe;if(!de&&($r(j),j=j||U,W)){if(Ct!==11&&(Qe=Zi.exec(V)))if(Se=Qe[1]){if(Ct===9)if(et=j.getElementById(Se)){if(et.id===Se)return P.call(oe,et),oe}else return oe;else if(wt&&(et=wt.getElementById(Se))&&hn.contains(j,et)&&et.id===Se)return P.call(oe,et),oe}else{if(Qe[2])return P.apply(oe,j.getElementsByTagName(V)),oe;if((Se=Qe[3])&&j.getElementsByClassName)return P.apply(oe,j.getElementsByClassName(Se)),oe}if(!oi[V+" "]&&(!Z||!Z.test(V))){if(xt=V,wt=j,Ct===1&&(cs.test(V)||Go.test(V))){for(wt=uc.test(V)&&hc(j.parentNode)||j,(wt!=j||!v.scope)&&((lt=j.getAttribute("id"))?lt=g.escapeSelector(lt):j.setAttribute("id",lt=Te)),zt=$o(V),Be=zt.length;Be--;)zt[Be]=(lt?"#"+lt:":scope")+" "+Yo(zt[Be]);xt=zt.join(",")}try{return P.apply(oe,wt.querySelectorAll(xt)),oe}catch{oi(V,!0)}finally{lt===Te&&j.removeAttribute("id")}}}return dc(V.replace(he,"$1"),j,oe,de)}function Xo(){var V=[];function j(oe,de){return V.push(oe+" ")>m.cacheLength&&delete j[V.shift()],j[oe+" "]=de}return j}function Ki(V){return V[Te]=!0,V}function so(V){var j=U.createElement("fieldset");try{return!!V(j)}catch{return!1}finally{j.parentNode&&j.parentNode.removeChild(j),j=null}}function Ad(V){return function(j){return R(j,"input")&&j.type===V}}function Ou(V){return function(j){return(R(j,"input")||R(j,"button"))&&j.type===V}}function qo(V){return function(j){return"form"in j?j.parentNode&&j.disabled===!1?"label"in j?"label"in j.parentNode?j.parentNode.disabled===V:j.disabled===V:j.isDisabled===V||j.isDisabled!==!V&&Ed(j)===V:j.disabled===V:"label"in j?j.disabled===V:!1}}function As(V){return Ki(function(j){return j=+j,Ki(function(oe,de){for(var Se,Be=V([],oe.length,j),et=Be.length;et--;)oe[Se=Be[et]]&&(oe[Se]=!(de[Se]=oe[Se]))})})}function hc(V){return V&&typeof V.getElementsByTagName<"u"&&V}function $r(V){var j,oe=V?V.ownerDocument||V:ge;return oe==U||oe.nodeType!==9||!oe.documentElement||(U=oe,X=U.documentElement,W=!g.isXMLDoc(U),ve=X.matches||X.webkitMatchesSelector||X.msMatchesSelector,X.msMatchesSelector&&ge!=U&&(j=U.defaultView)&&j.top!==j&&j.addEventListener("unload",wd),v.getById=so(function(de){return X.appendChild(de).id=g.expando,!U.getElementsByName||!U.getElementsByName(g.expando).length}),v.disconnectedMatch=so(function(de){return ve.call(de,"*")}),v.scope=so(function(){return U.querySelectorAll(":scope")}),v.cssHas=so(function(){try{return U.querySelector(":has(*,:jqfake)"),!1}catch{return!0}}),v.getById?(m.filter.ID=function(de){var Se=de.replace(Xr,qr);return function(Be){return Be.getAttribute("id")===Se}},m.find.ID=function(de,Se){if(typeof Se.getElementById<"u"&&W){var Be=Se.getElementById(de);return Be?[Be]:[]}}):(m.filter.ID=function(de){var Se=de.replace(Xr,qr);return function(Be){var et=typeof Be.getAttributeNode<"u"&&Be.getAttributeNode("id");return et&&et.value===Se}},m.find.ID=function(de,Se){if(typeof Se.getElementById<"u"&&W){var Be,et,lt,Qe=Se.getElementById(de);if(Qe){if(Be=Qe.getAttributeNode("id"),Be&&Be.value===de)return[Qe];for(lt=Se.getElementsByName(de),et=0;Qe=lt[et++];)if(Be=Qe.getAttributeNode("id"),Be&&Be.value===de)return[Qe]}return[]}}),m.find.TAG=function(de,Se){return typeof Se.getElementsByTagName<"u"?Se.getElementsByTagName(de):Se.querySelectorAll(de)},m.find.CLASS=function(de,Se){if(typeof Se.getElementsByClassName<"u"&&W)return Se.getElementsByClassName(de)},Z=[],so(function(de){var Se;X.appendChild(de).innerHTML="",de.querySelectorAll("[selected]").length||Z.push("\\["+Y+"*(?:value|"+Rr+")"),de.querySelectorAll("[id~="+Te+"-]").length||Z.push("~="),de.querySelectorAll("a#"+Te+"+*").length||Z.push(".#.+[+~]"),de.querySelectorAll(":checked").length||Z.push(":checked"),Se=U.createElement("input"),Se.setAttribute("type","hidden"),de.appendChild(Se).setAttribute("name","D"),X.appendChild(de).disabled=!0,de.querySelectorAll(":disabled").length!==2&&Z.push(":enabled",":disabled"),Se=U.createElement("input"),Se.setAttribute("name",""),de.appendChild(Se),de.querySelectorAll("[name='']").length||Z.push("\\["+Y+"*name"+Y+"*="+Y+`*(?:''|"")`)}),v.cssHas||Z.push(":has"),Z=Z.length&&new RegExp(Z.join("|")),Gn=function(de,Se){if(de===Se)return C=!0,0;var Be=!de.compareDocumentPosition-!Se.compareDocumentPosition;return Be||(Be=(de.ownerDocument||de)==(Se.ownerDocument||Se)?de.compareDocumentPosition(Se):1,Be&1||!v.sortDetached&&Se.compareDocumentPosition(de)===Be?de===U||de.ownerDocument==ge&&hn.contains(ge,de)?-1:Se===U||Se.ownerDocument==ge&&hn.contains(ge,Se)?1:T?l.call(T,de)-l.call(T,Se):0:Be&4?-1:1)}),U}hn.matches=function(V,j){return hn(V,null,null,j)},hn.matchesSelector=function(V,j){if($r(V),W&&!oi[j+" "]&&(!Z||!Z.test(j)))try{var oe=ve.call(V,j);if(oe||v.disconnectedMatch||V.document&&V.document.nodeType!==11)return oe}catch{oi(j,!0)}return hn(j,U,null,[V]).length>0},hn.contains=function(V,j){return(V.ownerDocument||V)!=U&&$r(V),g.contains(V,j)},hn.attr=function(V,j){(V.ownerDocument||V)!=U&&$r(V);var oe=m.attrHandle[j.toLowerCase()],de=oe&&f.call(m.attrHandle,j.toLowerCase())?oe(V,j,!W):void 0;return de!==void 0?de:V.getAttribute(j)},hn.error=function(V){throw new Error("Syntax error, unrecognized expression: "+V)},g.uniqueSort=function(V){var j,oe=[],de=0,Se=0;if(C=!v.sortStable,T=!v.sortStable&&r.call(V,0),G.call(V,Gn),C){for(;j=V[Se++];)j===V[Se]&&(de=oe.push(Se));for(;de--;)se.call(V,oe[de],1)}return T=null,V},g.fn.uniqueSort=function(){return this.pushStack(g.uniqueSort(r.apply(this)))},m=g.expr={cacheLength:50,createPseudo:Ki,match:Bi,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(V){return V[1]=V[1].replace(Xr,qr),V[3]=(V[3]||V[4]||V[5]||"").replace(Xr,qr),V[2]==="~="&&(V[3]=" "+V[3]+" "),V.slice(0,4)},CHILD:function(V){return V[1]=V[1].toLowerCase(),V[1].slice(0,3)==="nth"?(V[3]||hn.error(V[0]),V[4]=+(V[4]?V[5]+(V[6]||1):2*(V[3]==="even"||V[3]==="odd")),V[5]=+(V[7]+V[8]||V[3]==="odd")):V[3]&&hn.error(V[0]),V},PSEUDO:function(V){var j,oe=!V[6]&&V[2];return Bi.CHILD.test(V[0])?null:(V[3]?V[2]=V[4]||V[5]||"":oe&&gi.test(oe)&&(j=$o(oe,!0))&&(j=oe.indexOf(")",oe.length-j)-oe.length)&&(V[0]=V[0].slice(0,j),V[2]=oe.slice(0,j)),V.slice(0,3))}},filter:{TAG:function(V){var j=V.replace(Xr,qr).toLowerCase();return V==="*"?function(){return!0}:function(oe){return R(oe,j)}},CLASS:function(V){var j=bt[V+" "];return j||(j=new RegExp("(^|"+Y+")"+V+"("+Y+"|$)"))&&bt(V,function(oe){return j.test(typeof oe.className=="string"&&oe.className||typeof oe.getAttribute<"u"&&oe.getAttribute("class")||"")})},ATTR:function(V,j,oe){return function(de){var Se=hn.attr(de,V);return Se==null?j==="!=":j?(Se+="",j==="="?Se===oe:j==="!="?Se!==oe:j==="^="?oe&&Se.indexOf(oe)===0:j==="*="?oe&&Se.indexOf(oe)>-1:j==="$="?oe&&Se.slice(-oe.length)===oe:j==="~="?(" "+Se.replace(Qt," ")+" ").indexOf(oe)>-1:j==="|="?Se===oe||Se.slice(0,oe.length+1)===oe+"-":!1):!0}},CHILD:function(V,j,oe,de,Se){var Be=V.slice(0,3)!=="nth",et=V.slice(-4)!=="last",lt=j==="of-type";return de===1&&Se===0?function(Qe){return!!Qe.parentNode}:function(Qe,zt,xt){var wt,Ct,ct,_n,Ei,ai=Be!==et?"nextSibling":"previousSibling",ki=Qe.parentNode,fr=lt&&Qe.nodeName.toLowerCase(),Cs=!xt&&!lt,Mi=!1;if(ki){if(Be){for(;ai;){for(ct=Qe;ct=ct[ai];)if(lt?R(ct,fr):ct.nodeType===1)return!1;Ei=ai=V==="only"&&!Ei&&"nextSibling"}return!0}if(Ei=[et?ki.firstChild:ki.lastChild],et&&Cs){for(Ct=ki[Te]||(ki[Te]={}),wt=Ct[V]||[],_n=wt[0]===le&&wt[1],Mi=_n&&wt[2],ct=_n&&ki.childNodes[_n];ct=++_n&&ct&&ct[ai]||(Mi=_n=0)||Ei.pop();)if(ct.nodeType===1&&++Mi&&ct===Qe){Ct[V]=[le,_n,Mi];break}}else if(Cs&&(Ct=Qe[Te]||(Qe[Te]={}),wt=Ct[V]||[],_n=wt[0]===le&&wt[1],Mi=_n),Mi===!1)for(;(ct=++_n&&ct&&ct[ai]||(Mi=_n=0)||Ei.pop())&&!((lt?R(ct,fr):ct.nodeType===1)&&++Mi&&(Cs&&(Ct=ct[Te]||(ct[Te]={}),Ct[V]=[le,Mi]),ct===Qe)););return Mi-=Se,Mi===de||Mi%de===0&&Mi/de>=0}}},PSEUDO:function(V,j){var oe,de=m.pseudos[V]||m.setFilters[V.toLowerCase()]||hn.error("unsupported pseudo: "+V);return de[Te]?de(j):de.length>1?(oe=[V,V,"",j],m.setFilters.hasOwnProperty(V.toLowerCase())?Ki(function(Se,Be){for(var et,lt=de(Se,j),Qe=lt.length;Qe--;)et=l.call(Se,lt[Qe]),Se[et]=!(Be[et]=lt[Qe])}):function(Se){return de(Se,0,oe)}):de}},pseudos:{not:Ki(function(V){var j=[],oe=[],de=fc(V.replace(he,"$1"));return de[Te]?Ki(function(Se,Be,et,lt){for(var Qe,zt=de(Se,null,lt,[]),xt=Se.length;xt--;)(Qe=zt[xt])&&(Se[xt]=!(Be[xt]=Qe))}):function(Se,Be,et){return j[0]=Se,de(j,null,et,oe),j[0]=null,!oe.pop()}}),has:Ki(function(V){return function(j){return hn(V,j).length>0}}),contains:Ki(function(V){return V=V.replace(Xr,qr),function(j){return(j.textContent||g.text(j)).indexOf(V)>-1}}),lang:Ki(function(V){return Wo.test(V||"")||hn.error("unsupported lang: "+V),V=V.replace(Xr,qr).toLowerCase(),function(j){var oe;do if(oe=W?j.lang:j.getAttribute("xml:lang")||j.getAttribute("lang"))return oe=oe.toLowerCase(),oe===V||oe.indexOf(V+"-")===0;while((j=j.parentNode)&&j.nodeType===1);return!1}}),target:function(V){var j=e.location&&e.location.hash;return j&&j.slice(1)===V.id},root:function(V){return V===X},focus:function(V){return V===hr()&&U.hasFocus()&&!!(V.type||V.href||~V.tabIndex)},enabled:qo(!1),disabled:qo(!0),checked:function(V){return R(V,"input")&&!!V.checked||R(V,"option")&&!!V.selected},selected:function(V){return V.parentNode&&V.parentNode.selectedIndex,V.selected===!0},empty:function(V){for(V=V.firstChild;V;V=V.nextSibling)if(V.nodeType<6)return!1;return!0},parent:function(V){return!m.pseudos.empty(V)},header:function(V){return hs.test(V.nodeName)},input:function(V){return us.test(V.nodeName)},button:function(V){return R(V,"input")&&V.type==="button"||R(V,"button")},text:function(V){var j;return R(V,"input")&&V.type==="text"&&((j=V.getAttribute("type"))==null||j.toLowerCase()==="text")},first:As(function(){return[0]}),last:As(function(V,j){return[j-1]}),eq:As(function(V,j,oe){return[oe<0?oe+j:oe]}),even:As(function(V,j){for(var oe=0;oej?de=j:de=oe;--de>=0;)V.push(de);return V}),gt:As(function(V,j,oe){for(var de=oe<0?oe+j:oe;++de1?function(j,oe,de){for(var Se=V.length;Se--;)if(!V[Se](j,oe,de))return!1;return!0}:V[0]}function il(V,j,oe){for(var de=0,Se=j.length;de-1&&(et[xt]=!(lt[xt]=Ct))}}else ct=Zo(ct===lt?ct.splice(ai,ct.length):ct),Se?Se(null,lt,ct,zt):P.apply(lt,ct)})}function wi(V){for(var j,oe,de,Se=V.length,Be=m.relative[V[0].type],et=Be||m.relative[" "],lt=Be?1:0,Qe=jo(function(wt){return wt===j},et,!0),zt=jo(function(wt){return l.call(j,wt)>-1},et,!0),xt=[function(wt,Ct,ct){var _n=!Be&&(ct||Ct!=M)||((j=Ct).nodeType?Qe(wt,Ct,ct):zt(wt,Ct,ct));return j=null,_n}];lt1&&nl(xt),lt>1&&Yo(V.slice(0,lt-1).concat({value:V[lt-2].type===" "?"*":""})).replace(he,"$1"),oe,lt0,de=V.length>0,Se=function(Be,et,lt,Qe,zt){var xt,wt,Ct,ct=0,_n="0",Ei=Be&&[],ai=[],ki=M,fr=Be||de&&m.find.TAG("*",zt),Cs=le+=ki==null?1:Math.random()||.1,Mi=fr.length;for(zt&&(M=et==U||et||zt);_n!==Mi&&(xt=fr[_n])!=null;_n++){if(de&&xt){for(wt=0,!et&&xt.ownerDocument!=U&&($r(xt),lt=!W);Ct=V[wt++];)if(Ct(xt,et||U,lt)){P.call(Qe,xt);break}zt&&(le=Cs)}oe&&((xt=!Ct&&xt)&&ct--,Be&&Ei.push(xt))}if(ct+=_n,oe&&_n!==ct){for(wt=0;Ct=j[wt++];)Ct(Ei,ai,et,lt);if(Be){if(ct>0)for(;_n--;)Ei[_n]||ai[_n]||(ai[_n]=N.call(Qe));ai=Zo(ai)}P.apply(Qe,ai),zt&&!Be&&ai.length>0&&ct+j.length>1&&g.uniqueSort(Qe)}return zt&&(le=Cs,M=ki),Ei};return oe?Ki(Se):Se}function fc(V,j){var oe,de=[],Se=[],Be=Rt[V+" "];if(!Be){for(j||(j=$o(V)),oe=j.length;oe--;)Be=wi(j[oe]),Be[Te]?de.push(Be):Se.push(Be);Be=Rt(V,Cd(Se,de)),Be.selector=V}return Be}function dc(V,j,oe,de){var Se,Be,et,lt,Qe,zt=typeof V=="function"&&V,xt=!de&&$o(V=zt.selector||V);if(oe=oe||[],xt.length===1){if(Be=xt[0]=xt[0].slice(0),Be.length>2&&(et=Be[0]).type==="ID"&&j.nodeType===9&&W&&m.relative[Be[1].type]){if(j=(m.find.ID(et.matches[0].replace(Xr,qr),j)||[])[0],j)zt&&(j=j.parentNode);else return oe;V=V.slice(Be.shift().value.length)}for(Se=Bi.needsContext.test(V)?0:Be.length;Se--&&(et=Be[Se],!m.relative[lt=et.type]);)if((Qe=m.find[lt])&&(de=Qe(et.matches[0].replace(Xr,qr),uc.test(Be[0].type)&&hc(j.parentNode)||j))){if(Be.splice(Se,1),V=de.length&&Yo(Be),!V)return P.apply(oe,de),oe;break}}return(zt||fc(V,xt))(de,j,!W,oe,!j||uc.test(V)&&hc(j.parentNode)||j),oe}v.sortStable=Te.split("").sort(Gn).join("")===Te,$r(),v.sortDetached=so(function(V){return V.compareDocumentPosition(U.createElement("fieldset"))&1}),g.find=hn,g.expr[":"]=g.expr.pseudos,g.unique=g.uniqueSort,hn.compile=fc,hn.select=dc,hn.setDocument=$r,hn.tokenize=$o,hn.escape=g.escapeSelector,hn.getText=g.text,hn.isXML=g.isXMLDoc,hn.selectors=g.expr,hn.support=g.support,hn.uniqueSort=g.uniqueSort})();var Ue=function(h,m,M){for(var T=[],C=M!==void 0;(h=h[m])&&h.nodeType!==9;)if(h.nodeType===1){if(C&&g(h).is(M))break;T.push(h)}return T},ne=function(h,m){for(var M=[];h;h=h.nextSibling)h.nodeType===1&&h!==m&&M.push(h);return M},Ye=g.expr.match.needsContext,mt=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function Bt(h,m,M){return x(m)?g.grep(h,function(T,C){return!!m.call(T,C,T)!==M}):m.nodeType?g.grep(h,function(T){return T===m!==M}):typeof m!="string"?g.grep(h,function(T){return l.call(m,T)>-1!==M}):g.filter(m,h,M)}g.filter=function(h,m,M){var T=m[0];return M&&(h=":not("+h+")"),m.length===1&&T.nodeType===1?g.find.matchesSelector(T,h)?[T]:[]:g.find.matches(h,g.grep(m,function(C){return C.nodeType===1}))},g.fn.extend({find:function(h){var m,M,T=this.length,C=this;if(typeof h!="string")return this.pushStack(g(h).filter(function(){for(m=0;m1?g.uniqueSort(M):M},filter:function(h){return this.pushStack(Bt(this,h||[],!1))},not:function(h){return this.pushStack(Bt(this,h||[],!0))},is:function(h){return!!Bt(this,typeof h=="string"&&Ye.test(h)?g(h):h||[],!1).length}});var ye,Le=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Ge=g.fn.init=function(h,m,M){var T,C;if(!h)return this;if(M=M||ye,typeof h=="string")if(h[0]==="<"&&h[h.length-1]===">"&&h.length>=3?T=[null,h,null]:T=Le.exec(h),T&&(T[1]||!m))if(T[1]){if(m=m instanceof g?m[0]:m,g.merge(this,g.parseHTML(T[1],m&&m.nodeType?m.ownerDocument||m:y,!0)),mt.test(T[1])&&g.isPlainObject(m))for(T in m)x(this[T])?this[T](m[T]):this.attr(T,m[T]);return this}else return C=y.getElementById(T[2]),C&&(this[0]=C,this.length=1),this;else return!m||m.jquery?(m||M).find(h):this.constructor(m).find(h);else{if(h.nodeType)return this[0]=h,this.length=1,this;if(x(h))return M.ready!==void 0?M.ready(h):h(g)}return g.makeArray(h,this)};Ge.prototype=g.fn,ye=g(y);var He=/^(?:parents|prev(?:Until|All))/,Ie={children:!0,contents:!0,next:!0,prev:!0};g.fn.extend({has:function(h){var m=g(h,this),M=m.length;return this.filter(function(){for(var T=0;T-1:M.nodeType===1&&g.find.matchesSelector(M,h))){P.push(M);break}}return this.pushStack(P.length>1?g.uniqueSort(P):P)},index:function(h){return h?typeof h=="string"?l.call(g(h),this[0]):l.call(this,h.jquery?h[0]:h):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(h,m){return this.pushStack(g.uniqueSort(g.merge(this.get(),g(h,m))))},addBack:function(h){return this.add(h==null?this.prevObject:this.prevObject.filter(h))}});function kt(h,m){for(;(h=h[m])&&h.nodeType!==1;);return h}g.each({parent:function(h){var m=h.parentNode;return m&&m.nodeType!==11?m:null},parents:function(h){return Ue(h,"parentNode")},parentsUntil:function(h,m,M){return Ue(h,"parentNode",M)},next:function(h){return kt(h,"nextSibling")},prev:function(h){return kt(h,"previousSibling")},nextAll:function(h){return Ue(h,"nextSibling")},prevAll:function(h){return Ue(h,"previousSibling")},nextUntil:function(h,m,M){return Ue(h,"nextSibling",M)},prevUntil:function(h,m,M){return Ue(h,"previousSibling",M)},siblings:function(h){return ne((h.parentNode||{}).firstChild,h)},children:function(h){return ne(h.firstChild)},contents:function(h){return h.contentDocument!=null&&i(h.contentDocument)?h.contentDocument:(R(h,"template")&&(h=h.content||h),g.merge([],h.childNodes))}},function(h,m){g.fn[h]=function(M,T){var C=g.map(this,m,M);return h.slice(-5)!=="Until"&&(T=M),T&&typeof T=="string"&&(C=g.filter(T,C)),this.length>1&&(Ie[h]||g.uniqueSort(C),He.test(h)&&C.reverse()),this.pushStack(C)}});var at=/[^\x20\t\r\n\f]+/g;function tn(h){var m={};return g.each(h.match(at)||[],function(M,T){m[T]=!0}),m}g.Callbacks=function(h){h=typeof h=="string"?tn(h):g.extend({},h);var m,M,T,C,P=[],U=[],X=-1,W=function(){for(C=C||h.once,T=m=!0;U.length;X=-1)for(M=U.shift();++X-1;)P.splice(le,1),le<=X&&X--}),this},has:function(ve){return ve?g.inArray(ve,P)>-1:P.length>0},empty:function(){return P&&(P=[]),this},disable:function(){return C=U=[],P=M="",this},disabled:function(){return!P},lock:function(){return C=U=[],!M&&!m&&(P=M=""),this},locked:function(){return!!C},fireWith:function(ve,Te){return C||(Te=Te||[],Te=[ve,Te.slice?Te.slice():Te],U.push(Te),m||W()),this},fire:function(){return Z.fireWith(this,arguments),this},fired:function(){return!!T}};return Z};function Zt(h){return h}function St(h){throw h}function q(h,m,M,T){var C;try{h&&x(C=h.promise)?C.call(h).done(m).fail(M):h&&x(C=h.then)?C.call(h,m,M):m.apply(void 0,[h].slice(T))}catch(P){M.apply(void 0,[P])}}g.extend({Deferred:function(h){var m=[["notify","progress",g.Callbacks("memory"),g.Callbacks("memory"),2],["resolve","done",g.Callbacks("once memory"),g.Callbacks("once memory"),0,"resolved"],["reject","fail",g.Callbacks("once memory"),g.Callbacks("once memory"),1,"rejected"]],M="pending",T={state:function(){return M},always:function(){return C.done(arguments).fail(arguments),this},catch:function(P){return T.then(null,P)},pipe:function(){var P=arguments;return g.Deferred(function(U){g.each(m,function(X,W){var Z=x(P[W[4]])&&P[W[4]];C[W[1]](function(){var ve=Z&&Z.apply(this,arguments);ve&&x(ve.promise)?ve.promise().progress(U.notify).done(U.resolve).fail(U.reject):U[W[0]+"With"](this,Z?[ve]:arguments)})}),P=null}).promise()},then:function(P,U,X){var W=0;function Z(ve,Te,le,Ne){return function(){var bt=this,Ot=arguments,Rt=function(){var Gn,Rr;if(!(ve=W&&(le!==St&&(bt=void 0,Ot=[Gn]),Te.rejectWith(bt,Ot))}};ve?oi():(g.Deferred.getErrorHook?oi.error=g.Deferred.getErrorHook():g.Deferred.getStackHook&&(oi.error=g.Deferred.getStackHook()),e.setTimeout(oi))}}return g.Deferred(function(ve){m[0][3].add(Z(0,ve,x(X)?X:Zt,ve.notifyWith)),m[1][3].add(Z(0,ve,x(P)?P:Zt)),m[2][3].add(Z(0,ve,x(U)?U:St))}).promise()},promise:function(P){return P!=null?g.extend(P,T):T}},C={};return g.each(m,function(P,U){var X=U[2],W=U[5];T[U[1]]=X.add,W&&X.add(function(){M=W},m[3-P][2].disable,m[3-P][3].disable,m[0][2].lock,m[0][3].lock),X.add(U[3].fire),C[U[0]]=function(){return C[U[0]+"With"](this===C?void 0:this,arguments),this},C[U[0]+"With"]=X.fireWith}),T.promise(C),h&&h.call(C,C),C},when:function(h){var m=arguments.length,M=m,T=Array(M),C=r.call(arguments),P=g.Deferred(),U=function(X){return function(W){T[X]=this,C[X]=arguments.length>1?r.call(arguments):W,--m||P.resolveWith(T,C)}};if(m<=1&&(q(h,P.done(U(M)).resolve,P.reject,!m),P.state()==="pending"||x(C[M]&&C[M].then)))return P.then();for(;M--;)q(C[M],U(M),P.reject);return P.promise()}});var mn=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;g.Deferred.exceptionHook=function(h,m){e.console&&e.console.warn&&h&&mn.test(h.name)&&e.console.warn("jQuery.Deferred exception: "+h.message,h.stack,m)},g.readyException=function(h){e.setTimeout(function(){throw h})};var we=g.Deferred();g.fn.ready=function(h){return we.then(h).catch(function(m){g.readyException(m)}),this},g.extend({isReady:!1,readyWait:1,ready:function(h){(h===!0?--g.readyWait:g.isReady)||(g.isReady=!0,!(h!==!0&&--g.readyWait>0)&&we.resolveWith(y,[g]))}}),g.ready.then=we.then;function Re(){y.removeEventListener("DOMContentLoaded",Re),e.removeEventListener("load",Re),g.ready()}y.readyState==="complete"||y.readyState!=="loading"&&!y.documentElement.doScroll?e.setTimeout(g.ready):(y.addEventListener("DOMContentLoaded",Re),e.addEventListener("load",Re));var Me=function(h,m,M,T,C,P,U){var X=0,W=h.length,Z=M==null;if(S(M)==="object"){C=!0;for(X in M)Me(h,m,X,M[X],!0,P,U)}else if(T!==void 0&&(C=!0,x(T)||(U=!0),Z&&(U?(m.call(h,T),m=null):(Z=m,m=function(ve,Te,le){return Z.call(g(ve),le)})),m))for(;X1,null,!0)},removeData:function(h){return this.each(function(){me.remove(this,h)})}}),g.extend({queue:function(h,m,M){var T;if(h)return m=(m||"fx")+"queue",T=J.get(h,m),M&&(!T||Array.isArray(M)?T=J.access(h,m,g.makeArray(M)):T.push(M)),T||[]},dequeue:function(h,m){m=m||"fx";var M=g.queue(h,m),T=M.length,C=M.shift(),P=g._queueHooks(h,m),U=function(){g.dequeue(h,m)};C==="inprogress"&&(C=M.shift(),T--),C&&(m==="fx"&&M.unshift("inprogress"),delete P.stop,C.call(h,U,P)),!T&&P&&P.empty.fire()},_queueHooks:function(h,m){var M=m+"queueHooks";return J.get(h,M)||J.access(h,M,{empty:g.Callbacks("once memory").add(function(){J.remove(h,[m+"queue",M])})})}}),g.fn.extend({queue:function(h,m){var M=2;return typeof h!="string"&&(m=h,h="fx",M--),arguments.length\x20\t\r\n\f]*)/i,We=/^$|^module$|\/(?:java|ecma)script/i;(function(){var h=y.createDocumentFragment(),m=h.appendChild(y.createElement("div")),M=y.createElement("input");M.setAttribute("type","radio"),M.setAttribute("checked","checked"),M.setAttribute("name","t"),m.appendChild(M),v.checkClone=m.cloneNode(!0).cloneNode(!0).lastChild.checked,m.innerHTML="",v.noCloneChecked=!!m.cloneNode(!0).lastChild.defaultValue,m.innerHTML="",v.option=!!m.lastChild})();var gt={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};gt.tbody=gt.tfoot=gt.colgroup=gt.caption=gt.thead,gt.th=gt.td,v.option||(gt.optgroup=gt.option=[1,""]);function Xt(h,m){var M;return typeof h.getElementsByTagName<"u"?M=h.getElementsByTagName(m||"*"):typeof h.querySelectorAll<"u"?M=h.querySelectorAll(m||"*"):M=[],m===void 0||m&&R(h,m)?g.merge([h],M):M}function zn(h,m){for(var M=0,T=h.length;M-1){C&&C.push(P);continue}if(Z=Ze(P),U=Xt(Te.appendChild(P),"script"),Z&&zn(U),M)for(ve=0;P=U[ve++];)We.test(P.type||"")&&M.push(P)}return Te}var pi=/^([^.]*)(?:\.(.+)|)/;function Gr(){return!0}function Wr(){return!1}function lr(h,m,M,T,C,P){var U,X;if(typeof m=="object"){typeof M!="string"&&(T=T||M,M=void 0);for(X in m)lr(h,X,M,T,m[X],P);return h}if(T==null&&C==null?(C=M,T=M=void 0):C==null&&(typeof M=="string"?(C=T,T=void 0):(C=T,T=M,M=void 0)),C===!1)C=Wr;else if(!C)return h;return P===1&&(U=C,C=function(W){return g().off(W),U.apply(this,arguments)},C.guid=U.guid||(U.guid=g.guid++)),h.each(function(){g.event.add(this,m,C,T,M)})}g.event={global:{},add:function(h,m,M,T,C){var P,U,X,W,Z,ve,Te,le,Ne,bt,Ot,Rt=J.get(h);if(te(h))for(M.handler&&(P=M,M=P.handler,C=P.selector),C&&g.find.matchesSelector(ft,C),M.guid||(M.guid=g.guid++),(W=Rt.events)||(W=Rt.events=Object.create(null)),(U=Rt.handle)||(U=Rt.handle=function(oi){return typeof g<"u"&&g.event.triggered!==oi.type?g.event.dispatch.apply(h,arguments):void 0}),m=(m||"").match(at)||[""],Z=m.length;Z--;)X=pi.exec(m[Z])||[],Ne=Ot=X[1],bt=(X[2]||"").split(".").sort(),Ne&&(Te=g.event.special[Ne]||{},Ne=(C?Te.delegateType:Te.bindType)||Ne,Te=g.event.special[Ne]||{},ve=g.extend({type:Ne,origType:Ot,data:T,handler:M,guid:M.guid,selector:C,needsContext:C&&g.expr.match.needsContext.test(C),namespace:bt.join(".")},P),(le=W[Ne])||(le=W[Ne]=[],le.delegateCount=0,(!Te.setup||Te.setup.call(h,T,bt,U)===!1)&&h.addEventListener&&h.addEventListener(Ne,U)),Te.add&&(Te.add.call(h,ve),ve.handler.guid||(ve.handler.guid=M.guid)),C?le.splice(le.delegateCount++,0,ve):le.push(ve),g.event.global[Ne]=!0)},remove:function(h,m,M,T,C){var P,U,X,W,Z,ve,Te,le,Ne,bt,Ot,Rt=J.hasData(h)&&J.get(h);if(!(!Rt||!(W=Rt.events))){for(m=(m||"").match(at)||[""],Z=m.length;Z--;){if(X=pi.exec(m[Z])||[],Ne=Ot=X[1],bt=(X[2]||"").split(".").sort(),!Ne){for(Ne in W)g.event.remove(h,Ne+m[Z],M,T,!0);continue}for(Te=g.event.special[Ne]||{},Ne=(T?Te.delegateType:Te.bindType)||Ne,le=W[Ne]||[],X=X[2]&&new RegExp("(^|\\.)"+bt.join("\\.(?:.*\\.|)")+"(\\.|$)"),U=P=le.length;P--;)ve=le[P],(C||Ot===ve.origType)&&(!M||M.guid===ve.guid)&&(!X||X.test(ve.namespace))&&(!T||T===ve.selector||T==="**"&&ve.selector)&&(le.splice(P,1),ve.selector&&le.delegateCount--,Te.remove&&Te.remove.call(h,ve));U&&!le.length&&((!Te.teardown||Te.teardown.call(h,bt,Rt.handle)===!1)&&g.removeEvent(h,Ne,Rt.handle),delete W[Ne])}g.isEmptyObject(W)&&J.remove(h,"handle events")}},dispatch:function(h){var m,M,T,C,P,U,X=new Array(arguments.length),W=g.event.fix(h),Z=(J.get(this,"events")||Object.create(null))[W.type]||[],ve=g.event.special[W.type]||{};for(X[0]=W,m=1;m=1)){for(;Z!==this;Z=Z.parentNode||this)if(Z.nodeType===1&&!(h.type==="click"&&Z.disabled===!0)){for(P=[],U={},M=0;M-1:g.find(C,this,null,[Z]).length),U[C]&&P.push(T);P.length&&X.push({elem:Z,handlers:P})}}return Z=this,W\s*$/g;function os(h,m){return R(h,"table")&&R(m.nodeType!==11?m:m.firstChild,"tr")&&g(h).children("tbody")[0]||h}function eo(h){return h.type=(h.getAttribute("type")!==null)+"/"+h.type,h}function to(h){return(h.type||"").slice(0,5)==="true/"?h.type=h.type.slice(5):h.removeAttribute("type"),h}function Uo(h,m){var M,T,C,P,U,X,W;if(m.nodeType===1){if(J.hasData(h)&&(P=J.get(h),W=P.events,W)){J.remove(m,"handle events");for(C in W)for(M=0,T=W[C].length;M1&&typeof Ne=="string"&&!v.checkClone&&Qs.test(Ne))return h.each(function(Ot){var Rt=h.eq(Ot);bt&&(m[0]=Ne.call(this,Ot,Rt.html())),Ui(Rt,m,M,T)});if(Te&&(C=Yn(m,h[0].ownerDocument,!1,h,T),P=C.firstChild,C.childNodes.length===1&&(C=P),P||T)){for(U=g.map(Xt(C,"script"),eo),X=U.length;ve0&&zn(U,!W&&Xt(h,"script")),X},cleanData:function(h){for(var m,M,T,C=g.event.special,P=0;(M=h[P])!==void 0;P++)if(te(M)){if(m=M[J.expando]){if(m.events)for(T in m.events)C[T]?g.event.remove(M,T):g.removeEvent(M,T,m.handle);M[J.expando]=void 0}M[me.expando]&&(M[me.expando]=void 0)}}}),g.fn.extend({detach:function(h){return ei(this,h,!0)},remove:function(h){return ei(this,h)},text:function(h){return Me(this,function(m){return m===void 0?g.text(this):this.empty().each(function(){(this.nodeType===1||this.nodeType===11||this.nodeType===9)&&(this.textContent=m)})},null,h,arguments.length)},append:function(){return Ui(this,arguments,function(h){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var m=os(this,h);m.appendChild(h)}})},prepend:function(){return Ui(this,arguments,function(h){if(this.nodeType===1||this.nodeType===11||this.nodeType===9){var m=os(this,h);m.insertBefore(h,m.firstChild)}})},before:function(){return Ui(this,arguments,function(h){this.parentNode&&this.parentNode.insertBefore(h,this)})},after:function(){return Ui(this,arguments,function(h){this.parentNode&&this.parentNode.insertBefore(h,this.nextSibling)})},empty:function(){for(var h,m=0;(h=this[m])!=null;m++)h.nodeType===1&&(g.cleanData(Xt(h,!1)),h.textContent="");return this},clone:function(h,m){return h=h??!1,m=m??h,this.map(function(){return g.clone(this,h,m)})},html:function(h){return Me(this,function(m){var M=this[0]||{},T=0,C=this.length;if(m===void 0&&M.nodeType===1)return M.innerHTML;if(typeof m=="string"&&!ja.test(m)&&!gt[(Je.exec(m)||["",""])[1].toLowerCase()]){m=g.htmlPrefilter(m);try{for(;T=0&&(W+=Math.max(0,Math.ceil(h["offset"+m[0].toUpperCase()+m.slice(1)]-P-W-X-.5))||0),W+Z}function An(h,m,M){var T=Hn(h),C=!v.boxSizingReliable()||M,P=C&&g.css(h,"boxSizing",!1,T)==="border-box",U=P,X=ae(h,m,T),W="offset"+m[0].toUpperCase()+m.slice(1);if(ri.test(X)){if(!M)return X;X="auto"}return(!v.boxSizingReliable()&&P||!v.reliableTrDimensions()&&R(h,"tr")||X==="auto"||!parseFloat(X)&&g.css(h,"display",!1,T)==="inline")&&h.getClientRects().length&&(P=g.css(h,"boxSizing",!1,T)==="border-box",U=W in h,U&&(X=h[W])),X=parseFloat(X)||0,X+Kt(h,m,M||(P?"border":"content"),U,T,X)+"px"}g.extend({cssHooks:{opacity:{get:function(h,m){if(m){var M=ae(h,"opacity");return M===""?"1":M}}}},cssNumber:{animationIterationCount:!0,aspectRatio:!0,borderImageSlice:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,scale:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeMiterlimit:!0,strokeOpacity:!0},cssProps:{},style:function(h,m,M,T){if(!(!h||h.nodeType===3||h.nodeType===8||!h.style)){var C,P,U,X=O(m),W=si.test(m),Z=h.style;if(W||(m=nt(X)),U=g.cssHooks[m]||g.cssHooks[X],M!==void 0){if(P=typeof M,P==="string"&&(C=Xe.exec(M))&&C[1]&&(M=fn(h,m,C),P="number"),M==null||M!==M)return;P==="number"&&!W&&(M+=C&&C[3]||(g.cssNumber[X]?"":"px")),!v.clearCloneStyle&&M===""&&m.indexOf("background")===0&&(Z[m]="inherit"),(!U||!("set"in U)||(M=U.set(h,M,T))!==void 0)&&(W?Z.setProperty(m,M):Z[m]=M)}else return U&&"get"in U&&(C=U.get(h,!1,T))!==void 0?C:Z[m]}},css:function(h,m,M,T){var C,P,U,X=O(m),W=si.test(m);return W||(m=nt(X)),U=g.cssHooks[m]||g.cssHooks[X],U&&"get"in U&&(C=U.get(h,!0,M)),C===void 0&&(C=ae(h,m,T)),C==="normal"&&m in pt&&(C=pt[m]),M===""||M?(P=parseFloat(C),M===!0||isFinite(P)?P||0:C):C}}),g.each(["height","width"],function(h,m){g.cssHooks[m]={get:function(M,T,C){if(T)return yt.test(g.css(M,"display"))&&(!M.getClientRects().length||!M.getBoundingClientRect().width)?B(M,vt,function(){return An(M,m,C)}):An(M,m,C)},set:function(M,T,C){var P,U=Hn(M),X=!v.scrollboxSize()&&U.position==="absolute",W=X||C,Z=W&&g.css(M,"boxSizing",!1,U)==="border-box",ve=C?Kt(M,m,C,Z,U):0;return Z&&X&&(ve-=Math.ceil(M["offset"+m[0].toUpperCase()+m.slice(1)]-parseFloat(U[m])-Kt(M,m,"border",!1,U)-.5)),ve&&(P=Xe.exec(T))&&(P[3]||"px")!=="px"&&(M.style[m]=T,T=g.css(M,m)),qt(M,T,ve)}}}),g.cssHooks.marginLeft=ue(v.reliableMarginLeft,function(h,m){if(m)return(parseFloat(ae(h,"marginLeft"))||h.getBoundingClientRect().left-B(h,{marginLeft:0},function(){return h.getBoundingClientRect().left}))+"px"}),g.each({margin:"",padding:"",border:"Width"},function(h,m){g.cssHooks[h+m]={expand:function(M){for(var T=0,C={},P=typeof M=="string"?M.split(" "):[M];T<4;T++)C[h+ut[T]+m]=P[T]||P[T-2]||P[0];return C}},h!=="margin"&&(g.cssHooks[h+m].set=qt)}),g.fn.extend({css:function(h,m){return Me(this,function(M,T,C){var P,U,X={},W=0;if(Array.isArray(T)){for(P=Hn(M),U=T.length;W1)}});function Gt(h,m,M,T,C){return new Gt.prototype.init(h,m,M,T,C)}g.Tween=Gt,Gt.prototype={constructor:Gt,init:function(h,m,M,T,C,P){this.elem=h,this.prop=M,this.easing=C||g.easing._default,this.options=m,this.start=this.now=this.cur(),this.end=T,this.unit=P||(g.cssNumber[M]?"":"px")},cur:function(){var h=Gt.propHooks[this.prop];return h&&h.get?h.get(this):Gt.propHooks._default.get(this)},run:function(h){var m,M=Gt.propHooks[this.prop];return this.options.duration?this.pos=m=g.easing[this.easing](h,this.options.duration*h,0,1,this.options.duration):this.pos=m=h,this.now=(this.end-this.start)*m+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),M&&M.set?M.set(this):Gt.propHooks._default.set(this),this}},Gt.prototype.init.prototype=Gt.prototype,Gt.propHooks={_default:{get:function(h){var m;return h.elem.nodeType!==1||h.elem[h.prop]!=null&&h.elem.style[h.prop]==null?h.elem[h.prop]:(m=g.css(h.elem,h.prop,""),!m||m==="auto"?0:m)},set:function(h){g.fx.step[h.prop]?g.fx.step[h.prop](h):h.elem.nodeType===1&&(g.cssHooks[h.prop]||h.elem.style[nt(h.prop)]!=null)?g.style(h.elem,h.prop,h.now+h.unit):h.elem[h.prop]=h.now}}},Gt.propHooks.scrollTop=Gt.propHooks.scrollLeft={set:function(h){h.elem.nodeType&&h.elem.parentNode&&(h.elem[h.prop]=h.now)}},g.easing={linear:function(h){return h},swing:function(h){return .5-Math.cos(h*Math.PI)/2},_default:"swing"},g.fx=Gt.prototype.init,g.fx.step={};var Nt,dt,Vn=/^(?:toggle|show|hide)$/,nn=/queueHooks$/;function Cn(){dt&&(y.hidden===!1&&e.requestAnimationFrame?e.requestAnimationFrame(Cn):e.setTimeout(Cn,g.fx.interval),g.fx.tick())}function Un(){return e.setTimeout(function(){Nt=void 0}),Nt=Date.now()}function Rn(h,m){var M,T=0,C={height:h};for(m=m?1:0;T<4;T+=2-m)M=ut[T],C["margin"+M]=C["padding"+M]=h;return m&&(C.opacity=C.width=h),C}function jn(h,m,M){for(var T,C=(rn.tweeners[m]||[]).concat(rn.tweeners["*"]),P=0,U=C.length;P1)},removeAttr:function(h){return this.each(function(){g.removeAttr(this,h)})}}),g.extend({attr:function(h,m,M){var T,C,P=h.nodeType;if(!(P===3||P===8||P===2)){if(typeof h.getAttribute>"u")return g.prop(h,m,M);if((P!==1||!g.isXMLDoc(h))&&(C=g.attrHooks[m.toLowerCase()]||(g.expr.match.bool.test(m)?Pn:void 0)),M!==void 0){if(M===null){g.removeAttr(h,m);return}return C&&"set"in C&&(T=C.set(h,M,m))!==void 0?T:(h.setAttribute(m,M+""),M)}return C&&"get"in C&&(T=C.get(h,m))!==null?T:(T=g.find.attr(h,m),T??void 0)}},attrHooks:{type:{set:function(h,m){if(!v.radioValue&&m==="radio"&&R(h,"input")){var M=h.value;return h.setAttribute("type",m),M&&(h.value=M),m}}}},removeAttr:function(h,m){var M,T=0,C=m&&m.match(at);if(C&&h.nodeType===1)for(;M=C[T++];)h.removeAttribute(M)}}),Pn={set:function(h,m,M){return m===!1?g.removeAttr(h,M):h.setAttribute(M,M),M}},g.each(g.expr.match.bool.source.match(/\w+/g),function(h,m){var M=Ln[m]||g.find.attr;Ln[m]=function(T,C,P){var U,X,W=C.toLowerCase();return P||(X=Ln[W],Ln[W]=U,U=M(T,C,P)!=null?W:null,Ln[W]=X),U}});var Ar=/^(?:input|select|textarea|button)$/i,ur=/^(?:a|area)$/i;g.fn.extend({prop:function(h,m){return Me(this,g.prop,h,m,arguments.length>1)},removeProp:function(h){return this.each(function(){delete this[g.propFix[h]||h]})}}),g.extend({prop:function(h,m,M){var T,C,P=h.nodeType;if(!(P===3||P===8||P===2))return(P!==1||!g.isXMLDoc(h))&&(m=g.propFix[m]||m,C=g.propHooks[m]),M!==void 0?C&&"set"in C&&(T=C.set(h,M,m))!==void 0?T:h[m]=M:C&&"get"in C&&(T=C.get(h,m))!==null?T:h[m]},propHooks:{tabIndex:{get:function(h){var m=g.find.attr(h,"tabindex");return m?parseInt(m,10):Ar.test(h.nodeName)||ur.test(h.nodeName)&&h.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),v.optSelected||(g.propHooks.selected={get:function(h){var m=h.parentNode;return m&&m.parentNode&&m.parentNode.selectedIndex,null},set:function(h){var m=h.parentNode;m&&(m.selectedIndex,m.parentNode&&m.parentNode.selectedIndex)}}),g.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){g.propFix[this.toLowerCase()]=this});function as(h){var m=h.match(at)||[];return m.join(" ")}function ji(h){return h.getAttribute&&h.getAttribute("class")||""}function Fo(h){return Array.isArray(h)?h:typeof h=="string"?h.match(at)||[]:[]}g.fn.extend({addClass:function(h){var m,M,T,C,P,U;return x(h)?this.each(function(X){g(this).addClass(h.call(this,X,ji(this)))}):(m=Fo(h),m.length?this.each(function(){if(T=ji(this),M=this.nodeType===1&&" "+as(T)+" ",M){for(P=0;P-1;)M=M.replace(" "+C+" "," ");U=as(M),T!==U&&this.setAttribute("class",U)}}):this):this.attr("class","")},toggleClass:function(h,m){var M,T,C,P,U=typeof h,X=U==="string"||Array.isArray(h);return x(h)?this.each(function(W){g(this).toggleClass(h.call(this,W,ji(this),m),m)}):typeof m=="boolean"&&X?m?this.addClass(h):this.removeClass(h):(M=Fo(h),this.each(function(){if(X)for(P=g(this),C=0;C-1)return!0;return!1}});var wu=/\r/g;g.fn.extend({val:function(h){var m,M,T,C=this[0];return arguments.length?(T=x(h),this.each(function(P){var U;this.nodeType===1&&(T?U=h.call(this,P,g(this).val()):U=h,U==null?U="":typeof U=="number"?U+="":Array.isArray(U)&&(U=g.map(U,function(X){return X==null?"":X+""})),m=g.valHooks[this.type]||g.valHooks[this.nodeName.toLowerCase()],(!m||!("set"in m)||m.set(this,U,"value")===void 0)&&(this.value=U))})):C?(m=g.valHooks[C.type]||g.valHooks[C.nodeName.toLowerCase()],m&&"get"in m&&(M=m.get(C,"value"))!==void 0?M:(M=C.value,typeof M=="string"?M.replace(wu,""):M??"")):void 0}}),g.extend({valHooks:{option:{get:function(h){var m=g.find.attr(h,"value");return m??as(g.text(h))}},select:{get:function(h){var m,M,T,C=h.options,P=h.selectedIndex,U=h.type==="select-one",X=U?null:[],W=U?P+1:C.length;for(P<0?T=W:T=U?P:0;T-1)&&(M=!0);return M||(h.selectedIndex=-1),P}}}}),g.each(["radio","checkbox"],function(){g.valHooks[this]={set:function(h,m){if(Array.isArray(m))return h.checked=g.inArray(g(h).val(),m)>-1}},v.checkOn||(g.valHooks[this].get=function(h){return h.getAttribute("value")===null?"on":h.value})});var Fi=e.location,Eu={guid:Date.now()},Cr=/\?/;g.parseXML=function(h){var m,M;if(!h||typeof h!="string")return null;try{m=new e.DOMParser().parseFromString(h,"text/xml")}catch{}return M=m&&m.getElementsByTagName("parsererror")[0],(!m||M)&&g.error("Invalid XML: "+(M?g.map(M.childNodes,function(T){return T.textContent}).join(` `):h)),m};var Bo=/^(?:focusinfocus|focusoutblur)$/,sc=function(h){h.stopPropagation()};g.extend(g.event,{trigger:function(h,m,M,T){var C,P,U,X,W,Z,ve,Te,le=[M||y],Ne=f.call(h,"type")?h.type:h,bt=f.call(h,"namespace")?h.namespace.split("."):[];if(P=Te=U=M=M||y,!(M.nodeType===3||M.nodeType===8)&&!Bo.test(Ne+g.event.triggered)&&(Ne.indexOf(".")>-1&&(bt=Ne.split("."),Ne=bt.shift(),bt.sort()),W=Ne.indexOf(":")<0&&"on"+Ne,h=h[g.expando]?h:new g.Event(Ne,typeof h=="object"&&h),h.isTrigger=T?2:3,h.namespace=bt.join("."),h.rnamespace=h.namespace?new RegExp("(^|\\.)"+bt.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h.result=void 0,h.target||(h.target=M),m=m==null?[h]:g.makeArray(m,[h]),ve=g.event.special[Ne]||{},!(!T&&ve.trigger&&ve.trigger.apply(M,m)===!1))){if(!T&&!ve.noBubble&&!b(M)){for(X=ve.delegateType||Ne,Bo.test(X+Ne)||(P=P.parentNode);P;P=P.parentNode)le.push(P),U=P;U===(M.ownerDocument||y)&&le.push(U.defaultView||U.parentWindow||e)}for(C=0;(P=le[C++])&&!h.isPropagationStopped();)Te=P,h.type=C>1?X:ve.bindType||Ne,Z=(J.get(P,"events")||Object.create(null))[h.type]&&J.get(P,"handle"),Z&&Z.apply(P,m),Z=W&&P[W],Z&&Z.apply&&te(P)&&(h.result=Z.apply(P,m),h.result===!1&&h.preventDefault());return h.type=Ne,!T&&!h.isDefaultPrevented()&&(!ve._default||ve._default.apply(le.pop(),m)===!1)&&te(M)&&W&&x(M[Ne])&&!b(M)&&(U=M[W],U&&(M[W]=null),g.event.triggered=Ne,h.isPropagationStopped()&&Te.addEventListener(Ne,sc),M[Ne](),h.isPropagationStopped()&&Te.removeEventListener(Ne,sc),g.event.triggered=void 0,U&&(M[W]=U)),h.result}},simulate:function(h,m,M){var T=g.extend(new g.Event,M,{type:h,isSimulated:!0});g.event.trigger(T,null,m)}}),g.fn.extend({trigger:function(h,m){return this.each(function(){g.event.trigger(h,m,this)})},triggerHandler:function(h,m){var M=this[0];if(M)return g.event.trigger(h,m,M,!0)}});var ko=/\[\]$/,Za=/\r?\n/g,zo=/^(?:submit|button|image|reset|file)$/i,Au=/^(?:input|select|textarea|keygen)/i;function Ka(h,m,M,T){var C;if(Array.isArray(m))g.each(m,function(P,U){M||ko.test(h)?T(h,U):Ka(h+"["+(typeof U=="object"&&U!=null?P:"")+"]",U,M,T)});else if(!M&&S(m)==="object")for(C in m)Ka(h+"["+C+"]",m[C],M,T);else T(h,m)}g.param=function(h,m){var M,T=[],C=function(P,U){var X=x(U)?U():U;T[T.length]=encodeURIComponent(P)+"="+encodeURIComponent(X??"")};if(h==null)return"";if(Array.isArray(h)||h.jquery&&!g.isPlainObject(h))g.each(h,function(){C(this.name,this.value)});else for(M in h)Ka(M,h[M],m,C);return T.join("&")},g.fn.extend({serialize:function(){return g.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var h=g.prop(this,"elements");return h?g.makeArray(h):this}).filter(function(){var h=this.type;return this.name&&!g(this).is(":disabled")&&Au.test(this.nodeName)&&!zo.test(h)&&(this.checked||!Ce.test(h))}).map(function(h,m){var M=g(this).val();return M==null?null:Array.isArray(M)?g.map(M,function(T){return{name:m.name,value:T.replace(Za,`\r `)}}):{name:m.name,value:M.replace(Za,`\r `)}}).get()}});var Cu=/%20/g,no=/#.*$/,Sd=/([?&])_=[^&]*/,Ru=/^(.*?):[ \t]*([^\r\n]*)$/mg,oc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ja=/^(?:GET|HEAD)$/,ac=/^\/\//,Pu={},io={},Iu="*/".concat("*"),Qa=y.createElement("a");Qa.href=Fi.href;function el(h){return function(m,M){typeof m!="string"&&(M=m,m="*");var T,C=0,P=m.toLowerCase().match(at)||[];if(x(M))for(;T=P[C++];)T[0]==="+"?(T=T.slice(1)||"*",(h[T]=h[T]||[]).unshift(M)):(h[T]=h[T]||[]).push(M)}}function tl(h,m,M,T){var C={},P=h===io;function U(X){var W;return C[X]=!0,g.each(h[X]||[],function(Z,ve){var Te=ve(m,M,T);if(typeof Te=="string"&&!P&&!C[Te])return m.dataTypes.unshift(Te),U(Te),!1;if(P)return!(W=Te)}),W}return U(m.dataTypes[0])||!C["*"]&&U("*")}function Ho(h,m){var M,T,C=g.ajaxSettings.flatOptions||{};for(M in m)m[M]!==void 0&&((C[M]?h:T||(T={}))[M]=m[M]);return T&&g.extend(!0,h,T),h}function Lu(h,m,M){for(var T,C,P,U,X=h.contents,W=h.dataTypes;W[0]==="*";)W.shift(),T===void 0&&(T=h.mimeType||m.getResponseHeader("Content-Type"));if(T){for(C in X)if(X[C]&&X[C].test(T)){W.unshift(C);break}}if(W[0]in M)P=W[0];else{for(C in M){if(!W[0]||h.converters[C+" "+W[0]]){P=C;break}U||(U=C)}P=P||U}if(P)return P!==W[0]&&W.unshift(P),M[P]}function Vo(h,m,M,T){var C,P,U,X,W,Z={},ve=h.dataTypes.slice();if(ve[1])for(U in h.converters)Z[U.toLowerCase()]=h.converters[U];for(P=ve.shift();P;)if(h.responseFields[P]&&(M[h.responseFields[P]]=m),!W&&T&&h.dataFilter&&(m=h.dataFilter(m,h.dataType)),W=P,P=ve.shift(),P){if(P==="*")P=W;else if(W!=="*"&&W!==P){if(U=Z[W+" "+P]||Z["* "+P],!U){for(C in Z)if(X=C.split(" "),X[1]===P&&(U=Z[W+" "+X[0]]||Z["* "+X[0]],U)){U===!0?U=Z[C]:Z[C]!==!0&&(P=X[0],ve.unshift(X[1]));break}}if(U!==!0)if(U&&h.throws)m=U(m);else try{m=U(m)}catch(Te){return{state:"parsererror",error:U?Te:"No conversion from "+W+" to "+P}}}}return{state:"success",data:m}}g.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fi.href,type:"GET",isLocal:oc.test(Fi.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Iu,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":g.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(h,m){return m?Ho(Ho(h,g.ajaxSettings),m):Ho(g.ajaxSettings,h)},ajaxPrefilter:el(Pu),ajaxTransport:el(io),ajax:function(h,m){typeof h=="object"&&(m=h,h=void 0),m=m||{};var M,T,C,P,U,X,W,Z,ve,Te,le=g.ajaxSetup({},m),Ne=le.context||le,bt=le.context&&(Ne.nodeType||Ne.jquery)?g(Ne):g.event,Ot=g.Deferred(),Rt=g.Callbacks("once memory"),oi=le.statusCode||{},Gn={},Rr={},Pr="canceled",Yt={readyState:0,getResponseHeader:function(Qt){var Dn;if(W){if(!P)for(P={};Dn=Ru.exec(C);)P[Dn[1].toLowerCase()+" "]=(P[Dn[1].toLowerCase()+" "]||[]).concat(Dn[2]);Dn=P[Qt.toLowerCase()+" "]}return Dn==null?null:Dn.join(", ")},getAllResponseHeaders:function(){return W?C:null},setRequestHeader:function(Qt,Dn){return W==null&&(Qt=Rr[Qt.toLowerCase()]=Rr[Qt.toLowerCase()]||Qt,Gn[Qt]=Dn),this},overrideMimeType:function(Qt){return W==null&&(le.mimeType=Qt),this},statusCode:function(Qt){var Dn;if(Qt)if(W)Yt.always(Qt[Yt.status]);else for(Dn in Qt)oi[Dn]=[oi[Dn],Qt[Dn]];return this},abort:function(Qt){var Dn=Qt||Pr;return M&&M.abort(Dn),Es(0,Dn),this}};if(Ot.promise(Yt),le.url=((h||le.url||Fi.href)+"").replace(ac,Fi.protocol+"//"),le.type=m.method||m.type||le.method||le.type,le.dataTypes=(le.dataType||"*").toLowerCase().match(at)||[""],le.crossDomain==null){X=y.createElement("a");try{X.href=le.url,X.href=X.href,le.crossDomain=Qa.protocol+"//"+Qa.host!=X.protocol+"//"+X.host}catch{le.crossDomain=!0}}if(le.data&&le.processData&&typeof le.data!="string"&&(le.data=g.param(le.data,le.traditional)),tl(Pu,le,m,Yt),W)return Yt;Z=g.event&&le.global,Z&&g.active++===0&&g.event.trigger("ajaxStart"),le.type=le.type.toUpperCase(),le.hasContent=!Ja.test(le.type),T=le.url.replace(no,""),le.hasContent?le.data&&le.processData&&(le.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(le.data=le.data.replace(Cu,"+")):(Te=le.url.slice(T.length),le.data&&(le.processData||typeof le.data=="string")&&(T+=(Cr.test(T)?"&":"?")+le.data,delete le.data),le.cache===!1&&(T=T.replace(Sd,"$1"),Te=(Cr.test(T)?"&":"?")+"_="+Eu.guid+++Te),le.url=T+Te),le.ifModified&&(g.lastModified[T]&&Yt.setRequestHeader("If-Modified-Since",g.lastModified[T]),g.etag[T]&&Yt.setRequestHeader("If-None-Match",g.etag[T])),(le.data&&le.hasContent&&le.contentType!==!1||m.contentType)&&Yt.setRequestHeader("Content-Type",le.contentType),Yt.setRequestHeader("Accept",le.dataTypes[0]&&le.accepts[le.dataTypes[0]]?le.accepts[le.dataTypes[0]]+(le.dataTypes[0]!=="*"?", "+Iu+"; q=0.01":""):le.accepts["*"]);for(ve in le.headers)Yt.setRequestHeader(ve,le.headers[ve]);if(le.beforeSend&&(le.beforeSend.call(Ne,Yt,le)===!1||W))return Yt.abort();if(Pr="abort",Rt.add(le.complete),Yt.done(le.success),Yt.fail(le.error),M=tl(io,le,m,Yt),!M)Es(-1,"No Transport");else{if(Yt.readyState=1,Z&&bt.trigger("ajaxSend",[Yt,le]),W)return Yt;le.async&&le.timeout>0&&(U=e.setTimeout(function(){Yt.abort("timeout")},le.timeout));try{W=!1,M.send(Gn,Es)}catch(Qt){if(W)throw Qt;Es(-1,Qt)}}function Es(Qt,Dn,Go,cs){var gi,Wo,Bi,us,hs,Zi=Dn;W||(W=!0,U&&e.clearTimeout(U),M=void 0,C=cs||"",Yt.readyState=Qt>0?4:0,gi=Qt>=200&&Qt<300||Qt===304,Go&&(us=Lu(le,Yt,Go)),!gi&&g.inArray("script",le.dataTypes)>-1&&g.inArray("json",le.dataTypes)<0&&(le.converters["text script"]=function(){}),us=Vo(le,us,Yt,gi),gi?(le.ifModified&&(hs=Yt.getResponseHeader("Last-Modified"),hs&&(g.lastModified[T]=hs),hs=Yt.getResponseHeader("etag"),hs&&(g.etag[T]=hs)),Qt===204||le.type==="HEAD"?Zi="nocontent":Qt===304?Zi="notmodified":(Zi=us.state,Wo=us.data,Bi=us.error,gi=!Bi)):(Bi=Zi,(Qt||!Zi)&&(Zi="error",Qt<0&&(Qt=0))),Yt.status=Qt,Yt.statusText=(Dn||Zi)+"",gi?Ot.resolveWith(Ne,[Wo,Zi,Yt]):Ot.rejectWith(Ne,[Yt,Zi,Bi]),Yt.statusCode(oi),oi=void 0,Z&&bt.trigger(gi?"ajaxSuccess":"ajaxError",[Yt,le,gi?Wo:Bi]),Rt.fireWith(Ne,[Yt,Zi]),Z&&(bt.trigger("ajaxComplete",[Yt,le]),--g.active||g.event.trigger("ajaxStop")))}return Yt},getJSON:function(h,m,M){return g.get(h,m,M,"json")},getScript:function(h,m){return g.get(h,void 0,m,"script")}}),g.each(["get","post"],function(h,m){g[m]=function(M,T,C,P){return x(T)&&(P=P||C,C=T,T=void 0),g.ajax(g.extend({url:M,type:m,dataType:P,data:T,success:C},g.isPlainObject(M)&&M))}}),g.ajaxPrefilter(function(h){var m;for(m in h.headers)m.toLowerCase()==="content-type"&&(h.contentType=h.headers[m]||"")}),g._evalUrl=function(h,m,M){return g.ajax({url:h,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(T){g.globalEval(T,m,M)}})},g.fn.extend({wrapAll:function(h){var m;return this[0]&&(x(h)&&(h=h.call(this[0])),m=g(h,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&m.insertBefore(this[0]),m.map(function(){for(var M=this;M.firstElementChild;)M=M.firstElementChild;return M}).append(this)),this},wrapInner:function(h){return x(h)?this.each(function(m){g(this).wrapInner(h.call(this,m))}):this.each(function(){var m=g(this),M=m.contents();M.length?M.wrapAll(h):m.append(h)})},wrap:function(h){var m=x(h);return this.each(function(M){g(this).wrapAll(m?h.call(this,M):h)})},unwrap:function(h){return this.parent(h).not("body").each(function(){g(this).replaceWith(this.childNodes)}),this}}),g.expr.pseudos.hidden=function(h){return!g.expr.pseudos.visible(h)},g.expr.pseudos.visible=function(h){return!!(h.offsetWidth||h.offsetHeight||h.getClientRects().length)},g.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch{}};var lc={0:200,1223:204},ro=g.ajaxSettings.xhr();v.cors=!!ro&&"withCredentials"in ro,v.ajax=ro=!!ro,g.ajaxTransport(function(h){var m,M;if(v.cors||ro&&!h.crossDomain)return{send:function(T,C){var P,U=h.xhr();if(U.open(h.type,h.url,h.async,h.username,h.password),h.xhrFields)for(P in h.xhrFields)U[P]=h.xhrFields[P];h.mimeType&&U.overrideMimeType&&U.overrideMimeType(h.mimeType),!h.crossDomain&&!T["X-Requested-With"]&&(T["X-Requested-With"]="XMLHttpRequest");for(P in T)U.setRequestHeader(P,T[P]);m=function(X){return function(){m&&(m=M=U.onload=U.onerror=U.onabort=U.ontimeout=U.onreadystatechange=null,X==="abort"?U.abort():X==="error"?typeof U.status!="number"?C(0,"error"):C(U.status,U.statusText):C(lc[U.status]||U.status,U.statusText,(U.responseType||"text")!=="text"||typeof U.responseText!="string"?{binary:U.response}:{text:U.responseText},U.getAllResponseHeaders()))}},U.onload=m(),M=U.onerror=U.ontimeout=m("error"),U.onabort!==void 0?U.onabort=M:U.onreadystatechange=function(){U.readyState===4&&e.setTimeout(function(){m&&M()})},m=m("abort");try{U.send(h.hasContent&&h.data||null)}catch(X){if(m)throw X}},abort:function(){m&&m()}}}),g.ajaxPrefilter(function(h){h.crossDomain&&(h.contents.script=!1)}),g.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(h){return g.globalEval(h),h}}}),g.ajaxPrefilter("script",function(h){h.cache===void 0&&(h.cache=!1),h.crossDomain&&(h.type="GET")}),g.ajaxTransport("script",function(h){if(h.crossDomain||h.scriptAttrs){var m,M;return{send:function(T,C){m=g("