primocode 10.14.0 → 10.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSES/robo.txt +19 -0
- package/README.md +6 -2
- package/bin/primocode.js +46 -3
- package/lib/act.js +9 -2
- package/lib/estudio/cota.js +10 -3
- package/lib/estudio/editor.js +5 -0
- package/lib/estudio/index.js +9 -2
- package/lib/estudio/projetos.js +13 -1
- package/lib/limites.js +100 -0
- package/lib/marca-kit.js +3 -0
- package/lib/planos.js +10 -8
- package/lib/preparar.js +2 -0
- package/lib/voz-ponte.js +15 -0
- package/lib/voz.js +75 -5
- package/package.json +3 -2
- package/voz/primo_voz/__main__.py +307 -54
- package/voz/primo_voz/conversa.py +236 -0
- package/voz/primo_voz/escuta.py +32 -2
- package/voz/primo_voz/hud.html +550 -0
- package/voz/primo_voz/hud.py +224 -0
- package/voz/primo_voz/identidade.py +88 -0
- package/voz/primo_voz/luz.py +137 -0
- package/voz/primo_voz/painel.py +459 -0
- package/voz/primo_voz/painel_tui.py +26 -0
- package/voz/primo_voz/sons.py +96 -0
- package/voz/primo_voz/tela.py +337 -0
- package/voz/primo_voz/vendor/RobotExpressive.glb +0 -0
- package/voz/primo_voz/vendor/spline-runtime.min.js +8219 -0
- package/voz/primo_voz/vendor/three-robo.min.js +3824 -0
- package/voz/primo_voz/vendor/three.LICENSE.txt +21 -0
- package/voz/primo_voz/vivo.py +34 -0
|
@@ -0,0 +1,3824 @@
|
|
|
1
|
+
(()=>{var Ba="170";var Uh=0,zc=1,Oh=2;var nh=1,Fh=2,gn=3,sn=0,wt=1,Kt=2,zn=0,Ci=1,kc=2,Vc=3,Hc=4,Bh=5,ti=100,zh=101,kh=102,Vh=103,Hh=104,Gh=200,Wh=201,Xh=202,qh=203,To=204,Eo=205,Yh=206,Zh=207,Kh=208,Jh=209,$h=210,jh=211,Qh=212,eu=213,tu=214,wo=0,Ro=1,Co=2,Di=3,Io=4,Po=5,Lo=6,Do=7,ih=0,nu=1,iu=2,kn=0,su=1,ru=2,ou=3,za=4,au=5,cu=6,lu=7,Gc="attached",hu="detached",sh=300,Ni=301,Ui=302,No=303,Uo=304,zr=306,si=1e3,xn=1001,us=1002,Mt=1003,ka=1004;var Ti=1005;var Et=1006,as=1007;var tn=1008;var Mn=1009,rh=1010,oh=1011,ds=1012,Va=1013,ri=1014,$t=1015,bs=1016,Ha=1017,Ga=1018,Oi=1020,ah=35902,ch=1021,lh=1022,Bt=1023,hh=1024,uh=1025,Ii=1026,Fi=1027,Wa=1028,Xa=1029,dh=1030,qa=1031;var Ya=1033,tr=33776,nr=33777,ir=33778,sr=33779,Oo=35840,Fo=35841,Bo=35842,zo=35843,ko=36196,Vo=37492,Ho=37496,Go=37808,Wo=37809,Xo=37810,qo=37811,Yo=37812,Zo=37813,Ko=37814,Jo=37815,$o=37816,jo=37817,Qo=37818,ea=37819,ta=37820,na=37821,rr=36492,ia=36494,sa=36495,fh=36283,ra=36284,oa=36285,aa=36286,Za=2200,Ka=2201,uu=2202,Bi=2300,zi=2301,qr=2302,Ei=2400,wi=2401,or=2402,Ja=2500,du=2501,ph=0,kr=1,As=2,fu=3200,pu=3201;var mh=0,mu=1,Fn="",lt="srgb",St="srgb-linear",Vr="linear",Je="srgb";var hi=7680;var Wc=519,gu=512,_u=513,xu=514,gh=515,vu=516,yu=517,Mu=518,Su=519,ca=35044;var Xc="300 es",vn=2e3,ar=2001,Sn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let i=this._listeners[e];if(i!==void 0){let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,e);e.target=null}}},_t=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],qc=1234567,cs=Math.PI/180,ki=180/Math.PI;function jt(){let s=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(_t[s&255]+_t[s>>8&255]+_t[s>>16&255]+_t[s>>24&255]+"-"+_t[e&255]+_t[e>>8&255]+"-"+_t[e>>16&15|64]+_t[e>>24&255]+"-"+_t[t&63|128]+_t[t>>8&255]+"-"+_t[t>>16&255]+_t[t>>24&255]+_t[n&255]+_t[n>>8&255]+_t[n>>16&255]+_t[n>>24&255]).toLowerCase()}function vt(s,e,t){return Math.max(e,Math.min(t,s))}function $a(s,e){return(s%e+e)%e}function bu(s,e,t,n,i){return n+(s-e)*(i-n)/(t-e)}function Au(s,e,t){return s!==e?(t-s)/(e-s):0}function ls(s,e,t){return(1-t)*s+t*e}function Tu(s,e,t,n){return ls(s,e,1-Math.exp(-t*n))}function Eu(s,e=1){return e-Math.abs($a(s,e*2)-e)}function wu(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*(3-2*s))}function Ru(s,e,t){return s<=e?0:s>=t?1:(s=(s-e)/(t-e),s*s*s*(s*(s*6-15)+10))}function Cu(s,e){return s+Math.floor(Math.random()*(e-s+1))}function Iu(s,e){return s+Math.random()*(e-s)}function Pu(s){return s*(.5-Math.random())}function Lu(s){s!==void 0&&(qc=s);let e=qc+=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 Du(s){return s*cs}function Nu(s){return s*ki}function Uu(s){return(s&s-1)===0&&s!==0}function Ou(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Fu(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Bu(s,e,t,n,i){let r=Math.cos,o=Math.sin,a=r(t/2),c=o(t/2),l=r((e+n)/2),h=o((e+n)/2),u=r((e-n)/2),d=o((e-n)/2),p=r((n-e)/2),g=o((n-e)/2);switch(i){case"XYX":s.set(a*h,c*u,c*d,a*l);break;case"YZY":s.set(c*d,a*h,c*u,a*l);break;case"ZXZ":s.set(c*u,c*d,a*h,a*l);break;case"XZX":s.set(a*h,c*g,c*p,a*l);break;case"YXY":s.set(c*p,a*h,c*g,a*l);break;case"ZYZ":s.set(c*g,c*p,a*h,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Jt(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 Ke(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.")}}var _h={DEG2RAD:cs,RAD2DEG:ki,generateUUID:jt,clamp:vt,euclideanModulo:$a,mapLinear:bu,inverseLerp:Au,lerp:ls,damp:Tu,pingpong:Eu,smoothstep:wu,smootherstep:Ru,randInt:Cu,randFloat:Iu,randFloatSpread:Pu,seededRandom:Lu,degToRad:Du,radToDeg:Nu,isPowerOfTwo:Uu,ceilPowerOfTwo:Ou,floorPowerOfTwo:Fu,setQuaternionFromProperEuler:Bu,normalize:Ke,denormalize:Jt},Be=class s{constructor(e=0,t=0){s.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){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(vt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),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}},Ie=class s{constructor(e,t,n,i,r,o,a,c,l){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l)}set(e,t,n,i,r,o,a,c,l){let h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=r,h[5]=c,h[6]=n,h[7]=o,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],p=n[5],g=n[8],_=i[0],m=i[3],f=i[6],T=i[1],A=i[4],M=i[7],U=i[2],w=i[5],E=i[8];return r[0]=o*_+a*T+c*U,r[3]=o*m+a*A+c*w,r[6]=o*f+a*M+c*E,r[1]=l*_+h*T+u*U,r[4]=l*m+h*A+u*w,r[7]=l*f+h*M+u*E,r[2]=d*_+p*T+g*U,r[5]=d*m+p*A+g*w,r[8]=d*f+p*M+g*E,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8];return t*o*h-t*a*l-n*r*h+n*a*c+i*r*l-i*o*c}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=h*o-a*l,d=a*c-h*r,p=l*r-o*c,g=t*u+n*d+i*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;return e[0]=u*_,e[1]=(i*l-h*n)*_,e[2]=(a*n-i*o)*_,e[3]=d*_,e[4]=(h*t-i*c)*_,e[5]=(i*r-a*t)*_,e[6]=p*_,e[7]=(n*c-l*t)*_,e[8]=(o*t-n*r)*_,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,o,a){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-i*l,i*c,-i*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Yr.makeScale(e,t)),this}rotate(e){return this.premultiply(Yr.makeRotation(-e)),this}translate(e,t){return this.premultiply(Yr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let 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){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Yr=new Ie;function xh(s){for(let e=s.length-1;e>=0;--e)if(s[e]>=65535)return!0;return!1}function fs(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function zu(){let s=fs("canvas");return s.style.display="block",s}var Yc={};function rs(s){s in Yc||(Yc[s]=!0,console.warn(s))}function ku(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 Vu(s){let 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 Hu(s){let e=s.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}var Fe={enabled:!0,workingColorSpace:St,spaces:{},convert:function(s,e,t){return this.enabled===!1||e===t||!e||!t||(this.spaces[e].transfer===Je&&(s.r=yn(s.r),s.g=yn(s.g),s.b=yn(s.b)),this.spaces[e].primaries!==this.spaces[t].primaries&&(s.applyMatrix3(this.spaces[e].toXYZ),s.applyMatrix3(this.spaces[t].fromXYZ)),this.spaces[t].transfer===Je&&(s.r=Pi(s.r),s.g=Pi(s.g),s.b=Pi(s.b))),s},fromWorkingColorSpace:function(s,e){return this.convert(s,this.workingColorSpace,e)},toWorkingColorSpace:function(s,e){return this.convert(s,e,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Fn?Vr:this.spaces[s].transfer},getLuminanceCoefficients:function(s,e=this.workingColorSpace){return s.fromArray(this.spaces[e].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,e,t){return s.copy(this.spaces[e].toXYZ).multiply(this.spaces[t].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}};function yn(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Pi(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var Zc=[.64,.33,.3,.6,.15,.06],Kc=[.2126,.7152,.0722],Jc=[.3127,.329],$c=new Ie().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),jc=new Ie().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);Fe.define({[St]:{primaries:Zc,whitePoint:Jc,transfer:Vr,toXYZ:$c,fromXYZ:jc,luminanceCoefficients:Kc,workingColorSpaceConfig:{unpackColorSpace:lt},outputColorSpaceConfig:{drawingBufferColorSpace:lt}},[lt]:{primaries:Zc,whitePoint:Jc,transfer:Je,toXYZ:$c,fromXYZ:jc,luminanceCoefficients:Kc,outputColorSpaceConfig:{drawingBufferColorSpace:lt}}});var ui,la=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{ui===void 0&&(ui=fs("canvas")),ui.width=e.width,ui.height=e.height;let n=ui.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ui}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=fs("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=yn(r[o]/255)*255;return n.putImageData(i,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(yn(t[n]/255)*255):t[n]=yn(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Gu=0,cr=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Gu++}),this.uuid=jt(),this.data=e,this.dataReady=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(Zr(i[o].image)):r.push(Zr(i[o]))}else r=Zr(i);n.url=r}return t||(e.images[this.uuid]=n),n}};function Zr(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?la.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var Wu=0,mt=class s extends Sn{constructor(e=s.DEFAULT_IMAGE,t=s.DEFAULT_MAPPING,n=xn,i=xn,r=Et,o=tn,a=Bt,c=Mn,l=s.DEFAULT_ANISOTROPY,h=Fn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Wu++}),this.uuid=jt(),this.name="",this.source=new cr(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Be(0,0),this.repeat=new Be(1,1),this.center=new Be(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ie,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==sh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case si:e.x=e.x-Math.floor(e.x);break;case xn:e.x=e.x<0?0:1;break;case us: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 si:e.y=e.y-Math.floor(e.y);break;case xn:e.y=e.y<0?0:1;break;case us: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++}};mt.DEFAULT_IMAGE=null;mt.DEFAULT_MAPPING=sh;mt.DEFAULT_ANISOTROPY=1;var Xe=class s{constructor(e=0,t=0,n=0,i=1){s.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){let 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);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,c=e.elements,l=c[0],h=c[4],u=c[8],d=c[1],p=c[5],g=c[9],_=c[2],m=c[6],f=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let A=(l+1)/2,M=(p+1)/2,U=(f+1)/2,w=(h+d)/4,E=(u+_)/4,N=(g+m)/4;return A>M&&A>U?A<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(A),i=w/n,r=E/n):M>U?M<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(M),n=w/i,r=N/i):U<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(U),n=E/r,i=N/r),this.set(n,i,r,t),this}let T=Math.sqrt((m-g)*(m-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(T)<.001&&(T=1),this.x=(m-g)/T,this.y=(u-_)/T,this.z=(d-h)/T,this.w=Math.acos((l+p+f-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},ha=class extends Sn{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Xe(0,0,e,t),this.scissorTest=!1,this.viewport=new Xe(0,0,e,t);let i={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Et,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let r=new mt(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=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=e,this.textures[i].image.height=t,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,i=e.textures.length;n<i;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new cr(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},bn=class extends ha{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},lr=class extends mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Mt,this.minFilter=Mt,this.wrapR=xn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}};var ua=class extends mt{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Mt,this.minFilter=Mt,this.wrapR=xn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Rt=class{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,o,a){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3],d=r[o+0],p=r[o+1],g=r[o+2],_=r[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u;return}if(a===1){e[t+0]=d,e[t+1]=p,e[t+2]=g,e[t+3]=_;return}if(u!==_||c!==d||l!==p||h!==g){let m=1-a,f=c*d+l*p+h*g+u*_,T=f>=0?1:-1,A=1-f*f;if(A>Number.EPSILON){let U=Math.sqrt(A),w=Math.atan2(U,f*T);m=Math.sin(m*w)/U,a=Math.sin(a*w)/U}let M=a*T;if(c=c*m+d*M,l=l*m+p*M,h=h*m+g*M,u=u*m+_*M,m===1-a){let U=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=U,l*=U,h*=U,u*=U}}e[t]=c,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,o){let a=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[o],d=r[o+1],p=r[o+2],g=r[o+3];return e[t]=a*g+h*u+c*p-l*d,e[t+1]=c*g+h*d+l*u-a*p,e[t+2]=l*g+h*p+a*d-c*u,e[t+3]=h*g-a*u-c*d-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,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){let n=e._x,i=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),h=a(i/2),u=a(r/2),d=c(n/2),p=c(i/2),g=c(r/2);switch(o){case"XYZ":this._x=d*h*u+l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u-d*p*g;break;case"YXZ":this._x=d*h*u+l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u+d*p*g;break;case"ZXY":this._x=d*h*u-l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u-d*p*g;break;case"ZYX":this._x=d*h*u-l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u+d*p*g;break;case"YZX":this._x=d*h*u+l*p*g,this._y=l*p*u+d*h*g,this._z=l*h*g-d*p*u,this._w=l*h*u-d*p*g;break;case"XZY":this._x=d*h*u-l*p*g,this._y=l*p*u-d*h*g,this._z=l*h*g+d*p*u,this._w=l*h*u+d*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let 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){let t=e.elements,n=t[0],i=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],h=t[6],u=t[10],d=n+a+u;if(d>0){let p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(o-i)*p}else if(n>a&&n>u){let p=2*Math.sqrt(1+n-a-u);this._w=(h-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+l)/p}else if(a>u){let p=2*Math.sqrt(1+a-n-u);this._w=(r-l)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+u-n-a);this._w=(o-i)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(vt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let 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){let n=e._x,i=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,h=t._w;return this._x=n*h+o*a+i*l-r*c,this._y=i*h+o*c+r*a-n*l,this._z=r*h+o*l+n*c-i*a,this._w=o*h-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,i=this._y,r=this._z,o=this._w,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;let c=1-a*a;if(c<=Number.EPSILON){let 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}let l=Math.sqrt(c),h=Math.atan2(l,a),u=Math.sin((1-t)*h)/l,d=Math.sin(t*h)/l;return this._w=o*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),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}},L=class s{constructor(e=0,t=0,n=0){s.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(Qc.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Qc.setFromAxisAngle(e,t))}applyMatrix3(e){let 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){let 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){let t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*i-a*n),h=2*(a*t-r*i),u=2*(r*n-o*t);return this.x=t+c*l+o*u-a*h,this.y=n+c*h+a*l-r*u,this.z=i+c*u+r*h-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Kr.copy(this).projectOnVector(e),this.sub(Kr)}reflect(e){return this.sub(Kr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(vt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let 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){let 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){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),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(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Kr=new L,Qc=new Rt,kt=class{constructor(e=new L(1/0,1/0,1/0),t=new L(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(qt.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(qt.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=qt.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,qt):qt.fromBufferAttribute(r,o),qt.applyMatrix4(e.matrixWorld),this.expandByPoint(qt);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Rs.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Rs.copy(n.boundingBox)),Rs.applyMatrix4(e.matrixWorld),this.union(Rs)}let i=e.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,qt),qt.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($i),Cs.subVectors(this.max,$i),di.subVectors(e.a,$i),fi.subVectors(e.b,$i),pi.subVectors(e.c,$i),Pn.subVectors(fi,di),Ln.subVectors(pi,fi),Zn.subVectors(di,pi);let t=[0,-Pn.z,Pn.y,0,-Ln.z,Ln.y,0,-Zn.z,Zn.y,Pn.z,0,-Pn.x,Ln.z,0,-Ln.x,Zn.z,0,-Zn.x,-Pn.y,Pn.x,0,-Ln.y,Ln.x,0,-Zn.y,Zn.x,0];return!Jr(t,di,fi,pi,Cs)||(t=[1,0,0,0,1,0,0,0,1],!Jr(t,di,fi,pi,Cs))?!1:(Is.crossVectors(Pn,Ln),t=[Is.x,Is.y,Is.z],Jr(t,di,fi,pi,Cs))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qt).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(hn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),hn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),hn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),hn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),hn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),hn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),hn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),hn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(hn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},hn=[new L,new L,new L,new L,new L,new L,new L,new L],qt=new L,Rs=new kt,di=new L,fi=new L,pi=new L,Pn=new L,Ln=new L,Zn=new L,$i=new L,Cs=new L,Is=new L,Kn=new L;function Jr(s,e,t,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){Kn.fromArray(s,r);let a=i.x*Math.abs(Kn.x)+i.y*Math.abs(Kn.y)+i.z*Math.abs(Kn.z),c=e.dot(Kn),l=t.dot(Kn),h=n.dot(Kn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>a)return!1}return!0}var Xu=new kt,ji=new L,$r=new L,Lt=class{constructor(e=new L,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t!==void 0?n.copy(t):Xu.setFromPoints(e).getCenter(n);let i=0;for(let r=0,o=e.length;r<o;r++)i=Math.max(i,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ji.subVectors(e,this.center);let t=ji.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),i=(n-this.radius)*.5;this.center.addScaledVector(ji,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):($r.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ji.copy(e.center).add($r)),this.expandByPoint(ji.copy(e.center).sub($r))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},un=new L,jr=new L,Ps=new L,Dn=new L,Qr=new L,Ls=new L,eo=new L,Vi=class{constructor(e=new L,t=new L(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,un)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=un.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(un.copy(this.origin).addScaledVector(this.direction,t),un.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){jr.copy(e).add(t).multiplyScalar(.5),Ps.copy(t).sub(e).normalize(),Dn.copy(this.origin).sub(jr);let r=e.distanceTo(t)*.5,o=-this.direction.dot(Ps),a=Dn.dot(this.direction),c=-Dn.dot(Ps),l=Dn.lengthSq(),h=Math.abs(1-o*o),u,d,p,g;if(h>0)if(u=o*c-a,d=o*a-c,g=r*h,u>=0)if(d>=-g)if(d<=g){let _=1/h;u*=_,d*=_,p=u*(u+o*d+2*a)+d*(o*u+d+2*c)+l}else d=r,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+l;else d<=-g?(u=Math.max(0,-(-o*r+a)),d=u>0?-r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l):d<=g?(u=0,d=Math.min(Math.max(-r,-c),r),p=d*(d+2*c)+l):(u=Math.max(0,-(o*r+a)),d=u>0?r:Math.min(Math.max(-r,-c),r),p=-u*u+d*(d+2*c)+l);else d=o>0?-r:r,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(jr).addScaledVector(Ps,d),p}intersectSphere(e,t){un.subVectors(e.center,this.origin);let n=un.dot(this.direction),i=un.dot(un)-n*n,r=e.radius*e.radius;if(i>r)return null;let o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,o,a,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),h>=0?(r=(e.min.y-d.y)*h,o=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,o=(e.min.y-d.y)*h),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),u>=0?(a=(e.min.z-d.z)*u,c=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,c=(e.min.z-d.z)*u),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,t)}intersectsBox(e){return this.intersectBox(e,un)!==null}intersectTriangle(e,t,n,i,r){Qr.subVectors(t,e),Ls.subVectors(n,e),eo.crossVectors(Qr,Ls);let o=this.direction.dot(eo),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;Dn.subVectors(this.origin,e);let c=a*this.direction.dot(Ls.crossVectors(Dn,Ls));if(c<0)return null;let l=a*this.direction.dot(Qr.cross(Dn));if(l<0||c+l>o)return null;let h=-a*Dn.dot(eo);return h<0?null:this.at(h/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Pe=class s{constructor(e,t,n,i,r,o,a,c,l,h,u,d,p,g,_,m){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,i,r,o,a,c,l,h,u,d,p,g,_,m)}set(e,t,n,i,r,o,a,c,l,h,u,d,p,g,_,m){let f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=i,f[1]=r,f[5]=o,f[9]=a,f[13]=c,f[2]=l,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=g,f[11]=_,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new s().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return 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){let t=this.elements,n=e.elements,i=1/mi.setFromMatrixColumn(e,0).length(),r=1/mi.setFromMatrixColumn(e,1).length(),o=1/mi.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){let t=this.elements,n=e.x,i=e.y,r=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){let d=o*h,p=o*u,g=a*h,_=a*u;t[0]=c*h,t[4]=-c*u,t[8]=l,t[1]=p+g*l,t[5]=d-_*l,t[9]=-a*c,t[2]=_-d*l,t[6]=g+p*l,t[10]=o*c}else if(e.order==="YXZ"){let d=c*h,p=c*u,g=l*h,_=l*u;t[0]=d+_*a,t[4]=g*a-p,t[8]=o*l,t[1]=o*u,t[5]=o*h,t[9]=-a,t[2]=p*a-g,t[6]=_+d*a,t[10]=o*c}else if(e.order==="ZXY"){let d=c*h,p=c*u,g=l*h,_=l*u;t[0]=d-_*a,t[4]=-o*u,t[8]=g+p*a,t[1]=p+g*a,t[5]=o*h,t[9]=_-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let d=o*h,p=o*u,g=a*h,_=a*u;t[0]=c*h,t[4]=g*l-p,t[8]=d*l+_,t[1]=c*u,t[5]=_*l+d,t[9]=p*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let d=o*c,p=o*l,g=a*c,_=a*l;t[0]=c*h,t[4]=_-d*u,t[8]=g*u+p,t[1]=u,t[5]=o*h,t[9]=-a*h,t[2]=-l*h,t[6]=p*u+g,t[10]=d-_*u}else if(e.order==="XZY"){let d=o*c,p=o*l,g=a*c,_=a*l;t[0]=c*h,t[4]=-u,t[8]=l*h,t[1]=d*u+_,t[5]=o*h,t[9]=p*u-g,t[2]=g*u-p,t[6]=a*h,t[10]=_*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(qu,e,Yu)}lookAt(e,t,n){let i=this.elements;return It.subVectors(e,t),It.lengthSq()===0&&(It.z=1),It.normalize(),Nn.crossVectors(n,It),Nn.lengthSq()===0&&(Math.abs(n.z)===1?It.x+=1e-4:It.z+=1e-4,It.normalize(),Nn.crossVectors(n,It)),Nn.normalize(),Ds.crossVectors(It,Nn),i[0]=Nn.x,i[4]=Ds.x,i[8]=It.x,i[1]=Nn.y,i[5]=Ds.y,i[9]=It.y,i[2]=Nn.z,i[6]=Ds.z,i[10]=It.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],p=n[13],g=n[2],_=n[6],m=n[10],f=n[14],T=n[3],A=n[7],M=n[11],U=n[15],w=i[0],E=i[4],N=i[8],S=i[12],y=i[1],R=i[5],q=i[9],z=i[13],W=i[2],J=i[6],H=i[10],Q=i[14],V=i[3],ie=i[7],le=i[11],ve=i[15];return r[0]=o*w+a*y+c*W+l*V,r[4]=o*E+a*R+c*J+l*ie,r[8]=o*N+a*q+c*H+l*le,r[12]=o*S+a*z+c*Q+l*ve,r[1]=h*w+u*y+d*W+p*V,r[5]=h*E+u*R+d*J+p*ie,r[9]=h*N+u*q+d*H+p*le,r[13]=h*S+u*z+d*Q+p*ve,r[2]=g*w+_*y+m*W+f*V,r[6]=g*E+_*R+m*J+f*ie,r[10]=g*N+_*q+m*H+f*le,r[14]=g*S+_*z+m*Q+f*ve,r[3]=T*w+A*y+M*W+U*V,r[7]=T*E+A*R+M*J+U*ie,r[11]=T*N+A*q+M*H+U*le,r[15]=T*S+A*z+M*Q+U*ve,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],h=e[2],u=e[6],d=e[10],p=e[14],g=e[3],_=e[7],m=e[11],f=e[15];return g*(+r*c*u-i*l*u-r*a*d+n*l*d+i*a*p-n*c*p)+_*(+t*c*p-t*l*d+r*o*d-i*o*p+i*l*h-r*c*h)+m*(+t*l*u-t*a*p-r*o*u+n*o*p+r*a*h-n*l*h)+f*(-i*a*h-t*c*u+t*a*d+i*o*u-n*o*d+n*c*h)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let 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(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],d=e[10],p=e[11],g=e[12],_=e[13],m=e[14],f=e[15],T=u*m*l-_*d*l+_*c*p-a*m*p-u*c*f+a*d*f,A=g*d*l-h*m*l-g*c*p+o*m*p+h*c*f-o*d*f,M=h*_*l-g*u*l+g*a*p-o*_*p-h*a*f+o*u*f,U=g*u*c-h*_*c-g*a*d+o*_*d+h*a*m-o*u*m,w=t*T+n*A+i*M+r*U;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let E=1/w;return e[0]=T*E,e[1]=(_*d*r-u*m*r-_*i*p+n*m*p+u*i*f-n*d*f)*E,e[2]=(a*m*r-_*c*r+_*i*l-n*m*l-a*i*f+n*c*f)*E,e[3]=(u*c*r-a*d*r-u*i*l+n*d*l+a*i*p-n*c*p)*E,e[4]=A*E,e[5]=(h*m*r-g*d*r+g*i*p-t*m*p-h*i*f+t*d*f)*E,e[6]=(g*c*r-o*m*r-g*i*l+t*m*l+o*i*f-t*c*f)*E,e[7]=(o*d*r-h*c*r+h*i*l-t*d*l-o*i*p+t*c*p)*E,e[8]=M*E,e[9]=(g*u*r-h*_*r-g*n*p+t*_*p+h*n*f-t*u*f)*E,e[10]=(o*_*r-g*a*r+g*n*l-t*_*l-o*n*f+t*a*f)*E,e[11]=(h*a*r-o*u*r-h*n*l+t*u*l+o*n*p-t*a*p)*E,e[12]=U*E,e[13]=(h*_*i-g*u*i+g*n*d-t*_*d-h*n*m+t*u*m)*E,e[14]=(g*a*i-o*_*i-g*n*c+t*_*c+o*n*m-t*a*m)*E,e[15]=(o*u*i-h*a*i+h*n*c-t*u*c-o*n*d+t*a*d)*E,this}scale(e){let 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(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],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){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,o=e.x,a=e.y,c=e.z,l=r*o,h=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,h*a+n,h*c-i*o,0,l*c-i*a,h*c+i*o,r*c*c+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,o){return this.set(1,n,r,0,e,1,o,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,h=o+o,u=a+a,d=r*l,p=r*h,g=r*u,_=o*h,m=o*u,f=a*u,T=c*l,A=c*h,M=c*u,U=n.x,w=n.y,E=n.z;return i[0]=(1-(_+f))*U,i[1]=(p+M)*U,i[2]=(g-A)*U,i[3]=0,i[4]=(p-M)*w,i[5]=(1-(d+f))*w,i[6]=(m+T)*w,i[7]=0,i[8]=(g+A)*E,i[9]=(m-T)*E,i[10]=(1-(d+_))*E,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,r=mi.set(i[0],i[1],i[2]).length(),o=mi.set(i[4],i[5],i[6]).length(),a=mi.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],Yt.copy(this);let l=1/r,h=1/o,u=1/a;return Yt.elements[0]*=l,Yt.elements[1]*=l,Yt.elements[2]*=l,Yt.elements[4]*=h,Yt.elements[5]*=h,Yt.elements[6]*=h,Yt.elements[8]*=u,Yt.elements[9]*=u,Yt.elements[10]*=u,t.setFromRotationMatrix(Yt),n.x=r,n.y=o,n.z=a,this}makePerspective(e,t,n,i,r,o,a=vn){let c=this.elements,l=2*r/(t-e),h=2*r/(n-i),u=(t+e)/(t-e),d=(n+i)/(n-i),p,g;if(a===vn)p=-(o+r)/(o-r),g=-2*o*r/(o-r);else if(a===ar)p=-o/(o-r),g=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,o,a=vn){let c=this.elements,l=1/(t-e),h=1/(n-i),u=1/(o-r),d=(t+e)*l,p=(n+i)*h,g,_;if(a===vn)g=(o+r)*u,_=-2*u;else if(a===ar)g=r*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=_,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let 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){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},mi=new L,Yt=new Pe,qu=new L(0,0,0),Yu=new L(1,1,1),Nn=new L,Ds=new L,It=new L,el=new Pe,tl=new Rt,rn=class s{constructor(e=0,t=0,n=0,i=s.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){let i=e.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(vt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-vt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(vt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-vt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(vt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-vt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-h,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 el.makeRotationFromQuaternion(e),this.setFromRotationMatrix(el,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return tl.setFromEuler(this),this.setFromQuaternion(tl,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}};rn.DEFAULT_ORDER="XYZ";var hr=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},Zu=0,nl=new L,gi=new Rt,dn=new Pe,Ns=new L,Qi=new L,Ku=new L,Ju=new Rt,il=new L(1,0,0),sl=new L(0,1,0),rl=new L(0,0,1),ol={type:"added"},$u={type:"removed"},_i={type:"childadded",child:null},to={type:"childremoved",child:null},rt=class s extends Sn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Zu++}),this.uuid=jt(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=s.DEFAULT_UP.clone();let e=new L,t=new rn,n=new Rt,i=new L(1,1,1);function r(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Pe},normalMatrix:{value:new Ie}}),this.matrix=new Pe,this.matrixWorld=new Pe,this.matrixAutoUpdate=s.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new hr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return gi.setFromAxisAngle(e,t),this.quaternion.multiply(gi),this}rotateOnWorldAxis(e,t){return gi.setFromAxisAngle(e,t),this.quaternion.premultiply(gi),this}rotateX(e){return this.rotateOnAxis(il,e)}rotateY(e){return this.rotateOnAxis(sl,e)}rotateZ(e){return this.rotateOnAxis(rl,e)}translateOnAxis(e,t){return nl.copy(e).applyQuaternion(this.quaternion),this.position.add(nl.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(il,e)}translateY(e){return this.translateOnAxis(sl,e)}translateZ(e){return this.translateOnAxis(rl,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(dn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ns.copy(e):Ns.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),Qi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?dn.lookAt(Qi,Ns,this.up):dn.lookAt(Ns,Qi,this.up),this.quaternion.setFromRotationMatrix(dn),i&&(dn.extractRotation(i.matrixWorld),gi.setFromRotationMatrix(dn),this.quaternion.premultiply(gi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(ol),_i.child=e,this.dispatchEvent(_i),_i.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent($u),to.child=e,this.dispatchEvent(to),to.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),dn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),dn.multiply(e.parent.matrixWorld)),e.applyMatrix4(dn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(ol),_i.child=e,this.dispatchEvent(_i),_i.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qi,e,Ku),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qi,Ju,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(e){let t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),i.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,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let u=c[l];r(e.shapes,u)}else r(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(e.materials,this.material[c]));i.material=a}else i.material=r(e.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];i.animations.push(r(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),h=o(e.images),u=o(e.shapes),d=o(e.skeletons),p=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=i,n;function o(a){let c=[];for(let l in a){let h=a[l];delete h.metadata,c.push(h)}return c}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let i=e.children[n];this.add(i.clone())}return this}};rt.DEFAULT_UP=new L(0,1,0);rt.DEFAULT_MATRIX_AUTO_UPDATE=!0;rt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Zt=new L,fn=new L,no=new L,pn=new L,xi=new L,vi=new L,al=new L,io=new L,so=new L,ro=new L,oo=new Xe,ao=new Xe,co=new Xe,ni=class s{constructor(e=new L,t=new L,n=new L){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),Zt.subVectors(e,t),i.cross(Zt);let r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Zt.subVectors(i,t),fn.subVectors(n,t),no.subVectors(e,t);let o=Zt.dot(Zt),a=Zt.dot(fn),c=Zt.dot(no),l=fn.dot(fn),h=fn.dot(no),u=o*l-a*a;if(u===0)return r.set(0,0,0),null;let d=1/u,p=(l*c-a*h)*d,g=(o*h-a*c)*d;return r.set(1-p-g,g,p)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,pn)===null?!1:pn.x>=0&&pn.y>=0&&pn.x+pn.y<=1}static getInterpolation(e,t,n,i,r,o,a,c){return this.getBarycoord(e,t,n,i,pn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,pn.x),c.addScaledVector(o,pn.y),c.addScaledVector(a,pn.z),c)}static getInterpolatedAttribute(e,t,n,i,r,o){return oo.setScalar(0),ao.setScalar(0),co.setScalar(0),oo.fromBufferAttribute(e,t),ao.fromBufferAttribute(e,n),co.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(oo,r.x),o.addScaledVector(ao,r.y),o.addScaledVector(co,r.z),o}static isFrontFacing(e,t,n,i){return Zt.subVectors(n,t),fn.subVectors(e,t),Zt.cross(fn).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 Zt.subVectors(this.c,this.b),fn.subVectors(this.a,this.b),Zt.cross(fn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return s.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return s.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return s.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return s.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return s.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,i=this.b,r=this.c,o,a;xi.subVectors(i,n),vi.subVectors(r,n),io.subVectors(e,n);let c=xi.dot(io),l=vi.dot(io);if(c<=0&&l<=0)return t.copy(n);so.subVectors(e,i);let h=xi.dot(so),u=vi.dot(so);if(h>=0&&u<=h)return t.copy(i);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return o=c/(c-h),t.copy(n).addScaledVector(xi,o);ro.subVectors(e,r);let p=xi.dot(ro),g=vi.dot(ro);if(g>=0&&p<=g)return t.copy(r);let _=p*l-c*g;if(_<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(n).addScaledVector(vi,a);let m=h*g-p*u;if(m<=0&&u-h>=0&&p-g>=0)return al.subVectors(r,i),a=(u-h)/(u-h+(p-g)),t.copy(i).addScaledVector(al,a);let f=1/(m+_+d);return o=_*f,a=d*f,t.copy(n).addScaledVector(xi,o).addScaledVector(vi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},vh={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},Un={h:0,s:0,l:0},Us={h:0,s:0,l:0};function lo(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}var Se=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let 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=lt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Fe.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Fe.workingColorSpace){return this.r=e,this.g=t,this.b=n,Fe.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Fe.workingColorSpace){if(e=$a(e,1),t=vt(t,0,1),n=vt(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,o=2*n-r;this.r=lo(o,r,e+1/3),this.g=lo(o,r,e),this.b=lo(o,r,e-1/3)}return Fe.toWorkingColorSpace(this,i),this}setStyle(e,t=lt){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,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)){let 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=lt){let n=vh[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=yn(e.r),this.g=yn(e.g),this.b=yn(e.b),this}copyLinearToSRGB(e){return this.r=Pi(e.r),this.g=Pi(e.g),this.b=Pi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=lt){return Fe.fromWorkingColorSpace(xt.copy(this),e),Math.round(vt(xt.r*255,0,255))*65536+Math.round(vt(xt.g*255,0,255))*256+Math.round(vt(xt.b*255,0,255))}getHexString(e=lt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Fe.workingColorSpace){Fe.fromWorkingColorSpace(xt.copy(this),t);let n=xt.r,i=xt.g,r=xt.b,o=Math.max(n,i,r),a=Math.min(n,i,r),c,l,h=(a+o)/2;if(a===o)c=0,l=0;else{let u=o-a;switch(l=h<=.5?u/(o+a):u/(2-o-a),o){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return e.h=c,e.s=l,e.l=h,e}getRGB(e,t=Fe.workingColorSpace){return Fe.fromWorkingColorSpace(xt.copy(this),t),e.r=xt.r,e.g=xt.g,e.b=xt.b,e}getStyle(e=lt){Fe.fromWorkingColorSpace(xt.copy(this),e);let t=xt.r,n=xt.g,i=xt.b;return e!==lt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(e,t,n){return this.getHSL(Un),this.setHSL(Un.h+e,Un.s+t,Un.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Un),e.getHSL(Us);let n=ls(Un.h,Us.h,t),i=ls(Un.s,Us.s,t),r=ls(Un.l,Us.l,t);return this.setHSL(n,i,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,i=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*i,this.g=r[1]*t+r[4]*n+r[7]*i,this.b=r[2]*t+r[5]*n+r[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},xt=new Se;Se.NAMES=vh;var ju=0,Dt=class extends Sn{static get type(){return"Material"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ju++}),this.uuid=jt(),this.name="",this.blending=Ci,this.side=sn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=To,this.blendDst=Eo,this.blendEquation=ti,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Se(0,0,0),this.blendAlpha=0,this.depthFunc=Di,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Wc,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=hi,this.stencilZFail=hi,this.stencilZPass=hi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let 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){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let 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!==Ci&&(n.blending=this.blending),this.side!==sn&&(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!==To&&(n.blendSrc=this.blendSrc),this.blendDst!==Eo&&(n.blendDst=this.blendDst),this.blendEquation!==ti&&(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!==Di&&(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!==Wc&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==hi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==hi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==hi&&(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){let o=[];for(let a in r){let c=r[a];delete c.metadata,o.push(c)}return o}if(t){let 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;let t=e.clippingPlanes,n=null;if(t!==null){let 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.")}},on=class extends Dt{static get type(){return"MeshBasicMaterial"}constructor(e){super(),this.isMeshBasicMaterial=!0,this.color=new Se(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 rn,this.combine=ih,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}};var ct=new L,Os=new Be,ut=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=ca,this.updateRanges=[],this.gpuType=$t,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;i<r;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Os.fromBufferAttribute(this,t),Os.applyMatrix3(e),this.setXY(t,Os.x,Os.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.applyMatrix3(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.applyMatrix4(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.applyNormalMatrix(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ct.fromBufferAttribute(this,t),ct.transformDirection(e),this.setXYZ(t,ct.x,ct.y,ct.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=Jt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Ke(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Jt(t,this.array)),t}setX(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Jt(t,this.array)),t}setY(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Jt(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Jt(t,this.array)),t}setW(e,t){return this.normalized&&(t=Ke(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),n=Ke(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),n=Ke(n,this.array),i=Ke(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=Ke(t,this.array),n=Ke(n,this.array),i=Ke(i,this.array),r=Ke(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==ca&&(e.usage=this.usage),e}};var ur=class extends ut{constructor(e,t,n){super(new Uint16Array(e),t,n)}};var dr=class extends ut{constructor(e,t,n){super(new Uint32Array(e),t,n)}};var zt=class extends ut{constructor(e,t,n){super(new Float32Array(e),t,n)}},Qu=0,Ft=new Pe,ho=new rt,yi=new L,Pt=new kt,es=new kt,pt=new L,Vt=class s extends Sn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Qu++}),this.uuid=jt(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(xh(e)?dr:ur)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Ie().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Ft.makeRotationFromQuaternion(e),this.applyMatrix4(Ft),this}rotateX(e){return Ft.makeRotationX(e),this.applyMatrix4(Ft),this}rotateY(e){return Ft.makeRotationY(e),this.applyMatrix4(Ft),this}rotateZ(e){return Ft.makeRotationZ(e),this.applyMatrix4(Ft),this}translate(e,t,n){return Ft.makeTranslation(e,t,n),this.applyMatrix4(Ft),this}scale(e,t,n){return Ft.makeScale(e,t,n),this.applyMatrix4(Ft),this}lookAt(e){return ho.lookAt(e),ho.updateMatrix(),this.applyMatrix4(ho.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let i=0,r=e.length;i<r;i++){let o=e[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new zt(n,3))}else{for(let n=0,i=t.count;n<i;n++){let r=e[n];t.setXYZ(n,r.x,r.y,r.z||0)}e.length>t.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 kt);let 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 L(-1/0,-1/0,-1/0),new L(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,i=t.length;n<i;n++){let r=t[n];Pt.setFromBufferAttribute(r),this.morphTargetsRelative?(pt.addVectors(this.boundingBox.min,Pt.min),this.boundingBox.expandByPoint(pt),pt.addVectors(this.boundingBox.max,Pt.max),this.boundingBox.expandByPoint(pt)):(this.boundingBox.expandByPoint(Pt.min),this.boundingBox.expandByPoint(Pt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Lt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new L,1/0);return}if(e){let n=this.boundingSphere.center;if(Pt.setFromBufferAttribute(e),t)for(let r=0,o=t.length;r<o;r++){let a=t[r];es.setFromBufferAttribute(a),this.morphTargetsRelative?(pt.addVectors(Pt.min,es.min),Pt.expandByPoint(pt),pt.addVectors(Pt.max,es.max),Pt.expandByPoint(pt)):(Pt.expandByPoint(es.min),Pt.expandByPoint(es.max))}Pt.getCenter(n);let i=0;for(let r=0,o=e.count;r<o;r++)pt.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(pt));if(t)for(let r=0,o=t.length;r<o;r++){let a=t[r],c=this.morphTargetsRelative;for(let l=0,h=a.count;l<h;l++)pt.fromBufferAttribute(a,l),c&&(yi.fromBufferAttribute(e,l),pt.add(yi)),i=Math.max(i,n.distanceToSquared(pt))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,i=t.normal,r=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ut(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let N=0;N<n.count;N++)a[N]=new L,c[N]=new L;let l=new L,h=new L,u=new L,d=new Be,p=new Be,g=new Be,_=new L,m=new L;function f(N,S,y){l.fromBufferAttribute(n,N),h.fromBufferAttribute(n,S),u.fromBufferAttribute(n,y),d.fromBufferAttribute(r,N),p.fromBufferAttribute(r,S),g.fromBufferAttribute(r,y),h.sub(l),u.sub(l),p.sub(d),g.sub(d);let R=1/(p.x*g.y-g.x*p.y);isFinite(R)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(u,-p.y).multiplyScalar(R),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(R),a[N].add(_),a[S].add(_),a[y].add(_),c[N].add(m),c[S].add(m),c[y].add(m))}let T=this.groups;T.length===0&&(T=[{start:0,count:e.count}]);for(let N=0,S=T.length;N<S;++N){let y=T[N],R=y.start,q=y.count;for(let z=R,W=R+q;z<W;z+=3)f(e.getX(z+0),e.getX(z+1),e.getX(z+2))}let A=new L,M=new L,U=new L,w=new L;function E(N){U.fromBufferAttribute(i,N),w.copy(U);let S=a[N];A.copy(S),A.sub(U.multiplyScalar(U.dot(S))).normalize(),M.crossVectors(w,S);let R=M.dot(c[N])<0?-1:1;o.setXYZW(N,A.x,A.y,A.z,R)}for(let N=0,S=T.length;N<S;++N){let y=T[N],R=y.start,q=y.count;for(let z=R,W=R+q;z<W;z+=3)E(e.getX(z+0)),E(e.getX(z+1)),E(e.getX(z+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ut(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);let i=new L,r=new L,o=new L,a=new L,c=new L,l=new L,h=new L,u=new L;if(e)for(let d=0,p=e.count;d<p;d+=3){let g=e.getX(d+0),_=e.getX(d+1),m=e.getX(d+2);i.fromBufferAttribute(t,g),r.fromBufferAttribute(t,_),o.fromBufferAttribute(t,m),h.subVectors(o,r),u.subVectors(i,r),h.cross(u),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,_),l.fromBufferAttribute(n,m),a.add(h),c.add(h),l.add(h),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(_,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,p=t.count;d<p;d+=3)i.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),h.subVectors(o,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)pt.fromBufferAttribute(e,t),pt.normalize(),e.setXYZ(t,pt.x,pt.y,pt.z)}toNonIndexed(){function e(a,c){let l=a.array,h=a.itemSize,u=a.normalized,d=new l.constructor(c.length*h),p=0,g=0;for(let _=0,m=c.length;_<m;_++){a.isInterleavedBufferAttribute?p=c[_]*a.data.stride+a.offset:p=c[_]*h;for(let f=0;f<h;f++)d[g++]=l[p++]}return new ut(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new s,n=this.index.array,i=this.attributes;for(let a in i){let c=i[a],l=e(c,n);t.setAttribute(a,l)}let r=this.morphAttributes;for(let a in r){let c=[],l=r[a];for(let h=0,u=l.length;h<u;h++){let d=l[h],p=e(d,n);c.push(p)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let i={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){let p=l[u];h.push(p.toJSON(e.data))}h.length>0&&(i[c]=h,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={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;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let i=e.attributes;for(let l in i){let h=i[l];this.setAttribute(l,h.clone(t))}let r=e.morphAttributes;for(let l in r){let h=[],u=r[l];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(t));this.morphAttributes[l]=h}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,h=o.length;l<h;l++){let u=o[l];this.addGroup(u.start,u.count,u.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},cl=new Pe,Jn=new Vi,Fs=new Lt,ll=new L,Bs=new L,zs=new L,ks=new L,uo=new L,Vs=new L,hl=new L,Hs=new L,yt=class extends rt{constructor(e=new Vt,t=new on){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(e,t){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(i,e);let a=this.morphTargetInfluences;if(r&&a){Vs.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=a[c],u=r[c];h!==0&&(uo.fromBufferAttribute(u,e),o?Vs.addScaledVector(uo,h):Vs.addScaledVector(uo.sub(t),h))}t.add(Vs)}return t}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Fs.copy(n.boundingSphere),Fs.applyMatrix4(r),Jn.copy(e.ray).recast(e.near),!(Fs.containsPoint(Jn.origin)===!1&&(Jn.intersectSphere(Fs,ll)===null||Jn.origin.distanceToSquared(ll)>(e.far-e.near)**2))&&(cl.copy(r).invert(),Jn.copy(e.ray).applyMatrix4(cl),!(n.boundingBox!==null&&Jn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Jn)))}_computeIntersections(e,t,n){let i,r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,_=d.length;g<_;g++){let m=d[g],f=o[m.materialIndex],T=Math.max(m.start,p.start),A=Math.min(a.count,Math.min(m.start+m.count,p.start+p.count));for(let M=T,U=A;M<U;M+=3){let w=a.getX(M),E=a.getX(M+1),N=a.getX(M+2);i=Gs(this,f,e,n,l,h,u,w,E,N),i&&(i.faceIndex=Math.floor(M/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{let g=Math.max(0,p.start),_=Math.min(a.count,p.start+p.count);for(let m=g,f=_;m<f;m+=3){let T=a.getX(m),A=a.getX(m+1),M=a.getX(m+2);i=Gs(this,o,e,n,l,h,u,T,A,M),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,_=d.length;g<_;g++){let m=d[g],f=o[m.materialIndex],T=Math.max(m.start,p.start),A=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let M=T,U=A;M<U;M+=3){let w=M,E=M+1,N=M+2;i=Gs(this,f,e,n,l,h,u,w,E,N),i&&(i.faceIndex=Math.floor(M/3),i.face.materialIndex=m.materialIndex,t.push(i))}}else{let g=Math.max(0,p.start),_=Math.min(c.count,p.start+p.count);for(let m=g,f=_;m<f;m+=3){let T=m,A=m+1,M=m+2;i=Gs(this,o,e,n,l,h,u,T,A,M),i&&(i.faceIndex=Math.floor(m/3),t.push(i))}}}};function ed(s,e,t,n,i,r,o,a){let c;if(e.side===wt?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,e.side===sn,a),c===null)return null;Hs.copy(a),Hs.applyMatrix4(s.matrixWorld);let l=t.ray.origin.distanceTo(Hs);return l<t.near||l>t.far?null:{distance:l,point:Hs.clone(),object:s}}function Gs(s,e,t,n,i,r,o,a,c,l){s.getVertexPosition(a,Bs),s.getVertexPosition(c,zs),s.getVertexPosition(l,ks);let h=ed(s,e,t,n,Bs,zs,ks,hl);if(h){let u=new L;ni.getBarycoord(hl,Bs,zs,ks,u),i&&(h.uv=ni.getInterpolatedAttribute(i,a,c,l,u,new Be)),r&&(h.uv1=ni.getInterpolatedAttribute(r,a,c,l,u,new Be)),o&&(h.normal=ni.getInterpolatedAttribute(o,a,c,l,u,new L),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new L,materialIndex:0};ni.getNormal(Bs,zs,ks,d.normal),h.face=d,h.barycoord=u}return h}var ps=class s extends Vt{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};let a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);let c=[],l=[],h=[],u=[],d=0,p=0;g("z","y","x",-1,-1,n,t,e,o,r,0),g("z","y","x",1,-1,n,t,-e,o,r,1),g("x","z","y",1,1,e,n,t,i,o,2),g("x","z","y",1,-1,e,n,-t,i,o,3),g("x","y","z",1,-1,e,t,n,i,r,4),g("x","y","z",-1,-1,e,t,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new zt(l,3)),this.setAttribute("normal",new zt(h,3)),this.setAttribute("uv",new zt(u,2));function g(_,m,f,T,A,M,U,w,E,N,S){let y=M/E,R=U/N,q=M/2,z=U/2,W=w/2,J=E+1,H=N+1,Q=0,V=0,ie=new L;for(let le=0;le<H;le++){let ve=le*R-z;for(let Ne=0;Ne<J;Ne++){let $e=Ne*y-q;ie[_]=$e*T,ie[m]=ve*A,ie[f]=W,l.push(ie.x,ie.y,ie.z),ie[_]=0,ie[m]=0,ie[f]=w>0?1:-1,h.push(ie.x,ie.y,ie.z),u.push(Ne/E),u.push(1-le/N),Q+=1}}for(let le=0;le<N;le++)for(let ve=0;ve<E;ve++){let Ne=d+ve+J*le,$e=d+ve+J*(le+1),X=d+(ve+1)+J*(le+1),ee=d+(ve+1)+J*le;c.push(Ne,$e,ee),c.push($e,X,ee),V+=6}a.addGroup(p,V,S),p+=V,d+=Q}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new s(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Hi(s){let e={};for(let t in s){e[t]={};for(let n in s[t]){let i=s[t][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=i.clone():Array.isArray(i)?e[t][n]=i.slice():e[t][n]=i}}return e}function At(s){let e={};for(let t=0;t<s.length;t++){let n=Hi(s[t]);for(let i in n)e[i]=n[i]}return e}function td(s){let e=[];for(let t=0;t<s.length;t++)e.push(s[t].clone());return e}function yh(s){let e=s.getRenderTarget();return e===null?s.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Fe.workingColorSpace}var nd={clone:Hi,merge:At},id=`void main() {
|
|
2
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
|
+
}`,sd=`void main() {
|
|
4
|
+
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
5
|
+
}`,an=class extends Dt{static get type(){return"ShaderMaterial"}constructor(e){super(),this.isShaderMaterial=!0,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=id,this.fragmentShader=sd,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Hi(e.uniforms),this.uniformsGroups=td(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let i in this.uniforms){let o=this.uniforms[i].value;o&&o.isTexture?t.uniforms[i]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[i]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[i]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[i]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[i]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[i]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[i]={type:"m4",value:o.toArray()}:t.uniforms[i]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},fr=class extends rt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Pe,this.projectionMatrix=new Pe,this.projectionMatrixInverse=new Pe,this.coordinateSystem=vn}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)}},On=new L,ul=new Be,dl=new Be,ht=class extends fr{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){let t=.5*this.getFilmHeight()/e;this.fov=ki*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(cs*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ki*2*Math.atan(Math.tan(cs*.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){On.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(On.x,On.y).multiplyScalar(-e/On.z),On.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(On.x,On.y).multiplyScalar(-e/On.z)}getViewSize(e,t){return this.getViewBounds(e,ul,dl),t.subVectors(dl,ul)}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(){let e=this.near,t=e*Math.tan(cs*.5*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;r+=o.offsetX*i/c,t-=o.offsetY*n/l,i*=o.width/c,n*=o.height/l}let 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){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Mi=-90,Si=1,da=class extends rt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new ht(Mi,Si,e,t);i.layers=this.layers,this.add(i);let r=new ht(Mi,Si,e,t);r.layers=this.layers,this.add(r);let o=new ht(Mi,Si,e,t);o.layers=this.layers,this.add(o);let a=new ht(Mi,Si,e,t);a.layers=this.layers,this.add(a);let c=new ht(Mi,Si,e,t);c.layers=this.layers,this.add(c);let l=new ht(Mi,Si,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,o,a,c]=t;for(let l of t)this.remove(l);if(e===vn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===ar)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,o,a,c,l,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,o),e.setRenderTarget(n,2,i),e.render(t,a),e.setRenderTarget(n,3,i),e.render(t,c),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=_,e.setRenderTarget(n,5,i),e.render(t,h),e.setRenderTarget(u,d,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},pr=class extends mt{constructor(e,t,n,i,r,o,a,c,l,h){e=e!==void 0?e:[],t=t!==void 0?t:Ni,super(e,t,n,i,r,o,a,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},fa=class extends bn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new pr(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:Et}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
6
|
+
|
|
7
|
+
varying vec3 vWorldDirection;
|
|
8
|
+
|
|
9
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
10
|
+
|
|
11
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void main() {
|
|
16
|
+
|
|
17
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
18
|
+
|
|
19
|
+
#include <begin_vertex>
|
|
20
|
+
#include <project_vertex>
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
`,fragmentShader:`
|
|
24
|
+
|
|
25
|
+
uniform sampler2D tEquirect;
|
|
26
|
+
|
|
27
|
+
varying vec3 vWorldDirection;
|
|
28
|
+
|
|
29
|
+
#include <common>
|
|
30
|
+
|
|
31
|
+
void main() {
|
|
32
|
+
|
|
33
|
+
vec3 direction = normalize( vWorldDirection );
|
|
34
|
+
|
|
35
|
+
vec2 sampleUV = equirectUv( direction );
|
|
36
|
+
|
|
37
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
`},i=new ps(5,5,5),r=new an({name:"CubemapFromEquirect",uniforms:Hi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:wt,blending:zn});r.uniforms.tEquirect.value=t;let o=new yt(i,r),a=t.minFilter;return t.minFilter===tn&&(t.minFilter=Et),new da(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let r=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(r)}},fo=new L,rd=new L,od=new Ie,_n=class{constructor(e=new L(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=fo.subVectors(n,t).cross(rd.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(fo),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||od.getNormalMatrix(e),i=this.coplanarPoint(fo).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)}},$n=new Lt,Ws=new L,ms=class{constructor(e=new _n,t=new _n,n=new _n,i=new _n,r=new _n,o=new _n){this.planes=[e,t,n,i,r,o]}set(e,t,n,i,r,o){let 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){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=vn){let n=this.planes,i=e.elements,r=i[0],o=i[1],a=i[2],c=i[3],l=i[4],h=i[5],u=i[6],d=i[7],p=i[8],g=i[9],_=i[10],m=i[11],f=i[12],T=i[13],A=i[14],M=i[15];if(n[0].setComponents(c-r,d-l,m-p,M-f).normalize(),n[1].setComponents(c+r,d+l,m+p,M+f).normalize(),n[2].setComponents(c+o,d+h,m+g,M+T).normalize(),n[3].setComponents(c-o,d-h,m-g,M-T).normalize(),n[4].setComponents(c-a,d-u,m-_,M-A).normalize(),t===vn)n[5].setComponents(c+a,d+u,m+_,M+A).normalize();else if(t===ar)n[5].setComponents(a,u,_,A).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(),$n.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),$n.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere($n)}intersectsSprite(e){return $n.center.set(0,0,0),$n.radius=.7071067811865476,$n.applyMatrix4(e.matrixWorld),this.intersectsSphere($n)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let i=t[n];if(Ws.x=i.normal.x>0?e.max.x:e.min.x,Ws.y=i.normal.y>0?e.max.y:e.min.y,Ws.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ws)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Mh(){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 ad(s){let e=new WeakMap;function t(a,c){let l=a.array,h=a.usage,u=l.byteLength,d=s.createBuffer();s.bindBuffer(c,d),s.bufferData(c,l,h),a.onUploadCallback();let p;if(l instanceof Float32Array)p=s.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=s.SHORT;else if(l instanceof Uint32Array)p=s.UNSIGNED_INT;else if(l instanceof Int32Array)p=s.INT;else if(l instanceof Int8Array)p=s.BYTE;else if(l instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:u}}function n(a,c,l){let h=c.array,u=c.updateRanges;if(s.bindBuffer(l,a),u.length===0)s.bufferSubData(l,0,h);else{u.sort((p,g)=>p.start-g.start);let d=0;for(let p=1;p<u.length;p++){let g=u[d],_=u[p];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,u[d]=_)}u.length=d+1;for(let p=0,g=u.length;p<g;p++){let _=u[p];s.bufferSubData(l,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(s.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let h=e.get(a);(!h||h.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:i,remove:r,update:o}}var mr=class s extends Vt{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};let r=e/2,o=t/2,a=Math.floor(n),c=Math.floor(i),l=a+1,h=c+1,u=e/a,d=t/c,p=[],g=[],_=[],m=[];for(let f=0;f<h;f++){let T=f*d-o;for(let A=0;A<l;A++){let M=A*u-r;g.push(M,-T,0),_.push(0,0,1),m.push(A/a),m.push(1-f/c)}}for(let f=0;f<c;f++)for(let T=0;T<a;T++){let A=T+l*f,M=T+l*(f+1),U=T+1+l*(f+1),w=T+1+l*f;p.push(A,M,w),p.push(M,U,w)}this.setIndex(p),this.setAttribute("position",new zt(g,3)),this.setAttribute("normal",new zt(_,3)),this.setAttribute("uv",new zt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new s(e.width,e.height,e.widthSegments,e.heightSegments)}},cd=`#ifdef USE_ALPHAHASH
|
|
41
|
+
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
42
|
+
#endif`,ld=`#ifdef USE_ALPHAHASH
|
|
43
|
+
const float ALPHA_HASH_SCALE = 0.05;
|
|
44
|
+
float hash2D( vec2 value ) {
|
|
45
|
+
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
46
|
+
}
|
|
47
|
+
float hash3D( vec3 value ) {
|
|
48
|
+
return hash2D( vec2( hash2D( value.xy ), value.z ) );
|
|
49
|
+
}
|
|
50
|
+
float getAlphaHashThreshold( vec3 position ) {
|
|
51
|
+
float maxDeriv = max(
|
|
52
|
+
length( dFdx( position.xyz ) ),
|
|
53
|
+
length( dFdy( position.xyz ) )
|
|
54
|
+
);
|
|
55
|
+
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
|
|
56
|
+
vec2 pixScales = vec2(
|
|
57
|
+
exp2( floor( log2( pixScale ) ) ),
|
|
58
|
+
exp2( ceil( log2( pixScale ) ) )
|
|
59
|
+
);
|
|
60
|
+
vec2 alpha = vec2(
|
|
61
|
+
hash3D( floor( pixScales.x * position.xyz ) ),
|
|
62
|
+
hash3D( floor( pixScales.y * position.xyz ) )
|
|
63
|
+
);
|
|
64
|
+
float lerpFactor = fract( log2( pixScale ) );
|
|
65
|
+
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
|
|
66
|
+
float a = min( lerpFactor, 1.0 - lerpFactor );
|
|
67
|
+
vec3 cases = vec3(
|
|
68
|
+
x * x / ( 2.0 * a * ( 1.0 - a ) ),
|
|
69
|
+
( x - 0.5 * a ) / ( 1.0 - a ),
|
|
70
|
+
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
|
|
71
|
+
);
|
|
72
|
+
float threshold = ( x < ( 1.0 - a ) )
|
|
73
|
+
? ( ( x < a ) ? cases.x : cases.y )
|
|
74
|
+
: cases.z;
|
|
75
|
+
return clamp( threshold , 1.0e-6, 1.0 );
|
|
76
|
+
}
|
|
77
|
+
#endif`,hd=`#ifdef USE_ALPHAMAP
|
|
78
|
+
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
79
|
+
#endif`,ud=`#ifdef USE_ALPHAMAP
|
|
80
|
+
uniform sampler2D alphaMap;
|
|
81
|
+
#endif`,dd=`#ifdef USE_ALPHATEST
|
|
82
|
+
#ifdef ALPHA_TO_COVERAGE
|
|
83
|
+
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
84
|
+
if ( diffuseColor.a == 0.0 ) discard;
|
|
85
|
+
#else
|
|
86
|
+
if ( diffuseColor.a < alphaTest ) discard;
|
|
87
|
+
#endif
|
|
88
|
+
#endif`,fd=`#ifdef USE_ALPHATEST
|
|
89
|
+
uniform float alphaTest;
|
|
90
|
+
#endif`,pd=`#ifdef USE_AOMAP
|
|
91
|
+
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
92
|
+
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
93
|
+
#if defined( USE_CLEARCOAT )
|
|
94
|
+
clearcoatSpecularIndirect *= ambientOcclusion;
|
|
95
|
+
#endif
|
|
96
|
+
#if defined( USE_SHEEN )
|
|
97
|
+
sheenSpecularIndirect *= ambientOcclusion;
|
|
98
|
+
#endif
|
|
99
|
+
#if defined( USE_ENVMAP ) && defined( STANDARD )
|
|
100
|
+
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
101
|
+
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
102
|
+
#endif
|
|
103
|
+
#endif`,md=`#ifdef USE_AOMAP
|
|
104
|
+
uniform sampler2D aoMap;
|
|
105
|
+
uniform float aoMapIntensity;
|
|
106
|
+
#endif`,gd=`#ifdef USE_BATCHING
|
|
107
|
+
#if ! defined( GL_ANGLE_multi_draw )
|
|
108
|
+
#define gl_DrawID _gl_DrawID
|
|
109
|
+
uniform int _gl_DrawID;
|
|
110
|
+
#endif
|
|
111
|
+
uniform highp sampler2D batchingTexture;
|
|
112
|
+
uniform highp usampler2D batchingIdTexture;
|
|
113
|
+
mat4 getBatchingMatrix( const in float i ) {
|
|
114
|
+
int size = textureSize( batchingTexture, 0 ).x;
|
|
115
|
+
int j = int( i ) * 4;
|
|
116
|
+
int x = j % size;
|
|
117
|
+
int y = j / size;
|
|
118
|
+
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
|
|
119
|
+
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
|
|
120
|
+
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
|
|
121
|
+
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
|
|
122
|
+
return mat4( v1, v2, v3, v4 );
|
|
123
|
+
}
|
|
124
|
+
float getIndirectIndex( const in int i ) {
|
|
125
|
+
int size = textureSize( batchingIdTexture, 0 ).x;
|
|
126
|
+
int x = i % size;
|
|
127
|
+
int y = i / size;
|
|
128
|
+
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
|
|
129
|
+
}
|
|
130
|
+
#endif
|
|
131
|
+
#ifdef USE_BATCHING_COLOR
|
|
132
|
+
uniform sampler2D batchingColorTexture;
|
|
133
|
+
vec3 getBatchingColor( const in float i ) {
|
|
134
|
+
int size = textureSize( batchingColorTexture, 0 ).x;
|
|
135
|
+
int j = int( i );
|
|
136
|
+
int x = j % size;
|
|
137
|
+
int y = j / size;
|
|
138
|
+
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
|
|
139
|
+
}
|
|
140
|
+
#endif`,_d=`#ifdef USE_BATCHING
|
|
141
|
+
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
142
|
+
#endif`,xd=`vec3 transformed = vec3( position );
|
|
143
|
+
#ifdef USE_ALPHAHASH
|
|
144
|
+
vPosition = vec3( position );
|
|
145
|
+
#endif`,vd=`vec3 objectNormal = vec3( normal );
|
|
146
|
+
#ifdef USE_TANGENT
|
|
147
|
+
vec3 objectTangent = vec3( tangent.xyz );
|
|
148
|
+
#endif`,yd=`float G_BlinnPhong_Implicit( ) {
|
|
149
|
+
return 0.25;
|
|
150
|
+
}
|
|
151
|
+
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
152
|
+
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
|
|
153
|
+
}
|
|
154
|
+
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
|
|
155
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
156
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
157
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
158
|
+
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
|
|
159
|
+
float G = G_BlinnPhong_Implicit( );
|
|
160
|
+
float D = D_BlinnPhong( shininess, dotNH );
|
|
161
|
+
return F * ( G * D );
|
|
162
|
+
} // validated`,Md=`#ifdef USE_IRIDESCENCE
|
|
163
|
+
const mat3 XYZ_TO_REC709 = mat3(
|
|
164
|
+
3.2404542, -0.9692660, 0.0556434,
|
|
165
|
+
-1.5371385, 1.8760108, -0.2040259,
|
|
166
|
+
-0.4985314, 0.0415560, 1.0572252
|
|
167
|
+
);
|
|
168
|
+
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
|
|
169
|
+
vec3 sqrtF0 = sqrt( fresnel0 );
|
|
170
|
+
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
|
|
171
|
+
}
|
|
172
|
+
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
|
|
173
|
+
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
|
|
174
|
+
}
|
|
175
|
+
float IorToFresnel0( float transmittedIor, float incidentIor ) {
|
|
176
|
+
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
|
|
177
|
+
}
|
|
178
|
+
vec3 evalSensitivity( float OPD, vec3 shift ) {
|
|
179
|
+
float phase = 2.0 * PI * OPD * 1.0e-9;
|
|
180
|
+
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
|
|
181
|
+
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
|
|
182
|
+
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
|
|
183
|
+
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
|
|
184
|
+
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
|
|
185
|
+
xyz /= 1.0685e-7;
|
|
186
|
+
vec3 rgb = XYZ_TO_REC709 * xyz;
|
|
187
|
+
return rgb;
|
|
188
|
+
}
|
|
189
|
+
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
|
|
190
|
+
vec3 I;
|
|
191
|
+
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
|
|
192
|
+
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
|
|
193
|
+
float cosTheta2Sq = 1.0 - sinTheta2Sq;
|
|
194
|
+
if ( cosTheta2Sq < 0.0 ) {
|
|
195
|
+
return vec3( 1.0 );
|
|
196
|
+
}
|
|
197
|
+
float cosTheta2 = sqrt( cosTheta2Sq );
|
|
198
|
+
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
|
|
199
|
+
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
|
|
200
|
+
float T121 = 1.0 - R12;
|
|
201
|
+
float phi12 = 0.0;
|
|
202
|
+
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
|
|
203
|
+
float phi21 = PI - phi12;
|
|
204
|
+
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
|
|
205
|
+
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
|
|
206
|
+
vec3 phi23 = vec3( 0.0 );
|
|
207
|
+
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
|
|
208
|
+
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
|
|
209
|
+
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
|
|
210
|
+
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
|
|
211
|
+
vec3 phi = vec3( phi21 ) + phi23;
|
|
212
|
+
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
|
|
213
|
+
vec3 r123 = sqrt( R123 );
|
|
214
|
+
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
|
|
215
|
+
vec3 C0 = R12 + Rs;
|
|
216
|
+
I = C0;
|
|
217
|
+
vec3 Cm = Rs - T121;
|
|
218
|
+
for ( int m = 1; m <= 2; ++ m ) {
|
|
219
|
+
Cm *= r123;
|
|
220
|
+
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
|
|
221
|
+
I += Cm * Sm;
|
|
222
|
+
}
|
|
223
|
+
return max( I, vec3( 0.0 ) );
|
|
224
|
+
}
|
|
225
|
+
#endif`,Sd=`#ifdef USE_BUMPMAP
|
|
226
|
+
uniform sampler2D bumpMap;
|
|
227
|
+
uniform float bumpScale;
|
|
228
|
+
vec2 dHdxy_fwd() {
|
|
229
|
+
vec2 dSTdx = dFdx( vBumpMapUv );
|
|
230
|
+
vec2 dSTdy = dFdy( vBumpMapUv );
|
|
231
|
+
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
|
|
232
|
+
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
|
|
233
|
+
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
|
|
234
|
+
return vec2( dBx, dBy );
|
|
235
|
+
}
|
|
236
|
+
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
|
|
237
|
+
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
|
|
238
|
+
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
|
|
239
|
+
vec3 vN = surf_norm;
|
|
240
|
+
vec3 R1 = cross( vSigmaY, vN );
|
|
241
|
+
vec3 R2 = cross( vN, vSigmaX );
|
|
242
|
+
float fDet = dot( vSigmaX, R1 ) * faceDirection;
|
|
243
|
+
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
244
|
+
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
245
|
+
}
|
|
246
|
+
#endif`,bd=`#if NUM_CLIPPING_PLANES > 0
|
|
247
|
+
vec4 plane;
|
|
248
|
+
#ifdef ALPHA_TO_COVERAGE
|
|
249
|
+
float distanceToPlane, distanceGradient;
|
|
250
|
+
float clipOpacity = 1.0;
|
|
251
|
+
#pragma unroll_loop_start
|
|
252
|
+
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
253
|
+
plane = clippingPlanes[ i ];
|
|
254
|
+
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
255
|
+
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
256
|
+
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
257
|
+
if ( clipOpacity == 0.0 ) discard;
|
|
258
|
+
}
|
|
259
|
+
#pragma unroll_loop_end
|
|
260
|
+
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
261
|
+
float unionClipOpacity = 1.0;
|
|
262
|
+
#pragma unroll_loop_start
|
|
263
|
+
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
264
|
+
plane = clippingPlanes[ i ];
|
|
265
|
+
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
|
|
266
|
+
distanceGradient = fwidth( distanceToPlane ) / 2.0;
|
|
267
|
+
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
|
|
268
|
+
}
|
|
269
|
+
#pragma unroll_loop_end
|
|
270
|
+
clipOpacity *= 1.0 - unionClipOpacity;
|
|
271
|
+
#endif
|
|
272
|
+
diffuseColor.a *= clipOpacity;
|
|
273
|
+
if ( diffuseColor.a == 0.0 ) discard;
|
|
274
|
+
#else
|
|
275
|
+
#pragma unroll_loop_start
|
|
276
|
+
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
|
|
277
|
+
plane = clippingPlanes[ i ];
|
|
278
|
+
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
|
|
279
|
+
}
|
|
280
|
+
#pragma unroll_loop_end
|
|
281
|
+
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
|
|
282
|
+
bool clipped = true;
|
|
283
|
+
#pragma unroll_loop_start
|
|
284
|
+
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
|
|
285
|
+
plane = clippingPlanes[ i ];
|
|
286
|
+
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
|
|
287
|
+
}
|
|
288
|
+
#pragma unroll_loop_end
|
|
289
|
+
if ( clipped ) discard;
|
|
290
|
+
#endif
|
|
291
|
+
#endif
|
|
292
|
+
#endif`,Ad=`#if NUM_CLIPPING_PLANES > 0
|
|
293
|
+
varying vec3 vClipPosition;
|
|
294
|
+
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
295
|
+
#endif`,Td=`#if NUM_CLIPPING_PLANES > 0
|
|
296
|
+
varying vec3 vClipPosition;
|
|
297
|
+
#endif`,Ed=`#if NUM_CLIPPING_PLANES > 0
|
|
298
|
+
vClipPosition = - mvPosition.xyz;
|
|
299
|
+
#endif`,wd=`#if defined( USE_COLOR_ALPHA )
|
|
300
|
+
diffuseColor *= vColor;
|
|
301
|
+
#elif defined( USE_COLOR )
|
|
302
|
+
diffuseColor.rgb *= vColor;
|
|
303
|
+
#endif`,Rd=`#if defined( USE_COLOR_ALPHA )
|
|
304
|
+
varying vec4 vColor;
|
|
305
|
+
#elif defined( USE_COLOR )
|
|
306
|
+
varying vec3 vColor;
|
|
307
|
+
#endif`,Cd=`#if defined( USE_COLOR_ALPHA )
|
|
308
|
+
varying vec4 vColor;
|
|
309
|
+
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
310
|
+
varying vec3 vColor;
|
|
311
|
+
#endif`,Id=`#if defined( USE_COLOR_ALPHA )
|
|
312
|
+
vColor = vec4( 1.0 );
|
|
313
|
+
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
314
|
+
vColor = vec3( 1.0 );
|
|
315
|
+
#endif
|
|
316
|
+
#ifdef USE_COLOR
|
|
317
|
+
vColor *= color;
|
|
318
|
+
#endif
|
|
319
|
+
#ifdef USE_INSTANCING_COLOR
|
|
320
|
+
vColor.xyz *= instanceColor.xyz;
|
|
321
|
+
#endif
|
|
322
|
+
#ifdef USE_BATCHING_COLOR
|
|
323
|
+
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
324
|
+
vColor.xyz *= batchingColor.xyz;
|
|
325
|
+
#endif`,Pd=`#define PI 3.141592653589793
|
|
326
|
+
#define PI2 6.283185307179586
|
|
327
|
+
#define PI_HALF 1.5707963267948966
|
|
328
|
+
#define RECIPROCAL_PI 0.3183098861837907
|
|
329
|
+
#define RECIPROCAL_PI2 0.15915494309189535
|
|
330
|
+
#define EPSILON 1e-6
|
|
331
|
+
#ifndef saturate
|
|
332
|
+
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
333
|
+
#endif
|
|
334
|
+
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
|
|
335
|
+
float pow2( const in float x ) { return x*x; }
|
|
336
|
+
vec3 pow2( const in vec3 x ) { return x*x; }
|
|
337
|
+
float pow3( const in float x ) { return x*x*x; }
|
|
338
|
+
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
|
|
339
|
+
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
|
|
340
|
+
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
|
|
341
|
+
highp float rand( const in vec2 uv ) {
|
|
342
|
+
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
|
|
343
|
+
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
|
|
344
|
+
return fract( sin( sn ) * c );
|
|
345
|
+
}
|
|
346
|
+
#ifdef HIGH_PRECISION
|
|
347
|
+
float precisionSafeLength( vec3 v ) { return length( v ); }
|
|
348
|
+
#else
|
|
349
|
+
float precisionSafeLength( vec3 v ) {
|
|
350
|
+
float maxComponent = max3( abs( v ) );
|
|
351
|
+
return length( v / maxComponent ) * maxComponent;
|
|
352
|
+
}
|
|
353
|
+
#endif
|
|
354
|
+
struct IncidentLight {
|
|
355
|
+
vec3 color;
|
|
356
|
+
vec3 direction;
|
|
357
|
+
bool visible;
|
|
358
|
+
};
|
|
359
|
+
struct ReflectedLight {
|
|
360
|
+
vec3 directDiffuse;
|
|
361
|
+
vec3 directSpecular;
|
|
362
|
+
vec3 indirectDiffuse;
|
|
363
|
+
vec3 indirectSpecular;
|
|
364
|
+
};
|
|
365
|
+
#ifdef USE_ALPHAHASH
|
|
366
|
+
varying vec3 vPosition;
|
|
367
|
+
#endif
|
|
368
|
+
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
|
|
369
|
+
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
|
|
370
|
+
}
|
|
371
|
+
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
|
|
372
|
+
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
|
|
373
|
+
}
|
|
374
|
+
mat3 transposeMat3( const in mat3 m ) {
|
|
375
|
+
mat3 tmp;
|
|
376
|
+
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|
377
|
+
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|
378
|
+
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|
379
|
+
return tmp;
|
|
380
|
+
}
|
|
381
|
+
bool isPerspectiveMatrix( mat4 m ) {
|
|
382
|
+
return m[ 2 ][ 3 ] == - 1.0;
|
|
383
|
+
}
|
|
384
|
+
vec2 equirectUv( in vec3 dir ) {
|
|
385
|
+
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
|
|
386
|
+
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
|
|
387
|
+
return vec2( u, v );
|
|
388
|
+
}
|
|
389
|
+
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
|
|
390
|
+
return RECIPROCAL_PI * diffuseColor;
|
|
391
|
+
}
|
|
392
|
+
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
393
|
+
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
394
|
+
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
395
|
+
}
|
|
396
|
+
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
397
|
+
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
398
|
+
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
399
|
+
} // validated`,Ld=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
400
|
+
#define cubeUV_minMipLevel 4.0
|
|
401
|
+
#define cubeUV_minTileSize 16.0
|
|
402
|
+
float getFace( vec3 direction ) {
|
|
403
|
+
vec3 absDirection = abs( direction );
|
|
404
|
+
float face = - 1.0;
|
|
405
|
+
if ( absDirection.x > absDirection.z ) {
|
|
406
|
+
if ( absDirection.x > absDirection.y )
|
|
407
|
+
face = direction.x > 0.0 ? 0.0 : 3.0;
|
|
408
|
+
else
|
|
409
|
+
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
410
|
+
} else {
|
|
411
|
+
if ( absDirection.z > absDirection.y )
|
|
412
|
+
face = direction.z > 0.0 ? 2.0 : 5.0;
|
|
413
|
+
else
|
|
414
|
+
face = direction.y > 0.0 ? 1.0 : 4.0;
|
|
415
|
+
}
|
|
416
|
+
return face;
|
|
417
|
+
}
|
|
418
|
+
vec2 getUV( vec3 direction, float face ) {
|
|
419
|
+
vec2 uv;
|
|
420
|
+
if ( face == 0.0 ) {
|
|
421
|
+
uv = vec2( direction.z, direction.y ) / abs( direction.x );
|
|
422
|
+
} else if ( face == 1.0 ) {
|
|
423
|
+
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
|
|
424
|
+
} else if ( face == 2.0 ) {
|
|
425
|
+
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
|
|
426
|
+
} else if ( face == 3.0 ) {
|
|
427
|
+
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
|
|
428
|
+
} else if ( face == 4.0 ) {
|
|
429
|
+
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
|
|
430
|
+
} else {
|
|
431
|
+
uv = vec2( direction.x, direction.y ) / abs( direction.z );
|
|
432
|
+
}
|
|
433
|
+
return 0.5 * ( uv + 1.0 );
|
|
434
|
+
}
|
|
435
|
+
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
|
|
436
|
+
float face = getFace( direction );
|
|
437
|
+
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
|
|
438
|
+
mipInt = max( mipInt, cubeUV_minMipLevel );
|
|
439
|
+
float faceSize = exp2( mipInt );
|
|
440
|
+
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
|
|
441
|
+
if ( face > 2.0 ) {
|
|
442
|
+
uv.y += faceSize;
|
|
443
|
+
face -= 3.0;
|
|
444
|
+
}
|
|
445
|
+
uv.x += face * faceSize;
|
|
446
|
+
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
|
|
447
|
+
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
|
|
448
|
+
uv.x *= CUBEUV_TEXEL_WIDTH;
|
|
449
|
+
uv.y *= CUBEUV_TEXEL_HEIGHT;
|
|
450
|
+
#ifdef texture2DGradEXT
|
|
451
|
+
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
|
|
452
|
+
#else
|
|
453
|
+
return texture2D( envMap, uv ).rgb;
|
|
454
|
+
#endif
|
|
455
|
+
}
|
|
456
|
+
#define cubeUV_r0 1.0
|
|
457
|
+
#define cubeUV_m0 - 2.0
|
|
458
|
+
#define cubeUV_r1 0.8
|
|
459
|
+
#define cubeUV_m1 - 1.0
|
|
460
|
+
#define cubeUV_r4 0.4
|
|
461
|
+
#define cubeUV_m4 2.0
|
|
462
|
+
#define cubeUV_r5 0.305
|
|
463
|
+
#define cubeUV_m5 3.0
|
|
464
|
+
#define cubeUV_r6 0.21
|
|
465
|
+
#define cubeUV_m6 4.0
|
|
466
|
+
float roughnessToMip( float roughness ) {
|
|
467
|
+
float mip = 0.0;
|
|
468
|
+
if ( roughness >= cubeUV_r1 ) {
|
|
469
|
+
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
|
|
470
|
+
} else if ( roughness >= cubeUV_r4 ) {
|
|
471
|
+
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
|
|
472
|
+
} else if ( roughness >= cubeUV_r5 ) {
|
|
473
|
+
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
|
|
474
|
+
} else if ( roughness >= cubeUV_r6 ) {
|
|
475
|
+
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
|
|
476
|
+
} else {
|
|
477
|
+
mip = - 2.0 * log2( 1.16 * roughness ); }
|
|
478
|
+
return mip;
|
|
479
|
+
}
|
|
480
|
+
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
|
|
481
|
+
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
|
|
482
|
+
float mipF = fract( mip );
|
|
483
|
+
float mipInt = floor( mip );
|
|
484
|
+
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
|
|
485
|
+
if ( mipF == 0.0 ) {
|
|
486
|
+
return vec4( color0, 1.0 );
|
|
487
|
+
} else {
|
|
488
|
+
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
|
|
489
|
+
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
#endif`,Dd=`vec3 transformedNormal = objectNormal;
|
|
493
|
+
#ifdef USE_TANGENT
|
|
494
|
+
vec3 transformedTangent = objectTangent;
|
|
495
|
+
#endif
|
|
496
|
+
#ifdef USE_BATCHING
|
|
497
|
+
mat3 bm = mat3( batchingMatrix );
|
|
498
|
+
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
|
|
499
|
+
transformedNormal = bm * transformedNormal;
|
|
500
|
+
#ifdef USE_TANGENT
|
|
501
|
+
transformedTangent = bm * transformedTangent;
|
|
502
|
+
#endif
|
|
503
|
+
#endif
|
|
504
|
+
#ifdef USE_INSTANCING
|
|
505
|
+
mat3 im = mat3( instanceMatrix );
|
|
506
|
+
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
|
|
507
|
+
transformedNormal = im * transformedNormal;
|
|
508
|
+
#ifdef USE_TANGENT
|
|
509
|
+
transformedTangent = im * transformedTangent;
|
|
510
|
+
#endif
|
|
511
|
+
#endif
|
|
512
|
+
transformedNormal = normalMatrix * transformedNormal;
|
|
513
|
+
#ifdef FLIP_SIDED
|
|
514
|
+
transformedNormal = - transformedNormal;
|
|
515
|
+
#endif
|
|
516
|
+
#ifdef USE_TANGENT
|
|
517
|
+
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
518
|
+
#ifdef FLIP_SIDED
|
|
519
|
+
transformedTangent = - transformedTangent;
|
|
520
|
+
#endif
|
|
521
|
+
#endif`,Nd=`#ifdef USE_DISPLACEMENTMAP
|
|
522
|
+
uniform sampler2D displacementMap;
|
|
523
|
+
uniform float displacementScale;
|
|
524
|
+
uniform float displacementBias;
|
|
525
|
+
#endif`,Ud=`#ifdef USE_DISPLACEMENTMAP
|
|
526
|
+
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
527
|
+
#endif`,Od=`#ifdef USE_EMISSIVEMAP
|
|
528
|
+
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
529
|
+
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
530
|
+
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
531
|
+
#endif
|
|
532
|
+
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
533
|
+
#endif`,Fd=`#ifdef USE_EMISSIVEMAP
|
|
534
|
+
uniform sampler2D emissiveMap;
|
|
535
|
+
#endif`,Bd="gl_FragColor = linearToOutputTexel( gl_FragColor );",zd=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
536
|
+
return value;
|
|
537
|
+
}
|
|
538
|
+
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
539
|
+
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 );
|
|
540
|
+
}
|
|
541
|
+
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
542
|
+
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 );
|
|
543
|
+
}`,kd=`#ifdef USE_ENVMAP
|
|
544
|
+
#ifdef ENV_WORLDPOS
|
|
545
|
+
vec3 cameraToFrag;
|
|
546
|
+
if ( isOrthographic ) {
|
|
547
|
+
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
548
|
+
} else {
|
|
549
|
+
cameraToFrag = normalize( vWorldPosition - cameraPosition );
|
|
550
|
+
}
|
|
551
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
552
|
+
#ifdef ENVMAP_MODE_REFLECTION
|
|
553
|
+
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
|
|
554
|
+
#else
|
|
555
|
+
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
|
|
556
|
+
#endif
|
|
557
|
+
#else
|
|
558
|
+
vec3 reflectVec = vReflect;
|
|
559
|
+
#endif
|
|
560
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
561
|
+
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
|
|
562
|
+
#else
|
|
563
|
+
vec4 envColor = vec4( 0.0 );
|
|
564
|
+
#endif
|
|
565
|
+
#ifdef ENVMAP_BLENDING_MULTIPLY
|
|
566
|
+
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
|
|
567
|
+
#elif defined( ENVMAP_BLENDING_MIX )
|
|
568
|
+
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
|
|
569
|
+
#elif defined( ENVMAP_BLENDING_ADD )
|
|
570
|
+
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
571
|
+
#endif
|
|
572
|
+
#endif`,Vd=`#ifdef USE_ENVMAP
|
|
573
|
+
uniform float envMapIntensity;
|
|
574
|
+
uniform float flipEnvMap;
|
|
575
|
+
uniform mat3 envMapRotation;
|
|
576
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
577
|
+
uniform samplerCube envMap;
|
|
578
|
+
#else
|
|
579
|
+
uniform sampler2D envMap;
|
|
580
|
+
#endif
|
|
581
|
+
|
|
582
|
+
#endif`,Hd=`#ifdef USE_ENVMAP
|
|
583
|
+
uniform float reflectivity;
|
|
584
|
+
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
585
|
+
#define ENV_WORLDPOS
|
|
586
|
+
#endif
|
|
587
|
+
#ifdef ENV_WORLDPOS
|
|
588
|
+
varying vec3 vWorldPosition;
|
|
589
|
+
uniform float refractionRatio;
|
|
590
|
+
#else
|
|
591
|
+
varying vec3 vReflect;
|
|
592
|
+
#endif
|
|
593
|
+
#endif`,Gd=`#ifdef USE_ENVMAP
|
|
594
|
+
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
595
|
+
#define ENV_WORLDPOS
|
|
596
|
+
#endif
|
|
597
|
+
#ifdef ENV_WORLDPOS
|
|
598
|
+
|
|
599
|
+
varying vec3 vWorldPosition;
|
|
600
|
+
#else
|
|
601
|
+
varying vec3 vReflect;
|
|
602
|
+
uniform float refractionRatio;
|
|
603
|
+
#endif
|
|
604
|
+
#endif`,Wd=`#ifdef USE_ENVMAP
|
|
605
|
+
#ifdef ENV_WORLDPOS
|
|
606
|
+
vWorldPosition = worldPosition.xyz;
|
|
607
|
+
#else
|
|
608
|
+
vec3 cameraToVertex;
|
|
609
|
+
if ( isOrthographic ) {
|
|
610
|
+
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
|
|
611
|
+
} else {
|
|
612
|
+
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
|
|
613
|
+
}
|
|
614
|
+
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
615
|
+
#ifdef ENVMAP_MODE_REFLECTION
|
|
616
|
+
vReflect = reflect( cameraToVertex, worldNormal );
|
|
617
|
+
#else
|
|
618
|
+
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
619
|
+
#endif
|
|
620
|
+
#endif
|
|
621
|
+
#endif`,Xd=`#ifdef USE_FOG
|
|
622
|
+
vFogDepth = - mvPosition.z;
|
|
623
|
+
#endif`,qd=`#ifdef USE_FOG
|
|
624
|
+
varying float vFogDepth;
|
|
625
|
+
#endif`,Yd=`#ifdef USE_FOG
|
|
626
|
+
#ifdef FOG_EXP2
|
|
627
|
+
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
628
|
+
#else
|
|
629
|
+
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
630
|
+
#endif
|
|
631
|
+
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
632
|
+
#endif`,Zd=`#ifdef USE_FOG
|
|
633
|
+
uniform vec3 fogColor;
|
|
634
|
+
varying float vFogDepth;
|
|
635
|
+
#ifdef FOG_EXP2
|
|
636
|
+
uniform float fogDensity;
|
|
637
|
+
#else
|
|
638
|
+
uniform float fogNear;
|
|
639
|
+
uniform float fogFar;
|
|
640
|
+
#endif
|
|
641
|
+
#endif`,Kd=`#ifdef USE_GRADIENTMAP
|
|
642
|
+
uniform sampler2D gradientMap;
|
|
643
|
+
#endif
|
|
644
|
+
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
645
|
+
float dotNL = dot( normal, lightDirection );
|
|
646
|
+
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
|
|
647
|
+
#ifdef USE_GRADIENTMAP
|
|
648
|
+
return vec3( texture2D( gradientMap, coord ).r );
|
|
649
|
+
#else
|
|
650
|
+
vec2 fw = fwidth( coord ) * 0.5;
|
|
651
|
+
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
652
|
+
#endif
|
|
653
|
+
}`,Jd=`#ifdef USE_LIGHTMAP
|
|
654
|
+
uniform sampler2D lightMap;
|
|
655
|
+
uniform float lightMapIntensity;
|
|
656
|
+
#endif`,$d=`LambertMaterial material;
|
|
657
|
+
material.diffuseColor = diffuseColor.rgb;
|
|
658
|
+
material.specularStrength = specularStrength;`,jd=`varying vec3 vViewPosition;
|
|
659
|
+
struct LambertMaterial {
|
|
660
|
+
vec3 diffuseColor;
|
|
661
|
+
float specularStrength;
|
|
662
|
+
};
|
|
663
|
+
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 ) {
|
|
664
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
665
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
666
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
667
|
+
}
|
|
668
|
+
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 ) {
|
|
669
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
670
|
+
}
|
|
671
|
+
#define RE_Direct RE_Direct_Lambert
|
|
672
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Qd=`uniform bool receiveShadow;
|
|
673
|
+
uniform vec3 ambientLightColor;
|
|
674
|
+
#if defined( USE_LIGHT_PROBES )
|
|
675
|
+
uniform vec3 lightProbe[ 9 ];
|
|
676
|
+
#endif
|
|
677
|
+
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
678
|
+
float x = normal.x, y = normal.y, z = normal.z;
|
|
679
|
+
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
680
|
+
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
681
|
+
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
682
|
+
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
683
|
+
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
684
|
+
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
685
|
+
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
686
|
+
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
687
|
+
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
688
|
+
return result;
|
|
689
|
+
}
|
|
690
|
+
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
|
|
691
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
692
|
+
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
|
|
693
|
+
return irradiance;
|
|
694
|
+
}
|
|
695
|
+
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
|
|
696
|
+
vec3 irradiance = ambientLightColor;
|
|
697
|
+
return irradiance;
|
|
698
|
+
}
|
|
699
|
+
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
|
|
700
|
+
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
|
|
701
|
+
if ( cutoffDistance > 0.0 ) {
|
|
702
|
+
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
|
|
703
|
+
}
|
|
704
|
+
return distanceFalloff;
|
|
705
|
+
}
|
|
706
|
+
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
|
|
707
|
+
return smoothstep( coneCosine, penumbraCosine, angleCosine );
|
|
708
|
+
}
|
|
709
|
+
#if NUM_DIR_LIGHTS > 0
|
|
710
|
+
struct DirectionalLight {
|
|
711
|
+
vec3 direction;
|
|
712
|
+
vec3 color;
|
|
713
|
+
};
|
|
714
|
+
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
|
|
715
|
+
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
|
|
716
|
+
light.color = directionalLight.color;
|
|
717
|
+
light.direction = directionalLight.direction;
|
|
718
|
+
light.visible = true;
|
|
719
|
+
}
|
|
720
|
+
#endif
|
|
721
|
+
#if NUM_POINT_LIGHTS > 0
|
|
722
|
+
struct PointLight {
|
|
723
|
+
vec3 position;
|
|
724
|
+
vec3 color;
|
|
725
|
+
float distance;
|
|
726
|
+
float decay;
|
|
727
|
+
};
|
|
728
|
+
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
|
|
729
|
+
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
730
|
+
vec3 lVector = pointLight.position - geometryPosition;
|
|
731
|
+
light.direction = normalize( lVector );
|
|
732
|
+
float lightDistance = length( lVector );
|
|
733
|
+
light.color = pointLight.color;
|
|
734
|
+
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
|
|
735
|
+
light.visible = ( light.color != vec3( 0.0 ) );
|
|
736
|
+
}
|
|
737
|
+
#endif
|
|
738
|
+
#if NUM_SPOT_LIGHTS > 0
|
|
739
|
+
struct SpotLight {
|
|
740
|
+
vec3 position;
|
|
741
|
+
vec3 direction;
|
|
742
|
+
vec3 color;
|
|
743
|
+
float distance;
|
|
744
|
+
float decay;
|
|
745
|
+
float coneCos;
|
|
746
|
+
float penumbraCos;
|
|
747
|
+
};
|
|
748
|
+
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
|
|
749
|
+
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
|
|
750
|
+
vec3 lVector = spotLight.position - geometryPosition;
|
|
751
|
+
light.direction = normalize( lVector );
|
|
752
|
+
float angleCos = dot( light.direction, spotLight.direction );
|
|
753
|
+
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
|
|
754
|
+
if ( spotAttenuation > 0.0 ) {
|
|
755
|
+
float lightDistance = length( lVector );
|
|
756
|
+
light.color = spotLight.color * spotAttenuation;
|
|
757
|
+
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
|
|
758
|
+
light.visible = ( light.color != vec3( 0.0 ) );
|
|
759
|
+
} else {
|
|
760
|
+
light.color = vec3( 0.0 );
|
|
761
|
+
light.visible = false;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
#endif
|
|
765
|
+
#if NUM_RECT_AREA_LIGHTS > 0
|
|
766
|
+
struct RectAreaLight {
|
|
767
|
+
vec3 color;
|
|
768
|
+
vec3 position;
|
|
769
|
+
vec3 halfWidth;
|
|
770
|
+
vec3 halfHeight;
|
|
771
|
+
};
|
|
772
|
+
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
|
|
773
|
+
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
|
|
774
|
+
#endif
|
|
775
|
+
#if NUM_HEMI_LIGHTS > 0
|
|
776
|
+
struct HemisphereLight {
|
|
777
|
+
vec3 direction;
|
|
778
|
+
vec3 skyColor;
|
|
779
|
+
vec3 groundColor;
|
|
780
|
+
};
|
|
781
|
+
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
|
|
782
|
+
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
|
|
783
|
+
float dotNL = dot( normal, hemiLight.direction );
|
|
784
|
+
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
|
|
785
|
+
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
|
|
786
|
+
return irradiance;
|
|
787
|
+
}
|
|
788
|
+
#endif`,ef=`#ifdef USE_ENVMAP
|
|
789
|
+
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
790
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
791
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
792
|
+
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
|
|
793
|
+
return PI * envMapColor.rgb * envMapIntensity;
|
|
794
|
+
#else
|
|
795
|
+
return vec3( 0.0 );
|
|
796
|
+
#endif
|
|
797
|
+
}
|
|
798
|
+
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
|
|
799
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
800
|
+
vec3 reflectVec = reflect( - viewDir, normal );
|
|
801
|
+
reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
|
|
802
|
+
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
|
|
803
|
+
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
|
|
804
|
+
return envMapColor.rgb * envMapIntensity;
|
|
805
|
+
#else
|
|
806
|
+
return vec3( 0.0 );
|
|
807
|
+
#endif
|
|
808
|
+
}
|
|
809
|
+
#ifdef USE_ANISOTROPY
|
|
810
|
+
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
|
|
811
|
+
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
812
|
+
vec3 bentNormal = cross( bitangent, viewDir );
|
|
813
|
+
bentNormal = normalize( cross( bentNormal, bitangent ) );
|
|
814
|
+
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
|
|
815
|
+
return getIBLRadiance( viewDir, bentNormal, roughness );
|
|
816
|
+
#else
|
|
817
|
+
return vec3( 0.0 );
|
|
818
|
+
#endif
|
|
819
|
+
}
|
|
820
|
+
#endif
|
|
821
|
+
#endif`,tf=`ToonMaterial material;
|
|
822
|
+
material.diffuseColor = diffuseColor.rgb;`,nf=`varying vec3 vViewPosition;
|
|
823
|
+
struct ToonMaterial {
|
|
824
|
+
vec3 diffuseColor;
|
|
825
|
+
};
|
|
826
|
+
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 ) {
|
|
827
|
+
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
|
|
828
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
829
|
+
}
|
|
830
|
+
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 ) {
|
|
831
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
832
|
+
}
|
|
833
|
+
#define RE_Direct RE_Direct_Toon
|
|
834
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,sf=`BlinnPhongMaterial material;
|
|
835
|
+
material.diffuseColor = diffuseColor.rgb;
|
|
836
|
+
material.specularColor = specular;
|
|
837
|
+
material.specularShininess = shininess;
|
|
838
|
+
material.specularStrength = specularStrength;`,rf=`varying vec3 vViewPosition;
|
|
839
|
+
struct BlinnPhongMaterial {
|
|
840
|
+
vec3 diffuseColor;
|
|
841
|
+
vec3 specularColor;
|
|
842
|
+
float specularShininess;
|
|
843
|
+
float specularStrength;
|
|
844
|
+
};
|
|
845
|
+
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 ) {
|
|
846
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
847
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
848
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
849
|
+
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
|
|
850
|
+
}
|
|
851
|
+
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 ) {
|
|
852
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
853
|
+
}
|
|
854
|
+
#define RE_Direct RE_Direct_BlinnPhong
|
|
855
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,of=`PhysicalMaterial material;
|
|
856
|
+
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
857
|
+
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
858
|
+
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
859
|
+
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
860
|
+
material.roughness = min( material.roughness, 1.0 );
|
|
861
|
+
#ifdef IOR
|
|
862
|
+
material.ior = ior;
|
|
863
|
+
#ifdef USE_SPECULAR
|
|
864
|
+
float specularIntensityFactor = specularIntensity;
|
|
865
|
+
vec3 specularColorFactor = specularColor;
|
|
866
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
867
|
+
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
868
|
+
#endif
|
|
869
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
870
|
+
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
871
|
+
#endif
|
|
872
|
+
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
873
|
+
#else
|
|
874
|
+
float specularIntensityFactor = 1.0;
|
|
875
|
+
vec3 specularColorFactor = vec3( 1.0 );
|
|
876
|
+
material.specularF90 = 1.0;
|
|
877
|
+
#endif
|
|
878
|
+
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
879
|
+
#else
|
|
880
|
+
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
881
|
+
material.specularF90 = 1.0;
|
|
882
|
+
#endif
|
|
883
|
+
#ifdef USE_CLEARCOAT
|
|
884
|
+
material.clearcoat = clearcoat;
|
|
885
|
+
material.clearcoatRoughness = clearcoatRoughness;
|
|
886
|
+
material.clearcoatF0 = vec3( 0.04 );
|
|
887
|
+
material.clearcoatF90 = 1.0;
|
|
888
|
+
#ifdef USE_CLEARCOATMAP
|
|
889
|
+
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|
890
|
+
#endif
|
|
891
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
892
|
+
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
893
|
+
#endif
|
|
894
|
+
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
895
|
+
material.clearcoatRoughness += geometryRoughness;
|
|
896
|
+
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
897
|
+
#endif
|
|
898
|
+
#ifdef USE_DISPERSION
|
|
899
|
+
material.dispersion = dispersion;
|
|
900
|
+
#endif
|
|
901
|
+
#ifdef USE_IRIDESCENCE
|
|
902
|
+
material.iridescence = iridescence;
|
|
903
|
+
material.iridescenceIOR = iridescenceIOR;
|
|
904
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
905
|
+
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
906
|
+
#endif
|
|
907
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
908
|
+
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
909
|
+
#else
|
|
910
|
+
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
911
|
+
#endif
|
|
912
|
+
#endif
|
|
913
|
+
#ifdef USE_SHEEN
|
|
914
|
+
material.sheenColor = sheenColor;
|
|
915
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
916
|
+
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
917
|
+
#endif
|
|
918
|
+
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
919
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
920
|
+
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
921
|
+
#endif
|
|
922
|
+
#endif
|
|
923
|
+
#ifdef USE_ANISOTROPY
|
|
924
|
+
#ifdef USE_ANISOTROPYMAP
|
|
925
|
+
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
926
|
+
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
927
|
+
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
928
|
+
#else
|
|
929
|
+
vec2 anisotropyV = anisotropyVector;
|
|
930
|
+
#endif
|
|
931
|
+
material.anisotropy = length( anisotropyV );
|
|
932
|
+
if( material.anisotropy == 0.0 ) {
|
|
933
|
+
anisotropyV = vec2( 1.0, 0.0 );
|
|
934
|
+
} else {
|
|
935
|
+
anisotropyV /= material.anisotropy;
|
|
936
|
+
material.anisotropy = saturate( material.anisotropy );
|
|
937
|
+
}
|
|
938
|
+
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
939
|
+
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
940
|
+
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
941
|
+
#endif`,af=`struct PhysicalMaterial {
|
|
942
|
+
vec3 diffuseColor;
|
|
943
|
+
float roughness;
|
|
944
|
+
vec3 specularColor;
|
|
945
|
+
float specularF90;
|
|
946
|
+
float dispersion;
|
|
947
|
+
#ifdef USE_CLEARCOAT
|
|
948
|
+
float clearcoat;
|
|
949
|
+
float clearcoatRoughness;
|
|
950
|
+
vec3 clearcoatF0;
|
|
951
|
+
float clearcoatF90;
|
|
952
|
+
#endif
|
|
953
|
+
#ifdef USE_IRIDESCENCE
|
|
954
|
+
float iridescence;
|
|
955
|
+
float iridescenceIOR;
|
|
956
|
+
float iridescenceThickness;
|
|
957
|
+
vec3 iridescenceFresnel;
|
|
958
|
+
vec3 iridescenceF0;
|
|
959
|
+
#endif
|
|
960
|
+
#ifdef USE_SHEEN
|
|
961
|
+
vec3 sheenColor;
|
|
962
|
+
float sheenRoughness;
|
|
963
|
+
#endif
|
|
964
|
+
#ifdef IOR
|
|
965
|
+
float ior;
|
|
966
|
+
#endif
|
|
967
|
+
#ifdef USE_TRANSMISSION
|
|
968
|
+
float transmission;
|
|
969
|
+
float transmissionAlpha;
|
|
970
|
+
float thickness;
|
|
971
|
+
float attenuationDistance;
|
|
972
|
+
vec3 attenuationColor;
|
|
973
|
+
#endif
|
|
974
|
+
#ifdef USE_ANISOTROPY
|
|
975
|
+
float anisotropy;
|
|
976
|
+
float alphaT;
|
|
977
|
+
vec3 anisotropyT;
|
|
978
|
+
vec3 anisotropyB;
|
|
979
|
+
#endif
|
|
980
|
+
};
|
|
981
|
+
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
982
|
+
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
983
|
+
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
984
|
+
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
985
|
+
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
986
|
+
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
987
|
+
float x2 = x * x;
|
|
988
|
+
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
989
|
+
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
990
|
+
}
|
|
991
|
+
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
992
|
+
float a2 = pow2( alpha );
|
|
993
|
+
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
994
|
+
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
995
|
+
return 0.5 / max( gv + gl, EPSILON );
|
|
996
|
+
}
|
|
997
|
+
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
998
|
+
float a2 = pow2( alpha );
|
|
999
|
+
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
1000
|
+
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
1001
|
+
}
|
|
1002
|
+
#ifdef USE_ANISOTROPY
|
|
1003
|
+
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 ) {
|
|
1004
|
+
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
1005
|
+
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
1006
|
+
float v = 0.5 / ( gv + gl );
|
|
1007
|
+
return saturate(v);
|
|
1008
|
+
}
|
|
1009
|
+
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
1010
|
+
float a2 = alphaT * alphaB;
|
|
1011
|
+
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
1012
|
+
highp float v2 = dot( v, v );
|
|
1013
|
+
float w2 = a2 / v2;
|
|
1014
|
+
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
1015
|
+
}
|
|
1016
|
+
#endif
|
|
1017
|
+
#ifdef USE_CLEARCOAT
|
|
1018
|
+
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
1019
|
+
vec3 f0 = material.clearcoatF0;
|
|
1020
|
+
float f90 = material.clearcoatF90;
|
|
1021
|
+
float roughness = material.clearcoatRoughness;
|
|
1022
|
+
float alpha = pow2( roughness );
|
|
1023
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1024
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1025
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1026
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1027
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
1028
|
+
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
1029
|
+
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
1030
|
+
float D = D_GGX( alpha, dotNH );
|
|
1031
|
+
return F * ( V * D );
|
|
1032
|
+
}
|
|
1033
|
+
#endif
|
|
1034
|
+
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
1035
|
+
vec3 f0 = material.specularColor;
|
|
1036
|
+
float f90 = material.specularF90;
|
|
1037
|
+
float roughness = material.roughness;
|
|
1038
|
+
float alpha = pow2( roughness );
|
|
1039
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1040
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1041
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1042
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1043
|
+
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
1044
|
+
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
1045
|
+
#ifdef USE_IRIDESCENCE
|
|
1046
|
+
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
1047
|
+
#endif
|
|
1048
|
+
#ifdef USE_ANISOTROPY
|
|
1049
|
+
float dotTL = dot( material.anisotropyT, lightDir );
|
|
1050
|
+
float dotTV = dot( material.anisotropyT, viewDir );
|
|
1051
|
+
float dotTH = dot( material.anisotropyT, halfDir );
|
|
1052
|
+
float dotBL = dot( material.anisotropyB, lightDir );
|
|
1053
|
+
float dotBV = dot( material.anisotropyB, viewDir );
|
|
1054
|
+
float dotBH = dot( material.anisotropyB, halfDir );
|
|
1055
|
+
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
1056
|
+
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
1057
|
+
#else
|
|
1058
|
+
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
1059
|
+
float D = D_GGX( alpha, dotNH );
|
|
1060
|
+
#endif
|
|
1061
|
+
return F * ( V * D );
|
|
1062
|
+
}
|
|
1063
|
+
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
1064
|
+
const float LUT_SIZE = 64.0;
|
|
1065
|
+
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
1066
|
+
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
1067
|
+
float dotNV = saturate( dot( N, V ) );
|
|
1068
|
+
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
1069
|
+
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
1070
|
+
return uv;
|
|
1071
|
+
}
|
|
1072
|
+
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
1073
|
+
float l = length( f );
|
|
1074
|
+
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
1075
|
+
}
|
|
1076
|
+
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
1077
|
+
float x = dot( v1, v2 );
|
|
1078
|
+
float y = abs( x );
|
|
1079
|
+
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
1080
|
+
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
1081
|
+
float v = a / b;
|
|
1082
|
+
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
1083
|
+
return cross( v1, v2 ) * theta_sintheta;
|
|
1084
|
+
}
|
|
1085
|
+
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
1086
|
+
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
1087
|
+
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
1088
|
+
vec3 lightNormal = cross( v1, v2 );
|
|
1089
|
+
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
1090
|
+
vec3 T1, T2;
|
|
1091
|
+
T1 = normalize( V - N * dot( V, N ) );
|
|
1092
|
+
T2 = - cross( N, T1 );
|
|
1093
|
+
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
|
1094
|
+
vec3 coords[ 4 ];
|
|
1095
|
+
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
1096
|
+
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
1097
|
+
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
1098
|
+
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
1099
|
+
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
1100
|
+
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
1101
|
+
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
1102
|
+
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
1103
|
+
vec3 vectorFormFactor = vec3( 0.0 );
|
|
1104
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
1105
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
1106
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
1107
|
+
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
1108
|
+
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
1109
|
+
return vec3( result );
|
|
1110
|
+
}
|
|
1111
|
+
#if defined( USE_SHEEN )
|
|
1112
|
+
float D_Charlie( float roughness, float dotNH ) {
|
|
1113
|
+
float alpha = pow2( roughness );
|
|
1114
|
+
float invAlpha = 1.0 / alpha;
|
|
1115
|
+
float cos2h = dotNH * dotNH;
|
|
1116
|
+
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
1117
|
+
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
1118
|
+
}
|
|
1119
|
+
float V_Neubelt( float dotNV, float dotNL ) {
|
|
1120
|
+
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
1121
|
+
}
|
|
1122
|
+
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
1123
|
+
vec3 halfDir = normalize( lightDir + viewDir );
|
|
1124
|
+
float dotNL = saturate( dot( normal, lightDir ) );
|
|
1125
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1126
|
+
float dotNH = saturate( dot( normal, halfDir ) );
|
|
1127
|
+
float D = D_Charlie( sheenRoughness, dotNH );
|
|
1128
|
+
float V = V_Neubelt( dotNV, dotNL );
|
|
1129
|
+
return sheenColor * ( D * V );
|
|
1130
|
+
}
|
|
1131
|
+
#endif
|
|
1132
|
+
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
1133
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1134
|
+
float r2 = roughness * roughness;
|
|
1135
|
+
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
1136
|
+
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
1137
|
+
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
1138
|
+
return saturate( DG * RECIPROCAL_PI );
|
|
1139
|
+
}
|
|
1140
|
+
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
1141
|
+
float dotNV = saturate( dot( normal, viewDir ) );
|
|
1142
|
+
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
1143
|
+
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
1144
|
+
vec4 r = roughness * c0 + c1;
|
|
1145
|
+
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|
1146
|
+
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|
1147
|
+
return fab;
|
|
1148
|
+
}
|
|
1149
|
+
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
1150
|
+
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
1151
|
+
return specularColor * fab.x + specularF90 * fab.y;
|
|
1152
|
+
}
|
|
1153
|
+
#ifdef USE_IRIDESCENCE
|
|
1154
|
+
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 ) {
|
|
1155
|
+
#else
|
|
1156
|
+
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 ) {
|
|
1157
|
+
#endif
|
|
1158
|
+
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
1159
|
+
#ifdef USE_IRIDESCENCE
|
|
1160
|
+
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|
1161
|
+
#else
|
|
1162
|
+
vec3 Fr = specularColor;
|
|
1163
|
+
#endif
|
|
1164
|
+
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|
1165
|
+
float Ess = fab.x + fab.y;
|
|
1166
|
+
float Ems = 1.0 - Ess;
|
|
1167
|
+
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
1168
|
+
singleScatter += FssEss;
|
|
1169
|
+
multiScatter += Fms * Ems;
|
|
1170
|
+
}
|
|
1171
|
+
#if NUM_RECT_AREA_LIGHTS > 0
|
|
1172
|
+
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 ) {
|
|
1173
|
+
vec3 normal = geometryNormal;
|
|
1174
|
+
vec3 viewDir = geometryViewDir;
|
|
1175
|
+
vec3 position = geometryPosition;
|
|
1176
|
+
vec3 lightPos = rectAreaLight.position;
|
|
1177
|
+
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
1178
|
+
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
1179
|
+
vec3 lightColor = rectAreaLight.color;
|
|
1180
|
+
float roughness = material.roughness;
|
|
1181
|
+
vec3 rectCoords[ 4 ];
|
|
1182
|
+
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
1183
|
+
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
1184
|
+
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
1185
|
+
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
1186
|
+
vec4 t1 = texture2D( ltc_1, uv );
|
|
1187
|
+
vec4 t2 = texture2D( ltc_2, uv );
|
|
1188
|
+
mat3 mInv = mat3(
|
|
1189
|
+
vec3( t1.x, 0, t1.y ),
|
|
1190
|
+
vec3( 0, 1, 0 ),
|
|
1191
|
+
vec3( t1.z, 0, t1.w )
|
|
1192
|
+
);
|
|
1193
|
+
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
1194
|
+
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
1195
|
+
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
1196
|
+
}
|
|
1197
|
+
#endif
|
|
1198
|
+
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 ) {
|
|
1199
|
+
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
1200
|
+
vec3 irradiance = dotNL * directLight.color;
|
|
1201
|
+
#ifdef USE_CLEARCOAT
|
|
1202
|
+
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
1203
|
+
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
1204
|
+
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
1205
|
+
#endif
|
|
1206
|
+
#ifdef USE_SHEEN
|
|
1207
|
+
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
1208
|
+
#endif
|
|
1209
|
+
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
1210
|
+
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1211
|
+
}
|
|
1212
|
+
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 ) {
|
|
1213
|
+
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1214
|
+
}
|
|
1215
|
+
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) {
|
|
1216
|
+
#ifdef USE_CLEARCOAT
|
|
1217
|
+
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
1218
|
+
#endif
|
|
1219
|
+
#ifdef USE_SHEEN
|
|
1220
|
+
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
1221
|
+
#endif
|
|
1222
|
+
vec3 singleScattering = vec3( 0.0 );
|
|
1223
|
+
vec3 multiScattering = vec3( 0.0 );
|
|
1224
|
+
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
1225
|
+
#ifdef USE_IRIDESCENCE
|
|
1226
|
+
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
1227
|
+
#else
|
|
1228
|
+
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
1229
|
+
#endif
|
|
1230
|
+
vec3 totalScattering = singleScattering + multiScattering;
|
|
1231
|
+
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
1232
|
+
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
1233
|
+
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
1234
|
+
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
1235
|
+
}
|
|
1236
|
+
#define RE_Direct RE_Direct_Physical
|
|
1237
|
+
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
1238
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
1239
|
+
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1240
|
+
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1241
|
+
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1242
|
+
}`,cf=`
|
|
1243
|
+
vec3 geometryPosition = - vViewPosition;
|
|
1244
|
+
vec3 geometryNormal = normal;
|
|
1245
|
+
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
1246
|
+
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
1247
|
+
#ifdef USE_CLEARCOAT
|
|
1248
|
+
geometryClearcoatNormal = clearcoatNormal;
|
|
1249
|
+
#endif
|
|
1250
|
+
#ifdef USE_IRIDESCENCE
|
|
1251
|
+
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
1252
|
+
if ( material.iridescenceThickness == 0.0 ) {
|
|
1253
|
+
material.iridescence = 0.0;
|
|
1254
|
+
} else {
|
|
1255
|
+
material.iridescence = saturate( material.iridescence );
|
|
1256
|
+
}
|
|
1257
|
+
if ( material.iridescence > 0.0 ) {
|
|
1258
|
+
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
1259
|
+
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
1260
|
+
}
|
|
1261
|
+
#endif
|
|
1262
|
+
IncidentLight directLight;
|
|
1263
|
+
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1264
|
+
PointLight pointLight;
|
|
1265
|
+
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
1266
|
+
PointLightShadow pointLightShadow;
|
|
1267
|
+
#endif
|
|
1268
|
+
#pragma unroll_loop_start
|
|
1269
|
+
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
1270
|
+
pointLight = pointLights[ i ];
|
|
1271
|
+
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
1272
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
1273
|
+
pointLightShadow = pointLightShadows[ i ];
|
|
1274
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
1275
|
+
#endif
|
|
1276
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1277
|
+
}
|
|
1278
|
+
#pragma unroll_loop_end
|
|
1279
|
+
#endif
|
|
1280
|
+
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1281
|
+
SpotLight spotLight;
|
|
1282
|
+
vec4 spotColor;
|
|
1283
|
+
vec3 spotLightCoord;
|
|
1284
|
+
bool inSpotLightMap;
|
|
1285
|
+
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1286
|
+
SpotLightShadow spotLightShadow;
|
|
1287
|
+
#endif
|
|
1288
|
+
#pragma unroll_loop_start
|
|
1289
|
+
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
1290
|
+
spotLight = spotLights[ i ];
|
|
1291
|
+
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
1292
|
+
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
1293
|
+
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
1294
|
+
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1295
|
+
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
1296
|
+
#else
|
|
1297
|
+
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
1298
|
+
#endif
|
|
1299
|
+
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
1300
|
+
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
1301
|
+
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
1302
|
+
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
1303
|
+
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
1304
|
+
#endif
|
|
1305
|
+
#undef SPOT_LIGHT_MAP_INDEX
|
|
1306
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1307
|
+
spotLightShadow = spotLightShadows[ i ];
|
|
1308
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
1309
|
+
#endif
|
|
1310
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1311
|
+
}
|
|
1312
|
+
#pragma unroll_loop_end
|
|
1313
|
+
#endif
|
|
1314
|
+
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
1315
|
+
DirectionalLight directionalLight;
|
|
1316
|
+
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
1317
|
+
DirectionalLightShadow directionalLightShadow;
|
|
1318
|
+
#endif
|
|
1319
|
+
#pragma unroll_loop_start
|
|
1320
|
+
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
1321
|
+
directionalLight = directionalLights[ i ];
|
|
1322
|
+
getDirectionalLightInfo( directionalLight, directLight );
|
|
1323
|
+
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
1324
|
+
directionalLightShadow = directionalLightShadows[ i ];
|
|
1325
|
+
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
1326
|
+
#endif
|
|
1327
|
+
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1328
|
+
}
|
|
1329
|
+
#pragma unroll_loop_end
|
|
1330
|
+
#endif
|
|
1331
|
+
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
1332
|
+
RectAreaLight rectAreaLight;
|
|
1333
|
+
#pragma unroll_loop_start
|
|
1334
|
+
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
1335
|
+
rectAreaLight = rectAreaLights[ i ];
|
|
1336
|
+
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1337
|
+
}
|
|
1338
|
+
#pragma unroll_loop_end
|
|
1339
|
+
#endif
|
|
1340
|
+
#if defined( RE_IndirectDiffuse )
|
|
1341
|
+
vec3 iblIrradiance = vec3( 0.0 );
|
|
1342
|
+
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
1343
|
+
#if defined( USE_LIGHT_PROBES )
|
|
1344
|
+
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
1345
|
+
#endif
|
|
1346
|
+
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
1347
|
+
#pragma unroll_loop_start
|
|
1348
|
+
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
1349
|
+
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
1350
|
+
}
|
|
1351
|
+
#pragma unroll_loop_end
|
|
1352
|
+
#endif
|
|
1353
|
+
#endif
|
|
1354
|
+
#if defined( RE_IndirectSpecular )
|
|
1355
|
+
vec3 radiance = vec3( 0.0 );
|
|
1356
|
+
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1357
|
+
#endif`,lf=`#if defined( RE_IndirectDiffuse )
|
|
1358
|
+
#ifdef USE_LIGHTMAP
|
|
1359
|
+
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1360
|
+
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
1361
|
+
irradiance += lightMapIrradiance;
|
|
1362
|
+
#endif
|
|
1363
|
+
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
|
|
1364
|
+
iblIrradiance += getIBLIrradiance( geometryNormal );
|
|
1365
|
+
#endif
|
|
1366
|
+
#endif
|
|
1367
|
+
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
|
|
1368
|
+
#ifdef USE_ANISOTROPY
|
|
1369
|
+
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
|
|
1370
|
+
#else
|
|
1371
|
+
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
|
|
1372
|
+
#endif
|
|
1373
|
+
#ifdef USE_CLEARCOAT
|
|
1374
|
+
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1375
|
+
#endif
|
|
1376
|
+
#endif`,hf=`#if defined( RE_IndirectDiffuse )
|
|
1377
|
+
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1378
|
+
#endif
|
|
1379
|
+
#if defined( RE_IndirectSpecular )
|
|
1380
|
+
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1381
|
+
#endif`,uf=`#if defined( USE_LOGDEPTHBUF )
|
|
1382
|
+
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1383
|
+
#endif`,df=`#if defined( USE_LOGDEPTHBUF )
|
|
1384
|
+
uniform float logDepthBufFC;
|
|
1385
|
+
varying float vFragDepth;
|
|
1386
|
+
varying float vIsPerspective;
|
|
1387
|
+
#endif`,ff=`#ifdef USE_LOGDEPTHBUF
|
|
1388
|
+
varying float vFragDepth;
|
|
1389
|
+
varying float vIsPerspective;
|
|
1390
|
+
#endif`,pf=`#ifdef USE_LOGDEPTHBUF
|
|
1391
|
+
vFragDepth = 1.0 + gl_Position.w;
|
|
1392
|
+
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1393
|
+
#endif`,mf=`#ifdef USE_MAP
|
|
1394
|
+
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1395
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
1396
|
+
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1397
|
+
#endif
|
|
1398
|
+
diffuseColor *= sampledDiffuseColor;
|
|
1399
|
+
#endif`,gf=`#ifdef USE_MAP
|
|
1400
|
+
uniform sampler2D map;
|
|
1401
|
+
#endif`,_f=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1402
|
+
#if defined( USE_POINTS_UV )
|
|
1403
|
+
vec2 uv = vUv;
|
|
1404
|
+
#else
|
|
1405
|
+
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
|
|
1406
|
+
#endif
|
|
1407
|
+
#endif
|
|
1408
|
+
#ifdef USE_MAP
|
|
1409
|
+
diffuseColor *= texture2D( map, uv );
|
|
1410
|
+
#endif
|
|
1411
|
+
#ifdef USE_ALPHAMAP
|
|
1412
|
+
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1413
|
+
#endif`,xf=`#if defined( USE_POINTS_UV )
|
|
1414
|
+
varying vec2 vUv;
|
|
1415
|
+
#else
|
|
1416
|
+
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1417
|
+
uniform mat3 uvTransform;
|
|
1418
|
+
#endif
|
|
1419
|
+
#endif
|
|
1420
|
+
#ifdef USE_MAP
|
|
1421
|
+
uniform sampler2D map;
|
|
1422
|
+
#endif
|
|
1423
|
+
#ifdef USE_ALPHAMAP
|
|
1424
|
+
uniform sampler2D alphaMap;
|
|
1425
|
+
#endif`,vf=`float metalnessFactor = metalness;
|
|
1426
|
+
#ifdef USE_METALNESSMAP
|
|
1427
|
+
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
1428
|
+
metalnessFactor *= texelMetalness.b;
|
|
1429
|
+
#endif`,yf=`#ifdef USE_METALNESSMAP
|
|
1430
|
+
uniform sampler2D metalnessMap;
|
|
1431
|
+
#endif`,Mf=`#ifdef USE_INSTANCING_MORPH
|
|
1432
|
+
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1433
|
+
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
1434
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1435
|
+
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
1436
|
+
}
|
|
1437
|
+
#endif`,Sf=`#if defined( USE_MORPHCOLORS )
|
|
1438
|
+
vColor *= morphTargetBaseInfluence;
|
|
1439
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1440
|
+
#if defined( USE_COLOR_ALPHA )
|
|
1441
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
|
|
1442
|
+
#elif defined( USE_COLOR )
|
|
1443
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
1444
|
+
#endif
|
|
1445
|
+
}
|
|
1446
|
+
#endif`,bf=`#ifdef USE_MORPHNORMALS
|
|
1447
|
+
objectNormal *= morphTargetBaseInfluence;
|
|
1448
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1449
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
1450
|
+
}
|
|
1451
|
+
#endif`,Af=`#ifdef USE_MORPHTARGETS
|
|
1452
|
+
#ifndef USE_INSTANCING_MORPH
|
|
1453
|
+
uniform float morphTargetBaseInfluence;
|
|
1454
|
+
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
1455
|
+
#endif
|
|
1456
|
+
uniform sampler2DArray morphTargetsTexture;
|
|
1457
|
+
uniform ivec2 morphTargetsTextureSize;
|
|
1458
|
+
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
|
|
1459
|
+
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
|
|
1460
|
+
int y = texelIndex / morphTargetsTextureSize.x;
|
|
1461
|
+
int x = texelIndex - y * morphTargetsTextureSize.x;
|
|
1462
|
+
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
1463
|
+
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
1464
|
+
}
|
|
1465
|
+
#endif`,Tf=`#ifdef USE_MORPHTARGETS
|
|
1466
|
+
transformed *= morphTargetBaseInfluence;
|
|
1467
|
+
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
1468
|
+
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
1469
|
+
}
|
|
1470
|
+
#endif`,Ef=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
1471
|
+
#ifdef FLAT_SHADED
|
|
1472
|
+
vec3 fdx = dFdx( vViewPosition );
|
|
1473
|
+
vec3 fdy = dFdy( vViewPosition );
|
|
1474
|
+
vec3 normal = normalize( cross( fdx, fdy ) );
|
|
1475
|
+
#else
|
|
1476
|
+
vec3 normal = normalize( vNormal );
|
|
1477
|
+
#ifdef DOUBLE_SIDED
|
|
1478
|
+
normal *= faceDirection;
|
|
1479
|
+
#endif
|
|
1480
|
+
#endif
|
|
1481
|
+
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
|
|
1482
|
+
#ifdef USE_TANGENT
|
|
1483
|
+
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
1484
|
+
#else
|
|
1485
|
+
mat3 tbn = getTangentFrame( - vViewPosition, normal,
|
|
1486
|
+
#if defined( USE_NORMALMAP )
|
|
1487
|
+
vNormalMapUv
|
|
1488
|
+
#elif defined( USE_CLEARCOAT_NORMALMAP )
|
|
1489
|
+
vClearcoatNormalMapUv
|
|
1490
|
+
#else
|
|
1491
|
+
vUv
|
|
1492
|
+
#endif
|
|
1493
|
+
);
|
|
1494
|
+
#endif
|
|
1495
|
+
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
1496
|
+
tbn[0] *= faceDirection;
|
|
1497
|
+
tbn[1] *= faceDirection;
|
|
1498
|
+
#endif
|
|
1499
|
+
#endif
|
|
1500
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1501
|
+
#ifdef USE_TANGENT
|
|
1502
|
+
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
|
|
1503
|
+
#else
|
|
1504
|
+
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
|
|
1505
|
+
#endif
|
|
1506
|
+
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
|
|
1507
|
+
tbn2[0] *= faceDirection;
|
|
1508
|
+
tbn2[1] *= faceDirection;
|
|
1509
|
+
#endif
|
|
1510
|
+
#endif
|
|
1511
|
+
vec3 nonPerturbedNormal = normal;`,wf=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1512
|
+
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1513
|
+
#ifdef FLIP_SIDED
|
|
1514
|
+
normal = - normal;
|
|
1515
|
+
#endif
|
|
1516
|
+
#ifdef DOUBLE_SIDED
|
|
1517
|
+
normal = normal * faceDirection;
|
|
1518
|
+
#endif
|
|
1519
|
+
normal = normalize( normalMatrix * normal );
|
|
1520
|
+
#elif defined( USE_NORMALMAP_TANGENTSPACE )
|
|
1521
|
+
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1522
|
+
mapN.xy *= normalScale;
|
|
1523
|
+
normal = normalize( tbn * mapN );
|
|
1524
|
+
#elif defined( USE_BUMPMAP )
|
|
1525
|
+
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
1526
|
+
#endif`,Rf=`#ifndef FLAT_SHADED
|
|
1527
|
+
varying vec3 vNormal;
|
|
1528
|
+
#ifdef USE_TANGENT
|
|
1529
|
+
varying vec3 vTangent;
|
|
1530
|
+
varying vec3 vBitangent;
|
|
1531
|
+
#endif
|
|
1532
|
+
#endif`,Cf=`#ifndef FLAT_SHADED
|
|
1533
|
+
varying vec3 vNormal;
|
|
1534
|
+
#ifdef USE_TANGENT
|
|
1535
|
+
varying vec3 vTangent;
|
|
1536
|
+
varying vec3 vBitangent;
|
|
1537
|
+
#endif
|
|
1538
|
+
#endif`,If=`#ifndef FLAT_SHADED
|
|
1539
|
+
vNormal = normalize( transformedNormal );
|
|
1540
|
+
#ifdef USE_TANGENT
|
|
1541
|
+
vTangent = normalize( transformedTangent );
|
|
1542
|
+
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
1543
|
+
#endif
|
|
1544
|
+
#endif`,Pf=`#ifdef USE_NORMALMAP
|
|
1545
|
+
uniform sampler2D normalMap;
|
|
1546
|
+
uniform vec2 normalScale;
|
|
1547
|
+
#endif
|
|
1548
|
+
#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
1549
|
+
uniform mat3 normalMatrix;
|
|
1550
|
+
#endif
|
|
1551
|
+
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
|
|
1552
|
+
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
|
|
1553
|
+
vec3 q0 = dFdx( eye_pos.xyz );
|
|
1554
|
+
vec3 q1 = dFdy( eye_pos.xyz );
|
|
1555
|
+
vec2 st0 = dFdx( uv.st );
|
|
1556
|
+
vec2 st1 = dFdy( uv.st );
|
|
1557
|
+
vec3 N = surf_norm;
|
|
1558
|
+
vec3 q1perp = cross( q1, N );
|
|
1559
|
+
vec3 q0perp = cross( N, q0 );
|
|
1560
|
+
vec3 T = q1perp * st0.x + q0perp * st1.x;
|
|
1561
|
+
vec3 B = q1perp * st0.y + q0perp * st1.y;
|
|
1562
|
+
float det = max( dot( T, T ), dot( B, B ) );
|
|
1563
|
+
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
1564
|
+
return mat3( T * scale, B * scale, N );
|
|
1565
|
+
}
|
|
1566
|
+
#endif`,Lf=`#ifdef USE_CLEARCOAT
|
|
1567
|
+
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
1568
|
+
#endif`,Df=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1569
|
+
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
1570
|
+
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
1571
|
+
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
1572
|
+
#endif`,Nf=`#ifdef USE_CLEARCOATMAP
|
|
1573
|
+
uniform sampler2D clearcoatMap;
|
|
1574
|
+
#endif
|
|
1575
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
1576
|
+
uniform sampler2D clearcoatNormalMap;
|
|
1577
|
+
uniform vec2 clearcoatNormalScale;
|
|
1578
|
+
#endif
|
|
1579
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
1580
|
+
uniform sampler2D clearcoatRoughnessMap;
|
|
1581
|
+
#endif`,Uf=`#ifdef USE_IRIDESCENCEMAP
|
|
1582
|
+
uniform sampler2D iridescenceMap;
|
|
1583
|
+
#endif
|
|
1584
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
1585
|
+
uniform sampler2D iridescenceThicknessMap;
|
|
1586
|
+
#endif`,Of=`#ifdef OPAQUE
|
|
1587
|
+
diffuseColor.a = 1.0;
|
|
1588
|
+
#endif
|
|
1589
|
+
#ifdef USE_TRANSMISSION
|
|
1590
|
+
diffuseColor.a *= material.transmissionAlpha;
|
|
1591
|
+
#endif
|
|
1592
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ff=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
1593
|
+
return normalize( normal ) * 0.5 + 0.5;
|
|
1594
|
+
}
|
|
1595
|
+
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
1596
|
+
return 2.0 * rgb.xyz - 1.0;
|
|
1597
|
+
}
|
|
1598
|
+
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
|
|
1599
|
+
const float Inv255 = 1. / 255.;
|
|
1600
|
+
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
|
|
1601
|
+
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
|
|
1602
|
+
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
|
|
1603
|
+
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
|
|
1604
|
+
vec4 packDepthToRGBA( const in float v ) {
|
|
1605
|
+
if( v <= 0.0 )
|
|
1606
|
+
return vec4( 0., 0., 0., 0. );
|
|
1607
|
+
if( v >= 1.0 )
|
|
1608
|
+
return vec4( 1., 1., 1., 1. );
|
|
1609
|
+
float vuf;
|
|
1610
|
+
float af = modf( v * PackFactors.a, vuf );
|
|
1611
|
+
float bf = modf( vuf * ShiftRight8, vuf );
|
|
1612
|
+
float gf = modf( vuf * ShiftRight8, vuf );
|
|
1613
|
+
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
|
|
1614
|
+
}
|
|
1615
|
+
vec3 packDepthToRGB( const in float v ) {
|
|
1616
|
+
if( v <= 0.0 )
|
|
1617
|
+
return vec3( 0., 0., 0. );
|
|
1618
|
+
if( v >= 1.0 )
|
|
1619
|
+
return vec3( 1., 1., 1. );
|
|
1620
|
+
float vuf;
|
|
1621
|
+
float bf = modf( v * PackFactors.b, vuf );
|
|
1622
|
+
float gf = modf( vuf * ShiftRight8, vuf );
|
|
1623
|
+
return vec3( vuf * Inv255, gf * PackUpscale, bf );
|
|
1624
|
+
}
|
|
1625
|
+
vec2 packDepthToRG( const in float v ) {
|
|
1626
|
+
if( v <= 0.0 )
|
|
1627
|
+
return vec2( 0., 0. );
|
|
1628
|
+
if( v >= 1.0 )
|
|
1629
|
+
return vec2( 1., 1. );
|
|
1630
|
+
float vuf;
|
|
1631
|
+
float gf = modf( v * 256., vuf );
|
|
1632
|
+
return vec2( vuf * Inv255, gf );
|
|
1633
|
+
}
|
|
1634
|
+
float unpackRGBAToDepth( const in vec4 v ) {
|
|
1635
|
+
return dot( v, UnpackFactors4 );
|
|
1636
|
+
}
|
|
1637
|
+
float unpackRGBToDepth( const in vec3 v ) {
|
|
1638
|
+
return dot( v, UnpackFactors3 );
|
|
1639
|
+
}
|
|
1640
|
+
float unpackRGToDepth( const in vec2 v ) {
|
|
1641
|
+
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
|
|
1642
|
+
}
|
|
1643
|
+
vec4 pack2HalfToRGBA( const in vec2 v ) {
|
|
1644
|
+
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
|
|
1645
|
+
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
|
|
1646
|
+
}
|
|
1647
|
+
vec2 unpackRGBATo2Half( const in vec4 v ) {
|
|
1648
|
+
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
|
|
1649
|
+
}
|
|
1650
|
+
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
|
|
1651
|
+
return ( viewZ + near ) / ( near - far );
|
|
1652
|
+
}
|
|
1653
|
+
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1654
|
+
return depth * ( near - far ) - near;
|
|
1655
|
+
}
|
|
1656
|
+
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
|
|
1657
|
+
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
|
|
1658
|
+
}
|
|
1659
|
+
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
|
|
1660
|
+
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
1661
|
+
}`,Bf=`#ifdef PREMULTIPLIED_ALPHA
|
|
1662
|
+
gl_FragColor.rgb *= gl_FragColor.a;
|
|
1663
|
+
#endif`,zf=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
1664
|
+
#ifdef USE_BATCHING
|
|
1665
|
+
mvPosition = batchingMatrix * mvPosition;
|
|
1666
|
+
#endif
|
|
1667
|
+
#ifdef USE_INSTANCING
|
|
1668
|
+
mvPosition = instanceMatrix * mvPosition;
|
|
1669
|
+
#endif
|
|
1670
|
+
mvPosition = modelViewMatrix * mvPosition;
|
|
1671
|
+
gl_Position = projectionMatrix * mvPosition;`,kf=`#ifdef DITHERING
|
|
1672
|
+
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
1673
|
+
#endif`,Vf=`#ifdef DITHERING
|
|
1674
|
+
vec3 dithering( vec3 color ) {
|
|
1675
|
+
float grid_position = rand( gl_FragCoord.xy );
|
|
1676
|
+
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
1677
|
+
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
1678
|
+
return color + dither_shift_RGB;
|
|
1679
|
+
}
|
|
1680
|
+
#endif`,Hf=`float roughnessFactor = roughness;
|
|
1681
|
+
#ifdef USE_ROUGHNESSMAP
|
|
1682
|
+
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
1683
|
+
roughnessFactor *= texelRoughness.g;
|
|
1684
|
+
#endif`,Gf=`#ifdef USE_ROUGHNESSMAP
|
|
1685
|
+
uniform sampler2D roughnessMap;
|
|
1686
|
+
#endif`,Wf=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1687
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1688
|
+
#endif
|
|
1689
|
+
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
1690
|
+
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
1691
|
+
#endif
|
|
1692
|
+
#ifdef USE_SHADOWMAP
|
|
1693
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1694
|
+
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1695
|
+
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1696
|
+
struct DirectionalLightShadow {
|
|
1697
|
+
float shadowIntensity;
|
|
1698
|
+
float shadowBias;
|
|
1699
|
+
float shadowNormalBias;
|
|
1700
|
+
float shadowRadius;
|
|
1701
|
+
vec2 shadowMapSize;
|
|
1702
|
+
};
|
|
1703
|
+
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1704
|
+
#endif
|
|
1705
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1706
|
+
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1707
|
+
struct SpotLightShadow {
|
|
1708
|
+
float shadowIntensity;
|
|
1709
|
+
float shadowBias;
|
|
1710
|
+
float shadowNormalBias;
|
|
1711
|
+
float shadowRadius;
|
|
1712
|
+
vec2 shadowMapSize;
|
|
1713
|
+
};
|
|
1714
|
+
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1715
|
+
#endif
|
|
1716
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1717
|
+
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1718
|
+
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1719
|
+
struct PointLightShadow {
|
|
1720
|
+
float shadowIntensity;
|
|
1721
|
+
float shadowBias;
|
|
1722
|
+
float shadowNormalBias;
|
|
1723
|
+
float shadowRadius;
|
|
1724
|
+
vec2 shadowMapSize;
|
|
1725
|
+
float shadowCameraNear;
|
|
1726
|
+
float shadowCameraFar;
|
|
1727
|
+
};
|
|
1728
|
+
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1729
|
+
#endif
|
|
1730
|
+
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
1731
|
+
return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
|
|
1732
|
+
}
|
|
1733
|
+
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
1734
|
+
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
1735
|
+
}
|
|
1736
|
+
float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
|
|
1737
|
+
float occlusion = 1.0;
|
|
1738
|
+
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
1739
|
+
float hard_shadow = step( compare , distribution.x );
|
|
1740
|
+
if (hard_shadow != 1.0 ) {
|
|
1741
|
+
float distance = compare - distribution.x ;
|
|
1742
|
+
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
1743
|
+
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 );
|
|
1744
|
+
}
|
|
1745
|
+
return occlusion;
|
|
1746
|
+
}
|
|
1747
|
+
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
1748
|
+
float shadow = 1.0;
|
|
1749
|
+
shadowCoord.xyz /= shadowCoord.w;
|
|
1750
|
+
shadowCoord.z += shadowBias;
|
|
1751
|
+
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
1752
|
+
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
1753
|
+
if ( frustumTest ) {
|
|
1754
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
1755
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
1756
|
+
float dx0 = - texelSize.x * shadowRadius;
|
|
1757
|
+
float dy0 = - texelSize.y * shadowRadius;
|
|
1758
|
+
float dx1 = + texelSize.x * shadowRadius;
|
|
1759
|
+
float dy1 = + texelSize.y * shadowRadius;
|
|
1760
|
+
float dx2 = dx0 / 2.0;
|
|
1761
|
+
float dy2 = dy0 / 2.0;
|
|
1762
|
+
float dx3 = dx1 / 2.0;
|
|
1763
|
+
float dy3 = dy1 / 2.0;
|
|
1764
|
+
shadow = (
|
|
1765
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
1766
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
1767
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
1768
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
1769
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
1770
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
1771
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
1772
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
1773
|
+
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
1774
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
1775
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
1776
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
1777
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
1778
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
1779
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
1780
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
1781
|
+
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
1782
|
+
) * ( 1.0 / 17.0 );
|
|
1783
|
+
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
1784
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
1785
|
+
float dx = texelSize.x;
|
|
1786
|
+
float dy = texelSize.y;
|
|
1787
|
+
vec2 uv = shadowCoord.xy;
|
|
1788
|
+
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
1789
|
+
uv -= f * texelSize;
|
|
1790
|
+
shadow = (
|
|
1791
|
+
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
1792
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
1793
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
1794
|
+
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
1795
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
1796
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
1797
|
+
f.x ) +
|
|
1798
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
1799
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
1800
|
+
f.x ) +
|
|
1801
|
+
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
1802
|
+
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
1803
|
+
f.y ) +
|
|
1804
|
+
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
1805
|
+
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
1806
|
+
f.y ) +
|
|
1807
|
+
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
1808
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
1809
|
+
f.x ),
|
|
1810
|
+
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
1811
|
+
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
1812
|
+
f.x ),
|
|
1813
|
+
f.y )
|
|
1814
|
+
) * ( 1.0 / 9.0 );
|
|
1815
|
+
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
1816
|
+
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
1817
|
+
#else
|
|
1818
|
+
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
1819
|
+
#endif
|
|
1820
|
+
}
|
|
1821
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
1822
|
+
}
|
|
1823
|
+
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
1824
|
+
vec3 absV = abs( v );
|
|
1825
|
+
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
1826
|
+
absV *= scaleToCube;
|
|
1827
|
+
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
1828
|
+
vec2 planar = v.xy;
|
|
1829
|
+
float almostATexel = 1.5 * texelSizeY;
|
|
1830
|
+
float almostOne = 1.0 - almostATexel;
|
|
1831
|
+
if ( absV.z >= almostOne ) {
|
|
1832
|
+
if ( v.z > 0.0 )
|
|
1833
|
+
planar.x = 4.0 - v.x;
|
|
1834
|
+
} else if ( absV.x >= almostOne ) {
|
|
1835
|
+
float signX = sign( v.x );
|
|
1836
|
+
planar.x = v.z * signX + 2.0 * signX;
|
|
1837
|
+
} else if ( absV.y >= almostOne ) {
|
|
1838
|
+
float signY = sign( v.y );
|
|
1839
|
+
planar.x = v.x + 2.0 * signY + 2.0;
|
|
1840
|
+
planar.y = v.z * signY - 2.0;
|
|
1841
|
+
}
|
|
1842
|
+
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
1843
|
+
}
|
|
1844
|
+
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
1845
|
+
float shadow = 1.0;
|
|
1846
|
+
vec3 lightToPosition = shadowCoord.xyz;
|
|
1847
|
+
|
|
1848
|
+
float lightToPositionLength = length( lightToPosition );
|
|
1849
|
+
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
1850
|
+
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
1851
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
1852
|
+
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
1853
|
+
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
1854
|
+
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
1855
|
+
shadow = (
|
|
1856
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
1857
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
1858
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
1859
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
1860
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
1861
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
1862
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
1863
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
1864
|
+
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
1865
|
+
) * ( 1.0 / 9.0 );
|
|
1866
|
+
#else
|
|
1867
|
+
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
1868
|
+
#endif
|
|
1869
|
+
}
|
|
1870
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
1871
|
+
}
|
|
1872
|
+
#endif`,Xf=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1873
|
+
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
1874
|
+
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
1875
|
+
#endif
|
|
1876
|
+
#ifdef USE_SHADOWMAP
|
|
1877
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1878
|
+
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1879
|
+
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1880
|
+
struct DirectionalLightShadow {
|
|
1881
|
+
float shadowIntensity;
|
|
1882
|
+
float shadowBias;
|
|
1883
|
+
float shadowNormalBias;
|
|
1884
|
+
float shadowRadius;
|
|
1885
|
+
vec2 shadowMapSize;
|
|
1886
|
+
};
|
|
1887
|
+
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
1888
|
+
#endif
|
|
1889
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1890
|
+
struct SpotLightShadow {
|
|
1891
|
+
float shadowIntensity;
|
|
1892
|
+
float shadowBias;
|
|
1893
|
+
float shadowNormalBias;
|
|
1894
|
+
float shadowRadius;
|
|
1895
|
+
vec2 shadowMapSize;
|
|
1896
|
+
};
|
|
1897
|
+
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
1898
|
+
#endif
|
|
1899
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1900
|
+
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1901
|
+
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1902
|
+
struct PointLightShadow {
|
|
1903
|
+
float shadowIntensity;
|
|
1904
|
+
float shadowBias;
|
|
1905
|
+
float shadowNormalBias;
|
|
1906
|
+
float shadowRadius;
|
|
1907
|
+
vec2 shadowMapSize;
|
|
1908
|
+
float shadowCameraNear;
|
|
1909
|
+
float shadowCameraFar;
|
|
1910
|
+
};
|
|
1911
|
+
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
1912
|
+
#endif
|
|
1913
|
+
#endif`,qf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
1914
|
+
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
|
|
1915
|
+
vec4 shadowWorldPosition;
|
|
1916
|
+
#endif
|
|
1917
|
+
#if defined( USE_SHADOWMAP )
|
|
1918
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1919
|
+
#pragma unroll_loop_start
|
|
1920
|
+
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
1921
|
+
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
|
|
1922
|
+
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
|
|
1923
|
+
}
|
|
1924
|
+
#pragma unroll_loop_end
|
|
1925
|
+
#endif
|
|
1926
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1927
|
+
#pragma unroll_loop_start
|
|
1928
|
+
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
1929
|
+
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
|
|
1930
|
+
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
|
|
1931
|
+
}
|
|
1932
|
+
#pragma unroll_loop_end
|
|
1933
|
+
#endif
|
|
1934
|
+
#endif
|
|
1935
|
+
#if NUM_SPOT_LIGHT_COORDS > 0
|
|
1936
|
+
#pragma unroll_loop_start
|
|
1937
|
+
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
|
|
1938
|
+
shadowWorldPosition = worldPosition;
|
|
1939
|
+
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
1940
|
+
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
|
|
1941
|
+
#endif
|
|
1942
|
+
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
1943
|
+
}
|
|
1944
|
+
#pragma unroll_loop_end
|
|
1945
|
+
#endif`,Yf=`float getShadowMask() {
|
|
1946
|
+
float shadow = 1.0;
|
|
1947
|
+
#ifdef USE_SHADOWMAP
|
|
1948
|
+
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
1949
|
+
DirectionalLightShadow directionalLight;
|
|
1950
|
+
#pragma unroll_loop_start
|
|
1951
|
+
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
1952
|
+
directionalLight = directionalLightShadows[ i ];
|
|
1953
|
+
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
1954
|
+
}
|
|
1955
|
+
#pragma unroll_loop_end
|
|
1956
|
+
#endif
|
|
1957
|
+
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
1958
|
+
SpotLightShadow spotLight;
|
|
1959
|
+
#pragma unroll_loop_start
|
|
1960
|
+
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
1961
|
+
spotLight = spotLightShadows[ i ];
|
|
1962
|
+
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
1963
|
+
}
|
|
1964
|
+
#pragma unroll_loop_end
|
|
1965
|
+
#endif
|
|
1966
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
1967
|
+
PointLightShadow pointLight;
|
|
1968
|
+
#pragma unroll_loop_start
|
|
1969
|
+
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
1970
|
+
pointLight = pointLightShadows[ i ];
|
|
1971
|
+
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
1972
|
+
}
|
|
1973
|
+
#pragma unroll_loop_end
|
|
1974
|
+
#endif
|
|
1975
|
+
#endif
|
|
1976
|
+
return shadow;
|
|
1977
|
+
}`,Zf=`#ifdef USE_SKINNING
|
|
1978
|
+
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
1979
|
+
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
1980
|
+
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
1981
|
+
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
1982
|
+
#endif`,Kf=`#ifdef USE_SKINNING
|
|
1983
|
+
uniform mat4 bindMatrix;
|
|
1984
|
+
uniform mat4 bindMatrixInverse;
|
|
1985
|
+
uniform highp sampler2D boneTexture;
|
|
1986
|
+
mat4 getBoneMatrix( const in float i ) {
|
|
1987
|
+
int size = textureSize( boneTexture, 0 ).x;
|
|
1988
|
+
int j = int( i ) * 4;
|
|
1989
|
+
int x = j % size;
|
|
1990
|
+
int y = j / size;
|
|
1991
|
+
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
|
|
1992
|
+
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
|
|
1993
|
+
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
|
|
1994
|
+
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
1995
|
+
return mat4( v1, v2, v3, v4 );
|
|
1996
|
+
}
|
|
1997
|
+
#endif`,Jf=`#ifdef USE_SKINNING
|
|
1998
|
+
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
1999
|
+
vec4 skinned = vec4( 0.0 );
|
|
2000
|
+
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
2001
|
+
skinned += boneMatY * skinVertex * skinWeight.y;
|
|
2002
|
+
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2003
|
+
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2004
|
+
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2005
|
+
#endif`,$f=`#ifdef USE_SKINNING
|
|
2006
|
+
mat4 skinMatrix = mat4( 0.0 );
|
|
2007
|
+
skinMatrix += skinWeight.x * boneMatX;
|
|
2008
|
+
skinMatrix += skinWeight.y * boneMatY;
|
|
2009
|
+
skinMatrix += skinWeight.z * boneMatZ;
|
|
2010
|
+
skinMatrix += skinWeight.w * boneMatW;
|
|
2011
|
+
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
|
|
2012
|
+
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
|
|
2013
|
+
#ifdef USE_TANGENT
|
|
2014
|
+
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2015
|
+
#endif
|
|
2016
|
+
#endif`,jf=`float specularStrength;
|
|
2017
|
+
#ifdef USE_SPECULARMAP
|
|
2018
|
+
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2019
|
+
specularStrength = texelSpecular.r;
|
|
2020
|
+
#else
|
|
2021
|
+
specularStrength = 1.0;
|
|
2022
|
+
#endif`,Qf=`#ifdef USE_SPECULARMAP
|
|
2023
|
+
uniform sampler2D specularMap;
|
|
2024
|
+
#endif`,ep=`#if defined( TONE_MAPPING )
|
|
2025
|
+
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2026
|
+
#endif`,tp=`#ifndef saturate
|
|
2027
|
+
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2028
|
+
#endif
|
|
2029
|
+
uniform float toneMappingExposure;
|
|
2030
|
+
vec3 LinearToneMapping( vec3 color ) {
|
|
2031
|
+
return saturate( toneMappingExposure * color );
|
|
2032
|
+
}
|
|
2033
|
+
vec3 ReinhardToneMapping( vec3 color ) {
|
|
2034
|
+
color *= toneMappingExposure;
|
|
2035
|
+
return saturate( color / ( vec3( 1.0 ) + color ) );
|
|
2036
|
+
}
|
|
2037
|
+
vec3 CineonToneMapping( vec3 color ) {
|
|
2038
|
+
color *= toneMappingExposure;
|
|
2039
|
+
color = max( vec3( 0.0 ), color - 0.004 );
|
|
2040
|
+
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
|
|
2041
|
+
}
|
|
2042
|
+
vec3 RRTAndODTFit( vec3 v ) {
|
|
2043
|
+
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
|
|
2044
|
+
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
|
|
2045
|
+
return a / b;
|
|
2046
|
+
}
|
|
2047
|
+
vec3 ACESFilmicToneMapping( vec3 color ) {
|
|
2048
|
+
const mat3 ACESInputMat = mat3(
|
|
2049
|
+
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
|
|
2050
|
+
vec3( 0.04823, 0.01566, 0.83777 )
|
|
2051
|
+
);
|
|
2052
|
+
const mat3 ACESOutputMat = mat3(
|
|
2053
|
+
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
|
|
2054
|
+
vec3( -0.07367, -0.00605, 1.07602 )
|
|
2055
|
+
);
|
|
2056
|
+
color *= toneMappingExposure / 0.6;
|
|
2057
|
+
color = ACESInputMat * color;
|
|
2058
|
+
color = RRTAndODTFit( color );
|
|
2059
|
+
color = ACESOutputMat * color;
|
|
2060
|
+
return saturate( color );
|
|
2061
|
+
}
|
|
2062
|
+
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
|
|
2063
|
+
vec3( 1.6605, - 0.1246, - 0.0182 ),
|
|
2064
|
+
vec3( - 0.5876, 1.1329, - 0.1006 ),
|
|
2065
|
+
vec3( - 0.0728, - 0.0083, 1.1187 )
|
|
2066
|
+
);
|
|
2067
|
+
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
|
|
2068
|
+
vec3( 0.6274, 0.0691, 0.0164 ),
|
|
2069
|
+
vec3( 0.3293, 0.9195, 0.0880 ),
|
|
2070
|
+
vec3( 0.0433, 0.0113, 0.8956 )
|
|
2071
|
+
);
|
|
2072
|
+
vec3 agxDefaultContrastApprox( vec3 x ) {
|
|
2073
|
+
vec3 x2 = x * x;
|
|
2074
|
+
vec3 x4 = x2 * x2;
|
|
2075
|
+
return + 15.5 * x4 * x2
|
|
2076
|
+
- 40.14 * x4 * x
|
|
2077
|
+
+ 31.96 * x4
|
|
2078
|
+
- 6.868 * x2 * x
|
|
2079
|
+
+ 0.4298 * x2
|
|
2080
|
+
+ 0.1191 * x
|
|
2081
|
+
- 0.00232;
|
|
2082
|
+
}
|
|
2083
|
+
vec3 AgXToneMapping( vec3 color ) {
|
|
2084
|
+
const mat3 AgXInsetMatrix = mat3(
|
|
2085
|
+
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
|
|
2086
|
+
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
|
|
2087
|
+
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
|
|
2088
|
+
);
|
|
2089
|
+
const mat3 AgXOutsetMatrix = mat3(
|
|
2090
|
+
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
|
|
2091
|
+
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
|
|
2092
|
+
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
|
|
2093
|
+
);
|
|
2094
|
+
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
|
|
2095
|
+
color *= toneMappingExposure;
|
|
2096
|
+
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
|
|
2097
|
+
color = AgXInsetMatrix * color;
|
|
2098
|
+
color = max( color, 1e-10 ); color = log2( color );
|
|
2099
|
+
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
|
|
2100
|
+
color = clamp( color, 0.0, 1.0 );
|
|
2101
|
+
color = agxDefaultContrastApprox( color );
|
|
2102
|
+
color = AgXOutsetMatrix * color;
|
|
2103
|
+
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
|
|
2104
|
+
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
|
|
2105
|
+
color = clamp( color, 0.0, 1.0 );
|
|
2106
|
+
return color;
|
|
2107
|
+
}
|
|
2108
|
+
vec3 NeutralToneMapping( vec3 color ) {
|
|
2109
|
+
const float StartCompression = 0.8 - 0.04;
|
|
2110
|
+
const float Desaturation = 0.15;
|
|
2111
|
+
color *= toneMappingExposure;
|
|
2112
|
+
float x = min( color.r, min( color.g, color.b ) );
|
|
2113
|
+
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
2114
|
+
color -= offset;
|
|
2115
|
+
float peak = max( color.r, max( color.g, color.b ) );
|
|
2116
|
+
if ( peak < StartCompression ) return color;
|
|
2117
|
+
float d = 1. - StartCompression;
|
|
2118
|
+
float newPeak = 1. - d * d / ( peak + d - StartCompression );
|
|
2119
|
+
color *= newPeak / peak;
|
|
2120
|
+
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2121
|
+
return mix( color, vec3( newPeak ), g );
|
|
2122
|
+
}
|
|
2123
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,np=`#ifdef USE_TRANSMISSION
|
|
2124
|
+
material.transmission = transmission;
|
|
2125
|
+
material.transmissionAlpha = 1.0;
|
|
2126
|
+
material.thickness = thickness;
|
|
2127
|
+
material.attenuationDistance = attenuationDistance;
|
|
2128
|
+
material.attenuationColor = attenuationColor;
|
|
2129
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2130
|
+
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
2131
|
+
#endif
|
|
2132
|
+
#ifdef USE_THICKNESSMAP
|
|
2133
|
+
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
2134
|
+
#endif
|
|
2135
|
+
vec3 pos = vWorldPosition;
|
|
2136
|
+
vec3 v = normalize( cameraPosition - pos );
|
|
2137
|
+
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
2138
|
+
vec4 transmitted = getIBLVolumeRefraction(
|
|
2139
|
+
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
2140
|
+
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|
2141
|
+
material.attenuationColor, material.attenuationDistance );
|
|
2142
|
+
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2143
|
+
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2144
|
+
#endif`,ip=`#ifdef USE_TRANSMISSION
|
|
2145
|
+
uniform float transmission;
|
|
2146
|
+
uniform float thickness;
|
|
2147
|
+
uniform float attenuationDistance;
|
|
2148
|
+
uniform vec3 attenuationColor;
|
|
2149
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2150
|
+
uniform sampler2D transmissionMap;
|
|
2151
|
+
#endif
|
|
2152
|
+
#ifdef USE_THICKNESSMAP
|
|
2153
|
+
uniform sampler2D thicknessMap;
|
|
2154
|
+
#endif
|
|
2155
|
+
uniform vec2 transmissionSamplerSize;
|
|
2156
|
+
uniform sampler2D transmissionSamplerMap;
|
|
2157
|
+
uniform mat4 modelMatrix;
|
|
2158
|
+
uniform mat4 projectionMatrix;
|
|
2159
|
+
varying vec3 vWorldPosition;
|
|
2160
|
+
float w0( float a ) {
|
|
2161
|
+
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
|
|
2162
|
+
}
|
|
2163
|
+
float w1( float a ) {
|
|
2164
|
+
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
|
|
2165
|
+
}
|
|
2166
|
+
float w2( float a ){
|
|
2167
|
+
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
|
|
2168
|
+
}
|
|
2169
|
+
float w3( float a ) {
|
|
2170
|
+
return ( 1.0 / 6.0 ) * ( a * a * a );
|
|
2171
|
+
}
|
|
2172
|
+
float g0( float a ) {
|
|
2173
|
+
return w0( a ) + w1( a );
|
|
2174
|
+
}
|
|
2175
|
+
float g1( float a ) {
|
|
2176
|
+
return w2( a ) + w3( a );
|
|
2177
|
+
}
|
|
2178
|
+
float h0( float a ) {
|
|
2179
|
+
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
|
|
2180
|
+
}
|
|
2181
|
+
float h1( float a ) {
|
|
2182
|
+
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
|
|
2183
|
+
}
|
|
2184
|
+
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
|
|
2185
|
+
uv = uv * texelSize.zw + 0.5;
|
|
2186
|
+
vec2 iuv = floor( uv );
|
|
2187
|
+
vec2 fuv = fract( uv );
|
|
2188
|
+
float g0x = g0( fuv.x );
|
|
2189
|
+
float g1x = g1( fuv.x );
|
|
2190
|
+
float h0x = h0( fuv.x );
|
|
2191
|
+
float h1x = h1( fuv.x );
|
|
2192
|
+
float h0y = h0( fuv.y );
|
|
2193
|
+
float h1y = h1( fuv.y );
|
|
2194
|
+
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
2195
|
+
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
|
|
2196
|
+
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
2197
|
+
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
|
|
2198
|
+
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
|
|
2199
|
+
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
|
|
2200
|
+
}
|
|
2201
|
+
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
|
|
2202
|
+
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
|
|
2203
|
+
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
|
|
2204
|
+
vec2 fLodSizeInv = 1.0 / fLodSize;
|
|
2205
|
+
vec2 cLodSizeInv = 1.0 / cLodSize;
|
|
2206
|
+
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
|
|
2207
|
+
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
|
|
2208
|
+
return mix( fSample, cSample, fract( lod ) );
|
|
2209
|
+
}
|
|
2210
|
+
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
|
|
2211
|
+
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
|
|
2212
|
+
vec3 modelScale;
|
|
2213
|
+
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
|
|
2214
|
+
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
|
|
2215
|
+
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
|
|
2216
|
+
return normalize( refractionVector ) * thickness * modelScale;
|
|
2217
|
+
}
|
|
2218
|
+
float applyIorToRoughness( const in float roughness, const in float ior ) {
|
|
2219
|
+
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
|
|
2220
|
+
}
|
|
2221
|
+
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
|
|
2222
|
+
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
|
|
2223
|
+
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
|
|
2224
|
+
}
|
|
2225
|
+
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
2226
|
+
if ( isinf( attenuationDistance ) ) {
|
|
2227
|
+
return vec3( 1.0 );
|
|
2228
|
+
} else {
|
|
2229
|
+
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
|
|
2230
|
+
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
|
|
2234
|
+
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
|
|
2235
|
+
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
|
|
2236
|
+
const in vec3 attenuationColor, const in float attenuationDistance ) {
|
|
2237
|
+
vec4 transmittedLight;
|
|
2238
|
+
vec3 transmittance;
|
|
2239
|
+
#ifdef USE_DISPERSION
|
|
2240
|
+
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
|
|
2241
|
+
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
|
|
2242
|
+
for ( int i = 0; i < 3; i ++ ) {
|
|
2243
|
+
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
|
|
2244
|
+
vec3 refractedRayExit = position + transmissionRay;
|
|
2245
|
+
|
|
2246
|
+
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
2247
|
+
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
2248
|
+
refractionCoords += 1.0;
|
|
2249
|
+
refractionCoords /= 2.0;
|
|
2250
|
+
|
|
2251
|
+
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
|
|
2252
|
+
transmittedLight[ i ] = transmissionSample[ i ];
|
|
2253
|
+
transmittedLight.a += transmissionSample.a;
|
|
2254
|
+
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
|
|
2255
|
+
}
|
|
2256
|
+
transmittedLight.a /= 3.0;
|
|
2257
|
+
|
|
2258
|
+
#else
|
|
2259
|
+
|
|
2260
|
+
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
|
|
2261
|
+
vec3 refractedRayExit = position + transmissionRay;
|
|
2262
|
+
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
|
|
2263
|
+
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
|
|
2264
|
+
refractionCoords += 1.0;
|
|
2265
|
+
refractionCoords /= 2.0;
|
|
2266
|
+
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
|
|
2267
|
+
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
|
|
2268
|
+
|
|
2269
|
+
#endif
|
|
2270
|
+
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
|
|
2271
|
+
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
|
|
2272
|
+
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2273
|
+
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2274
|
+
}
|
|
2275
|
+
#endif`,sp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2276
|
+
varying vec2 vUv;
|
|
2277
|
+
#endif
|
|
2278
|
+
#ifdef USE_MAP
|
|
2279
|
+
varying vec2 vMapUv;
|
|
2280
|
+
#endif
|
|
2281
|
+
#ifdef USE_ALPHAMAP
|
|
2282
|
+
varying vec2 vAlphaMapUv;
|
|
2283
|
+
#endif
|
|
2284
|
+
#ifdef USE_LIGHTMAP
|
|
2285
|
+
varying vec2 vLightMapUv;
|
|
2286
|
+
#endif
|
|
2287
|
+
#ifdef USE_AOMAP
|
|
2288
|
+
varying vec2 vAoMapUv;
|
|
2289
|
+
#endif
|
|
2290
|
+
#ifdef USE_BUMPMAP
|
|
2291
|
+
varying vec2 vBumpMapUv;
|
|
2292
|
+
#endif
|
|
2293
|
+
#ifdef USE_NORMALMAP
|
|
2294
|
+
varying vec2 vNormalMapUv;
|
|
2295
|
+
#endif
|
|
2296
|
+
#ifdef USE_EMISSIVEMAP
|
|
2297
|
+
varying vec2 vEmissiveMapUv;
|
|
2298
|
+
#endif
|
|
2299
|
+
#ifdef USE_METALNESSMAP
|
|
2300
|
+
varying vec2 vMetalnessMapUv;
|
|
2301
|
+
#endif
|
|
2302
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2303
|
+
varying vec2 vRoughnessMapUv;
|
|
2304
|
+
#endif
|
|
2305
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2306
|
+
varying vec2 vAnisotropyMapUv;
|
|
2307
|
+
#endif
|
|
2308
|
+
#ifdef USE_CLEARCOATMAP
|
|
2309
|
+
varying vec2 vClearcoatMapUv;
|
|
2310
|
+
#endif
|
|
2311
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2312
|
+
varying vec2 vClearcoatNormalMapUv;
|
|
2313
|
+
#endif
|
|
2314
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2315
|
+
varying vec2 vClearcoatRoughnessMapUv;
|
|
2316
|
+
#endif
|
|
2317
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2318
|
+
varying vec2 vIridescenceMapUv;
|
|
2319
|
+
#endif
|
|
2320
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2321
|
+
varying vec2 vIridescenceThicknessMapUv;
|
|
2322
|
+
#endif
|
|
2323
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2324
|
+
varying vec2 vSheenColorMapUv;
|
|
2325
|
+
#endif
|
|
2326
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2327
|
+
varying vec2 vSheenRoughnessMapUv;
|
|
2328
|
+
#endif
|
|
2329
|
+
#ifdef USE_SPECULARMAP
|
|
2330
|
+
varying vec2 vSpecularMapUv;
|
|
2331
|
+
#endif
|
|
2332
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2333
|
+
varying vec2 vSpecularColorMapUv;
|
|
2334
|
+
#endif
|
|
2335
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2336
|
+
varying vec2 vSpecularIntensityMapUv;
|
|
2337
|
+
#endif
|
|
2338
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2339
|
+
uniform mat3 transmissionMapTransform;
|
|
2340
|
+
varying vec2 vTransmissionMapUv;
|
|
2341
|
+
#endif
|
|
2342
|
+
#ifdef USE_THICKNESSMAP
|
|
2343
|
+
uniform mat3 thicknessMapTransform;
|
|
2344
|
+
varying vec2 vThicknessMapUv;
|
|
2345
|
+
#endif`,rp=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2346
|
+
varying vec2 vUv;
|
|
2347
|
+
#endif
|
|
2348
|
+
#ifdef USE_MAP
|
|
2349
|
+
uniform mat3 mapTransform;
|
|
2350
|
+
varying vec2 vMapUv;
|
|
2351
|
+
#endif
|
|
2352
|
+
#ifdef USE_ALPHAMAP
|
|
2353
|
+
uniform mat3 alphaMapTransform;
|
|
2354
|
+
varying vec2 vAlphaMapUv;
|
|
2355
|
+
#endif
|
|
2356
|
+
#ifdef USE_LIGHTMAP
|
|
2357
|
+
uniform mat3 lightMapTransform;
|
|
2358
|
+
varying vec2 vLightMapUv;
|
|
2359
|
+
#endif
|
|
2360
|
+
#ifdef USE_AOMAP
|
|
2361
|
+
uniform mat3 aoMapTransform;
|
|
2362
|
+
varying vec2 vAoMapUv;
|
|
2363
|
+
#endif
|
|
2364
|
+
#ifdef USE_BUMPMAP
|
|
2365
|
+
uniform mat3 bumpMapTransform;
|
|
2366
|
+
varying vec2 vBumpMapUv;
|
|
2367
|
+
#endif
|
|
2368
|
+
#ifdef USE_NORMALMAP
|
|
2369
|
+
uniform mat3 normalMapTransform;
|
|
2370
|
+
varying vec2 vNormalMapUv;
|
|
2371
|
+
#endif
|
|
2372
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2373
|
+
uniform mat3 displacementMapTransform;
|
|
2374
|
+
varying vec2 vDisplacementMapUv;
|
|
2375
|
+
#endif
|
|
2376
|
+
#ifdef USE_EMISSIVEMAP
|
|
2377
|
+
uniform mat3 emissiveMapTransform;
|
|
2378
|
+
varying vec2 vEmissiveMapUv;
|
|
2379
|
+
#endif
|
|
2380
|
+
#ifdef USE_METALNESSMAP
|
|
2381
|
+
uniform mat3 metalnessMapTransform;
|
|
2382
|
+
varying vec2 vMetalnessMapUv;
|
|
2383
|
+
#endif
|
|
2384
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2385
|
+
uniform mat3 roughnessMapTransform;
|
|
2386
|
+
varying vec2 vRoughnessMapUv;
|
|
2387
|
+
#endif
|
|
2388
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2389
|
+
uniform mat3 anisotropyMapTransform;
|
|
2390
|
+
varying vec2 vAnisotropyMapUv;
|
|
2391
|
+
#endif
|
|
2392
|
+
#ifdef USE_CLEARCOATMAP
|
|
2393
|
+
uniform mat3 clearcoatMapTransform;
|
|
2394
|
+
varying vec2 vClearcoatMapUv;
|
|
2395
|
+
#endif
|
|
2396
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2397
|
+
uniform mat3 clearcoatNormalMapTransform;
|
|
2398
|
+
varying vec2 vClearcoatNormalMapUv;
|
|
2399
|
+
#endif
|
|
2400
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2401
|
+
uniform mat3 clearcoatRoughnessMapTransform;
|
|
2402
|
+
varying vec2 vClearcoatRoughnessMapUv;
|
|
2403
|
+
#endif
|
|
2404
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2405
|
+
uniform mat3 sheenColorMapTransform;
|
|
2406
|
+
varying vec2 vSheenColorMapUv;
|
|
2407
|
+
#endif
|
|
2408
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2409
|
+
uniform mat3 sheenRoughnessMapTransform;
|
|
2410
|
+
varying vec2 vSheenRoughnessMapUv;
|
|
2411
|
+
#endif
|
|
2412
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2413
|
+
uniform mat3 iridescenceMapTransform;
|
|
2414
|
+
varying vec2 vIridescenceMapUv;
|
|
2415
|
+
#endif
|
|
2416
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2417
|
+
uniform mat3 iridescenceThicknessMapTransform;
|
|
2418
|
+
varying vec2 vIridescenceThicknessMapUv;
|
|
2419
|
+
#endif
|
|
2420
|
+
#ifdef USE_SPECULARMAP
|
|
2421
|
+
uniform mat3 specularMapTransform;
|
|
2422
|
+
varying vec2 vSpecularMapUv;
|
|
2423
|
+
#endif
|
|
2424
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2425
|
+
uniform mat3 specularColorMapTransform;
|
|
2426
|
+
varying vec2 vSpecularColorMapUv;
|
|
2427
|
+
#endif
|
|
2428
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2429
|
+
uniform mat3 specularIntensityMapTransform;
|
|
2430
|
+
varying vec2 vSpecularIntensityMapUv;
|
|
2431
|
+
#endif
|
|
2432
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2433
|
+
uniform mat3 transmissionMapTransform;
|
|
2434
|
+
varying vec2 vTransmissionMapUv;
|
|
2435
|
+
#endif
|
|
2436
|
+
#ifdef USE_THICKNESSMAP
|
|
2437
|
+
uniform mat3 thicknessMapTransform;
|
|
2438
|
+
varying vec2 vThicknessMapUv;
|
|
2439
|
+
#endif`,op=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2440
|
+
vUv = vec3( uv, 1 ).xy;
|
|
2441
|
+
#endif
|
|
2442
|
+
#ifdef USE_MAP
|
|
2443
|
+
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
|
|
2444
|
+
#endif
|
|
2445
|
+
#ifdef USE_ALPHAMAP
|
|
2446
|
+
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
|
|
2447
|
+
#endif
|
|
2448
|
+
#ifdef USE_LIGHTMAP
|
|
2449
|
+
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
|
|
2450
|
+
#endif
|
|
2451
|
+
#ifdef USE_AOMAP
|
|
2452
|
+
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
|
|
2453
|
+
#endif
|
|
2454
|
+
#ifdef USE_BUMPMAP
|
|
2455
|
+
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
|
|
2456
|
+
#endif
|
|
2457
|
+
#ifdef USE_NORMALMAP
|
|
2458
|
+
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
|
|
2459
|
+
#endif
|
|
2460
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2461
|
+
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
|
|
2462
|
+
#endif
|
|
2463
|
+
#ifdef USE_EMISSIVEMAP
|
|
2464
|
+
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
|
|
2465
|
+
#endif
|
|
2466
|
+
#ifdef USE_METALNESSMAP
|
|
2467
|
+
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
|
|
2468
|
+
#endif
|
|
2469
|
+
#ifdef USE_ROUGHNESSMAP
|
|
2470
|
+
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2471
|
+
#endif
|
|
2472
|
+
#ifdef USE_ANISOTROPYMAP
|
|
2473
|
+
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
|
|
2474
|
+
#endif
|
|
2475
|
+
#ifdef USE_CLEARCOATMAP
|
|
2476
|
+
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
|
|
2477
|
+
#endif
|
|
2478
|
+
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2479
|
+
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
|
|
2480
|
+
#endif
|
|
2481
|
+
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2482
|
+
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2483
|
+
#endif
|
|
2484
|
+
#ifdef USE_IRIDESCENCEMAP
|
|
2485
|
+
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
|
|
2486
|
+
#endif
|
|
2487
|
+
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2488
|
+
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
|
|
2489
|
+
#endif
|
|
2490
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
2491
|
+
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
|
|
2492
|
+
#endif
|
|
2493
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
2494
|
+
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
|
|
2495
|
+
#endif
|
|
2496
|
+
#ifdef USE_SPECULARMAP
|
|
2497
|
+
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
|
|
2498
|
+
#endif
|
|
2499
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
2500
|
+
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
|
|
2501
|
+
#endif
|
|
2502
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
2503
|
+
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
|
|
2504
|
+
#endif
|
|
2505
|
+
#ifdef USE_TRANSMISSIONMAP
|
|
2506
|
+
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
|
|
2507
|
+
#endif
|
|
2508
|
+
#ifdef USE_THICKNESSMAP
|
|
2509
|
+
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
2510
|
+
#endif`,ap=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
2511
|
+
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
2512
|
+
#ifdef USE_BATCHING
|
|
2513
|
+
worldPosition = batchingMatrix * worldPosition;
|
|
2514
|
+
#endif
|
|
2515
|
+
#ifdef USE_INSTANCING
|
|
2516
|
+
worldPosition = instanceMatrix * worldPosition;
|
|
2517
|
+
#endif
|
|
2518
|
+
worldPosition = modelMatrix * worldPosition;
|
|
2519
|
+
#endif`,cp=`varying vec2 vUv;
|
|
2520
|
+
uniform mat3 uvTransform;
|
|
2521
|
+
void main() {
|
|
2522
|
+
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
2523
|
+
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
2524
|
+
}`,lp=`uniform sampler2D t2D;
|
|
2525
|
+
uniform float backgroundIntensity;
|
|
2526
|
+
varying vec2 vUv;
|
|
2527
|
+
void main() {
|
|
2528
|
+
vec4 texColor = texture2D( t2D, vUv );
|
|
2529
|
+
#ifdef DECODE_VIDEO_TEXTURE
|
|
2530
|
+
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 );
|
|
2531
|
+
#endif
|
|
2532
|
+
texColor.rgb *= backgroundIntensity;
|
|
2533
|
+
gl_FragColor = texColor;
|
|
2534
|
+
#include <tonemapping_fragment>
|
|
2535
|
+
#include <colorspace_fragment>
|
|
2536
|
+
}`,hp=`varying vec3 vWorldDirection;
|
|
2537
|
+
#include <common>
|
|
2538
|
+
void main() {
|
|
2539
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2540
|
+
#include <begin_vertex>
|
|
2541
|
+
#include <project_vertex>
|
|
2542
|
+
gl_Position.z = gl_Position.w;
|
|
2543
|
+
}`,up=`#ifdef ENVMAP_TYPE_CUBE
|
|
2544
|
+
uniform samplerCube envMap;
|
|
2545
|
+
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2546
|
+
uniform sampler2D envMap;
|
|
2547
|
+
#endif
|
|
2548
|
+
uniform float flipEnvMap;
|
|
2549
|
+
uniform float backgroundBlurriness;
|
|
2550
|
+
uniform float backgroundIntensity;
|
|
2551
|
+
uniform mat3 backgroundRotation;
|
|
2552
|
+
varying vec3 vWorldDirection;
|
|
2553
|
+
#include <cube_uv_reflection_fragment>
|
|
2554
|
+
void main() {
|
|
2555
|
+
#ifdef ENVMAP_TYPE_CUBE
|
|
2556
|
+
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
2557
|
+
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
2558
|
+
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
2559
|
+
#else
|
|
2560
|
+
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
2561
|
+
#endif
|
|
2562
|
+
texColor.rgb *= backgroundIntensity;
|
|
2563
|
+
gl_FragColor = texColor;
|
|
2564
|
+
#include <tonemapping_fragment>
|
|
2565
|
+
#include <colorspace_fragment>
|
|
2566
|
+
}`,dp=`varying vec3 vWorldDirection;
|
|
2567
|
+
#include <common>
|
|
2568
|
+
void main() {
|
|
2569
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2570
|
+
#include <begin_vertex>
|
|
2571
|
+
#include <project_vertex>
|
|
2572
|
+
gl_Position.z = gl_Position.w;
|
|
2573
|
+
}`,fp=`uniform samplerCube tCube;
|
|
2574
|
+
uniform float tFlip;
|
|
2575
|
+
uniform float opacity;
|
|
2576
|
+
varying vec3 vWorldDirection;
|
|
2577
|
+
void main() {
|
|
2578
|
+
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|
2579
|
+
gl_FragColor = texColor;
|
|
2580
|
+
gl_FragColor.a *= opacity;
|
|
2581
|
+
#include <tonemapping_fragment>
|
|
2582
|
+
#include <colorspace_fragment>
|
|
2583
|
+
}`,pp=`#include <common>
|
|
2584
|
+
#include <batching_pars_vertex>
|
|
2585
|
+
#include <uv_pars_vertex>
|
|
2586
|
+
#include <displacementmap_pars_vertex>
|
|
2587
|
+
#include <morphtarget_pars_vertex>
|
|
2588
|
+
#include <skinning_pars_vertex>
|
|
2589
|
+
#include <logdepthbuf_pars_vertex>
|
|
2590
|
+
#include <clipping_planes_pars_vertex>
|
|
2591
|
+
varying vec2 vHighPrecisionZW;
|
|
2592
|
+
void main() {
|
|
2593
|
+
#include <uv_vertex>
|
|
2594
|
+
#include <batching_vertex>
|
|
2595
|
+
#include <skinbase_vertex>
|
|
2596
|
+
#include <morphinstance_vertex>
|
|
2597
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2598
|
+
#include <beginnormal_vertex>
|
|
2599
|
+
#include <morphnormal_vertex>
|
|
2600
|
+
#include <skinnormal_vertex>
|
|
2601
|
+
#endif
|
|
2602
|
+
#include <begin_vertex>
|
|
2603
|
+
#include <morphtarget_vertex>
|
|
2604
|
+
#include <skinning_vertex>
|
|
2605
|
+
#include <displacementmap_vertex>
|
|
2606
|
+
#include <project_vertex>
|
|
2607
|
+
#include <logdepthbuf_vertex>
|
|
2608
|
+
#include <clipping_planes_vertex>
|
|
2609
|
+
vHighPrecisionZW = gl_Position.zw;
|
|
2610
|
+
}`,mp=`#if DEPTH_PACKING == 3200
|
|
2611
|
+
uniform float opacity;
|
|
2612
|
+
#endif
|
|
2613
|
+
#include <common>
|
|
2614
|
+
#include <packing>
|
|
2615
|
+
#include <uv_pars_fragment>
|
|
2616
|
+
#include <map_pars_fragment>
|
|
2617
|
+
#include <alphamap_pars_fragment>
|
|
2618
|
+
#include <alphatest_pars_fragment>
|
|
2619
|
+
#include <alphahash_pars_fragment>
|
|
2620
|
+
#include <logdepthbuf_pars_fragment>
|
|
2621
|
+
#include <clipping_planes_pars_fragment>
|
|
2622
|
+
varying vec2 vHighPrecisionZW;
|
|
2623
|
+
void main() {
|
|
2624
|
+
vec4 diffuseColor = vec4( 1.0 );
|
|
2625
|
+
#include <clipping_planes_fragment>
|
|
2626
|
+
#if DEPTH_PACKING == 3200
|
|
2627
|
+
diffuseColor.a = opacity;
|
|
2628
|
+
#endif
|
|
2629
|
+
#include <map_fragment>
|
|
2630
|
+
#include <alphamap_fragment>
|
|
2631
|
+
#include <alphatest_fragment>
|
|
2632
|
+
#include <alphahash_fragment>
|
|
2633
|
+
#include <logdepthbuf_fragment>
|
|
2634
|
+
float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
|
|
2635
|
+
#if DEPTH_PACKING == 3200
|
|
2636
|
+
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
2637
|
+
#elif DEPTH_PACKING == 3201
|
|
2638
|
+
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
2639
|
+
#elif DEPTH_PACKING == 3202
|
|
2640
|
+
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
2641
|
+
#elif DEPTH_PACKING == 3203
|
|
2642
|
+
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
2643
|
+
#endif
|
|
2644
|
+
}`,gp=`#define DISTANCE
|
|
2645
|
+
varying vec3 vWorldPosition;
|
|
2646
|
+
#include <common>
|
|
2647
|
+
#include <batching_pars_vertex>
|
|
2648
|
+
#include <uv_pars_vertex>
|
|
2649
|
+
#include <displacementmap_pars_vertex>
|
|
2650
|
+
#include <morphtarget_pars_vertex>
|
|
2651
|
+
#include <skinning_pars_vertex>
|
|
2652
|
+
#include <clipping_planes_pars_vertex>
|
|
2653
|
+
void main() {
|
|
2654
|
+
#include <uv_vertex>
|
|
2655
|
+
#include <batching_vertex>
|
|
2656
|
+
#include <skinbase_vertex>
|
|
2657
|
+
#include <morphinstance_vertex>
|
|
2658
|
+
#ifdef USE_DISPLACEMENTMAP
|
|
2659
|
+
#include <beginnormal_vertex>
|
|
2660
|
+
#include <morphnormal_vertex>
|
|
2661
|
+
#include <skinnormal_vertex>
|
|
2662
|
+
#endif
|
|
2663
|
+
#include <begin_vertex>
|
|
2664
|
+
#include <morphtarget_vertex>
|
|
2665
|
+
#include <skinning_vertex>
|
|
2666
|
+
#include <displacementmap_vertex>
|
|
2667
|
+
#include <project_vertex>
|
|
2668
|
+
#include <worldpos_vertex>
|
|
2669
|
+
#include <clipping_planes_vertex>
|
|
2670
|
+
vWorldPosition = worldPosition.xyz;
|
|
2671
|
+
}`,_p=`#define DISTANCE
|
|
2672
|
+
uniform vec3 referencePosition;
|
|
2673
|
+
uniform float nearDistance;
|
|
2674
|
+
uniform float farDistance;
|
|
2675
|
+
varying vec3 vWorldPosition;
|
|
2676
|
+
#include <common>
|
|
2677
|
+
#include <packing>
|
|
2678
|
+
#include <uv_pars_fragment>
|
|
2679
|
+
#include <map_pars_fragment>
|
|
2680
|
+
#include <alphamap_pars_fragment>
|
|
2681
|
+
#include <alphatest_pars_fragment>
|
|
2682
|
+
#include <alphahash_pars_fragment>
|
|
2683
|
+
#include <clipping_planes_pars_fragment>
|
|
2684
|
+
void main () {
|
|
2685
|
+
vec4 diffuseColor = vec4( 1.0 );
|
|
2686
|
+
#include <clipping_planes_fragment>
|
|
2687
|
+
#include <map_fragment>
|
|
2688
|
+
#include <alphamap_fragment>
|
|
2689
|
+
#include <alphatest_fragment>
|
|
2690
|
+
#include <alphahash_fragment>
|
|
2691
|
+
float dist = length( vWorldPosition - referencePosition );
|
|
2692
|
+
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
2693
|
+
dist = saturate( dist );
|
|
2694
|
+
gl_FragColor = packDepthToRGBA( dist );
|
|
2695
|
+
}`,xp=`varying vec3 vWorldDirection;
|
|
2696
|
+
#include <common>
|
|
2697
|
+
void main() {
|
|
2698
|
+
vWorldDirection = transformDirection( position, modelMatrix );
|
|
2699
|
+
#include <begin_vertex>
|
|
2700
|
+
#include <project_vertex>
|
|
2701
|
+
}`,vp=`uniform sampler2D tEquirect;
|
|
2702
|
+
varying vec3 vWorldDirection;
|
|
2703
|
+
#include <common>
|
|
2704
|
+
void main() {
|
|
2705
|
+
vec3 direction = normalize( vWorldDirection );
|
|
2706
|
+
vec2 sampleUV = equirectUv( direction );
|
|
2707
|
+
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
2708
|
+
#include <tonemapping_fragment>
|
|
2709
|
+
#include <colorspace_fragment>
|
|
2710
|
+
}`,yp=`uniform float scale;
|
|
2711
|
+
attribute float lineDistance;
|
|
2712
|
+
varying float vLineDistance;
|
|
2713
|
+
#include <common>
|
|
2714
|
+
#include <uv_pars_vertex>
|
|
2715
|
+
#include <color_pars_vertex>
|
|
2716
|
+
#include <fog_pars_vertex>
|
|
2717
|
+
#include <morphtarget_pars_vertex>
|
|
2718
|
+
#include <logdepthbuf_pars_vertex>
|
|
2719
|
+
#include <clipping_planes_pars_vertex>
|
|
2720
|
+
void main() {
|
|
2721
|
+
vLineDistance = scale * lineDistance;
|
|
2722
|
+
#include <uv_vertex>
|
|
2723
|
+
#include <color_vertex>
|
|
2724
|
+
#include <morphinstance_vertex>
|
|
2725
|
+
#include <morphcolor_vertex>
|
|
2726
|
+
#include <begin_vertex>
|
|
2727
|
+
#include <morphtarget_vertex>
|
|
2728
|
+
#include <project_vertex>
|
|
2729
|
+
#include <logdepthbuf_vertex>
|
|
2730
|
+
#include <clipping_planes_vertex>
|
|
2731
|
+
#include <fog_vertex>
|
|
2732
|
+
}`,Mp=`uniform vec3 diffuse;
|
|
2733
|
+
uniform float opacity;
|
|
2734
|
+
uniform float dashSize;
|
|
2735
|
+
uniform float totalSize;
|
|
2736
|
+
varying float vLineDistance;
|
|
2737
|
+
#include <common>
|
|
2738
|
+
#include <color_pars_fragment>
|
|
2739
|
+
#include <uv_pars_fragment>
|
|
2740
|
+
#include <map_pars_fragment>
|
|
2741
|
+
#include <fog_pars_fragment>
|
|
2742
|
+
#include <logdepthbuf_pars_fragment>
|
|
2743
|
+
#include <clipping_planes_pars_fragment>
|
|
2744
|
+
void main() {
|
|
2745
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2746
|
+
#include <clipping_planes_fragment>
|
|
2747
|
+
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
2748
|
+
discard;
|
|
2749
|
+
}
|
|
2750
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
2751
|
+
#include <logdepthbuf_fragment>
|
|
2752
|
+
#include <map_fragment>
|
|
2753
|
+
#include <color_fragment>
|
|
2754
|
+
outgoingLight = diffuseColor.rgb;
|
|
2755
|
+
#include <opaque_fragment>
|
|
2756
|
+
#include <tonemapping_fragment>
|
|
2757
|
+
#include <colorspace_fragment>
|
|
2758
|
+
#include <fog_fragment>
|
|
2759
|
+
#include <premultiplied_alpha_fragment>
|
|
2760
|
+
}`,Sp=`#include <common>
|
|
2761
|
+
#include <batching_pars_vertex>
|
|
2762
|
+
#include <uv_pars_vertex>
|
|
2763
|
+
#include <envmap_pars_vertex>
|
|
2764
|
+
#include <color_pars_vertex>
|
|
2765
|
+
#include <fog_pars_vertex>
|
|
2766
|
+
#include <morphtarget_pars_vertex>
|
|
2767
|
+
#include <skinning_pars_vertex>
|
|
2768
|
+
#include <logdepthbuf_pars_vertex>
|
|
2769
|
+
#include <clipping_planes_pars_vertex>
|
|
2770
|
+
void main() {
|
|
2771
|
+
#include <uv_vertex>
|
|
2772
|
+
#include <color_vertex>
|
|
2773
|
+
#include <morphinstance_vertex>
|
|
2774
|
+
#include <morphcolor_vertex>
|
|
2775
|
+
#include <batching_vertex>
|
|
2776
|
+
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
2777
|
+
#include <beginnormal_vertex>
|
|
2778
|
+
#include <morphnormal_vertex>
|
|
2779
|
+
#include <skinbase_vertex>
|
|
2780
|
+
#include <skinnormal_vertex>
|
|
2781
|
+
#include <defaultnormal_vertex>
|
|
2782
|
+
#endif
|
|
2783
|
+
#include <begin_vertex>
|
|
2784
|
+
#include <morphtarget_vertex>
|
|
2785
|
+
#include <skinning_vertex>
|
|
2786
|
+
#include <project_vertex>
|
|
2787
|
+
#include <logdepthbuf_vertex>
|
|
2788
|
+
#include <clipping_planes_vertex>
|
|
2789
|
+
#include <worldpos_vertex>
|
|
2790
|
+
#include <envmap_vertex>
|
|
2791
|
+
#include <fog_vertex>
|
|
2792
|
+
}`,bp=`uniform vec3 diffuse;
|
|
2793
|
+
uniform float opacity;
|
|
2794
|
+
#ifndef FLAT_SHADED
|
|
2795
|
+
varying vec3 vNormal;
|
|
2796
|
+
#endif
|
|
2797
|
+
#include <common>
|
|
2798
|
+
#include <dithering_pars_fragment>
|
|
2799
|
+
#include <color_pars_fragment>
|
|
2800
|
+
#include <uv_pars_fragment>
|
|
2801
|
+
#include <map_pars_fragment>
|
|
2802
|
+
#include <alphamap_pars_fragment>
|
|
2803
|
+
#include <alphatest_pars_fragment>
|
|
2804
|
+
#include <alphahash_pars_fragment>
|
|
2805
|
+
#include <aomap_pars_fragment>
|
|
2806
|
+
#include <lightmap_pars_fragment>
|
|
2807
|
+
#include <envmap_common_pars_fragment>
|
|
2808
|
+
#include <envmap_pars_fragment>
|
|
2809
|
+
#include <fog_pars_fragment>
|
|
2810
|
+
#include <specularmap_pars_fragment>
|
|
2811
|
+
#include <logdepthbuf_pars_fragment>
|
|
2812
|
+
#include <clipping_planes_pars_fragment>
|
|
2813
|
+
void main() {
|
|
2814
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2815
|
+
#include <clipping_planes_fragment>
|
|
2816
|
+
#include <logdepthbuf_fragment>
|
|
2817
|
+
#include <map_fragment>
|
|
2818
|
+
#include <color_fragment>
|
|
2819
|
+
#include <alphamap_fragment>
|
|
2820
|
+
#include <alphatest_fragment>
|
|
2821
|
+
#include <alphahash_fragment>
|
|
2822
|
+
#include <specularmap_fragment>
|
|
2823
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
2824
|
+
#ifdef USE_LIGHTMAP
|
|
2825
|
+
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
2826
|
+
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
2827
|
+
#else
|
|
2828
|
+
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
2829
|
+
#endif
|
|
2830
|
+
#include <aomap_fragment>
|
|
2831
|
+
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
2832
|
+
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
2833
|
+
#include <envmap_fragment>
|
|
2834
|
+
#include <opaque_fragment>
|
|
2835
|
+
#include <tonemapping_fragment>
|
|
2836
|
+
#include <colorspace_fragment>
|
|
2837
|
+
#include <fog_fragment>
|
|
2838
|
+
#include <premultiplied_alpha_fragment>
|
|
2839
|
+
#include <dithering_fragment>
|
|
2840
|
+
}`,Ap=`#define LAMBERT
|
|
2841
|
+
varying vec3 vViewPosition;
|
|
2842
|
+
#include <common>
|
|
2843
|
+
#include <batching_pars_vertex>
|
|
2844
|
+
#include <uv_pars_vertex>
|
|
2845
|
+
#include <displacementmap_pars_vertex>
|
|
2846
|
+
#include <envmap_pars_vertex>
|
|
2847
|
+
#include <color_pars_vertex>
|
|
2848
|
+
#include <fog_pars_vertex>
|
|
2849
|
+
#include <normal_pars_vertex>
|
|
2850
|
+
#include <morphtarget_pars_vertex>
|
|
2851
|
+
#include <skinning_pars_vertex>
|
|
2852
|
+
#include <shadowmap_pars_vertex>
|
|
2853
|
+
#include <logdepthbuf_pars_vertex>
|
|
2854
|
+
#include <clipping_planes_pars_vertex>
|
|
2855
|
+
void main() {
|
|
2856
|
+
#include <uv_vertex>
|
|
2857
|
+
#include <color_vertex>
|
|
2858
|
+
#include <morphinstance_vertex>
|
|
2859
|
+
#include <morphcolor_vertex>
|
|
2860
|
+
#include <batching_vertex>
|
|
2861
|
+
#include <beginnormal_vertex>
|
|
2862
|
+
#include <morphnormal_vertex>
|
|
2863
|
+
#include <skinbase_vertex>
|
|
2864
|
+
#include <skinnormal_vertex>
|
|
2865
|
+
#include <defaultnormal_vertex>
|
|
2866
|
+
#include <normal_vertex>
|
|
2867
|
+
#include <begin_vertex>
|
|
2868
|
+
#include <morphtarget_vertex>
|
|
2869
|
+
#include <skinning_vertex>
|
|
2870
|
+
#include <displacementmap_vertex>
|
|
2871
|
+
#include <project_vertex>
|
|
2872
|
+
#include <logdepthbuf_vertex>
|
|
2873
|
+
#include <clipping_planes_vertex>
|
|
2874
|
+
vViewPosition = - mvPosition.xyz;
|
|
2875
|
+
#include <worldpos_vertex>
|
|
2876
|
+
#include <envmap_vertex>
|
|
2877
|
+
#include <shadowmap_vertex>
|
|
2878
|
+
#include <fog_vertex>
|
|
2879
|
+
}`,Tp=`#define LAMBERT
|
|
2880
|
+
uniform vec3 diffuse;
|
|
2881
|
+
uniform vec3 emissive;
|
|
2882
|
+
uniform float opacity;
|
|
2883
|
+
#include <common>
|
|
2884
|
+
#include <packing>
|
|
2885
|
+
#include <dithering_pars_fragment>
|
|
2886
|
+
#include <color_pars_fragment>
|
|
2887
|
+
#include <uv_pars_fragment>
|
|
2888
|
+
#include <map_pars_fragment>
|
|
2889
|
+
#include <alphamap_pars_fragment>
|
|
2890
|
+
#include <alphatest_pars_fragment>
|
|
2891
|
+
#include <alphahash_pars_fragment>
|
|
2892
|
+
#include <aomap_pars_fragment>
|
|
2893
|
+
#include <lightmap_pars_fragment>
|
|
2894
|
+
#include <emissivemap_pars_fragment>
|
|
2895
|
+
#include <envmap_common_pars_fragment>
|
|
2896
|
+
#include <envmap_pars_fragment>
|
|
2897
|
+
#include <fog_pars_fragment>
|
|
2898
|
+
#include <bsdfs>
|
|
2899
|
+
#include <lights_pars_begin>
|
|
2900
|
+
#include <normal_pars_fragment>
|
|
2901
|
+
#include <lights_lambert_pars_fragment>
|
|
2902
|
+
#include <shadowmap_pars_fragment>
|
|
2903
|
+
#include <bumpmap_pars_fragment>
|
|
2904
|
+
#include <normalmap_pars_fragment>
|
|
2905
|
+
#include <specularmap_pars_fragment>
|
|
2906
|
+
#include <logdepthbuf_pars_fragment>
|
|
2907
|
+
#include <clipping_planes_pars_fragment>
|
|
2908
|
+
void main() {
|
|
2909
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2910
|
+
#include <clipping_planes_fragment>
|
|
2911
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
2912
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
2913
|
+
#include <logdepthbuf_fragment>
|
|
2914
|
+
#include <map_fragment>
|
|
2915
|
+
#include <color_fragment>
|
|
2916
|
+
#include <alphamap_fragment>
|
|
2917
|
+
#include <alphatest_fragment>
|
|
2918
|
+
#include <alphahash_fragment>
|
|
2919
|
+
#include <specularmap_fragment>
|
|
2920
|
+
#include <normal_fragment_begin>
|
|
2921
|
+
#include <normal_fragment_maps>
|
|
2922
|
+
#include <emissivemap_fragment>
|
|
2923
|
+
#include <lights_lambert_fragment>
|
|
2924
|
+
#include <lights_fragment_begin>
|
|
2925
|
+
#include <lights_fragment_maps>
|
|
2926
|
+
#include <lights_fragment_end>
|
|
2927
|
+
#include <aomap_fragment>
|
|
2928
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
2929
|
+
#include <envmap_fragment>
|
|
2930
|
+
#include <opaque_fragment>
|
|
2931
|
+
#include <tonemapping_fragment>
|
|
2932
|
+
#include <colorspace_fragment>
|
|
2933
|
+
#include <fog_fragment>
|
|
2934
|
+
#include <premultiplied_alpha_fragment>
|
|
2935
|
+
#include <dithering_fragment>
|
|
2936
|
+
}`,Ep=`#define MATCAP
|
|
2937
|
+
varying vec3 vViewPosition;
|
|
2938
|
+
#include <common>
|
|
2939
|
+
#include <batching_pars_vertex>
|
|
2940
|
+
#include <uv_pars_vertex>
|
|
2941
|
+
#include <color_pars_vertex>
|
|
2942
|
+
#include <displacementmap_pars_vertex>
|
|
2943
|
+
#include <fog_pars_vertex>
|
|
2944
|
+
#include <normal_pars_vertex>
|
|
2945
|
+
#include <morphtarget_pars_vertex>
|
|
2946
|
+
#include <skinning_pars_vertex>
|
|
2947
|
+
#include <logdepthbuf_pars_vertex>
|
|
2948
|
+
#include <clipping_planes_pars_vertex>
|
|
2949
|
+
void main() {
|
|
2950
|
+
#include <uv_vertex>
|
|
2951
|
+
#include <color_vertex>
|
|
2952
|
+
#include <morphinstance_vertex>
|
|
2953
|
+
#include <morphcolor_vertex>
|
|
2954
|
+
#include <batching_vertex>
|
|
2955
|
+
#include <beginnormal_vertex>
|
|
2956
|
+
#include <morphnormal_vertex>
|
|
2957
|
+
#include <skinbase_vertex>
|
|
2958
|
+
#include <skinnormal_vertex>
|
|
2959
|
+
#include <defaultnormal_vertex>
|
|
2960
|
+
#include <normal_vertex>
|
|
2961
|
+
#include <begin_vertex>
|
|
2962
|
+
#include <morphtarget_vertex>
|
|
2963
|
+
#include <skinning_vertex>
|
|
2964
|
+
#include <displacementmap_vertex>
|
|
2965
|
+
#include <project_vertex>
|
|
2966
|
+
#include <logdepthbuf_vertex>
|
|
2967
|
+
#include <clipping_planes_vertex>
|
|
2968
|
+
#include <fog_vertex>
|
|
2969
|
+
vViewPosition = - mvPosition.xyz;
|
|
2970
|
+
}`,wp=`#define MATCAP
|
|
2971
|
+
uniform vec3 diffuse;
|
|
2972
|
+
uniform float opacity;
|
|
2973
|
+
uniform sampler2D matcap;
|
|
2974
|
+
varying vec3 vViewPosition;
|
|
2975
|
+
#include <common>
|
|
2976
|
+
#include <dithering_pars_fragment>
|
|
2977
|
+
#include <color_pars_fragment>
|
|
2978
|
+
#include <uv_pars_fragment>
|
|
2979
|
+
#include <map_pars_fragment>
|
|
2980
|
+
#include <alphamap_pars_fragment>
|
|
2981
|
+
#include <alphatest_pars_fragment>
|
|
2982
|
+
#include <alphahash_pars_fragment>
|
|
2983
|
+
#include <fog_pars_fragment>
|
|
2984
|
+
#include <normal_pars_fragment>
|
|
2985
|
+
#include <bumpmap_pars_fragment>
|
|
2986
|
+
#include <normalmap_pars_fragment>
|
|
2987
|
+
#include <logdepthbuf_pars_fragment>
|
|
2988
|
+
#include <clipping_planes_pars_fragment>
|
|
2989
|
+
void main() {
|
|
2990
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
2991
|
+
#include <clipping_planes_fragment>
|
|
2992
|
+
#include <logdepthbuf_fragment>
|
|
2993
|
+
#include <map_fragment>
|
|
2994
|
+
#include <color_fragment>
|
|
2995
|
+
#include <alphamap_fragment>
|
|
2996
|
+
#include <alphatest_fragment>
|
|
2997
|
+
#include <alphahash_fragment>
|
|
2998
|
+
#include <normal_fragment_begin>
|
|
2999
|
+
#include <normal_fragment_maps>
|
|
3000
|
+
vec3 viewDir = normalize( vViewPosition );
|
|
3001
|
+
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
3002
|
+
vec3 y = cross( viewDir, x );
|
|
3003
|
+
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
3004
|
+
#ifdef USE_MATCAP
|
|
3005
|
+
vec4 matcapColor = texture2D( matcap, uv );
|
|
3006
|
+
#else
|
|
3007
|
+
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
3008
|
+
#endif
|
|
3009
|
+
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
3010
|
+
#include <opaque_fragment>
|
|
3011
|
+
#include <tonemapping_fragment>
|
|
3012
|
+
#include <colorspace_fragment>
|
|
3013
|
+
#include <fog_fragment>
|
|
3014
|
+
#include <premultiplied_alpha_fragment>
|
|
3015
|
+
#include <dithering_fragment>
|
|
3016
|
+
}`,Rp=`#define NORMAL
|
|
3017
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3018
|
+
varying vec3 vViewPosition;
|
|
3019
|
+
#endif
|
|
3020
|
+
#include <common>
|
|
3021
|
+
#include <batching_pars_vertex>
|
|
3022
|
+
#include <uv_pars_vertex>
|
|
3023
|
+
#include <displacementmap_pars_vertex>
|
|
3024
|
+
#include <normal_pars_vertex>
|
|
3025
|
+
#include <morphtarget_pars_vertex>
|
|
3026
|
+
#include <skinning_pars_vertex>
|
|
3027
|
+
#include <logdepthbuf_pars_vertex>
|
|
3028
|
+
#include <clipping_planes_pars_vertex>
|
|
3029
|
+
void main() {
|
|
3030
|
+
#include <uv_vertex>
|
|
3031
|
+
#include <batching_vertex>
|
|
3032
|
+
#include <beginnormal_vertex>
|
|
3033
|
+
#include <morphinstance_vertex>
|
|
3034
|
+
#include <morphnormal_vertex>
|
|
3035
|
+
#include <skinbase_vertex>
|
|
3036
|
+
#include <skinnormal_vertex>
|
|
3037
|
+
#include <defaultnormal_vertex>
|
|
3038
|
+
#include <normal_vertex>
|
|
3039
|
+
#include <begin_vertex>
|
|
3040
|
+
#include <morphtarget_vertex>
|
|
3041
|
+
#include <skinning_vertex>
|
|
3042
|
+
#include <displacementmap_vertex>
|
|
3043
|
+
#include <project_vertex>
|
|
3044
|
+
#include <logdepthbuf_vertex>
|
|
3045
|
+
#include <clipping_planes_vertex>
|
|
3046
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3047
|
+
vViewPosition = - mvPosition.xyz;
|
|
3048
|
+
#endif
|
|
3049
|
+
}`,Cp=`#define NORMAL
|
|
3050
|
+
uniform float opacity;
|
|
3051
|
+
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3052
|
+
varying vec3 vViewPosition;
|
|
3053
|
+
#endif
|
|
3054
|
+
#include <packing>
|
|
3055
|
+
#include <uv_pars_fragment>
|
|
3056
|
+
#include <normal_pars_fragment>
|
|
3057
|
+
#include <bumpmap_pars_fragment>
|
|
3058
|
+
#include <normalmap_pars_fragment>
|
|
3059
|
+
#include <logdepthbuf_pars_fragment>
|
|
3060
|
+
#include <clipping_planes_pars_fragment>
|
|
3061
|
+
void main() {
|
|
3062
|
+
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
3063
|
+
#include <clipping_planes_fragment>
|
|
3064
|
+
#include <logdepthbuf_fragment>
|
|
3065
|
+
#include <normal_fragment_begin>
|
|
3066
|
+
#include <normal_fragment_maps>
|
|
3067
|
+
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
|
3068
|
+
#ifdef OPAQUE
|
|
3069
|
+
gl_FragColor.a = 1.0;
|
|
3070
|
+
#endif
|
|
3071
|
+
}`,Ip=`#define PHONG
|
|
3072
|
+
varying vec3 vViewPosition;
|
|
3073
|
+
#include <common>
|
|
3074
|
+
#include <batching_pars_vertex>
|
|
3075
|
+
#include <uv_pars_vertex>
|
|
3076
|
+
#include <displacementmap_pars_vertex>
|
|
3077
|
+
#include <envmap_pars_vertex>
|
|
3078
|
+
#include <color_pars_vertex>
|
|
3079
|
+
#include <fog_pars_vertex>
|
|
3080
|
+
#include <normal_pars_vertex>
|
|
3081
|
+
#include <morphtarget_pars_vertex>
|
|
3082
|
+
#include <skinning_pars_vertex>
|
|
3083
|
+
#include <shadowmap_pars_vertex>
|
|
3084
|
+
#include <logdepthbuf_pars_vertex>
|
|
3085
|
+
#include <clipping_planes_pars_vertex>
|
|
3086
|
+
void main() {
|
|
3087
|
+
#include <uv_vertex>
|
|
3088
|
+
#include <color_vertex>
|
|
3089
|
+
#include <morphcolor_vertex>
|
|
3090
|
+
#include <batching_vertex>
|
|
3091
|
+
#include <beginnormal_vertex>
|
|
3092
|
+
#include <morphinstance_vertex>
|
|
3093
|
+
#include <morphnormal_vertex>
|
|
3094
|
+
#include <skinbase_vertex>
|
|
3095
|
+
#include <skinnormal_vertex>
|
|
3096
|
+
#include <defaultnormal_vertex>
|
|
3097
|
+
#include <normal_vertex>
|
|
3098
|
+
#include <begin_vertex>
|
|
3099
|
+
#include <morphtarget_vertex>
|
|
3100
|
+
#include <skinning_vertex>
|
|
3101
|
+
#include <displacementmap_vertex>
|
|
3102
|
+
#include <project_vertex>
|
|
3103
|
+
#include <logdepthbuf_vertex>
|
|
3104
|
+
#include <clipping_planes_vertex>
|
|
3105
|
+
vViewPosition = - mvPosition.xyz;
|
|
3106
|
+
#include <worldpos_vertex>
|
|
3107
|
+
#include <envmap_vertex>
|
|
3108
|
+
#include <shadowmap_vertex>
|
|
3109
|
+
#include <fog_vertex>
|
|
3110
|
+
}`,Pp=`#define PHONG
|
|
3111
|
+
uniform vec3 diffuse;
|
|
3112
|
+
uniform vec3 emissive;
|
|
3113
|
+
uniform vec3 specular;
|
|
3114
|
+
uniform float shininess;
|
|
3115
|
+
uniform float opacity;
|
|
3116
|
+
#include <common>
|
|
3117
|
+
#include <packing>
|
|
3118
|
+
#include <dithering_pars_fragment>
|
|
3119
|
+
#include <color_pars_fragment>
|
|
3120
|
+
#include <uv_pars_fragment>
|
|
3121
|
+
#include <map_pars_fragment>
|
|
3122
|
+
#include <alphamap_pars_fragment>
|
|
3123
|
+
#include <alphatest_pars_fragment>
|
|
3124
|
+
#include <alphahash_pars_fragment>
|
|
3125
|
+
#include <aomap_pars_fragment>
|
|
3126
|
+
#include <lightmap_pars_fragment>
|
|
3127
|
+
#include <emissivemap_pars_fragment>
|
|
3128
|
+
#include <envmap_common_pars_fragment>
|
|
3129
|
+
#include <envmap_pars_fragment>
|
|
3130
|
+
#include <fog_pars_fragment>
|
|
3131
|
+
#include <bsdfs>
|
|
3132
|
+
#include <lights_pars_begin>
|
|
3133
|
+
#include <normal_pars_fragment>
|
|
3134
|
+
#include <lights_phong_pars_fragment>
|
|
3135
|
+
#include <shadowmap_pars_fragment>
|
|
3136
|
+
#include <bumpmap_pars_fragment>
|
|
3137
|
+
#include <normalmap_pars_fragment>
|
|
3138
|
+
#include <specularmap_pars_fragment>
|
|
3139
|
+
#include <logdepthbuf_pars_fragment>
|
|
3140
|
+
#include <clipping_planes_pars_fragment>
|
|
3141
|
+
void main() {
|
|
3142
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3143
|
+
#include <clipping_planes_fragment>
|
|
3144
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3145
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3146
|
+
#include <logdepthbuf_fragment>
|
|
3147
|
+
#include <map_fragment>
|
|
3148
|
+
#include <color_fragment>
|
|
3149
|
+
#include <alphamap_fragment>
|
|
3150
|
+
#include <alphatest_fragment>
|
|
3151
|
+
#include <alphahash_fragment>
|
|
3152
|
+
#include <specularmap_fragment>
|
|
3153
|
+
#include <normal_fragment_begin>
|
|
3154
|
+
#include <normal_fragment_maps>
|
|
3155
|
+
#include <emissivemap_fragment>
|
|
3156
|
+
#include <lights_phong_fragment>
|
|
3157
|
+
#include <lights_fragment_begin>
|
|
3158
|
+
#include <lights_fragment_maps>
|
|
3159
|
+
#include <lights_fragment_end>
|
|
3160
|
+
#include <aomap_fragment>
|
|
3161
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
3162
|
+
#include <envmap_fragment>
|
|
3163
|
+
#include <opaque_fragment>
|
|
3164
|
+
#include <tonemapping_fragment>
|
|
3165
|
+
#include <colorspace_fragment>
|
|
3166
|
+
#include <fog_fragment>
|
|
3167
|
+
#include <premultiplied_alpha_fragment>
|
|
3168
|
+
#include <dithering_fragment>
|
|
3169
|
+
}`,Lp=`#define STANDARD
|
|
3170
|
+
varying vec3 vViewPosition;
|
|
3171
|
+
#ifdef USE_TRANSMISSION
|
|
3172
|
+
varying vec3 vWorldPosition;
|
|
3173
|
+
#endif
|
|
3174
|
+
#include <common>
|
|
3175
|
+
#include <batching_pars_vertex>
|
|
3176
|
+
#include <uv_pars_vertex>
|
|
3177
|
+
#include <displacementmap_pars_vertex>
|
|
3178
|
+
#include <color_pars_vertex>
|
|
3179
|
+
#include <fog_pars_vertex>
|
|
3180
|
+
#include <normal_pars_vertex>
|
|
3181
|
+
#include <morphtarget_pars_vertex>
|
|
3182
|
+
#include <skinning_pars_vertex>
|
|
3183
|
+
#include <shadowmap_pars_vertex>
|
|
3184
|
+
#include <logdepthbuf_pars_vertex>
|
|
3185
|
+
#include <clipping_planes_pars_vertex>
|
|
3186
|
+
void main() {
|
|
3187
|
+
#include <uv_vertex>
|
|
3188
|
+
#include <color_vertex>
|
|
3189
|
+
#include <morphinstance_vertex>
|
|
3190
|
+
#include <morphcolor_vertex>
|
|
3191
|
+
#include <batching_vertex>
|
|
3192
|
+
#include <beginnormal_vertex>
|
|
3193
|
+
#include <morphnormal_vertex>
|
|
3194
|
+
#include <skinbase_vertex>
|
|
3195
|
+
#include <skinnormal_vertex>
|
|
3196
|
+
#include <defaultnormal_vertex>
|
|
3197
|
+
#include <normal_vertex>
|
|
3198
|
+
#include <begin_vertex>
|
|
3199
|
+
#include <morphtarget_vertex>
|
|
3200
|
+
#include <skinning_vertex>
|
|
3201
|
+
#include <displacementmap_vertex>
|
|
3202
|
+
#include <project_vertex>
|
|
3203
|
+
#include <logdepthbuf_vertex>
|
|
3204
|
+
#include <clipping_planes_vertex>
|
|
3205
|
+
vViewPosition = - mvPosition.xyz;
|
|
3206
|
+
#include <worldpos_vertex>
|
|
3207
|
+
#include <shadowmap_vertex>
|
|
3208
|
+
#include <fog_vertex>
|
|
3209
|
+
#ifdef USE_TRANSMISSION
|
|
3210
|
+
vWorldPosition = worldPosition.xyz;
|
|
3211
|
+
#endif
|
|
3212
|
+
}`,Dp=`#define STANDARD
|
|
3213
|
+
#ifdef PHYSICAL
|
|
3214
|
+
#define IOR
|
|
3215
|
+
#define USE_SPECULAR
|
|
3216
|
+
#endif
|
|
3217
|
+
uniform vec3 diffuse;
|
|
3218
|
+
uniform vec3 emissive;
|
|
3219
|
+
uniform float roughness;
|
|
3220
|
+
uniform float metalness;
|
|
3221
|
+
uniform float opacity;
|
|
3222
|
+
#ifdef IOR
|
|
3223
|
+
uniform float ior;
|
|
3224
|
+
#endif
|
|
3225
|
+
#ifdef USE_SPECULAR
|
|
3226
|
+
uniform float specularIntensity;
|
|
3227
|
+
uniform vec3 specularColor;
|
|
3228
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
3229
|
+
uniform sampler2D specularColorMap;
|
|
3230
|
+
#endif
|
|
3231
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
3232
|
+
uniform sampler2D specularIntensityMap;
|
|
3233
|
+
#endif
|
|
3234
|
+
#endif
|
|
3235
|
+
#ifdef USE_CLEARCOAT
|
|
3236
|
+
uniform float clearcoat;
|
|
3237
|
+
uniform float clearcoatRoughness;
|
|
3238
|
+
#endif
|
|
3239
|
+
#ifdef USE_DISPERSION
|
|
3240
|
+
uniform float dispersion;
|
|
3241
|
+
#endif
|
|
3242
|
+
#ifdef USE_IRIDESCENCE
|
|
3243
|
+
uniform float iridescence;
|
|
3244
|
+
uniform float iridescenceIOR;
|
|
3245
|
+
uniform float iridescenceThicknessMinimum;
|
|
3246
|
+
uniform float iridescenceThicknessMaximum;
|
|
3247
|
+
#endif
|
|
3248
|
+
#ifdef USE_SHEEN
|
|
3249
|
+
uniform vec3 sheenColor;
|
|
3250
|
+
uniform float sheenRoughness;
|
|
3251
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
3252
|
+
uniform sampler2D sheenColorMap;
|
|
3253
|
+
#endif
|
|
3254
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
3255
|
+
uniform sampler2D sheenRoughnessMap;
|
|
3256
|
+
#endif
|
|
3257
|
+
#endif
|
|
3258
|
+
#ifdef USE_ANISOTROPY
|
|
3259
|
+
uniform vec2 anisotropyVector;
|
|
3260
|
+
#ifdef USE_ANISOTROPYMAP
|
|
3261
|
+
uniform sampler2D anisotropyMap;
|
|
3262
|
+
#endif
|
|
3263
|
+
#endif
|
|
3264
|
+
varying vec3 vViewPosition;
|
|
3265
|
+
#include <common>
|
|
3266
|
+
#include <packing>
|
|
3267
|
+
#include <dithering_pars_fragment>
|
|
3268
|
+
#include <color_pars_fragment>
|
|
3269
|
+
#include <uv_pars_fragment>
|
|
3270
|
+
#include <map_pars_fragment>
|
|
3271
|
+
#include <alphamap_pars_fragment>
|
|
3272
|
+
#include <alphatest_pars_fragment>
|
|
3273
|
+
#include <alphahash_pars_fragment>
|
|
3274
|
+
#include <aomap_pars_fragment>
|
|
3275
|
+
#include <lightmap_pars_fragment>
|
|
3276
|
+
#include <emissivemap_pars_fragment>
|
|
3277
|
+
#include <iridescence_fragment>
|
|
3278
|
+
#include <cube_uv_reflection_fragment>
|
|
3279
|
+
#include <envmap_common_pars_fragment>
|
|
3280
|
+
#include <envmap_physical_pars_fragment>
|
|
3281
|
+
#include <fog_pars_fragment>
|
|
3282
|
+
#include <lights_pars_begin>
|
|
3283
|
+
#include <normal_pars_fragment>
|
|
3284
|
+
#include <lights_physical_pars_fragment>
|
|
3285
|
+
#include <transmission_pars_fragment>
|
|
3286
|
+
#include <shadowmap_pars_fragment>
|
|
3287
|
+
#include <bumpmap_pars_fragment>
|
|
3288
|
+
#include <normalmap_pars_fragment>
|
|
3289
|
+
#include <clearcoat_pars_fragment>
|
|
3290
|
+
#include <iridescence_pars_fragment>
|
|
3291
|
+
#include <roughnessmap_pars_fragment>
|
|
3292
|
+
#include <metalnessmap_pars_fragment>
|
|
3293
|
+
#include <logdepthbuf_pars_fragment>
|
|
3294
|
+
#include <clipping_planes_pars_fragment>
|
|
3295
|
+
void main() {
|
|
3296
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3297
|
+
#include <clipping_planes_fragment>
|
|
3298
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3299
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3300
|
+
#include <logdepthbuf_fragment>
|
|
3301
|
+
#include <map_fragment>
|
|
3302
|
+
#include <color_fragment>
|
|
3303
|
+
#include <alphamap_fragment>
|
|
3304
|
+
#include <alphatest_fragment>
|
|
3305
|
+
#include <alphahash_fragment>
|
|
3306
|
+
#include <roughnessmap_fragment>
|
|
3307
|
+
#include <metalnessmap_fragment>
|
|
3308
|
+
#include <normal_fragment_begin>
|
|
3309
|
+
#include <normal_fragment_maps>
|
|
3310
|
+
#include <clearcoat_normal_fragment_begin>
|
|
3311
|
+
#include <clearcoat_normal_fragment_maps>
|
|
3312
|
+
#include <emissivemap_fragment>
|
|
3313
|
+
#include <lights_physical_fragment>
|
|
3314
|
+
#include <lights_fragment_begin>
|
|
3315
|
+
#include <lights_fragment_maps>
|
|
3316
|
+
#include <lights_fragment_end>
|
|
3317
|
+
#include <aomap_fragment>
|
|
3318
|
+
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
3319
|
+
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
3320
|
+
#include <transmission_fragment>
|
|
3321
|
+
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
3322
|
+
#ifdef USE_SHEEN
|
|
3323
|
+
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
3324
|
+
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
3325
|
+
#endif
|
|
3326
|
+
#ifdef USE_CLEARCOAT
|
|
3327
|
+
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
3328
|
+
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
3329
|
+
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
3330
|
+
#endif
|
|
3331
|
+
#include <opaque_fragment>
|
|
3332
|
+
#include <tonemapping_fragment>
|
|
3333
|
+
#include <colorspace_fragment>
|
|
3334
|
+
#include <fog_fragment>
|
|
3335
|
+
#include <premultiplied_alpha_fragment>
|
|
3336
|
+
#include <dithering_fragment>
|
|
3337
|
+
}`,Np=`#define TOON
|
|
3338
|
+
varying vec3 vViewPosition;
|
|
3339
|
+
#include <common>
|
|
3340
|
+
#include <batching_pars_vertex>
|
|
3341
|
+
#include <uv_pars_vertex>
|
|
3342
|
+
#include <displacementmap_pars_vertex>
|
|
3343
|
+
#include <color_pars_vertex>
|
|
3344
|
+
#include <fog_pars_vertex>
|
|
3345
|
+
#include <normal_pars_vertex>
|
|
3346
|
+
#include <morphtarget_pars_vertex>
|
|
3347
|
+
#include <skinning_pars_vertex>
|
|
3348
|
+
#include <shadowmap_pars_vertex>
|
|
3349
|
+
#include <logdepthbuf_pars_vertex>
|
|
3350
|
+
#include <clipping_planes_pars_vertex>
|
|
3351
|
+
void main() {
|
|
3352
|
+
#include <uv_vertex>
|
|
3353
|
+
#include <color_vertex>
|
|
3354
|
+
#include <morphinstance_vertex>
|
|
3355
|
+
#include <morphcolor_vertex>
|
|
3356
|
+
#include <batching_vertex>
|
|
3357
|
+
#include <beginnormal_vertex>
|
|
3358
|
+
#include <morphnormal_vertex>
|
|
3359
|
+
#include <skinbase_vertex>
|
|
3360
|
+
#include <skinnormal_vertex>
|
|
3361
|
+
#include <defaultnormal_vertex>
|
|
3362
|
+
#include <normal_vertex>
|
|
3363
|
+
#include <begin_vertex>
|
|
3364
|
+
#include <morphtarget_vertex>
|
|
3365
|
+
#include <skinning_vertex>
|
|
3366
|
+
#include <displacementmap_vertex>
|
|
3367
|
+
#include <project_vertex>
|
|
3368
|
+
#include <logdepthbuf_vertex>
|
|
3369
|
+
#include <clipping_planes_vertex>
|
|
3370
|
+
vViewPosition = - mvPosition.xyz;
|
|
3371
|
+
#include <worldpos_vertex>
|
|
3372
|
+
#include <shadowmap_vertex>
|
|
3373
|
+
#include <fog_vertex>
|
|
3374
|
+
}`,Up=`#define TOON
|
|
3375
|
+
uniform vec3 diffuse;
|
|
3376
|
+
uniform vec3 emissive;
|
|
3377
|
+
uniform float opacity;
|
|
3378
|
+
#include <common>
|
|
3379
|
+
#include <packing>
|
|
3380
|
+
#include <dithering_pars_fragment>
|
|
3381
|
+
#include <color_pars_fragment>
|
|
3382
|
+
#include <uv_pars_fragment>
|
|
3383
|
+
#include <map_pars_fragment>
|
|
3384
|
+
#include <alphamap_pars_fragment>
|
|
3385
|
+
#include <alphatest_pars_fragment>
|
|
3386
|
+
#include <alphahash_pars_fragment>
|
|
3387
|
+
#include <aomap_pars_fragment>
|
|
3388
|
+
#include <lightmap_pars_fragment>
|
|
3389
|
+
#include <emissivemap_pars_fragment>
|
|
3390
|
+
#include <gradientmap_pars_fragment>
|
|
3391
|
+
#include <fog_pars_fragment>
|
|
3392
|
+
#include <bsdfs>
|
|
3393
|
+
#include <lights_pars_begin>
|
|
3394
|
+
#include <normal_pars_fragment>
|
|
3395
|
+
#include <lights_toon_pars_fragment>
|
|
3396
|
+
#include <shadowmap_pars_fragment>
|
|
3397
|
+
#include <bumpmap_pars_fragment>
|
|
3398
|
+
#include <normalmap_pars_fragment>
|
|
3399
|
+
#include <logdepthbuf_pars_fragment>
|
|
3400
|
+
#include <clipping_planes_pars_fragment>
|
|
3401
|
+
void main() {
|
|
3402
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3403
|
+
#include <clipping_planes_fragment>
|
|
3404
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
3405
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
3406
|
+
#include <logdepthbuf_fragment>
|
|
3407
|
+
#include <map_fragment>
|
|
3408
|
+
#include <color_fragment>
|
|
3409
|
+
#include <alphamap_fragment>
|
|
3410
|
+
#include <alphatest_fragment>
|
|
3411
|
+
#include <alphahash_fragment>
|
|
3412
|
+
#include <normal_fragment_begin>
|
|
3413
|
+
#include <normal_fragment_maps>
|
|
3414
|
+
#include <emissivemap_fragment>
|
|
3415
|
+
#include <lights_toon_fragment>
|
|
3416
|
+
#include <lights_fragment_begin>
|
|
3417
|
+
#include <lights_fragment_maps>
|
|
3418
|
+
#include <lights_fragment_end>
|
|
3419
|
+
#include <aomap_fragment>
|
|
3420
|
+
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
3421
|
+
#include <opaque_fragment>
|
|
3422
|
+
#include <tonemapping_fragment>
|
|
3423
|
+
#include <colorspace_fragment>
|
|
3424
|
+
#include <fog_fragment>
|
|
3425
|
+
#include <premultiplied_alpha_fragment>
|
|
3426
|
+
#include <dithering_fragment>
|
|
3427
|
+
}`,Op=`uniform float size;
|
|
3428
|
+
uniform float scale;
|
|
3429
|
+
#include <common>
|
|
3430
|
+
#include <color_pars_vertex>
|
|
3431
|
+
#include <fog_pars_vertex>
|
|
3432
|
+
#include <morphtarget_pars_vertex>
|
|
3433
|
+
#include <logdepthbuf_pars_vertex>
|
|
3434
|
+
#include <clipping_planes_pars_vertex>
|
|
3435
|
+
#ifdef USE_POINTS_UV
|
|
3436
|
+
varying vec2 vUv;
|
|
3437
|
+
uniform mat3 uvTransform;
|
|
3438
|
+
#endif
|
|
3439
|
+
void main() {
|
|
3440
|
+
#ifdef USE_POINTS_UV
|
|
3441
|
+
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
3442
|
+
#endif
|
|
3443
|
+
#include <color_vertex>
|
|
3444
|
+
#include <morphinstance_vertex>
|
|
3445
|
+
#include <morphcolor_vertex>
|
|
3446
|
+
#include <begin_vertex>
|
|
3447
|
+
#include <morphtarget_vertex>
|
|
3448
|
+
#include <project_vertex>
|
|
3449
|
+
gl_PointSize = size;
|
|
3450
|
+
#ifdef USE_SIZEATTENUATION
|
|
3451
|
+
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
3452
|
+
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
3453
|
+
#endif
|
|
3454
|
+
#include <logdepthbuf_vertex>
|
|
3455
|
+
#include <clipping_planes_vertex>
|
|
3456
|
+
#include <worldpos_vertex>
|
|
3457
|
+
#include <fog_vertex>
|
|
3458
|
+
}`,Fp=`uniform vec3 diffuse;
|
|
3459
|
+
uniform float opacity;
|
|
3460
|
+
#include <common>
|
|
3461
|
+
#include <color_pars_fragment>
|
|
3462
|
+
#include <map_particle_pars_fragment>
|
|
3463
|
+
#include <alphatest_pars_fragment>
|
|
3464
|
+
#include <alphahash_pars_fragment>
|
|
3465
|
+
#include <fog_pars_fragment>
|
|
3466
|
+
#include <logdepthbuf_pars_fragment>
|
|
3467
|
+
#include <clipping_planes_pars_fragment>
|
|
3468
|
+
void main() {
|
|
3469
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3470
|
+
#include <clipping_planes_fragment>
|
|
3471
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
3472
|
+
#include <logdepthbuf_fragment>
|
|
3473
|
+
#include <map_particle_fragment>
|
|
3474
|
+
#include <color_fragment>
|
|
3475
|
+
#include <alphatest_fragment>
|
|
3476
|
+
#include <alphahash_fragment>
|
|
3477
|
+
outgoingLight = diffuseColor.rgb;
|
|
3478
|
+
#include <opaque_fragment>
|
|
3479
|
+
#include <tonemapping_fragment>
|
|
3480
|
+
#include <colorspace_fragment>
|
|
3481
|
+
#include <fog_fragment>
|
|
3482
|
+
#include <premultiplied_alpha_fragment>
|
|
3483
|
+
}`,Bp=`#include <common>
|
|
3484
|
+
#include <batching_pars_vertex>
|
|
3485
|
+
#include <fog_pars_vertex>
|
|
3486
|
+
#include <morphtarget_pars_vertex>
|
|
3487
|
+
#include <skinning_pars_vertex>
|
|
3488
|
+
#include <logdepthbuf_pars_vertex>
|
|
3489
|
+
#include <shadowmap_pars_vertex>
|
|
3490
|
+
void main() {
|
|
3491
|
+
#include <batching_vertex>
|
|
3492
|
+
#include <beginnormal_vertex>
|
|
3493
|
+
#include <morphinstance_vertex>
|
|
3494
|
+
#include <morphnormal_vertex>
|
|
3495
|
+
#include <skinbase_vertex>
|
|
3496
|
+
#include <skinnormal_vertex>
|
|
3497
|
+
#include <defaultnormal_vertex>
|
|
3498
|
+
#include <begin_vertex>
|
|
3499
|
+
#include <morphtarget_vertex>
|
|
3500
|
+
#include <skinning_vertex>
|
|
3501
|
+
#include <project_vertex>
|
|
3502
|
+
#include <logdepthbuf_vertex>
|
|
3503
|
+
#include <worldpos_vertex>
|
|
3504
|
+
#include <shadowmap_vertex>
|
|
3505
|
+
#include <fog_vertex>
|
|
3506
|
+
}`,zp=`uniform vec3 color;
|
|
3507
|
+
uniform float opacity;
|
|
3508
|
+
#include <common>
|
|
3509
|
+
#include <packing>
|
|
3510
|
+
#include <fog_pars_fragment>
|
|
3511
|
+
#include <bsdfs>
|
|
3512
|
+
#include <lights_pars_begin>
|
|
3513
|
+
#include <logdepthbuf_pars_fragment>
|
|
3514
|
+
#include <shadowmap_pars_fragment>
|
|
3515
|
+
#include <shadowmask_pars_fragment>
|
|
3516
|
+
void main() {
|
|
3517
|
+
#include <logdepthbuf_fragment>
|
|
3518
|
+
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
3519
|
+
#include <tonemapping_fragment>
|
|
3520
|
+
#include <colorspace_fragment>
|
|
3521
|
+
#include <fog_fragment>
|
|
3522
|
+
}`,kp=`uniform float rotation;
|
|
3523
|
+
uniform vec2 center;
|
|
3524
|
+
#include <common>
|
|
3525
|
+
#include <uv_pars_vertex>
|
|
3526
|
+
#include <fog_pars_vertex>
|
|
3527
|
+
#include <logdepthbuf_pars_vertex>
|
|
3528
|
+
#include <clipping_planes_pars_vertex>
|
|
3529
|
+
void main() {
|
|
3530
|
+
#include <uv_vertex>
|
|
3531
|
+
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|
3532
|
+
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
3533
|
+
#ifndef USE_SIZEATTENUATION
|
|
3534
|
+
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
3535
|
+
if ( isPerspective ) scale *= - mvPosition.z;
|
|
3536
|
+
#endif
|
|
3537
|
+
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
3538
|
+
vec2 rotatedPosition;
|
|
3539
|
+
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
3540
|
+
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
3541
|
+
mvPosition.xy += rotatedPosition;
|
|
3542
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
3543
|
+
#include <logdepthbuf_vertex>
|
|
3544
|
+
#include <clipping_planes_vertex>
|
|
3545
|
+
#include <fog_vertex>
|
|
3546
|
+
}`,Vp=`uniform vec3 diffuse;
|
|
3547
|
+
uniform float opacity;
|
|
3548
|
+
#include <common>
|
|
3549
|
+
#include <uv_pars_fragment>
|
|
3550
|
+
#include <map_pars_fragment>
|
|
3551
|
+
#include <alphamap_pars_fragment>
|
|
3552
|
+
#include <alphatest_pars_fragment>
|
|
3553
|
+
#include <alphahash_pars_fragment>
|
|
3554
|
+
#include <fog_pars_fragment>
|
|
3555
|
+
#include <logdepthbuf_pars_fragment>
|
|
3556
|
+
#include <clipping_planes_pars_fragment>
|
|
3557
|
+
void main() {
|
|
3558
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
3559
|
+
#include <clipping_planes_fragment>
|
|
3560
|
+
vec3 outgoingLight = vec3( 0.0 );
|
|
3561
|
+
#include <logdepthbuf_fragment>
|
|
3562
|
+
#include <map_fragment>
|
|
3563
|
+
#include <alphamap_fragment>
|
|
3564
|
+
#include <alphatest_fragment>
|
|
3565
|
+
#include <alphahash_fragment>
|
|
3566
|
+
outgoingLight = diffuseColor.rgb;
|
|
3567
|
+
#include <opaque_fragment>
|
|
3568
|
+
#include <tonemapping_fragment>
|
|
3569
|
+
#include <colorspace_fragment>
|
|
3570
|
+
#include <fog_fragment>
|
|
3571
|
+
}`,De={alphahash_fragment:cd,alphahash_pars_fragment:ld,alphamap_fragment:hd,alphamap_pars_fragment:ud,alphatest_fragment:dd,alphatest_pars_fragment:fd,aomap_fragment:pd,aomap_pars_fragment:md,batching_pars_vertex:gd,batching_vertex:_d,begin_vertex:xd,beginnormal_vertex:vd,bsdfs:yd,iridescence_fragment:Md,bumpmap_pars_fragment:Sd,clipping_planes_fragment:bd,clipping_planes_pars_fragment:Ad,clipping_planes_pars_vertex:Td,clipping_planes_vertex:Ed,color_fragment:wd,color_pars_fragment:Rd,color_pars_vertex:Cd,color_vertex:Id,common:Pd,cube_uv_reflection_fragment:Ld,defaultnormal_vertex:Dd,displacementmap_pars_vertex:Nd,displacementmap_vertex:Ud,emissivemap_fragment:Od,emissivemap_pars_fragment:Fd,colorspace_fragment:Bd,colorspace_pars_fragment:zd,envmap_fragment:kd,envmap_common_pars_fragment:Vd,envmap_pars_fragment:Hd,envmap_pars_vertex:Gd,envmap_physical_pars_fragment:ef,envmap_vertex:Wd,fog_vertex:Xd,fog_pars_vertex:qd,fog_fragment:Yd,fog_pars_fragment:Zd,gradientmap_pars_fragment:Kd,lightmap_pars_fragment:Jd,lights_lambert_fragment:$d,lights_lambert_pars_fragment:jd,lights_pars_begin:Qd,lights_toon_fragment:tf,lights_toon_pars_fragment:nf,lights_phong_fragment:sf,lights_phong_pars_fragment:rf,lights_physical_fragment:of,lights_physical_pars_fragment:af,lights_fragment_begin:cf,lights_fragment_maps:lf,lights_fragment_end:hf,logdepthbuf_fragment:uf,logdepthbuf_pars_fragment:df,logdepthbuf_pars_vertex:ff,logdepthbuf_vertex:pf,map_fragment:mf,map_pars_fragment:gf,map_particle_fragment:_f,map_particle_pars_fragment:xf,metalnessmap_fragment:vf,metalnessmap_pars_fragment:yf,morphinstance_vertex:Mf,morphcolor_vertex:Sf,morphnormal_vertex:bf,morphtarget_pars_vertex:Af,morphtarget_vertex:Tf,normal_fragment_begin:Ef,normal_fragment_maps:wf,normal_pars_fragment:Rf,normal_pars_vertex:Cf,normal_vertex:If,normalmap_pars_fragment:Pf,clearcoat_normal_fragment_begin:Lf,clearcoat_normal_fragment_maps:Df,clearcoat_pars_fragment:Nf,iridescence_pars_fragment:Uf,opaque_fragment:Of,packing:Ff,premultiplied_alpha_fragment:Bf,project_vertex:zf,dithering_fragment:kf,dithering_pars_fragment:Vf,roughnessmap_fragment:Hf,roughnessmap_pars_fragment:Gf,shadowmap_pars_fragment:Wf,shadowmap_pars_vertex:Xf,shadowmap_vertex:qf,shadowmask_pars_fragment:Yf,skinbase_vertex:Zf,skinning_pars_vertex:Kf,skinning_vertex:Jf,skinnormal_vertex:$f,specularmap_fragment:jf,specularmap_pars_fragment:Qf,tonemapping_fragment:ep,tonemapping_pars_fragment:tp,transmission_fragment:np,transmission_pars_fragment:ip,uv_pars_fragment:sp,uv_pars_vertex:rp,uv_vertex:op,worldpos_vertex:ap,background_vert:cp,background_frag:lp,backgroundCube_vert:hp,backgroundCube_frag:up,cube_vert:dp,cube_frag:fp,depth_vert:pp,depth_frag:mp,distanceRGBA_vert:gp,distanceRGBA_frag:_p,equirect_vert:xp,equirect_frag:vp,linedashed_vert:yp,linedashed_frag:Mp,meshbasic_vert:Sp,meshbasic_frag:bp,meshlambert_vert:Ap,meshlambert_frag:Tp,meshmatcap_vert:Ep,meshmatcap_frag:wp,meshnormal_vert:Rp,meshnormal_frag:Cp,meshphong_vert:Ip,meshphong_frag:Pp,meshphysical_vert:Lp,meshphysical_frag:Dp,meshtoon_vert:Np,meshtoon_frag:Up,points_vert:Op,points_frag:Fp,shadow_vert:Bp,shadow_frag:zp,sprite_vert:kp,sprite_frag:Vp},te={common:{diffuse:{value:new Se(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ie}},envmap:{envMap:{value:null},envMapRotation:{value:new Ie},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ie}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ie}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ie},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ie},normalScale:{value:new Be(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ie},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ie}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ie}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ie}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Se(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 Se(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0},uvTransform:{value:new Ie}},sprite:{diffuse:{value:new Se(16777215)},opacity:{value:1},center:{value:new Be(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ie},alphaMap:{value:null},alphaMapTransform:{value:new Ie},alphaTest:{value:0}}},en={basic:{uniforms:At([te.common,te.specularmap,te.envmap,te.aomap,te.lightmap,te.fog]),vertexShader:De.meshbasic_vert,fragmentShader:De.meshbasic_frag},lambert:{uniforms:At([te.common,te.specularmap,te.envmap,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.fog,te.lights,{emissive:{value:new Se(0)}}]),vertexShader:De.meshlambert_vert,fragmentShader:De.meshlambert_frag},phong:{uniforms:At([te.common,te.specularmap,te.envmap,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.fog,te.lights,{emissive:{value:new Se(0)},specular:{value:new Se(1118481)},shininess:{value:30}}]),vertexShader:De.meshphong_vert,fragmentShader:De.meshphong_frag},standard:{uniforms:At([te.common,te.envmap,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.roughnessmap,te.metalnessmap,te.fog,te.lights,{emissive:{value:new Se(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:De.meshphysical_vert,fragmentShader:De.meshphysical_frag},toon:{uniforms:At([te.common,te.aomap,te.lightmap,te.emissivemap,te.bumpmap,te.normalmap,te.displacementmap,te.gradientmap,te.fog,te.lights,{emissive:{value:new Se(0)}}]),vertexShader:De.meshtoon_vert,fragmentShader:De.meshtoon_frag},matcap:{uniforms:At([te.common,te.bumpmap,te.normalmap,te.displacementmap,te.fog,{matcap:{value:null}}]),vertexShader:De.meshmatcap_vert,fragmentShader:De.meshmatcap_frag},points:{uniforms:At([te.points,te.fog]),vertexShader:De.points_vert,fragmentShader:De.points_frag},dashed:{uniforms:At([te.common,te.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:De.linedashed_vert,fragmentShader:De.linedashed_frag},depth:{uniforms:At([te.common,te.displacementmap]),vertexShader:De.depth_vert,fragmentShader:De.depth_frag},normal:{uniforms:At([te.common,te.bumpmap,te.normalmap,te.displacementmap,{opacity:{value:1}}]),vertexShader:De.meshnormal_vert,fragmentShader:De.meshnormal_frag},sprite:{uniforms:At([te.sprite,te.fog]),vertexShader:De.sprite_vert,fragmentShader:De.sprite_frag},background:{uniforms:{uvTransform:{value:new Ie},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:De.background_vert,fragmentShader:De.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ie}},vertexShader:De.backgroundCube_vert,fragmentShader:De.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:De.cube_vert,fragmentShader:De.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:De.equirect_vert,fragmentShader:De.equirect_frag},distanceRGBA:{uniforms:At([te.common,te.displacementmap,{referencePosition:{value:new L},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:De.distanceRGBA_vert,fragmentShader:De.distanceRGBA_frag},shadow:{uniforms:At([te.lights,te.fog,{color:{value:new Se(0)},opacity:{value:1}}]),vertexShader:De.shadow_vert,fragmentShader:De.shadow_frag}};en.physical={uniforms:At([en.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ie},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ie},clearcoatNormalScale:{value:new Be(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ie},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ie},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ie},sheen:{value:0},sheenColor:{value:new Se(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ie},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ie},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ie},transmissionSamplerSize:{value:new Be},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ie},attenuationDistance:{value:0},attenuationColor:{value:new Se(0)},specularColor:{value:new Se(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ie},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ie},anisotropyVector:{value:new Be},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ie}}]),vertexShader:De.meshphysical_vert,fragmentShader:De.meshphysical_frag};var Xs={r:0,b:0,g:0},jn=new rn,Hp=new Pe;function Gp(s,e,t,n,i,r,o){let a=new Se(0),c=r===!0?0:1,l,h,u=null,d=0,p=null;function g(T){let A=T.isScene===!0?T.background:null;return A&&A.isTexture&&(A=(T.backgroundBlurriness>0?t:e).get(A)),A}function _(T){let A=!1,M=g(T);M===null?f(a,c):M&&M.isColor&&(f(M,1),A=!0);let U=s.xr.getEnvironmentBlendMode();U==="additive"?n.buffers.color.setClear(0,0,0,1,o):U==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||A)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function m(T,A){let M=g(A);M&&(M.isCubeTexture||M.mapping===zr)?(h===void 0&&(h=new yt(new ps(1,1,1),new an({name:"BackgroundCubeMaterial",uniforms:Hi(en.backgroundCube.uniforms),vertexShader:en.backgroundCube.vertexShader,fragmentShader:en.backgroundCube.fragmentShader,side:wt,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(U,w,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),jn.copy(A.backgroundRotation),jn.x*=-1,jn.y*=-1,jn.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(jn.y*=-1,jn.z*=-1),h.material.uniforms.envMap.value=M,h.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Hp.makeRotationFromEuler(jn)),h.material.toneMapped=Fe.getTransfer(M.colorSpace)!==Je,(u!==M||d!==M.version||p!==s.toneMapping)&&(h.material.needsUpdate=!0,u=M,d=M.version,p=s.toneMapping),h.layers.enableAll(),T.unshift(h,h.geometry,h.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new yt(new mr(2,2),new an({name:"BackgroundMaterial",uniforms:Hi(en.background.uniforms),vertexShader:en.background.vertexShader,fragmentShader:en.background.fragmentShader,side:sn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=Fe.getTransfer(M.colorSpace)!==Je,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(u!==M||d!==M.version||p!==s.toneMapping)&&(l.material.needsUpdate=!0,u=M,d=M.version,p=s.toneMapping),l.layers.enableAll(),T.unshift(l,l.geometry,l.material,0,0,null))}function f(T,A){T.getRGB(Xs,yh(s)),n.buffers.color.setClear(Xs.r,Xs.g,Xs.b,A,o)}return{getClearColor:function(){return a},setClearColor:function(T,A=1){a.set(T),c=A,f(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(T){c=T,f(a,c)},render:_,addToRenderList:m}}function Wp(s,e){let t=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null),r=i,o=!1;function a(y,R,q,z,W){let J=!1,H=u(z,q,R);r!==H&&(r=H,l(r.object)),J=p(y,z,q,W),J&&g(y,z,q,W),W!==null&&e.update(W,s.ELEMENT_ARRAY_BUFFER),(J||o)&&(o=!1,M(y,R,q,z),W!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,e.get(W).buffer))}function c(){return s.createVertexArray()}function l(y){return s.bindVertexArray(y)}function h(y){return s.deleteVertexArray(y)}function u(y,R,q){let z=q.wireframe===!0,W=n[y.id];W===void 0&&(W={},n[y.id]=W);let J=W[R.id];J===void 0&&(J={},W[R.id]=J);let H=J[z];return H===void 0&&(H=d(c()),J[z]=H),H}function d(y){let R=[],q=[],z=[];for(let W=0;W<t;W++)R[W]=0,q[W]=0,z[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:R,enabledAttributes:q,attributeDivisors:z,object:y,attributes:{},index:null}}function p(y,R,q,z){let W=r.attributes,J=R.attributes,H=0,Q=q.getAttributes();for(let V in Q)if(Q[V].location>=0){let le=W[V],ve=J[V];if(ve===void 0&&(V==="instanceMatrix"&&y.instanceMatrix&&(ve=y.instanceMatrix),V==="instanceColor"&&y.instanceColor&&(ve=y.instanceColor)),le===void 0||le.attribute!==ve||ve&&le.data!==ve.data)return!0;H++}return r.attributesNum!==H||r.index!==z}function g(y,R,q,z){let W={},J=R.attributes,H=0,Q=q.getAttributes();for(let V in Q)if(Q[V].location>=0){let le=J[V];le===void 0&&(V==="instanceMatrix"&&y.instanceMatrix&&(le=y.instanceMatrix),V==="instanceColor"&&y.instanceColor&&(le=y.instanceColor));let ve={};ve.attribute=le,le&&le.data&&(ve.data=le.data),W[V]=ve,H++}r.attributes=W,r.attributesNum=H,r.index=z}function _(){let y=r.newAttributes;for(let R=0,q=y.length;R<q;R++)y[R]=0}function m(y){f(y,0)}function f(y,R){let q=r.newAttributes,z=r.enabledAttributes,W=r.attributeDivisors;q[y]=1,z[y]===0&&(s.enableVertexAttribArray(y),z[y]=1),W[y]!==R&&(s.vertexAttribDivisor(y,R),W[y]=R)}function T(){let y=r.newAttributes,R=r.enabledAttributes;for(let q=0,z=R.length;q<z;q++)R[q]!==y[q]&&(s.disableVertexAttribArray(q),R[q]=0)}function A(y,R,q,z,W,J,H){H===!0?s.vertexAttribIPointer(y,R,q,W,J):s.vertexAttribPointer(y,R,q,z,W,J)}function M(y,R,q,z){_();let W=z.attributes,J=q.getAttributes(),H=R.defaultAttributeValues;for(let Q in J){let V=J[Q];if(V.location>=0){let ie=W[Q];if(ie===void 0&&(Q==="instanceMatrix"&&y.instanceMatrix&&(ie=y.instanceMatrix),Q==="instanceColor"&&y.instanceColor&&(ie=y.instanceColor)),ie!==void 0){let le=ie.normalized,ve=ie.itemSize,Ne=e.get(ie);if(Ne===void 0)continue;let $e=Ne.buffer,X=Ne.type,ee=Ne.bytesPerElement,ge=X===s.INT||X===s.UNSIGNED_INT||ie.gpuType===Va;if(ie.isInterleavedBufferAttribute){let se=ie.data,Ae=se.stride,we=ie.offset;if(se.isInstancedInterleavedBuffer){for(let Ue=0;Ue<V.locationSize;Ue++)f(V.location+Ue,se.meshPerAttribute);y.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=se.meshPerAttribute*se.count)}else for(let Ue=0;Ue<V.locationSize;Ue++)m(V.location+Ue);s.bindBuffer(s.ARRAY_BUFFER,$e);for(let Ue=0;Ue<V.locationSize;Ue++)A(V.location+Ue,ve/V.locationSize,X,le,Ae*ee,(we+ve/V.locationSize*Ue)*ee,ge)}else{if(ie.isInstancedBufferAttribute){for(let se=0;se<V.locationSize;se++)f(V.location+se,ie.meshPerAttribute);y.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ie.meshPerAttribute*ie.count)}else for(let se=0;se<V.locationSize;se++)m(V.location+se);s.bindBuffer(s.ARRAY_BUFFER,$e);for(let se=0;se<V.locationSize;se++)A(V.location+se,ve/V.locationSize,X,le,ve*ee,ve/V.locationSize*se*ee,ge)}}else if(H!==void 0){let le=H[Q];if(le!==void 0)switch(le.length){case 2:s.vertexAttrib2fv(V.location,le);break;case 3:s.vertexAttrib3fv(V.location,le);break;case 4:s.vertexAttrib4fv(V.location,le);break;default:s.vertexAttrib1fv(V.location,le)}}}}T()}function U(){N();for(let y in n){let R=n[y];for(let q in R){let z=R[q];for(let W in z)h(z[W].object),delete z[W];delete R[q]}delete n[y]}}function w(y){if(n[y.id]===void 0)return;let R=n[y.id];for(let q in R){let z=R[q];for(let W in z)h(z[W].object),delete z[W];delete R[q]}delete n[y.id]}function E(y){for(let R in n){let q=n[R];if(q[y.id]===void 0)continue;let z=q[y.id];for(let W in z)h(z[W].object),delete z[W];delete q[y.id]}}function N(){S(),o=!0,r!==i&&(r=i,l(r.object))}function S(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:N,resetDefaultState:S,dispose:U,releaseStatesOfGeometry:w,releaseStatesOfProgram:E,initAttributes:_,enableAttribute:m,disableUnusedAttributes:T}}function Xp(s,e,t){let n;function i(l){n=l}function r(l,h){s.drawArrays(n,l,h),t.update(h,n,1)}function o(l,h,u){u!==0&&(s.drawArraysInstanced(n,l,h,u),t.update(h,n,u))}function a(l,h,u){if(u===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,h,0,u);let p=0;for(let g=0;g<u;g++)p+=h[g];t.update(p,n,1)}function c(l,h,u,d){if(u===0)return;let p=e.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<l.length;g++)o(l[g],h[g],d[g]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,h,0,d,0,u);let g=0;for(let _=0;_<u;_++)g+=h[_]*d[_];t.update(g,n,1)}}this.setMode=i,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function qp(s,e,t,n){let i;function r(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){let E=e.get("EXT_texture_filter_anisotropic");i=s.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==Bt&&n.convert(E)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(E){let N=E===bs&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==Mn&&n.convert(E)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==$t&&!N)}function c(E){if(E==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",h=c(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let u=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=s.getParameter(s.MAX_TEXTURE_SIZE),m=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),f=s.getParameter(s.MAX_VERTEX_ATTRIBS),T=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),A=s.getParameter(s.MAX_VARYING_VECTORS),M=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),U=g>0,w=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:T,maxVaryings:A,maxFragmentUniforms:M,vertexTextures:U,maxSamples:w}}function Yp(s){let e=this,t=null,n=0,i=!1,r=!1,o=new _n,a=new Ie,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let p=u.length!==0||d||n!==0||i;return i=d,n=u.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,p){let g=u.clippingPlanes,_=u.clipIntersection,m=u.clipShadows,f=s.get(u);if(!i||g===null||g.length===0||r&&!m)r?h(null):l();else{let T=r?0:n,A=T*4,M=f.clippingState||null;c.value=M,M=h(g,d,A,p);for(let U=0;U!==A;++U)M[U]=t[U];f.clippingState=M,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=T}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,p,g){let _=u!==null?u.length:0,m=null;if(_!==0){if(m=c.value,g!==!0||m===null){let f=p+_*4,T=d.matrixWorldInverse;a.getNormalMatrix(T),(m===null||m.length<f)&&(m=new Float32Array(f));for(let A=0,M=p;A!==_;++A,M+=4)o.copy(u[A]).applyMatrix4(T,a),o.normal.toArray(m,M),m[M+3]=o.constant}c.value=m,c.needsUpdate=!0}return e.numPlanes=_,e.numIntersection=0,m}}function Zp(s){let e=new WeakMap;function t(o,a){return a===No?o.mapping=Ni:a===Uo&&(o.mapping=Ui),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===No||a===Uo)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new fa(c.height);return l.fromEquirectangularTexture(s,o),e.set(o,l),o.addEventListener("dispose",i),t(l.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function r(){e=new WeakMap}return{get:n,dispose:r}}var Gi=class extends fr{constructor(e=-1,t=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,o=n+e,a=i+t,c=i-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=h*this.view.offsetY,c=a-h*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Ri=4,fl=[.125,.215,.35,.446,.526,.582],ii=20,po=new Gi,pl=new Se,mo=null,go=0,_o=0,xo=!1,ei=(1+Math.sqrt(5))/2,bi=1/ei,ml=[new L(-ei,bi,0),new L(ei,bi,0),new L(-bi,0,ei),new L(bi,0,ei),new L(0,ei,-bi),new L(0,ei,bi),new L(-1,1,-1),new L(1,1,-1),new L(-1,1,1),new L(1,1,1)],gr=class{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){mo=this._renderer.getRenderTarget(),go=this._renderer.getActiveCubeFace(),_o=this._renderer.getActiveMipmapLevel(),xo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=xl(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=_l(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(mo,go,_o),this._renderer.xr.enabled=xo,e.scissorTest=!1,qs(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Ni||e.mapping===Ui?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),mo=this._renderer.getRenderTarget(),go=this._renderer.getActiveCubeFace(),_o=this._renderer.getActiveMipmapLevel(),xo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Et,minFilter:Et,generateMipmaps:!1,type:bs,format:Bt,colorSpace:St,depthBuffer:!1},i=gl(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=gl(e,t,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Kp(r)),this._blurMaterial=Jp(r,e,t)}return i}_compileMaterial(e){let t=new yt(this._lodPlanes[0],e);this._renderer.compile(t,po)}_sceneToCubeUV(e,t,n,i){let a=new ht(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(pl),h.toneMapping=kn,h.autoClear=!1;let p=new on({name:"PMREM.Background",side:wt,depthWrite:!1,depthTest:!1}),g=new yt(new ps,p),_=!1,m=e.background;m?m.isColor&&(p.color.copy(m),e.background=null,_=!0):(p.color.copy(pl),_=!0);for(let f=0;f<6;f++){let T=f%3;T===0?(a.up.set(0,c[f],0),a.lookAt(l[f],0,0)):T===1?(a.up.set(0,0,c[f]),a.lookAt(0,l[f],0)):(a.up.set(0,c[f],0),a.lookAt(0,0,l[f]));let A=this._cubeSize;qs(i,T*A,f>2?A:0,A,A),h.setRenderTarget(i),_&&h.render(g,a),h.render(e,a)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Ni||e.mapping===Ui;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=xl()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=_l());let r=i?this._cubemapMaterial:this._equirectMaterial,o=new yt(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=e;let c=this._cubeSize;qs(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,po)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodPlanes.length;for(let r=1;r<i;r++){let o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=ml[(i-r-1)%ml.length];this._blur(e,r-1,r,o,a)}t.autoClear=n}_blur(e,t,n,i,r){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,i,"latitudinal",r),this._halfBlur(o,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,u=new yt(this._lodPlanes[i],l),d=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*ii-1),_=r/g,m=isFinite(r)?1+Math.floor(h*_):ii;m>ii&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ii}`);let f=[],T=0;for(let E=0;E<ii;++E){let N=E/_,S=Math.exp(-N*N/2);f.push(S),E===0?T+=S:E<m&&(T+=2*S)}for(let E=0;E<f.length;E++)f[E]=f[E]/T;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:A}=this;d.dTheta.value=g,d.mipInt.value=A-n;let M=this._sizeLods[i],U=3*M*(i>A-Ri?i-A+Ri:0),w=4*(this._cubeSize-M);qs(t,U,w,3*M,2*M),c.setRenderTarget(t),c.render(u,po)}};function Kp(s){let e=[],t=[],n=[],i=s,r=s-Ri+1+fl.length;for(let o=0;o<r;o++){let a=Math.pow(2,i);t.push(a);let c=1/a;o>s-Ri?c=fl[o-s+Ri-1]:o===0&&(c=0),n.push(c);let l=1/(a-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,g=6,_=3,m=2,f=1,T=new Float32Array(_*g*p),A=new Float32Array(m*g*p),M=new Float32Array(f*g*p);for(let w=0;w<p;w++){let E=w%3*2/3-1,N=w>2?0:-1,S=[E,N,0,E+2/3,N,0,E+2/3,N+1,0,E,N,0,E+2/3,N+1,0,E,N+1,0];T.set(S,_*g*w),A.set(d,m*g*w);let y=[w,w,w,w,w,w];M.set(y,f*g*w)}let U=new Vt;U.setAttribute("position",new ut(T,_)),U.setAttribute("uv",new ut(A,m)),U.setAttribute("faceIndex",new ut(M,f)),e.push(U),i>Ri&&i--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function gl(s,e,t){let n=new bn(s,e,t);return n.texture.mapping=zr,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function qs(s,e,t,n,i){s.viewport.set(e,t,n,i),s.scissor.set(e,t,n,i)}function Jp(s,e,t){let n=new Float32Array(ii),i=new L(0,1,0);return new an({name:"SphericalGaussianBlur",defines:{n:ii,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:ja(),fragmentShader:`
|
|
3572
|
+
|
|
3573
|
+
precision mediump float;
|
|
3574
|
+
precision mediump int;
|
|
3575
|
+
|
|
3576
|
+
varying vec3 vOutputDirection;
|
|
3577
|
+
|
|
3578
|
+
uniform sampler2D envMap;
|
|
3579
|
+
uniform int samples;
|
|
3580
|
+
uniform float weights[ n ];
|
|
3581
|
+
uniform bool latitudinal;
|
|
3582
|
+
uniform float dTheta;
|
|
3583
|
+
uniform float mipInt;
|
|
3584
|
+
uniform vec3 poleAxis;
|
|
3585
|
+
|
|
3586
|
+
#define ENVMAP_TYPE_CUBE_UV
|
|
3587
|
+
#include <cube_uv_reflection_fragment>
|
|
3588
|
+
|
|
3589
|
+
vec3 getSample( float theta, vec3 axis ) {
|
|
3590
|
+
|
|
3591
|
+
float cosTheta = cos( theta );
|
|
3592
|
+
// Rodrigues' axis-angle rotation
|
|
3593
|
+
vec3 sampleDirection = vOutputDirection * cosTheta
|
|
3594
|
+
+ cross( axis, vOutputDirection ) * sin( theta )
|
|
3595
|
+
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
|
|
3596
|
+
|
|
3597
|
+
return bilinearCubeUV( envMap, sampleDirection, mipInt );
|
|
3598
|
+
|
|
3599
|
+
}
|
|
3600
|
+
|
|
3601
|
+
void main() {
|
|
3602
|
+
|
|
3603
|
+
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
|
|
3604
|
+
|
|
3605
|
+
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
|
|
3606
|
+
|
|
3607
|
+
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
|
|
3608
|
+
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
axis = normalize( axis );
|
|
3612
|
+
|
|
3613
|
+
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
3614
|
+
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
|
|
3615
|
+
|
|
3616
|
+
for ( int i = 1; i < n; i++ ) {
|
|
3617
|
+
|
|
3618
|
+
if ( i >= samples ) {
|
|
3619
|
+
|
|
3620
|
+
break;
|
|
3621
|
+
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
float theta = dTheta * float( i );
|
|
3625
|
+
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
|
|
3626
|
+
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
|
|
3627
|
+
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3630
|
+
}
|
|
3631
|
+
`,blending:zn,depthTest:!1,depthWrite:!1})}function _l(){return new an({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ja(),fragmentShader:`
|
|
3632
|
+
|
|
3633
|
+
precision mediump float;
|
|
3634
|
+
precision mediump int;
|
|
3635
|
+
|
|
3636
|
+
varying vec3 vOutputDirection;
|
|
3637
|
+
|
|
3638
|
+
uniform sampler2D envMap;
|
|
3639
|
+
|
|
3640
|
+
#include <common>
|
|
3641
|
+
|
|
3642
|
+
void main() {
|
|
3643
|
+
|
|
3644
|
+
vec3 outputDirection = normalize( vOutputDirection );
|
|
3645
|
+
vec2 uv = equirectUv( outputDirection );
|
|
3646
|
+
|
|
3647
|
+
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3648
|
+
|
|
3649
|
+
}
|
|
3650
|
+
`,blending:zn,depthTest:!1,depthWrite:!1})}function xl(){return new an({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ja(),fragmentShader:`
|
|
3651
|
+
|
|
3652
|
+
precision mediump float;
|
|
3653
|
+
precision mediump int;
|
|
3654
|
+
|
|
3655
|
+
uniform float flipEnvMap;
|
|
3656
|
+
|
|
3657
|
+
varying vec3 vOutputDirection;
|
|
3658
|
+
|
|
3659
|
+
uniform samplerCube envMap;
|
|
3660
|
+
|
|
3661
|
+
void main() {
|
|
3662
|
+
|
|
3663
|
+
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3664
|
+
|
|
3665
|
+
}
|
|
3666
|
+
`,blending:zn,depthTest:!1,depthWrite:!1})}function ja(){return`
|
|
3667
|
+
|
|
3668
|
+
precision mediump float;
|
|
3669
|
+
precision mediump int;
|
|
3670
|
+
|
|
3671
|
+
attribute float faceIndex;
|
|
3672
|
+
|
|
3673
|
+
varying vec3 vOutputDirection;
|
|
3674
|
+
|
|
3675
|
+
// RH coordinate system; PMREM face-indexing convention
|
|
3676
|
+
vec3 getDirection( vec2 uv, float face ) {
|
|
3677
|
+
|
|
3678
|
+
uv = 2.0 * uv - 1.0;
|
|
3679
|
+
|
|
3680
|
+
vec3 direction = vec3( uv, 1.0 );
|
|
3681
|
+
|
|
3682
|
+
if ( face == 0.0 ) {
|
|
3683
|
+
|
|
3684
|
+
direction = direction.zyx; // ( 1, v, u ) pos x
|
|
3685
|
+
|
|
3686
|
+
} else if ( face == 1.0 ) {
|
|
3687
|
+
|
|
3688
|
+
direction = direction.xzy;
|
|
3689
|
+
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
|
|
3690
|
+
|
|
3691
|
+
} else if ( face == 2.0 ) {
|
|
3692
|
+
|
|
3693
|
+
direction.x *= -1.0; // ( -u, v, 1 ) pos z
|
|
3694
|
+
|
|
3695
|
+
} else if ( face == 3.0 ) {
|
|
3696
|
+
|
|
3697
|
+
direction = direction.zyx;
|
|
3698
|
+
direction.xz *= -1.0; // ( -1, v, -u ) neg x
|
|
3699
|
+
|
|
3700
|
+
} else if ( face == 4.0 ) {
|
|
3701
|
+
|
|
3702
|
+
direction = direction.xzy;
|
|
3703
|
+
direction.xy *= -1.0; // ( -u, -1, v ) neg y
|
|
3704
|
+
|
|
3705
|
+
} else if ( face == 5.0 ) {
|
|
3706
|
+
|
|
3707
|
+
direction.z *= -1.0; // ( u, v, -1 ) neg z
|
|
3708
|
+
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
return direction;
|
|
3712
|
+
|
|
3713
|
+
}
|
|
3714
|
+
|
|
3715
|
+
void main() {
|
|
3716
|
+
|
|
3717
|
+
vOutputDirection = getDirection( uv, faceIndex );
|
|
3718
|
+
gl_Position = vec4( position, 1.0 );
|
|
3719
|
+
|
|
3720
|
+
}
|
|
3721
|
+
`}function $p(s){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let c=a.mapping,l=c===No||c===Uo,h=c===Ni||c===Ui;if(l||h){let u=e.get(a),d=u!==void 0?u.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new gr(s)),u=l?t.fromEquirectangular(a,u):t.fromCubemap(a,u),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),u.texture;if(u!==void 0)return u.texture;{let p=a.image;return l&&p&&p.height>0||h&&p&&i(p)?(t===null&&(t=new gr(s)),u=l?t.fromEquirectangular(a):t.fromCubemap(a),u.texture.pmremVersion=a.pmremVersion,e.set(a,u),a.addEventListener("dispose",r),u.texture):null}}}return a}function i(a){let c=0,l=6;for(let h=0;h<l;h++)a[h]!==void 0&&c++;return c===l}function r(a){let c=a.target;c.removeEventListener("dispose",r);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function jp(s){let e={};function t(n){if(e[n]!==void 0)return e[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return e[n]=i,i}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let i=t(n);return i===null&&rs("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function Qp(s,e,t,n){let i={},r=new WeakMap;function o(u){let d=u.target;d.index!==null&&e.remove(d.index);for(let g in d.attributes)e.remove(d.attributes[g]);for(let g in d.morphAttributes){let _=d.morphAttributes[g];for(let m=0,f=_.length;m<f;m++)e.remove(_[m])}d.removeEventListener("dispose",o),delete i[d.id];let p=r.get(d);p&&(e.remove(p),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(u,d){return i[d.id]===!0||(d.addEventListener("dispose",o),i[d.id]=!0,t.memory.geometries++),d}function c(u){let d=u.attributes;for(let g in d)e.update(d[g],s.ARRAY_BUFFER);let p=u.morphAttributes;for(let g in p){let _=p[g];for(let m=0,f=_.length;m<f;m++)e.update(_[m],s.ARRAY_BUFFER)}}function l(u){let d=[],p=u.index,g=u.attributes.position,_=0;if(p!==null){let T=p.array;_=p.version;for(let A=0,M=T.length;A<M;A+=3){let U=T[A+0],w=T[A+1],E=T[A+2];d.push(U,w,w,E,E,U)}}else if(g!==void 0){let T=g.array;_=g.version;for(let A=0,M=T.length/3-1;A<M;A+=3){let U=A+0,w=A+1,E=A+2;d.push(U,w,w,E,E,U)}}else return;let m=new(xh(d)?dr:ur)(d,1);m.version=_;let f=r.get(u);f&&e.remove(f),r.set(u,m)}function h(u){let d=r.get(u);if(d){let p=u.index;p!==null&&d.version<p.version&&l(u)}else l(u);return r.get(u)}return{get:a,update:c,getWireframeAttribute:h}}function em(s,e,t){let n;function i(d){n=d}let r,o;function a(d){r=d.type,o=d.bytesPerElement}function c(d,p){s.drawElements(n,p,r,d*o),t.update(p,n,1)}function l(d,p,g){g!==0&&(s.drawElementsInstanced(n,p,r,d*o,g),t.update(p,n,g))}function h(d,p,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,d,0,g);let m=0;for(let f=0;f<g;f++)m+=p[f];t.update(m,n,1)}function u(d,p,g,_){if(g===0)return;let m=e.get("WEBGL_multi_draw");if(m===null)for(let f=0;f<d.length;f++)l(d[f]/o,p[f],_[f]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,r,d,0,_,0,g);let f=0;for(let T=0;T<g;T++)f+=p[T]*_[T];t.update(f,n,1)}}this.setMode=i,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function tm(s){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(t.calls++,o){case s.TRIANGLES:t.triangles+=a*(r/3);break;case s.LINES:t.lines+=a*(r/2);break;case s.LINE_STRIP:t.lines+=a*(r-1);break;case s.LINE_LOOP:t.lines+=a*r;break;case s.POINTS:t.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:i,update:n}}function nm(s,e,t){let n=new WeakMap,i=new Xe;function r(o,a,c){let l=o.morphTargetInfluences,h=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,u=h!==void 0?h.length:0,d=n.get(a);if(d===void 0||d.count!==u){let S=function(){E.dispose(),n.delete(a),a.removeEventListener("dispose",S)};d!==void 0&&d.texture.dispose();let p=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,_=a.morphAttributes.color!==void 0,m=a.morphAttributes.position||[],f=a.morphAttributes.normal||[],T=a.morphAttributes.color||[],A=0;p===!0&&(A=1),g===!0&&(A=2),_===!0&&(A=3);let M=a.attributes.position.count*A,U=1;M>e.maxTextureSize&&(U=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);let w=new Float32Array(M*U*4*u),E=new lr(w,M,U,u);E.type=$t,E.needsUpdate=!0;let N=A*4;for(let y=0;y<u;y++){let R=m[y],q=f[y],z=T[y],W=M*U*4*y;for(let J=0;J<R.count;J++){let H=J*N;p===!0&&(i.fromBufferAttribute(R,J),w[W+H+0]=i.x,w[W+H+1]=i.y,w[W+H+2]=i.z,w[W+H+3]=0),g===!0&&(i.fromBufferAttribute(q,J),w[W+H+4]=i.x,w[W+H+5]=i.y,w[W+H+6]=i.z,w[W+H+7]=0),_===!0&&(i.fromBufferAttribute(z,J),w[W+H+8]=i.x,w[W+H+9]=i.y,w[W+H+10]=i.z,w[W+H+11]=z.itemSize===4?i.w:1)}}d={count:u,texture:E,size:new Be(M,U)},n.set(a,d),a.addEventListener("dispose",S)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",o.morphTexture,t);else{let p=0;for(let _=0;_<l.length;_++)p+=l[_];let g=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(s,"morphTargetBaseInfluence",g),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function im(s,e,t,n){let i=new WeakMap;function r(c){let l=n.render.frame,h=c.geometry,u=e.get(c,h);if(i.get(u)!==l&&(e.update(u),i.set(u,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(t.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,s.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){let d=c.skeleton;i.get(d)!==l&&(d.update(),i.set(d,l))}return u}function o(){i=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:r,dispose:o}}var _r=class extends mt{constructor(e,t,n,i,r,o,a,c,l,h=Ii){if(h!==Ii&&h!==Fi)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===Ii&&(n=ri),n===void 0&&h===Fi&&(n=Oi),super(null,i,r,o,a,c,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Mt,this.minFilter=c!==void 0?c:Mt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},Sh=new mt,vl=new _r(1,1),bh=new lr,Ah=new ua,Th=new pr,yl=[],Ml=[],Sl=new Float32Array(16),bl=new Float32Array(9),Al=new Float32Array(4);function Yi(s,e,t){let n=s[0];if(n<=0||n>0)return s;let i=e*t,r=yl[i];if(r===void 0&&(r=new Float32Array(i),yl[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 dt(s,e){if(s.length!==e.length)return!1;for(let t=0,n=s.length;t<n;t++)if(s[t]!==e[t])return!1;return!0}function ft(s,e){for(let t=0,n=e.length;t<n;t++)s[t]=e[t]}function Hr(s,e){let t=Ml[e];t===void 0&&(t=new Int32Array(e),Ml[e]=t);for(let n=0;n!==e;++n)t[n]=s.allocateTextureUnit();return t}function sm(s,e){let t=this.cache;t[0]!==e&&(s.uniform1f(this.addr,e),t[0]=e)}function rm(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;s.uniform2fv(this.addr,e),ft(t,e)}}function om(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(s.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(dt(t,e))return;s.uniform3fv(this.addr,e),ft(t,e)}}function am(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;s.uniform4fv(this.addr,e),ft(t,e)}}function cm(s,e){let t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;s.uniformMatrix2fv(this.addr,!1,e),ft(t,e)}else{if(dt(t,n))return;Al.set(n),s.uniformMatrix2fv(this.addr,!1,Al),ft(t,n)}}function lm(s,e){let t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;s.uniformMatrix3fv(this.addr,!1,e),ft(t,e)}else{if(dt(t,n))return;bl.set(n),s.uniformMatrix3fv(this.addr,!1,bl),ft(t,n)}}function hm(s,e){let t=this.cache,n=e.elements;if(n===void 0){if(dt(t,e))return;s.uniformMatrix4fv(this.addr,!1,e),ft(t,e)}else{if(dt(t,n))return;Sl.set(n),s.uniformMatrix4fv(this.addr,!1,Sl),ft(t,n)}}function um(s,e){let t=this.cache;t[0]!==e&&(s.uniform1i(this.addr,e),t[0]=e)}function dm(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;s.uniform2iv(this.addr,e),ft(t,e)}}function fm(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;s.uniform3iv(this.addr,e),ft(t,e)}}function pm(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;s.uniform4iv(this.addr,e),ft(t,e)}}function mm(s,e){let t=this.cache;t[0]!==e&&(s.uniform1ui(this.addr,e),t[0]=e)}function gm(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(s.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(dt(t,e))return;s.uniform2uiv(this.addr,e),ft(t,e)}}function _m(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(s.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(dt(t,e))return;s.uniform3uiv(this.addr,e),ft(t,e)}}function xm(s,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(s.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(dt(t,e))return;s.uniform4uiv(this.addr,e),ft(t,e)}}function vm(s,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(vl.compareFunction=gh,r=vl):r=Sh,t.setTexture2D(e||r,i)}function ym(s,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture3D(e||Ah,i)}function Mm(s,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTextureCube(e||Th,i)}function Sm(s,e,t){let n=this.cache,i=t.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),t.setTexture2DArray(e||bh,i)}function bm(s){switch(s){case 5126:return sm;case 35664:return rm;case 35665:return om;case 35666:return am;case 35674:return cm;case 35675:return lm;case 35676:return hm;case 5124:case 35670:return um;case 35667:case 35671:return dm;case 35668:case 35672:return fm;case 35669:case 35673:return pm;case 5125:return mm;case 36294:return gm;case 36295:return _m;case 36296:return xm;case 35678:case 36198:case 36298:case 36306:case 35682:return vm;case 35679:case 36299:case 36307:return ym;case 35680:case 36300:case 36308:case 36293:return Mm;case 36289:case 36303:case 36311:case 36292:return Sm}}function Am(s,e){s.uniform1fv(this.addr,e)}function Tm(s,e){let t=Yi(e,this.size,2);s.uniform2fv(this.addr,t)}function Em(s,e){let t=Yi(e,this.size,3);s.uniform3fv(this.addr,t)}function wm(s,e){let t=Yi(e,this.size,4);s.uniform4fv(this.addr,t)}function Rm(s,e){let t=Yi(e,this.size,4);s.uniformMatrix2fv(this.addr,!1,t)}function Cm(s,e){let t=Yi(e,this.size,9);s.uniformMatrix3fv(this.addr,!1,t)}function Im(s,e){let t=Yi(e,this.size,16);s.uniformMatrix4fv(this.addr,!1,t)}function Pm(s,e){s.uniform1iv(this.addr,e)}function Lm(s,e){s.uniform2iv(this.addr,e)}function Dm(s,e){s.uniform3iv(this.addr,e)}function Nm(s,e){s.uniform4iv(this.addr,e)}function Um(s,e){s.uniform1uiv(this.addr,e)}function Om(s,e){s.uniform2uiv(this.addr,e)}function Fm(s,e){s.uniform3uiv(this.addr,e)}function Bm(s,e){s.uniform4uiv(this.addr,e)}function zm(s,e,t){let n=this.cache,i=e.length,r=Hr(t,i);dt(n,r)||(s.uniform1iv(this.addr,r),ft(n,r));for(let o=0;o!==i;++o)t.setTexture2D(e[o]||Sh,r[o])}function km(s,e,t){let n=this.cache,i=e.length,r=Hr(t,i);dt(n,r)||(s.uniform1iv(this.addr,r),ft(n,r));for(let o=0;o!==i;++o)t.setTexture3D(e[o]||Ah,r[o])}function Vm(s,e,t){let n=this.cache,i=e.length,r=Hr(t,i);dt(n,r)||(s.uniform1iv(this.addr,r),ft(n,r));for(let o=0;o!==i;++o)t.setTextureCube(e[o]||Th,r[o])}function Hm(s,e,t){let n=this.cache,i=e.length,r=Hr(t,i);dt(n,r)||(s.uniform1iv(this.addr,r),ft(n,r));for(let o=0;o!==i;++o)t.setTexture2DArray(e[o]||bh,r[o])}function Gm(s){switch(s){case 5126:return Am;case 35664:return Tm;case 35665:return Em;case 35666:return wm;case 35674:return Rm;case 35675:return Cm;case 35676:return Im;case 5124:case 35670:return Pm;case 35667:case 35671:return Lm;case 35668:case 35672:return Dm;case 35669:case 35673:return Nm;case 5125:return Um;case 36294:return Om;case 36295:return Fm;case 36296:return Bm;case 35678:case 36198:case 36298:case 36306:case 35682:return zm;case 35679:case 36299:case 36307:return km;case 35680:case 36300:case 36308:case 36293:return Vm;case 36289:case 36303:case 36311:case 36292:return Hm}}var pa=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=bm(t.type)}},ma=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Gm(t.type)}},ga=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let i=this.seq;for(let r=0,o=i.length;r!==o;++r){let a=i[r];a.setValue(e,t[a.id],n)}}},vo=/(\w+)(\])?(\[|\.)?/g;function Tl(s,e){s.seq.push(e),s.map[e.id]=e}function Wm(s,e,t){let n=s.name,i=n.length;for(vo.lastIndex=0;;){let r=vo.exec(n),o=vo.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){Tl(t,l===void 0?new pa(a,s,e):new ma(a,s,e));break}else{let u=t.map[a];u===void 0&&(u=new ga(a),Tl(t,u)),t=u}}}var Li=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let r=e.getActiveUniform(t,i),o=e.getUniformLocation(t,r.name);Wm(r,o,this)}}setValue(e,t,n,i){let r=this.map[t];r!==void 0&&r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];i!==void 0&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,o=t.length;r!==o;++r){let a=t[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let o=e[i];o.id in t&&n.push(o)}return n}};function El(s,e,t){let n=s.createShader(e);return s.shaderSource(n,t),s.compileShader(n),n}var Xm=37297,qm=0;function Ym(s,e){let t=s.split(`
|
|
3722
|
+
`),n=[],i=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let o=i;o<r;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
|
|
3723
|
+
`)}var wl=new Ie;function Zm(s){Fe._getMatrix(wl,Fe.workingColorSpace,s);let e=`mat3( ${wl.elements.map(t=>t.toFixed(4))} )`;switch(Fe.getTransfer(s)){case Vr:return[e,"LinearTransferOETF"];case Je:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[e,"LinearTransferOETF"]}}function Rl(s,e,t){let n=s.getShaderParameter(e,s.COMPILE_STATUS),i=s.getShaderInfoLog(e).trim();if(n&&i==="")return"";let r=/ERROR: 0:(\d+)/.exec(i);if(r){let o=parseInt(r[1]);return t.toUpperCase()+`
|
|
3724
|
+
|
|
3725
|
+
`+i+`
|
|
3726
|
+
|
|
3727
|
+
`+Ym(s.getShaderSource(e),o)}else return i}function Km(s,e){let t=Zm(e);return[`vec4 ${s}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
3728
|
+
`)}function Jm(s,e){let t;switch(e){case su:t="Linear";break;case ru:t="Reinhard";break;case ou:t="Cineon";break;case za:t="ACESFilmic";break;case cu:t="AgX";break;case lu:t="Neutral";break;case au:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+s+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Ys=new L;function $m(){Fe.getLuminanceCoefficients(Ys);let s=Ys.x.toFixed(4),e=Ys.y.toFixed(4),t=Ys.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
3729
|
+
`)}function jm(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(os).join(`
|
|
3730
|
+
`)}function Qm(s){let e=[];for(let t in s){let n=s[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
3731
|
+
`)}function eg(s,e){let t={},n=s.getProgramParameter(e,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let r=s.getActiveAttrib(e,i),o=r.name,a=1;r.type===s.FLOAT_MAT2&&(a=2),r.type===s.FLOAT_MAT3&&(a=3),r.type===s.FLOAT_MAT4&&(a=4),t[o]={type:r.type,location:s.getAttribLocation(e,o),locationSize:a}}return t}function os(s){return s!==""}function Cl(s,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Il(s,e){return s.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var tg=/^[ \t]*#include +<([\w\d./]+)>/gm;function _a(s){return s.replace(tg,ig)}var ng=new Map;function ig(s,e){let t=De[e];if(t===void 0){let n=ng.get(e);if(n!==void 0)t=De[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 _a(t)}var sg=/#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 Pl(s){return s.replace(sg,rg)}function rg(s,e,t,n){let i="";for(let r=parseInt(e);r<parseInt(t);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function Ll(s){let e=`precision ${s.precision} float;
|
|
3732
|
+
precision ${s.precision} int;
|
|
3733
|
+
precision ${s.precision} sampler2D;
|
|
3734
|
+
precision ${s.precision} samplerCube;
|
|
3735
|
+
precision ${s.precision} sampler3D;
|
|
3736
|
+
precision ${s.precision} sampler2DArray;
|
|
3737
|
+
precision ${s.precision} sampler2DShadow;
|
|
3738
|
+
precision ${s.precision} samplerCubeShadow;
|
|
3739
|
+
precision ${s.precision} sampler2DArrayShadow;
|
|
3740
|
+
precision ${s.precision} isampler2D;
|
|
3741
|
+
precision ${s.precision} isampler3D;
|
|
3742
|
+
precision ${s.precision} isamplerCube;
|
|
3743
|
+
precision ${s.precision} isampler2DArray;
|
|
3744
|
+
precision ${s.precision} usampler2D;
|
|
3745
|
+
precision ${s.precision} usampler3D;
|
|
3746
|
+
precision ${s.precision} usamplerCube;
|
|
3747
|
+
precision ${s.precision} usampler2DArray;
|
|
3748
|
+
`;return s.precision==="highp"?e+=`
|
|
3749
|
+
#define HIGH_PRECISION`:s.precision==="mediump"?e+=`
|
|
3750
|
+
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(e+=`
|
|
3751
|
+
#define LOW_PRECISION`),e}function og(s){let e="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===nh?e="SHADOWMAP_TYPE_PCF":s.shadowMapType===Fh?e="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===gn&&(e="SHADOWMAP_TYPE_VSM"),e}function ag(s){let e="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Ni:case Ui:e="ENVMAP_TYPE_CUBE";break;case zr:e="ENVMAP_TYPE_CUBE_UV";break}return e}function cg(s){let e="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case Ui:e="ENVMAP_MODE_REFRACTION";break}return e}function lg(s){let e="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case ih:e="ENVMAP_BLENDING_MULTIPLY";break;case nu:e="ENVMAP_BLENDING_MIX";break;case iu:e="ENVMAP_BLENDING_ADD";break}return e}function hg(s){let e=s.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function ug(s,e,t,n){let i=s.getContext(),r=t.defines,o=t.vertexShader,a=t.fragmentShader,c=og(t),l=ag(t),h=cg(t),u=lg(t),d=hg(t),p=jm(t),g=Qm(r),_=i.createProgram(),m,f,T=t.glslVersion?"#version "+t.glslVersion+`
|
|
3752
|
+
`:"";t.isRawShaderMaterial?(m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(os).join(`
|
|
3753
|
+
`),m.length>0&&(m+=`
|
|
3754
|
+
`),f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(os).join(`
|
|
3755
|
+
`),f.length>0&&(f+=`
|
|
3756
|
+
`)):(m=[Ll(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.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 "+c:"",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",`
|
|
3757
|
+
`].filter(os).join(`
|
|
3758
|
+
`),f=[Ll(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",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 "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==kn?"#define TONE_MAPPING":"",t.toneMapping!==kn?De.tonemapping_pars_fragment:"",t.toneMapping!==kn?Jm("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",De.colorspace_pars_fragment,Km("linearToOutputTexel",t.outputColorSpace),$m(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
3759
|
+
`].filter(os).join(`
|
|
3760
|
+
`)),o=_a(o),o=Cl(o,t),o=Il(o,t),a=_a(a),a=Cl(a,t),a=Il(a,t),o=Pl(o),a=Pl(a),t.isRawShaderMaterial!==!0&&(T=`#version 300 es
|
|
3761
|
+
`,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3762
|
+
`)+`
|
|
3763
|
+
`+m,f=["#define varying in",t.glslVersion===Xc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Xc?"":"#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(`
|
|
3764
|
+
`)+`
|
|
3765
|
+
`+f);let A=T+m+o,M=T+f+a,U=El(i,i.VERTEX_SHADER,A),w=El(i,i.FRAGMENT_SHADER,M);i.attachShader(_,U),i.attachShader(_,w),t.index0AttributeName!==void 0?i.bindAttribLocation(_,0,t.index0AttributeName):t.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function E(R){if(s.debug.checkShaderErrors){let q=i.getProgramInfoLog(_).trim(),z=i.getShaderInfoLog(U).trim(),W=i.getShaderInfoLog(w).trim(),J=!0,H=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(J=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,_,U,w);else{let Q=Rl(i,U,"vertex"),V=Rl(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+`
|
|
3766
|
+
|
|
3767
|
+
Material Name: `+R.name+`
|
|
3768
|
+
Material Type: `+R.type+`
|
|
3769
|
+
|
|
3770
|
+
Program Info Log: `+q+`
|
|
3771
|
+
`+Q+`
|
|
3772
|
+
`+V)}else q!==""?console.warn("THREE.WebGLProgram: Program Info Log:",q):(z===""||W==="")&&(H=!1);H&&(R.diagnostics={runnable:J,programLog:q,vertexShader:{log:z,prefix:m},fragmentShader:{log:W,prefix:f}})}i.deleteShader(U),i.deleteShader(w),N=new Li(i,_),S=eg(i,_)}let N;this.getUniforms=function(){return N===void 0&&E(this),N};let S;this.getAttributes=function(){return S===void 0&&E(this),S};let y=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return y===!1&&(y=i.getProgramParameter(_,Xm)),y},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=qm++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=U,this.fragmentShader=w,this}var dg=0,xa=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let 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){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}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){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new va(e),t.set(e,n)),n}},va=class{constructor(e){this.id=dg++,this.code=e,this.usedTimes=0}};function fg(s,e,t,n,i,r,o){let a=new hr,c=new xa,l=new Set,h=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures,p=i.precision,g={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 _(S){return l.add(S),S===0?"uv":`uv${S}`}function m(S,y,R,q,z){let W=q.fog,J=z.geometry,H=S.isMeshStandardMaterial?q.environment:null,Q=(S.isMeshStandardMaterial?t:e).get(S.envMap||H),V=Q&&Q.mapping===zr?Q.image.height:null,ie=g[S.type];S.precision!==null&&(p=i.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));let le=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,ve=le!==void 0?le.length:0,Ne=0;J.morphAttributes.position!==void 0&&(Ne=1),J.morphAttributes.normal!==void 0&&(Ne=2),J.morphAttributes.color!==void 0&&(Ne=3);let $e,X,ee,ge;if(ie){let Ze=en[ie];$e=Ze.vertexShader,X=Ze.fragmentShader}else $e=S.vertexShader,X=S.fragmentShader,c.update(S),ee=c.getVertexShaderID(S),ge=c.getFragmentShaderID(S);let se=s.getRenderTarget(),Ae=s.state.buffers.depth.getReversed(),we=z.isInstancedMesh===!0,Ue=z.isBatchedMesh===!0,st=!!S.map,He=!!S.matcap,at=!!Q,D=!!S.aoMap,Ut=!!S.lightMap,ze=!!S.bumpMap,ke=!!S.normalMap,Me=!!S.displacementMap,tt=!!S.emissiveMap,ye=!!S.metalnessMap,b=!!S.roughnessMap,x=S.anisotropy>0,O=S.clearcoat>0,Y=S.dispersion>0,K=S.iridescence>0,G=S.sheen>0,_e=S.transmission>0,re=x&&!!S.anisotropyMap,he=O&&!!S.clearcoatMap,Ge=O&&!!S.clearcoatNormalMap,$=O&&!!S.clearcoatRoughnessMap,ue=K&&!!S.iridescenceMap,be=K&&!!S.iridescenceThicknessMap,Te=G&&!!S.sheenColorMap,de=G&&!!S.sheenRoughnessMap,Ve=!!S.specularMap,Le=!!S.specularColorMap,Qe=!!S.specularIntensityMap,C=_e&&!!S.transmissionMap,ne=_e&&!!S.thicknessMap,k=!!S.gradientMap,Z=!!S.alphaMap,ce=S.alphaTest>0,oe=!!S.alphaHash,Re=!!S.extensions,ot=kn;S.toneMapped&&(se===null||se.isXRRenderTarget===!0)&&(ot=s.toneMapping);let gt={shaderID:ie,shaderType:S.type,shaderName:S.name,vertexShader:$e,fragmentShader:X,defines:S.defines,customVertexShaderID:ee,customFragmentShaderID:ge,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:Ue,batchingColor:Ue&&z._colorsTexture!==null,instancing:we,instancingColor:we&&z.instanceColor!==null,instancingMorph:we&&z.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:se===null?s.outputColorSpace:se.isXRRenderTarget===!0?se.texture.colorSpace:St,alphaToCoverage:!!S.alphaToCoverage,map:st,matcap:He,envMap:at,envMapMode:at&&Q.mapping,envMapCubeUVHeight:V,aoMap:D,lightMap:Ut,bumpMap:ze,normalMap:ke,displacementMap:d&&Me,emissiveMap:tt,normalMapObjectSpace:ke&&S.normalMapType===mu,normalMapTangentSpace:ke&&S.normalMapType===mh,metalnessMap:ye,roughnessMap:b,anisotropy:x,anisotropyMap:re,clearcoat:O,clearcoatMap:he,clearcoatNormalMap:Ge,clearcoatRoughnessMap:$,dispersion:Y,iridescence:K,iridescenceMap:ue,iridescenceThicknessMap:be,sheen:G,sheenColorMap:Te,sheenRoughnessMap:de,specularMap:Ve,specularColorMap:Le,specularIntensityMap:Qe,transmission:_e,transmissionMap:C,thicknessMap:ne,gradientMap:k,opaque:S.transparent===!1&&S.blending===Ci&&S.alphaToCoverage===!1,alphaMap:Z,alphaTest:ce,alphaHash:oe,combine:S.combine,mapUv:st&&_(S.map.channel),aoMapUv:D&&_(S.aoMap.channel),lightMapUv:Ut&&_(S.lightMap.channel),bumpMapUv:ze&&_(S.bumpMap.channel),normalMapUv:ke&&_(S.normalMap.channel),displacementMapUv:Me&&_(S.displacementMap.channel),emissiveMapUv:tt&&_(S.emissiveMap.channel),metalnessMapUv:ye&&_(S.metalnessMap.channel),roughnessMapUv:b&&_(S.roughnessMap.channel),anisotropyMapUv:re&&_(S.anisotropyMap.channel),clearcoatMapUv:he&&_(S.clearcoatMap.channel),clearcoatNormalMapUv:Ge&&_(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$&&_(S.clearcoatRoughnessMap.channel),iridescenceMapUv:ue&&_(S.iridescenceMap.channel),iridescenceThicknessMapUv:be&&_(S.iridescenceThicknessMap.channel),sheenColorMapUv:Te&&_(S.sheenColorMap.channel),sheenRoughnessMapUv:de&&_(S.sheenRoughnessMap.channel),specularMapUv:Ve&&_(S.specularMap.channel),specularColorMapUv:Le&&_(S.specularColorMap.channel),specularIntensityMapUv:Qe&&_(S.specularIntensityMap.channel),transmissionMapUv:C&&_(S.transmissionMap.channel),thicknessMapUv:ne&&_(S.thicknessMap.channel),alphaMapUv:Z&&_(S.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(ke||x),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!J.attributes.uv&&(st||Z),fog:!!W,useFog:S.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:S.flatShading===!0,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:Ae,skinning:z.isSkinnedMesh===!0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:ve,morphTextureStride:Ne,numDirLights:y.directional.length,numPointLights:y.point.length,numSpotLights:y.spot.length,numSpotLightMaps:y.spotLightMap.length,numRectAreaLights:y.rectArea.length,numHemiLights:y.hemi.length,numDirLightShadows:y.directionalShadowMap.length,numPointLightShadows:y.pointShadowMap.length,numSpotLightShadows:y.spotShadowMap.length,numSpotLightShadowsWithMaps:y.numSpotLightShadowsWithMaps,numLightProbes:y.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:S.dithering,shadowMapEnabled:s.shadowMap.enabled&&R.length>0,shadowMapType:s.shadowMap.type,toneMapping:ot,decodeVideoTexture:st&&S.map.isVideoTexture===!0&&Fe.getTransfer(S.map.colorSpace)===Je,decodeVideoTextureEmissive:tt&&S.emissiveMap.isVideoTexture===!0&&Fe.getTransfer(S.emissiveMap.colorSpace)===Je,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Kt,flipSided:S.side===wt,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:Re&&S.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Re&&S.extensions.multiDraw===!0||Ue)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return gt.vertexUv1s=l.has(1),gt.vertexUv2s=l.has(2),gt.vertexUv3s=l.has(3),l.clear(),gt}function f(S){let y=[];if(S.shaderID?y.push(S.shaderID):(y.push(S.customVertexShaderID),y.push(S.customFragmentShaderID)),S.defines!==void 0)for(let R in S.defines)y.push(R),y.push(S.defines[R]);return S.isRawShaderMaterial===!1&&(T(y,S),A(y,S),y.push(s.outputColorSpace)),y.push(S.customProgramCacheKey),y.join()}function T(S,y){S.push(y.precision),S.push(y.outputColorSpace),S.push(y.envMapMode),S.push(y.envMapCubeUVHeight),S.push(y.mapUv),S.push(y.alphaMapUv),S.push(y.lightMapUv),S.push(y.aoMapUv),S.push(y.bumpMapUv),S.push(y.normalMapUv),S.push(y.displacementMapUv),S.push(y.emissiveMapUv),S.push(y.metalnessMapUv),S.push(y.roughnessMapUv),S.push(y.anisotropyMapUv),S.push(y.clearcoatMapUv),S.push(y.clearcoatNormalMapUv),S.push(y.clearcoatRoughnessMapUv),S.push(y.iridescenceMapUv),S.push(y.iridescenceThicknessMapUv),S.push(y.sheenColorMapUv),S.push(y.sheenRoughnessMapUv),S.push(y.specularMapUv),S.push(y.specularColorMapUv),S.push(y.specularIntensityMapUv),S.push(y.transmissionMapUv),S.push(y.thicknessMapUv),S.push(y.combine),S.push(y.fogExp2),S.push(y.sizeAttenuation),S.push(y.morphTargetsCount),S.push(y.morphAttributeCount),S.push(y.numDirLights),S.push(y.numPointLights),S.push(y.numSpotLights),S.push(y.numSpotLightMaps),S.push(y.numHemiLights),S.push(y.numRectAreaLights),S.push(y.numDirLightShadows),S.push(y.numPointLightShadows),S.push(y.numSpotLightShadows),S.push(y.numSpotLightShadowsWithMaps),S.push(y.numLightProbes),S.push(y.shadowMapType),S.push(y.toneMapping),S.push(y.numClippingPlanes),S.push(y.numClipIntersection),S.push(y.depthPacking)}function A(S,y){a.disableAll(),y.supportsVertexTextures&&a.enable(0),y.instancing&&a.enable(1),y.instancingColor&&a.enable(2),y.instancingMorph&&a.enable(3),y.matcap&&a.enable(4),y.envMap&&a.enable(5),y.normalMapObjectSpace&&a.enable(6),y.normalMapTangentSpace&&a.enable(7),y.clearcoat&&a.enable(8),y.iridescence&&a.enable(9),y.alphaTest&&a.enable(10),y.vertexColors&&a.enable(11),y.vertexAlphas&&a.enable(12),y.vertexUv1s&&a.enable(13),y.vertexUv2s&&a.enable(14),y.vertexUv3s&&a.enable(15),y.vertexTangents&&a.enable(16),y.anisotropy&&a.enable(17),y.alphaHash&&a.enable(18),y.batching&&a.enable(19),y.dispersion&&a.enable(20),y.batchingColor&&a.enable(21),S.push(a.mask),a.disableAll(),y.fog&&a.enable(0),y.useFog&&a.enable(1),y.flatShading&&a.enable(2),y.logarithmicDepthBuffer&&a.enable(3),y.reverseDepthBuffer&&a.enable(4),y.skinning&&a.enable(5),y.morphTargets&&a.enable(6),y.morphNormals&&a.enable(7),y.morphColors&&a.enable(8),y.premultipliedAlpha&&a.enable(9),y.shadowMapEnabled&&a.enable(10),y.doubleSided&&a.enable(11),y.flipSided&&a.enable(12),y.useDepthPacking&&a.enable(13),y.dithering&&a.enable(14),y.transmission&&a.enable(15),y.sheen&&a.enable(16),y.opaque&&a.enable(17),y.pointsUvs&&a.enable(18),y.decodeVideoTexture&&a.enable(19),y.decodeVideoTextureEmissive&&a.enable(20),y.alphaToCoverage&&a.enable(21),S.push(a.mask)}function M(S){let y=g[S.type],R;if(y){let q=en[y];R=nd.clone(q.uniforms)}else R=S.uniforms;return R}function U(S,y){let R;for(let q=0,z=h.length;q<z;q++){let W=h[q];if(W.cacheKey===y){R=W,++R.usedTimes;break}}return R===void 0&&(R=new ug(s,y,S,r),h.push(R)),R}function w(S){if(--S.usedTimes===0){let y=h.indexOf(S);h[y]=h[h.length-1],h.pop(),S.destroy()}}function E(S){c.remove(S)}function N(){c.dispose()}return{getParameters:m,getProgramCacheKey:f,getUniforms:M,acquireProgram:U,releaseProgram:w,releaseShaderCache:E,programs:h,dispose:N}}function pg(){let s=new WeakMap;function e(o){return s.has(o)}function t(o){let a=s.get(o);return a===void 0&&(a={},s.set(o,a)),a}function n(o){s.delete(o)}function i(o,a,c){s.get(o)[a]=c}function r(){s=new WeakMap}return{has:e,get:t,remove:n,update:i,dispose:r}}function mg(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.material.id!==e.material.id?s.material.id-e.material.id:s.z!==e.z?s.z-e.z:s.id-e.id}function Dl(s,e){return s.groupOrder!==e.groupOrder?s.groupOrder-e.groupOrder:s.renderOrder!==e.renderOrder?s.renderOrder-e.renderOrder:s.z!==e.z?e.z-s.z:s.id-e.id}function Nl(){let s=[],e=0,t=[],n=[],i=[];function r(){e=0,t.length=0,n.length=0,i.length=0}function o(u,d,p,g,_,m){let f=s[e];return f===void 0?(f={id:u.id,object:u,geometry:d,material:p,groupOrder:g,renderOrder:u.renderOrder,z:_,group:m},s[e]=f):(f.id=u.id,f.object=u,f.geometry=d,f.material=p,f.groupOrder=g,f.renderOrder=u.renderOrder,f.z=_,f.group=m),e++,f}function a(u,d,p,g,_,m){let f=o(u,d,p,g,_,m);p.transmission>0?n.push(f):p.transparent===!0?i.push(f):t.push(f)}function c(u,d,p,g,_,m){let f=o(u,d,p,g,_,m);p.transmission>0?n.unshift(f):p.transparent===!0?i.unshift(f):t.unshift(f)}function l(u,d){t.length>1&&t.sort(u||mg),n.length>1&&n.sort(d||Dl),i.length>1&&i.sort(d||Dl)}function h(){for(let u=e,d=s.length;u<d;u++){let p=s[u];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:t,transmissive:n,transparent:i,init:r,push:a,unshift:c,finish:h,sort:l}}function gg(){let s=new WeakMap;function e(n,i){let r=s.get(n),o;return r===void 0?(o=new Nl,s.set(n,[o])):i>=r.length?(o=new Nl,r.push(o)):o=r[i],o}function t(){s=new WeakMap}return{get:e,dispose:t}}function _g(){let 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 L,color:new Se};break;case"SpotLight":t={position:new L,direction:new L,color:new Se,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new L,color:new Se,distance:0,decay:0};break;case"HemisphereLight":t={direction:new L,skyColor:new Se,groundColor:new Se};break;case"RectAreaLight":t={color:new Se,position:new L,halfWidth:new L,halfHeight:new L};break}return s[e.id]=t,t}}}function xg(){let 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 Be};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Be,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[e.id]=t,t}}}var vg=0;function yg(s,e){return(e.castShadow?2:0)-(s.castShadow?2:0)+(e.map?1:0)-(s.map?1:0)}function Mg(s){let e=new _g,t=xg(),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 l=0;l<9;l++)n.probe.push(new L);let i=new L,r=new Pe,o=new Pe;function a(l){let h=0,u=0,d=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let p=0,g=0,_=0,m=0,f=0,T=0,A=0,M=0,U=0,w=0,E=0;l.sort(yg);for(let S=0,y=l.length;S<y;S++){let R=l[S],q=R.color,z=R.intensity,W=R.distance,J=R.shadow&&R.shadow.map?R.shadow.map.texture:null;if(R.isAmbientLight)h+=q.r*z,u+=q.g*z,d+=q.b*z;else if(R.isLightProbe){for(let H=0;H<9;H++)n.probe[H].addScaledVector(R.sh.coefficients[H],z);E++}else if(R.isDirectionalLight){let H=e.get(R);if(H.color.copy(R.color).multiplyScalar(R.intensity),R.castShadow){let Q=R.shadow,V=t.get(R);V.shadowIntensity=Q.intensity,V.shadowBias=Q.bias,V.shadowNormalBias=Q.normalBias,V.shadowRadius=Q.radius,V.shadowMapSize=Q.mapSize,n.directionalShadow[p]=V,n.directionalShadowMap[p]=J,n.directionalShadowMatrix[p]=R.shadow.matrix,T++}n.directional[p]=H,p++}else if(R.isSpotLight){let H=e.get(R);H.position.setFromMatrixPosition(R.matrixWorld),H.color.copy(q).multiplyScalar(z),H.distance=W,H.coneCos=Math.cos(R.angle),H.penumbraCos=Math.cos(R.angle*(1-R.penumbra)),H.decay=R.decay,n.spot[_]=H;let Q=R.shadow;if(R.map&&(n.spotLightMap[U]=R.map,U++,Q.updateMatrices(R),R.castShadow&&w++),n.spotLightMatrix[_]=Q.matrix,R.castShadow){let V=t.get(R);V.shadowIntensity=Q.intensity,V.shadowBias=Q.bias,V.shadowNormalBias=Q.normalBias,V.shadowRadius=Q.radius,V.shadowMapSize=Q.mapSize,n.spotShadow[_]=V,n.spotShadowMap[_]=J,M++}_++}else if(R.isRectAreaLight){let H=e.get(R);H.color.copy(q).multiplyScalar(z),H.halfWidth.set(R.width*.5,0,0),H.halfHeight.set(0,R.height*.5,0),n.rectArea[m]=H,m++}else if(R.isPointLight){let H=e.get(R);if(H.color.copy(R.color).multiplyScalar(R.intensity),H.distance=R.distance,H.decay=R.decay,R.castShadow){let Q=R.shadow,V=t.get(R);V.shadowIntensity=Q.intensity,V.shadowBias=Q.bias,V.shadowNormalBias=Q.normalBias,V.shadowRadius=Q.radius,V.shadowMapSize=Q.mapSize,V.shadowCameraNear=Q.camera.near,V.shadowCameraFar=Q.camera.far,n.pointShadow[g]=V,n.pointShadowMap[g]=J,n.pointShadowMatrix[g]=R.shadow.matrix,A++}n.point[g]=H,g++}else if(R.isHemisphereLight){let H=e.get(R);H.skyColor.copy(R.color).multiplyScalar(z),H.groundColor.copy(R.groundColor).multiplyScalar(z),n.hemi[f]=H,f++}}m>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=te.LTC_FLOAT_1,n.rectAreaLTC2=te.LTC_FLOAT_2):(n.rectAreaLTC1=te.LTC_HALF_1,n.rectAreaLTC2=te.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;let N=n.hash;(N.directionalLength!==p||N.pointLength!==g||N.spotLength!==_||N.rectAreaLength!==m||N.hemiLength!==f||N.numDirectionalShadows!==T||N.numPointShadows!==A||N.numSpotShadows!==M||N.numSpotMaps!==U||N.numLightProbes!==E)&&(n.directional.length=p,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=f,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=M+U-w,n.spotLightMap.length=U,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=E,N.directionalLength=p,N.pointLength=g,N.spotLength=_,N.rectAreaLength=m,N.hemiLength=f,N.numDirectionalShadows=T,N.numPointShadows=A,N.numSpotShadows=M,N.numSpotMaps=U,N.numLightProbes=E,n.version=vg++)}function c(l,h){let u=0,d=0,p=0,g=0,_=0,m=h.matrixWorldInverse;for(let f=0,T=l.length;f<T;f++){let A=l[f];if(A.isDirectionalLight){let M=n.directional[u];M.direction.setFromMatrixPosition(A.matrixWorld),i.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(i),M.direction.transformDirection(m),u++}else if(A.isSpotLight){let M=n.spot[p];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(A.matrixWorld),i.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(i),M.direction.transformDirection(m),p++}else if(A.isRectAreaLight){let M=n.rectArea[g];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),o.identity(),r.copy(A.matrixWorld),r.premultiply(m),o.extractRotation(r),M.halfWidth.set(A.width*.5,0,0),M.halfHeight.set(0,A.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),g++}else if(A.isPointLight){let M=n.point[d];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),d++}else if(A.isHemisphereLight){let M=n.hemi[_];M.direction.setFromMatrixPosition(A.matrixWorld),M.direction.transformDirection(m),_++}}}return{setup:a,setupView:c,state:n}}function Ul(s){let e=new Mg(s),t=[],n=[];function i(h){l.camera=h,t.length=0,n.length=0}function r(h){t.push(h)}function o(h){n.push(h)}function a(){e.setup(t)}function c(h){e.setupView(t,h)}let l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:i,state:l,setupLights:a,setupLightsView:c,pushLight:r,pushShadow:o}}function Sg(s){let e=new WeakMap;function t(i,r=0){let o=e.get(i),a;return o===void 0?(a=new Ul(s),e.set(i,[a])):r>=o.length?(a=new Ul(s),o.push(a)):a=o[r],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var ya=class extends Dt{static get type(){return"MeshDepthMaterial"}constructor(e){super(),this.isMeshDepthMaterial=!0,this.depthPacking=fu,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}},Ma=class extends Dt{static get type(){return"MeshDistanceMaterial"}constructor(e){super(),this.isMeshDistanceMaterial=!0,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}},bg=`void main() {
|
|
3773
|
+
gl_Position = vec4( position, 1.0 );
|
|
3774
|
+
}`,Ag=`uniform sampler2D shadow_pass;
|
|
3775
|
+
uniform vec2 resolution;
|
|
3776
|
+
uniform float radius;
|
|
3777
|
+
#include <packing>
|
|
3778
|
+
void main() {
|
|
3779
|
+
const float samples = float( VSM_SAMPLES );
|
|
3780
|
+
float mean = 0.0;
|
|
3781
|
+
float squared_mean = 0.0;
|
|
3782
|
+
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
3783
|
+
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
3784
|
+
for ( float i = 0.0; i < samples; i ++ ) {
|
|
3785
|
+
float uvOffset = uvStart + i * uvStride;
|
|
3786
|
+
#ifdef HORIZONTAL_PASS
|
|
3787
|
+
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
3788
|
+
mean += distribution.x;
|
|
3789
|
+
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
3790
|
+
#else
|
|
3791
|
+
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
3792
|
+
mean += depth;
|
|
3793
|
+
squared_mean += depth * depth;
|
|
3794
|
+
#endif
|
|
3795
|
+
}
|
|
3796
|
+
mean = mean / samples;
|
|
3797
|
+
squared_mean = squared_mean / samples;
|
|
3798
|
+
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3799
|
+
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3800
|
+
}`;function Tg(s,e,t){let n=new ms,i=new Be,r=new Be,o=new Xe,a=new ya({depthPacking:pu}),c=new Ma,l={},h=t.maxTextureSize,u={[sn]:wt,[wt]:sn,[Kt]:Kt},d=new an({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Be},radius:{value:4}},vertexShader:bg,fragmentShader:Ag}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let g=new Vt;g.setAttribute("position",new ut(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new yt(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=nh;let f=this.type;this.render=function(w,E,N){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let S=s.getRenderTarget(),y=s.getActiveCubeFace(),R=s.getActiveMipmapLevel(),q=s.state;q.setBlending(zn),q.buffers.color.setClear(1,1,1,1),q.buffers.depth.setTest(!0),q.setScissorTest(!1);let z=f!==gn&&this.type===gn,W=f===gn&&this.type!==gn;for(let J=0,H=w.length;J<H;J++){let Q=w[J],V=Q.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",Q,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);let ie=V.getFrameExtents();if(i.multiply(ie),r.copy(V.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/ie.x),i.x=r.x*ie.x,V.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/ie.y),i.y=r.y*ie.y,V.mapSize.y=r.y)),V.map===null||z===!0||W===!0){let ve=this.type!==gn?{minFilter:Mt,magFilter:Mt}:{};V.map!==null&&V.map.dispose(),V.map=new bn(i.x,i.y,ve),V.map.texture.name=Q.name+".shadowMap",V.camera.updateProjectionMatrix()}s.setRenderTarget(V.map),s.clear();let le=V.getViewportCount();for(let ve=0;ve<le;ve++){let Ne=V.getViewport(ve);o.set(r.x*Ne.x,r.y*Ne.y,r.x*Ne.z,r.y*Ne.w),q.viewport(o),V.updateMatrices(Q,ve),n=V.getFrustum(),M(E,N,V.camera,Q,this.type)}V.isPointLightShadow!==!0&&this.type===gn&&T(V,N),V.needsUpdate=!1}f=this.type,m.needsUpdate=!1,s.setRenderTarget(S,y,R)};function T(w,E){let N=e.update(_);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new bn(i.x,i.y)),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(E,null,N,d,_,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(E,null,N,p,_,null)}function A(w,E,N,S){let y=null,R=N.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0)y=R;else if(y=N.isPointLight===!0?c:a,s.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0){let q=y.uuid,z=E.uuid,W=l[q];W===void 0&&(W={},l[q]=W);let J=W[z];J===void 0&&(J=y.clone(),W[z]=J,E.addEventListener("dispose",U)),y=J}if(y.visible=E.visible,y.wireframe=E.wireframe,S===gn?y.side=E.shadowSide!==null?E.shadowSide:E.side:y.side=E.shadowSide!==null?E.shadowSide:u[E.side],y.alphaMap=E.alphaMap,y.alphaTest=E.alphaTest,y.map=E.map,y.clipShadows=E.clipShadows,y.clippingPlanes=E.clippingPlanes,y.clipIntersection=E.clipIntersection,y.displacementMap=E.displacementMap,y.displacementScale=E.displacementScale,y.displacementBias=E.displacementBias,y.wireframeLinewidth=E.wireframeLinewidth,y.linewidth=E.linewidth,N.isPointLight===!0&&y.isMeshDistanceMaterial===!0){let q=s.properties.get(y);q.light=N}return y}function M(w,E,N,S,y){if(w.visible===!1)return;if(w.layers.test(E.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&y===gn)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,w.matrixWorld);let z=e.update(w),W=w.material;if(Array.isArray(W)){let J=z.groups;for(let H=0,Q=J.length;H<Q;H++){let V=J[H],ie=W[V.materialIndex];if(ie&&ie.visible){let le=A(w,ie,S,y);w.onBeforeShadow(s,w,E,N,z,le,V),s.renderBufferDirect(N,null,z,le,w,V),w.onAfterShadow(s,w,E,N,z,le,V)}}}else if(W.visible){let J=A(w,W,S,y);w.onBeforeShadow(s,w,E,N,z,J,null),s.renderBufferDirect(N,null,z,J,w,null),w.onAfterShadow(s,w,E,N,z,J,null)}}let q=w.children;for(let z=0,W=q.length;z<W;z++)M(q[z],E,N,S,y)}function U(w){w.target.removeEventListener("dispose",U);for(let N in l){let S=l[N],y=w.target.uuid;y in S&&(S[y].dispose(),delete S[y])}}}var Eg={[wo]:Ro,[Co]:Lo,[Io]:Do,[Di]:Po,[Ro]:wo,[Lo]:Co,[Do]:Io,[Po]:Di};function wg(s,e){function t(){let C=!1,ne=new Xe,k=null,Z=new Xe(0,0,0,0);return{setMask:function(ce){k!==ce&&!C&&(s.colorMask(ce,ce,ce,ce),k=ce)},setLocked:function(ce){C=ce},setClear:function(ce,oe,Re,ot,gt){gt===!0&&(ce*=ot,oe*=ot,Re*=ot),ne.set(ce,oe,Re,ot),Z.equals(ne)===!1&&(s.clearColor(ce,oe,Re,ot),Z.copy(ne))},reset:function(){C=!1,k=null,Z.set(-1,0,0,0)}}}function n(){let C=!1,ne=!1,k=null,Z=null,ce=null;return{setReversed:function(oe){if(ne!==oe){let Re=e.get("EXT_clip_control");ne?Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.ZERO_TO_ONE_EXT):Re.clipControlEXT(Re.LOWER_LEFT_EXT,Re.NEGATIVE_ONE_TO_ONE_EXT);let ot=ce;ce=null,this.setClear(ot)}ne=oe},getReversed:function(){return ne},setTest:function(oe){oe?se(s.DEPTH_TEST):Ae(s.DEPTH_TEST)},setMask:function(oe){k!==oe&&!C&&(s.depthMask(oe),k=oe)},setFunc:function(oe){if(ne&&(oe=Eg[oe]),Z!==oe){switch(oe){case wo:s.depthFunc(s.NEVER);break;case Ro:s.depthFunc(s.ALWAYS);break;case Co:s.depthFunc(s.LESS);break;case Di:s.depthFunc(s.LEQUAL);break;case Io:s.depthFunc(s.EQUAL);break;case Po:s.depthFunc(s.GEQUAL);break;case Lo:s.depthFunc(s.GREATER);break;case Do:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Z=oe}},setLocked:function(oe){C=oe},setClear:function(oe){ce!==oe&&(ne&&(oe=1-oe),s.clearDepth(oe),ce=oe)},reset:function(){C=!1,k=null,Z=null,ce=null,ne=!1}}}function i(){let C=!1,ne=null,k=null,Z=null,ce=null,oe=null,Re=null,ot=null,gt=null;return{setTest:function(Ze){C||(Ze?se(s.STENCIL_TEST):Ae(s.STENCIL_TEST))},setMask:function(Ze){ne!==Ze&&!C&&(s.stencilMask(Ze),ne=Ze)},setFunc:function(Ze,Wt,cn){(k!==Ze||Z!==Wt||ce!==cn)&&(s.stencilFunc(Ze,Wt,cn),k=Ze,Z=Wt,ce=cn)},setOp:function(Ze,Wt,cn){(oe!==Ze||Re!==Wt||ot!==cn)&&(s.stencilOp(Ze,Wt,cn),oe=Ze,Re=Wt,ot=cn)},setLocked:function(Ze){C=Ze},setClear:function(Ze){gt!==Ze&&(s.clearStencil(Ze),gt=Ze)},reset:function(){C=!1,ne=null,k=null,Z=null,ce=null,oe=null,Re=null,ot=null,gt=null}}}let r=new t,o=new n,a=new i,c=new WeakMap,l=new WeakMap,h={},u={},d=new WeakMap,p=[],g=null,_=!1,m=null,f=null,T=null,A=null,M=null,U=null,w=null,E=new Se(0,0,0),N=0,S=!1,y=null,R=null,q=null,z=null,W=null,J=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),H=!1,Q=0,V=s.getParameter(s.VERSION);V.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(V)[1]),H=Q>=1):V.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),H=Q>=2);let ie=null,le={},ve=s.getParameter(s.SCISSOR_BOX),Ne=s.getParameter(s.VIEWPORT),$e=new Xe().fromArray(ve),X=new Xe().fromArray(Ne);function ee(C,ne,k,Z){let ce=new Uint8Array(4),oe=s.createTexture();s.bindTexture(C,oe),s.texParameteri(C,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(C,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Re=0;Re<k;Re++)C===s.TEXTURE_3D||C===s.TEXTURE_2D_ARRAY?s.texImage3D(ne,0,s.RGBA,1,1,Z,0,s.RGBA,s.UNSIGNED_BYTE,ce):s.texImage2D(ne+Re,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,ce);return oe}let ge={};ge[s.TEXTURE_2D]=ee(s.TEXTURE_2D,s.TEXTURE_2D,1),ge[s.TEXTURE_CUBE_MAP]=ee(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),ge[s.TEXTURE_2D_ARRAY]=ee(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),ge[s.TEXTURE_3D]=ee(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),se(s.DEPTH_TEST),o.setFunc(Di),ze(!1),ke(zc),se(s.CULL_FACE),D(zn);function se(C){h[C]!==!0&&(s.enable(C),h[C]=!0)}function Ae(C){h[C]!==!1&&(s.disable(C),h[C]=!1)}function we(C,ne){return u[C]!==ne?(s.bindFramebuffer(C,ne),u[C]=ne,C===s.DRAW_FRAMEBUFFER&&(u[s.FRAMEBUFFER]=ne),C===s.FRAMEBUFFER&&(u[s.DRAW_FRAMEBUFFER]=ne),!0):!1}function Ue(C,ne){let k=p,Z=!1;if(C){k=d.get(ne),k===void 0&&(k=[],d.set(ne,k));let ce=C.textures;if(k.length!==ce.length||k[0]!==s.COLOR_ATTACHMENT0){for(let oe=0,Re=ce.length;oe<Re;oe++)k[oe]=s.COLOR_ATTACHMENT0+oe;k.length=ce.length,Z=!0}}else k[0]!==s.BACK&&(k[0]=s.BACK,Z=!0);Z&&s.drawBuffers(k)}function st(C){return g!==C?(s.useProgram(C),g=C,!0):!1}let He={[ti]:s.FUNC_ADD,[zh]:s.FUNC_SUBTRACT,[kh]:s.FUNC_REVERSE_SUBTRACT};He[Vh]=s.MIN,He[Hh]=s.MAX;let at={[Gh]:s.ZERO,[Wh]:s.ONE,[Xh]:s.SRC_COLOR,[To]:s.SRC_ALPHA,[$h]:s.SRC_ALPHA_SATURATE,[Kh]:s.DST_COLOR,[Yh]:s.DST_ALPHA,[qh]:s.ONE_MINUS_SRC_COLOR,[Eo]:s.ONE_MINUS_SRC_ALPHA,[Jh]:s.ONE_MINUS_DST_COLOR,[Zh]:s.ONE_MINUS_DST_ALPHA,[jh]:s.CONSTANT_COLOR,[Qh]:s.ONE_MINUS_CONSTANT_COLOR,[eu]:s.CONSTANT_ALPHA,[tu]:s.ONE_MINUS_CONSTANT_ALPHA};function D(C,ne,k,Z,ce,oe,Re,ot,gt,Ze){if(C===zn){_===!0&&(Ae(s.BLEND),_=!1);return}if(_===!1&&(se(s.BLEND),_=!0),C!==Bh){if(C!==m||Ze!==S){if((f!==ti||M!==ti)&&(s.blendEquation(s.FUNC_ADD),f=ti,M=ti),Ze)switch(C){case Ci:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case kc:s.blendFunc(s.ONE,s.ONE);break;case Vc:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Hc:s.blendFuncSeparate(s.ZERO,s.SRC_COLOR,s.ZERO,s.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}else switch(C){case Ci:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case kc:s.blendFunc(s.SRC_ALPHA,s.ONE);break;case Vc:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Hc:s.blendFunc(s.ZERO,s.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}T=null,A=null,U=null,w=null,E.set(0,0,0),N=0,m=C,S=Ze}return}ce=ce||ne,oe=oe||k,Re=Re||Z,(ne!==f||ce!==M)&&(s.blendEquationSeparate(He[ne],He[ce]),f=ne,M=ce),(k!==T||Z!==A||oe!==U||Re!==w)&&(s.blendFuncSeparate(at[k],at[Z],at[oe],at[Re]),T=k,A=Z,U=oe,w=Re),(ot.equals(E)===!1||gt!==N)&&(s.blendColor(ot.r,ot.g,ot.b,gt),E.copy(ot),N=gt),m=C,S=!1}function Ut(C,ne){C.side===Kt?Ae(s.CULL_FACE):se(s.CULL_FACE);let k=C.side===wt;ne&&(k=!k),ze(k),C.blending===Ci&&C.transparent===!1?D(zn):D(C.blending,C.blendEquation,C.blendSrc,C.blendDst,C.blendEquationAlpha,C.blendSrcAlpha,C.blendDstAlpha,C.blendColor,C.blendAlpha,C.premultipliedAlpha),o.setFunc(C.depthFunc),o.setTest(C.depthTest),o.setMask(C.depthWrite),r.setMask(C.colorWrite);let Z=C.stencilWrite;a.setTest(Z),Z&&(a.setMask(C.stencilWriteMask),a.setFunc(C.stencilFunc,C.stencilRef,C.stencilFuncMask),a.setOp(C.stencilFail,C.stencilZFail,C.stencilZPass)),tt(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),C.alphaToCoverage===!0?se(s.SAMPLE_ALPHA_TO_COVERAGE):Ae(s.SAMPLE_ALPHA_TO_COVERAGE)}function ze(C){y!==C&&(C?s.frontFace(s.CW):s.frontFace(s.CCW),y=C)}function ke(C){C!==Uh?(se(s.CULL_FACE),C!==R&&(C===zc?s.cullFace(s.BACK):C===Oh?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):Ae(s.CULL_FACE),R=C}function Me(C){C!==q&&(H&&s.lineWidth(C),q=C)}function tt(C,ne,k){C?(se(s.POLYGON_OFFSET_FILL),(z!==ne||W!==k)&&(s.polygonOffset(ne,k),z=ne,W=k)):Ae(s.POLYGON_OFFSET_FILL)}function ye(C){C?se(s.SCISSOR_TEST):Ae(s.SCISSOR_TEST)}function b(C){C===void 0&&(C=s.TEXTURE0+J-1),ie!==C&&(s.activeTexture(C),ie=C)}function x(C,ne,k){k===void 0&&(ie===null?k=s.TEXTURE0+J-1:k=ie);let Z=le[k];Z===void 0&&(Z={type:void 0,texture:void 0},le[k]=Z),(Z.type!==C||Z.texture!==ne)&&(ie!==k&&(s.activeTexture(k),ie=k),s.bindTexture(C,ne||ge[C]),Z.type=C,Z.texture=ne)}function O(){let C=le[ie];C!==void 0&&C.type!==void 0&&(s.bindTexture(C.type,null),C.type=void 0,C.texture=void 0)}function Y(){try{s.compressedTexImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function K(){try{s.compressedTexImage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function G(){try{s.texSubImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function _e(){try{s.texSubImage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function re(){try{s.compressedTexSubImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function he(){try{s.compressedTexSubImage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Ge(){try{s.texStorage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function $(){try{s.texStorage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ue(){try{s.texImage2D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function be(){try{s.texImage3D.apply(s,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Te(C){$e.equals(C)===!1&&(s.scissor(C.x,C.y,C.z,C.w),$e.copy(C))}function de(C){X.equals(C)===!1&&(s.viewport(C.x,C.y,C.z,C.w),X.copy(C))}function Ve(C,ne){let k=l.get(ne);k===void 0&&(k=new WeakMap,l.set(ne,k));let Z=k.get(C);Z===void 0&&(Z=s.getUniformBlockIndex(ne,C.name),k.set(C,Z))}function Le(C,ne){let Z=l.get(ne).get(C);c.get(ne)!==Z&&(s.uniformBlockBinding(ne,Z,C.__bindingPointIndex),c.set(ne,Z))}function Qe(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),o.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),h={},ie=null,le={},u={},d=new WeakMap,p=[],g=null,_=!1,m=null,f=null,T=null,A=null,M=null,U=null,w=null,E=new Se(0,0,0),N=0,S=!1,y=null,R=null,q=null,z=null,W=null,$e.set(0,0,s.canvas.width,s.canvas.height),X.set(0,0,s.canvas.width,s.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:se,disable:Ae,bindFramebuffer:we,drawBuffers:Ue,useProgram:st,setBlending:D,setMaterial:Ut,setFlipSided:ze,setCullFace:ke,setLineWidth:Me,setPolygonOffset:tt,setScissorTest:ye,activeTexture:b,bindTexture:x,unbindTexture:O,compressedTexImage2D:Y,compressedTexImage3D:K,texImage2D:ue,texImage3D:be,updateUBOMapping:Ve,uniformBlockBinding:Le,texStorage2D:Ge,texStorage3D:$,texSubImage2D:G,texSubImage3D:_e,compressedTexSubImage2D:re,compressedTexSubImage3D:he,scissor:Te,viewport:de,reset:Qe}}function Ol(s,e,t,n){let i=Rg(n);switch(t){case ch:return s*e;case hh:return s*e;case uh:return s*e*2;case Wa:return s*e/i.components*i.byteLength;case Xa:return s*e/i.components*i.byteLength;case dh:return s*e*2/i.components*i.byteLength;case qa:return s*e*2/i.components*i.byteLength;case lh:return s*e*3/i.components*i.byteLength;case Bt:return s*e*4/i.components*i.byteLength;case Ya:return s*e*4/i.components*i.byteLength;case tr:case nr:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case ir:case sr:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Fo:case zo:return Math.max(s,16)*Math.max(e,8)/4;case Oo:case Bo:return Math.max(s,8)*Math.max(e,8)/2;case ko:case Vo:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*8;case Ho:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Go:return Math.floor((s+3)/4)*Math.floor((e+3)/4)*16;case Wo:return Math.floor((s+4)/5)*Math.floor((e+3)/4)*16;case Xo:return Math.floor((s+4)/5)*Math.floor((e+4)/5)*16;case qo:return Math.floor((s+5)/6)*Math.floor((e+4)/5)*16;case Yo:return Math.floor((s+5)/6)*Math.floor((e+5)/6)*16;case Zo:return Math.floor((s+7)/8)*Math.floor((e+4)/5)*16;case Ko:return Math.floor((s+7)/8)*Math.floor((e+5)/6)*16;case Jo:return Math.floor((s+7)/8)*Math.floor((e+7)/8)*16;case $o:return Math.floor((s+9)/10)*Math.floor((e+4)/5)*16;case jo:return Math.floor((s+9)/10)*Math.floor((e+5)/6)*16;case Qo:return Math.floor((s+9)/10)*Math.floor((e+7)/8)*16;case ea:return Math.floor((s+9)/10)*Math.floor((e+9)/10)*16;case ta:return Math.floor((s+11)/12)*Math.floor((e+9)/10)*16;case na:return Math.floor((s+11)/12)*Math.floor((e+11)/12)*16;case rr:case ia:case sa:return Math.ceil(s/4)*Math.ceil(e/4)*16;case fh:case ra:return Math.ceil(s/4)*Math.ceil(e/4)*8;case oa:case aa:return Math.ceil(s/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Rg(s){switch(s){case Mn:case rh:return{byteLength:1,components:1};case ds:case oh:case bs:return{byteLength:2,components:1};case Ha:case Ga:return{byteLength:2,components:4};case ri:case Va:case $t:return{byteLength:4,components:1};case ah:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}function Cg(s,e,t,n,i,r,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Be,h=new WeakMap,u,d=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(b,x){return p?new OffscreenCanvas(b,x):fs("canvas")}function _(b,x,O){let Y=1,K=ye(b);if((K.width>O||K.height>O)&&(Y=O/Math.max(K.width,K.height)),Y<1)if(typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&b instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&b instanceof ImageBitmap||typeof VideoFrame<"u"&&b instanceof VideoFrame){let G=Math.floor(Y*K.width),_e=Math.floor(Y*K.height);u===void 0&&(u=g(G,_e));let re=x?g(G,_e):u;return re.width=G,re.height=_e,re.getContext("2d").drawImage(b,0,0,G,_e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+G+"x"+_e+")."),re}else return"data"in b&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),b;return b}function m(b){return b.generateMipmaps}function f(b){s.generateMipmap(b)}function T(b){return b.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:b.isWebGL3DRenderTarget?s.TEXTURE_3D:b.isWebGLArrayRenderTarget||b.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function A(b,x,O,Y,K=!1){if(b!==null){if(s[b]!==void 0)return s[b];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+b+"'")}let G=x;if(x===s.RED&&(O===s.FLOAT&&(G=s.R32F),O===s.HALF_FLOAT&&(G=s.R16F),O===s.UNSIGNED_BYTE&&(G=s.R8)),x===s.RED_INTEGER&&(O===s.UNSIGNED_BYTE&&(G=s.R8UI),O===s.UNSIGNED_SHORT&&(G=s.R16UI),O===s.UNSIGNED_INT&&(G=s.R32UI),O===s.BYTE&&(G=s.R8I),O===s.SHORT&&(G=s.R16I),O===s.INT&&(G=s.R32I)),x===s.RG&&(O===s.FLOAT&&(G=s.RG32F),O===s.HALF_FLOAT&&(G=s.RG16F),O===s.UNSIGNED_BYTE&&(G=s.RG8)),x===s.RG_INTEGER&&(O===s.UNSIGNED_BYTE&&(G=s.RG8UI),O===s.UNSIGNED_SHORT&&(G=s.RG16UI),O===s.UNSIGNED_INT&&(G=s.RG32UI),O===s.BYTE&&(G=s.RG8I),O===s.SHORT&&(G=s.RG16I),O===s.INT&&(G=s.RG32I)),x===s.RGB_INTEGER&&(O===s.UNSIGNED_BYTE&&(G=s.RGB8UI),O===s.UNSIGNED_SHORT&&(G=s.RGB16UI),O===s.UNSIGNED_INT&&(G=s.RGB32UI),O===s.BYTE&&(G=s.RGB8I),O===s.SHORT&&(G=s.RGB16I),O===s.INT&&(G=s.RGB32I)),x===s.RGBA_INTEGER&&(O===s.UNSIGNED_BYTE&&(G=s.RGBA8UI),O===s.UNSIGNED_SHORT&&(G=s.RGBA16UI),O===s.UNSIGNED_INT&&(G=s.RGBA32UI),O===s.BYTE&&(G=s.RGBA8I),O===s.SHORT&&(G=s.RGBA16I),O===s.INT&&(G=s.RGBA32I)),x===s.RGB&&O===s.UNSIGNED_INT_5_9_9_9_REV&&(G=s.RGB9_E5),x===s.RGBA){let _e=K?Vr:Fe.getTransfer(Y);O===s.FLOAT&&(G=s.RGBA32F),O===s.HALF_FLOAT&&(G=s.RGBA16F),O===s.UNSIGNED_BYTE&&(G=_e===Je?s.SRGB8_ALPHA8:s.RGBA8),O===s.UNSIGNED_SHORT_4_4_4_4&&(G=s.RGBA4),O===s.UNSIGNED_SHORT_5_5_5_1&&(G=s.RGB5_A1)}return(G===s.R16F||G===s.R32F||G===s.RG16F||G===s.RG32F||G===s.RGBA16F||G===s.RGBA32F)&&e.get("EXT_color_buffer_float"),G}function M(b,x){let O;return b?x===null||x===ri||x===Oi?O=s.DEPTH24_STENCIL8:x===$t?O=s.DEPTH32F_STENCIL8:x===ds&&(O=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ri||x===Oi?O=s.DEPTH_COMPONENT24:x===$t?O=s.DEPTH_COMPONENT32F:x===ds&&(O=s.DEPTH_COMPONENT16),O}function U(b,x){return m(b)===!0||b.isFramebufferTexture&&b.minFilter!==Mt&&b.minFilter!==Et?Math.log2(Math.max(x.width,x.height))+1:b.mipmaps!==void 0&&b.mipmaps.length>0?b.mipmaps.length:b.isCompressedTexture&&Array.isArray(b.image)?x.mipmaps.length:1}function w(b){let x=b.target;x.removeEventListener("dispose",w),N(x),x.isVideoTexture&&h.delete(x)}function E(b){let x=b.target;x.removeEventListener("dispose",E),y(x)}function N(b){let x=n.get(b);if(x.__webglInit===void 0)return;let O=b.source,Y=d.get(O);if(Y){let K=Y[x.__cacheKey];K.usedTimes--,K.usedTimes===0&&S(b),Object.keys(Y).length===0&&d.delete(O)}n.remove(b)}function S(b){let x=n.get(b);s.deleteTexture(x.__webglTexture);let O=b.source,Y=d.get(O);delete Y[x.__cacheKey],o.memory.textures--}function y(b){let x=n.get(b);if(b.depthTexture&&(b.depthTexture.dispose(),n.remove(b.depthTexture)),b.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(x.__webglFramebuffer[Y]))for(let K=0;K<x.__webglFramebuffer[Y].length;K++)s.deleteFramebuffer(x.__webglFramebuffer[Y][K]);else s.deleteFramebuffer(x.__webglFramebuffer[Y]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[Y])}else{if(Array.isArray(x.__webglFramebuffer))for(let Y=0;Y<x.__webglFramebuffer.length;Y++)s.deleteFramebuffer(x.__webglFramebuffer[Y]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let Y=0;Y<x.__webglColorRenderbuffer.length;Y++)x.__webglColorRenderbuffer[Y]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[Y]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}let O=b.textures;for(let Y=0,K=O.length;Y<K;Y++){let G=n.get(O[Y]);G.__webglTexture&&(s.deleteTexture(G.__webglTexture),o.memory.textures--),n.remove(O[Y])}n.remove(b)}let R=0;function q(){R=0}function z(){let b=R;return b>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+b+" texture units while this GPU supports only "+i.maxTextures),R+=1,b}function W(b){let x=[];return x.push(b.wrapS),x.push(b.wrapT),x.push(b.wrapR||0),x.push(b.magFilter),x.push(b.minFilter),x.push(b.anisotropy),x.push(b.internalFormat),x.push(b.format),x.push(b.type),x.push(b.generateMipmaps),x.push(b.premultiplyAlpha),x.push(b.flipY),x.push(b.unpackAlignment),x.push(b.colorSpace),x.join()}function J(b,x){let O=n.get(b);if(b.isVideoTexture&&Me(b),b.isRenderTargetTexture===!1&&b.version>0&&O.__version!==b.version){let Y=b.image;if(Y===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{X(O,b,x);return}}t.bindTexture(s.TEXTURE_2D,O.__webglTexture,s.TEXTURE0+x)}function H(b,x){let O=n.get(b);if(b.version>0&&O.__version!==b.version){X(O,b,x);return}t.bindTexture(s.TEXTURE_2D_ARRAY,O.__webglTexture,s.TEXTURE0+x)}function Q(b,x){let O=n.get(b);if(b.version>0&&O.__version!==b.version){X(O,b,x);return}t.bindTexture(s.TEXTURE_3D,O.__webglTexture,s.TEXTURE0+x)}function V(b,x){let O=n.get(b);if(b.version>0&&O.__version!==b.version){ee(O,b,x);return}t.bindTexture(s.TEXTURE_CUBE_MAP,O.__webglTexture,s.TEXTURE0+x)}let ie={[si]:s.REPEAT,[xn]:s.CLAMP_TO_EDGE,[us]:s.MIRRORED_REPEAT},le={[Mt]:s.NEAREST,[ka]:s.NEAREST_MIPMAP_NEAREST,[Ti]:s.NEAREST_MIPMAP_LINEAR,[Et]:s.LINEAR,[as]:s.LINEAR_MIPMAP_NEAREST,[tn]:s.LINEAR_MIPMAP_LINEAR},ve={[gu]:s.NEVER,[Su]:s.ALWAYS,[_u]:s.LESS,[gh]:s.LEQUAL,[xu]:s.EQUAL,[Mu]:s.GEQUAL,[vu]:s.GREATER,[yu]:s.NOTEQUAL};function Ne(b,x){if(x.type===$t&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Et||x.magFilter===as||x.magFilter===Ti||x.magFilter===tn||x.minFilter===Et||x.minFilter===as||x.minFilter===Ti||x.minFilter===tn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(b,s.TEXTURE_WRAP_S,ie[x.wrapS]),s.texParameteri(b,s.TEXTURE_WRAP_T,ie[x.wrapT]),(b===s.TEXTURE_3D||b===s.TEXTURE_2D_ARRAY)&&s.texParameteri(b,s.TEXTURE_WRAP_R,ie[x.wrapR]),s.texParameteri(b,s.TEXTURE_MAG_FILTER,le[x.magFilter]),s.texParameteri(b,s.TEXTURE_MIN_FILTER,le[x.minFilter]),x.compareFunction&&(s.texParameteri(b,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(b,s.TEXTURE_COMPARE_FUNC,ve[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Mt||x.minFilter!==Ti&&x.minFilter!==tn||x.type===$t&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){let O=e.get("EXT_texture_filter_anisotropic");s.texParameterf(b,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function $e(b,x){let O=!1;b.__webglInit===void 0&&(b.__webglInit=!0,x.addEventListener("dispose",w));let Y=x.source,K=d.get(Y);K===void 0&&(K={},d.set(Y,K));let G=W(x);if(G!==b.__cacheKey){K[G]===void 0&&(K[G]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,O=!0),K[G].usedTimes++;let _e=K[b.__cacheKey];_e!==void 0&&(K[b.__cacheKey].usedTimes--,_e.usedTimes===0&&S(x)),b.__cacheKey=G,b.__webglTexture=K[G].texture}return O}function X(b,x,O){let Y=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(Y=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(Y=s.TEXTURE_3D);let K=$e(b,x),G=x.source;t.bindTexture(Y,b.__webglTexture,s.TEXTURE0+O);let _e=n.get(G);if(G.version!==_e.__version||K===!0){t.activeTexture(s.TEXTURE0+O);let re=Fe.getPrimaries(Fe.workingColorSpace),he=x.colorSpace===Fn?null:Fe.getPrimaries(x.colorSpace),Ge=x.colorSpace===Fn||re===he?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ge);let $=_(x.image,!1,i.maxTextureSize);$=tt(x,$);let ue=r.convert(x.format,x.colorSpace),be=r.convert(x.type),Te=A(x.internalFormat,ue,be,x.colorSpace,x.isVideoTexture);Ne(Y,x);let de,Ve=x.mipmaps,Le=x.isVideoTexture!==!0,Qe=_e.__version===void 0||K===!0,C=G.dataReady,ne=U(x,$);if(x.isDepthTexture)Te=M(x.format===Fi,x.type),Qe&&(Le?t.texStorage2D(s.TEXTURE_2D,1,Te,$.width,$.height):t.texImage2D(s.TEXTURE_2D,0,Te,$.width,$.height,0,ue,be,null));else if(x.isDataTexture)if(Ve.length>0){Le&&Qe&&t.texStorage2D(s.TEXTURE_2D,ne,Te,Ve[0].width,Ve[0].height);for(let k=0,Z=Ve.length;k<Z;k++)de=Ve[k],Le?C&&t.texSubImage2D(s.TEXTURE_2D,k,0,0,de.width,de.height,ue,be,de.data):t.texImage2D(s.TEXTURE_2D,k,Te,de.width,de.height,0,ue,be,de.data);x.generateMipmaps=!1}else Le?(Qe&&t.texStorage2D(s.TEXTURE_2D,ne,Te,$.width,$.height),C&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,$.width,$.height,ue,be,$.data)):t.texImage2D(s.TEXTURE_2D,0,Te,$.width,$.height,0,ue,be,$.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Le&&Qe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ne,Te,Ve[0].width,Ve[0].height,$.depth);for(let k=0,Z=Ve.length;k<Z;k++)if(de=Ve[k],x.format!==Bt)if(ue!==null)if(Le){if(C)if(x.layerUpdates.size>0){let ce=Ol(de.width,de.height,x.format,x.type);for(let oe of x.layerUpdates){let Re=de.data.subarray(oe*ce/de.data.BYTES_PER_ELEMENT,(oe+1)*ce/de.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,k,0,0,oe,de.width,de.height,1,ue,Re)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,k,0,0,0,de.width,de.height,$.depth,ue,de.data)}else t.compressedTexImage3D(s.TEXTURE_2D_ARRAY,k,Te,de.width,de.height,$.depth,0,de.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Le?C&&t.texSubImage3D(s.TEXTURE_2D_ARRAY,k,0,0,0,de.width,de.height,$.depth,ue,be,de.data):t.texImage3D(s.TEXTURE_2D_ARRAY,k,Te,de.width,de.height,$.depth,0,ue,be,de.data)}else{Le&&Qe&&t.texStorage2D(s.TEXTURE_2D,ne,Te,Ve[0].width,Ve[0].height);for(let k=0,Z=Ve.length;k<Z;k++)de=Ve[k],x.format!==Bt?ue!==null?Le?C&&t.compressedTexSubImage2D(s.TEXTURE_2D,k,0,0,de.width,de.height,ue,de.data):t.compressedTexImage2D(s.TEXTURE_2D,k,Te,de.width,de.height,0,de.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Le?C&&t.texSubImage2D(s.TEXTURE_2D,k,0,0,de.width,de.height,ue,be,de.data):t.texImage2D(s.TEXTURE_2D,k,Te,de.width,de.height,0,ue,be,de.data)}else if(x.isDataArrayTexture)if(Le){if(Qe&&t.texStorage3D(s.TEXTURE_2D_ARRAY,ne,Te,$.width,$.height,$.depth),C)if(x.layerUpdates.size>0){let k=Ol($.width,$.height,x.format,x.type);for(let Z of x.layerUpdates){let ce=$.data.subarray(Z*k/$.data.BYTES_PER_ELEMENT,(Z+1)*k/$.data.BYTES_PER_ELEMENT);t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,Z,$.width,$.height,1,ue,be,ce)}x.clearLayerUpdates()}else t.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,$.width,$.height,$.depth,ue,be,$.data)}else t.texImage3D(s.TEXTURE_2D_ARRAY,0,Te,$.width,$.height,$.depth,0,ue,be,$.data);else if(x.isData3DTexture)Le?(Qe&&t.texStorage3D(s.TEXTURE_3D,ne,Te,$.width,$.height,$.depth),C&&t.texSubImage3D(s.TEXTURE_3D,0,0,0,0,$.width,$.height,$.depth,ue,be,$.data)):t.texImage3D(s.TEXTURE_3D,0,Te,$.width,$.height,$.depth,0,ue,be,$.data);else if(x.isFramebufferTexture){if(Qe)if(Le)t.texStorage2D(s.TEXTURE_2D,ne,Te,$.width,$.height);else{let k=$.width,Z=$.height;for(let ce=0;ce<ne;ce++)t.texImage2D(s.TEXTURE_2D,ce,Te,k,Z,0,ue,be,null),k>>=1,Z>>=1}}else if(Ve.length>0){if(Le&&Qe){let k=ye(Ve[0]);t.texStorage2D(s.TEXTURE_2D,ne,Te,k.width,k.height)}for(let k=0,Z=Ve.length;k<Z;k++)de=Ve[k],Le?C&&t.texSubImage2D(s.TEXTURE_2D,k,0,0,ue,be,de):t.texImage2D(s.TEXTURE_2D,k,Te,ue,be,de);x.generateMipmaps=!1}else if(Le){if(Qe){let k=ye($);t.texStorage2D(s.TEXTURE_2D,ne,Te,k.width,k.height)}C&&t.texSubImage2D(s.TEXTURE_2D,0,0,0,ue,be,$)}else t.texImage2D(s.TEXTURE_2D,0,Te,ue,be,$);m(x)&&f(Y),_e.__version=G.version,x.onUpdate&&x.onUpdate(x)}b.__version=x.version}function ee(b,x,O){if(x.image.length!==6)return;let Y=$e(b,x),K=x.source;t.bindTexture(s.TEXTURE_CUBE_MAP,b.__webglTexture,s.TEXTURE0+O);let G=n.get(K);if(K.version!==G.__version||Y===!0){t.activeTexture(s.TEXTURE0+O);let _e=Fe.getPrimaries(Fe.workingColorSpace),re=x.colorSpace===Fn?null:Fe.getPrimaries(x.colorSpace),he=x.colorSpace===Fn||_e===re?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,he);let Ge=x.isCompressedTexture||x.image[0].isCompressedTexture,$=x.image[0]&&x.image[0].isDataTexture,ue=[];for(let Z=0;Z<6;Z++)!Ge&&!$?ue[Z]=_(x.image[Z],!0,i.maxCubemapSize):ue[Z]=$?x.image[Z].image:x.image[Z],ue[Z]=tt(x,ue[Z]);let be=ue[0],Te=r.convert(x.format,x.colorSpace),de=r.convert(x.type),Ve=A(x.internalFormat,Te,de,x.colorSpace),Le=x.isVideoTexture!==!0,Qe=G.__version===void 0||Y===!0,C=K.dataReady,ne=U(x,be);Ne(s.TEXTURE_CUBE_MAP,x);let k;if(Ge){Le&&Qe&&t.texStorage2D(s.TEXTURE_CUBE_MAP,ne,Ve,be.width,be.height);for(let Z=0;Z<6;Z++){k=ue[Z].mipmaps;for(let ce=0;ce<k.length;ce++){let oe=k[ce];x.format!==Bt?Te!==null?Le?C&&t.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce,0,0,oe.width,oe.height,Te,oe.data):t.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce,Ve,oe.width,oe.height,0,oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Le?C&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce,0,0,oe.width,oe.height,Te,de,oe.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce,Ve,oe.width,oe.height,0,Te,de,oe.data)}}}else{if(k=x.mipmaps,Le&&Qe){k.length>0&&ne++;let Z=ye(ue[0]);t.texStorage2D(s.TEXTURE_CUBE_MAP,ne,Ve,Z.width,Z.height)}for(let Z=0;Z<6;Z++)if($){Le?C&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,ue[Z].width,ue[Z].height,Te,de,ue[Z].data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ve,ue[Z].width,ue[Z].height,0,Te,de,ue[Z].data);for(let ce=0;ce<k.length;ce++){let Re=k[ce].image[Z].image;Le?C&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce+1,0,0,Re.width,Re.height,Te,de,Re.data):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce+1,Ve,Re.width,Re.height,0,Te,de,Re.data)}}else{Le?C&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,0,0,Te,de,ue[Z]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0,Ve,Te,de,ue[Z]);for(let ce=0;ce<k.length;ce++){let oe=k[ce];Le?C&&t.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce+1,0,0,Te,de,oe.image[Z]):t.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,ce+1,Ve,Te,de,oe.image[Z])}}}m(x)&&f(s.TEXTURE_CUBE_MAP),G.__version=K.version,x.onUpdate&&x.onUpdate(x)}b.__version=x.version}function ge(b,x,O,Y,K,G){let _e=r.convert(O.format,O.colorSpace),re=r.convert(O.type),he=A(O.internalFormat,_e,re,O.colorSpace),Ge=n.get(x),$=n.get(O);if($.__renderTarget=x,!Ge.__hasExternalTextures){let ue=Math.max(1,x.width>>G),be=Math.max(1,x.height>>G);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?t.texImage3D(K,G,he,ue,be,x.depth,0,_e,re,null):t.texImage2D(K,G,he,ue,be,0,_e,re,null)}t.bindFramebuffer(s.FRAMEBUFFER,b),ke(x)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Y,K,$.__webglTexture,0,ze(x)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,Y,K,$.__webglTexture,G),t.bindFramebuffer(s.FRAMEBUFFER,null)}function se(b,x,O){if(s.bindRenderbuffer(s.RENDERBUFFER,b),x.depthBuffer){let Y=x.depthTexture,K=Y&&Y.isDepthTexture?Y.type:null,G=M(x.stencilBuffer,K),_e=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,re=ze(x);ke(x)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,re,G,x.width,x.height):O?s.renderbufferStorageMultisample(s.RENDERBUFFER,re,G,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,G,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,_e,s.RENDERBUFFER,b)}else{let Y=x.textures;for(let K=0;K<Y.length;K++){let G=Y[K],_e=r.convert(G.format,G.colorSpace),re=r.convert(G.type),he=A(G.internalFormat,_e,re,G.colorSpace),Ge=ze(x);O&&ke(x)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Ge,he,x.width,x.height):ke(x)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Ge,he,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,he,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function Ae(b,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(s.FRAMEBUFFER,b),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let Y=n.get(x.depthTexture);Y.__renderTarget=x,(!Y.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),J(x.depthTexture,0);let K=Y.__webglTexture,G=ze(x);if(x.depthTexture.format===Ii)ke(x)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,K,0,G):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,K,0);else if(x.depthTexture.format===Fi)ke(x)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,K,0,G):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,K,0);else throw new Error("Unknown depthTexture format")}function we(b){let x=n.get(b),O=b.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==b.depthTexture){let Y=b.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),Y){let K=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,Y.removeEventListener("dispose",K)};Y.addEventListener("dispose",K),x.__depthDisposeCallback=K}x.__boundDepthTexture=Y}if(b.depthTexture&&!x.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");Ae(x.__webglFramebuffer,b)}else if(O){x.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[Y]),x.__webglDepthbuffer[Y]===void 0)x.__webglDepthbuffer[Y]=s.createRenderbuffer(),se(x.__webglDepthbuffer[Y],b,!1);else{let K=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,G=x.__webglDepthbuffer[Y];s.bindRenderbuffer(s.RENDERBUFFER,G),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,G)}}else if(t.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),se(x.__webglDepthbuffer,b,!1);else{let Y=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,K=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,K),s.framebufferRenderbuffer(s.FRAMEBUFFER,Y,s.RENDERBUFFER,K)}t.bindFramebuffer(s.FRAMEBUFFER,null)}function Ue(b,x,O){let Y=n.get(b);x!==void 0&&ge(Y.__webglFramebuffer,b,b.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),O!==void 0&&we(b)}function st(b){let x=b.texture,O=n.get(b),Y=n.get(x);b.addEventListener("dispose",E);let K=b.textures,G=b.isWebGLCubeRenderTarget===!0,_e=K.length>1;if(_e||(Y.__webglTexture===void 0&&(Y.__webglTexture=s.createTexture()),Y.__version=x.version,o.memory.textures++),G){O.__webglFramebuffer=[];for(let re=0;re<6;re++)if(x.mipmaps&&x.mipmaps.length>0){O.__webglFramebuffer[re]=[];for(let he=0;he<x.mipmaps.length;he++)O.__webglFramebuffer[re][he]=s.createFramebuffer()}else O.__webglFramebuffer[re]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){O.__webglFramebuffer=[];for(let re=0;re<x.mipmaps.length;re++)O.__webglFramebuffer[re]=s.createFramebuffer()}else O.__webglFramebuffer=s.createFramebuffer();if(_e)for(let re=0,he=K.length;re<he;re++){let Ge=n.get(K[re]);Ge.__webglTexture===void 0&&(Ge.__webglTexture=s.createTexture(),o.memory.textures++)}if(b.samples>0&&ke(b)===!1){O.__webglMultisampledFramebuffer=s.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(s.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let re=0;re<K.length;re++){let he=K[re];O.__webglColorRenderbuffer[re]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,O.__webglColorRenderbuffer[re]);let Ge=r.convert(he.format,he.colorSpace),$=r.convert(he.type),ue=A(he.internalFormat,Ge,$,he.colorSpace,b.isXRRenderTarget===!0),be=ze(b);s.renderbufferStorageMultisample(s.RENDERBUFFER,be,ue,b.width,b.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+re,s.RENDERBUFFER,O.__webglColorRenderbuffer[re])}s.bindRenderbuffer(s.RENDERBUFFER,null),b.depthBuffer&&(O.__webglDepthRenderbuffer=s.createRenderbuffer(),se(O.__webglDepthRenderbuffer,b,!0)),t.bindFramebuffer(s.FRAMEBUFFER,null)}}if(G){t.bindTexture(s.TEXTURE_CUBE_MAP,Y.__webglTexture),Ne(s.TEXTURE_CUBE_MAP,x);for(let re=0;re<6;re++)if(x.mipmaps&&x.mipmaps.length>0)for(let he=0;he<x.mipmaps.length;he++)ge(O.__webglFramebuffer[re][he],b,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+re,he);else ge(O.__webglFramebuffer[re],b,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+re,0);m(x)&&f(s.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(_e){for(let re=0,he=K.length;re<he;re++){let Ge=K[re],$=n.get(Ge);t.bindTexture(s.TEXTURE_2D,$.__webglTexture),Ne(s.TEXTURE_2D,Ge),ge(O.__webglFramebuffer,b,Ge,s.COLOR_ATTACHMENT0+re,s.TEXTURE_2D,0),m(Ge)&&f(s.TEXTURE_2D)}t.unbindTexture()}else{let re=s.TEXTURE_2D;if((b.isWebGL3DRenderTarget||b.isWebGLArrayRenderTarget)&&(re=b.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),t.bindTexture(re,Y.__webglTexture),Ne(re,x),x.mipmaps&&x.mipmaps.length>0)for(let he=0;he<x.mipmaps.length;he++)ge(O.__webglFramebuffer[he],b,x,s.COLOR_ATTACHMENT0,re,he);else ge(O.__webglFramebuffer,b,x,s.COLOR_ATTACHMENT0,re,0);m(x)&&f(re),t.unbindTexture()}b.depthBuffer&&we(b)}function He(b){let x=b.textures;for(let O=0,Y=x.length;O<Y;O++){let K=x[O];if(m(K)){let G=T(b),_e=n.get(K).__webglTexture;t.bindTexture(G,_e),f(G),t.unbindTexture()}}}let at=[],D=[];function Ut(b){if(b.samples>0){if(ke(b)===!1){let x=b.textures,O=b.width,Y=b.height,K=s.COLOR_BUFFER_BIT,G=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,_e=n.get(b),re=x.length>1;if(re)for(let he=0;he<x.length;he++)t.bindFramebuffer(s.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,null),t.bindFramebuffer(s.FRAMEBUFFER,_e.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,null,0);t.bindFramebuffer(s.READ_FRAMEBUFFER,_e.__webglMultisampledFramebuffer),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,_e.__webglFramebuffer);for(let he=0;he<x.length;he++){if(b.resolveDepthBuffer&&(b.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),b.stencilBuffer&&b.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),re){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,_e.__webglColorRenderbuffer[he]);let Ge=n.get(x[he]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Ge,0)}s.blitFramebuffer(0,0,O,Y,0,0,O,Y,K,s.NEAREST),c===!0&&(at.length=0,D.length=0,at.push(s.COLOR_ATTACHMENT0+he),b.depthBuffer&&b.resolveDepthBuffer===!1&&(at.push(G),D.push(G),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,D)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,at))}if(t.bindFramebuffer(s.READ_FRAMEBUFFER,null),t.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),re)for(let he=0;he<x.length;he++){t.bindFramebuffer(s.FRAMEBUFFER,_e.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.RENDERBUFFER,_e.__webglColorRenderbuffer[he]);let Ge=n.get(x[he]).__webglTexture;t.bindFramebuffer(s.FRAMEBUFFER,_e.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+he,s.TEXTURE_2D,Ge,0)}t.bindFramebuffer(s.DRAW_FRAMEBUFFER,_e.__webglMultisampledFramebuffer)}else if(b.depthBuffer&&b.resolveDepthBuffer===!1&&c){let x=b.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function ze(b){return Math.min(i.maxSamples,b.samples)}function ke(b){let x=n.get(b);return b.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function Me(b){let x=o.render.frame;h.get(b)!==x&&(h.set(b,x),b.update())}function tt(b,x){let O=b.colorSpace,Y=b.format,K=b.type;return b.isCompressedTexture===!0||b.isVideoTexture===!0||O!==St&&O!==Fn&&(Fe.getTransfer(O)===Je?(Y!==Bt||K!==Mn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),x}function ye(b){return typeof HTMLImageElement<"u"&&b instanceof HTMLImageElement?(l.width=b.naturalWidth||b.width,l.height=b.naturalHeight||b.height):typeof VideoFrame<"u"&&b instanceof VideoFrame?(l.width=b.displayWidth,l.height=b.displayHeight):(l.width=b.width,l.height=b.height),l}this.allocateTextureUnit=z,this.resetTextureUnits=q,this.setTexture2D=J,this.setTexture2DArray=H,this.setTexture3D=Q,this.setTextureCube=V,this.rebindTextures=Ue,this.setupRenderTarget=st,this.updateRenderTargetMipmap=He,this.updateMultisampleRenderTarget=Ut,this.setupDepthRenderbuffer=we,this.setupFrameBufferTexture=ge,this.useMultisampledRTT=ke}function Ig(s,e){function t(n,i=Fn){let r,o=Fe.getTransfer(i);if(n===Mn)return s.UNSIGNED_BYTE;if(n===Ha)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Ga)return s.UNSIGNED_SHORT_5_5_5_1;if(n===ah)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===rh)return s.BYTE;if(n===oh)return s.SHORT;if(n===ds)return s.UNSIGNED_SHORT;if(n===Va)return s.INT;if(n===ri)return s.UNSIGNED_INT;if(n===$t)return s.FLOAT;if(n===bs)return s.HALF_FLOAT;if(n===ch)return s.ALPHA;if(n===lh)return s.RGB;if(n===Bt)return s.RGBA;if(n===hh)return s.LUMINANCE;if(n===uh)return s.LUMINANCE_ALPHA;if(n===Ii)return s.DEPTH_COMPONENT;if(n===Fi)return s.DEPTH_STENCIL;if(n===Wa)return s.RED;if(n===Xa)return s.RED_INTEGER;if(n===dh)return s.RG;if(n===qa)return s.RG_INTEGER;if(n===Ya)return s.RGBA_INTEGER;if(n===tr||n===nr||n===ir||n===sr)if(o===Je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===tr)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===nr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ir)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===sr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===tr)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===nr)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ir)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===sr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Oo||n===Fo||n===Bo||n===zo)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Oo)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Fo)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Bo)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===zo)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ko||n===Vo||n===Ho)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ko||n===Vo)return o===Je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Ho)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Go||n===Wo||n===Xo||n===qo||n===Yo||n===Zo||n===Ko||n===Jo||n===$o||n===jo||n===Qo||n===ea||n===ta||n===na)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Go)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Wo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Xo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===qo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Yo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Zo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Ko)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Jo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===$o)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===jo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Qo)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ea)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ta)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===na)return o===Je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===rr||n===ia||n===sa)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===rr)return o===Je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ia)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===sa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===fh||n===ra||n===oa||n===aa)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===rr)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ra)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===oa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===aa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Oi?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:t}}var Sa=class extends ht{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},nn=class extends rt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Pg={type:"move"},hs=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new nn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new nn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new L,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new L),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new nn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new L,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new L),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let _ of e.hand.values()){let m=t.getJointPose(_,n),f=this._getHandJoint(l,_);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,g=.005;l.inputState.pinching&&d>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=t.getPose(e.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Pg)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new nn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Lg=`
|
|
3801
|
+
void main() {
|
|
3802
|
+
|
|
3803
|
+
gl_Position = vec4( position, 1.0 );
|
|
3804
|
+
|
|
3805
|
+
}`,Dg=`
|
|
3806
|
+
uniform sampler2DArray depthColor;
|
|
3807
|
+
uniform float depthWidth;
|
|
3808
|
+
uniform float depthHeight;
|
|
3809
|
+
|
|
3810
|
+
void main() {
|
|
3811
|
+
|
|
3812
|
+
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
|
|
3813
|
+
|
|
3814
|
+
if ( coord.x >= 1.0 ) {
|
|
3815
|
+
|
|
3816
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
|
|
3817
|
+
|
|
3818
|
+
} else {
|
|
3819
|
+
|
|
3820
|
+
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
|
|
3821
|
+
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
}`,ba=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let i=new mt,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){let t=e.cameras[0].viewport,n=new an({vertexShader:Lg,fragmentShader:Dg,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new yt(new mr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Aa=class extends Sn{constructor(e,t){super();let n=this,i=null,r=1,o=null,a="local-floor",c=1,l=null,h=null,u=null,d=null,p=null,g=null,_=new ba,m=t.getContextAttributes(),f=null,T=null,A=[],M=[],U=new Be,w=null,E=new ht;E.viewport=new Xe;let N=new ht;N.viewport=new Xe;let S=[E,N],y=new Sa,R=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(X){let ee=A[X];return ee===void 0&&(ee=new hs,A[X]=ee),ee.getTargetRaySpace()},this.getControllerGrip=function(X){let ee=A[X];return ee===void 0&&(ee=new hs,A[X]=ee),ee.getGripSpace()},this.getHand=function(X){let ee=A[X];return ee===void 0&&(ee=new hs,A[X]=ee),ee.getHandSpace()};function z(X){let ee=M.indexOf(X.inputSource);if(ee===-1)return;let ge=A[ee];ge!==void 0&&(ge.update(X.inputSource,X.frame,l||o),ge.dispatchEvent({type:X.type,data:X.inputSource}))}function W(){i.removeEventListener("select",z),i.removeEventListener("selectstart",z),i.removeEventListener("selectend",z),i.removeEventListener("squeeze",z),i.removeEventListener("squeezestart",z),i.removeEventListener("squeezeend",z),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",J);for(let X=0;X<A.length;X++){let ee=M[X];ee!==null&&(M[X]=null,A[X].disconnect(ee))}R=null,q=null,_.reset(),e.setRenderTarget(f),p=null,d=null,u=null,i=null,T=null,$e.stop(),n.isPresenting=!1,e.setPixelRatio(w),e.setSize(U.width,U.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(X){r=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(X){a=X,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(X){l=X},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(X){if(i=X,i!==null){if(f=e.getRenderTarget(),i.addEventListener("select",z),i.addEventListener("selectstart",z),i.addEventListener("selectend",z),i.addEventListener("squeeze",z),i.addEventListener("squeezestart",z),i.addEventListener("squeezeend",z),i.addEventListener("end",W),i.addEventListener("inputsourceschange",J),m.xrCompatible!==!0&&await t.makeXRCompatible(),w=e.getPixelRatio(),e.getSize(U),i.renderState.layers===void 0){let ee={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,t,ee),i.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),T=new bn(p.framebufferWidth,p.framebufferHeight,{format:Bt,type:Mn,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let ee=null,ge=null,se=null;m.depth&&(se=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ee=m.stencil?Fi:Ii,ge=m.stencil?Oi:ri);let Ae={colorFormat:t.RGBA8,depthFormat:se,scaleFactor:r};u=new XRWebGLBinding(i,t),d=u.createProjectionLayer(Ae),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new bn(d.textureWidth,d.textureHeight,{format:Bt,type:Mn,depthTexture:new _r(d.textureWidth,d.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,ee),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),$e.setContext(i),$e.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function J(X){for(let ee=0;ee<X.removed.length;ee++){let ge=X.removed[ee],se=M.indexOf(ge);se>=0&&(M[se]=null,A[se].disconnect(ge))}for(let ee=0;ee<X.added.length;ee++){let ge=X.added[ee],se=M.indexOf(ge);if(se===-1){for(let we=0;we<A.length;we++)if(we>=M.length){M.push(ge),se=we;break}else if(M[we]===null){M[we]=ge,se=we;break}if(se===-1)break}let Ae=A[se];Ae&&Ae.connect(ge)}}let H=new L,Q=new L;function V(X,ee,ge){H.setFromMatrixPosition(ee.matrixWorld),Q.setFromMatrixPosition(ge.matrixWorld);let se=H.distanceTo(Q),Ae=ee.projectionMatrix.elements,we=ge.projectionMatrix.elements,Ue=Ae[14]/(Ae[10]-1),st=Ae[14]/(Ae[10]+1),He=(Ae[9]+1)/Ae[5],at=(Ae[9]-1)/Ae[5],D=(Ae[8]-1)/Ae[0],Ut=(we[8]+1)/we[0],ze=Ue*D,ke=Ue*Ut,Me=se/(-D+Ut),tt=Me*-D;if(ee.matrixWorld.decompose(X.position,X.quaternion,X.scale),X.translateX(tt),X.translateZ(Me),X.matrixWorld.compose(X.position,X.quaternion,X.scale),X.matrixWorldInverse.copy(X.matrixWorld).invert(),Ae[10]===-1)X.projectionMatrix.copy(ee.projectionMatrix),X.projectionMatrixInverse.copy(ee.projectionMatrixInverse);else{let ye=Ue+Me,b=st+Me,x=ze-tt,O=ke+(se-tt),Y=He*st/b*ye,K=at*st/b*ye;X.projectionMatrix.makePerspective(x,O,Y,K,ye,b),X.projectionMatrixInverse.copy(X.projectionMatrix).invert()}}function ie(X,ee){ee===null?X.matrixWorld.copy(X.matrix):X.matrixWorld.multiplyMatrices(ee.matrixWorld,X.matrix),X.matrixWorldInverse.copy(X.matrixWorld).invert()}this.updateCamera=function(X){if(i===null)return;let ee=X.near,ge=X.far;_.texture!==null&&(_.depthNear>0&&(ee=_.depthNear),_.depthFar>0&&(ge=_.depthFar)),y.near=N.near=E.near=ee,y.far=N.far=E.far=ge,(R!==y.near||q!==y.far)&&(i.updateRenderState({depthNear:y.near,depthFar:y.far}),R=y.near,q=y.far),E.layers.mask=X.layers.mask|2,N.layers.mask=X.layers.mask|4,y.layers.mask=E.layers.mask|N.layers.mask;let se=X.parent,Ae=y.cameras;ie(y,se);for(let we=0;we<Ae.length;we++)ie(Ae[we],se);Ae.length===2?V(y,E,N):y.projectionMatrix.copy(E.projectionMatrix),le(X,y,se)};function le(X,ee,ge){ge===null?X.matrix.copy(ee.matrixWorld):(X.matrix.copy(ge.matrixWorld),X.matrix.invert(),X.matrix.multiply(ee.matrixWorld)),X.matrix.decompose(X.position,X.quaternion,X.scale),X.updateMatrixWorld(!0),X.projectionMatrix.copy(ee.projectionMatrix),X.projectionMatrixInverse.copy(ee.projectionMatrixInverse),X.isPerspectiveCamera&&(X.fov=ki*2*Math.atan(1/X.projectionMatrix.elements[5]),X.zoom=1)}this.getCamera=function(){return y},this.getFoveation=function(){if(!(d===null&&p===null))return c},this.setFoveation=function(X){c=X,d!==null&&(d.fixedFoveation=X),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=X)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(y)};let ve=null;function Ne(X,ee){if(h=ee.getViewerPose(l||o),g=ee,h!==null){let ge=h.views;p!==null&&(e.setRenderTargetFramebuffer(T,p.framebuffer),e.setRenderTarget(T));let se=!1;ge.length!==y.cameras.length&&(y.cameras.length=0,se=!0);for(let we=0;we<ge.length;we++){let Ue=ge[we],st=null;if(p!==null)st=p.getViewport(Ue);else{let at=u.getViewSubImage(d,Ue);st=at.viewport,we===0&&(e.setRenderTargetTextures(T,at.colorTexture,d.ignoreDepthValues?void 0:at.depthStencilTexture),e.setRenderTarget(T))}let He=S[we];He===void 0&&(He=new ht,He.layers.enable(we),He.viewport=new Xe,S[we]=He),He.matrix.fromArray(Ue.transform.matrix),He.matrix.decompose(He.position,He.quaternion,He.scale),He.projectionMatrix.fromArray(Ue.projectionMatrix),He.projectionMatrixInverse.copy(He.projectionMatrix).invert(),He.viewport.set(st.x,st.y,st.width,st.height),we===0&&(y.matrix.copy(He.matrix),y.matrix.decompose(y.position,y.quaternion,y.scale)),se===!0&&y.cameras.push(He)}let Ae=i.enabledFeatures;if(Ae&&Ae.includes("depth-sensing")){let we=u.getDepthInformation(ge[0]);we&&we.isValid&&we.texture&&_.init(e,we,i.renderState)}}for(let ge=0;ge<A.length;ge++){let se=M[ge],Ae=A[ge];se!==null&&Ae!==void 0&&Ae.update(se,ee,l||o)}ve&&ve(X,ee),ee.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:ee}),g=null}let $e=new Mh;$e.setAnimationLoop(Ne),this.setAnimationLoop=function(X){ve=X},this.dispose=function(){}}},Qn=new rn,Ng=new Pe;function Ug(s,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,yh(s)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function i(m,f,T,A,M){f.isMeshBasicMaterial||f.isMeshLambertMaterial?r(m,f):f.isMeshToonMaterial?(r(m,f),u(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f)):f.isMeshStandardMaterial?(r(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,M)):f.isMeshMatcapMaterial?(r(m,f),g(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),_(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(o(m,f),f.isLineDashedMaterial&&a(m,f)):f.isPointsMaterial?c(m,f,T,A):f.isSpriteMaterial?l(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===wt&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===wt&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);let T=e.get(f),A=T.envMap,M=T.envMapRotation;A&&(m.envMap.value=A,Qn.copy(M),Qn.x*=-1,Qn.y*=-1,Qn.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(Qn.y*=-1,Qn.z*=-1),m.envMapRotation.value.setFromMatrix4(Ng.makeRotationFromEuler(Qn)),m.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function o(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function a(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function c(m,f,T,A){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*T,m.scale.value=A*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function l(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,T){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===wt&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function _(m,f){let T=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Og(s,e,t,n){let i={},r={},o=[],a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(T,A){let M=A.program;n.uniformBlockBinding(T,M)}function l(T,A){let M=i[T.id];M===void 0&&(g(T),M=h(T),i[T.id]=M,T.addEventListener("dispose",m));let U=A.program;n.updateUBOMapping(T,U);let w=e.render.frame;r[T.id]!==w&&(d(T),r[T.id]=w)}function h(T){let A=u();T.__bindingPointIndex=A;let M=s.createBuffer(),U=T.__size,w=T.usage;return s.bindBuffer(s.UNIFORM_BUFFER,M),s.bufferData(s.UNIFORM_BUFFER,U,w),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,A,M),M}function u(){for(let T=0;T<a;T++)if(o.indexOf(T)===-1)return o.push(T),T;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(T){let A=i[T.id],M=T.uniforms,U=T.__cache;s.bindBuffer(s.UNIFORM_BUFFER,A);for(let w=0,E=M.length;w<E;w++){let N=Array.isArray(M[w])?M[w]:[M[w]];for(let S=0,y=N.length;S<y;S++){let R=N[S];if(p(R,w,S,U)===!0){let q=R.__offset,z=Array.isArray(R.value)?R.value:[R.value],W=0;for(let J=0;J<z.length;J++){let H=z[J],Q=_(H);typeof H=="number"||typeof H=="boolean"?(R.__data[0]=H,s.bufferSubData(s.UNIFORM_BUFFER,q+W,R.__data)):H.isMatrix3?(R.__data[0]=H.elements[0],R.__data[1]=H.elements[1],R.__data[2]=H.elements[2],R.__data[3]=0,R.__data[4]=H.elements[3],R.__data[5]=H.elements[4],R.__data[6]=H.elements[5],R.__data[7]=0,R.__data[8]=H.elements[6],R.__data[9]=H.elements[7],R.__data[10]=H.elements[8],R.__data[11]=0):(H.toArray(R.__data,W),W+=Q.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,q,R.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(T,A,M,U){let w=T.value,E=A+"_"+M;if(U[E]===void 0)return typeof w=="number"||typeof w=="boolean"?U[E]=w:U[E]=w.clone(),!0;{let N=U[E];if(typeof w=="number"||typeof w=="boolean"){if(N!==w)return U[E]=w,!0}else if(N.equals(w)===!1)return N.copy(w),!0}return!1}function g(T){let A=T.uniforms,M=0,U=16;for(let E=0,N=A.length;E<N;E++){let S=Array.isArray(A[E])?A[E]:[A[E]];for(let y=0,R=S.length;y<R;y++){let q=S[y],z=Array.isArray(q.value)?q.value:[q.value];for(let W=0,J=z.length;W<J;W++){let H=z[W],Q=_(H),V=M%U,ie=V%Q.boundary,le=V+ie;M+=ie,le!==0&&U-le<Q.storage&&(M+=U-le),q.__data=new Float32Array(Q.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=M,M+=Q.storage}}}let w=M%U;return w>0&&(M+=U-w),T.__size=M,T.__cache={},this}function _(T){let A={boundary:0,storage:0};return typeof T=="number"||typeof T=="boolean"?(A.boundary=4,A.storage=4):T.isVector2?(A.boundary=8,A.storage=8):T.isVector3||T.isColor?(A.boundary=16,A.storage=12):T.isVector4?(A.boundary=16,A.storage=16):T.isMatrix3?(A.boundary=48,A.storage=48):T.isMatrix4?(A.boundary=64,A.storage=64):T.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",T),A}function m(T){let A=T.target;A.removeEventListener("dispose",m);let M=o.indexOf(A.__bindingPointIndex);o.splice(M,1),s.deleteBuffer(i[A.id]),delete i[A.id],delete r[A.id]}function f(){for(let T in i)s.deleteBuffer(i[T]);o=[],i={},r={}}return{bind:c,update:l,dispose:f}}var xr=class{constructor(e={}){let{canvas:t=zu(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!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;let g=new Uint32Array(4),_=new Int32Array(4),m=null,f=null,T=[],A=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=lt,this.toneMapping=kn,this.toneMappingExposure=1;let M=this,U=!1,w=0,E=0,N=null,S=-1,y=null,R=new Xe,q=new Xe,z=null,W=new Se(0),J=0,H=t.width,Q=t.height,V=1,ie=null,le=null,ve=new Xe(0,0,H,Q),Ne=new Xe(0,0,H,Q),$e=!1,X=new ms,ee=!1,ge=!1,se=new Pe,Ae=new Pe,we=new L,Ue=new Xe,st={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},He=!1;function at(){return N===null?V:1}let D=n;function Ut(v,I){return t.getContext(v,I)}try{let v={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ba}`),t.addEventListener("webglcontextlost",Z,!1),t.addEventListener("webglcontextrestored",ce,!1),t.addEventListener("webglcontextcreationerror",oe,!1),D===null){let I="webgl2";if(D=Ut(I,v),D===null)throw Ut(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(v){throw console.error("THREE.WebGLRenderer: "+v.message),v}let ze,ke,Me,tt,ye,b,x,O,Y,K,G,_e,re,he,Ge,$,ue,be,Te,de,Ve,Le,Qe,C;function ne(){ze=new jp(D),ze.init(),Le=new Ig(D,ze),ke=new qp(D,ze,e,Le),Me=new wg(D,ze),ke.reverseDepthBuffer&&d&&Me.buffers.depth.setReversed(!0),tt=new tm(D),ye=new pg,b=new Cg(D,ze,Me,ye,ke,Le,tt),x=new Zp(M),O=new $p(M),Y=new ad(D),Qe=new Wp(D,Y),K=new Qp(D,Y,tt,Qe),G=new im(D,K,Y,tt),Te=new nm(D,ke,b),$=new Yp(ye),_e=new fg(M,x,O,ze,ke,Qe,$),re=new Ug(M,ye),he=new gg,Ge=new Sg(ze),be=new Gp(M,x,O,Me,G,p,c),ue=new Tg(M,G,ke),C=new Og(D,tt,ke,Me),de=new Xp(D,ze,tt),Ve=new em(D,ze,tt),tt.programs=_e.programs,M.capabilities=ke,M.extensions=ze,M.properties=ye,M.renderLists=he,M.shadowMap=ue,M.state=Me,M.info=tt}ne();let k=new Aa(M,D);this.xr=k,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){let v=ze.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){let v=ze.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(v){v!==void 0&&(V=v,this.setSize(H,Q,!1))},this.getSize=function(v){return v.set(H,Q)},this.setSize=function(v,I,F=!0){if(k.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=v,Q=I,t.width=Math.floor(v*V),t.height=Math.floor(I*V),F===!0&&(t.style.width=v+"px",t.style.height=I+"px"),this.setViewport(0,0,v,I)},this.getDrawingBufferSize=function(v){return v.set(H*V,Q*V).floor()},this.setDrawingBufferSize=function(v,I,F){H=v,Q=I,V=F,t.width=Math.floor(v*F),t.height=Math.floor(I*F),this.setViewport(0,0,v,I)},this.getCurrentViewport=function(v){return v.copy(R)},this.getViewport=function(v){return v.copy(ve)},this.setViewport=function(v,I,F,B){v.isVector4?ve.set(v.x,v.y,v.z,v.w):ve.set(v,I,F,B),Me.viewport(R.copy(ve).multiplyScalar(V).round())},this.getScissor=function(v){return v.copy(Ne)},this.setScissor=function(v,I,F,B){v.isVector4?Ne.set(v.x,v.y,v.z,v.w):Ne.set(v,I,F,B),Me.scissor(q.copy(Ne).multiplyScalar(V).round())},this.getScissorTest=function(){return $e},this.setScissorTest=function(v){Me.setScissorTest($e=v)},this.setOpaqueSort=function(v){ie=v},this.setTransparentSort=function(v){le=v},this.getClearColor=function(v){return v.copy(be.getClearColor())},this.setClearColor=function(){be.setClearColor.apply(be,arguments)},this.getClearAlpha=function(){return be.getClearAlpha()},this.setClearAlpha=function(){be.setClearAlpha.apply(be,arguments)},this.clear=function(v=!0,I=!0,F=!0){let B=0;if(v){let P=!1;if(N!==null){let j=N.texture.format;P=j===Ya||j===qa||j===Xa}if(P){let j=N.texture.type,ae=j===Mn||j===ri||j===ds||j===Oi||j===Ha||j===Ga,fe=be.getClearColor(),pe=be.getClearAlpha(),Ee=fe.r,Ce=fe.g,me=fe.b;ae?(g[0]=Ee,g[1]=Ce,g[2]=me,g[3]=pe,D.clearBufferuiv(D.COLOR,0,g)):(_[0]=Ee,_[1]=Ce,_[2]=me,_[3]=pe,D.clearBufferiv(D.COLOR,0,_))}else B|=D.COLOR_BUFFER_BIT}I&&(B|=D.DEPTH_BUFFER_BIT),F&&(B|=D.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),D.clear(B)},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",Z,!1),t.removeEventListener("webglcontextrestored",ce,!1),t.removeEventListener("webglcontextcreationerror",oe,!1),he.dispose(),Ge.dispose(),ye.dispose(),x.dispose(),O.dispose(),G.dispose(),Qe.dispose(),C.dispose(),_e.dispose(),k.dispose(),k.removeEventListener("sessionstart",Pc),k.removeEventListener("sessionend",Lc),Yn.stop()};function Z(v){v.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),U=!0}function ce(){console.log("THREE.WebGLRenderer: Context Restored."),U=!1;let v=tt.autoReset,I=ue.enabled,F=ue.autoUpdate,B=ue.needsUpdate,P=ue.type;ne(),tt.autoReset=v,ue.enabled=I,ue.autoUpdate=F,ue.needsUpdate=B,ue.type=P}function oe(v){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function Re(v){let I=v.target;I.removeEventListener("dispose",Re),ot(I)}function ot(v){gt(v),ye.remove(v)}function gt(v){let I=ye.get(v).programs;I!==void 0&&(I.forEach(function(F){_e.releaseProgram(F)}),v.isShaderMaterial&&_e.releaseShaderCache(v))}this.renderBufferDirect=function(v,I,F,B,P,j){I===null&&(I=st);let ae=P.isMesh&&P.matrixWorld.determinant()<0,fe=Lh(v,I,F,B,P);Me.setMaterial(B,ae);let pe=F.index,Ee=1;if(B.wireframe===!0){if(pe=K.getWireframeAttribute(F),pe===void 0)return;Ee=2}let Ce=F.drawRange,me=F.attributes.position,We=Ce.start*Ee,et=(Ce.start+Ce.count)*Ee;j!==null&&(We=Math.max(We,j.start*Ee),et=Math.min(et,(j.start+j.count)*Ee)),pe!==null?(We=Math.max(We,0),et=Math.min(et,pe.count)):me!=null&&(We=Math.max(We,0),et=Math.min(et,me.count));let nt=et-We;if(nt<0||nt===1/0)return;Qe.setup(P,B,fe,F,pe);let Tt,qe=de;if(pe!==null&&(Tt=Y.get(pe),qe=Ve,qe.setIndex(Tt)),P.isMesh)B.wireframe===!0?(Me.setLineWidth(B.wireframeLinewidth*at()),qe.setMode(D.LINES)):qe.setMode(D.TRIANGLES);else if(P.isLine){let xe=B.linewidth;xe===void 0&&(xe=1),Me.setLineWidth(xe*at()),P.isLineSegments?qe.setMode(D.LINES):P.isLineLoop?qe.setMode(D.LINE_LOOP):qe.setMode(D.LINE_STRIP)}else P.isPoints?qe.setMode(D.POINTS):P.isSprite&&qe.setMode(D.TRIANGLES);if(P.isBatchedMesh)if(P._multiDrawInstances!==null)qe.renderMultiDrawInstances(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount,P._multiDrawInstances);else if(ze.get("WEBGL_multi_draw"))qe.renderMultiDraw(P._multiDrawStarts,P._multiDrawCounts,P._multiDrawCount);else{let xe=P._multiDrawStarts,ln=P._multiDrawCounts,Ye=P._multiDrawCount,Xt=pe?Y.get(pe).bytesPerElement:1,li=ye.get(B).currentProgram.getUniforms();for(let Ct=0;Ct<Ye;Ct++)li.setValue(D,"_gl_DrawID",Ct),qe.render(xe[Ct]/Xt,ln[Ct])}else if(P.isInstancedMesh)qe.renderInstances(We,nt,P.count);else if(F.isInstancedBufferGeometry){let xe=F._maxInstanceCount!==void 0?F._maxInstanceCount:1/0,ln=Math.min(F.instanceCount,xe);qe.renderInstances(We,nt,ln)}else qe.render(We,nt)};function Ze(v,I,F){v.transparent===!0&&v.side===Kt&&v.forceSinglePass===!1?(v.side=wt,v.needsUpdate=!0,ws(v,I,F),v.side=sn,v.needsUpdate=!0,ws(v,I,F),v.side=Kt):ws(v,I,F)}this.compile=function(v,I,F=null){F===null&&(F=v),f=Ge.get(F),f.init(I),A.push(f),F.traverseVisible(function(P){P.isLight&&P.layers.test(I.layers)&&(f.pushLight(P),P.castShadow&&f.pushShadow(P))}),v!==F&&v.traverseVisible(function(P){P.isLight&&P.layers.test(I.layers)&&(f.pushLight(P),P.castShadow&&f.pushShadow(P))}),f.setupLights();let B=new Set;return v.traverse(function(P){if(!(P.isMesh||P.isPoints||P.isLine||P.isSprite))return;let j=P.material;if(j)if(Array.isArray(j))for(let ae=0;ae<j.length;ae++){let fe=j[ae];Ze(fe,F,P),B.add(fe)}else Ze(j,F,P),B.add(j)}),A.pop(),f=null,B},this.compileAsync=function(v,I,F=null){let B=this.compile(v,I,F);return new Promise(P=>{function j(){if(B.forEach(function(ae){ye.get(ae).currentProgram.isReady()&&B.delete(ae)}),B.size===0){P(v);return}setTimeout(j,10)}ze.get("KHR_parallel_shader_compile")!==null?j():setTimeout(j,10)})};let Wt=null;function cn(v){Wt&&Wt(v)}function Pc(){Yn.stop()}function Lc(){Yn.start()}let Yn=new Mh;Yn.setAnimationLoop(cn),typeof self<"u"&&Yn.setContext(self),this.setAnimationLoop=function(v){Wt=v,k.setAnimationLoop(v),v===null?Yn.stop():Yn.start()},k.addEventListener("sessionstart",Pc),k.addEventListener("sessionend",Lc),this.render=function(v,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),k.enabled===!0&&k.isPresenting===!0&&(k.cameraAutoUpdate===!0&&k.updateCamera(I),I=k.getCamera()),v.isScene===!0&&v.onBeforeRender(M,v,I,N),f=Ge.get(v,A.length),f.init(I),A.push(f),Ae.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),X.setFromProjectionMatrix(Ae),ge=this.localClippingEnabled,ee=$.init(this.clippingPlanes,ge),m=he.get(v,T.length),m.init(),T.push(m),k.enabled===!0&&k.isPresenting===!0){let j=M.xr.getDepthSensingMesh();j!==null&&Xr(j,I,-1/0,M.sortObjects)}Xr(v,I,0,M.sortObjects),m.finish(),M.sortObjects===!0&&m.sort(ie,le),He=k.enabled===!1||k.isPresenting===!1||k.hasDepthSensing()===!1,He&&be.addToRenderList(m,v),this.info.render.frame++,ee===!0&&$.beginShadows();let F=f.state.shadowsArray;ue.render(F,v,I),ee===!0&&$.endShadows(),this.info.autoReset===!0&&this.info.reset();let B=m.opaque,P=m.transmissive;if(f.setupLights(),I.isArrayCamera){let j=I.cameras;if(P.length>0)for(let ae=0,fe=j.length;ae<fe;ae++){let pe=j[ae];Nc(B,P,v,pe)}He&&be.render(v);for(let ae=0,fe=j.length;ae<fe;ae++){let pe=j[ae];Dc(m,v,pe,pe.viewport)}}else P.length>0&&Nc(B,P,v,I),He&&be.render(v),Dc(m,v,I);N!==null&&(b.updateMultisampleRenderTarget(N),b.updateRenderTargetMipmap(N)),v.isScene===!0&&v.onAfterRender(M,v,I),Qe.resetDefaultState(),S=-1,y=null,A.pop(),A.length>0?(f=A[A.length-1],ee===!0&&$.setGlobalState(M.clippingPlanes,f.state.camera)):f=null,T.pop(),T.length>0?m=T[T.length-1]:m=null};function Xr(v,I,F,B){if(v.visible===!1)return;if(v.layers.test(I.layers)){if(v.isGroup)F=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(I);else if(v.isLight)f.pushLight(v),v.castShadow&&f.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||X.intersectsSprite(v)){B&&Ue.setFromMatrixPosition(v.matrixWorld).applyMatrix4(Ae);let ae=G.update(v),fe=v.material;fe.visible&&m.push(v,ae,fe,F,Ue.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||X.intersectsObject(v))){let ae=G.update(v),fe=v.material;if(B&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),Ue.copy(v.boundingSphere.center)):(ae.boundingSphere===null&&ae.computeBoundingSphere(),Ue.copy(ae.boundingSphere.center)),Ue.applyMatrix4(v.matrixWorld).applyMatrix4(Ae)),Array.isArray(fe)){let pe=ae.groups;for(let Ee=0,Ce=pe.length;Ee<Ce;Ee++){let me=pe[Ee],We=fe[me.materialIndex];We&&We.visible&&m.push(v,ae,We,F,Ue.z,me)}}else fe.visible&&m.push(v,ae,fe,F,Ue.z,null)}}let j=v.children;for(let ae=0,fe=j.length;ae<fe;ae++)Xr(j[ae],I,F,B)}function Dc(v,I,F,B){let P=v.opaque,j=v.transmissive,ae=v.transparent;f.setupLightsView(F),ee===!0&&$.setGlobalState(M.clippingPlanes,F),B&&Me.viewport(R.copy(B)),P.length>0&&Es(P,I,F),j.length>0&&Es(j,I,F),ae.length>0&&Es(ae,I,F),Me.buffers.depth.setTest(!0),Me.buffers.depth.setMask(!0),Me.buffers.color.setMask(!0),Me.setPolygonOffset(!1)}function Nc(v,I,F,B){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;f.state.transmissionRenderTarget[B.id]===void 0&&(f.state.transmissionRenderTarget[B.id]=new bn(1,1,{generateMipmaps:!0,type:ze.has("EXT_color_buffer_half_float")||ze.has("EXT_color_buffer_float")?bs:Mn,minFilter:tn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Fe.workingColorSpace}));let j=f.state.transmissionRenderTarget[B.id],ae=B.viewport||R;j.setSize(ae.z,ae.w);let fe=M.getRenderTarget();M.setRenderTarget(j),M.getClearColor(W),J=M.getClearAlpha(),J<1&&M.setClearColor(16777215,.5),M.clear(),He&&be.render(F);let pe=M.toneMapping;M.toneMapping=kn;let Ee=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),f.setupLightsView(B),ee===!0&&$.setGlobalState(M.clippingPlanes,B),Es(v,F,B),b.updateMultisampleRenderTarget(j),b.updateRenderTargetMipmap(j),ze.has("WEBGL_multisampled_render_to_texture")===!1){let Ce=!1;for(let me=0,We=I.length;me<We;me++){let et=I[me],nt=et.object,Tt=et.geometry,qe=et.material,xe=et.group;if(qe.side===Kt&&nt.layers.test(B.layers)){let ln=qe.side;qe.side=wt,qe.needsUpdate=!0,Uc(nt,F,B,Tt,qe,xe),qe.side=ln,qe.needsUpdate=!0,Ce=!0}}Ce===!0&&(b.updateMultisampleRenderTarget(j),b.updateRenderTargetMipmap(j))}M.setRenderTarget(fe),M.setClearColor(W,J),Ee!==void 0&&(B.viewport=Ee),M.toneMapping=pe}function Es(v,I,F){let B=I.isScene===!0?I.overrideMaterial:null;for(let P=0,j=v.length;P<j;P++){let ae=v[P],fe=ae.object,pe=ae.geometry,Ee=B===null?ae.material:B,Ce=ae.group;fe.layers.test(F.layers)&&Uc(fe,I,F,pe,Ee,Ce)}}function Uc(v,I,F,B,P,j){v.onBeforeRender(M,I,F,B,P,j),v.modelViewMatrix.multiplyMatrices(F.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),P.onBeforeRender(M,I,F,B,v,j),P.transparent===!0&&P.side===Kt&&P.forceSinglePass===!1?(P.side=wt,P.needsUpdate=!0,M.renderBufferDirect(F,I,B,P,v,j),P.side=sn,P.needsUpdate=!0,M.renderBufferDirect(F,I,B,P,v,j),P.side=Kt):M.renderBufferDirect(F,I,B,P,v,j),v.onAfterRender(M,I,F,B,P,j)}function ws(v,I,F){I.isScene!==!0&&(I=st);let B=ye.get(v),P=f.state.lights,j=f.state.shadowsArray,ae=P.state.version,fe=_e.getParameters(v,P.state,j,I,F),pe=_e.getProgramCacheKey(fe),Ee=B.programs;B.environment=v.isMeshStandardMaterial?I.environment:null,B.fog=I.fog,B.envMap=(v.isMeshStandardMaterial?O:x).get(v.envMap||B.environment),B.envMapRotation=B.environment!==null&&v.envMap===null?I.environmentRotation:v.envMapRotation,Ee===void 0&&(v.addEventListener("dispose",Re),Ee=new Map,B.programs=Ee);let Ce=Ee.get(pe);if(Ce!==void 0){if(B.currentProgram===Ce&&B.lightsStateVersion===ae)return Fc(v,fe),Ce}else fe.uniforms=_e.getUniforms(v),v.onBeforeCompile(fe,M),Ce=_e.acquireProgram(fe,pe),Ee.set(pe,Ce),B.uniforms=fe.uniforms;let me=B.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(me.clippingPlanes=$.uniform),Fc(v,fe),B.needsLights=Nh(v),B.lightsStateVersion=ae,B.needsLights&&(me.ambientLightColor.value=P.state.ambient,me.lightProbe.value=P.state.probe,me.directionalLights.value=P.state.directional,me.directionalLightShadows.value=P.state.directionalShadow,me.spotLights.value=P.state.spot,me.spotLightShadows.value=P.state.spotShadow,me.rectAreaLights.value=P.state.rectArea,me.ltc_1.value=P.state.rectAreaLTC1,me.ltc_2.value=P.state.rectAreaLTC2,me.pointLights.value=P.state.point,me.pointLightShadows.value=P.state.pointShadow,me.hemisphereLights.value=P.state.hemi,me.directionalShadowMap.value=P.state.directionalShadowMap,me.directionalShadowMatrix.value=P.state.directionalShadowMatrix,me.spotShadowMap.value=P.state.spotShadowMap,me.spotLightMatrix.value=P.state.spotLightMatrix,me.spotLightMap.value=P.state.spotLightMap,me.pointShadowMap.value=P.state.pointShadowMap,me.pointShadowMatrix.value=P.state.pointShadowMatrix),B.currentProgram=Ce,B.uniformsList=null,Ce}function Oc(v){if(v.uniformsList===null){let I=v.currentProgram.getUniforms();v.uniformsList=Li.seqWithValue(I.seq,v.uniforms)}return v.uniformsList}function Fc(v,I){let F=ye.get(v);F.outputColorSpace=I.outputColorSpace,F.batching=I.batching,F.batchingColor=I.batchingColor,F.instancing=I.instancing,F.instancingColor=I.instancingColor,F.instancingMorph=I.instancingMorph,F.skinning=I.skinning,F.morphTargets=I.morphTargets,F.morphNormals=I.morphNormals,F.morphColors=I.morphColors,F.morphTargetsCount=I.morphTargetsCount,F.numClippingPlanes=I.numClippingPlanes,F.numIntersection=I.numClipIntersection,F.vertexAlphas=I.vertexAlphas,F.vertexTangents=I.vertexTangents,F.toneMapping=I.toneMapping}function Lh(v,I,F,B,P){I.isScene!==!0&&(I=st),b.resetTextureUnits();let j=I.fog,ae=B.isMeshStandardMaterial?I.environment:null,fe=N===null?M.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:St,pe=(B.isMeshStandardMaterial?O:x).get(B.envMap||ae),Ee=B.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,Ce=!!F.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),me=!!F.morphAttributes.position,We=!!F.morphAttributes.normal,et=!!F.morphAttributes.color,nt=kn;B.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(nt=M.toneMapping);let Tt=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,qe=Tt!==void 0?Tt.length:0,xe=ye.get(B),ln=f.state.lights;if(ee===!0&&(ge===!0||v!==y)){let Ot=v===y&&B.id===S;$.setState(B,v,Ot)}let Ye=!1;B.version===xe.__version?(xe.needsLights&&xe.lightsStateVersion!==ln.state.version||xe.outputColorSpace!==fe||P.isBatchedMesh&&xe.batching===!1||!P.isBatchedMesh&&xe.batching===!0||P.isBatchedMesh&&xe.batchingColor===!0&&P.colorTexture===null||P.isBatchedMesh&&xe.batchingColor===!1&&P.colorTexture!==null||P.isInstancedMesh&&xe.instancing===!1||!P.isInstancedMesh&&xe.instancing===!0||P.isSkinnedMesh&&xe.skinning===!1||!P.isSkinnedMesh&&xe.skinning===!0||P.isInstancedMesh&&xe.instancingColor===!0&&P.instanceColor===null||P.isInstancedMesh&&xe.instancingColor===!1&&P.instanceColor!==null||P.isInstancedMesh&&xe.instancingMorph===!0&&P.morphTexture===null||P.isInstancedMesh&&xe.instancingMorph===!1&&P.morphTexture!==null||xe.envMap!==pe||B.fog===!0&&xe.fog!==j||xe.numClippingPlanes!==void 0&&(xe.numClippingPlanes!==$.numPlanes||xe.numIntersection!==$.numIntersection)||xe.vertexAlphas!==Ee||xe.vertexTangents!==Ce||xe.morphTargets!==me||xe.morphNormals!==We||xe.morphColors!==et||xe.toneMapping!==nt||xe.morphTargetsCount!==qe)&&(Ye=!0):(Ye=!0,xe.__version=B.version);let Xt=xe.currentProgram;Ye===!0&&(Xt=ws(B,I,P));let li=!1,Ct=!1,Ki=!1,it=Xt.getUniforms(),Qt=xe.uniforms;if(Me.useProgram(Xt.program)&&(li=!0,Ct=!0,Ki=!0),B.id!==S&&(S=B.id,Ct=!0),li||y!==v){Me.buffers.depth.getReversed()?(se.copy(v.projectionMatrix),Vu(se),Hu(se),it.setValue(D,"projectionMatrix",se)):it.setValue(D,"projectionMatrix",v.projectionMatrix),it.setValue(D,"viewMatrix",v.matrixWorldInverse);let Cn=it.map.cameraPosition;Cn!==void 0&&Cn.setValue(D,we.setFromMatrixPosition(v.matrixWorld)),ke.logarithmicDepthBuffer&&it.setValue(D,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&it.setValue(D,"isOrthographic",v.isOrthographicCamera===!0),y!==v&&(y=v,Ct=!0,Ki=!0)}if(P.isSkinnedMesh){it.setOptional(D,P,"bindMatrix"),it.setOptional(D,P,"bindMatrixInverse");let Ot=P.skeleton;Ot&&(Ot.boneTexture===null&&Ot.computeBoneTexture(),it.setValue(D,"boneTexture",Ot.boneTexture,b))}P.isBatchedMesh&&(it.setOptional(D,P,"batchingTexture"),it.setValue(D,"batchingTexture",P._matricesTexture,b),it.setOptional(D,P,"batchingIdTexture"),it.setValue(D,"batchingIdTexture",P._indirectTexture,b),it.setOptional(D,P,"batchingColorTexture"),P._colorsTexture!==null&&it.setValue(D,"batchingColorTexture",P._colorsTexture,b));let Ji=F.morphAttributes;if((Ji.position!==void 0||Ji.normal!==void 0||Ji.color!==void 0)&&Te.update(P,F,Xt),(Ct||xe.receiveShadow!==P.receiveShadow)&&(xe.receiveShadow=P.receiveShadow,it.setValue(D,"receiveShadow",P.receiveShadow)),B.isMeshGouraudMaterial&&B.envMap!==null&&(Qt.envMap.value=pe,Qt.flipEnvMap.value=pe.isCubeTexture&&pe.isRenderTargetTexture===!1?-1:1),B.isMeshStandardMaterial&&B.envMap===null&&I.environment!==null&&(Qt.envMapIntensity.value=I.environmentIntensity),Ct&&(it.setValue(D,"toneMappingExposure",M.toneMappingExposure),xe.needsLights&&Dh(Qt,Ki),j&&B.fog===!0&&re.refreshFogUniforms(Qt,j),re.refreshMaterialUniforms(Qt,B,V,Q,f.state.transmissionRenderTarget[v.id]),Li.upload(D,Oc(xe),Qt,b)),B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Li.upload(D,Oc(xe),Qt,b),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&it.setValue(D,"center",P.center),it.setValue(D,"modelViewMatrix",P.modelViewMatrix),it.setValue(D,"normalMatrix",P.normalMatrix),it.setValue(D,"modelMatrix",P.matrixWorld),B.isShaderMaterial||B.isRawShaderMaterial){let Ot=B.uniformsGroups;for(let Cn=0,In=Ot.length;Cn<In;Cn++){let Bc=Ot[Cn];C.update(Bc,Xt),C.bind(Bc,Xt)}}return Xt}function Dh(v,I){v.ambientLightColor.needsUpdate=I,v.lightProbe.needsUpdate=I,v.directionalLights.needsUpdate=I,v.directionalLightShadows.needsUpdate=I,v.pointLights.needsUpdate=I,v.pointLightShadows.needsUpdate=I,v.spotLights.needsUpdate=I,v.spotLightShadows.needsUpdate=I,v.rectAreaLights.needsUpdate=I,v.hemisphereLights.needsUpdate=I}function Nh(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(v,I,F){ye.get(v.texture).__webglTexture=I,ye.get(v.depthTexture).__webglTexture=F;let B=ye.get(v);B.__hasExternalTextures=!0,B.__autoAllocateDepthBuffer=F===void 0,B.__autoAllocateDepthBuffer||ze.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),B.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(v,I){let F=ye.get(v);F.__webglFramebuffer=I,F.__useDefaultFramebuffer=I===void 0},this.setRenderTarget=function(v,I=0,F=0){N=v,w=I,E=F;let B=!0,P=null,j=!1,ae=!1;if(v){let pe=ye.get(v);if(pe.__useDefaultFramebuffer!==void 0)Me.bindFramebuffer(D.FRAMEBUFFER,null),B=!1;else if(pe.__webglFramebuffer===void 0)b.setupRenderTarget(v);else if(pe.__hasExternalTextures)b.rebindTextures(v,ye.get(v.texture).__webglTexture,ye.get(v.depthTexture).__webglTexture);else if(v.depthBuffer){let me=v.depthTexture;if(pe.__boundDepthTexture!==me){if(me!==null&&ye.has(me)&&(v.width!==me.image.width||v.height!==me.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");b.setupDepthRenderbuffer(v)}}let Ee=v.texture;(Ee.isData3DTexture||Ee.isDataArrayTexture||Ee.isCompressedArrayTexture)&&(ae=!0);let Ce=ye.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(Ce[I])?P=Ce[I][F]:P=Ce[I],j=!0):v.samples>0&&b.useMultisampledRTT(v)===!1?P=ye.get(v).__webglMultisampledFramebuffer:Array.isArray(Ce)?P=Ce[F]:P=Ce,R.copy(v.viewport),q.copy(v.scissor),z=v.scissorTest}else R.copy(ve).multiplyScalar(V).floor(),q.copy(Ne).multiplyScalar(V).floor(),z=$e;if(Me.bindFramebuffer(D.FRAMEBUFFER,P)&&B&&Me.drawBuffers(v,P),Me.viewport(R),Me.scissor(q),Me.setScissorTest(z),j){let pe=ye.get(v.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+I,pe.__webglTexture,F)}else if(ae){let pe=ye.get(v.texture),Ee=I||0;D.framebufferTextureLayer(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,pe.__webglTexture,F||0,Ee)}S=-1},this.readRenderTargetPixels=function(v,I,F,B,P,j,ae){if(!(v&&v.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let fe=ye.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&ae!==void 0&&(fe=fe[ae]),fe){Me.bindFramebuffer(D.FRAMEBUFFER,fe);try{let pe=v.texture,Ee=pe.format,Ce=pe.type;if(!ke.textureFormatReadable(Ee)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ke.textureTypeReadable(Ce)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=v.width-B&&F>=0&&F<=v.height-P&&D.readPixels(I,F,B,P,Le.convert(Ee),Le.convert(Ce),j)}finally{let pe=N!==null?ye.get(N).__webglFramebuffer:null;Me.bindFramebuffer(D.FRAMEBUFFER,pe)}}},this.readRenderTargetPixelsAsync=async function(v,I,F,B,P,j,ae){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let fe=ye.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&ae!==void 0&&(fe=fe[ae]),fe){let pe=v.texture,Ee=pe.format,Ce=pe.type;if(!ke.textureFormatReadable(Ee))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ke.textureTypeReadable(Ce))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(I>=0&&I<=v.width-B&&F>=0&&F<=v.height-P){Me.bindFramebuffer(D.FRAMEBUFFER,fe);let me=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,me),D.bufferData(D.PIXEL_PACK_BUFFER,j.byteLength,D.STREAM_READ),D.readPixels(I,F,B,P,Le.convert(Ee),Le.convert(Ce),0);let We=N!==null?ye.get(N).__webglFramebuffer:null;Me.bindFramebuffer(D.FRAMEBUFFER,We);let et=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await ku(D,et,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,me),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,j),D.deleteBuffer(me),D.deleteSync(et),j}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(v,I=null,F=0){v.isTexture!==!0&&(rs("WebGLRenderer: copyFramebufferToTexture function signature has changed."),I=arguments[0]||null,v=arguments[1]);let B=Math.pow(2,-F),P=Math.floor(v.image.width*B),j=Math.floor(v.image.height*B),ae=I!==null?I.x:0,fe=I!==null?I.y:0;b.setTexture2D(v,0),D.copyTexSubImage2D(D.TEXTURE_2D,F,0,0,ae,fe,P,j),Me.unbindTexture()},this.copyTextureToTexture=function(v,I,F=null,B=null,P=0){v.isTexture!==!0&&(rs("WebGLRenderer: copyTextureToTexture function signature has changed."),B=arguments[0]||null,v=arguments[1],I=arguments[2],P=arguments[3]||0,F=null);let j,ae,fe,pe,Ee,Ce,me,We,et,nt=v.isCompressedTexture?v.mipmaps[P]:v.image;F!==null?(j=F.max.x-F.min.x,ae=F.max.y-F.min.y,fe=F.isBox3?F.max.z-F.min.z:1,pe=F.min.x,Ee=F.min.y,Ce=F.isBox3?F.min.z:0):(j=nt.width,ae=nt.height,fe=nt.depth||1,pe=0,Ee=0,Ce=0),B!==null?(me=B.x,We=B.y,et=B.z):(me=0,We=0,et=0);let Tt=Le.convert(I.format),qe=Le.convert(I.type),xe;I.isData3DTexture?(b.setTexture3D(I,0),xe=D.TEXTURE_3D):I.isDataArrayTexture||I.isCompressedArrayTexture?(b.setTexture2DArray(I,0),xe=D.TEXTURE_2D_ARRAY):(b.setTexture2D(I,0),xe=D.TEXTURE_2D),D.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,I.flipY),D.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),D.pixelStorei(D.UNPACK_ALIGNMENT,I.unpackAlignment);let ln=D.getParameter(D.UNPACK_ROW_LENGTH),Ye=D.getParameter(D.UNPACK_IMAGE_HEIGHT),Xt=D.getParameter(D.UNPACK_SKIP_PIXELS),li=D.getParameter(D.UNPACK_SKIP_ROWS),Ct=D.getParameter(D.UNPACK_SKIP_IMAGES);D.pixelStorei(D.UNPACK_ROW_LENGTH,nt.width),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,nt.height),D.pixelStorei(D.UNPACK_SKIP_PIXELS,pe),D.pixelStorei(D.UNPACK_SKIP_ROWS,Ee),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Ce);let Ki=v.isDataArrayTexture||v.isData3DTexture,it=I.isDataArrayTexture||I.isData3DTexture;if(v.isRenderTargetTexture||v.isDepthTexture){let Qt=ye.get(v),Ji=ye.get(I),Ot=ye.get(Qt.__renderTarget),Cn=ye.get(Ji.__renderTarget);Me.bindFramebuffer(D.READ_FRAMEBUFFER,Ot.__webglFramebuffer),Me.bindFramebuffer(D.DRAW_FRAMEBUFFER,Cn.__webglFramebuffer);for(let In=0;In<fe;In++)Ki&&D.framebufferTextureLayer(D.READ_FRAMEBUFFER,D.COLOR_ATTACHMENT0,ye.get(v).__webglTexture,P,Ce+In),v.isDepthTexture?(it&&D.framebufferTextureLayer(D.DRAW_FRAMEBUFFER,D.COLOR_ATTACHMENT0,ye.get(I).__webglTexture,P,et+In),D.blitFramebuffer(pe,Ee,j,ae,me,We,j,ae,D.DEPTH_BUFFER_BIT,D.NEAREST)):it?D.copyTexSubImage3D(xe,P,me,We,et+In,pe,Ee,j,ae):D.copyTexSubImage2D(xe,P,me,We,et+In,pe,Ee,j,ae);Me.bindFramebuffer(D.READ_FRAMEBUFFER,null),Me.bindFramebuffer(D.DRAW_FRAMEBUFFER,null)}else it?v.isDataTexture||v.isData3DTexture?D.texSubImage3D(xe,P,me,We,et,j,ae,fe,Tt,qe,nt.data):I.isCompressedArrayTexture?D.compressedTexSubImage3D(xe,P,me,We,et,j,ae,fe,Tt,nt.data):D.texSubImage3D(xe,P,me,We,et,j,ae,fe,Tt,qe,nt):v.isDataTexture?D.texSubImage2D(D.TEXTURE_2D,P,me,We,j,ae,Tt,qe,nt.data):v.isCompressedTexture?D.compressedTexSubImage2D(D.TEXTURE_2D,P,me,We,nt.width,nt.height,Tt,nt.data):D.texSubImage2D(D.TEXTURE_2D,P,me,We,j,ae,Tt,qe,nt);D.pixelStorei(D.UNPACK_ROW_LENGTH,ln),D.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Ye),D.pixelStorei(D.UNPACK_SKIP_PIXELS,Xt),D.pixelStorei(D.UNPACK_SKIP_ROWS,li),D.pixelStorei(D.UNPACK_SKIP_IMAGES,Ct),P===0&&I.generateMipmaps&&D.generateMipmap(xe),Me.unbindTexture()},this.copyTextureToTexture3D=function(v,I,F=null,B=null,P=0){return v.isTexture!==!0&&(rs("WebGLRenderer: copyTextureToTexture3D function signature has changed."),F=arguments[0]||null,B=arguments[1]||null,v=arguments[2],I=arguments[3],P=arguments[4]||0),rs('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(v,I,F,B,P)},this.initRenderTarget=function(v){ye.get(v).__webglFramebuffer===void 0&&b.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?b.setTextureCube(v,0):v.isData3DTexture?b.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?b.setTexture2DArray(v,0):b.setTexture2D(v,0),Me.unbindTexture()},this.resetState=function(){w=0,E=0,N=null,Me.reset(),Qe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return vn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorspace=Fe._getDrawingBufferColorSpace(e),t.unpackColorSpace=Fe._getUnpackColorSpace()}};var vr=class extends rt{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 rn,this.environmentIntensity=1,this.environmentRotation=new rn,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){let 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}},gs=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ca,this.updateRanges=[],this.version=0,this.uuid=jt()}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;i<r;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=jt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=jt()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},bt=new L,_s=class s{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)bt.fromBufferAttribute(this,t),bt.applyMatrix4(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bt.fromBufferAttribute(this,t),bt.applyNormalMatrix(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bt.fromBufferAttribute(this,t),bt.transformDirection(e),this.setXYZ(t,bt.x,bt.y,bt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Jt(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Ke(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Ke(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Jt(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Jt(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Jt(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Jt(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ke(t,this.array),n=Ke(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ke(t,this.array),n=Ke(n,this.array),i=Ke(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Ke(t,this.array),n=Ke(n,this.array),i=Ke(i,this.array),r=Ke(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=r,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return new ut(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new s(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}};var Fl=new L,Bl=new Xe,zl=new Xe,Fg=new L,kl=new Pe,Zs=new L,yo=new Lt,Vl=new Pe,Mo=new Vi,yr=class extends yt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Gc,this.bindMatrix=new Pe,this.bindMatrixInverse=new Pe,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new kt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zs),this.boundingBox.expandByPoint(Zs)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Lt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zs),this.boundingSphere.expandByPoint(Zs)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),yo.copy(this.boundingSphere),yo.applyMatrix4(i),e.ray.intersectsSphere(yo)!==!1&&(Vl.copy(i).invert(),Mo.copy(e.ray).applyMatrix4(Vl),!(this.boundingBox!==null&&Mo.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Mo)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new Xe,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);let r=1/e.manhattanLength();r!==1/0?e.multiplyScalar(r):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Gc?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===hu?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,i=this.geometry;Bl.fromBufferAttribute(i.attributes.skinIndex,e),zl.fromBufferAttribute(i.attributes.skinWeight,e),Fl.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){let o=zl.getComponent(r);if(o!==0){let a=Bl.getComponent(r);kl.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(Fg.copy(Fl).applyMatrix4(kl),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},xs=class extends rt{constructor(){super(),this.isBone=!0,this.type="Bone"}},Mr=class extends mt{constructor(e=null,t=1,n=1,i,r,o,a,c,l=Mt,h=Mt,u,d){super(null,o,a,c,l,h,i,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Hl=new Pe,Bg=new Pe,Sr=class s{constructor(e=[],t=[]){this.uuid=jt(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Pe)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new Pe;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=e.length;r<o;r++){let a=e[r]?e[r].matrixWorld:Bg;Hl.multiplyMatrices(a,t[r]),Hl.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new s(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new Mr(t,e,e,Bt,$t);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let i=this.bones[t];if(i.name===e)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){let r=e.bones[n],o=t[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new xs),this.bones.push(o),this.boneInverses.push(new Pe().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let i=0,r=t.length;i<r;i++){let o=t[i];e.bones.push(o.uuid);let a=n[i];e.boneInverses.push(a.toArray())}return e}},oi=class extends ut{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Ai=new Pe,Gl=new Pe,Ks=[],Wl=new kt,zg=new Pe,ts=new yt,ns=new Lt,br=class extends yt{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new oi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,zg)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new kt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ai),Wl.copy(e.boundingBox).applyMatrix4(Ai),this.boundingBox.union(Wl)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Lt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Ai),ns.copy(e.boundingSphere).applyMatrix4(Ai),this.boundingSphere.union(ns)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=e*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(e,t){let n=this.matrixWorld,i=this.count;if(ts.geometry=this.geometry,ts.material=this.material,ts.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ns.copy(this.boundingSphere),ns.applyMatrix4(n),e.ray.intersectsSphere(ns)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,Ai),Gl.multiplyMatrices(n,Ai),ts.matrixWorld=Gl,ts.raycast(e,Ks);for(let o=0,a=Ks.length;o<a;o++){let c=Ks[o];c.instanceId=r,c.object=this,t.push(c)}Ks.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new oi(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Mr(new Float32Array(i*this.count),i,this.count,Wa,$t));let r=this.morphTexture.source.data.data,o=0;for(let l=0;l<n.length;l++)o+=n[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=i*e;r[c]=a,r.set(n,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}};var vs=class extends Dt{static get type(){return"LineBasicMaterial"}constructor(e){super(),this.isLineBasicMaterial=!0,this.color=new Se(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},Ar=new L,Tr=new L,Xl=new Pe,is=new Vi,Js=new Lt,So=new L,ql=new L,Wi=class extends rt{constructor(e=new Vt,t=new vs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let i=1,r=t.count;i<r;i++)Ar.fromBufferAttribute(t,i-1),Tr.fromBufferAttribute(t,i),n[i]=n[i-1],n[i]+=Ar.distanceTo(Tr);e.setAttribute("lineDistance",new zt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Js.copy(n.boundingSphere),Js.applyMatrix4(i),Js.radius+=r,e.ray.intersectsSphere(Js)===!1)return;Xl.copy(i).invert(),is.copy(e.ray).applyMatrix4(Xl);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){let p=Math.max(0,o.start),g=Math.min(h.count,o.start+o.count);for(let _=p,m=g-1;_<m;_+=l){let f=h.getX(_),T=h.getX(_+1),A=$s(this,e,is,c,f,T);A&&t.push(A)}if(this.isLineLoop){let _=h.getX(g-1),m=h.getX(p),f=$s(this,e,is,c,_,m);f&&t.push(f)}}else{let p=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let _=p,m=g-1;_<m;_+=l){let f=$s(this,e,is,c,_,_+1);f&&t.push(f)}if(this.isLineLoop){let _=$s(this,e,is,c,g-1,p);_&&t.push(_)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function $s(s,e,t,n,i,r){let o=s.geometry.attributes.position;if(Ar.fromBufferAttribute(o,i),Tr.fromBufferAttribute(o,r),t.distanceSqToSegment(Ar,Tr,So,ql)>n)return;So.applyMatrix4(s.matrixWorld);let c=e.ray.origin.distanceTo(So);if(!(c<e.near||c>e.far))return{distance:c,point:ql.clone().applyMatrix4(s.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:s}}var Yl=new L,Zl=new L,Er=class extends Wi{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let i=0,r=t.count;i<r;i+=2)Yl.fromBufferAttribute(t,i),Zl.fromBufferAttribute(t,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Yl.distanceTo(Zl);e.setAttribute("lineDistance",new zt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},wr=class extends Wi{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},ys=class extends Dt{static get type(){return"PointsMaterial"}constructor(e){super(),this.isPointsMaterial=!0,this.color=new Se(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Kl=new Pe,Ta=new Vi,js=new Lt,Qs=new L,Rr=class extends rt{constructor(e=new Vt,t=new ys){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),js.copy(n.boundingSphere),js.applyMatrix4(i),js.radius+=r,e.ray.intersectsSphere(js)===!1)return;Kl.copy(i).invert(),Ta.copy(e.ray).applyMatrix4(Kl);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,u=n.attributes.position;if(l!==null){let d=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let g=d,_=p;g<_;g++){let m=l.getX(g);Qs.fromBufferAttribute(u,m),Jl(Qs,m,c,i,e,t,this)}}else{let d=Math.max(0,o.start),p=Math.min(u.count,o.start+o.count);for(let g=d,_=p;g<_;g++)Qs.fromBufferAttribute(u,g),Jl(Qs,g,c,i,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let i=t[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function Jl(s,e,t,n,i,r,o){let a=Ta.distanceSqToPoint(s);if(a<t){let c=new L;Ta.closestPointToPoint(s,c),c.applyMatrix4(n);let l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var Vn=class extends Dt{static get type(){return"MeshStandardMaterial"}constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.color=new Se(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Se(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mh,this.normalScale=new Be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new rn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Nt=class extends Vn{static get type(){return"MeshPhysicalMaterial"}constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Be(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return vt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Se(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Se(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Se(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get 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}};function er(s,e,t){return!s||!t&&s.constructor===e?s:typeof e.BYTES_PER_ELEMENT=="number"?new e(s):Array.prototype.slice.call(s)}function kg(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Vg(s){function e(i,r){return s[i]-s[r]}let t=s.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort(e),n}function $l(s,e,t){let n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){let a=t[r]*e;for(let c=0;c!==e;++c)i[o++]=s[a+c]}return i}function Eh(s,e,t,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(e.push(r.time),t.push.apply(t,o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(e.push(r.time),o.toArray(t,t.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(e.push(r.time),t.push(o)),r=s[i++];while(r!==void 0)}var Hn=class{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let o;n:{i:if(!(e<i)){for(let a=n+2;;){if(i===void 0){if(e<r)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=t[++n],e<i)break t}o=t.length;break n}if(!(e>=r)){let a=t[1];e<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=t[--n-1],e>=r)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(i=t[n],r=t[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i;for(let o=0;o!==i;++o)t[o]=n[r+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Ea=class extends Hn{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ei,endingEnd:Ei}}intervalChanged_(e,t,n){let i=this.parameterPositions,r=e-2,o=e+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case wi:r=e,a=2*t-n;break;case or:r=i.length-2,a=t+i[r]-i[r+1];break;default:r=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case wi:o=e,c=2*n-t;break;case or:o=1,c=n+i[1]-i[0];break;default:o=e-1,c=t}let l=(n-t)*.5,h=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=o*h}interpolate_(e,t,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,p=this._weightNext,g=(n-t)/(i-t),_=g*g,m=_*g,f=-d*m+2*d*_-d*g,T=(1+d)*m+(-1.5-2*d)*_+(-.5+d)*g+1,A=(-1-p)*m+(1.5+p)*_+.5*g,M=p*m-p*_;for(let U=0;U!==a;++U)r[U]=f*o[h+U]+T*o[l+U]+A*o[c+U]+M*o[u+U];return r}},Cr=class extends Hn{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,h=(n-t)/(i-t),u=1-h;for(let d=0;d!==a;++d)r[d]=o[l+d]*u+o[c+d]*h;return r}},wa=class extends Hn{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},Ht=class{constructor(e,t,n,i){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=er(t,this.TimeBufferType),this.values=er(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:er(e.times,Array),values:er(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(n.interpolation=i)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new wa(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Cr(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Ea(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bi:t=this.InterpolantFactoryMethodDiscrete;break;case zi:t=this.InterpolantFactoryMethodLinear;break;case qr:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bi;case this.InterpolantFactoryMethodLinear:return zi;case this.InterpolantFactoryMethodSmooth:return qr}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){let n=this.times,i=n.length,r=0,o=i-1;for(;r!==i&&n[r]<e;)++r;for(;o!==-1&&n[o]>t;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let 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++){let c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(i!==void 0&&kg(i))for(let a=0,c=i.length;a!==c;++a){let l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===qr,r=e.length-1,o=1;for(let a=1;a<r;++a){let c=!1,l=e[a],h=e[a+1];if(l!==h&&(a!==1||l!==e[0]))if(i)c=!0;else{let u=a*n,d=u-n,p=u+n;for(let g=0;g!==n;++g){let _=t[u+g];if(_!==t[d+g]||_!==t[p+g]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let u=a*n,d=o*n;for(let p=0;p!==n;++p)t[d+p]=t[u+p]}++o}}if(r>0){e[o]=e[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,i=new n(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Ht.prototype.TimeBufferType=Float32Array;Ht.prototype.ValueBufferType=Float32Array;Ht.prototype.DefaultInterpolation=zi;var Gn=class extends Ht{constructor(e,t,n){super(e,t,n)}};Gn.prototype.ValueTypeName="bool";Gn.prototype.ValueBufferType=Array;Gn.prototype.DefaultInterpolation=Bi;Gn.prototype.InterpolantFactoryMethodLinear=void 0;Gn.prototype.InterpolantFactoryMethodSmooth=void 0;var Ir=class extends Ht{};Ir.prototype.ValueTypeName="color";var An=class extends Ht{};An.prototype.ValueTypeName="number";var Ra=class extends Hn{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(i-t),l=e*a;for(let h=l+a;l!==h;l+=4)Rt.slerpFlat(r,0,o,l-a,o,l,c);return r}},Tn=class extends Ht{InterpolantFactoryMethodLinear(e){return new Ra(this.times,this.values,this.getValueSize(),e)}};Tn.prototype.ValueTypeName="quaternion";Tn.prototype.InterpolantFactoryMethodSmooth=void 0;var Wn=class extends Ht{constructor(e,t,n){super(e,t,n)}};Wn.prototype.ValueTypeName="string";Wn.prototype.ValueBufferType=Array;Wn.prototype.DefaultInterpolation=Bi;Wn.prototype.InterpolantFactoryMethodLinear=void 0;Wn.prototype.InterpolantFactoryMethodSmooth=void 0;var En=class extends Ht{};En.prototype.ValueTypeName="vector";var Xi=class{constructor(e="",t=-1,n=[],i=Ja){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=jt(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(Gg(n[o]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){let 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(Ht.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);let h=Vg(c);c=$l(c,1,h),l=$l(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new An(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let i=e;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===t)return n[i];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],h=l.name.match(r);if(h&&h.length>1){let u=h[1],d=i[u];d||(i[u]=d=[]),d.push(l)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(u,d,p,g,_){if(p.length!==0){let m=[],f=[];Eh(p,m,f,g),m.length!==0&&_.push(new u(d,m,f))}},i=[],r=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let u=0;u<l.length;u++){let d=l[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let p={},g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let _=0;_<d[g].morphTargets.length;_++)p[d[g].morphTargets[_]]=-1;for(let _ in p){let m=[],f=[];for(let T=0;T!==d[g].morphTargets.length;++T){let A=d[g];m.push(A.time),f.push(A.morphTarget===_?1:0)}i.push(new An(".morphTargetInfluence["+_+"]",m,f))}c=p.length*o}else{let p=".bones["+t[u].name+"]";n(En,p+".position",d,"pos",i),n(Tn,p+".quaternion",d,"rot",i),n(En,p+".scale",d,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){let e=this.tracks,t=0;for(let n=0,i=e.length;n!==i;++n){let r=this.tracks[n];t=Math.max(t,r.times[r.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function Hg(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return An;case"vector":case"vector2":case"vector3":case"vector4":return En;case"color":return Ir;case"quaternion":return Tn;case"bool":case"boolean":return Gn;case"string":return Wn}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function Gg(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=Hg(s.type);if(s.times===void 0){let t=[],n=[];Eh(s.keys,t,n,"value"),s.times=t,s.values=n}return e.parse!==void 0?e.parse(s):new e(s.name,s.times,s.values,s.interpolation)}var Bn={enabled:!1,files:{},add:function(s,e){this.enabled!==!1&&(this.files[s]=e)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}},Ca=class{constructor(e,t,n){let i=this,r=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(h){a++,r===!1&&i.onStart!==void 0&&i.onStart(h,o,a),r=!0},this.itemEnd=function(h){o++,i.onProgress!==void 0&&i.onProgress(h,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){let u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){let p=l[u],g=l[u+1];if(p.global&&(p.lastIndex=0),p.test(h))return g}return null}}},Wg=new Ca,wn=class{constructor(e){this.manager=e!==void 0?e:Wg,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(i,r){n.load(e,i,t,r)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};wn.DEFAULT_MATERIAL_NAME="__DEFAULT";var mn={},Ia=class extends Error{constructor(e,t){super(e),this.response=t}},Ms=class extends wn{constructor(e){super(e)}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=Bn.get(e);if(r!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(r),this.manager.itemEnd(e)},0),r;if(mn[e]!==void 0){mn[e].push({onLoad:t,onProgress:n,onError:i});return}mn[e]=[],mn[e].push({onLoad:t,onProgress:n,onError:i});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=mn[e],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),p=d?parseInt(d):0,g=p!==0,_=0,m=new ReadableStream({start(f){T();function T(){u.read().then(({done:A,value:M})=>{if(A)f.close();else{_+=M.byteLength;let U=new ProgressEvent("progress",{lengthComputable:g,loaded:_,total:p});for(let w=0,E=h.length;w<E;w++){let N=h[w];N.onProgress&&N.onProgress(U)}f.enqueue(M),T()}},A=>{f.error(A)})}}});return new Response(m)}else throw new Ia(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,a));case"json":return l.json();default:if(a===void 0)return l.text();{let u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return l.arrayBuffer().then(g=>p.decode(g))}}}).then(l=>{Bn.add(e,l);let h=mn[e];delete mn[e];for(let u=0,d=h.length;u<d;u++){let p=h[u];p.onLoad&&p.onLoad(l)}}).catch(l=>{let h=mn[e];if(h===void 0)throw this.manager.itemError(e),l;delete mn[e];for(let u=0,d=h.length;u<d;u++){let p=h[u];p.onError&&p.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}};var Pa=class extends wn{constructor(e){super(e)}load(e,t,n,i){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Bn.get(e);if(o!==void 0)return r.manager.itemStart(e),setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o;let a=fs("img");function c(){h(),Bn.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(u){h(),i&&i(u),r.manager.itemError(e),r.manager.itemEnd(e)}function h(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}};var Pr=class extends wn{constructor(e){super(e)}load(e,t,n,i){let r=new mt,o=new Pa(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){r.image=a,r.needsUpdate=!0,t!==void 0&&t(r)},n,i),r}},ai=class extends rt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Se(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}},Lr=class extends ai{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(rt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Se(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},bo=new Pe,jl=new L,Ql=new L,Ss=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Be(512,512),this.map=null,this.mapPass=null,this.matrix=new Pe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ms,this._frameExtents=new Be(1,1),this._viewportCount=1,this._viewports=[new Xe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;jl.setFromMatrixPosition(e.matrixWorld),t.position.copy(jl),Ql.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ql),t.updateMatrixWorld(),bo.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(bo),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(bo)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},La=class extends Ss{constructor(){super(new ht(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=ki*2*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(n!==t.fov||i!==t.aspect||r!==t.far)&&(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Dr=class extends ai{constructor(e,t,n=0,i=Math.PI/3,r=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(rt.DEFAULT_UP),this.updateMatrix(),this.target=new rt,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new La}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},eh=new Pe,ss=new L,Ao=new L,Da=class extends Ss{constructor(){super(new ht(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Be(4,2),this._viewportCount=6,this._viewports=[new Xe(2,1,1,1),new Xe(0,1,1,1),new Xe(3,1,1,1),new Xe(1,1,1,1),new Xe(3,0,1,1),new Xe(1,0,1,1)],this._cubeDirections=[new L(1,0,0),new L(-1,0,0),new L(0,0,1),new L(0,0,-1),new L(0,1,0),new L(0,-1,0)],this._cubeUps=[new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,1,0),new L(0,0,1),new L(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),ss.setFromMatrixPosition(e.matrixWorld),n.position.copy(ss),Ao.copy(n.position),Ao.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Ao),n.updateMatrixWorld(),i.makeTranslation(-ss.x,-ss.y,-ss.z),eh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(eh)}},Nr=class extends ai{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Da}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},Na=class extends Ss{constructor(){super(new Gi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},qi=class extends ai{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(rt.DEFAULT_UP),this.updateMatrix(),this.target=new rt,this.shadow=new Na}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Ur=class extends ai{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}};var Xn=class{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let 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)}};var Or=class extends wn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,o=Bn.get(e);if(o!==void 0){if(r.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),r.manager.itemEnd(e)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){t&&t(o),r.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Bn.add(e,l),t&&t(l),r.manager.itemEnd(e),l}).catch(function(l){i&&i(l),Bn.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)});Bn.add(e,c),r.manager.itemStart(e)}};var Fr=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=th(),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){let t=th();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function th(){return performance.now()}var Ua=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let i,r,o;switch(t){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,i=this.valueSize,r=e*i+i,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,i=e*t+t,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let c=t*this._origIndex;this._mixBufferRegion(n,i,c,1-r,t)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,i);break}}saveOriginalState(){let 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(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)e[t+o]=e[n+o]}_slerp(e,t,n,i){Rt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let o=this._workIndex*r;Rt.multiplyQuaternionsFlat(e,o,e,t,e,n),Rt.slerpFlat(e,t,e,t,e,o,i)}_lerp(e,t,n,i,r){let o=1-i;for(let a=0;a!==r;++a){let c=t+a;e[c]=e[c]*o+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let o=0;o!==r;++o){let a=t+o;e[a]=e[a]+e[n+o]*i}}},Qa="\\[\\]\\.:\\/",Xg=new RegExp("["+Qa+"]","g"),ec="[^"+Qa+"]",qg="[^"+Qa.replace("\\.","")+"]",Yg=/((?:WC+[\/:])*)/.source.replace("WC",ec),Zg=/(WCOD+)?/.source.replace("WCOD",qg),Kg=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ec),Jg=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ec),$g=new RegExp("^"+Yg+Zg+Kg+Jg+"$"),jg=["material","materials","bones","map"],Oa=class{constructor(e,t,n){let i=n||je.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},je=class s{constructor(e,t,n){this.path=t,this.parsedPath=n||s.parseTrackName(t),this.node=s.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 s.Composite(e,t,n):new s(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Xg,"")}static parseTrackName(e){let t=$g.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let 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){let r=n.nodeName.substring(i+1);jg.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){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===t||a.uuid===t)return a;let c=n(a.children);if(c)return c}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,i=t.propertyName,r=t.propertyIndex;if(e||(e=s.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let h=0;h<e.length;h++)if(e[h].name===l){l=h;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[i];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[r]!==void 0&&(r=e.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};je.Composite=Oa;je.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};je.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};je.prototype.GetterByBindingType=[je.prototype._getValue_direct,je.prototype._getValue_array,je.prototype._getValue_arrayElement,je.prototype._getValue_toArray];je.prototype.SetterByBindingTypeAndVersioning=[[je.prototype._setValue_direct,je.prototype._setValue_direct_setNeedsUpdate,je.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[je.prototype._setValue_array,je.prototype._setValue_array_setNeedsUpdate,je.prototype._setValue_array_setMatrixWorldNeedsUpdate],[je.prototype._setValue_arrayElement,je.prototype._setValue_arrayElement_setNeedsUpdate,je.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[je.prototype._setValue_fromArray,je.prototype._setValue_fromArray_setNeedsUpdate,je.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Fa=class{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,o=r.length,a=new Array(o),c={endingStart:Ei,endingEnd:Ei};for(let l=0;l!==o;++l){let h=r[l].createInterpolant(null);a[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Ka,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let i=this._clip.duration,r=e._clip.duration,o=r/i,a=i/r;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let 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){let i=this._mixer,r=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=r,c[1]=r+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){let 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}let r=this._startTime;if(r!==null){let c=(e-r)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case du:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulateAdditive(a);break;case Ja:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulate(i,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let 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;let n=this._timeScaleInterpolant;if(n!==null){let 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){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,o=n===uu;if(e===0)return r===-1?i:o&&(r&1)===1?t-i:i;if(n===Za){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){let a=Math.floor(i/t);i-=t*a,r+=Math.abs(a);let c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=wi,i.endingEnd=wi):(e?i.endingStart=this.zeroSlopeAtStart?wi:Ei:i.endingStart=or,t?i.endingEnd=this.zeroSlopeAtEnd?wi:Ei:i.endingEnd=or)}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,c[0]=t,a[1]=r+e,c[1]=n,this}},Qg=new Float32Array(1),Br=class extends Sn{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName,h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){let d=i[u],p=d.name,g=h[p];if(g!==void 0)++g.referenceCount,o[u]=g;else{if(g=o[u],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,c,p));continue}let _=t&&t._propertyBindings[u].binding.parsedPath;g=new Ua(je.create(n,p,_),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,c,p),o[u]=g}a[u].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let 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)}let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let 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;let 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){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let i=this._actions,r=this._actionsByClip,o=r[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,r[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=i.length,i.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;let r=e._clip.uuid,o=this._actionsByClip,a=o[r],c=a.knownActions,l=c[c.length-1],h=e._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),e._byClipCacheIndex=null;let u=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete u[d],c.length===0&&delete o[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,i=t.length;n!==i;++n){let r=t[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_addInactiveBinding(e,t,n){let i=this._bindingsByRootAndName,r=this._bindings,o=i[t];o===void 0&&(o={},i[t]=o),o[n]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,r=t[i];e._cacheIndex=i,t[i]=e,r._cacheIndex=n,t[n]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new Cr(new Float32Array(2),new Float32Array(2),1,Qg),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,r=t[i];e.__cacheIndex=i,t[i]=e,r.__cacheIndex=n,t[n]=r}clipAction(e,t,n){let i=t||this._root,r=i.uuid,o=typeof e=="string"?Xi.findByName(i,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Ja),c!==void 0){let u=c.actionByRoot[r];if(u!==void 0&&u.blendMode===n)return u;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let h=new Fa(this,o,t,n);return this._bindAction(h,l),this._addInactiveAction(h,a,r),h}existingAction(e,t){let n=t||this._root,i=n.uuid,r=typeof e=="string"?Xi.findByName(n,e):e,o=r?r.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let o=r.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let h=l._cacheIndex,u=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,t[h]=u,t.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let i=this._bindingsByRootAndName,r=i[t];if(r!==void 0)for(let o in r){let a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ba}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ba);function tc(s,e){if(e===ph)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===As||e===kr){let t=s.getIndex();if(t===null){let o=[],a=s.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}let n=t.count-2,i=[];if(e===As)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}var Gr=class extends wn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new cc(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new xc(t)}),this.register(function(t){return new vc(t)}),this.register(function(t){return new yc(t)}),this.register(function(t){return new uc(t)}),this.register(function(t){return new dc(t)}),this.register(function(t){return new fc(t)}),this.register(function(t){return new pc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new mc(t)}),this.register(function(t){return new hc(t)}),this.register(function(t){return new _c(t)}),this.register(function(t){return new gc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new Mc(t)}),this.register(function(t){return new Sc(t)})}load(e,t,n,i){let r=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=Xn.extractUrlBase(e);o=Xn.resolveURL(l,this.path)}else o=Xn.extractUrlBase(e);this.manager.itemStart(e);let a=function(l){i?i(l):console.error(l),r.manager.itemError(e),r.manager.itemEnd(e)},c=new Ms(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{r.parse(l,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let r,o={},a={},c=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===Ph){try{o[Oe.KHR_BINARY_GLTF]=new bc(e)}catch(u){i&&i(u);return}r=JSON.parse(o[Oe.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new Ic(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){let u=this.pluginCallbacks[h](l);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){let u=r.extensionsUsed[h],d=r.extensionsRequired||[];switch(u){case Oe.KHR_MATERIALS_UNLIT:o[u]=new oc;break;case Oe.KHR_DRACO_MESH_COMPRESSION:o[u]=new Ac(r,this.dracoLoader);break;case Oe.KHR_TEXTURE_TRANSFORM:o[u]=new Tc;break;case Oe.KHR_MESH_QUANTIZATION:o[u]=new Ec;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){let n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}};function e_(){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={}}}}var Oe={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"},rc=class{constructor(e){this.parser=e,this.name=Oe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,i=t.cache.get(n);if(i)return i;let r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e],l,h=new Se(16777215);c.color!==void 0&&h.setRGB(c.color[0],c.color[1],c.color[2],St);let u=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new qi(h),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Nr(h),l.distance=u;break;case"spot":l=new Dr(h),l.distance=u,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,Rn(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),i=Promise.resolve(l),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}},oc=class{constructor(){this.name=Oe.KHR_MATERIALS_UNLIT}getMaterialType(){return on}extendParams(e,t,n){let i=[];e.color=new Se(1,1,1),e.opacity=1;let r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],St),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,lt))}return Promise.all(i)}},ac=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}},cc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Be(a,a)}return Promise.all(r)}},lc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_DISPERSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}},hc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},uc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_SHEEN}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[];t.sheenColor=new Se(0,0,0),t.sheenRoughness=0,t.sheen=1;let o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],St)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,lt)),o.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},dc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},fc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_VOLUME}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return t.attenuationColor=new Se().setRGB(a[0],a[1],a[2],St),Promise.all(r)}},pc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_IOR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},mc=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_SPECULAR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return t.specularColor=new Se().setRGB(a[0],a[1],a[2],St),o.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,lt)),Promise.all(r)}},gc=class{constructor(e){this.parser=e,this.name=Oe.EXT_MATERIALS_BUMP}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}},_c=class{constructor(e){this.parser=e,this.name=Oe.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Nt}extendMaterialParams(e,t){let n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}},xc=class{constructor(e){this.parser=e,this.name=Oe.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,o)}},vc=class{constructor(e){this.parser=e,this.name=Oe.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=i.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},yc=class{constructor(e){this.parser=e,this.name=Oe.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let o=r.extensions[t],a=i.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},Mc=class{constructor(e){this.name=Oe.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let 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){let c=i.byteOffset||0,l=i.byteLength||0,h=i.count,u=i.byteStride,d=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,d,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){let p=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(p),h,u,d,i.mode,i.filter),p})})}else return null}},Sc=class{constructor(e){this.name=Oe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=t.meshes[n.mesh];for(let l of i.primitives)if(l.mode!==Gt.TRIANGLES&&l.mode!==Gt.TRIANGLE_STRIP&&l.mode!==Gt.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(h=>(c[l]=h,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{let h=l.pop(),u=h.isGroup?h.children:[h],d=l[0].count,p=[];for(let g of u){let _=new Pe,m=new L,f=new Rt,T=new L(1,1,1),A=new br(g.geometry,g.material,d);for(let M=0;M<d;M++)c.TRANSLATION&&m.fromBufferAttribute(c.TRANSLATION,M),c.ROTATION&&f.fromBufferAttribute(c.ROTATION,M),c.SCALE&&T.fromBufferAttribute(c.SCALE,M),A.setMatrixAt(M,_.compose(m,f,T));for(let M in c)if(M==="_COLOR_0"){let U=c[M];A.instanceColor=new oi(U.array,U.itemSize,U.normalized)}else M!=="TRANSLATION"&&M!=="ROTATION"&&M!=="SCALE"&&g.geometry.setAttribute(M,c[M]);rt.prototype.copy.call(A,g),this.parser.assignFinalMaterial(A),p.push(A)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}},Ph="glTF",Ts=12,wh={JSON:1313821514,BIN:5130562},bc=class{constructor(e){this.name=Oe.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Ts),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ph)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-Ts,r=new DataView(e,Ts),o=0;for(;o<i;){let a=r.getUint32(o,!0);o+=4;let c=r.getUint32(o,!0);if(o+=4,c===wh.JSON){let l=new Uint8Array(e,Ts+o,a);this.content=n.decode(l)}else if(c===wh.BIN){let l=Ts+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Ac=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Oe.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(let h in o){let u=Rc[h]||h.toLowerCase();a[u]=o[h]}for(let h in e.attributes){let u=Rc[h]||h.toLowerCase();if(o[h]!==void 0){let d=n.accessors[e.attributes[h]],p=Zi[d.componentType];l[u]=p.name,c[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,d){i.decodeDracoFile(h,function(p){for(let g in p.attributes){let _=p.attributes[g],m=c[g];m!==void 0&&(_.normalized=m)}u(p)},a,l,St,d)})})}},Tc=class{constructor(){this.name=Oe.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},Ec=class{constructor(){this.name=Oe.KHR_MESH_QUANTIZATION}},Wr=class extends Hn{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,h=i-t,u=(n-t)/h,d=u*u,p=d*u,g=e*l,_=g-l,m=-2*p+3*d,f=p-d,T=1-m,A=f-d+u;for(let M=0;M!==a;M++){let U=o[_+M+a],w=o[_+M+c]*h,E=o[g+M+a],N=o[g+M]*h;r[M]=T*U+A*w+m*E+f*N}return r}},t_=new Rt,wc=class extends Wr{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return t_.fromArray(r).normalize().toArray(r),r}},Gt={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Zi={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Rh={9728:Mt,9729:Et,9984:ka,9985:as,9986:Ti,9987:tn},Ch={33071:xn,33648:us,10497:si},nc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Rc={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},qn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},n_={CUBICSPLINE:void 0,LINEAR:zi,STEP:Bi},ic={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function i_(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new Vn({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:sn})),s.DefaultMaterial}function ci(s,e,t){for(let n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Rn(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function s_(s,e,t){let n=!1,i=!1,r=!1;for(let l=0,h=e.length;l<h;l++){let u=e[l];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);let o=[],a=[],c=[];for(let l=0,h=e.length;l<h;l++){let u=e[l];if(n){let d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(d)}if(i){let d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(d)}if(r){let d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let h=l[0],u=l[1],d=l[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function r_(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function o_(s){let e,t=s.extensions&&s.extensions[Oe.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+sc(t.attributes):e=s.indices+":"+sc(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+sc(s.targets[n]);return e}function sc(s){let e="",t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function Cc(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function a_(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var c_=new Pe,Ic=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new e_,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"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let c=a.match(/Version\/(\d+)/);i=n&&c?parseInt(c[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 Pr(this.options.manager):this.textureLoader=new Or(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ms(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){let 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){let a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return ci(r,a,i),Rn(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(let c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i<r;i++){let o=t[i].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){let o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let i=n.clone(),r=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,h]of o.children.entries())r(h,a.children[l])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let i=e(t[n]);if(i)return i}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let i=0;i<t.length;i++){let r=e(t[i]);r&&n.push(r)}return n}getDependency(e,t){let n=e+":"+t,i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(r,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Oe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,o){n.load(Xn.resolveURL(t.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){let t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){let o=nc[i.type],a=Zi[i.componentType],c=i.normalized===!0,l=new a(i.count*o);return Promise.resolve(new ut(l,o,c))}let r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){let a=o[0],c=nc[i.type],l=Zi[i.componentType],h=l.BYTES_PER_ELEMENT,u=h*c,d=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0,_,m;if(p&&p!==u){let f=Math.floor(d/p),T="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+f+":"+i.count,A=t.cache.get(T);A||(_=new l(a,f*p,i.count*p/h),A=new gs(_,p/h),t.cache.add(T,A)),m=new _s(A,c,d%p/h,g)}else a===null?_=new l(i.count*c):_=new l(a,d,i.count*c),m=new ut(_,c,g);if(i.sparse!==void 0){let f=nc.SCALAR,T=Zi[i.sparse.indices.componentType],A=i.sparse.indices.byteOffset||0,M=i.sparse.values.byteOffset||0,U=new T(o[1],A,i.sparse.count*f),w=new l(o[2],M,i.sparse.count*c);a!==null&&(m=new ut(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let E=0,N=U.length;E<N;E++){let S=U[E];if(m.setX(S,w[E*c]),c>=2&&m.setY(S,w[E*c+1]),c>=3&&m.setZ(S,w[E*c+2]),c>=4&&m.setW(S,w[E*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r],a=this.textureLoader;if(o.uri){let c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let i=this,r=this.json,o=r.textures[e],a=r.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);let d=(r.samplers||{})[o.sampler]||{};return h.magFilter=Rh[d.magFilter]||Et,h.minFilter=Rh[d.minFilter]||tn,h.wrapS=Ch[d.wrapS]||si,h.wrapT=Ch[d.wrapT]||si,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==Mt&&h.minFilter!==Et,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());let o=i.images[e],a=self.URL||self.webkitURL,c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(u){l=!0;let d=new Blob([u],{type:o.mimeType});return c=a.createObjectURL(d),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let h=Promise.resolve(c).then(function(u){return new Promise(function(d,p){let g=d;t.isImageBitmapLoader===!0&&(g=function(_){let m=new mt(_);m.needsUpdate=!0,d(m)}),t.load(Xn.resolveURL(u,r.path),g,void 0,p)})}).then(function(u){return l===!0&&a.revokeObjectURL(c),Rn(u,o),u.userData.mimeType=o.mimeType||a_(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){let 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[Oe.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[Oe.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=r.associations.get(o);o=r.extensions[Oe.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new ys,Dt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new vs,Dt.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),r&&(c.vertexColors=!0),o&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return Vn}loadMaterial(e){let t=this,n=this.json,i=this.extensions,r=n.materials[e],o,a={},c=r.extensions||{},l=[];if(c[Oe.KHR_MATERIALS_UNLIT]){let u=i[Oe.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),l.push(u.extendParams(a,r,t))}else{let u=r.pbrMetallicRoughness||{};if(a.color=new Se(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],St),a.opacity=d[3]}u.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",u.baseColorTexture,lt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=Kt);let h=r.alphaMode||ic.OPAQUE;if(h===ic.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===ic.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==on&&(l.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new Be(1,1),r.normalTexture.scale!==void 0)){let u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==on&&(l.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==on){let u=r.emissiveFactor;a.emissive=new Se().setRGB(u[0],u[1],u[2],St)}return r.emissiveTexture!==void 0&&o!==on&&l.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,lt)),Promise.all(l).then(function(){let u=new o(a);return r.name&&(u.name=r.name),Rn(u,r),t.associations.set(u,{materials:e}),r.extensions&&ci(i,u,r),u})}createUniqueName(e){let t=je.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[Oe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Ih(c,a,t)})}let o=[];for(let a=0,c=e.length;a<c;a++){let l=e[a],h=o_(l),u=i[h];if(u)o.push(u.promise);else{let d;l.extensions&&l.extensions[Oe.KHR_DRACO_MESH_COMPRESSION]?d=r(l):d=Ih(new Vt,l,t),i[h]={primitive:l,promise:d},o.push(d)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let h=o[c].material===void 0?i_(this.cache):this.getDependency("material",o[c].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){let l=c.slice(0,c.length-1),h=c[c.length-1],u=[];for(let p=0,g=h.length;p<g;p++){let _=h[p],m=o[p],f,T=l[p];if(m.mode===Gt.TRIANGLES||m.mode===Gt.TRIANGLE_STRIP||m.mode===Gt.TRIANGLE_FAN||m.mode===void 0)f=r.isSkinnedMesh===!0?new yr(_,T):new yt(_,T),f.isSkinnedMesh===!0&&f.normalizeSkinWeights(),m.mode===Gt.TRIANGLE_STRIP?f.geometry=tc(f.geometry,kr):m.mode===Gt.TRIANGLE_FAN&&(f.geometry=tc(f.geometry,As));else if(m.mode===Gt.LINES)f=new Er(_,T);else if(m.mode===Gt.LINE_STRIP)f=new Wi(_,T);else if(m.mode===Gt.LINE_LOOP)f=new wr(_,T);else if(m.mode===Gt.POINTS)f=new Rr(_,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(f.geometry.morphAttributes).length>0&&r_(f,r),f.name=t.createUniqueName(r.name||"mesh_"+e),Rn(f,r),m.extensions&&ci(i,f,m),t.assignFinalMaterial(f),u.push(f)}for(let p=0,g=u.length;p<g;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return r.extensions&&ci(i,u[0],r),u[0];let d=new nn;r.extensions&&ci(i,d,r),t.associations.set(d,{meshes:e});for(let p=0,g=u.length;p<g;p++)d.add(u[p]);return d})}loadCamera(e){let t,n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new ht(_h.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new Gi(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Rn(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){let r=i.pop(),o=i,a=[],c=[];for(let l=0,h=o.length;l<h;l++){let u=o[l];if(u){a.push(u);let d=new Pe;r!==null&&d.fromArray(r.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new Sr(a,c)})}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,o=[],a=[],c=[],l=[],h=[];for(let u=0,d=i.channels.length;u<d;u++){let p=i.channels[u],g=i.samplers[p.sampler],_=p.target,m=_.node,f=i.parameters!==void 0?i.parameters[g.input]:g.input,T=i.parameters!==void 0?i.parameters[g.output]:g.output;_.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",f)),c.push(this.getDependency("accessor",T)),l.push(g),h.push(_))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(h)]).then(function(u){let d=u[0],p=u[1],g=u[2],_=u[3],m=u[4],f=[];for(let T=0,A=d.length;T<A;T++){let M=d[T],U=p[T],w=g[T],E=_[T],N=m[T];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();let S=n._createAnimationTracks(M,U,w,E,N);if(S)for(let y=0;y<S.length;y++)f.push(S[y])}return new Xi(r,void 0,f)})}createNodeMesh(e){let t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){let o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=i.weights.length;c<l;c++)a.morphTargetInfluences[c]=i.weights[c]}),o})}loadNode(e){let t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=i.children||[];for(let l=0,h=a.length;l<h;l++)o.push(n.getDependency("node",a[l]));let c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){let h=l[0],u=l[1],d=l[2];d!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(d,c_)});for(let p=0,g=u.length;p<g;p++)h.add(u[p]);return h})}_loadNodeShallow(e){let t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"",a=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(l){return i._getNodeRef(i.cameraCache,r.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let h;if(r.isBone===!0?h=new xs:l.length>1?h=new nn:l.length===1?h=l[0]:h=new rt,h!==l[0])for(let u=0,d=l.length;u<d;u++)h.add(l[u]);if(r.name&&(h.userData.name=r.name,h.name=o),Rn(h,r),r.extensions&&ci(n,h,r),r.matrix!==void 0){let u=new Pe;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return i.associations.has(h)||i.associations.set(h,{}),i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],i=this,r=new nn;n.name&&(r.name=i.createUniqueName(n.name)),Rn(r,n),n.extensions&&ci(t,r,n);let o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(i.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let h=0,u=c.length;h<u;h++)r.add(c[h]);let l=h=>{let u=new Map;for(let[d,p]of i.associations)(d instanceof Dt||d instanceof mt)&&u.set(d,p);return h.traverse(d=>{let p=i.associations.get(d);p!=null&&u.set(d,p)}),u};return i.associations=l(r),r})}_createAnimationTracks(e,t,n,i,r){let o=[],a=e.name?e.name:e.uuid,c=[];qn[r.path]===qn.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(a);let l;switch(qn[r.path]){case qn.weights:l=An;break;case qn.rotation:l=Tn;break;case qn.position:case qn.scale:l=En;break;default:switch(n.itemSize){case 1:l=An;break;case 2:case 3:default:l=En;break}break}let h=i.interpolation!==void 0?n_[i.interpolation]:zi,u=this._getArrayFromAccessor(n);for(let d=0,p=c.length;d<p;d++){let g=new l(c[d]+"."+qn[r.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Cc(t.constructor),i=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let i=this instanceof Tn?wc:Wr;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function l_(s,e,t){let n=e.attributes,i=new kt;if(n.POSITION!==void 0){let a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(i.set(new L(c[0],c[1],c[2]),new L(l[0],l[1],l[2])),a.normalized){let h=Cc(Zi[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let r=e.targets;if(r!==void 0){let a=new L,c=new L;for(let l=0,h=r.length;l<h;l++){let u=r[l];if(u.POSITION!==void 0){let d=t.json.accessors[u.POSITION],p=d.min,g=d.max;if(p!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(g[2]))),d.normalized){let _=Cc(Zi[d.componentType]);c.multiplyScalar(_)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;let o=new Lt;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function Ih(s,e,t){let n=e.attributes,i=[];function r(o,a){return t.getDependency("accessor",o).then(function(c){s.setAttribute(a,c)})}for(let o in n){let a=Rc[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(e.indices!==void 0&&!s.index){let o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});i.push(o)}return Fe.workingColorSpace!==St&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Fe.workingColorSpace}" not supported.`),Rn(s,e),l_(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?s_(s,e.targets,t):s})}window.THREE={WebGLRenderer:xr,Scene:vr,PerspectiveCamera:ht,AmbientLight:Ur,HemisphereLight:Lr,DirectionalLight:qi,AnimationMixer:Br,Clock:Fr,Color:Se,MeshStandardMaterial:Vn,Vector3:L,LoopOnce:Za,LoopRepeat:Ka,SRGBColorSpace:lt,ACESFilmicToneMapping:za,GLTFLoader:Gr};})();
|