aicodeswitch 5.2.13 → 6.0.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.
@@ -0,0 +1,3802 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2010-2024 Three.js Authors
4
+ * SPDX-License-Identifier: MIT
5
+ */const $r="165",rp={ROTATE:0,DOLLY:1,PAN:2},sp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},bo=0,hs=1,wo=2,Ba=1,Ro=2,Ye=3,hn=0,xe=1,Ke=2,ln=0,Yn=1,us=2,ds=3,fs=4,Co=5,Tn=100,Po=101,Lo=102,Uo=103,Do=104,Io=200,No=201,Fo=202,Oo=203,Hr=204,Gr=205,Bo=206,zo=207,Ho=208,Go=209,Vo=210,ko=211,Wo=212,Xo=213,qo=214,Yo=0,Ko=1,$o=2,Xi=3,Zo=4,jo=5,Jo=6,Qo=7,za=0,tl=1,el=2,cn=0,nl=1,il=2,rl=3,sl=4,al=5,ol=6,ll=7,Ha=300,Zn=301,jn=302,Vr=303,kr=304,Ji=306,Wr=1e3,bn=1001,Xr=1002,we=1003,cl=1004,Mi=1005,Le=1006,or=1007,wn=1008,un=1009,hl=1010,ul=1011,qi=1012,Ga=1013,Jn=1014,on=1015,Qi=1016,Va=1017,ka=1018,Qn=1020,dl=35902,fl=1021,pl=1022,ze=1023,ml=1024,_l=1025,Kn=1026,ti=1027,gl=1028,Wa=1029,vl=1030,Xa=1031,qa=1033,lr=33776,cr=33777,hr=33778,ur=33779,ps=35840,ms=35841,_s=35842,gs=35843,vs=36196,xs=37492,Ms=37496,Ss=37808,Es=37809,ys=37810,Ts=37811,As=37812,bs=37813,ws=37814,Rs=37815,Cs=37816,Ps=37817,Ls=37818,Us=37819,Ds=37820,Is=37821,dr=36492,Ns=36494,Fs=36495,xl=36283,Os=36284,Bs=36285,zs=36286,Ml=3200,Sl=3201,Ya=0,El=1,an="",Fe="srgb",fn="srgb-linear",Zr="display-p3",tr="display-p3-linear",Yi="linear",$t="srgb",Ki="rec709",$i="p3",Cn=7680,Hs=519,yl=512,Tl=513,Al=514,Ka=515,bl=516,wl=517,Rl=518,Cl=519,qr=35044,Gs="300 es",$e=2e3,Zi=2001;class ni{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const r=this._listeners[t];if(r!==void 0){const s=r.indexOf(e);s!==-1&&r.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,t);t.target=null}}}const de=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Vs=1234567;const hi=Math.PI/180,di=180/Math.PI;function je(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(de[i&255]+de[i>>8&255]+de[i>>16&255]+de[i>>24&255]+"-"+de[t&255]+de[t>>8&255]+"-"+de[t>>16&15|64]+de[t>>24&255]+"-"+de[e&63|128]+de[e>>8&255]+"-"+de[e>>16&255]+de[e>>24&255]+de[n&255]+de[n>>8&255]+de[n>>16&255]+de[n>>24&255]).toLowerCase()}function ue(i,t,e){return Math.max(t,Math.min(e,i))}function jr(i,t){return(i%t+t)%t}function Pl(i,t,e,n,r){return n+(i-t)*(r-n)/(e-t)}function Ll(i,t,e){return i!==t?(e-i)/(t-i):0}function ui(i,t,e){return(1-e)*i+e*t}function Ul(i,t,e,n){return ui(i,t,1-Math.exp(-e*n))}function Dl(i,t=1){return t-Math.abs(jr(i,t*2)-t)}function Il(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Nl(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Fl(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Ol(i,t){return i+Math.random()*(t-i)}function Bl(i){return i*(.5-Math.random())}function zl(i){i!==void 0&&(Vs=i);let t=Vs+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Hl(i){return i*hi}function Gl(i){return i*di}function Vl(i){return(i&i-1)===0&&i!==0}function kl(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Wl(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Xl(i,t,e,n,r){const s=Math.cos,o=Math.sin,a=s(e/2),l=o(e/2),c=s((t+n)/2),u=o((t+n)/2),f=s((t-n)/2),p=o((t-n)/2),m=s((n-t)/2),_=o((n-t)/2);switch(r){case"XYX":i.set(a*u,l*f,l*p,a*c);break;case"YZY":i.set(l*p,a*u,l*f,a*c);break;case"ZXZ":i.set(l*f,l*p,a*u,a*c);break;case"XZX":i.set(a*u,l*_,l*m,a*c);break;case"YXY":i.set(l*m,a*u,l*_,a*c);break;case"ZYZ":i.set(l*_,l*m,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ue(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Wt(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const ap={DEG2RAD:hi,RAD2DEG:di,generateUUID:je,clamp:ue,euclideanModulo:jr,mapLinear:Pl,inverseLerp:Ll,lerp:ui,damp:Ul,pingpong:Dl,smoothstep:Il,smootherstep:Nl,randInt:Fl,randFloat:Ol,randFloatSpread:Bl,seededRandom:zl,degToRad:Hl,radToDeg:Gl,isPowerOfTwo:Vl,ceilPowerOfTwo:kl,floorPowerOfTwo:Wl,setQuaternionFromProperEuler:Xl,normalize:Wt,denormalize:Ue};class Dt{constructor(t=0,e=0){Dt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ue(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*n-o*r+t.x,this.y=s*r+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class bt{constructor(t,e,n,r,s,o,a,l,c){bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,l,c)}set(t,e,n,r,s,o,a,l,c){const u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],f=n[7],p=n[2],m=n[5],_=n[8],x=r[0],d=r[3],h=r[6],y=r[1],S=r[4],A=r[7],F=r[2],b=r[5],C=r[8];return s[0]=o*x+a*y+l*F,s[3]=o*d+a*S+l*b,s[6]=o*h+a*A+l*C,s[1]=c*x+u*y+f*F,s[4]=c*d+u*S+f*b,s[7]=c*h+u*A+f*C,s[2]=p*x+m*y+_*F,s[5]=p*d+m*S+_*b,s[8]=p*h+m*A+_*C,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e*o*u-e*a*c-n*s*u+n*a*l+r*s*c-r*o*l}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],f=u*o-a*c,p=a*l-u*s,m=c*s-o*l,_=e*f+n*p+r*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/_;return t[0]=f*x,t[1]=(r*c-u*n)*x,t[2]=(a*n-r*o)*x,t[3]=p*x,t[4]=(u*e-r*l)*x,t[5]=(r*s-a*e)*x,t[6]=m*x,t[7]=(n*l-c*e)*x,t[8]=(o*e-n*s)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,s,o,a){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+t,-r*c,r*l,-r*(-c*o+l*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(fr.makeScale(t,e)),this}rotate(t){return this.premultiply(fr.makeRotation(-t)),this}translate(t,e){return this.premultiply(fr.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<9;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const fr=new bt;function $a(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function ji(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ql(){const i=ji("canvas");return i.style.display="block",i}const ks={};function Jr(i){i in ks||(ks[i]=!0,console.warn(i))}function Yl(i,t,e){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}const Ws=new bt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Xs=new bt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Si={[fn]:{transfer:Yi,primaries:Ki,toReference:i=>i,fromReference:i=>i},[Fe]:{transfer:$t,primaries:Ki,toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[tr]:{transfer:Yi,primaries:$i,toReference:i=>i.applyMatrix3(Xs),fromReference:i=>i.applyMatrix3(Ws)},[Zr]:{transfer:$t,primaries:$i,toReference:i=>i.convertSRGBToLinear().applyMatrix3(Xs),fromReference:i=>i.applyMatrix3(Ws).convertLinearToSRGB()}},Kl=new Set([fn,tr]),Xt={enabled:!0,_workingColorSpace:fn,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!Kl.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;const n=Si[t].toReference,r=Si[e].fromReference;return r(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this._workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this._workingColorSpace)},getPrimaries:function(i){return Si[i].primaries},getTransfer:function(i){return i===an?Yi:Si[i].transfer}};function $n(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function pr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Pn;class $l{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Pn===void 0&&(Pn=ji("canvas")),Pn.width=t.width,Pn.height=t.height;const n=Pn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Pn}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=ji("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=$n(s[o]/255)*255;return n.putImageData(r,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor($n(e[n]/255)*255):e[n]=$n(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let Zl=0;class Za{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Zl++}),this.uuid=je(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(mr(r[o].image)):s.push(mr(r[o]))}else s=mr(r);n.url=s}return e||(t.images[this.uuid]=n),n}}function mr(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?$l.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let jl=0;class ve extends ni{constructor(t=ve.DEFAULT_IMAGE,e=ve.DEFAULT_MAPPING,n=bn,r=bn,s=Le,o=wn,a=ze,l=un,c=ve.DEFAULT_ANISOTROPY,u=an){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:jl++}),this.uuid=je(),this.name="",this.source=new Za(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=c,this.format=a,this.internalFormat=null,this.type=l,this.offset=new Dt(0,0),this.repeat=new Dt(1,1),this.center=new Dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new bt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}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(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Ha)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Wr:t.x=t.x-Math.floor(t.x);break;case bn:t.x=t.x<0?0:1;break;case Xr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Wr:t.y=t.y-Math.floor(t.y);break;case bn:t.y=t.y<0?0:1;break;case Xr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ve.DEFAULT_IMAGE=null;ve.DEFAULT_MAPPING=Ha;ve.DEFAULT_ANISOTROPY=1;class Zt{constructor(t=0,e=0,n=0,r=1){Zt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,s;const l=t.elements,c=l[0],u=l[4],f=l[8],p=l[1],m=l[5],_=l[9],x=l[2],d=l[6],h=l[10];if(Math.abs(u-p)<.01&&Math.abs(f-x)<.01&&Math.abs(_-d)<.01){if(Math.abs(u+p)<.1&&Math.abs(f+x)<.1&&Math.abs(_+d)<.1&&Math.abs(c+m+h-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const S=(c+1)/2,A=(m+1)/2,F=(h+1)/2,b=(u+p)/4,C=(f+x)/4,O=(_+d)/4;return S>A&&S>F?S<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(S),r=b/n,s=C/n):A>F?A<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(A),n=b/r,s=O/r):F<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(F),n=C/s,r=O/s),this.set(n,r,s,e),this}let y=Math.sqrt((d-_)*(d-_)+(f-x)*(f-x)+(p-u)*(p-u));return Math.abs(y)<.001&&(y=1),this.x=(d-_)/y,this.y=(f-x)/y,this.z=(p-u)/y,this.w=Math.acos((c+m+h-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Jl extends ni{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Zt(0,0,t,e),this.scissorTest=!1,this.viewport=new Zt(0,0,t,e);const r={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Le,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ve(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.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(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let r=0,s=this.textures.length;r<s;r++)this.textures[r].image.width=t,this.textures[r].image.height=e,this.textures[r].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,r=t.textures.length;n<r;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Za(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Rn extends Jl{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class ja extends ve{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=we,this.minFilter=we,this.wrapR=bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Ql extends ve{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=we,this.minFilter=we,this.wrapR=bn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class fi{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,s,o,a){let l=n[r+0],c=n[r+1],u=n[r+2],f=n[r+3];const p=s[o+0],m=s[o+1],_=s[o+2],x=s[o+3];if(a===0){t[e+0]=l,t[e+1]=c,t[e+2]=u,t[e+3]=f;return}if(a===1){t[e+0]=p,t[e+1]=m,t[e+2]=_,t[e+3]=x;return}if(f!==x||l!==p||c!==m||u!==_){let d=1-a;const h=l*p+c*m+u*_+f*x,y=h>=0?1:-1,S=1-h*h;if(S>Number.EPSILON){const F=Math.sqrt(S),b=Math.atan2(F,h*y);d=Math.sin(d*b)/F,a=Math.sin(a*b)/F}const A=a*y;if(l=l*d+p*A,c=c*d+m*A,u=u*d+_*A,f=f*d+x*A,d===1-a){const F=1/Math.sqrt(l*l+c*c+u*u+f*f);l*=F,c*=F,u*=F,f*=F}}t[e]=l,t[e+1]=c,t[e+2]=u,t[e+3]=f}static multiplyQuaternionsFlat(t,e,n,r,s,o){const a=n[r],l=n[r+1],c=n[r+2],u=n[r+3],f=s[o],p=s[o+1],m=s[o+2],_=s[o+3];return t[e]=a*_+u*f+l*m-c*p,t[e+1]=l*_+u*p+c*f-a*m,t[e+2]=c*_+u*m+a*p-l*f,t[e+3]=u*_-a*f-l*p-c*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,r=t._y,s=t._z,o=t._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(r/2),f=a(s/2),p=l(n/2),m=l(r/2),_=l(s/2);switch(o){case"XYZ":this._x=p*u*f+c*m*_,this._y=c*m*f-p*u*_,this._z=c*u*_+p*m*f,this._w=c*u*f-p*m*_;break;case"YXZ":this._x=p*u*f+c*m*_,this._y=c*m*f-p*u*_,this._z=c*u*_-p*m*f,this._w=c*u*f+p*m*_;break;case"ZXY":this._x=p*u*f-c*m*_,this._y=c*m*f+p*u*_,this._z=c*u*_+p*m*f,this._w=c*u*f-p*m*_;break;case"ZYX":this._x=p*u*f-c*m*_,this._y=c*m*f+p*u*_,this._z=c*u*_-p*m*f,this._w=c*u*f+p*m*_;break;case"YZX":this._x=p*u*f+c*m*_,this._y=c*m*f+p*u*_,this._z=c*u*_-p*m*f,this._w=c*u*f-p*m*_;break;case"XZY":this._x=p*u*f-c*m*_,this._y=c*m*f-p*u*_,this._z=c*u*_+p*m*f,this._w=c*u*f+p*m*_;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],s=e[8],o=e[1],a=e[5],l=e[9],c=e[2],u=e[6],f=e[10],p=n+a+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(u-l)*m,this._y=(s-c)*m,this._z=(o-r)*m}else if(n>a&&n>f){const m=2*Math.sqrt(1+n-a-f);this._w=(u-l)/m,this._x=.25*m,this._y=(r+o)/m,this._z=(s+c)/m}else if(a>f){const m=2*Math.sqrt(1+a-n-f);this._w=(s-c)/m,this._x=(r+o)/m,this._y=.25*m,this._z=(l+u)/m}else{const m=2*Math.sqrt(1+f-n-a);this._w=(o-r)/m,this._x=(s+c)/m,this._y=(l+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ue(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const r=Math.min(1,e/n);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,s=t._z,o=t._w,a=e._x,l=e._y,c=e._z,u=e._w;return this._x=n*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-r*a,this._w=o*u-n*a-r*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,r=this._y,s=this._z,o=this._w;let a=o*t._w+n*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=s,this;const l=1-a*a;if(l<=Number.EPSILON){const m=1-e;return this._w=m*o+e*this._w,this._x=m*n+e*this._x,this._y=m*r+e*this._y,this._z=m*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),u=Math.atan2(c,a),f=Math.sin((1-e)*u)/c,p=Math.sin(e*u)/c;return this._w=o*f+this._w*p,this._x=n*f+this._x*p,this._y=r*f+this._y*p,this._z=s*f+this._z*p,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class U{constructor(t=0,e=0,n=0){U.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(qs.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(qs.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*r,this.y=s[1]*e+s[4]*n+s[7]*r,this.z=s[2]*e+s[5]*n+s[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,s=t.elements,o=1/(s[3]*e+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*e+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,s=t.x,o=t.y,a=t.z,l=t.w,c=2*(o*r-a*n),u=2*(a*e-s*r),f=2*(s*n-o*e);return this.x=e+l*c+o*f-a*u,this.y=n+l*u+a*c-s*f,this.z=r+l*f+s*u-o*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*r,this.y=s[1]*e+s[5]*n+s[9]*r,this.z=s[2]*e+s[6]*n+s[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,s=t.z,o=e.x,a=e.y,l=e.z;return this.x=r*l-s*a,this.y=s*o-n*l,this.z=n*a-r*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return _r.copy(this).projectOnVector(t),this.sub(_r)}reflect(t){return this.sub(_r.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(ue(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _r=new U,qs=new fi;class pi{constructor(t=new U(1/0,1/0,1/0),e=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Re.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Re.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Re.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const s=n.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Re):Re.fromBufferAttribute(s,o),Re.applyMatrix4(t.matrixWorld),this.expandByPoint(Re);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ei.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Ei.copy(n.boundingBox)),Ei.applyMatrix4(t.matrixWorld),this.union(Ei)}const r=t.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Re),Re.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(ri),yi.subVectors(this.max,ri),Ln.subVectors(t.a,ri),Un.subVectors(t.b,ri),Dn.subVectors(t.c,ri),Qe.subVectors(Un,Ln),tn.subVectors(Dn,Un),_n.subVectors(Ln,Dn);let e=[0,-Qe.z,Qe.y,0,-tn.z,tn.y,0,-_n.z,_n.y,Qe.z,0,-Qe.x,tn.z,0,-tn.x,_n.z,0,-_n.x,-Qe.y,Qe.x,0,-tn.y,tn.x,0,-_n.y,_n.x,0];return!gr(e,Ln,Un,Dn,yi)||(e=[1,0,0,0,1,0,0,0,1],!gr(e,Ln,Un,Dn,yi))?!1:(Ti.crossVectors(Qe,tn),e=[Ti.x,Ti.y,Ti.z],gr(e,Ln,Un,Dn,yi))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Re).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Re).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ve[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ve[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ve[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ve[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ve[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ve[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ve[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ve[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ve),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Ve=[new U,new U,new U,new U,new U,new U,new U,new U],Re=new U,Ei=new pi,Ln=new U,Un=new U,Dn=new U,Qe=new U,tn=new U,_n=new U,ri=new U,yi=new U,Ti=new U,gn=new U;function gr(i,t,e,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){gn.fromArray(i,s);const a=r.x*Math.abs(gn.x)+r.y*Math.abs(gn.y)+r.z*Math.abs(gn.z),l=t.dot(gn),c=e.dot(gn),u=n.dot(gn);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}const tc=new pi,si=new U,vr=new U;class Qr{constructor(t=new U,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):tc.setFromPoints(t).getCenter(n);let r=0;for(let s=0,o=t.length;s<o;s++)r=Math.max(r,n.distanceToSquared(t[s]));return this.radius=Math.sqrt(r),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;si.subVectors(t,this.center);const e=si.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),r=(n-this.radius)*.5;this.center.addScaledVector(si,r/n),this.radius+=r}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(vr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(si.copy(t.center).add(vr)),this.expandByPoint(si.copy(t.center).sub(vr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const ke=new U,xr=new U,Ai=new U,en=new U,Mr=new U,bi=new U,Sr=new U;class Ja{constructor(t=new U,e=new U(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ke)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=ke.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ke.copy(this.origin).addScaledVector(this.direction,e),ke.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){xr.copy(t).add(e).multiplyScalar(.5),Ai.copy(e).sub(t).normalize(),en.copy(this.origin).sub(xr);const s=t.distanceTo(e)*.5,o=-this.direction.dot(Ai),a=en.dot(this.direction),l=-en.dot(Ai),c=en.lengthSq(),u=Math.abs(1-o*o);let f,p,m,_;if(u>0)if(f=o*l-a,p=o*a-l,_=s*u,f>=0)if(p>=-_)if(p<=_){const x=1/u;f*=x,p*=x,m=f*(f+o*p+2*a)+p*(o*f+p+2*l)+c}else p=s,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;else p=-s,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;else p<=-_?(f=Math.max(0,-(-o*s+a)),p=f>0?-s:Math.min(Math.max(-s,-l),s),m=-f*f+p*(p+2*l)+c):p<=_?(f=0,p=Math.min(Math.max(-s,-l),s),m=p*(p+2*l)+c):(f=Math.max(0,-(o*s+a)),p=f>0?s:Math.min(Math.max(-s,-l),s),m=-f*f+p*(p+2*l)+c);else p=o>0?-s:s,f=Math.max(0,-(o*p+a)),m=-f*f+p*(p+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,f),r&&r.copy(xr).addScaledVector(Ai,p),m}intersectSphere(t,e){ke.subVectors(t.center,this.origin);const n=ke.dot(this.direction),r=ke.dot(ke)-n*n,s=t.radius*t.radius;if(r>s)return null;const o=Math.sqrt(s-r),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,s,o,a,l;const c=1/this.direction.x,u=1/this.direction.y,f=1/this.direction.z,p=this.origin;return c>=0?(n=(t.min.x-p.x)*c,r=(t.max.x-p.x)*c):(n=(t.max.x-p.x)*c,r=(t.min.x-p.x)*c),u>=0?(s=(t.min.y-p.y)*u,o=(t.max.y-p.y)*u):(s=(t.max.y-p.y)*u,o=(t.min.y-p.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),f>=0?(a=(t.min.z-p.z)*f,l=(t.max.z-p.z)*f):(a=(t.max.z-p.z)*f,l=(t.min.z-p.z)*f),n>l||a>r)||((a>n||n!==n)&&(n=a),(l<r||r!==r)&&(r=l),r<0)?null:this.at(n>=0?n:r,e)}intersectsBox(t){return this.intersectBox(t,ke)!==null}intersectTriangle(t,e,n,r,s){Mr.subVectors(e,t),bi.subVectors(n,t),Sr.crossVectors(Mr,bi);let o=this.direction.dot(Sr),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;en.subVectors(this.origin,t);const l=a*this.direction.dot(bi.crossVectors(en,bi));if(l<0)return null;const c=a*this.direction.dot(Mr.cross(en));if(c<0||l+c>o)return null;const u=-a*en.dot(Sr);return u<0?null:this.at(u/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Jt{constructor(t,e,n,r,s,o,a,l,c,u,f,p,m,_,x,d){Jt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,r,s,o,a,l,c,u,f,p,m,_,x,d)}set(t,e,n,r,s,o,a,l,c,u,f,p,m,_,x,d){const h=this.elements;return h[0]=t,h[4]=e,h[8]=n,h[12]=r,h[1]=s,h[5]=o,h[9]=a,h[13]=l,h[2]=c,h[6]=u,h[10]=f,h[14]=p,h[3]=m,h[7]=_,h[11]=x,h[15]=d,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 Jt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/In.setFromMatrixColumn(t,0).length(),s=1/In.setFromMatrixColumn(t,1).length(),o=1/In.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,s=t.z,o=Math.cos(n),a=Math.sin(n),l=Math.cos(r),c=Math.sin(r),u=Math.cos(s),f=Math.sin(s);if(t.order==="XYZ"){const p=o*u,m=o*f,_=a*u,x=a*f;e[0]=l*u,e[4]=-l*f,e[8]=c,e[1]=m+_*c,e[5]=p-x*c,e[9]=-a*l,e[2]=x-p*c,e[6]=_+m*c,e[10]=o*l}else if(t.order==="YXZ"){const p=l*u,m=l*f,_=c*u,x=c*f;e[0]=p+x*a,e[4]=_*a-m,e[8]=o*c,e[1]=o*f,e[5]=o*u,e[9]=-a,e[2]=m*a-_,e[6]=x+p*a,e[10]=o*l}else if(t.order==="ZXY"){const p=l*u,m=l*f,_=c*u,x=c*f;e[0]=p-x*a,e[4]=-o*f,e[8]=_+m*a,e[1]=m+_*a,e[5]=o*u,e[9]=x-p*a,e[2]=-o*c,e[6]=a,e[10]=o*l}else if(t.order==="ZYX"){const p=o*u,m=o*f,_=a*u,x=a*f;e[0]=l*u,e[4]=_*c-m,e[8]=p*c+x,e[1]=l*f,e[5]=x*c+p,e[9]=m*c-_,e[2]=-c,e[6]=a*l,e[10]=o*l}else if(t.order==="YZX"){const p=o*l,m=o*c,_=a*l,x=a*c;e[0]=l*u,e[4]=x-p*f,e[8]=_*f+m,e[1]=f,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=m*f+_,e[10]=p-x*f}else if(t.order==="XZY"){const p=o*l,m=o*c,_=a*l,x=a*c;e[0]=l*u,e[4]=-f,e[8]=c*u,e[1]=p*f+x,e[5]=o*u,e[9]=m*f-_,e[2]=_*f-m,e[6]=a*u,e[10]=x*f+p}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ec,t,nc)}lookAt(t,e,n){const r=this.elements;return Se.subVectors(t,e),Se.lengthSq()===0&&(Se.z=1),Se.normalize(),nn.crossVectors(n,Se),nn.lengthSq()===0&&(Math.abs(n.z)===1?Se.x+=1e-4:Se.z+=1e-4,Se.normalize(),nn.crossVectors(n,Se)),nn.normalize(),wi.crossVectors(Se,nn),r[0]=nn.x,r[4]=wi.x,r[8]=Se.x,r[1]=nn.y,r[5]=wi.y,r[9]=Se.y,r[2]=nn.z,r[6]=wi.z,r[10]=Se.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,s=this.elements,o=n[0],a=n[4],l=n[8],c=n[12],u=n[1],f=n[5],p=n[9],m=n[13],_=n[2],x=n[6],d=n[10],h=n[14],y=n[3],S=n[7],A=n[11],F=n[15],b=r[0],C=r[4],O=r[8],E=r[12],M=r[1],P=r[5],X=r[9],z=r[13],W=r[2],K=r[6],G=r[10],J=r[14],H=r[3],ct=r[7],dt=r[11],pt=r[15];return s[0]=o*b+a*M+l*W+c*H,s[4]=o*C+a*P+l*K+c*ct,s[8]=o*O+a*X+l*G+c*dt,s[12]=o*E+a*z+l*J+c*pt,s[1]=u*b+f*M+p*W+m*H,s[5]=u*C+f*P+p*K+m*ct,s[9]=u*O+f*X+p*G+m*dt,s[13]=u*E+f*z+p*J+m*pt,s[2]=_*b+x*M+d*W+h*H,s[6]=_*C+x*P+d*K+h*ct,s[10]=_*O+x*X+d*G+h*dt,s[14]=_*E+x*z+d*J+h*pt,s[3]=y*b+S*M+A*W+F*H,s[7]=y*C+S*P+A*K+F*ct,s[11]=y*O+S*X+A*G+F*dt,s[15]=y*E+S*z+A*J+F*pt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],s=t[12],o=t[1],a=t[5],l=t[9],c=t[13],u=t[2],f=t[6],p=t[10],m=t[14],_=t[3],x=t[7],d=t[11],h=t[15];return _*(+s*l*f-r*c*f-s*a*p+n*c*p+r*a*m-n*l*m)+x*(+e*l*m-e*c*p+s*o*p-r*o*m+r*c*u-s*l*u)+d*(+e*c*f-e*a*m-s*o*f+n*o*m+s*a*u-n*c*u)+h*(-r*a*u-e*l*f+e*a*p+r*o*f-n*o*p+n*l*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],s=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],f=t[9],p=t[10],m=t[11],_=t[12],x=t[13],d=t[14],h=t[15],y=f*d*c-x*p*c+x*l*m-a*d*m-f*l*h+a*p*h,S=_*p*c-u*d*c-_*l*m+o*d*m+u*l*h-o*p*h,A=u*x*c-_*f*c+_*a*m-o*x*m-u*a*h+o*f*h,F=_*f*l-u*x*l-_*a*p+o*x*p+u*a*d-o*f*d,b=e*y+n*S+r*A+s*F;if(b===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/b;return t[0]=y*C,t[1]=(x*p*s-f*d*s-x*r*m+n*d*m+f*r*h-n*p*h)*C,t[2]=(a*d*s-x*l*s+x*r*c-n*d*c-a*r*h+n*l*h)*C,t[3]=(f*l*s-a*p*s-f*r*c+n*p*c+a*r*m-n*l*m)*C,t[4]=S*C,t[5]=(u*d*s-_*p*s+_*r*m-e*d*m-u*r*h+e*p*h)*C,t[6]=(_*l*s-o*d*s-_*r*c+e*d*c+o*r*h-e*l*h)*C,t[7]=(o*p*s-u*l*s+u*r*c-e*p*c-o*r*m+e*l*m)*C,t[8]=A*C,t[9]=(_*f*s-u*x*s-_*n*m+e*x*m+u*n*h-e*f*h)*C,t[10]=(o*x*s-_*a*s+_*n*c-e*x*c-o*n*h+e*a*h)*C,t[11]=(u*a*s-o*f*s-u*n*c+e*f*c+o*n*m-e*a*m)*C,t[12]=F*C,t[13]=(u*x*r-_*f*r+_*n*p-e*x*p-u*n*d+e*f*d)*C,t[14]=(_*a*r-o*x*r-_*n*l+e*x*l+o*n*d-e*a*d)*C,t[15]=(o*f*r-u*a*r+u*n*l-e*f*l-o*n*p+e*a*p)*C,this}scale(t){const e=this.elements,n=t.x,r=t.y,s=t.z;return e[0]*=n,e[4]*=r,e[8]*=s,e[1]*=n,e[5]*=r,e[9]*=s,e[2]*=n,e[6]*=r,e[10]*=s,e[3]*=n,e[7]*=r,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),s=1-n,o=t.x,a=t.y,l=t.z,c=s*o,u=s*a;return this.set(c*o+n,c*a-r*l,c*l+r*a,0,c*a+r*l,u*a+n,u*l-r*o,0,c*l-r*a,u*l+r*o,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,s,o){return this.set(1,n,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,s=e._x,o=e._y,a=e._z,l=e._w,c=s+s,u=o+o,f=a+a,p=s*c,m=s*u,_=s*f,x=o*u,d=o*f,h=a*f,y=l*c,S=l*u,A=l*f,F=n.x,b=n.y,C=n.z;return r[0]=(1-(x+h))*F,r[1]=(m+A)*F,r[2]=(_-S)*F,r[3]=0,r[4]=(m-A)*b,r[5]=(1-(p+h))*b,r[6]=(d+y)*b,r[7]=0,r[8]=(_+S)*C,r[9]=(d-y)*C,r[10]=(1-(p+x))*C,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let s=In.set(r[0],r[1],r[2]).length();const o=In.set(r[4],r[5],r[6]).length(),a=In.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Ce.copy(this);const c=1/s,u=1/o,f=1/a;return Ce.elements[0]*=c,Ce.elements[1]*=c,Ce.elements[2]*=c,Ce.elements[4]*=u,Ce.elements[5]*=u,Ce.elements[6]*=u,Ce.elements[8]*=f,Ce.elements[9]*=f,Ce.elements[10]*=f,e.setFromRotationMatrix(Ce),n.x=s,n.y=o,n.z=a,this}makePerspective(t,e,n,r,s,o,a=$e){const l=this.elements,c=2*s/(e-t),u=2*s/(n-r),f=(e+t)/(e-t),p=(n+r)/(n-r);let m,_;if(a===$e)m=-(o+s)/(o-s),_=-2*o*s/(o-s);else if(a===Zi)m=-o/(o-s),_=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=c,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=u,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=m,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,r,s,o,a=$e){const l=this.elements,c=1/(e-t),u=1/(n-r),f=1/(o-s),p=(e+t)*c,m=(n+r)*u;let _,x;if(a===$e)_=(o+s)*f,x=-2*f;else if(a===Zi)_=s*f,x=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-p,l[1]=0,l[5]=2*u,l[9]=0,l[13]=-m,l[2]=0,l[6]=0,l[10]=x,l[14]=-_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let r=0;r<16;r++)if(e[r]!==n[r])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const In=new U,Ce=new Jt,ec=new U(0,0,0),nc=new U(1,1,1),nn=new U,wi=new U,Se=new U,Ys=new Jt,Ks=new fi;class He{constructor(t=0,e=0,n=0,r=He.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,s=r[0],o=r[4],a=r[8],l=r[1],c=r[5],u=r[9],f=r[2],p=r[6],m=r[10];switch(e){case"XYZ":this._y=Math.asin(ue(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ue(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-f,s),this._z=0);break;case"ZXY":this._x=Math.asin(ue(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-ue(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(ue(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-f,s)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-ue(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ys.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ys,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Ks.setFromEuler(this),this.setFromQuaternion(Ks,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}He.DEFAULT_ORDER="XYZ";class ts{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let ic=0;const $s=new U,Nn=new fi,We=new Jt,Ri=new U,ai=new U,rc=new U,sc=new fi,Zs=new U(1,0,0),js=new U(0,1,0),Js=new U(0,0,1),Qs={type:"added"},ac={type:"removed"},Fn={type:"childadded",child:null},Er={type:"childremoved",child:null};class pe extends ni{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ic++}),this.uuid=je(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=pe.DEFAULT_UP.clone();const t=new U,e=new He,n=new fi,r=new U(1,1,1);function s(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Jt},normalMatrix:{value:new bt}}),this.matrix=new Jt,this.matrixWorld=new Jt,this.matrixAutoUpdate=pe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=pe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ts,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Nn.setFromAxisAngle(t,e),this.quaternion.multiply(Nn),this}rotateOnWorldAxis(t,e){return Nn.setFromAxisAngle(t,e),this.quaternion.premultiply(Nn),this}rotateX(t){return this.rotateOnAxis(Zs,t)}rotateY(t){return this.rotateOnAxis(js,t)}rotateZ(t){return this.rotateOnAxis(Js,t)}translateOnAxis(t,e){return $s.copy(t).applyQuaternion(this.quaternion),this.position.add($s.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Zs,t)}translateY(t){return this.translateOnAxis(js,t)}translateZ(t){return this.translateOnAxis(Js,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(We.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ri.copy(t):Ri.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),ai.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?We.lookAt(ai,Ri,this.up):We.lookAt(Ri,ai,this.up),this.quaternion.setFromRotationMatrix(We),r&&(We.extractRotation(r.matrixWorld),Nn.setFromRotationMatrix(We),this.quaternion.premultiply(Nn.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Qs),Fn.child=t,this.dispatchEvent(Fn),Fn.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(ac),Er.child=t,this.dispatchEvent(Er),Er.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),We.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),We.multiply(t.parent.matrixWorld)),t.applyMatrix4(We),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Qs),Fn.child=t,this.dispatchEvent(Fn),Fn.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){const o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ai,t,rc),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ai,sc,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++){const s=e[n];(s.matrixWorldAutoUpdate===!0||t===!0)&&s.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.matrixWorldAutoUpdate===!0&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){const r=this.children;for(let s=0,o=r.length;s<o;s++){const a=r[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(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()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c<u;c++){const f=l[c];s(t.shapes,f)}else s(t.shapes,l)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let l=0,c=this.material.length;l<c;l++)a.push(s(t.materials,this.material[l]));r.material=a}else r.material=s(t.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){const l=this.animations[a];r.animations.push(s(t.animations,l))}}if(e){const a=o(t.geometries),l=o(t.materials),c=o(t.textures),u=o(t.images),f=o(t.shapes),p=o(t.skeletons),m=o(t.animations),_=o(t.nodes);a.length>0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),f.length>0&&(n.shapes=f),p.length>0&&(n.skeletons=p),m.length>0&&(n.animations=m),_.length>0&&(n.nodes=_)}return n.object=r,n;function o(a){const l=[];for(const c in a){const u=a[c];delete u.metadata,l.push(u)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const r=t.children[n];this.add(r.clone())}return this}}pe.DEFAULT_UP=new U(0,1,0);pe.DEFAULT_MATRIX_AUTO_UPDATE=!0;pe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Pe=new U,Xe=new U,yr=new U,qe=new U,On=new U,Bn=new U,ta=new U,Tr=new U,Ar=new U,br=new U;class Be{constructor(t=new U,e=new U,n=new U){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),Pe.subVectors(t,e),r.cross(Pe);const s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(t,e,n,r,s){Pe.subVectors(r,e),Xe.subVectors(n,e),yr.subVectors(t,e);const o=Pe.dot(Pe),a=Pe.dot(Xe),l=Pe.dot(yr),c=Xe.dot(Xe),u=Xe.dot(yr),f=o*c-a*a;if(f===0)return s.set(0,0,0),null;const p=1/f,m=(c*l-a*u)*p,_=(o*u-a*l)*p;return s.set(1-m-_,_,m)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,qe)===null?!1:qe.x>=0&&qe.y>=0&&qe.x+qe.y<=1}static getInterpolation(t,e,n,r,s,o,a,l){return this.getBarycoord(t,e,n,r,qe)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,qe.x),l.addScaledVector(o,qe.y),l.addScaledVector(a,qe.z),l)}static isFrontFacing(t,e,n,r){return Pe.subVectors(n,e),Xe.subVectors(t,e),Pe.cross(Xe).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Pe.subVectors(this.c,this.b),Xe.subVectors(this.a,this.b),Pe.cross(Xe).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Be.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Be.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,r,s){return Be.getInterpolation(t,this.a,this.b,this.c,e,n,r,s)}containsPoint(t){return Be.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Be.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,s=this.c;let o,a;On.subVectors(r,n),Bn.subVectors(s,n),Tr.subVectors(t,n);const l=On.dot(Tr),c=Bn.dot(Tr);if(l<=0&&c<=0)return e.copy(n);Ar.subVectors(t,r);const u=On.dot(Ar),f=Bn.dot(Ar);if(u>=0&&f<=u)return e.copy(r);const p=l*f-u*c;if(p<=0&&l>=0&&u<=0)return o=l/(l-u),e.copy(n).addScaledVector(On,o);br.subVectors(t,s);const m=On.dot(br),_=Bn.dot(br);if(_>=0&&m<=_)return e.copy(s);const x=m*c-l*_;if(x<=0&&c>=0&&_<=0)return a=c/(c-_),e.copy(n).addScaledVector(Bn,a);const d=u*_-m*f;if(d<=0&&f-u>=0&&m-_>=0)return ta.subVectors(s,r),a=(f-u)/(f-u+(m-_)),e.copy(r).addScaledVector(ta,a);const h=1/(d+x+p);return o=x*h,a=p*h,e.copy(n).addScaledVector(On,o).addScaledVector(Bn,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Qa={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},rn={h:0,s:0,l:0},Ci={h:0,s:0,l:0};function wr(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Ht{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const r=t;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Fe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Xt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,r=Xt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Xt.toWorkingColorSpace(this,r),this}setHSL(t,e,n,r=Xt.workingColorSpace){if(t=jr(t,1),e=ue(e,0,1),n=ue(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,o=2*n-s;this.r=wr(o,s,t+1/3),this.g=wr(o,s,t),this.b=wr(o,s,t-1/3)}return Xt.toWorkingColorSpace(this,r),this}setStyle(t,e=Fe){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Fe){const n=Qa[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=$n(t.r),this.g=$n(t.g),this.b=$n(t.b),this}copyLinearToSRGB(t){return this.r=pr(t.r),this.g=pr(t.g),this.b=pr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Fe){return Xt.fromWorkingColorSpace(fe.copy(this),t),Math.round(ue(fe.r*255,0,255))*65536+Math.round(ue(fe.g*255,0,255))*256+Math.round(ue(fe.b*255,0,255))}getHexString(t=Fe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Xt.workingColorSpace){Xt.fromWorkingColorSpace(fe.copy(this),e);const n=fe.r,r=fe.g,s=fe.b,o=Math.max(n,r,s),a=Math.min(n,r,s);let l,c;const u=(a+o)/2;if(a===o)l=0,c=0;else{const f=o-a;switch(c=u<=.5?f/(o+a):f/(2-o-a),o){case n:l=(r-s)/f+(r<s?6:0);break;case r:l=(s-n)/f+2;break;case s:l=(n-r)/f+4;break}l/=6}return t.h=l,t.s=c,t.l=u,t}getRGB(t,e=Xt.workingColorSpace){return Xt.fromWorkingColorSpace(fe.copy(this),e),t.r=fe.r,t.g=fe.g,t.b=fe.b,t}getStyle(t=Fe){Xt.fromWorkingColorSpace(fe.copy(this),t);const e=fe.r,n=fe.g,r=fe.b;return t!==Fe?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(t,e,n){return this.getHSL(rn),this.setHSL(rn.h+t,rn.s+e,rn.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(rn),t.getHSL(Ci);const n=ui(rn.h,Ci.h,e),r=ui(rn.s,Ci.s,e),s=ui(rn.l,Ci.l,e);return this.setHSL(n,r,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,r=this.b,s=t.elements;return this.r=s[0]*e+s[3]*n+s[6]*r,this.g=s[1]*e+s[4]*n+s[7]*r,this.b=s[2]*e+s[5]*n+s[8]*r,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const fe=new Ht;Ht.NAMES=Qa;let oc=0;class mi extends ni{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:oc++}),this.uuid=je(),this.name="",this.type="Material",this.blending=Yn,this.side=hn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Hr,this.blendDst=Gr,this.blendEquation=Tn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Ht(0,0,0),this.blendAlpha=0,this.depthFunc=Xi,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Hs,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Cn,this.stencilZFail=Cn,this.stencilZPass=Cn,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const r=this[e];if(r===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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!==Yn&&(n.blending=this.blending),this.side!==hn&&(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!==Hr&&(n.blendSrc=this.blendSrc),this.blendDst!==Gr&&(n.blendDst=this.blendDst),this.blendEquation!==Tn&&(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!==Xi&&(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!==Hs&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Cn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Cn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Cn&&(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 r(s){const o=[];for(const a in s){const l=s[a];delete l.metadata,o.push(l)}return o}if(e){const s=r(t.textures),o=r(t.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const r=e.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class to extends mi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ht(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 He,this.combine=za,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const re=new U,Pi=new Dt;class De{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=qr,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=on,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Jr("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,s=this.itemSize;r<s;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Pi.fromBufferAttribute(this,e),Pi.applyMatrix3(t),this.setXY(e,Pi.x,Pi.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.applyMatrix3(t),this.setXYZ(e,re.x,re.y,re.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.applyMatrix4(t),this.setXYZ(e,re.x,re.y,re.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.applyNormalMatrix(t),this.setXYZ(e,re.x,re.y,re.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)re.fromBufferAttribute(this,e),re.transformDirection(t),this.setXYZ(e,re.x,re.y,re.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Ue(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Wt(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Ue(e,this.array)),e}setX(t,e){return this.normalized&&(e=Wt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Ue(e,this.array)),e}setY(t,e){return this.normalized&&(e=Wt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Ue(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Wt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Ue(e,this.array)),e}setW(t,e){return this.normalized&&(e=Wt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t*=this.itemSize,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array),s=Wt(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==qr&&(t.usage=this.usage),t}}class eo extends De{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class no extends De{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class se extends De{constructor(t,e,n){super(new Float32Array(t),e,n)}}let lc=0;const Ae=new Jt,Rr=new pe,zn=new U,Ee=new pi,oi=new pi,he=new U;class ye extends ni{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:lc++}),this.uuid=je(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new($a(t)?no:eo)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const s=new bt().getNormalMatrix(t);n.applyNormalMatrix(s),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(t),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Ae.makeRotationFromQuaternion(t),this.applyMatrix4(Ae),this}rotateX(t){return Ae.makeRotationX(t),this.applyMatrix4(Ae),this}rotateY(t){return Ae.makeRotationY(t),this.applyMatrix4(Ae),this}rotateZ(t){return Ae.makeRotationZ(t),this.applyMatrix4(Ae),this}translate(t,e,n){return Ae.makeTranslation(t,e,n),this.applyMatrix4(Ae),this}scale(t,e,n){return Ae.makeScale(t,e,n),this.applyMatrix4(Ae),this}lookAt(t){return Rr.lookAt(t),Rr.updateMatrix(),this.applyMatrix4(Rr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(zn).negate(),this.translate(zn.x,zn.y,zn.z),this}setFromPoints(t){const e=[];for(let n=0,r=t.length;n<r;n++){const s=t[n];e.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new se(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new pi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,r=e.length;n<r;n++){const s=e[n];Ee.setFromBufferAttribute(s),this.morphTargetsRelative?(he.addVectors(this.boundingBox.min,Ee.min),this.boundingBox.expandByPoint(he),he.addVectors(this.boundingBox.max,Ee.max),this.boundingBox.expandByPoint(he)):(this.boundingBox.expandByPoint(Ee.min),this.boundingBox.expandByPoint(Ee.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 Qr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(t){const n=this.boundingSphere.center;if(Ee.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];oi.setFromBufferAttribute(a),this.morphTargetsRelative?(he.addVectors(Ee.min,oi.min),Ee.expandByPoint(he),he.addVectors(Ee.max,oi.max),Ee.expandByPoint(he)):(Ee.expandByPoint(oi.min),Ee.expandByPoint(oi.max))}Ee.getCenter(n);let r=0;for(let s=0,o=t.count;s<o;s++)he.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(he));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],l=this.morphTargetsRelative;for(let c=0,u=a.count;c<u;c++)he.fromBufferAttribute(a,c),l&&(zn.fromBufferAttribute(t,c),he.add(zn)),r=Math.max(r,n.distanceToSquared(he))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,r=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new De(new Float32Array(4*n.count),4));const o=this.getAttribute("tangent"),a=[],l=[];for(let O=0;O<n.count;O++)a[O]=new U,l[O]=new U;const c=new U,u=new U,f=new U,p=new Dt,m=new Dt,_=new Dt,x=new U,d=new U;function h(O,E,M){c.fromBufferAttribute(n,O),u.fromBufferAttribute(n,E),f.fromBufferAttribute(n,M),p.fromBufferAttribute(s,O),m.fromBufferAttribute(s,E),_.fromBufferAttribute(s,M),u.sub(c),f.sub(c),m.sub(p),_.sub(p);const P=1/(m.x*_.y-_.x*m.y);isFinite(P)&&(x.copy(u).multiplyScalar(_.y).addScaledVector(f,-m.y).multiplyScalar(P),d.copy(f).multiplyScalar(m.x).addScaledVector(u,-_.x).multiplyScalar(P),a[O].add(x),a[E].add(x),a[M].add(x),l[O].add(d),l[E].add(d),l[M].add(d))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let O=0,E=y.length;O<E;++O){const M=y[O],P=M.start,X=M.count;for(let z=P,W=P+X;z<W;z+=3)h(t.getX(z+0),t.getX(z+1),t.getX(z+2))}const S=new U,A=new U,F=new U,b=new U;function C(O){F.fromBufferAttribute(r,O),b.copy(F);const E=a[O];S.copy(E),S.sub(F.multiplyScalar(F.dot(E))).normalize(),A.crossVectors(b,E);const P=A.dot(l[O])<0?-1:1;o.setXYZW(O,S.x,S.y,S.z,P)}for(let O=0,E=y.length;O<E;++O){const M=y[O],P=M.start,X=M.count;for(let z=P,W=P+X;z<W;z+=3)C(t.getX(z+0)),C(t.getX(z+1)),C(t.getX(z+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new De(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let p=0,m=n.count;p<m;p++)n.setXYZ(p,0,0,0);const r=new U,s=new U,o=new U,a=new U,l=new U,c=new U,u=new U,f=new U;if(t)for(let p=0,m=t.count;p<m;p+=3){const _=t.getX(p+0),x=t.getX(p+1),d=t.getX(p+2);r.fromBufferAttribute(e,_),s.fromBufferAttribute(e,x),o.fromBufferAttribute(e,d),u.subVectors(o,s),f.subVectors(r,s),u.cross(f),a.fromBufferAttribute(n,_),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,d),a.add(u),l.add(u),c.add(u),n.setXYZ(_,a.x,a.y,a.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(d,c.x,c.y,c.z)}else for(let p=0,m=e.count;p<m;p+=3)r.fromBufferAttribute(e,p+0),s.fromBufferAttribute(e,p+1),o.fromBufferAttribute(e,p+2),u.subVectors(o,s),f.subVectors(r,s),u.cross(f),n.setXYZ(p+0,u.x,u.y,u.z),n.setXYZ(p+1,u.x,u.y,u.z),n.setXYZ(p+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)he.fromBufferAttribute(t,e),he.normalize(),t.setXYZ(e,he.x,he.y,he.z)}toNonIndexed(){function t(a,l){const c=a.array,u=a.itemSize,f=a.normalized,p=new c.constructor(l.length*u);let m=0,_=0;for(let x=0,d=l.length;x<d;x++){a.isInterleavedBufferAttribute?m=l[x]*a.data.stride+a.offset:m=l[x]*u;for(let h=0;h<u;h++)p[_++]=c[m++]}return new De(p,u,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ye,n=this.index.array,r=this.attributes;for(const a in r){const l=r[a],c=t(l,n);e.setAttribute(a,c)}const s=this.morphAttributes;for(const a in s){const l=[],c=s[a];for(let u=0,f=c.length;u<f;u++){const p=c[u],m=t(p,n);l.push(m)}e.morphAttributes[a]=l}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,l=o.length;a<l;a++){const c=o[a];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const r={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let f=0,p=c.length;f<p;f++){const m=c[f];u.push(m.toJSON(t.data))}u.length>0&&(r[l]=u,s=!0)}s&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const r=t.attributes;for(const c in r){const u=r[c];this.setAttribute(c,u.clone(e))}const s=t.morphAttributes;for(const c in s){const u=[],f=s[c];for(let p=0,m=f.length;p<m;p++)u.push(f[p].clone(e));this.morphAttributes[c]=u}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let c=0,u=o.length;c<u;c++){const f=o[c];this.addGroup(f.start,f.count,f.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const ea=new Jt,vn=new Ja,Li=new Qr,na=new U,Hn=new U,Gn=new U,Vn=new U,Cr=new U,Ui=new U,Di=new Dt,Ii=new Dt,Ni=new Dt,ia=new U,ra=new U,sa=new U,Fi=new U,Oi=new U;class Ze extends pe{constructor(t=new ye,e=new to){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const r=e[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){const a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(r,t);const a=this.morphTargetInfluences;if(s&&a){Ui.set(0,0,0);for(let l=0,c=s.length;l<c;l++){const u=a[l],f=s[l];u!==0&&(Cr.fromBufferAttribute(f,t),o?Ui.addScaledVector(Cr,u):Ui.addScaledVector(Cr.sub(e),u))}e.add(Ui)}return e}raycast(t,e){const n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Li.copy(n.boundingSphere),Li.applyMatrix4(s),vn.copy(t.ray).recast(t.near),!(Li.containsPoint(vn.origin)===!1&&(vn.intersectSphere(Li,na)===null||vn.origin.distanceToSquared(na)>(t.far-t.near)**2))&&(ea.copy(s).invert(),vn.copy(t.ray).applyMatrix4(ea),!(n.boundingBox!==null&&vn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,vn)))}_computeIntersections(t,e,n){let r;const s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,f=s.attributes.normal,p=s.groups,m=s.drawRange;if(a!==null)if(Array.isArray(o))for(let _=0,x=p.length;_<x;_++){const d=p[_],h=o[d.materialIndex],y=Math.max(d.start,m.start),S=Math.min(a.count,Math.min(d.start+d.count,m.start+m.count));for(let A=y,F=S;A<F;A+=3){const b=a.getX(A),C=a.getX(A+1),O=a.getX(A+2);r=Bi(this,h,t,n,c,u,f,b,C,O),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=d.materialIndex,e.push(r))}}else{const _=Math.max(0,m.start),x=Math.min(a.count,m.start+m.count);for(let d=_,h=x;d<h;d+=3){const y=a.getX(d),S=a.getX(d+1),A=a.getX(d+2);r=Bi(this,o,t,n,c,u,f,y,S,A),r&&(r.faceIndex=Math.floor(d/3),e.push(r))}}else if(l!==void 0)if(Array.isArray(o))for(let _=0,x=p.length;_<x;_++){const d=p[_],h=o[d.materialIndex],y=Math.max(d.start,m.start),S=Math.min(l.count,Math.min(d.start+d.count,m.start+m.count));for(let A=y,F=S;A<F;A+=3){const b=A,C=A+1,O=A+2;r=Bi(this,h,t,n,c,u,f,b,C,O),r&&(r.faceIndex=Math.floor(A/3),r.face.materialIndex=d.materialIndex,e.push(r))}}else{const _=Math.max(0,m.start),x=Math.min(l.count,m.start+m.count);for(let d=_,h=x;d<h;d+=3){const y=d,S=d+1,A=d+2;r=Bi(this,o,t,n,c,u,f,y,S,A),r&&(r.faceIndex=Math.floor(d/3),e.push(r))}}}}function cc(i,t,e,n,r,s,o,a){let l;if(t.side===xe?l=n.intersectTriangle(o,s,r,!0,a):l=n.intersectTriangle(r,s,o,t.side===hn,a),l===null)return null;Oi.copy(a),Oi.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Oi);return c<e.near||c>e.far?null:{distance:c,point:Oi.clone(),object:i}}function Bi(i,t,e,n,r,s,o,a,l,c){i.getVertexPosition(a,Hn),i.getVertexPosition(l,Gn),i.getVertexPosition(c,Vn);const u=cc(i,t,e,n,Hn,Gn,Vn,Fi);if(u){r&&(Di.fromBufferAttribute(r,a),Ii.fromBufferAttribute(r,l),Ni.fromBufferAttribute(r,c),u.uv=Be.getInterpolation(Fi,Hn,Gn,Vn,Di,Ii,Ni,new Dt)),s&&(Di.fromBufferAttribute(s,a),Ii.fromBufferAttribute(s,l),Ni.fromBufferAttribute(s,c),u.uv1=Be.getInterpolation(Fi,Hn,Gn,Vn,Di,Ii,Ni,new Dt)),o&&(ia.fromBufferAttribute(o,a),ra.fromBufferAttribute(o,l),sa.fromBufferAttribute(o,c),u.normal=Be.getInterpolation(Fi,Hn,Gn,Vn,ia,ra,sa,new U),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));const f={a,b:l,c,normal:new U,materialIndex:0};Be.getNormal(Hn,Gn,Vn,f.normal),u.face=f}return u}class _i extends ye{constructor(t=1,e=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};const a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);const l=[],c=[],u=[],f=[];let p=0,m=0;_("z","y","x",-1,-1,n,e,t,o,s,0),_("z","y","x",1,-1,n,e,-t,o,s,1),_("x","z","y",1,1,t,n,e,r,o,2),_("x","z","y",1,-1,t,n,-e,r,o,3),_("x","y","z",1,-1,t,e,n,r,s,4),_("x","y","z",-1,-1,t,e,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new se(c,3)),this.setAttribute("normal",new se(u,3)),this.setAttribute("uv",new se(f,2));function _(x,d,h,y,S,A,F,b,C,O,E){const M=A/C,P=F/O,X=A/2,z=F/2,W=b/2,K=C+1,G=O+1;let J=0,H=0;const ct=new U;for(let dt=0;dt<G;dt++){const pt=dt*P-z;for(let Ft=0;Ft<K;Ft++){const qt=Ft*M-X;ct[x]=qt*y,ct[d]=pt*S,ct[h]=W,c.push(ct.x,ct.y,ct.z),ct[x]=0,ct[d]=0,ct[h]=b>0?1:-1,u.push(ct.x,ct.y,ct.z),f.push(Ft/C),f.push(1-dt/O),J+=1}}for(let dt=0;dt<O;dt++)for(let pt=0;pt<C;pt++){const Ft=p+pt+K*dt,qt=p+pt+K*(dt+1),k=p+(pt+1)+K*(dt+1),j=p+(pt+1)+K*dt;l.push(Ft,qt,j),l.push(qt,k,j),H+=6}a.addGroup(m,H,E),m+=H,p+=J}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new _i(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function ei(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const r=i[e][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=r.clone():Array.isArray(r)?t[e][n]=r.slice():t[e][n]=r}}return t}function ge(i){const t={};for(let e=0;e<i.length;e++){const n=ei(i[e]);for(const r in n)t[r]=n[r]}return t}function hc(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function io(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Xt.workingColorSpace}const uc={clone:ei,merge:ge};var dc=`void main() {
6
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
7
+ }`,fc=`void main() {
8
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
9
+ }`;class dn extends mi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=dc,this.fragmentShader=fc,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,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=ei(t.uniforms),this.uniformsGroups=hc(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?e.uniforms[r]={type:"t",value:o.toJSON(t).uuid}:o&&o.isColor?e.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?e.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?e.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?e.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?e.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?e.uniforms[r]={type:"m4",value:o.toArray()}:e.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class ro extends pe{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Jt,this.projectionMatrix=new Jt,this.projectionMatrixInverse=new Jt,this.coordinateSystem=$e}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const sn=new U,aa=new Dt,oa=new Dt;class be extends ro{constructor(t=50,e=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=di*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(hi*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return di*2*Math.atan(Math.tan(hi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){sn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(sn.x,sn.y).multiplyScalar(-t/sn.z),sn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(sn.x,sn.y).multiplyScalar(-t/sn.z)}getViewSize(t,e){return this.getViewBounds(t,aa,oa),e.subVectors(oa,aa)}setViewOffset(t,e,n,r,s,o){this.aspect=t/e,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(hi*.5*this.fov)/this.zoom,n=2*e,r=this.aspect*n,s=-.5*r;const o=this.view;if(this.view!==null&&this.view.enabled){const l=o.fullWidth,c=o.fullHeight;s+=o.offsetX*r/l,e-=o.offsetY*n/c,r*=o.width/l,n*=o.height/c}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const kn=-90,Wn=1;class pc extends pe{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new be(kn,Wn,t,e);r.layers=this.layers,this.add(r);const s=new be(kn,Wn,t,e);s.layers=this.layers,this.add(s);const o=new be(kn,Wn,t,e);o.layers=this.layers,this.add(o);const a=new be(kn,Wn,t,e);a.layers=this.layers,this.add(a);const l=new be(kn,Wn,t,e);l.layers=this.layers,this.add(l);const c=new be(kn,Wn,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,r,s,o,a,l]=e;for(const c of e)this.remove(c);if(t===$e)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Zi)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,o,a,l,c,u]=this.children,f=t.getRenderTarget(),p=t.getActiveCubeFace(),m=t.getActiveMipmapLevel(),_=t.xr.enabled;t.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,r),t.render(e,s),t.setRenderTarget(n,1,r),t.render(e,o),t.setRenderTarget(n,2,r),t.render(e,a),t.setRenderTarget(n,3,r),t.render(e,l),t.setRenderTarget(n,4,r),t.render(e,c),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,r),t.render(e,u),t.setRenderTarget(f,p,m),t.xr.enabled=_,n.texture.needsPMREMUpdate=!0}}class so extends ve{constructor(t,e,n,r,s,o,a,l,c,u){t=t!==void 0?t:[],e=e!==void 0?e:Zn,super(t,e,n,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class mc extends Rn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},r=[n,n,n,n,n,n];this.texture=new so(r,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Le}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
10
+
11
+ varying vec3 vWorldDirection;
12
+
13
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
14
+
15
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
16
+
17
+ }
18
+
19
+ void main() {
20
+
21
+ vWorldDirection = transformDirection( position, modelMatrix );
22
+
23
+ #include <begin_vertex>
24
+ #include <project_vertex>
25
+
26
+ }
27
+ `,fragmentShader:`
28
+
29
+ uniform sampler2D tEquirect;
30
+
31
+ varying vec3 vWorldDirection;
32
+
33
+ #include <common>
34
+
35
+ void main() {
36
+
37
+ vec3 direction = normalize( vWorldDirection );
38
+
39
+ vec2 sampleUV = equirectUv( direction );
40
+
41
+ gl_FragColor = texture2D( tEquirect, sampleUV );
42
+
43
+ }
44
+ `},r=new _i(5,5,5),s=new dn({name:"CubemapFromEquirect",uniforms:ei(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:xe,blending:ln});s.uniforms.tEquirect.value=e;const o=new Ze(r,s),a=e.minFilter;return e.minFilter===wn&&(e.minFilter=Le),new pc(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,n,r){const s=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,r);t.setRenderTarget(s)}}const Pr=new U,_c=new U,gc=new bt;class En{constructor(t=new U(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=Pr.subVectors(n,e).cross(_c.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Pr),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||gc.getNormalMatrix(t),r=this.coplanarPoint(Pr).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const xn=new Qr,zi=new U;class es{constructor(t=new En,e=new En,n=new En,r=new En,s=new En,o=new En){this.planes=[t,e,n,r,s,o]}set(t,e,n,r,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=$e){const n=this.planes,r=t.elements,s=r[0],o=r[1],a=r[2],l=r[3],c=r[4],u=r[5],f=r[6],p=r[7],m=r[8],_=r[9],x=r[10],d=r[11],h=r[12],y=r[13],S=r[14],A=r[15];if(n[0].setComponents(l-s,p-c,d-m,A-h).normalize(),n[1].setComponents(l+s,p+c,d+m,A+h).normalize(),n[2].setComponents(l+o,p+u,d+_,A+y).normalize(),n[3].setComponents(l-o,p-u,d-_,A-y).normalize(),n[4].setComponents(l-a,p-f,d-x,A-S).normalize(),e===$e)n[5].setComponents(l+a,p+f,d+x,A+S).normalize();else if(e===Zi)n[5].setComponents(a,f,x,S).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),xn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),xn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(xn)}intersectsSprite(t){return xn.center.set(0,0,0),xn.radius=.7071067811865476,xn.applyMatrix4(t.matrixWorld),this.intersectsSphere(xn)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(zi.x=r.normal.x>0?t.max.x:t.min.x,zi.y=r.normal.y>0?t.max.y:t.min.y,zi.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(zi)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function ao(){let i=null,t=!1,e=null,n=null;function r(s,o){e(s,o),n=i.requestAnimationFrame(r)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(r),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){i=s}}}function vc(i){const t=new WeakMap;function e(a,l){const c=a.array,u=a.usage,f=c.byteLength,p=i.createBuffer();i.bindBuffer(l,p),i.bufferData(l,c,u),a.onUploadCallback();let m;if(c instanceof Float32Array)m=i.FLOAT;else if(c instanceof Uint16Array)a.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)m=i.SHORT;else if(c instanceof Uint32Array)m=i.UNSIGNED_INT;else if(c instanceof Int32Array)m=i.INT;else if(c instanceof Int8Array)m=i.BYTE;else if(c instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:p,type:m,bytesPerElement:c.BYTES_PER_ELEMENT,version:a.version,size:f}}function n(a,l,c){const u=l.array,f=l._updateRange,p=l.updateRanges;if(i.bindBuffer(c,a),f.count===-1&&p.length===0&&i.bufferSubData(c,0,u),p.length!==0){for(let m=0,_=p.length;m<_;m++){const x=p[m];i.bufferSubData(c,x.start*u.BYTES_PER_ELEMENT,u,x.start,x.count)}l.clearUpdateRanges()}f.count!==-1&&(i.bufferSubData(c,f.offset*u.BYTES_PER_ELEMENT,u,f.offset,f.count),f.count=-1),l.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);const l=t.get(a);l&&(i.deleteBuffer(l.buffer),t.delete(a))}function o(a,l){if(a.isGLBufferAttribute){const u=t.get(a);(!u||u.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}a.isInterleavedBufferAttribute&&(a=a.data);const c=t.get(a);if(c===void 0)t.set(a,e(a,l));else if(c.version<a.version){if(c.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(c.buffer,a,l),c.version=a.version}}return{get:r,remove:s,update:o}}class er extends ye{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const s=t/2,o=e/2,a=Math.floor(n),l=Math.floor(r),c=a+1,u=l+1,f=t/a,p=e/l,m=[],_=[],x=[],d=[];for(let h=0;h<u;h++){const y=h*p-o;for(let S=0;S<c;S++){const A=S*f-s;_.push(A,-y,0),x.push(0,0,1),d.push(S/a),d.push(1-h/l)}}for(let h=0;h<l;h++)for(let y=0;y<a;y++){const S=y+c*h,A=y+c*(h+1),F=y+1+c*(h+1),b=y+1+c*h;m.push(S,A,b),m.push(A,F,b)}this.setIndex(m),this.setAttribute("position",new se(_,3)),this.setAttribute("normal",new se(x,3)),this.setAttribute("uv",new se(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new er(t.width,t.height,t.widthSegments,t.heightSegments)}}var xc=`#ifdef USE_ALPHAHASH
45
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
46
+ #endif`,Mc=`#ifdef USE_ALPHAHASH
47
+ const float ALPHA_HASH_SCALE = 0.05;
48
+ float hash2D( vec2 value ) {
49
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
50
+ }
51
+ float hash3D( vec3 value ) {
52
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
53
+ }
54
+ float getAlphaHashThreshold( vec3 position ) {
55
+ float maxDeriv = max(
56
+ length( dFdx( position.xyz ) ),
57
+ length( dFdy( position.xyz ) )
58
+ );
59
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
60
+ vec2 pixScales = vec2(
61
+ exp2( floor( log2( pixScale ) ) ),
62
+ exp2( ceil( log2( pixScale ) ) )
63
+ );
64
+ vec2 alpha = vec2(
65
+ hash3D( floor( pixScales.x * position.xyz ) ),
66
+ hash3D( floor( pixScales.y * position.xyz ) )
67
+ );
68
+ float lerpFactor = fract( log2( pixScale ) );
69
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
70
+ float a = min( lerpFactor, 1.0 - lerpFactor );
71
+ vec3 cases = vec3(
72
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
73
+ ( x - 0.5 * a ) / ( 1.0 - a ),
74
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
75
+ );
76
+ float threshold = ( x < ( 1.0 - a ) )
77
+ ? ( ( x < a ) ? cases.x : cases.y )
78
+ : cases.z;
79
+ return clamp( threshold , 1.0e-6, 1.0 );
80
+ }
81
+ #endif`,Sc=`#ifdef USE_ALPHAMAP
82
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
83
+ #endif`,Ec=`#ifdef USE_ALPHAMAP
84
+ uniform sampler2D alphaMap;
85
+ #endif`,yc=`#ifdef USE_ALPHATEST
86
+ #ifdef ALPHA_TO_COVERAGE
87
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
88
+ if ( diffuseColor.a == 0.0 ) discard;
89
+ #else
90
+ if ( diffuseColor.a < alphaTest ) discard;
91
+ #endif
92
+ #endif`,Tc=`#ifdef USE_ALPHATEST
93
+ uniform float alphaTest;
94
+ #endif`,Ac=`#ifdef USE_AOMAP
95
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
96
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
97
+ #if defined( USE_CLEARCOAT )
98
+ clearcoatSpecularIndirect *= ambientOcclusion;
99
+ #endif
100
+ #if defined( USE_SHEEN )
101
+ sheenSpecularIndirect *= ambientOcclusion;
102
+ #endif
103
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
104
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
105
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
106
+ #endif
107
+ #endif`,bc=`#ifdef USE_AOMAP
108
+ uniform sampler2D aoMap;
109
+ uniform float aoMapIntensity;
110
+ #endif`,wc=`#ifdef USE_BATCHING
111
+ attribute float batchId;
112
+ uniform highp sampler2D batchingTexture;
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
+ #endif
125
+ #ifdef USE_BATCHING_COLOR
126
+ uniform sampler2D batchingColorTexture;
127
+ vec3 getBatchingColor( const in float i ) {
128
+ int size = textureSize( batchingColorTexture, 0 ).x;
129
+ int j = int( i );
130
+ int x = j % size;
131
+ int y = j / size;
132
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
133
+ }
134
+ #endif`,Rc=`#ifdef USE_BATCHING
135
+ mat4 batchingMatrix = getBatchingMatrix( batchId );
136
+ #endif`,Cc=`vec3 transformed = vec3( position );
137
+ #ifdef USE_ALPHAHASH
138
+ vPosition = vec3( position );
139
+ #endif`,Pc=`vec3 objectNormal = vec3( normal );
140
+ #ifdef USE_TANGENT
141
+ vec3 objectTangent = vec3( tangent.xyz );
142
+ #endif`,Lc=`float G_BlinnPhong_Implicit( ) {
143
+ return 0.25;
144
+ }
145
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
146
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
147
+ }
148
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
149
+ vec3 halfDir = normalize( lightDir + viewDir );
150
+ float dotNH = saturate( dot( normal, halfDir ) );
151
+ float dotVH = saturate( dot( viewDir, halfDir ) );
152
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
153
+ float G = G_BlinnPhong_Implicit( );
154
+ float D = D_BlinnPhong( shininess, dotNH );
155
+ return F * ( G * D );
156
+ } // validated`,Uc=`#ifdef USE_IRIDESCENCE
157
+ const mat3 XYZ_TO_REC709 = mat3(
158
+ 3.2404542, -0.9692660, 0.0556434,
159
+ -1.5371385, 1.8760108, -0.2040259,
160
+ -0.4985314, 0.0415560, 1.0572252
161
+ );
162
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
163
+ vec3 sqrtF0 = sqrt( fresnel0 );
164
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
165
+ }
166
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
167
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
168
+ }
169
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
170
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
171
+ }
172
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
173
+ float phase = 2.0 * PI * OPD * 1.0e-9;
174
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
175
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
176
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
177
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
178
+ 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 ) );
179
+ xyz /= 1.0685e-7;
180
+ vec3 rgb = XYZ_TO_REC709 * xyz;
181
+ return rgb;
182
+ }
183
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
184
+ vec3 I;
185
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
186
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
187
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
188
+ if ( cosTheta2Sq < 0.0 ) {
189
+ return vec3( 1.0 );
190
+ }
191
+ float cosTheta2 = sqrt( cosTheta2Sq );
192
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
193
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
194
+ float T121 = 1.0 - R12;
195
+ float phi12 = 0.0;
196
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
197
+ float phi21 = PI - phi12;
198
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
199
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
200
+ vec3 phi23 = vec3( 0.0 );
201
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
202
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
203
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
204
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
205
+ vec3 phi = vec3( phi21 ) + phi23;
206
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
207
+ vec3 r123 = sqrt( R123 );
208
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
209
+ vec3 C0 = R12 + Rs;
210
+ I = C0;
211
+ vec3 Cm = Rs - T121;
212
+ for ( int m = 1; m <= 2; ++ m ) {
213
+ Cm *= r123;
214
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
215
+ I += Cm * Sm;
216
+ }
217
+ return max( I, vec3( 0.0 ) );
218
+ }
219
+ #endif`,Dc=`#ifdef USE_BUMPMAP
220
+ uniform sampler2D bumpMap;
221
+ uniform float bumpScale;
222
+ vec2 dHdxy_fwd() {
223
+ vec2 dSTdx = dFdx( vBumpMapUv );
224
+ vec2 dSTdy = dFdy( vBumpMapUv );
225
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
226
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
227
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
228
+ return vec2( dBx, dBy );
229
+ }
230
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
231
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
232
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
233
+ vec3 vN = surf_norm;
234
+ vec3 R1 = cross( vSigmaY, vN );
235
+ vec3 R2 = cross( vN, vSigmaX );
236
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
237
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
238
+ return normalize( abs( fDet ) * surf_norm - vGrad );
239
+ }
240
+ #endif`,Ic=`#if NUM_CLIPPING_PLANES > 0
241
+ vec4 plane;
242
+ #ifdef ALPHA_TO_COVERAGE
243
+ float distanceToPlane, distanceGradient;
244
+ float clipOpacity = 1.0;
245
+ #pragma unroll_loop_start
246
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
247
+ plane = clippingPlanes[ i ];
248
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
249
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
250
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
251
+ if ( clipOpacity == 0.0 ) discard;
252
+ }
253
+ #pragma unroll_loop_end
254
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
255
+ float unionClipOpacity = 1.0;
256
+ #pragma unroll_loop_start
257
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
258
+ plane = clippingPlanes[ i ];
259
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
260
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
261
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
262
+ }
263
+ #pragma unroll_loop_end
264
+ clipOpacity *= 1.0 - unionClipOpacity;
265
+ #endif
266
+ diffuseColor.a *= clipOpacity;
267
+ if ( diffuseColor.a == 0.0 ) discard;
268
+ #else
269
+ #pragma unroll_loop_start
270
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
271
+ plane = clippingPlanes[ i ];
272
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
273
+ }
274
+ #pragma unroll_loop_end
275
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
276
+ bool clipped = true;
277
+ #pragma unroll_loop_start
278
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
279
+ plane = clippingPlanes[ i ];
280
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
281
+ }
282
+ #pragma unroll_loop_end
283
+ if ( clipped ) discard;
284
+ #endif
285
+ #endif
286
+ #endif`,Nc=`#if NUM_CLIPPING_PLANES > 0
287
+ varying vec3 vClipPosition;
288
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
289
+ #endif`,Fc=`#if NUM_CLIPPING_PLANES > 0
290
+ varying vec3 vClipPosition;
291
+ #endif`,Oc=`#if NUM_CLIPPING_PLANES > 0
292
+ vClipPosition = - mvPosition.xyz;
293
+ #endif`,Bc=`#if defined( USE_COLOR_ALPHA )
294
+ diffuseColor *= vColor;
295
+ #elif defined( USE_COLOR )
296
+ diffuseColor.rgb *= vColor;
297
+ #endif`,zc=`#if defined( USE_COLOR_ALPHA )
298
+ varying vec4 vColor;
299
+ #elif defined( USE_COLOR )
300
+ varying vec3 vColor;
301
+ #endif`,Hc=`#if defined( USE_COLOR_ALPHA )
302
+ varying vec4 vColor;
303
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
304
+ varying vec3 vColor;
305
+ #endif`,Gc=`#if defined( USE_COLOR_ALPHA )
306
+ vColor = vec4( 1.0 );
307
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
308
+ vColor = vec3( 1.0 );
309
+ #endif
310
+ #ifdef USE_COLOR
311
+ vColor *= color;
312
+ #endif
313
+ #ifdef USE_INSTANCING_COLOR
314
+ vColor.xyz *= instanceColor.xyz;
315
+ #endif
316
+ #ifdef USE_BATCHING_COLOR
317
+ vec3 batchingColor = getBatchingColor( batchId );
318
+ vColor.xyz *= batchingColor.xyz;
319
+ #endif`,Vc=`#define PI 3.141592653589793
320
+ #define PI2 6.283185307179586
321
+ #define PI_HALF 1.5707963267948966
322
+ #define RECIPROCAL_PI 0.3183098861837907
323
+ #define RECIPROCAL_PI2 0.15915494309189535
324
+ #define EPSILON 1e-6
325
+ #ifndef saturate
326
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
327
+ #endif
328
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
329
+ float pow2( const in float x ) { return x*x; }
330
+ vec3 pow2( const in vec3 x ) { return x*x; }
331
+ float pow3( const in float x ) { return x*x*x; }
332
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
333
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
334
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
335
+ highp float rand( const in vec2 uv ) {
336
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
337
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
338
+ return fract( sin( sn ) * c );
339
+ }
340
+ #ifdef HIGH_PRECISION
341
+ float precisionSafeLength( vec3 v ) { return length( v ); }
342
+ #else
343
+ float precisionSafeLength( vec3 v ) {
344
+ float maxComponent = max3( abs( v ) );
345
+ return length( v / maxComponent ) * maxComponent;
346
+ }
347
+ #endif
348
+ struct IncidentLight {
349
+ vec3 color;
350
+ vec3 direction;
351
+ bool visible;
352
+ };
353
+ struct ReflectedLight {
354
+ vec3 directDiffuse;
355
+ vec3 directSpecular;
356
+ vec3 indirectDiffuse;
357
+ vec3 indirectSpecular;
358
+ };
359
+ #ifdef USE_ALPHAHASH
360
+ varying vec3 vPosition;
361
+ #endif
362
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
363
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
364
+ }
365
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
366
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
367
+ }
368
+ mat3 transposeMat3( const in mat3 m ) {
369
+ mat3 tmp;
370
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
371
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
372
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
373
+ return tmp;
374
+ }
375
+ float luminance( const in vec3 rgb ) {
376
+ const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
377
+ return dot( weights, rgb );
378
+ }
379
+ bool isPerspectiveMatrix( mat4 m ) {
380
+ return m[ 2 ][ 3 ] == - 1.0;
381
+ }
382
+ vec2 equirectUv( in vec3 dir ) {
383
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
384
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
385
+ return vec2( u, v );
386
+ }
387
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
388
+ return RECIPROCAL_PI * diffuseColor;
389
+ }
390
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
391
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
392
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
393
+ }
394
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
395
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
396
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
397
+ } // validated`,kc=`#ifdef ENVMAP_TYPE_CUBE_UV
398
+ #define cubeUV_minMipLevel 4.0
399
+ #define cubeUV_minTileSize 16.0
400
+ float getFace( vec3 direction ) {
401
+ vec3 absDirection = abs( direction );
402
+ float face = - 1.0;
403
+ if ( absDirection.x > absDirection.z ) {
404
+ if ( absDirection.x > absDirection.y )
405
+ face = direction.x > 0.0 ? 0.0 : 3.0;
406
+ else
407
+ face = direction.y > 0.0 ? 1.0 : 4.0;
408
+ } else {
409
+ if ( absDirection.z > absDirection.y )
410
+ face = direction.z > 0.0 ? 2.0 : 5.0;
411
+ else
412
+ face = direction.y > 0.0 ? 1.0 : 4.0;
413
+ }
414
+ return face;
415
+ }
416
+ vec2 getUV( vec3 direction, float face ) {
417
+ vec2 uv;
418
+ if ( face == 0.0 ) {
419
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
420
+ } else if ( face == 1.0 ) {
421
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
422
+ } else if ( face == 2.0 ) {
423
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
424
+ } else if ( face == 3.0 ) {
425
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
426
+ } else if ( face == 4.0 ) {
427
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
428
+ } else {
429
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
430
+ }
431
+ return 0.5 * ( uv + 1.0 );
432
+ }
433
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
434
+ float face = getFace( direction );
435
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
436
+ mipInt = max( mipInt, cubeUV_minMipLevel );
437
+ float faceSize = exp2( mipInt );
438
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
439
+ if ( face > 2.0 ) {
440
+ uv.y += faceSize;
441
+ face -= 3.0;
442
+ }
443
+ uv.x += face * faceSize;
444
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
445
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
446
+ uv.x *= CUBEUV_TEXEL_WIDTH;
447
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
448
+ #ifdef texture2DGradEXT
449
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
450
+ #else
451
+ return texture2D( envMap, uv ).rgb;
452
+ #endif
453
+ }
454
+ #define cubeUV_r0 1.0
455
+ #define cubeUV_m0 - 2.0
456
+ #define cubeUV_r1 0.8
457
+ #define cubeUV_m1 - 1.0
458
+ #define cubeUV_r4 0.4
459
+ #define cubeUV_m4 2.0
460
+ #define cubeUV_r5 0.305
461
+ #define cubeUV_m5 3.0
462
+ #define cubeUV_r6 0.21
463
+ #define cubeUV_m6 4.0
464
+ float roughnessToMip( float roughness ) {
465
+ float mip = 0.0;
466
+ if ( roughness >= cubeUV_r1 ) {
467
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
468
+ } else if ( roughness >= cubeUV_r4 ) {
469
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
470
+ } else if ( roughness >= cubeUV_r5 ) {
471
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
472
+ } else if ( roughness >= cubeUV_r6 ) {
473
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
474
+ } else {
475
+ mip = - 2.0 * log2( 1.16 * roughness ); }
476
+ return mip;
477
+ }
478
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
479
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
480
+ float mipF = fract( mip );
481
+ float mipInt = floor( mip );
482
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
483
+ if ( mipF == 0.0 ) {
484
+ return vec4( color0, 1.0 );
485
+ } else {
486
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
487
+ return vec4( mix( color0, color1, mipF ), 1.0 );
488
+ }
489
+ }
490
+ #endif`,Wc=`vec3 transformedNormal = objectNormal;
491
+ #ifdef USE_TANGENT
492
+ vec3 transformedTangent = objectTangent;
493
+ #endif
494
+ #ifdef USE_BATCHING
495
+ mat3 bm = mat3( batchingMatrix );
496
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
497
+ transformedNormal = bm * transformedNormal;
498
+ #ifdef USE_TANGENT
499
+ transformedTangent = bm * transformedTangent;
500
+ #endif
501
+ #endif
502
+ #ifdef USE_INSTANCING
503
+ mat3 im = mat3( instanceMatrix );
504
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
505
+ transformedNormal = im * transformedNormal;
506
+ #ifdef USE_TANGENT
507
+ transformedTangent = im * transformedTangent;
508
+ #endif
509
+ #endif
510
+ transformedNormal = normalMatrix * transformedNormal;
511
+ #ifdef FLIP_SIDED
512
+ transformedNormal = - transformedNormal;
513
+ #endif
514
+ #ifdef USE_TANGENT
515
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
516
+ #ifdef FLIP_SIDED
517
+ transformedTangent = - transformedTangent;
518
+ #endif
519
+ #endif`,Xc=`#ifdef USE_DISPLACEMENTMAP
520
+ uniform sampler2D displacementMap;
521
+ uniform float displacementScale;
522
+ uniform float displacementBias;
523
+ #endif`,qc=`#ifdef USE_DISPLACEMENTMAP
524
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
525
+ #endif`,Yc=`#ifdef USE_EMISSIVEMAP
526
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
527
+ totalEmissiveRadiance *= emissiveColor.rgb;
528
+ #endif`,Kc=`#ifdef USE_EMISSIVEMAP
529
+ uniform sampler2D emissiveMap;
530
+ #endif`,$c="gl_FragColor = linearToOutputTexel( gl_FragColor );",Zc=`
531
+ const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
532
+ vec3( 0.8224621, 0.177538, 0.0 ),
533
+ vec3( 0.0331941, 0.9668058, 0.0 ),
534
+ vec3( 0.0170827, 0.0723974, 0.9105199 )
535
+ );
536
+ const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
537
+ vec3( 1.2249401, - 0.2249404, 0.0 ),
538
+ vec3( - 0.0420569, 1.0420571, 0.0 ),
539
+ vec3( - 0.0196376, - 0.0786361, 1.0982735 )
540
+ );
541
+ vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
542
+ return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
543
+ }
544
+ vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
545
+ return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
546
+ }
547
+ vec4 LinearTransferOETF( in vec4 value ) {
548
+ return value;
549
+ }
550
+ vec4 sRGBTransferOETF( in vec4 value ) {
551
+ 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 );
552
+ }
553
+ vec4 LinearToLinear( in vec4 value ) {
554
+ return value;
555
+ }
556
+ vec4 LinearTosRGB( in vec4 value ) {
557
+ return sRGBTransferOETF( value );
558
+ }`,jc=`#ifdef USE_ENVMAP
559
+ #ifdef ENV_WORLDPOS
560
+ vec3 cameraToFrag;
561
+ if ( isOrthographic ) {
562
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
563
+ } else {
564
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
565
+ }
566
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
567
+ #ifdef ENVMAP_MODE_REFLECTION
568
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
569
+ #else
570
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
571
+ #endif
572
+ #else
573
+ vec3 reflectVec = vReflect;
574
+ #endif
575
+ #ifdef ENVMAP_TYPE_CUBE
576
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
577
+ #else
578
+ vec4 envColor = vec4( 0.0 );
579
+ #endif
580
+ #ifdef ENVMAP_BLENDING_MULTIPLY
581
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
582
+ #elif defined( ENVMAP_BLENDING_MIX )
583
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
584
+ #elif defined( ENVMAP_BLENDING_ADD )
585
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
586
+ #endif
587
+ #endif`,Jc=`#ifdef USE_ENVMAP
588
+ uniform float envMapIntensity;
589
+ uniform float flipEnvMap;
590
+ uniform mat3 envMapRotation;
591
+ #ifdef ENVMAP_TYPE_CUBE
592
+ uniform samplerCube envMap;
593
+ #else
594
+ uniform sampler2D envMap;
595
+ #endif
596
+
597
+ #endif`,Qc=`#ifdef USE_ENVMAP
598
+ uniform float reflectivity;
599
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
600
+ #define ENV_WORLDPOS
601
+ #endif
602
+ #ifdef ENV_WORLDPOS
603
+ varying vec3 vWorldPosition;
604
+ uniform float refractionRatio;
605
+ #else
606
+ varying vec3 vReflect;
607
+ #endif
608
+ #endif`,th=`#ifdef USE_ENVMAP
609
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
610
+ #define ENV_WORLDPOS
611
+ #endif
612
+ #ifdef ENV_WORLDPOS
613
+
614
+ varying vec3 vWorldPosition;
615
+ #else
616
+ varying vec3 vReflect;
617
+ uniform float refractionRatio;
618
+ #endif
619
+ #endif`,eh=`#ifdef USE_ENVMAP
620
+ #ifdef ENV_WORLDPOS
621
+ vWorldPosition = worldPosition.xyz;
622
+ #else
623
+ vec3 cameraToVertex;
624
+ if ( isOrthographic ) {
625
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
626
+ } else {
627
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
628
+ }
629
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
630
+ #ifdef ENVMAP_MODE_REFLECTION
631
+ vReflect = reflect( cameraToVertex, worldNormal );
632
+ #else
633
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
634
+ #endif
635
+ #endif
636
+ #endif`,nh=`#ifdef USE_FOG
637
+ vFogDepth = - mvPosition.z;
638
+ #endif`,ih=`#ifdef USE_FOG
639
+ varying float vFogDepth;
640
+ #endif`,rh=`#ifdef USE_FOG
641
+ #ifdef FOG_EXP2
642
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
643
+ #else
644
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
645
+ #endif
646
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
647
+ #endif`,sh=`#ifdef USE_FOG
648
+ uniform vec3 fogColor;
649
+ varying float vFogDepth;
650
+ #ifdef FOG_EXP2
651
+ uniform float fogDensity;
652
+ #else
653
+ uniform float fogNear;
654
+ uniform float fogFar;
655
+ #endif
656
+ #endif`,ah=`#ifdef USE_GRADIENTMAP
657
+ uniform sampler2D gradientMap;
658
+ #endif
659
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
660
+ float dotNL = dot( normal, lightDirection );
661
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
662
+ #ifdef USE_GRADIENTMAP
663
+ return vec3( texture2D( gradientMap, coord ).r );
664
+ #else
665
+ vec2 fw = fwidth( coord ) * 0.5;
666
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
667
+ #endif
668
+ }`,oh=`#ifdef USE_LIGHTMAP
669
+ uniform sampler2D lightMap;
670
+ uniform float lightMapIntensity;
671
+ #endif`,lh=`LambertMaterial material;
672
+ material.diffuseColor = diffuseColor.rgb;
673
+ material.specularStrength = specularStrength;`,ch=`varying vec3 vViewPosition;
674
+ struct LambertMaterial {
675
+ vec3 diffuseColor;
676
+ float specularStrength;
677
+ };
678
+ 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 ) {
679
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
680
+ vec3 irradiance = dotNL * directLight.color;
681
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
682
+ }
683
+ 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 ) {
684
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
685
+ }
686
+ #define RE_Direct RE_Direct_Lambert
687
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,hh=`uniform bool receiveShadow;
688
+ uniform vec3 ambientLightColor;
689
+ #if defined( USE_LIGHT_PROBES )
690
+ uniform vec3 lightProbe[ 9 ];
691
+ #endif
692
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
693
+ float x = normal.x, y = normal.y, z = normal.z;
694
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
695
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
696
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
697
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
698
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
699
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
700
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
701
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
702
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
703
+ return result;
704
+ }
705
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
706
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
707
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
708
+ return irradiance;
709
+ }
710
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
711
+ vec3 irradiance = ambientLightColor;
712
+ return irradiance;
713
+ }
714
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
715
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
716
+ if ( cutoffDistance > 0.0 ) {
717
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
718
+ }
719
+ return distanceFalloff;
720
+ }
721
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
722
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
723
+ }
724
+ #if NUM_DIR_LIGHTS > 0
725
+ struct DirectionalLight {
726
+ vec3 direction;
727
+ vec3 color;
728
+ };
729
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
730
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
731
+ light.color = directionalLight.color;
732
+ light.direction = directionalLight.direction;
733
+ light.visible = true;
734
+ }
735
+ #endif
736
+ #if NUM_POINT_LIGHTS > 0
737
+ struct PointLight {
738
+ vec3 position;
739
+ vec3 color;
740
+ float distance;
741
+ float decay;
742
+ };
743
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
744
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
745
+ vec3 lVector = pointLight.position - geometryPosition;
746
+ light.direction = normalize( lVector );
747
+ float lightDistance = length( lVector );
748
+ light.color = pointLight.color;
749
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
750
+ light.visible = ( light.color != vec3( 0.0 ) );
751
+ }
752
+ #endif
753
+ #if NUM_SPOT_LIGHTS > 0
754
+ struct SpotLight {
755
+ vec3 position;
756
+ vec3 direction;
757
+ vec3 color;
758
+ float distance;
759
+ float decay;
760
+ float coneCos;
761
+ float penumbraCos;
762
+ };
763
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
764
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
765
+ vec3 lVector = spotLight.position - geometryPosition;
766
+ light.direction = normalize( lVector );
767
+ float angleCos = dot( light.direction, spotLight.direction );
768
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
769
+ if ( spotAttenuation > 0.0 ) {
770
+ float lightDistance = length( lVector );
771
+ light.color = spotLight.color * spotAttenuation;
772
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
773
+ light.visible = ( light.color != vec3( 0.0 ) );
774
+ } else {
775
+ light.color = vec3( 0.0 );
776
+ light.visible = false;
777
+ }
778
+ }
779
+ #endif
780
+ #if NUM_RECT_AREA_LIGHTS > 0
781
+ struct RectAreaLight {
782
+ vec3 color;
783
+ vec3 position;
784
+ vec3 halfWidth;
785
+ vec3 halfHeight;
786
+ };
787
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
788
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
789
+ #endif
790
+ #if NUM_HEMI_LIGHTS > 0
791
+ struct HemisphereLight {
792
+ vec3 direction;
793
+ vec3 skyColor;
794
+ vec3 groundColor;
795
+ };
796
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
797
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
798
+ float dotNL = dot( normal, hemiLight.direction );
799
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
800
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
801
+ return irradiance;
802
+ }
803
+ #endif`,uh=`#ifdef USE_ENVMAP
804
+ vec3 getIBLIrradiance( const in vec3 normal ) {
805
+ #ifdef ENVMAP_TYPE_CUBE_UV
806
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
807
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
808
+ return PI * envMapColor.rgb * envMapIntensity;
809
+ #else
810
+ return vec3( 0.0 );
811
+ #endif
812
+ }
813
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
814
+ #ifdef ENVMAP_TYPE_CUBE_UV
815
+ vec3 reflectVec = reflect( - viewDir, normal );
816
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
817
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
818
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
819
+ return envMapColor.rgb * envMapIntensity;
820
+ #else
821
+ return vec3( 0.0 );
822
+ #endif
823
+ }
824
+ #ifdef USE_ANISOTROPY
825
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
826
+ #ifdef ENVMAP_TYPE_CUBE_UV
827
+ vec3 bentNormal = cross( bitangent, viewDir );
828
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
829
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
830
+ return getIBLRadiance( viewDir, bentNormal, roughness );
831
+ #else
832
+ return vec3( 0.0 );
833
+ #endif
834
+ }
835
+ #endif
836
+ #endif`,dh=`ToonMaterial material;
837
+ material.diffuseColor = diffuseColor.rgb;`,fh=`varying vec3 vViewPosition;
838
+ struct ToonMaterial {
839
+ vec3 diffuseColor;
840
+ };
841
+ 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 ) {
842
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
843
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
844
+ }
845
+ 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 ) {
846
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
847
+ }
848
+ #define RE_Direct RE_Direct_Toon
849
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,ph=`BlinnPhongMaterial material;
850
+ material.diffuseColor = diffuseColor.rgb;
851
+ material.specularColor = specular;
852
+ material.specularShininess = shininess;
853
+ material.specularStrength = specularStrength;`,mh=`varying vec3 vViewPosition;
854
+ struct BlinnPhongMaterial {
855
+ vec3 diffuseColor;
856
+ vec3 specularColor;
857
+ float specularShininess;
858
+ float specularStrength;
859
+ };
860
+ 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 ) {
861
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
862
+ vec3 irradiance = dotNL * directLight.color;
863
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
864
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
865
+ }
866
+ 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 ) {
867
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
868
+ }
869
+ #define RE_Direct RE_Direct_BlinnPhong
870
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,_h=`PhysicalMaterial material;
871
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
872
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
873
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
874
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
875
+ material.roughness = min( material.roughness, 1.0 );
876
+ #ifdef IOR
877
+ material.ior = ior;
878
+ #ifdef USE_SPECULAR
879
+ float specularIntensityFactor = specularIntensity;
880
+ vec3 specularColorFactor = specularColor;
881
+ #ifdef USE_SPECULAR_COLORMAP
882
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
883
+ #endif
884
+ #ifdef USE_SPECULAR_INTENSITYMAP
885
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
886
+ #endif
887
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
888
+ #else
889
+ float specularIntensityFactor = 1.0;
890
+ vec3 specularColorFactor = vec3( 1.0 );
891
+ material.specularF90 = 1.0;
892
+ #endif
893
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
894
+ #else
895
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
896
+ material.specularF90 = 1.0;
897
+ #endif
898
+ #ifdef USE_CLEARCOAT
899
+ material.clearcoat = clearcoat;
900
+ material.clearcoatRoughness = clearcoatRoughness;
901
+ material.clearcoatF0 = vec3( 0.04 );
902
+ material.clearcoatF90 = 1.0;
903
+ #ifdef USE_CLEARCOATMAP
904
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
905
+ #endif
906
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
907
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
908
+ #endif
909
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
910
+ material.clearcoatRoughness += geometryRoughness;
911
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
912
+ #endif
913
+ #ifdef USE_DISPERSION
914
+ material.dispersion = dispersion;
915
+ #endif
916
+ #ifdef USE_IRIDESCENCE
917
+ material.iridescence = iridescence;
918
+ material.iridescenceIOR = iridescenceIOR;
919
+ #ifdef USE_IRIDESCENCEMAP
920
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
921
+ #endif
922
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
923
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
924
+ #else
925
+ material.iridescenceThickness = iridescenceThicknessMaximum;
926
+ #endif
927
+ #endif
928
+ #ifdef USE_SHEEN
929
+ material.sheenColor = sheenColor;
930
+ #ifdef USE_SHEEN_COLORMAP
931
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
932
+ #endif
933
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
934
+ #ifdef USE_SHEEN_ROUGHNESSMAP
935
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
936
+ #endif
937
+ #endif
938
+ #ifdef USE_ANISOTROPY
939
+ #ifdef USE_ANISOTROPYMAP
940
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
941
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
942
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
943
+ #else
944
+ vec2 anisotropyV = anisotropyVector;
945
+ #endif
946
+ material.anisotropy = length( anisotropyV );
947
+ if( material.anisotropy == 0.0 ) {
948
+ anisotropyV = vec2( 1.0, 0.0 );
949
+ } else {
950
+ anisotropyV /= material.anisotropy;
951
+ material.anisotropy = saturate( material.anisotropy );
952
+ }
953
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
954
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
955
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
956
+ #endif`,gh=`struct PhysicalMaterial {
957
+ vec3 diffuseColor;
958
+ float roughness;
959
+ vec3 specularColor;
960
+ float specularF90;
961
+ float dispersion;
962
+ #ifdef USE_CLEARCOAT
963
+ float clearcoat;
964
+ float clearcoatRoughness;
965
+ vec3 clearcoatF0;
966
+ float clearcoatF90;
967
+ #endif
968
+ #ifdef USE_IRIDESCENCE
969
+ float iridescence;
970
+ float iridescenceIOR;
971
+ float iridescenceThickness;
972
+ vec3 iridescenceFresnel;
973
+ vec3 iridescenceF0;
974
+ #endif
975
+ #ifdef USE_SHEEN
976
+ vec3 sheenColor;
977
+ float sheenRoughness;
978
+ #endif
979
+ #ifdef IOR
980
+ float ior;
981
+ #endif
982
+ #ifdef USE_TRANSMISSION
983
+ float transmission;
984
+ float transmissionAlpha;
985
+ float thickness;
986
+ float attenuationDistance;
987
+ vec3 attenuationColor;
988
+ #endif
989
+ #ifdef USE_ANISOTROPY
990
+ float anisotropy;
991
+ float alphaT;
992
+ vec3 anisotropyT;
993
+ vec3 anisotropyB;
994
+ #endif
995
+ };
996
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
997
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
998
+ vec3 sheenSpecularDirect = vec3( 0.0 );
999
+ vec3 sheenSpecularIndirect = vec3(0.0 );
1000
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
1001
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
1002
+ float x2 = x * x;
1003
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
1004
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
1005
+ }
1006
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
1007
+ float a2 = pow2( alpha );
1008
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
1009
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
1010
+ return 0.5 / max( gv + gl, EPSILON );
1011
+ }
1012
+ float D_GGX( const in float alpha, const in float dotNH ) {
1013
+ float a2 = pow2( alpha );
1014
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1015
+ return RECIPROCAL_PI * a2 / pow2( denom );
1016
+ }
1017
+ #ifdef USE_ANISOTROPY
1018
+ 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 ) {
1019
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1020
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1021
+ float v = 0.5 / ( gv + gl );
1022
+ return saturate(v);
1023
+ }
1024
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1025
+ float a2 = alphaT * alphaB;
1026
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1027
+ highp float v2 = dot( v, v );
1028
+ float w2 = a2 / v2;
1029
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1030
+ }
1031
+ #endif
1032
+ #ifdef USE_CLEARCOAT
1033
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1034
+ vec3 f0 = material.clearcoatF0;
1035
+ float f90 = material.clearcoatF90;
1036
+ float roughness = material.clearcoatRoughness;
1037
+ float alpha = pow2( roughness );
1038
+ vec3 halfDir = normalize( lightDir + viewDir );
1039
+ float dotNL = saturate( dot( normal, lightDir ) );
1040
+ float dotNV = saturate( dot( normal, viewDir ) );
1041
+ float dotNH = saturate( dot( normal, halfDir ) );
1042
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1043
+ vec3 F = F_Schlick( f0, f90, dotVH );
1044
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1045
+ float D = D_GGX( alpha, dotNH );
1046
+ return F * ( V * D );
1047
+ }
1048
+ #endif
1049
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1050
+ vec3 f0 = material.specularColor;
1051
+ float f90 = material.specularF90;
1052
+ float roughness = material.roughness;
1053
+ float alpha = pow2( roughness );
1054
+ vec3 halfDir = normalize( lightDir + viewDir );
1055
+ float dotNL = saturate( dot( normal, lightDir ) );
1056
+ float dotNV = saturate( dot( normal, viewDir ) );
1057
+ float dotNH = saturate( dot( normal, halfDir ) );
1058
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1059
+ vec3 F = F_Schlick( f0, f90, dotVH );
1060
+ #ifdef USE_IRIDESCENCE
1061
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1062
+ #endif
1063
+ #ifdef USE_ANISOTROPY
1064
+ float dotTL = dot( material.anisotropyT, lightDir );
1065
+ float dotTV = dot( material.anisotropyT, viewDir );
1066
+ float dotTH = dot( material.anisotropyT, halfDir );
1067
+ float dotBL = dot( material.anisotropyB, lightDir );
1068
+ float dotBV = dot( material.anisotropyB, viewDir );
1069
+ float dotBH = dot( material.anisotropyB, halfDir );
1070
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1071
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1072
+ #else
1073
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1074
+ float D = D_GGX( alpha, dotNH );
1075
+ #endif
1076
+ return F * ( V * D );
1077
+ }
1078
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1079
+ const float LUT_SIZE = 64.0;
1080
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1081
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1082
+ float dotNV = saturate( dot( N, V ) );
1083
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1084
+ uv = uv * LUT_SCALE + LUT_BIAS;
1085
+ return uv;
1086
+ }
1087
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1088
+ float l = length( f );
1089
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1090
+ }
1091
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1092
+ float x = dot( v1, v2 );
1093
+ float y = abs( x );
1094
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1095
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1096
+ float v = a / b;
1097
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1098
+ return cross( v1, v2 ) * theta_sintheta;
1099
+ }
1100
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1101
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1102
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1103
+ vec3 lightNormal = cross( v1, v2 );
1104
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1105
+ vec3 T1, T2;
1106
+ T1 = normalize( V - N * dot( V, N ) );
1107
+ T2 = - cross( N, T1 );
1108
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1109
+ vec3 coords[ 4 ];
1110
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1111
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1112
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1113
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1114
+ coords[ 0 ] = normalize( coords[ 0 ] );
1115
+ coords[ 1 ] = normalize( coords[ 1 ] );
1116
+ coords[ 2 ] = normalize( coords[ 2 ] );
1117
+ coords[ 3 ] = normalize( coords[ 3 ] );
1118
+ vec3 vectorFormFactor = vec3( 0.0 );
1119
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1120
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1121
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1122
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1123
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1124
+ return vec3( result );
1125
+ }
1126
+ #if defined( USE_SHEEN )
1127
+ float D_Charlie( float roughness, float dotNH ) {
1128
+ float alpha = pow2( roughness );
1129
+ float invAlpha = 1.0 / alpha;
1130
+ float cos2h = dotNH * dotNH;
1131
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1132
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1133
+ }
1134
+ float V_Neubelt( float dotNV, float dotNL ) {
1135
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1136
+ }
1137
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1138
+ vec3 halfDir = normalize( lightDir + viewDir );
1139
+ float dotNL = saturate( dot( normal, lightDir ) );
1140
+ float dotNV = saturate( dot( normal, viewDir ) );
1141
+ float dotNH = saturate( dot( normal, halfDir ) );
1142
+ float D = D_Charlie( sheenRoughness, dotNH );
1143
+ float V = V_Neubelt( dotNV, dotNL );
1144
+ return sheenColor * ( D * V );
1145
+ }
1146
+ #endif
1147
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1148
+ float dotNV = saturate( dot( normal, viewDir ) );
1149
+ float r2 = roughness * roughness;
1150
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1151
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1152
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1153
+ return saturate( DG * RECIPROCAL_PI );
1154
+ }
1155
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1156
+ float dotNV = saturate( dot( normal, viewDir ) );
1157
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1158
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1159
+ vec4 r = roughness * c0 + c1;
1160
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1161
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1162
+ return fab;
1163
+ }
1164
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1165
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1166
+ return specularColor * fab.x + specularF90 * fab.y;
1167
+ }
1168
+ #ifdef USE_IRIDESCENCE
1169
+ 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 ) {
1170
+ #else
1171
+ 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 ) {
1172
+ #endif
1173
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1174
+ #ifdef USE_IRIDESCENCE
1175
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1176
+ #else
1177
+ vec3 Fr = specularColor;
1178
+ #endif
1179
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1180
+ float Ess = fab.x + fab.y;
1181
+ float Ems = 1.0 - Ess;
1182
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1183
+ singleScatter += FssEss;
1184
+ multiScatter += Fms * Ems;
1185
+ }
1186
+ #if NUM_RECT_AREA_LIGHTS > 0
1187
+ 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 ) {
1188
+ vec3 normal = geometryNormal;
1189
+ vec3 viewDir = geometryViewDir;
1190
+ vec3 position = geometryPosition;
1191
+ vec3 lightPos = rectAreaLight.position;
1192
+ vec3 halfWidth = rectAreaLight.halfWidth;
1193
+ vec3 halfHeight = rectAreaLight.halfHeight;
1194
+ vec3 lightColor = rectAreaLight.color;
1195
+ float roughness = material.roughness;
1196
+ vec3 rectCoords[ 4 ];
1197
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1198
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1199
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1200
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1201
+ vec4 t1 = texture2D( ltc_1, uv );
1202
+ vec4 t2 = texture2D( ltc_2, uv );
1203
+ mat3 mInv = mat3(
1204
+ vec3( t1.x, 0, t1.y ),
1205
+ vec3( 0, 1, 0 ),
1206
+ vec3( t1.z, 0, t1.w )
1207
+ );
1208
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1209
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1210
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1211
+ }
1212
+ #endif
1213
+ 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 ) {
1214
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1215
+ vec3 irradiance = dotNL * directLight.color;
1216
+ #ifdef USE_CLEARCOAT
1217
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1218
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1219
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1220
+ #endif
1221
+ #ifdef USE_SHEEN
1222
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1223
+ #endif
1224
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1225
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1226
+ }
1227
+ 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 ) {
1228
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1229
+ }
1230
+ 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) {
1231
+ #ifdef USE_CLEARCOAT
1232
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1233
+ #endif
1234
+ #ifdef USE_SHEEN
1235
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1236
+ #endif
1237
+ vec3 singleScattering = vec3( 0.0 );
1238
+ vec3 multiScattering = vec3( 0.0 );
1239
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1240
+ #ifdef USE_IRIDESCENCE
1241
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1242
+ #else
1243
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1244
+ #endif
1245
+ vec3 totalScattering = singleScattering + multiScattering;
1246
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1247
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1248
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1249
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1250
+ }
1251
+ #define RE_Direct RE_Direct_Physical
1252
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1253
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1254
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1255
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1256
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1257
+ }`,vh=`
1258
+ vec3 geometryPosition = - vViewPosition;
1259
+ vec3 geometryNormal = normal;
1260
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1261
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1262
+ #ifdef USE_CLEARCOAT
1263
+ geometryClearcoatNormal = clearcoatNormal;
1264
+ #endif
1265
+ #ifdef USE_IRIDESCENCE
1266
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1267
+ if ( material.iridescenceThickness == 0.0 ) {
1268
+ material.iridescence = 0.0;
1269
+ } else {
1270
+ material.iridescence = saturate( material.iridescence );
1271
+ }
1272
+ if ( material.iridescence > 0.0 ) {
1273
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1274
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1275
+ }
1276
+ #endif
1277
+ IncidentLight directLight;
1278
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1279
+ PointLight pointLight;
1280
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1281
+ PointLightShadow pointLightShadow;
1282
+ #endif
1283
+ #pragma unroll_loop_start
1284
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1285
+ pointLight = pointLights[ i ];
1286
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1287
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1288
+ pointLightShadow = pointLightShadows[ i ];
1289
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1290
+ #endif
1291
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1292
+ }
1293
+ #pragma unroll_loop_end
1294
+ #endif
1295
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1296
+ SpotLight spotLight;
1297
+ vec4 spotColor;
1298
+ vec3 spotLightCoord;
1299
+ bool inSpotLightMap;
1300
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1301
+ SpotLightShadow spotLightShadow;
1302
+ #endif
1303
+ #pragma unroll_loop_start
1304
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1305
+ spotLight = spotLights[ i ];
1306
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1307
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1308
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1309
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1310
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1311
+ #else
1312
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1313
+ #endif
1314
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1315
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1316
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1317
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1318
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1319
+ #endif
1320
+ #undef SPOT_LIGHT_MAP_INDEX
1321
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1322
+ spotLightShadow = spotLightShadows[ i ];
1323
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1324
+ #endif
1325
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1326
+ }
1327
+ #pragma unroll_loop_end
1328
+ #endif
1329
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1330
+ DirectionalLight directionalLight;
1331
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1332
+ DirectionalLightShadow directionalLightShadow;
1333
+ #endif
1334
+ #pragma unroll_loop_start
1335
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1336
+ directionalLight = directionalLights[ i ];
1337
+ getDirectionalLightInfo( directionalLight, directLight );
1338
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1339
+ directionalLightShadow = directionalLightShadows[ i ];
1340
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1341
+ #endif
1342
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1343
+ }
1344
+ #pragma unroll_loop_end
1345
+ #endif
1346
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1347
+ RectAreaLight rectAreaLight;
1348
+ #pragma unroll_loop_start
1349
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1350
+ rectAreaLight = rectAreaLights[ i ];
1351
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1352
+ }
1353
+ #pragma unroll_loop_end
1354
+ #endif
1355
+ #if defined( RE_IndirectDiffuse )
1356
+ vec3 iblIrradiance = vec3( 0.0 );
1357
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1358
+ #if defined( USE_LIGHT_PROBES )
1359
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1360
+ #endif
1361
+ #if ( NUM_HEMI_LIGHTS > 0 )
1362
+ #pragma unroll_loop_start
1363
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1364
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1365
+ }
1366
+ #pragma unroll_loop_end
1367
+ #endif
1368
+ #endif
1369
+ #if defined( RE_IndirectSpecular )
1370
+ vec3 radiance = vec3( 0.0 );
1371
+ vec3 clearcoatRadiance = vec3( 0.0 );
1372
+ #endif`,xh=`#if defined( RE_IndirectDiffuse )
1373
+ #ifdef USE_LIGHTMAP
1374
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1375
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1376
+ irradiance += lightMapIrradiance;
1377
+ #endif
1378
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1379
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1380
+ #endif
1381
+ #endif
1382
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1383
+ #ifdef USE_ANISOTROPY
1384
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1385
+ #else
1386
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1387
+ #endif
1388
+ #ifdef USE_CLEARCOAT
1389
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1390
+ #endif
1391
+ #endif`,Mh=`#if defined( RE_IndirectDiffuse )
1392
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1393
+ #endif
1394
+ #if defined( RE_IndirectSpecular )
1395
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1396
+ #endif`,Sh=`#if defined( USE_LOGDEPTHBUF )
1397
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1398
+ #endif`,Eh=`#if defined( USE_LOGDEPTHBUF )
1399
+ uniform float logDepthBufFC;
1400
+ varying float vFragDepth;
1401
+ varying float vIsPerspective;
1402
+ #endif`,yh=`#ifdef USE_LOGDEPTHBUF
1403
+ varying float vFragDepth;
1404
+ varying float vIsPerspective;
1405
+ #endif`,Th=`#ifdef USE_LOGDEPTHBUF
1406
+ vFragDepth = 1.0 + gl_Position.w;
1407
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1408
+ #endif`,Ah=`#ifdef USE_MAP
1409
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1410
+ #ifdef DECODE_VIDEO_TEXTURE
1411
+ sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
1412
+
1413
+ #endif
1414
+ diffuseColor *= sampledDiffuseColor;
1415
+ #endif`,bh=`#ifdef USE_MAP
1416
+ uniform sampler2D map;
1417
+ #endif`,wh=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1418
+ #if defined( USE_POINTS_UV )
1419
+ vec2 uv = vUv;
1420
+ #else
1421
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1422
+ #endif
1423
+ #endif
1424
+ #ifdef USE_MAP
1425
+ diffuseColor *= texture2D( map, uv );
1426
+ #endif
1427
+ #ifdef USE_ALPHAMAP
1428
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1429
+ #endif`,Rh=`#if defined( USE_POINTS_UV )
1430
+ varying vec2 vUv;
1431
+ #else
1432
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1433
+ uniform mat3 uvTransform;
1434
+ #endif
1435
+ #endif
1436
+ #ifdef USE_MAP
1437
+ uniform sampler2D map;
1438
+ #endif
1439
+ #ifdef USE_ALPHAMAP
1440
+ uniform sampler2D alphaMap;
1441
+ #endif`,Ch=`float metalnessFactor = metalness;
1442
+ #ifdef USE_METALNESSMAP
1443
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1444
+ metalnessFactor *= texelMetalness.b;
1445
+ #endif`,Ph=`#ifdef USE_METALNESSMAP
1446
+ uniform sampler2D metalnessMap;
1447
+ #endif`,Lh=`#ifdef USE_INSTANCING_MORPH
1448
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1449
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1450
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1451
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1452
+ }
1453
+ #endif`,Uh=`#if defined( USE_MORPHCOLORS )
1454
+ vColor *= morphTargetBaseInfluence;
1455
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1456
+ #if defined( USE_COLOR_ALPHA )
1457
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1458
+ #elif defined( USE_COLOR )
1459
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1460
+ #endif
1461
+ }
1462
+ #endif`,Dh=`#ifdef USE_MORPHNORMALS
1463
+ objectNormal *= morphTargetBaseInfluence;
1464
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1465
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1466
+ }
1467
+ #endif`,Ih=`#ifdef USE_MORPHTARGETS
1468
+ #ifndef USE_INSTANCING_MORPH
1469
+ uniform float morphTargetBaseInfluence;
1470
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1471
+ #endif
1472
+ uniform sampler2DArray morphTargetsTexture;
1473
+ uniform ivec2 morphTargetsTextureSize;
1474
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1475
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1476
+ int y = texelIndex / morphTargetsTextureSize.x;
1477
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1478
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1479
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1480
+ }
1481
+ #endif`,Nh=`#ifdef USE_MORPHTARGETS
1482
+ transformed *= morphTargetBaseInfluence;
1483
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1484
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1485
+ }
1486
+ #endif`,Fh=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1487
+ #ifdef FLAT_SHADED
1488
+ vec3 fdx = dFdx( vViewPosition );
1489
+ vec3 fdy = dFdy( vViewPosition );
1490
+ vec3 normal = normalize( cross( fdx, fdy ) );
1491
+ #else
1492
+ vec3 normal = normalize( vNormal );
1493
+ #ifdef DOUBLE_SIDED
1494
+ normal *= faceDirection;
1495
+ #endif
1496
+ #endif
1497
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1498
+ #ifdef USE_TANGENT
1499
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1500
+ #else
1501
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1502
+ #if defined( USE_NORMALMAP )
1503
+ vNormalMapUv
1504
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1505
+ vClearcoatNormalMapUv
1506
+ #else
1507
+ vUv
1508
+ #endif
1509
+ );
1510
+ #endif
1511
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1512
+ tbn[0] *= faceDirection;
1513
+ tbn[1] *= faceDirection;
1514
+ #endif
1515
+ #endif
1516
+ #ifdef USE_CLEARCOAT_NORMALMAP
1517
+ #ifdef USE_TANGENT
1518
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1519
+ #else
1520
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1521
+ #endif
1522
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1523
+ tbn2[0] *= faceDirection;
1524
+ tbn2[1] *= faceDirection;
1525
+ #endif
1526
+ #endif
1527
+ vec3 nonPerturbedNormal = normal;`,Oh=`#ifdef USE_NORMALMAP_OBJECTSPACE
1528
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1529
+ #ifdef FLIP_SIDED
1530
+ normal = - normal;
1531
+ #endif
1532
+ #ifdef DOUBLE_SIDED
1533
+ normal = normal * faceDirection;
1534
+ #endif
1535
+ normal = normalize( normalMatrix * normal );
1536
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1537
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1538
+ mapN.xy *= normalScale;
1539
+ normal = normalize( tbn * mapN );
1540
+ #elif defined( USE_BUMPMAP )
1541
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1542
+ #endif`,Bh=`#ifndef FLAT_SHADED
1543
+ varying vec3 vNormal;
1544
+ #ifdef USE_TANGENT
1545
+ varying vec3 vTangent;
1546
+ varying vec3 vBitangent;
1547
+ #endif
1548
+ #endif`,zh=`#ifndef FLAT_SHADED
1549
+ varying vec3 vNormal;
1550
+ #ifdef USE_TANGENT
1551
+ varying vec3 vTangent;
1552
+ varying vec3 vBitangent;
1553
+ #endif
1554
+ #endif`,Hh=`#ifndef FLAT_SHADED
1555
+ vNormal = normalize( transformedNormal );
1556
+ #ifdef USE_TANGENT
1557
+ vTangent = normalize( transformedTangent );
1558
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1559
+ #endif
1560
+ #endif`,Gh=`#ifdef USE_NORMALMAP
1561
+ uniform sampler2D normalMap;
1562
+ uniform vec2 normalScale;
1563
+ #endif
1564
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1565
+ uniform mat3 normalMatrix;
1566
+ #endif
1567
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1568
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1569
+ vec3 q0 = dFdx( eye_pos.xyz );
1570
+ vec3 q1 = dFdy( eye_pos.xyz );
1571
+ vec2 st0 = dFdx( uv.st );
1572
+ vec2 st1 = dFdy( uv.st );
1573
+ vec3 N = surf_norm;
1574
+ vec3 q1perp = cross( q1, N );
1575
+ vec3 q0perp = cross( N, q0 );
1576
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1577
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1578
+ float det = max( dot( T, T ), dot( B, B ) );
1579
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1580
+ return mat3( T * scale, B * scale, N );
1581
+ }
1582
+ #endif`,Vh=`#ifdef USE_CLEARCOAT
1583
+ vec3 clearcoatNormal = nonPerturbedNormal;
1584
+ #endif`,kh=`#ifdef USE_CLEARCOAT_NORMALMAP
1585
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1586
+ clearcoatMapN.xy *= clearcoatNormalScale;
1587
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1588
+ #endif`,Wh=`#ifdef USE_CLEARCOATMAP
1589
+ uniform sampler2D clearcoatMap;
1590
+ #endif
1591
+ #ifdef USE_CLEARCOAT_NORMALMAP
1592
+ uniform sampler2D clearcoatNormalMap;
1593
+ uniform vec2 clearcoatNormalScale;
1594
+ #endif
1595
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1596
+ uniform sampler2D clearcoatRoughnessMap;
1597
+ #endif`,Xh=`#ifdef USE_IRIDESCENCEMAP
1598
+ uniform sampler2D iridescenceMap;
1599
+ #endif
1600
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1601
+ uniform sampler2D iridescenceThicknessMap;
1602
+ #endif`,qh=`#ifdef OPAQUE
1603
+ diffuseColor.a = 1.0;
1604
+ #endif
1605
+ #ifdef USE_TRANSMISSION
1606
+ diffuseColor.a *= material.transmissionAlpha;
1607
+ #endif
1608
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Yh=`vec3 packNormalToRGB( const in vec3 normal ) {
1609
+ return normalize( normal ) * 0.5 + 0.5;
1610
+ }
1611
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1612
+ return 2.0 * rgb.xyz - 1.0;
1613
+ }
1614
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
1615
+ const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
1616
+ const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
1617
+ const float ShiftRight8 = 1. / 256.;
1618
+ vec4 packDepthToRGBA( const in float v ) {
1619
+ vec4 r = vec4( fract( v * PackFactors ), v );
1620
+ r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
1621
+ }
1622
+ float unpackRGBAToDepth( const in vec4 v ) {
1623
+ return dot( v, UnpackFactors );
1624
+ }
1625
+ vec2 packDepthToRG( in highp float v ) {
1626
+ return packDepthToRGBA( v ).yx;
1627
+ }
1628
+ float unpackRGToDepth( const in highp vec2 v ) {
1629
+ return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
1630
+ }
1631
+ vec4 pack2HalfToRGBA( vec2 v ) {
1632
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1633
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1634
+ }
1635
+ vec2 unpackRGBATo2Half( vec4 v ) {
1636
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1637
+ }
1638
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1639
+ return ( viewZ + near ) / ( near - far );
1640
+ }
1641
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1642
+ return depth * ( near - far ) - near;
1643
+ }
1644
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1645
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1646
+ }
1647
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1648
+ return ( near * far ) / ( ( far - near ) * depth - far );
1649
+ }`,Kh=`#ifdef PREMULTIPLIED_ALPHA
1650
+ gl_FragColor.rgb *= gl_FragColor.a;
1651
+ #endif`,$h=`vec4 mvPosition = vec4( transformed, 1.0 );
1652
+ #ifdef USE_BATCHING
1653
+ mvPosition = batchingMatrix * mvPosition;
1654
+ #endif
1655
+ #ifdef USE_INSTANCING
1656
+ mvPosition = instanceMatrix * mvPosition;
1657
+ #endif
1658
+ mvPosition = modelViewMatrix * mvPosition;
1659
+ gl_Position = projectionMatrix * mvPosition;`,Zh=`#ifdef DITHERING
1660
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1661
+ #endif`,jh=`#ifdef DITHERING
1662
+ vec3 dithering( vec3 color ) {
1663
+ float grid_position = rand( gl_FragCoord.xy );
1664
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1665
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1666
+ return color + dither_shift_RGB;
1667
+ }
1668
+ #endif`,Jh=`float roughnessFactor = roughness;
1669
+ #ifdef USE_ROUGHNESSMAP
1670
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1671
+ roughnessFactor *= texelRoughness.g;
1672
+ #endif`,Qh=`#ifdef USE_ROUGHNESSMAP
1673
+ uniform sampler2D roughnessMap;
1674
+ #endif`,tu=`#if NUM_SPOT_LIGHT_COORDS > 0
1675
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1676
+ #endif
1677
+ #if NUM_SPOT_LIGHT_MAPS > 0
1678
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1679
+ #endif
1680
+ #ifdef USE_SHADOWMAP
1681
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1682
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1683
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1684
+ struct DirectionalLightShadow {
1685
+ float shadowBias;
1686
+ float shadowNormalBias;
1687
+ float shadowRadius;
1688
+ vec2 shadowMapSize;
1689
+ };
1690
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1691
+ #endif
1692
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1693
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1694
+ struct SpotLightShadow {
1695
+ float shadowBias;
1696
+ float shadowNormalBias;
1697
+ float shadowRadius;
1698
+ vec2 shadowMapSize;
1699
+ };
1700
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1701
+ #endif
1702
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1703
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1704
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1705
+ struct PointLightShadow {
1706
+ float shadowBias;
1707
+ float shadowNormalBias;
1708
+ float shadowRadius;
1709
+ vec2 shadowMapSize;
1710
+ float shadowCameraNear;
1711
+ float shadowCameraFar;
1712
+ };
1713
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1714
+ #endif
1715
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1716
+ return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
1717
+ }
1718
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1719
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1720
+ }
1721
+ float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
1722
+ float occlusion = 1.0;
1723
+ vec2 distribution = texture2DDistribution( shadow, uv );
1724
+ float hard_shadow = step( compare , distribution.x );
1725
+ if (hard_shadow != 1.0 ) {
1726
+ float distance = compare - distribution.x ;
1727
+ float variance = max( 0.00000, distribution.y * distribution.y );
1728
+ 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 );
1729
+ }
1730
+ return occlusion;
1731
+ }
1732
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1733
+ float shadow = 1.0;
1734
+ shadowCoord.xyz /= shadowCoord.w;
1735
+ shadowCoord.z += shadowBias;
1736
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1737
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1738
+ if ( frustumTest ) {
1739
+ #if defined( SHADOWMAP_TYPE_PCF )
1740
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1741
+ float dx0 = - texelSize.x * shadowRadius;
1742
+ float dy0 = - texelSize.y * shadowRadius;
1743
+ float dx1 = + texelSize.x * shadowRadius;
1744
+ float dy1 = + texelSize.y * shadowRadius;
1745
+ float dx2 = dx0 / 2.0;
1746
+ float dy2 = dy0 / 2.0;
1747
+ float dx3 = dx1 / 2.0;
1748
+ float dy3 = dy1 / 2.0;
1749
+ shadow = (
1750
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1751
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1752
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1753
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1754
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1755
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1756
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1757
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1758
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1759
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1760
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1761
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1762
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1763
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1764
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1765
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1766
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1767
+ ) * ( 1.0 / 17.0 );
1768
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1769
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1770
+ float dx = texelSize.x;
1771
+ float dy = texelSize.y;
1772
+ vec2 uv = shadowCoord.xy;
1773
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1774
+ uv -= f * texelSize;
1775
+ shadow = (
1776
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1777
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1778
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1779
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1780
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1781
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1782
+ f.x ) +
1783
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1784
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1785
+ f.x ) +
1786
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1787
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1788
+ f.y ) +
1789
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1790
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1791
+ f.y ) +
1792
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1793
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1794
+ f.x ),
1795
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1796
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1797
+ f.x ),
1798
+ f.y )
1799
+ ) * ( 1.0 / 9.0 );
1800
+ #elif defined( SHADOWMAP_TYPE_VSM )
1801
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1802
+ #else
1803
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1804
+ #endif
1805
+ }
1806
+ return shadow;
1807
+ }
1808
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1809
+ vec3 absV = abs( v );
1810
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1811
+ absV *= scaleToCube;
1812
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1813
+ vec2 planar = v.xy;
1814
+ float almostATexel = 1.5 * texelSizeY;
1815
+ float almostOne = 1.0 - almostATexel;
1816
+ if ( absV.z >= almostOne ) {
1817
+ if ( v.z > 0.0 )
1818
+ planar.x = 4.0 - v.x;
1819
+ } else if ( absV.x >= almostOne ) {
1820
+ float signX = sign( v.x );
1821
+ planar.x = v.z * signX + 2.0 * signX;
1822
+ } else if ( absV.y >= almostOne ) {
1823
+ float signY = sign( v.y );
1824
+ planar.x = v.x + 2.0 * signY + 2.0;
1825
+ planar.y = v.z * signY - 2.0;
1826
+ }
1827
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1828
+ }
1829
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1830
+ float shadow = 1.0;
1831
+ vec3 lightToPosition = shadowCoord.xyz;
1832
+
1833
+ float lightToPositionLength = length( lightToPosition );
1834
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1835
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1836
+ vec3 bd3D = normalize( lightToPosition );
1837
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1838
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1839
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1840
+ shadow = (
1841
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1842
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1843
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1844
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1845
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1846
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1847
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1848
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1849
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1850
+ ) * ( 1.0 / 9.0 );
1851
+ #else
1852
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1853
+ #endif
1854
+ }
1855
+ return shadow;
1856
+ }
1857
+ #endif`,eu=`#if NUM_SPOT_LIGHT_COORDS > 0
1858
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1859
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1860
+ #endif
1861
+ #ifdef USE_SHADOWMAP
1862
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1863
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1864
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1865
+ struct DirectionalLightShadow {
1866
+ float shadowBias;
1867
+ float shadowNormalBias;
1868
+ float shadowRadius;
1869
+ vec2 shadowMapSize;
1870
+ };
1871
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1872
+ #endif
1873
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1874
+ struct SpotLightShadow {
1875
+ float shadowBias;
1876
+ float shadowNormalBias;
1877
+ float shadowRadius;
1878
+ vec2 shadowMapSize;
1879
+ };
1880
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1881
+ #endif
1882
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1883
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1884
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1885
+ struct PointLightShadow {
1886
+ float shadowBias;
1887
+ float shadowNormalBias;
1888
+ float shadowRadius;
1889
+ vec2 shadowMapSize;
1890
+ float shadowCameraNear;
1891
+ float shadowCameraFar;
1892
+ };
1893
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1894
+ #endif
1895
+ #endif`,nu=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1896
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1897
+ vec4 shadowWorldPosition;
1898
+ #endif
1899
+ #if defined( USE_SHADOWMAP )
1900
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1901
+ #pragma unroll_loop_start
1902
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1903
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1904
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1905
+ }
1906
+ #pragma unroll_loop_end
1907
+ #endif
1908
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1909
+ #pragma unroll_loop_start
1910
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1911
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1912
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1913
+ }
1914
+ #pragma unroll_loop_end
1915
+ #endif
1916
+ #endif
1917
+ #if NUM_SPOT_LIGHT_COORDS > 0
1918
+ #pragma unroll_loop_start
1919
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1920
+ shadowWorldPosition = worldPosition;
1921
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1922
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1923
+ #endif
1924
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1925
+ }
1926
+ #pragma unroll_loop_end
1927
+ #endif`,iu=`float getShadowMask() {
1928
+ float shadow = 1.0;
1929
+ #ifdef USE_SHADOWMAP
1930
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1931
+ DirectionalLightShadow directionalLight;
1932
+ #pragma unroll_loop_start
1933
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1934
+ directionalLight = directionalLightShadows[ i ];
1935
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1936
+ }
1937
+ #pragma unroll_loop_end
1938
+ #endif
1939
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1940
+ SpotLightShadow spotLight;
1941
+ #pragma unroll_loop_start
1942
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1943
+ spotLight = spotLightShadows[ i ];
1944
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1945
+ }
1946
+ #pragma unroll_loop_end
1947
+ #endif
1948
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1949
+ PointLightShadow pointLight;
1950
+ #pragma unroll_loop_start
1951
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1952
+ pointLight = pointLightShadows[ i ];
1953
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1954
+ }
1955
+ #pragma unroll_loop_end
1956
+ #endif
1957
+ #endif
1958
+ return shadow;
1959
+ }`,ru=`#ifdef USE_SKINNING
1960
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1961
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1962
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1963
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1964
+ #endif`,su=`#ifdef USE_SKINNING
1965
+ uniform mat4 bindMatrix;
1966
+ uniform mat4 bindMatrixInverse;
1967
+ uniform highp sampler2D boneTexture;
1968
+ mat4 getBoneMatrix( const in float i ) {
1969
+ int size = textureSize( boneTexture, 0 ).x;
1970
+ int j = int( i ) * 4;
1971
+ int x = j % size;
1972
+ int y = j / size;
1973
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
1974
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
1975
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
1976
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
1977
+ return mat4( v1, v2, v3, v4 );
1978
+ }
1979
+ #endif`,au=`#ifdef USE_SKINNING
1980
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
1981
+ vec4 skinned = vec4( 0.0 );
1982
+ skinned += boneMatX * skinVertex * skinWeight.x;
1983
+ skinned += boneMatY * skinVertex * skinWeight.y;
1984
+ skinned += boneMatZ * skinVertex * skinWeight.z;
1985
+ skinned += boneMatW * skinVertex * skinWeight.w;
1986
+ transformed = ( bindMatrixInverse * skinned ).xyz;
1987
+ #endif`,ou=`#ifdef USE_SKINNING
1988
+ mat4 skinMatrix = mat4( 0.0 );
1989
+ skinMatrix += skinWeight.x * boneMatX;
1990
+ skinMatrix += skinWeight.y * boneMatY;
1991
+ skinMatrix += skinWeight.z * boneMatZ;
1992
+ skinMatrix += skinWeight.w * boneMatW;
1993
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
1994
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
1995
+ #ifdef USE_TANGENT
1996
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
1997
+ #endif
1998
+ #endif`,lu=`float specularStrength;
1999
+ #ifdef USE_SPECULARMAP
2000
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2001
+ specularStrength = texelSpecular.r;
2002
+ #else
2003
+ specularStrength = 1.0;
2004
+ #endif`,cu=`#ifdef USE_SPECULARMAP
2005
+ uniform sampler2D specularMap;
2006
+ #endif`,hu=`#if defined( TONE_MAPPING )
2007
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2008
+ #endif`,uu=`#ifndef saturate
2009
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2010
+ #endif
2011
+ uniform float toneMappingExposure;
2012
+ vec3 LinearToneMapping( vec3 color ) {
2013
+ return saturate( toneMappingExposure * color );
2014
+ }
2015
+ vec3 ReinhardToneMapping( vec3 color ) {
2016
+ color *= toneMappingExposure;
2017
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2018
+ }
2019
+ vec3 OptimizedCineonToneMapping( vec3 color ) {
2020
+ color *= toneMappingExposure;
2021
+ color = max( vec3( 0.0 ), color - 0.004 );
2022
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2023
+ }
2024
+ vec3 RRTAndODTFit( vec3 v ) {
2025
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2026
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2027
+ return a / b;
2028
+ }
2029
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2030
+ const mat3 ACESInputMat = mat3(
2031
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2032
+ vec3( 0.04823, 0.01566, 0.83777 )
2033
+ );
2034
+ const mat3 ACESOutputMat = mat3(
2035
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2036
+ vec3( -0.07367, -0.00605, 1.07602 )
2037
+ );
2038
+ color *= toneMappingExposure / 0.6;
2039
+ color = ACESInputMat * color;
2040
+ color = RRTAndODTFit( color );
2041
+ color = ACESOutputMat * color;
2042
+ return saturate( color );
2043
+ }
2044
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2045
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2046
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2047
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2048
+ );
2049
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2050
+ vec3( 0.6274, 0.0691, 0.0164 ),
2051
+ vec3( 0.3293, 0.9195, 0.0880 ),
2052
+ vec3( 0.0433, 0.0113, 0.8956 )
2053
+ );
2054
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2055
+ vec3 x2 = x * x;
2056
+ vec3 x4 = x2 * x2;
2057
+ return + 15.5 * x4 * x2
2058
+ - 40.14 * x4 * x
2059
+ + 31.96 * x4
2060
+ - 6.868 * x2 * x
2061
+ + 0.4298 * x2
2062
+ + 0.1191 * x
2063
+ - 0.00232;
2064
+ }
2065
+ vec3 AgXToneMapping( vec3 color ) {
2066
+ const mat3 AgXInsetMatrix = mat3(
2067
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2068
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2069
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2070
+ );
2071
+ const mat3 AgXOutsetMatrix = mat3(
2072
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2073
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2074
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2075
+ );
2076
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2077
+ color *= toneMappingExposure;
2078
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2079
+ color = AgXInsetMatrix * color;
2080
+ color = max( color, 1e-10 ); color = log2( color );
2081
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2082
+ color = clamp( color, 0.0, 1.0 );
2083
+ color = agxDefaultContrastApprox( color );
2084
+ color = AgXOutsetMatrix * color;
2085
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2086
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2087
+ color = clamp( color, 0.0, 1.0 );
2088
+ return color;
2089
+ }
2090
+ vec3 NeutralToneMapping( vec3 color ) {
2091
+ const float StartCompression = 0.8 - 0.04;
2092
+ const float Desaturation = 0.15;
2093
+ color *= toneMappingExposure;
2094
+ float x = min( color.r, min( color.g, color.b ) );
2095
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2096
+ color -= offset;
2097
+ float peak = max( color.r, max( color.g, color.b ) );
2098
+ if ( peak < StartCompression ) return color;
2099
+ float d = 1. - StartCompression;
2100
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2101
+ color *= newPeak / peak;
2102
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2103
+ return mix( color, vec3( newPeak ), g );
2104
+ }
2105
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,du=`#ifdef USE_TRANSMISSION
2106
+ material.transmission = transmission;
2107
+ material.transmissionAlpha = 1.0;
2108
+ material.thickness = thickness;
2109
+ material.attenuationDistance = attenuationDistance;
2110
+ material.attenuationColor = attenuationColor;
2111
+ #ifdef USE_TRANSMISSIONMAP
2112
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2113
+ #endif
2114
+ #ifdef USE_THICKNESSMAP
2115
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2116
+ #endif
2117
+ vec3 pos = vWorldPosition;
2118
+ vec3 v = normalize( cameraPosition - pos );
2119
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2120
+ vec4 transmitted = getIBLVolumeRefraction(
2121
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2122
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2123
+ material.attenuationColor, material.attenuationDistance );
2124
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2125
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2126
+ #endif`,fu=`#ifdef USE_TRANSMISSION
2127
+ uniform float transmission;
2128
+ uniform float thickness;
2129
+ uniform float attenuationDistance;
2130
+ uniform vec3 attenuationColor;
2131
+ #ifdef USE_TRANSMISSIONMAP
2132
+ uniform sampler2D transmissionMap;
2133
+ #endif
2134
+ #ifdef USE_THICKNESSMAP
2135
+ uniform sampler2D thicknessMap;
2136
+ #endif
2137
+ uniform vec2 transmissionSamplerSize;
2138
+ uniform sampler2D transmissionSamplerMap;
2139
+ uniform mat4 modelMatrix;
2140
+ uniform mat4 projectionMatrix;
2141
+ varying vec3 vWorldPosition;
2142
+ float w0( float a ) {
2143
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2144
+ }
2145
+ float w1( float a ) {
2146
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2147
+ }
2148
+ float w2( float a ){
2149
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2150
+ }
2151
+ float w3( float a ) {
2152
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2153
+ }
2154
+ float g0( float a ) {
2155
+ return w0( a ) + w1( a );
2156
+ }
2157
+ float g1( float a ) {
2158
+ return w2( a ) + w3( a );
2159
+ }
2160
+ float h0( float a ) {
2161
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2162
+ }
2163
+ float h1( float a ) {
2164
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2165
+ }
2166
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2167
+ uv = uv * texelSize.zw + 0.5;
2168
+ vec2 iuv = floor( uv );
2169
+ vec2 fuv = fract( uv );
2170
+ float g0x = g0( fuv.x );
2171
+ float g1x = g1( fuv.x );
2172
+ float h0x = h0( fuv.x );
2173
+ float h1x = h1( fuv.x );
2174
+ float h0y = h0( fuv.y );
2175
+ float h1y = h1( fuv.y );
2176
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2177
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2178
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2179
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2180
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2181
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2182
+ }
2183
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2184
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2185
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2186
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2187
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2188
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2189
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2190
+ return mix( fSample, cSample, fract( lod ) );
2191
+ }
2192
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2193
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2194
+ vec3 modelScale;
2195
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2196
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2197
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2198
+ return normalize( refractionVector ) * thickness * modelScale;
2199
+ }
2200
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2201
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2202
+ }
2203
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2204
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2205
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2206
+ }
2207
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2208
+ if ( isinf( attenuationDistance ) ) {
2209
+ return vec3( 1.0 );
2210
+ } else {
2211
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2212
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2213
+ }
2214
+ }
2215
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2216
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2217
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2218
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2219
+ vec4 transmittedLight;
2220
+ vec3 transmittance;
2221
+ #ifdef USE_DISPERSION
2222
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2223
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2224
+ for ( int i = 0; i < 3; i ++ ) {
2225
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2226
+ vec3 refractedRayExit = position + transmissionRay;
2227
+
2228
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2229
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2230
+ refractionCoords += 1.0;
2231
+ refractionCoords /= 2.0;
2232
+
2233
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2234
+ transmittedLight[ i ] = transmissionSample[ i ];
2235
+ transmittedLight.a += transmissionSample.a;
2236
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2237
+ }
2238
+ transmittedLight.a /= 3.0;
2239
+
2240
+ #else
2241
+
2242
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2243
+ vec3 refractedRayExit = position + transmissionRay;
2244
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2245
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2246
+ refractionCoords += 1.0;
2247
+ refractionCoords /= 2.0;
2248
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2249
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2250
+
2251
+ #endif
2252
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2253
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2254
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2255
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2256
+ }
2257
+ #endif`,pu=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2258
+ varying vec2 vUv;
2259
+ #endif
2260
+ #ifdef USE_MAP
2261
+ varying vec2 vMapUv;
2262
+ #endif
2263
+ #ifdef USE_ALPHAMAP
2264
+ varying vec2 vAlphaMapUv;
2265
+ #endif
2266
+ #ifdef USE_LIGHTMAP
2267
+ varying vec2 vLightMapUv;
2268
+ #endif
2269
+ #ifdef USE_AOMAP
2270
+ varying vec2 vAoMapUv;
2271
+ #endif
2272
+ #ifdef USE_BUMPMAP
2273
+ varying vec2 vBumpMapUv;
2274
+ #endif
2275
+ #ifdef USE_NORMALMAP
2276
+ varying vec2 vNormalMapUv;
2277
+ #endif
2278
+ #ifdef USE_EMISSIVEMAP
2279
+ varying vec2 vEmissiveMapUv;
2280
+ #endif
2281
+ #ifdef USE_METALNESSMAP
2282
+ varying vec2 vMetalnessMapUv;
2283
+ #endif
2284
+ #ifdef USE_ROUGHNESSMAP
2285
+ varying vec2 vRoughnessMapUv;
2286
+ #endif
2287
+ #ifdef USE_ANISOTROPYMAP
2288
+ varying vec2 vAnisotropyMapUv;
2289
+ #endif
2290
+ #ifdef USE_CLEARCOATMAP
2291
+ varying vec2 vClearcoatMapUv;
2292
+ #endif
2293
+ #ifdef USE_CLEARCOAT_NORMALMAP
2294
+ varying vec2 vClearcoatNormalMapUv;
2295
+ #endif
2296
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2297
+ varying vec2 vClearcoatRoughnessMapUv;
2298
+ #endif
2299
+ #ifdef USE_IRIDESCENCEMAP
2300
+ varying vec2 vIridescenceMapUv;
2301
+ #endif
2302
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2303
+ varying vec2 vIridescenceThicknessMapUv;
2304
+ #endif
2305
+ #ifdef USE_SHEEN_COLORMAP
2306
+ varying vec2 vSheenColorMapUv;
2307
+ #endif
2308
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2309
+ varying vec2 vSheenRoughnessMapUv;
2310
+ #endif
2311
+ #ifdef USE_SPECULARMAP
2312
+ varying vec2 vSpecularMapUv;
2313
+ #endif
2314
+ #ifdef USE_SPECULAR_COLORMAP
2315
+ varying vec2 vSpecularColorMapUv;
2316
+ #endif
2317
+ #ifdef USE_SPECULAR_INTENSITYMAP
2318
+ varying vec2 vSpecularIntensityMapUv;
2319
+ #endif
2320
+ #ifdef USE_TRANSMISSIONMAP
2321
+ uniform mat3 transmissionMapTransform;
2322
+ varying vec2 vTransmissionMapUv;
2323
+ #endif
2324
+ #ifdef USE_THICKNESSMAP
2325
+ uniform mat3 thicknessMapTransform;
2326
+ varying vec2 vThicknessMapUv;
2327
+ #endif`,mu=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2328
+ varying vec2 vUv;
2329
+ #endif
2330
+ #ifdef USE_MAP
2331
+ uniform mat3 mapTransform;
2332
+ varying vec2 vMapUv;
2333
+ #endif
2334
+ #ifdef USE_ALPHAMAP
2335
+ uniform mat3 alphaMapTransform;
2336
+ varying vec2 vAlphaMapUv;
2337
+ #endif
2338
+ #ifdef USE_LIGHTMAP
2339
+ uniform mat3 lightMapTransform;
2340
+ varying vec2 vLightMapUv;
2341
+ #endif
2342
+ #ifdef USE_AOMAP
2343
+ uniform mat3 aoMapTransform;
2344
+ varying vec2 vAoMapUv;
2345
+ #endif
2346
+ #ifdef USE_BUMPMAP
2347
+ uniform mat3 bumpMapTransform;
2348
+ varying vec2 vBumpMapUv;
2349
+ #endif
2350
+ #ifdef USE_NORMALMAP
2351
+ uniform mat3 normalMapTransform;
2352
+ varying vec2 vNormalMapUv;
2353
+ #endif
2354
+ #ifdef USE_DISPLACEMENTMAP
2355
+ uniform mat3 displacementMapTransform;
2356
+ varying vec2 vDisplacementMapUv;
2357
+ #endif
2358
+ #ifdef USE_EMISSIVEMAP
2359
+ uniform mat3 emissiveMapTransform;
2360
+ varying vec2 vEmissiveMapUv;
2361
+ #endif
2362
+ #ifdef USE_METALNESSMAP
2363
+ uniform mat3 metalnessMapTransform;
2364
+ varying vec2 vMetalnessMapUv;
2365
+ #endif
2366
+ #ifdef USE_ROUGHNESSMAP
2367
+ uniform mat3 roughnessMapTransform;
2368
+ varying vec2 vRoughnessMapUv;
2369
+ #endif
2370
+ #ifdef USE_ANISOTROPYMAP
2371
+ uniform mat3 anisotropyMapTransform;
2372
+ varying vec2 vAnisotropyMapUv;
2373
+ #endif
2374
+ #ifdef USE_CLEARCOATMAP
2375
+ uniform mat3 clearcoatMapTransform;
2376
+ varying vec2 vClearcoatMapUv;
2377
+ #endif
2378
+ #ifdef USE_CLEARCOAT_NORMALMAP
2379
+ uniform mat3 clearcoatNormalMapTransform;
2380
+ varying vec2 vClearcoatNormalMapUv;
2381
+ #endif
2382
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2383
+ uniform mat3 clearcoatRoughnessMapTransform;
2384
+ varying vec2 vClearcoatRoughnessMapUv;
2385
+ #endif
2386
+ #ifdef USE_SHEEN_COLORMAP
2387
+ uniform mat3 sheenColorMapTransform;
2388
+ varying vec2 vSheenColorMapUv;
2389
+ #endif
2390
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2391
+ uniform mat3 sheenRoughnessMapTransform;
2392
+ varying vec2 vSheenRoughnessMapUv;
2393
+ #endif
2394
+ #ifdef USE_IRIDESCENCEMAP
2395
+ uniform mat3 iridescenceMapTransform;
2396
+ varying vec2 vIridescenceMapUv;
2397
+ #endif
2398
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2399
+ uniform mat3 iridescenceThicknessMapTransform;
2400
+ varying vec2 vIridescenceThicknessMapUv;
2401
+ #endif
2402
+ #ifdef USE_SPECULARMAP
2403
+ uniform mat3 specularMapTransform;
2404
+ varying vec2 vSpecularMapUv;
2405
+ #endif
2406
+ #ifdef USE_SPECULAR_COLORMAP
2407
+ uniform mat3 specularColorMapTransform;
2408
+ varying vec2 vSpecularColorMapUv;
2409
+ #endif
2410
+ #ifdef USE_SPECULAR_INTENSITYMAP
2411
+ uniform mat3 specularIntensityMapTransform;
2412
+ varying vec2 vSpecularIntensityMapUv;
2413
+ #endif
2414
+ #ifdef USE_TRANSMISSIONMAP
2415
+ uniform mat3 transmissionMapTransform;
2416
+ varying vec2 vTransmissionMapUv;
2417
+ #endif
2418
+ #ifdef USE_THICKNESSMAP
2419
+ uniform mat3 thicknessMapTransform;
2420
+ varying vec2 vThicknessMapUv;
2421
+ #endif`,_u=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2422
+ vUv = vec3( uv, 1 ).xy;
2423
+ #endif
2424
+ #ifdef USE_MAP
2425
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2426
+ #endif
2427
+ #ifdef USE_ALPHAMAP
2428
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2429
+ #endif
2430
+ #ifdef USE_LIGHTMAP
2431
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2432
+ #endif
2433
+ #ifdef USE_AOMAP
2434
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2435
+ #endif
2436
+ #ifdef USE_BUMPMAP
2437
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2438
+ #endif
2439
+ #ifdef USE_NORMALMAP
2440
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2441
+ #endif
2442
+ #ifdef USE_DISPLACEMENTMAP
2443
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2444
+ #endif
2445
+ #ifdef USE_EMISSIVEMAP
2446
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2447
+ #endif
2448
+ #ifdef USE_METALNESSMAP
2449
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2450
+ #endif
2451
+ #ifdef USE_ROUGHNESSMAP
2452
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2453
+ #endif
2454
+ #ifdef USE_ANISOTROPYMAP
2455
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2456
+ #endif
2457
+ #ifdef USE_CLEARCOATMAP
2458
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2459
+ #endif
2460
+ #ifdef USE_CLEARCOAT_NORMALMAP
2461
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2462
+ #endif
2463
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2464
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2465
+ #endif
2466
+ #ifdef USE_IRIDESCENCEMAP
2467
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2468
+ #endif
2469
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2470
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2471
+ #endif
2472
+ #ifdef USE_SHEEN_COLORMAP
2473
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2474
+ #endif
2475
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2476
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2477
+ #endif
2478
+ #ifdef USE_SPECULARMAP
2479
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2480
+ #endif
2481
+ #ifdef USE_SPECULAR_COLORMAP
2482
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2483
+ #endif
2484
+ #ifdef USE_SPECULAR_INTENSITYMAP
2485
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2486
+ #endif
2487
+ #ifdef USE_TRANSMISSIONMAP
2488
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2489
+ #endif
2490
+ #ifdef USE_THICKNESSMAP
2491
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2492
+ #endif`,gu=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2493
+ vec4 worldPosition = vec4( transformed, 1.0 );
2494
+ #ifdef USE_BATCHING
2495
+ worldPosition = batchingMatrix * worldPosition;
2496
+ #endif
2497
+ #ifdef USE_INSTANCING
2498
+ worldPosition = instanceMatrix * worldPosition;
2499
+ #endif
2500
+ worldPosition = modelMatrix * worldPosition;
2501
+ #endif`;const vu=`varying vec2 vUv;
2502
+ uniform mat3 uvTransform;
2503
+ void main() {
2504
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2505
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2506
+ }`,xu=`uniform sampler2D t2D;
2507
+ uniform float backgroundIntensity;
2508
+ varying vec2 vUv;
2509
+ void main() {
2510
+ vec4 texColor = texture2D( t2D, vUv );
2511
+ #ifdef DECODE_VIDEO_TEXTURE
2512
+ 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 );
2513
+ #endif
2514
+ texColor.rgb *= backgroundIntensity;
2515
+ gl_FragColor = texColor;
2516
+ #include <tonemapping_fragment>
2517
+ #include <colorspace_fragment>
2518
+ }`,Mu=`varying vec3 vWorldDirection;
2519
+ #include <common>
2520
+ void main() {
2521
+ vWorldDirection = transformDirection( position, modelMatrix );
2522
+ #include <begin_vertex>
2523
+ #include <project_vertex>
2524
+ gl_Position.z = gl_Position.w;
2525
+ }`,Su=`#ifdef ENVMAP_TYPE_CUBE
2526
+ uniform samplerCube envMap;
2527
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2528
+ uniform sampler2D envMap;
2529
+ #endif
2530
+ uniform float flipEnvMap;
2531
+ uniform float backgroundBlurriness;
2532
+ uniform float backgroundIntensity;
2533
+ uniform mat3 backgroundRotation;
2534
+ varying vec3 vWorldDirection;
2535
+ #include <cube_uv_reflection_fragment>
2536
+ void main() {
2537
+ #ifdef ENVMAP_TYPE_CUBE
2538
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2539
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2540
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2541
+ #else
2542
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2543
+ #endif
2544
+ texColor.rgb *= backgroundIntensity;
2545
+ gl_FragColor = texColor;
2546
+ #include <tonemapping_fragment>
2547
+ #include <colorspace_fragment>
2548
+ }`,Eu=`varying vec3 vWorldDirection;
2549
+ #include <common>
2550
+ void main() {
2551
+ vWorldDirection = transformDirection( position, modelMatrix );
2552
+ #include <begin_vertex>
2553
+ #include <project_vertex>
2554
+ gl_Position.z = gl_Position.w;
2555
+ }`,yu=`uniform samplerCube tCube;
2556
+ uniform float tFlip;
2557
+ uniform float opacity;
2558
+ varying vec3 vWorldDirection;
2559
+ void main() {
2560
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2561
+ gl_FragColor = texColor;
2562
+ gl_FragColor.a *= opacity;
2563
+ #include <tonemapping_fragment>
2564
+ #include <colorspace_fragment>
2565
+ }`,Tu=`#include <common>
2566
+ #include <batching_pars_vertex>
2567
+ #include <uv_pars_vertex>
2568
+ #include <displacementmap_pars_vertex>
2569
+ #include <morphtarget_pars_vertex>
2570
+ #include <skinning_pars_vertex>
2571
+ #include <logdepthbuf_pars_vertex>
2572
+ #include <clipping_planes_pars_vertex>
2573
+ varying vec2 vHighPrecisionZW;
2574
+ void main() {
2575
+ #include <uv_vertex>
2576
+ #include <batching_vertex>
2577
+ #include <skinbase_vertex>
2578
+ #include <morphinstance_vertex>
2579
+ #ifdef USE_DISPLACEMENTMAP
2580
+ #include <beginnormal_vertex>
2581
+ #include <morphnormal_vertex>
2582
+ #include <skinnormal_vertex>
2583
+ #endif
2584
+ #include <begin_vertex>
2585
+ #include <morphtarget_vertex>
2586
+ #include <skinning_vertex>
2587
+ #include <displacementmap_vertex>
2588
+ #include <project_vertex>
2589
+ #include <logdepthbuf_vertex>
2590
+ #include <clipping_planes_vertex>
2591
+ vHighPrecisionZW = gl_Position.zw;
2592
+ }`,Au=`#if DEPTH_PACKING == 3200
2593
+ uniform float opacity;
2594
+ #endif
2595
+ #include <common>
2596
+ #include <packing>
2597
+ #include <uv_pars_fragment>
2598
+ #include <map_pars_fragment>
2599
+ #include <alphamap_pars_fragment>
2600
+ #include <alphatest_pars_fragment>
2601
+ #include <alphahash_pars_fragment>
2602
+ #include <logdepthbuf_pars_fragment>
2603
+ #include <clipping_planes_pars_fragment>
2604
+ varying vec2 vHighPrecisionZW;
2605
+ void main() {
2606
+ vec4 diffuseColor = vec4( 1.0 );
2607
+ #include <clipping_planes_fragment>
2608
+ #if DEPTH_PACKING == 3200
2609
+ diffuseColor.a = opacity;
2610
+ #endif
2611
+ #include <map_fragment>
2612
+ #include <alphamap_fragment>
2613
+ #include <alphatest_fragment>
2614
+ #include <alphahash_fragment>
2615
+ #include <logdepthbuf_fragment>
2616
+ float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
2617
+ #if DEPTH_PACKING == 3200
2618
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2619
+ #elif DEPTH_PACKING == 3201
2620
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2621
+ #endif
2622
+ }`,bu=`#define DISTANCE
2623
+ varying vec3 vWorldPosition;
2624
+ #include <common>
2625
+ #include <batching_pars_vertex>
2626
+ #include <uv_pars_vertex>
2627
+ #include <displacementmap_pars_vertex>
2628
+ #include <morphtarget_pars_vertex>
2629
+ #include <skinning_pars_vertex>
2630
+ #include <clipping_planes_pars_vertex>
2631
+ void main() {
2632
+ #include <uv_vertex>
2633
+ #include <batching_vertex>
2634
+ #include <skinbase_vertex>
2635
+ #include <morphinstance_vertex>
2636
+ #ifdef USE_DISPLACEMENTMAP
2637
+ #include <beginnormal_vertex>
2638
+ #include <morphnormal_vertex>
2639
+ #include <skinnormal_vertex>
2640
+ #endif
2641
+ #include <begin_vertex>
2642
+ #include <morphtarget_vertex>
2643
+ #include <skinning_vertex>
2644
+ #include <displacementmap_vertex>
2645
+ #include <project_vertex>
2646
+ #include <worldpos_vertex>
2647
+ #include <clipping_planes_vertex>
2648
+ vWorldPosition = worldPosition.xyz;
2649
+ }`,wu=`#define DISTANCE
2650
+ uniform vec3 referencePosition;
2651
+ uniform float nearDistance;
2652
+ uniform float farDistance;
2653
+ varying vec3 vWorldPosition;
2654
+ #include <common>
2655
+ #include <packing>
2656
+ #include <uv_pars_fragment>
2657
+ #include <map_pars_fragment>
2658
+ #include <alphamap_pars_fragment>
2659
+ #include <alphatest_pars_fragment>
2660
+ #include <alphahash_pars_fragment>
2661
+ #include <clipping_planes_pars_fragment>
2662
+ void main () {
2663
+ vec4 diffuseColor = vec4( 1.0 );
2664
+ #include <clipping_planes_fragment>
2665
+ #include <map_fragment>
2666
+ #include <alphamap_fragment>
2667
+ #include <alphatest_fragment>
2668
+ #include <alphahash_fragment>
2669
+ float dist = length( vWorldPosition - referencePosition );
2670
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2671
+ dist = saturate( dist );
2672
+ gl_FragColor = packDepthToRGBA( dist );
2673
+ }`,Ru=`varying vec3 vWorldDirection;
2674
+ #include <common>
2675
+ void main() {
2676
+ vWorldDirection = transformDirection( position, modelMatrix );
2677
+ #include <begin_vertex>
2678
+ #include <project_vertex>
2679
+ }`,Cu=`uniform sampler2D tEquirect;
2680
+ varying vec3 vWorldDirection;
2681
+ #include <common>
2682
+ void main() {
2683
+ vec3 direction = normalize( vWorldDirection );
2684
+ vec2 sampleUV = equirectUv( direction );
2685
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2686
+ #include <tonemapping_fragment>
2687
+ #include <colorspace_fragment>
2688
+ }`,Pu=`uniform float scale;
2689
+ attribute float lineDistance;
2690
+ varying float vLineDistance;
2691
+ #include <common>
2692
+ #include <uv_pars_vertex>
2693
+ #include <color_pars_vertex>
2694
+ #include <fog_pars_vertex>
2695
+ #include <morphtarget_pars_vertex>
2696
+ #include <logdepthbuf_pars_vertex>
2697
+ #include <clipping_planes_pars_vertex>
2698
+ void main() {
2699
+ vLineDistance = scale * lineDistance;
2700
+ #include <uv_vertex>
2701
+ #include <color_vertex>
2702
+ #include <morphinstance_vertex>
2703
+ #include <morphcolor_vertex>
2704
+ #include <begin_vertex>
2705
+ #include <morphtarget_vertex>
2706
+ #include <project_vertex>
2707
+ #include <logdepthbuf_vertex>
2708
+ #include <clipping_planes_vertex>
2709
+ #include <fog_vertex>
2710
+ }`,Lu=`uniform vec3 diffuse;
2711
+ uniform float opacity;
2712
+ uniform float dashSize;
2713
+ uniform float totalSize;
2714
+ varying float vLineDistance;
2715
+ #include <common>
2716
+ #include <color_pars_fragment>
2717
+ #include <uv_pars_fragment>
2718
+ #include <map_pars_fragment>
2719
+ #include <fog_pars_fragment>
2720
+ #include <logdepthbuf_pars_fragment>
2721
+ #include <clipping_planes_pars_fragment>
2722
+ void main() {
2723
+ vec4 diffuseColor = vec4( diffuse, opacity );
2724
+ #include <clipping_planes_fragment>
2725
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2726
+ discard;
2727
+ }
2728
+ vec3 outgoingLight = vec3( 0.0 );
2729
+ #include <logdepthbuf_fragment>
2730
+ #include <map_fragment>
2731
+ #include <color_fragment>
2732
+ outgoingLight = diffuseColor.rgb;
2733
+ #include <opaque_fragment>
2734
+ #include <tonemapping_fragment>
2735
+ #include <colorspace_fragment>
2736
+ #include <fog_fragment>
2737
+ #include <premultiplied_alpha_fragment>
2738
+ }`,Uu=`#include <common>
2739
+ #include <batching_pars_vertex>
2740
+ #include <uv_pars_vertex>
2741
+ #include <envmap_pars_vertex>
2742
+ #include <color_pars_vertex>
2743
+ #include <fog_pars_vertex>
2744
+ #include <morphtarget_pars_vertex>
2745
+ #include <skinning_pars_vertex>
2746
+ #include <logdepthbuf_pars_vertex>
2747
+ #include <clipping_planes_pars_vertex>
2748
+ void main() {
2749
+ #include <uv_vertex>
2750
+ #include <color_vertex>
2751
+ #include <morphinstance_vertex>
2752
+ #include <morphcolor_vertex>
2753
+ #include <batching_vertex>
2754
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2755
+ #include <beginnormal_vertex>
2756
+ #include <morphnormal_vertex>
2757
+ #include <skinbase_vertex>
2758
+ #include <skinnormal_vertex>
2759
+ #include <defaultnormal_vertex>
2760
+ #endif
2761
+ #include <begin_vertex>
2762
+ #include <morphtarget_vertex>
2763
+ #include <skinning_vertex>
2764
+ #include <project_vertex>
2765
+ #include <logdepthbuf_vertex>
2766
+ #include <clipping_planes_vertex>
2767
+ #include <worldpos_vertex>
2768
+ #include <envmap_vertex>
2769
+ #include <fog_vertex>
2770
+ }`,Du=`uniform vec3 diffuse;
2771
+ uniform float opacity;
2772
+ #ifndef FLAT_SHADED
2773
+ varying vec3 vNormal;
2774
+ #endif
2775
+ #include <common>
2776
+ #include <dithering_pars_fragment>
2777
+ #include <color_pars_fragment>
2778
+ #include <uv_pars_fragment>
2779
+ #include <map_pars_fragment>
2780
+ #include <alphamap_pars_fragment>
2781
+ #include <alphatest_pars_fragment>
2782
+ #include <alphahash_pars_fragment>
2783
+ #include <aomap_pars_fragment>
2784
+ #include <lightmap_pars_fragment>
2785
+ #include <envmap_common_pars_fragment>
2786
+ #include <envmap_pars_fragment>
2787
+ #include <fog_pars_fragment>
2788
+ #include <specularmap_pars_fragment>
2789
+ #include <logdepthbuf_pars_fragment>
2790
+ #include <clipping_planes_pars_fragment>
2791
+ void main() {
2792
+ vec4 diffuseColor = vec4( diffuse, opacity );
2793
+ #include <clipping_planes_fragment>
2794
+ #include <logdepthbuf_fragment>
2795
+ #include <map_fragment>
2796
+ #include <color_fragment>
2797
+ #include <alphamap_fragment>
2798
+ #include <alphatest_fragment>
2799
+ #include <alphahash_fragment>
2800
+ #include <specularmap_fragment>
2801
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2802
+ #ifdef USE_LIGHTMAP
2803
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2804
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2805
+ #else
2806
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2807
+ #endif
2808
+ #include <aomap_fragment>
2809
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2810
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2811
+ #include <envmap_fragment>
2812
+ #include <opaque_fragment>
2813
+ #include <tonemapping_fragment>
2814
+ #include <colorspace_fragment>
2815
+ #include <fog_fragment>
2816
+ #include <premultiplied_alpha_fragment>
2817
+ #include <dithering_fragment>
2818
+ }`,Iu=`#define LAMBERT
2819
+ varying vec3 vViewPosition;
2820
+ #include <common>
2821
+ #include <batching_pars_vertex>
2822
+ #include <uv_pars_vertex>
2823
+ #include <displacementmap_pars_vertex>
2824
+ #include <envmap_pars_vertex>
2825
+ #include <color_pars_vertex>
2826
+ #include <fog_pars_vertex>
2827
+ #include <normal_pars_vertex>
2828
+ #include <morphtarget_pars_vertex>
2829
+ #include <skinning_pars_vertex>
2830
+ #include <shadowmap_pars_vertex>
2831
+ #include <logdepthbuf_pars_vertex>
2832
+ #include <clipping_planes_pars_vertex>
2833
+ void main() {
2834
+ #include <uv_vertex>
2835
+ #include <color_vertex>
2836
+ #include <morphinstance_vertex>
2837
+ #include <morphcolor_vertex>
2838
+ #include <batching_vertex>
2839
+ #include <beginnormal_vertex>
2840
+ #include <morphnormal_vertex>
2841
+ #include <skinbase_vertex>
2842
+ #include <skinnormal_vertex>
2843
+ #include <defaultnormal_vertex>
2844
+ #include <normal_vertex>
2845
+ #include <begin_vertex>
2846
+ #include <morphtarget_vertex>
2847
+ #include <skinning_vertex>
2848
+ #include <displacementmap_vertex>
2849
+ #include <project_vertex>
2850
+ #include <logdepthbuf_vertex>
2851
+ #include <clipping_planes_vertex>
2852
+ vViewPosition = - mvPosition.xyz;
2853
+ #include <worldpos_vertex>
2854
+ #include <envmap_vertex>
2855
+ #include <shadowmap_vertex>
2856
+ #include <fog_vertex>
2857
+ }`,Nu=`#define LAMBERT
2858
+ uniform vec3 diffuse;
2859
+ uniform vec3 emissive;
2860
+ uniform float opacity;
2861
+ #include <common>
2862
+ #include <packing>
2863
+ #include <dithering_pars_fragment>
2864
+ #include <color_pars_fragment>
2865
+ #include <uv_pars_fragment>
2866
+ #include <map_pars_fragment>
2867
+ #include <alphamap_pars_fragment>
2868
+ #include <alphatest_pars_fragment>
2869
+ #include <alphahash_pars_fragment>
2870
+ #include <aomap_pars_fragment>
2871
+ #include <lightmap_pars_fragment>
2872
+ #include <emissivemap_pars_fragment>
2873
+ #include <envmap_common_pars_fragment>
2874
+ #include <envmap_pars_fragment>
2875
+ #include <fog_pars_fragment>
2876
+ #include <bsdfs>
2877
+ #include <lights_pars_begin>
2878
+ #include <normal_pars_fragment>
2879
+ #include <lights_lambert_pars_fragment>
2880
+ #include <shadowmap_pars_fragment>
2881
+ #include <bumpmap_pars_fragment>
2882
+ #include <normalmap_pars_fragment>
2883
+ #include <specularmap_pars_fragment>
2884
+ #include <logdepthbuf_pars_fragment>
2885
+ #include <clipping_planes_pars_fragment>
2886
+ void main() {
2887
+ vec4 diffuseColor = vec4( diffuse, opacity );
2888
+ #include <clipping_planes_fragment>
2889
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2890
+ vec3 totalEmissiveRadiance = emissive;
2891
+ #include <logdepthbuf_fragment>
2892
+ #include <map_fragment>
2893
+ #include <color_fragment>
2894
+ #include <alphamap_fragment>
2895
+ #include <alphatest_fragment>
2896
+ #include <alphahash_fragment>
2897
+ #include <specularmap_fragment>
2898
+ #include <normal_fragment_begin>
2899
+ #include <normal_fragment_maps>
2900
+ #include <emissivemap_fragment>
2901
+ #include <lights_lambert_fragment>
2902
+ #include <lights_fragment_begin>
2903
+ #include <lights_fragment_maps>
2904
+ #include <lights_fragment_end>
2905
+ #include <aomap_fragment>
2906
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2907
+ #include <envmap_fragment>
2908
+ #include <opaque_fragment>
2909
+ #include <tonemapping_fragment>
2910
+ #include <colorspace_fragment>
2911
+ #include <fog_fragment>
2912
+ #include <premultiplied_alpha_fragment>
2913
+ #include <dithering_fragment>
2914
+ }`,Fu=`#define MATCAP
2915
+ varying vec3 vViewPosition;
2916
+ #include <common>
2917
+ #include <batching_pars_vertex>
2918
+ #include <uv_pars_vertex>
2919
+ #include <color_pars_vertex>
2920
+ #include <displacementmap_pars_vertex>
2921
+ #include <fog_pars_vertex>
2922
+ #include <normal_pars_vertex>
2923
+ #include <morphtarget_pars_vertex>
2924
+ #include <skinning_pars_vertex>
2925
+ #include <logdepthbuf_pars_vertex>
2926
+ #include <clipping_planes_pars_vertex>
2927
+ void main() {
2928
+ #include <uv_vertex>
2929
+ #include <color_vertex>
2930
+ #include <morphinstance_vertex>
2931
+ #include <morphcolor_vertex>
2932
+ #include <batching_vertex>
2933
+ #include <beginnormal_vertex>
2934
+ #include <morphnormal_vertex>
2935
+ #include <skinbase_vertex>
2936
+ #include <skinnormal_vertex>
2937
+ #include <defaultnormal_vertex>
2938
+ #include <normal_vertex>
2939
+ #include <begin_vertex>
2940
+ #include <morphtarget_vertex>
2941
+ #include <skinning_vertex>
2942
+ #include <displacementmap_vertex>
2943
+ #include <project_vertex>
2944
+ #include <logdepthbuf_vertex>
2945
+ #include <clipping_planes_vertex>
2946
+ #include <fog_vertex>
2947
+ vViewPosition = - mvPosition.xyz;
2948
+ }`,Ou=`#define MATCAP
2949
+ uniform vec3 diffuse;
2950
+ uniform float opacity;
2951
+ uniform sampler2D matcap;
2952
+ varying vec3 vViewPosition;
2953
+ #include <common>
2954
+ #include <dithering_pars_fragment>
2955
+ #include <color_pars_fragment>
2956
+ #include <uv_pars_fragment>
2957
+ #include <map_pars_fragment>
2958
+ #include <alphamap_pars_fragment>
2959
+ #include <alphatest_pars_fragment>
2960
+ #include <alphahash_pars_fragment>
2961
+ #include <fog_pars_fragment>
2962
+ #include <normal_pars_fragment>
2963
+ #include <bumpmap_pars_fragment>
2964
+ #include <normalmap_pars_fragment>
2965
+ #include <logdepthbuf_pars_fragment>
2966
+ #include <clipping_planes_pars_fragment>
2967
+ void main() {
2968
+ vec4 diffuseColor = vec4( diffuse, opacity );
2969
+ #include <clipping_planes_fragment>
2970
+ #include <logdepthbuf_fragment>
2971
+ #include <map_fragment>
2972
+ #include <color_fragment>
2973
+ #include <alphamap_fragment>
2974
+ #include <alphatest_fragment>
2975
+ #include <alphahash_fragment>
2976
+ #include <normal_fragment_begin>
2977
+ #include <normal_fragment_maps>
2978
+ vec3 viewDir = normalize( vViewPosition );
2979
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
2980
+ vec3 y = cross( viewDir, x );
2981
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
2982
+ #ifdef USE_MATCAP
2983
+ vec4 matcapColor = texture2D( matcap, uv );
2984
+ #else
2985
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
2986
+ #endif
2987
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
2988
+ #include <opaque_fragment>
2989
+ #include <tonemapping_fragment>
2990
+ #include <colorspace_fragment>
2991
+ #include <fog_fragment>
2992
+ #include <premultiplied_alpha_fragment>
2993
+ #include <dithering_fragment>
2994
+ }`,Bu=`#define NORMAL
2995
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
2996
+ varying vec3 vViewPosition;
2997
+ #endif
2998
+ #include <common>
2999
+ #include <batching_pars_vertex>
3000
+ #include <uv_pars_vertex>
3001
+ #include <displacementmap_pars_vertex>
3002
+ #include <normal_pars_vertex>
3003
+ #include <morphtarget_pars_vertex>
3004
+ #include <skinning_pars_vertex>
3005
+ #include <logdepthbuf_pars_vertex>
3006
+ #include <clipping_planes_pars_vertex>
3007
+ void main() {
3008
+ #include <uv_vertex>
3009
+ #include <batching_vertex>
3010
+ #include <beginnormal_vertex>
3011
+ #include <morphinstance_vertex>
3012
+ #include <morphnormal_vertex>
3013
+ #include <skinbase_vertex>
3014
+ #include <skinnormal_vertex>
3015
+ #include <defaultnormal_vertex>
3016
+ #include <normal_vertex>
3017
+ #include <begin_vertex>
3018
+ #include <morphtarget_vertex>
3019
+ #include <skinning_vertex>
3020
+ #include <displacementmap_vertex>
3021
+ #include <project_vertex>
3022
+ #include <logdepthbuf_vertex>
3023
+ #include <clipping_planes_vertex>
3024
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3025
+ vViewPosition = - mvPosition.xyz;
3026
+ #endif
3027
+ }`,zu=`#define NORMAL
3028
+ uniform float opacity;
3029
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3030
+ varying vec3 vViewPosition;
3031
+ #endif
3032
+ #include <packing>
3033
+ #include <uv_pars_fragment>
3034
+ #include <normal_pars_fragment>
3035
+ #include <bumpmap_pars_fragment>
3036
+ #include <normalmap_pars_fragment>
3037
+ #include <logdepthbuf_pars_fragment>
3038
+ #include <clipping_planes_pars_fragment>
3039
+ void main() {
3040
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3041
+ #include <clipping_planes_fragment>
3042
+ #include <logdepthbuf_fragment>
3043
+ #include <normal_fragment_begin>
3044
+ #include <normal_fragment_maps>
3045
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3046
+ #ifdef OPAQUE
3047
+ gl_FragColor.a = 1.0;
3048
+ #endif
3049
+ }`,Hu=`#define PHONG
3050
+ varying vec3 vViewPosition;
3051
+ #include <common>
3052
+ #include <batching_pars_vertex>
3053
+ #include <uv_pars_vertex>
3054
+ #include <displacementmap_pars_vertex>
3055
+ #include <envmap_pars_vertex>
3056
+ #include <color_pars_vertex>
3057
+ #include <fog_pars_vertex>
3058
+ #include <normal_pars_vertex>
3059
+ #include <morphtarget_pars_vertex>
3060
+ #include <skinning_pars_vertex>
3061
+ #include <shadowmap_pars_vertex>
3062
+ #include <logdepthbuf_pars_vertex>
3063
+ #include <clipping_planes_pars_vertex>
3064
+ void main() {
3065
+ #include <uv_vertex>
3066
+ #include <color_vertex>
3067
+ #include <morphcolor_vertex>
3068
+ #include <batching_vertex>
3069
+ #include <beginnormal_vertex>
3070
+ #include <morphinstance_vertex>
3071
+ #include <morphnormal_vertex>
3072
+ #include <skinbase_vertex>
3073
+ #include <skinnormal_vertex>
3074
+ #include <defaultnormal_vertex>
3075
+ #include <normal_vertex>
3076
+ #include <begin_vertex>
3077
+ #include <morphtarget_vertex>
3078
+ #include <skinning_vertex>
3079
+ #include <displacementmap_vertex>
3080
+ #include <project_vertex>
3081
+ #include <logdepthbuf_vertex>
3082
+ #include <clipping_planes_vertex>
3083
+ vViewPosition = - mvPosition.xyz;
3084
+ #include <worldpos_vertex>
3085
+ #include <envmap_vertex>
3086
+ #include <shadowmap_vertex>
3087
+ #include <fog_vertex>
3088
+ }`,Gu=`#define PHONG
3089
+ uniform vec3 diffuse;
3090
+ uniform vec3 emissive;
3091
+ uniform vec3 specular;
3092
+ uniform float shininess;
3093
+ uniform float opacity;
3094
+ #include <common>
3095
+ #include <packing>
3096
+ #include <dithering_pars_fragment>
3097
+ #include <color_pars_fragment>
3098
+ #include <uv_pars_fragment>
3099
+ #include <map_pars_fragment>
3100
+ #include <alphamap_pars_fragment>
3101
+ #include <alphatest_pars_fragment>
3102
+ #include <alphahash_pars_fragment>
3103
+ #include <aomap_pars_fragment>
3104
+ #include <lightmap_pars_fragment>
3105
+ #include <emissivemap_pars_fragment>
3106
+ #include <envmap_common_pars_fragment>
3107
+ #include <envmap_pars_fragment>
3108
+ #include <fog_pars_fragment>
3109
+ #include <bsdfs>
3110
+ #include <lights_pars_begin>
3111
+ #include <normal_pars_fragment>
3112
+ #include <lights_phong_pars_fragment>
3113
+ #include <shadowmap_pars_fragment>
3114
+ #include <bumpmap_pars_fragment>
3115
+ #include <normalmap_pars_fragment>
3116
+ #include <specularmap_pars_fragment>
3117
+ #include <logdepthbuf_pars_fragment>
3118
+ #include <clipping_planes_pars_fragment>
3119
+ void main() {
3120
+ vec4 diffuseColor = vec4( diffuse, opacity );
3121
+ #include <clipping_planes_fragment>
3122
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3123
+ vec3 totalEmissiveRadiance = emissive;
3124
+ #include <logdepthbuf_fragment>
3125
+ #include <map_fragment>
3126
+ #include <color_fragment>
3127
+ #include <alphamap_fragment>
3128
+ #include <alphatest_fragment>
3129
+ #include <alphahash_fragment>
3130
+ #include <specularmap_fragment>
3131
+ #include <normal_fragment_begin>
3132
+ #include <normal_fragment_maps>
3133
+ #include <emissivemap_fragment>
3134
+ #include <lights_phong_fragment>
3135
+ #include <lights_fragment_begin>
3136
+ #include <lights_fragment_maps>
3137
+ #include <lights_fragment_end>
3138
+ #include <aomap_fragment>
3139
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3140
+ #include <envmap_fragment>
3141
+ #include <opaque_fragment>
3142
+ #include <tonemapping_fragment>
3143
+ #include <colorspace_fragment>
3144
+ #include <fog_fragment>
3145
+ #include <premultiplied_alpha_fragment>
3146
+ #include <dithering_fragment>
3147
+ }`,Vu=`#define STANDARD
3148
+ varying vec3 vViewPosition;
3149
+ #ifdef USE_TRANSMISSION
3150
+ varying vec3 vWorldPosition;
3151
+ #endif
3152
+ #include <common>
3153
+ #include <batching_pars_vertex>
3154
+ #include <uv_pars_vertex>
3155
+ #include <displacementmap_pars_vertex>
3156
+ #include <color_pars_vertex>
3157
+ #include <fog_pars_vertex>
3158
+ #include <normal_pars_vertex>
3159
+ #include <morphtarget_pars_vertex>
3160
+ #include <skinning_pars_vertex>
3161
+ #include <shadowmap_pars_vertex>
3162
+ #include <logdepthbuf_pars_vertex>
3163
+ #include <clipping_planes_pars_vertex>
3164
+ void main() {
3165
+ #include <uv_vertex>
3166
+ #include <color_vertex>
3167
+ #include <morphinstance_vertex>
3168
+ #include <morphcolor_vertex>
3169
+ #include <batching_vertex>
3170
+ #include <beginnormal_vertex>
3171
+ #include <morphnormal_vertex>
3172
+ #include <skinbase_vertex>
3173
+ #include <skinnormal_vertex>
3174
+ #include <defaultnormal_vertex>
3175
+ #include <normal_vertex>
3176
+ #include <begin_vertex>
3177
+ #include <morphtarget_vertex>
3178
+ #include <skinning_vertex>
3179
+ #include <displacementmap_vertex>
3180
+ #include <project_vertex>
3181
+ #include <logdepthbuf_vertex>
3182
+ #include <clipping_planes_vertex>
3183
+ vViewPosition = - mvPosition.xyz;
3184
+ #include <worldpos_vertex>
3185
+ #include <shadowmap_vertex>
3186
+ #include <fog_vertex>
3187
+ #ifdef USE_TRANSMISSION
3188
+ vWorldPosition = worldPosition.xyz;
3189
+ #endif
3190
+ }`,ku=`#define STANDARD
3191
+ #ifdef PHYSICAL
3192
+ #define IOR
3193
+ #define USE_SPECULAR
3194
+ #endif
3195
+ uniform vec3 diffuse;
3196
+ uniform vec3 emissive;
3197
+ uniform float roughness;
3198
+ uniform float metalness;
3199
+ uniform float opacity;
3200
+ #ifdef IOR
3201
+ uniform float ior;
3202
+ #endif
3203
+ #ifdef USE_SPECULAR
3204
+ uniform float specularIntensity;
3205
+ uniform vec3 specularColor;
3206
+ #ifdef USE_SPECULAR_COLORMAP
3207
+ uniform sampler2D specularColorMap;
3208
+ #endif
3209
+ #ifdef USE_SPECULAR_INTENSITYMAP
3210
+ uniform sampler2D specularIntensityMap;
3211
+ #endif
3212
+ #endif
3213
+ #ifdef USE_CLEARCOAT
3214
+ uniform float clearcoat;
3215
+ uniform float clearcoatRoughness;
3216
+ #endif
3217
+ #ifdef USE_DISPERSION
3218
+ uniform float dispersion;
3219
+ #endif
3220
+ #ifdef USE_IRIDESCENCE
3221
+ uniform float iridescence;
3222
+ uniform float iridescenceIOR;
3223
+ uniform float iridescenceThicknessMinimum;
3224
+ uniform float iridescenceThicknessMaximum;
3225
+ #endif
3226
+ #ifdef USE_SHEEN
3227
+ uniform vec3 sheenColor;
3228
+ uniform float sheenRoughness;
3229
+ #ifdef USE_SHEEN_COLORMAP
3230
+ uniform sampler2D sheenColorMap;
3231
+ #endif
3232
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3233
+ uniform sampler2D sheenRoughnessMap;
3234
+ #endif
3235
+ #endif
3236
+ #ifdef USE_ANISOTROPY
3237
+ uniform vec2 anisotropyVector;
3238
+ #ifdef USE_ANISOTROPYMAP
3239
+ uniform sampler2D anisotropyMap;
3240
+ #endif
3241
+ #endif
3242
+ varying vec3 vViewPosition;
3243
+ #include <common>
3244
+ #include <packing>
3245
+ #include <dithering_pars_fragment>
3246
+ #include <color_pars_fragment>
3247
+ #include <uv_pars_fragment>
3248
+ #include <map_pars_fragment>
3249
+ #include <alphamap_pars_fragment>
3250
+ #include <alphatest_pars_fragment>
3251
+ #include <alphahash_pars_fragment>
3252
+ #include <aomap_pars_fragment>
3253
+ #include <lightmap_pars_fragment>
3254
+ #include <emissivemap_pars_fragment>
3255
+ #include <iridescence_fragment>
3256
+ #include <cube_uv_reflection_fragment>
3257
+ #include <envmap_common_pars_fragment>
3258
+ #include <envmap_physical_pars_fragment>
3259
+ #include <fog_pars_fragment>
3260
+ #include <lights_pars_begin>
3261
+ #include <normal_pars_fragment>
3262
+ #include <lights_physical_pars_fragment>
3263
+ #include <transmission_pars_fragment>
3264
+ #include <shadowmap_pars_fragment>
3265
+ #include <bumpmap_pars_fragment>
3266
+ #include <normalmap_pars_fragment>
3267
+ #include <clearcoat_pars_fragment>
3268
+ #include <iridescence_pars_fragment>
3269
+ #include <roughnessmap_pars_fragment>
3270
+ #include <metalnessmap_pars_fragment>
3271
+ #include <logdepthbuf_pars_fragment>
3272
+ #include <clipping_planes_pars_fragment>
3273
+ void main() {
3274
+ vec4 diffuseColor = vec4( diffuse, opacity );
3275
+ #include <clipping_planes_fragment>
3276
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3277
+ vec3 totalEmissiveRadiance = emissive;
3278
+ #include <logdepthbuf_fragment>
3279
+ #include <map_fragment>
3280
+ #include <color_fragment>
3281
+ #include <alphamap_fragment>
3282
+ #include <alphatest_fragment>
3283
+ #include <alphahash_fragment>
3284
+ #include <roughnessmap_fragment>
3285
+ #include <metalnessmap_fragment>
3286
+ #include <normal_fragment_begin>
3287
+ #include <normal_fragment_maps>
3288
+ #include <clearcoat_normal_fragment_begin>
3289
+ #include <clearcoat_normal_fragment_maps>
3290
+ #include <emissivemap_fragment>
3291
+ #include <lights_physical_fragment>
3292
+ #include <lights_fragment_begin>
3293
+ #include <lights_fragment_maps>
3294
+ #include <lights_fragment_end>
3295
+ #include <aomap_fragment>
3296
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3297
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3298
+ #include <transmission_fragment>
3299
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3300
+ #ifdef USE_SHEEN
3301
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3302
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3303
+ #endif
3304
+ #ifdef USE_CLEARCOAT
3305
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3306
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3307
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3308
+ #endif
3309
+ #include <opaque_fragment>
3310
+ #include <tonemapping_fragment>
3311
+ #include <colorspace_fragment>
3312
+ #include <fog_fragment>
3313
+ #include <premultiplied_alpha_fragment>
3314
+ #include <dithering_fragment>
3315
+ }`,Wu=`#define TOON
3316
+ varying vec3 vViewPosition;
3317
+ #include <common>
3318
+ #include <batching_pars_vertex>
3319
+ #include <uv_pars_vertex>
3320
+ #include <displacementmap_pars_vertex>
3321
+ #include <color_pars_vertex>
3322
+ #include <fog_pars_vertex>
3323
+ #include <normal_pars_vertex>
3324
+ #include <morphtarget_pars_vertex>
3325
+ #include <skinning_pars_vertex>
3326
+ #include <shadowmap_pars_vertex>
3327
+ #include <logdepthbuf_pars_vertex>
3328
+ #include <clipping_planes_pars_vertex>
3329
+ void main() {
3330
+ #include <uv_vertex>
3331
+ #include <color_vertex>
3332
+ #include <morphinstance_vertex>
3333
+ #include <morphcolor_vertex>
3334
+ #include <batching_vertex>
3335
+ #include <beginnormal_vertex>
3336
+ #include <morphnormal_vertex>
3337
+ #include <skinbase_vertex>
3338
+ #include <skinnormal_vertex>
3339
+ #include <defaultnormal_vertex>
3340
+ #include <normal_vertex>
3341
+ #include <begin_vertex>
3342
+ #include <morphtarget_vertex>
3343
+ #include <skinning_vertex>
3344
+ #include <displacementmap_vertex>
3345
+ #include <project_vertex>
3346
+ #include <logdepthbuf_vertex>
3347
+ #include <clipping_planes_vertex>
3348
+ vViewPosition = - mvPosition.xyz;
3349
+ #include <worldpos_vertex>
3350
+ #include <shadowmap_vertex>
3351
+ #include <fog_vertex>
3352
+ }`,Xu=`#define TOON
3353
+ uniform vec3 diffuse;
3354
+ uniform vec3 emissive;
3355
+ uniform float opacity;
3356
+ #include <common>
3357
+ #include <packing>
3358
+ #include <dithering_pars_fragment>
3359
+ #include <color_pars_fragment>
3360
+ #include <uv_pars_fragment>
3361
+ #include <map_pars_fragment>
3362
+ #include <alphamap_pars_fragment>
3363
+ #include <alphatest_pars_fragment>
3364
+ #include <alphahash_pars_fragment>
3365
+ #include <aomap_pars_fragment>
3366
+ #include <lightmap_pars_fragment>
3367
+ #include <emissivemap_pars_fragment>
3368
+ #include <gradientmap_pars_fragment>
3369
+ #include <fog_pars_fragment>
3370
+ #include <bsdfs>
3371
+ #include <lights_pars_begin>
3372
+ #include <normal_pars_fragment>
3373
+ #include <lights_toon_pars_fragment>
3374
+ #include <shadowmap_pars_fragment>
3375
+ #include <bumpmap_pars_fragment>
3376
+ #include <normalmap_pars_fragment>
3377
+ #include <logdepthbuf_pars_fragment>
3378
+ #include <clipping_planes_pars_fragment>
3379
+ void main() {
3380
+ vec4 diffuseColor = vec4( diffuse, opacity );
3381
+ #include <clipping_planes_fragment>
3382
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3383
+ vec3 totalEmissiveRadiance = emissive;
3384
+ #include <logdepthbuf_fragment>
3385
+ #include <map_fragment>
3386
+ #include <color_fragment>
3387
+ #include <alphamap_fragment>
3388
+ #include <alphatest_fragment>
3389
+ #include <alphahash_fragment>
3390
+ #include <normal_fragment_begin>
3391
+ #include <normal_fragment_maps>
3392
+ #include <emissivemap_fragment>
3393
+ #include <lights_toon_fragment>
3394
+ #include <lights_fragment_begin>
3395
+ #include <lights_fragment_maps>
3396
+ #include <lights_fragment_end>
3397
+ #include <aomap_fragment>
3398
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3399
+ #include <opaque_fragment>
3400
+ #include <tonemapping_fragment>
3401
+ #include <colorspace_fragment>
3402
+ #include <fog_fragment>
3403
+ #include <premultiplied_alpha_fragment>
3404
+ #include <dithering_fragment>
3405
+ }`,qu=`uniform float size;
3406
+ uniform float scale;
3407
+ #include <common>
3408
+ #include <color_pars_vertex>
3409
+ #include <fog_pars_vertex>
3410
+ #include <morphtarget_pars_vertex>
3411
+ #include <logdepthbuf_pars_vertex>
3412
+ #include <clipping_planes_pars_vertex>
3413
+ #ifdef USE_POINTS_UV
3414
+ varying vec2 vUv;
3415
+ uniform mat3 uvTransform;
3416
+ #endif
3417
+ void main() {
3418
+ #ifdef USE_POINTS_UV
3419
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3420
+ #endif
3421
+ #include <color_vertex>
3422
+ #include <morphinstance_vertex>
3423
+ #include <morphcolor_vertex>
3424
+ #include <begin_vertex>
3425
+ #include <morphtarget_vertex>
3426
+ #include <project_vertex>
3427
+ gl_PointSize = size;
3428
+ #ifdef USE_SIZEATTENUATION
3429
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3430
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3431
+ #endif
3432
+ #include <logdepthbuf_vertex>
3433
+ #include <clipping_planes_vertex>
3434
+ #include <worldpos_vertex>
3435
+ #include <fog_vertex>
3436
+ }`,Yu=`uniform vec3 diffuse;
3437
+ uniform float opacity;
3438
+ #include <common>
3439
+ #include <color_pars_fragment>
3440
+ #include <map_particle_pars_fragment>
3441
+ #include <alphatest_pars_fragment>
3442
+ #include <alphahash_pars_fragment>
3443
+ #include <fog_pars_fragment>
3444
+ #include <logdepthbuf_pars_fragment>
3445
+ #include <clipping_planes_pars_fragment>
3446
+ void main() {
3447
+ vec4 diffuseColor = vec4( diffuse, opacity );
3448
+ #include <clipping_planes_fragment>
3449
+ vec3 outgoingLight = vec3( 0.0 );
3450
+ #include <logdepthbuf_fragment>
3451
+ #include <map_particle_fragment>
3452
+ #include <color_fragment>
3453
+ #include <alphatest_fragment>
3454
+ #include <alphahash_fragment>
3455
+ outgoingLight = diffuseColor.rgb;
3456
+ #include <opaque_fragment>
3457
+ #include <tonemapping_fragment>
3458
+ #include <colorspace_fragment>
3459
+ #include <fog_fragment>
3460
+ #include <premultiplied_alpha_fragment>
3461
+ }`,Ku=`#include <common>
3462
+ #include <batching_pars_vertex>
3463
+ #include <fog_pars_vertex>
3464
+ #include <morphtarget_pars_vertex>
3465
+ #include <skinning_pars_vertex>
3466
+ #include <logdepthbuf_pars_vertex>
3467
+ #include <shadowmap_pars_vertex>
3468
+ void main() {
3469
+ #include <batching_vertex>
3470
+ #include <beginnormal_vertex>
3471
+ #include <morphinstance_vertex>
3472
+ #include <morphnormal_vertex>
3473
+ #include <skinbase_vertex>
3474
+ #include <skinnormal_vertex>
3475
+ #include <defaultnormal_vertex>
3476
+ #include <begin_vertex>
3477
+ #include <morphtarget_vertex>
3478
+ #include <skinning_vertex>
3479
+ #include <project_vertex>
3480
+ #include <logdepthbuf_vertex>
3481
+ #include <worldpos_vertex>
3482
+ #include <shadowmap_vertex>
3483
+ #include <fog_vertex>
3484
+ }`,$u=`uniform vec3 color;
3485
+ uniform float opacity;
3486
+ #include <common>
3487
+ #include <packing>
3488
+ #include <fog_pars_fragment>
3489
+ #include <bsdfs>
3490
+ #include <lights_pars_begin>
3491
+ #include <logdepthbuf_pars_fragment>
3492
+ #include <shadowmap_pars_fragment>
3493
+ #include <shadowmask_pars_fragment>
3494
+ void main() {
3495
+ #include <logdepthbuf_fragment>
3496
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3497
+ #include <tonemapping_fragment>
3498
+ #include <colorspace_fragment>
3499
+ #include <fog_fragment>
3500
+ }`,Zu=`uniform float rotation;
3501
+ uniform vec2 center;
3502
+ #include <common>
3503
+ #include <uv_pars_vertex>
3504
+ #include <fog_pars_vertex>
3505
+ #include <logdepthbuf_pars_vertex>
3506
+ #include <clipping_planes_pars_vertex>
3507
+ void main() {
3508
+ #include <uv_vertex>
3509
+ vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
3510
+ vec2 scale;
3511
+ scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
3512
+ scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
3513
+ #ifndef USE_SIZEATTENUATION
3514
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3515
+ if ( isPerspective ) scale *= - mvPosition.z;
3516
+ #endif
3517
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3518
+ vec2 rotatedPosition;
3519
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3520
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3521
+ mvPosition.xy += rotatedPosition;
3522
+ gl_Position = projectionMatrix * mvPosition;
3523
+ #include <logdepthbuf_vertex>
3524
+ #include <clipping_planes_vertex>
3525
+ #include <fog_vertex>
3526
+ }`,ju=`uniform vec3 diffuse;
3527
+ uniform float opacity;
3528
+ #include <common>
3529
+ #include <uv_pars_fragment>
3530
+ #include <map_pars_fragment>
3531
+ #include <alphamap_pars_fragment>
3532
+ #include <alphatest_pars_fragment>
3533
+ #include <alphahash_pars_fragment>
3534
+ #include <fog_pars_fragment>
3535
+ #include <logdepthbuf_pars_fragment>
3536
+ #include <clipping_planes_pars_fragment>
3537
+ void main() {
3538
+ vec4 diffuseColor = vec4( diffuse, opacity );
3539
+ #include <clipping_planes_fragment>
3540
+ vec3 outgoingLight = vec3( 0.0 );
3541
+ #include <logdepthbuf_fragment>
3542
+ #include <map_fragment>
3543
+ #include <alphamap_fragment>
3544
+ #include <alphatest_fragment>
3545
+ #include <alphahash_fragment>
3546
+ outgoingLight = diffuseColor.rgb;
3547
+ #include <opaque_fragment>
3548
+ #include <tonemapping_fragment>
3549
+ #include <colorspace_fragment>
3550
+ #include <fog_fragment>
3551
+ }`,At={alphahash_fragment:xc,alphahash_pars_fragment:Mc,alphamap_fragment:Sc,alphamap_pars_fragment:Ec,alphatest_fragment:yc,alphatest_pars_fragment:Tc,aomap_fragment:Ac,aomap_pars_fragment:bc,batching_pars_vertex:wc,batching_vertex:Rc,begin_vertex:Cc,beginnormal_vertex:Pc,bsdfs:Lc,iridescence_fragment:Uc,bumpmap_pars_fragment:Dc,clipping_planes_fragment:Ic,clipping_planes_pars_fragment:Nc,clipping_planes_pars_vertex:Fc,clipping_planes_vertex:Oc,color_fragment:Bc,color_pars_fragment:zc,color_pars_vertex:Hc,color_vertex:Gc,common:Vc,cube_uv_reflection_fragment:kc,defaultnormal_vertex:Wc,displacementmap_pars_vertex:Xc,displacementmap_vertex:qc,emissivemap_fragment:Yc,emissivemap_pars_fragment:Kc,colorspace_fragment:$c,colorspace_pars_fragment:Zc,envmap_fragment:jc,envmap_common_pars_fragment:Jc,envmap_pars_fragment:Qc,envmap_pars_vertex:th,envmap_physical_pars_fragment:uh,envmap_vertex:eh,fog_vertex:nh,fog_pars_vertex:ih,fog_fragment:rh,fog_pars_fragment:sh,gradientmap_pars_fragment:ah,lightmap_pars_fragment:oh,lights_lambert_fragment:lh,lights_lambert_pars_fragment:ch,lights_pars_begin:hh,lights_toon_fragment:dh,lights_toon_pars_fragment:fh,lights_phong_fragment:ph,lights_phong_pars_fragment:mh,lights_physical_fragment:_h,lights_physical_pars_fragment:gh,lights_fragment_begin:vh,lights_fragment_maps:xh,lights_fragment_end:Mh,logdepthbuf_fragment:Sh,logdepthbuf_pars_fragment:Eh,logdepthbuf_pars_vertex:yh,logdepthbuf_vertex:Th,map_fragment:Ah,map_pars_fragment:bh,map_particle_fragment:wh,map_particle_pars_fragment:Rh,metalnessmap_fragment:Ch,metalnessmap_pars_fragment:Ph,morphinstance_vertex:Lh,morphcolor_vertex:Uh,morphnormal_vertex:Dh,morphtarget_pars_vertex:Ih,morphtarget_vertex:Nh,normal_fragment_begin:Fh,normal_fragment_maps:Oh,normal_pars_fragment:Bh,normal_pars_vertex:zh,normal_vertex:Hh,normalmap_pars_fragment:Gh,clearcoat_normal_fragment_begin:Vh,clearcoat_normal_fragment_maps:kh,clearcoat_pars_fragment:Wh,iridescence_pars_fragment:Xh,opaque_fragment:qh,packing:Yh,premultiplied_alpha_fragment:Kh,project_vertex:$h,dithering_fragment:Zh,dithering_pars_fragment:jh,roughnessmap_fragment:Jh,roughnessmap_pars_fragment:Qh,shadowmap_pars_fragment:tu,shadowmap_pars_vertex:eu,shadowmap_vertex:nu,shadowmask_pars_fragment:iu,skinbase_vertex:ru,skinning_pars_vertex:su,skinning_vertex:au,skinnormal_vertex:ou,specularmap_fragment:lu,specularmap_pars_fragment:cu,tonemapping_fragment:hu,tonemapping_pars_fragment:uu,transmission_fragment:du,transmission_pars_fragment:fu,uv_pars_fragment:pu,uv_pars_vertex:mu,uv_vertex:_u,worldpos_vertex:gu,background_vert:vu,background_frag:xu,backgroundCube_vert:Mu,backgroundCube_frag:Su,cube_vert:Eu,cube_frag:yu,depth_vert:Tu,depth_frag:Au,distanceRGBA_vert:bu,distanceRGBA_frag:wu,equirect_vert:Ru,equirect_frag:Cu,linedashed_vert:Pu,linedashed_frag:Lu,meshbasic_vert:Uu,meshbasic_frag:Du,meshlambert_vert:Iu,meshlambert_frag:Nu,meshmatcap_vert:Fu,meshmatcap_frag:Ou,meshnormal_vert:Bu,meshnormal_frag:zu,meshphong_vert:Hu,meshphong_frag:Gu,meshphysical_vert:Vu,meshphysical_frag:ku,meshtoon_vert:Wu,meshtoon_frag:Xu,points_vert:qu,points_frag:Yu,shadow_vert:Ku,shadow_frag:$u,sprite_vert:Zu,sprite_frag:ju},nt={common:{diffuse:{value:new Ht(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new bt},alphaMap:{value:null},alphaMapTransform:{value:new bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new bt}},envmap:{envMap:{value:null},envMapRotation:{value:new bt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new bt},normalScale:{value:new Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ht(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ht(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new bt},alphaTest:{value:0},uvTransform:{value:new bt}},sprite:{diffuse:{value:new Ht(16777215)},opacity:{value:1},center:{value:new Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new bt},alphaMap:{value:null},alphaMapTransform:{value:new bt},alphaTest:{value:0}}},Oe={basic:{uniforms:ge([nt.common,nt.specularmap,nt.envmap,nt.aomap,nt.lightmap,nt.fog]),vertexShader:At.meshbasic_vert,fragmentShader:At.meshbasic_frag},lambert:{uniforms:ge([nt.common,nt.specularmap,nt.envmap,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.fog,nt.lights,{emissive:{value:new Ht(0)}}]),vertexShader:At.meshlambert_vert,fragmentShader:At.meshlambert_frag},phong:{uniforms:ge([nt.common,nt.specularmap,nt.envmap,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.fog,nt.lights,{emissive:{value:new Ht(0)},specular:{value:new Ht(1118481)},shininess:{value:30}}]),vertexShader:At.meshphong_vert,fragmentShader:At.meshphong_frag},standard:{uniforms:ge([nt.common,nt.envmap,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.roughnessmap,nt.metalnessmap,nt.fog,nt.lights,{emissive:{value:new Ht(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag},toon:{uniforms:ge([nt.common,nt.aomap,nt.lightmap,nt.emissivemap,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.gradientmap,nt.fog,nt.lights,{emissive:{value:new Ht(0)}}]),vertexShader:At.meshtoon_vert,fragmentShader:At.meshtoon_frag},matcap:{uniforms:ge([nt.common,nt.bumpmap,nt.normalmap,nt.displacementmap,nt.fog,{matcap:{value:null}}]),vertexShader:At.meshmatcap_vert,fragmentShader:At.meshmatcap_frag},points:{uniforms:ge([nt.points,nt.fog]),vertexShader:At.points_vert,fragmentShader:At.points_frag},dashed:{uniforms:ge([nt.common,nt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:At.linedashed_vert,fragmentShader:At.linedashed_frag},depth:{uniforms:ge([nt.common,nt.displacementmap]),vertexShader:At.depth_vert,fragmentShader:At.depth_frag},normal:{uniforms:ge([nt.common,nt.bumpmap,nt.normalmap,nt.displacementmap,{opacity:{value:1}}]),vertexShader:At.meshnormal_vert,fragmentShader:At.meshnormal_frag},sprite:{uniforms:ge([nt.sprite,nt.fog]),vertexShader:At.sprite_vert,fragmentShader:At.sprite_frag},background:{uniforms:{uvTransform:{value:new bt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:At.background_vert,fragmentShader:At.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new bt}},vertexShader:At.backgroundCube_vert,fragmentShader:At.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:At.cube_vert,fragmentShader:At.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:At.equirect_vert,fragmentShader:At.equirect_frag},distanceRGBA:{uniforms:ge([nt.common,nt.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:At.distanceRGBA_vert,fragmentShader:At.distanceRGBA_frag},shadow:{uniforms:ge([nt.lights,nt.fog,{color:{value:new Ht(0)},opacity:{value:1}}]),vertexShader:At.shadow_vert,fragmentShader:At.shadow_frag}};Oe.physical={uniforms:ge([Oe.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new bt},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new bt},sheen:{value:0},sheenColor:{value:new Ht(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new bt},transmissionSamplerSize:{value:new Dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new bt},attenuationDistance:{value:0},attenuationColor:{value:new Ht(0)},specularColor:{value:new Ht(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new bt},anisotropyVector:{value:new Dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new bt}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag};const Hi={r:0,b:0,g:0},Mn=new He,Ju=new Jt;function Qu(i,t,e,n,r,s,o){const a=new Ht(0);let l=s===!0?0:1,c,u,f=null,p=0,m=null;function _(y){let S=y.isScene===!0?y.background:null;return S&&S.isTexture&&(S=(y.backgroundBlurriness>0?e:t).get(S)),S}function x(y){let S=!1;const A=_(y);A===null?h(a,l):A&&A.isColor&&(h(A,1),S=!0);const F=i.xr.getEnvironmentBlendMode();F==="additive"?n.buffers.color.setClear(0,0,0,1,o):F==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||S)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function d(y,S){const A=_(S);A&&(A.isCubeTexture||A.mapping===Ji)?(u===void 0&&(u=new Ze(new _i(1,1,1),new dn({name:"BackgroundCubeMaterial",uniforms:ei(Oe.backgroundCube.uniforms),vertexShader:Oe.backgroundCube.vertexShader,fragmentShader:Oe.backgroundCube.fragmentShader,side:xe,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(F,b,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),Mn.copy(S.backgroundRotation),Mn.x*=-1,Mn.y*=-1,Mn.z*=-1,A.isCubeTexture&&A.isRenderTargetTexture===!1&&(Mn.y*=-1,Mn.z*=-1),u.material.uniforms.envMap.value=A,u.material.uniforms.flipEnvMap.value=A.isCubeTexture&&A.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=S.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Ju.makeRotationFromEuler(Mn)),u.material.toneMapped=Xt.getTransfer(A.colorSpace)!==$t,(f!==A||p!==A.version||m!==i.toneMapping)&&(u.material.needsUpdate=!0,f=A,p=A.version,m=i.toneMapping),u.layers.enableAll(),y.unshift(u,u.geometry,u.material,0,0,null)):A&&A.isTexture&&(c===void 0&&(c=new Ze(new er(2,2),new dn({name:"BackgroundMaterial",uniforms:ei(Oe.background.uniforms),vertexShader:Oe.background.vertexShader,fragmentShader:Oe.background.fragmentShader,side:hn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=A,c.material.uniforms.backgroundIntensity.value=S.backgroundIntensity,c.material.toneMapped=Xt.getTransfer(A.colorSpace)!==$t,A.matrixAutoUpdate===!0&&A.updateMatrix(),c.material.uniforms.uvTransform.value.copy(A.matrix),(f!==A||p!==A.version||m!==i.toneMapping)&&(c.material.needsUpdate=!0,f=A,p=A.version,m=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function h(y,S){y.getRGB(Hi,io(i)),n.buffers.color.setClear(Hi.r,Hi.g,Hi.b,S,o)}return{getClearColor:function(){return a},setClearColor:function(y,S=1){a.set(y),l=S,h(a,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,h(a,l)},render:x,addToRenderList:d}}function td(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=p(null);let s=r,o=!1;function a(M,P,X,z,W){let K=!1;const G=f(z,X,P);s!==G&&(s=G,c(s.object)),K=m(M,z,X,W),K&&_(M,z,X,W),W!==null&&t.update(W,i.ELEMENT_ARRAY_BUFFER),(K||o)&&(o=!1,A(M,P,X,z),W!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(W).buffer))}function l(){return i.createVertexArray()}function c(M){return i.bindVertexArray(M)}function u(M){return i.deleteVertexArray(M)}function f(M,P,X){const z=X.wireframe===!0;let W=n[M.id];W===void 0&&(W={},n[M.id]=W);let K=W[P.id];K===void 0&&(K={},W[P.id]=K);let G=K[z];return G===void 0&&(G=p(l()),K[z]=G),G}function p(M){const P=[],X=[],z=[];for(let W=0;W<e;W++)P[W]=0,X[W]=0,z[W]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:X,attributeDivisors:z,object:M,attributes:{},index:null}}function m(M,P,X,z){const W=s.attributes,K=P.attributes;let G=0;const J=X.getAttributes();for(const H in J)if(J[H].location>=0){const dt=W[H];let pt=K[H];if(pt===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(pt=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(pt=M.instanceColor)),dt===void 0||dt.attribute!==pt||pt&&dt.data!==pt.data)return!0;G++}return s.attributesNum!==G||s.index!==z}function _(M,P,X,z){const W={},K=P.attributes;let G=0;const J=X.getAttributes();for(const H in J)if(J[H].location>=0){let dt=K[H];dt===void 0&&(H==="instanceMatrix"&&M.instanceMatrix&&(dt=M.instanceMatrix),H==="instanceColor"&&M.instanceColor&&(dt=M.instanceColor));const pt={};pt.attribute=dt,dt&&dt.data&&(pt.data=dt.data),W[H]=pt,G++}s.attributes=W,s.attributesNum=G,s.index=z}function x(){const M=s.newAttributes;for(let P=0,X=M.length;P<X;P++)M[P]=0}function d(M){h(M,0)}function h(M,P){const X=s.newAttributes,z=s.enabledAttributes,W=s.attributeDivisors;X[M]=1,z[M]===0&&(i.enableVertexAttribArray(M),z[M]=1),W[M]!==P&&(i.vertexAttribDivisor(M,P),W[M]=P)}function y(){const M=s.newAttributes,P=s.enabledAttributes;for(let X=0,z=P.length;X<z;X++)P[X]!==M[X]&&(i.disableVertexAttribArray(X),P[X]=0)}function S(M,P,X,z,W,K,G){G===!0?i.vertexAttribIPointer(M,P,X,W,K):i.vertexAttribPointer(M,P,X,z,W,K)}function A(M,P,X,z){x();const W=z.attributes,K=X.getAttributes(),G=P.defaultAttributeValues;for(const J in K){const H=K[J];if(H.location>=0){let ct=W[J];if(ct===void 0&&(J==="instanceMatrix"&&M.instanceMatrix&&(ct=M.instanceMatrix),J==="instanceColor"&&M.instanceColor&&(ct=M.instanceColor)),ct!==void 0){const dt=ct.normalized,pt=ct.itemSize,Ft=t.get(ct);if(Ft===void 0)continue;const qt=Ft.buffer,k=Ft.type,j=Ft.bytesPerElement,ut=k===i.INT||k===i.UNSIGNED_INT||ct.gpuType===Ga;if(ct.isInterleavedBufferAttribute){const st=ct.data,Pt=st.stride,wt=ct.offset;if(st.isInstancedInterleavedBuffer){for(let Bt=0;Bt<H.locationSize;Bt++)h(H.location+Bt,st.meshPerAttribute);M.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=st.meshPerAttribute*st.count)}else for(let Bt=0;Bt<H.locationSize;Bt++)d(H.location+Bt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let Bt=0;Bt<H.locationSize;Bt++)S(H.location+Bt,pt/H.locationSize,k,dt,Pt*j,(wt+pt/H.locationSize*Bt)*j,ut)}else{if(ct.isInstancedBufferAttribute){for(let st=0;st<H.locationSize;st++)h(H.location+st,ct.meshPerAttribute);M.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ct.meshPerAttribute*ct.count)}else for(let st=0;st<H.locationSize;st++)d(H.location+st);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let st=0;st<H.locationSize;st++)S(H.location+st,pt/H.locationSize,k,dt,pt*j,pt/H.locationSize*st*j,ut)}}else if(G!==void 0){const dt=G[J];if(dt!==void 0)switch(dt.length){case 2:i.vertexAttrib2fv(H.location,dt);break;case 3:i.vertexAttrib3fv(H.location,dt);break;case 4:i.vertexAttrib4fv(H.location,dt);break;default:i.vertexAttrib1fv(H.location,dt)}}}}y()}function F(){O();for(const M in n){const P=n[M];for(const X in P){const z=P[X];for(const W in z)u(z[W].object),delete z[W];delete P[X]}delete n[M]}}function b(M){if(n[M.id]===void 0)return;const P=n[M.id];for(const X in P){const z=P[X];for(const W in z)u(z[W].object),delete z[W];delete P[X]}delete n[M.id]}function C(M){for(const P in n){const X=n[P];if(X[M.id]===void 0)continue;const z=X[M.id];for(const W in z)u(z[W].object),delete z[W];delete X[M.id]}}function O(){E(),o=!0,s!==r&&(s=r,c(s.object))}function E(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:O,resetDefaultState:E,dispose:F,releaseStatesOfGeometry:b,releaseStatesOfProgram:C,initAttributes:x,enableAttribute:d,disableUnusedAttributes:y}}function ed(i,t,e){let n;function r(c){n=c}function s(c,u){i.drawArrays(n,c,u),e.update(u,n,1)}function o(c,u,f){f!==0&&(i.drawArraysInstanced(n,c,u,f),e.update(u,n,f))}function a(c,u,f){if(f===0)return;const p=t.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<f;m++)this.render(c[m],u[m]);else{p.multiDrawArraysWEBGL(n,c,0,u,0,f);let m=0;for(let _=0;_<f;_++)m+=u[_];e.update(m,n,1)}}function l(c,u,f,p){if(f===0)return;const m=t.get("WEBGL_multi_draw");if(m===null)for(let _=0;_<c.length;_++)o(c[_],u[_],p[_]);else{m.multiDrawArraysInstancedWEBGL(n,c,0,u,0,p,0,f);let _=0;for(let x=0;x<f;x++)_+=u[x];for(let x=0;x<p.length;x++)e.update(_,n,p[x])}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=l}function nd(i,t,e,n){let r;function s(){if(r!==void 0)return r;if(t.has("EXT_texture_filter_anisotropic")===!0){const b=t.get("EXT_texture_filter_anisotropic");r=i.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(b){return!(b!==ze&&n.convert(b)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(b){const C=b===Qi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(b!==un&&n.convert(b)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&b!==on&&!C)}function l(b){if(b==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";b="mediump"}return b==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const u=l(c);u!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const f=e.logarithmicDepthBuffer===!0,p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),x=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),d=i.getParameter(i.MAX_VERTEX_ATTRIBS),h=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),y=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),A=m>0,F=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:x,maxAttributes:d,maxVertexUniforms:h,maxVaryings:y,maxFragmentUniforms:S,vertexTextures:A,maxSamples:F}}function id(i){const t=this;let e=null,n=0,r=!1,s=!1;const o=new En,a=new bt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||n!==0||r;return r=p,n=f.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(f,p){e=u(f,p,0)},this.setState=function(f,p,m){const _=f.clippingPlanes,x=f.clipIntersection,d=f.clipShadows,h=i.get(f);if(!r||_===null||_.length===0||s&&!d)s?u(null):c();else{const y=s?0:n,S=y*4;let A=h.clippingState||null;l.value=A,A=u(_,p,S,m);for(let F=0;F!==S;++F)A[F]=e[F];h.clippingState=A,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(f,p,m,_){const x=f!==null?f.length:0;let d=null;if(x!==0){if(d=l.value,_!==!0||d===null){const h=m+x*4,y=p.matrixWorldInverse;a.getNormalMatrix(y),(d===null||d.length<h)&&(d=new Float32Array(h));for(let S=0,A=m;S!==x;++S,A+=4)o.copy(f[S]).applyMatrix4(y,a),o.normal.toArray(d,A),d[A+3]=o.constant}l.value=d,l.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,d}}function rd(i){let t=new WeakMap;function e(o,a){return a===Vr?o.mapping=Zn:a===kr&&(o.mapping=jn),o}function n(o){if(o&&o.isTexture){const a=o.mapping;if(a===Vr||a===kr)if(t.has(o)){const l=t.get(o).texture;return e(l,o.mapping)}else{const l=o.image;if(l&&l.height>0){const c=new mc(l.height);return c.fromEquirectangularTexture(i,o),t.set(o,c),o.addEventListener("dispose",r),e(c.texture,o.mapping)}else return null}}return o}function r(o){const a=o.target;a.removeEventListener("dispose",r);const l=t.get(a);l!==void 0&&(t.delete(a),l.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}class oo extends ro{constructor(t=-1,e=1,n=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,r,s,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=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let s=n-t,o=n+t,a=r+e,l=r-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,o=s+c*this.view.width,a-=u*this.view.offsetY,l=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const qn=4,la=[.125,.215,.35,.446,.526,.582],An=20,Lr=new oo,ca=new Ht;let Ur=null,Dr=0,Ir=0,Nr=!1;const yn=(1+Math.sqrt(5))/2,Xn=1/yn,ha=[new U(-yn,Xn,0),new U(yn,Xn,0),new U(-Xn,0,yn),new U(Xn,0,yn),new U(0,yn,-Xn),new U(0,yn,Xn),new U(-1,1,-1),new U(1,1,-1),new U(-1,1,1),new U(1,1,1)];class ua{constructor(t){this._renderer=t,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(t,e=0,n=.1,r=100){Ur=this._renderer.getRenderTarget(),Dr=this._renderer.getActiveCubeFace(),Ir=this._renderer.getActiveMipmapLevel(),Nr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,r,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=pa(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=fa(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Ur,Dr,Ir),this._renderer.xr.enabled=Nr,t.scissorTest=!1,Gi(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Zn||t.mapping===jn?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Ur=this._renderer.getRenderTarget(),Dr=this._renderer.getActiveCubeFace(),Ir=this._renderer.getActiveMipmapLevel(),Nr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Le,minFilter:Le,generateMipmaps:!1,type:Qi,format:ze,colorSpace:fn,depthBuffer:!1},r=da(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=da(t,e,n);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=sd(s)),this._blurMaterial=ad(s,t,e)}return r}_compileMaterial(t){const e=new Ze(this._lodPlanes[0],t);this._renderer.compile(e,Lr)}_sceneToCubeUV(t,e,n,r){const a=new be(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],u=this._renderer,f=u.autoClear,p=u.toneMapping;u.getClearColor(ca),u.toneMapping=cn,u.autoClear=!1;const m=new to({name:"PMREM.Background",side:xe,depthWrite:!1,depthTest:!1}),_=new Ze(new _i,m);let x=!1;const d=t.background;d?d.isColor&&(m.color.copy(d),t.background=null,x=!0):(m.color.copy(ca),x=!0);for(let h=0;h<6;h++){const y=h%3;y===0?(a.up.set(0,l[h],0),a.lookAt(c[h],0,0)):y===1?(a.up.set(0,0,l[h]),a.lookAt(0,c[h],0)):(a.up.set(0,l[h],0),a.lookAt(0,0,c[h]));const S=this._cubeSize;Gi(r,y*S,h>2?S:0,S,S),u.setRenderTarget(r),x&&u.render(_,a),u.render(t,a)}_.geometry.dispose(),_.material.dispose(),u.toneMapping=p,u.autoClear=f,t.background=d}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===Zn||t.mapping===jn;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=pa()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=fa());const s=r?this._cubemapMaterial:this._equirectMaterial,o=new Ze(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=t;const l=this._cubeSize;Gi(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(o,Lr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const r=this._lodPlanes.length;for(let s=1;s<r;s++){const o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=ha[(r-s-1)%ha.length];this._blur(t,s-1,s,o,a)}e.autoClear=n}_blur(t,e,n,r,s){const o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,r,"latitudinal",s),this._halfBlur(o,t,n,n,r,"longitudinal",s)}_halfBlur(t,e,n,r,s,o,a){const l=this._renderer,c=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const u=3,f=new Ze(this._lodPlanes[r],c),p=c.uniforms,m=this._sizeLods[n]-1,_=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*An-1),x=s/_,d=isFinite(s)?1+Math.floor(u*x):An;d>An&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${An}`);const h=[];let y=0;for(let C=0;C<An;++C){const O=C/x,E=Math.exp(-O*O/2);h.push(E),C===0?y+=E:C<d&&(y+=2*E)}for(let C=0;C<h.length;C++)h[C]=h[C]/y;p.envMap.value=t.texture,p.samples.value=d,p.weights.value=h,p.latitudinal.value=o==="latitudinal",a&&(p.poleAxis.value=a);const{_lodMax:S}=this;p.dTheta.value=_,p.mipInt.value=S-n;const A=this._sizeLods[r],F=3*A*(r>S-qn?r-S+qn:0),b=4*(this._cubeSize-A);Gi(e,F,b,3*A,2*A),l.setRenderTarget(e),l.render(f,Lr)}}function sd(i){const t=[],e=[],n=[];let r=i;const s=i-qn+1+la.length;for(let o=0;o<s;o++){const a=Math.pow(2,r);e.push(a);let l=1/a;o>i-qn?l=la[o-i+qn-1]:o===0&&(l=0),n.push(l);const c=1/(a-2),u=-c,f=1+c,p=[u,u,f,u,f,f,u,u,f,f,u,f],m=6,_=6,x=3,d=2,h=1,y=new Float32Array(x*_*m),S=new Float32Array(d*_*m),A=new Float32Array(h*_*m);for(let b=0;b<m;b++){const C=b%3*2/3-1,O=b>2?0:-1,E=[C,O,0,C+2/3,O,0,C+2/3,O+1,0,C,O,0,C+2/3,O+1,0,C,O+1,0];y.set(E,x*_*b),S.set(p,d*_*b);const M=[b,b,b,b,b,b];A.set(M,h*_*b)}const F=new ye;F.setAttribute("position",new De(y,x)),F.setAttribute("uv",new De(S,d)),F.setAttribute("faceIndex",new De(A,h)),t.push(F),r>qn&&r--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function da(i,t,e){const n=new Rn(i,t,e);return n.texture.mapping=Ji,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Gi(i,t,e,n,r){i.viewport.set(t,e,n,r),i.scissor.set(t,e,n,r)}function ad(i,t,e){const n=new Float32Array(An),r=new U(0,1,0);return new dn({name:"SphericalGaussianBlur",defines:{n:An,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:ns(),fragmentShader:`
3552
+
3553
+ precision mediump float;
3554
+ precision mediump int;
3555
+
3556
+ varying vec3 vOutputDirection;
3557
+
3558
+ uniform sampler2D envMap;
3559
+ uniform int samples;
3560
+ uniform float weights[ n ];
3561
+ uniform bool latitudinal;
3562
+ uniform float dTheta;
3563
+ uniform float mipInt;
3564
+ uniform vec3 poleAxis;
3565
+
3566
+ #define ENVMAP_TYPE_CUBE_UV
3567
+ #include <cube_uv_reflection_fragment>
3568
+
3569
+ vec3 getSample( float theta, vec3 axis ) {
3570
+
3571
+ float cosTheta = cos( theta );
3572
+ // Rodrigues' axis-angle rotation
3573
+ vec3 sampleDirection = vOutputDirection * cosTheta
3574
+ + cross( axis, vOutputDirection ) * sin( theta )
3575
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3576
+
3577
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3578
+
3579
+ }
3580
+
3581
+ void main() {
3582
+
3583
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3584
+
3585
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3586
+
3587
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3588
+
3589
+ }
3590
+
3591
+ axis = normalize( axis );
3592
+
3593
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3594
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3595
+
3596
+ for ( int i = 1; i < n; i++ ) {
3597
+
3598
+ if ( i >= samples ) {
3599
+
3600
+ break;
3601
+
3602
+ }
3603
+
3604
+ float theta = dTheta * float( i );
3605
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3606
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3607
+
3608
+ }
3609
+
3610
+ }
3611
+ `,blending:ln,depthTest:!1,depthWrite:!1})}function fa(){return new dn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ns(),fragmentShader:`
3612
+
3613
+ precision mediump float;
3614
+ precision mediump int;
3615
+
3616
+ varying vec3 vOutputDirection;
3617
+
3618
+ uniform sampler2D envMap;
3619
+
3620
+ #include <common>
3621
+
3622
+ void main() {
3623
+
3624
+ vec3 outputDirection = normalize( vOutputDirection );
3625
+ vec2 uv = equirectUv( outputDirection );
3626
+
3627
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3628
+
3629
+ }
3630
+ `,blending:ln,depthTest:!1,depthWrite:!1})}function pa(){return new dn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ns(),fragmentShader:`
3631
+
3632
+ precision mediump float;
3633
+ precision mediump int;
3634
+
3635
+ uniform float flipEnvMap;
3636
+
3637
+ varying vec3 vOutputDirection;
3638
+
3639
+ uniform samplerCube envMap;
3640
+
3641
+ void main() {
3642
+
3643
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3644
+
3645
+ }
3646
+ `,blending:ln,depthTest:!1,depthWrite:!1})}function ns(){return`
3647
+
3648
+ precision mediump float;
3649
+ precision mediump int;
3650
+
3651
+ attribute float faceIndex;
3652
+
3653
+ varying vec3 vOutputDirection;
3654
+
3655
+ // RH coordinate system; PMREM face-indexing convention
3656
+ vec3 getDirection( vec2 uv, float face ) {
3657
+
3658
+ uv = 2.0 * uv - 1.0;
3659
+
3660
+ vec3 direction = vec3( uv, 1.0 );
3661
+
3662
+ if ( face == 0.0 ) {
3663
+
3664
+ direction = direction.zyx; // ( 1, v, u ) pos x
3665
+
3666
+ } else if ( face == 1.0 ) {
3667
+
3668
+ direction = direction.xzy;
3669
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3670
+
3671
+ } else if ( face == 2.0 ) {
3672
+
3673
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3674
+
3675
+ } else if ( face == 3.0 ) {
3676
+
3677
+ direction = direction.zyx;
3678
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3679
+
3680
+ } else if ( face == 4.0 ) {
3681
+
3682
+ direction = direction.xzy;
3683
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3684
+
3685
+ } else if ( face == 5.0 ) {
3686
+
3687
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3688
+
3689
+ }
3690
+
3691
+ return direction;
3692
+
3693
+ }
3694
+
3695
+ void main() {
3696
+
3697
+ vOutputDirection = getDirection( uv, faceIndex );
3698
+ gl_Position = vec4( position, 1.0 );
3699
+
3700
+ }
3701
+ `}function od(i){let t=new WeakMap,e=null;function n(a){if(a&&a.isTexture){const l=a.mapping,c=l===Vr||l===kr,u=l===Zn||l===jn;if(c||u){let f=t.get(a);const p=f!==void 0?f.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==p)return e===null&&(e=new ua(i)),f=c?e.fromEquirectangular(a,f):e.fromCubemap(a,f),f.texture.pmremVersion=a.pmremVersion,t.set(a,f),f.texture;if(f!==void 0)return f.texture;{const m=a.image;return c&&m&&m.height>0||u&&m&&r(m)?(e===null&&(e=new ua(i)),f=c?e.fromEquirectangular(a):e.fromCubemap(a),f.texture.pmremVersion=a.pmremVersion,t.set(a,f),a.addEventListener("dispose",s),f.texture):null}}}return a}function r(a){let l=0;const c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){const l=a.target;l.removeEventListener("dispose",s);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:o}}function ld(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return t[n]=r,r}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const r=e(n);return r===null&&Jr("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function cd(i,t,e,n){const r={},s=new WeakMap;function o(f){const p=f.target;p.index!==null&&t.remove(p.index);for(const _ in p.attributes)t.remove(p.attributes[_]);for(const _ in p.morphAttributes){const x=p.morphAttributes[_];for(let d=0,h=x.length;d<h;d++)t.remove(x[d])}p.removeEventListener("dispose",o),delete r[p.id];const m=s.get(p);m&&(t.remove(m),s.delete(p)),n.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,e.memory.geometries--}function a(f,p){return r[p.id]===!0||(p.addEventListener("dispose",o),r[p.id]=!0,e.memory.geometries++),p}function l(f){const p=f.attributes;for(const _ in p)t.update(p[_],i.ARRAY_BUFFER);const m=f.morphAttributes;for(const _ in m){const x=m[_];for(let d=0,h=x.length;d<h;d++)t.update(x[d],i.ARRAY_BUFFER)}}function c(f){const p=[],m=f.index,_=f.attributes.position;let x=0;if(m!==null){const y=m.array;x=m.version;for(let S=0,A=y.length;S<A;S+=3){const F=y[S+0],b=y[S+1],C=y[S+2];p.push(F,b,b,C,C,F)}}else if(_!==void 0){const y=_.array;x=_.version;for(let S=0,A=y.length/3-1;S<A;S+=3){const F=S+0,b=S+1,C=S+2;p.push(F,b,b,C,C,F)}}else return;const d=new($a(p)?no:eo)(p,1);d.version=x;const h=s.get(f);h&&t.remove(h),s.set(f,d)}function u(f){const p=s.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&c(f)}else c(f);return s.get(f)}return{get:a,update:l,getWireframeAttribute:u}}function hd(i,t,e){let n;function r(p){n=p}let s,o;function a(p){s=p.type,o=p.bytesPerElement}function l(p,m){i.drawElements(n,m,s,p*o),e.update(m,n,1)}function c(p,m,_){_!==0&&(i.drawElementsInstanced(n,m,s,p*o,_),e.update(m,n,_))}function u(p,m,_){if(_===0)return;const x=t.get("WEBGL_multi_draw");if(x===null)for(let d=0;d<_;d++)this.render(p[d]/o,m[d]);else{x.multiDrawElementsWEBGL(n,m,0,s,p,0,_);let d=0;for(let h=0;h<_;h++)d+=m[h];e.update(d,n,1)}}function f(p,m,_,x){if(_===0)return;const d=t.get("WEBGL_multi_draw");if(d===null)for(let h=0;h<p.length;h++)c(p[h]/o,m[h],x[h]);else{d.multiDrawElementsInstancedWEBGL(n,m,0,s,p,0,x,0,_);let h=0;for(let y=0;y<_;y++)h+=m[y];for(let y=0;y<x.length;y++)e.update(h,n,x[y])}}this.setMode=r,this.setIndex=a,this.render=l,this.renderInstances=c,this.renderMultiDraw=u,this.renderMultiDrawInstances=f}function ud(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(e.calls++,o){case i.TRIANGLES:e.triangles+=a*(s/3);break;case i.LINES:e.lines+=a*(s/2);break;case i.LINE_STRIP:e.lines+=a*(s-1);break;case i.LINE_LOOP:e.lines+=a*s;break;case i.POINTS:e.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:r,update:n}}function dd(i,t,e){const n=new WeakMap,r=new Zt;function s(o,a,l){const c=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,f=u!==void 0?u.length:0;let p=n.get(a);if(p===void 0||p.count!==f){let E=function(){C.dispose(),n.delete(a),a.removeEventListener("dispose",E)};p!==void 0&&p.texture.dispose();const m=a.morphAttributes.position!==void 0,_=a.morphAttributes.normal!==void 0,x=a.morphAttributes.color!==void 0,d=a.morphAttributes.position||[],h=a.morphAttributes.normal||[],y=a.morphAttributes.color||[];let S=0;m===!0&&(S=1),_===!0&&(S=2),x===!0&&(S=3);let A=a.attributes.position.count*S,F=1;A>t.maxTextureSize&&(F=Math.ceil(A/t.maxTextureSize),A=t.maxTextureSize);const b=new Float32Array(A*F*4*f),C=new ja(b,A,F,f);C.type=on,C.needsUpdate=!0;const O=S*4;for(let M=0;M<f;M++){const P=d[M],X=h[M],z=y[M],W=A*F*4*M;for(let K=0;K<P.count;K++){const G=K*O;m===!0&&(r.fromBufferAttribute(P,K),b[W+G+0]=r.x,b[W+G+1]=r.y,b[W+G+2]=r.z,b[W+G+3]=0),_===!0&&(r.fromBufferAttribute(X,K),b[W+G+4]=r.x,b[W+G+5]=r.y,b[W+G+6]=r.z,b[W+G+7]=0),x===!0&&(r.fromBufferAttribute(z,K),b[W+G+8]=r.x,b[W+G+9]=r.y,b[W+G+10]=r.z,b[W+G+11]=z.itemSize===4?r.w:1)}}p={count:f,texture:C,size:new Dt(A,F)},n.set(a,p),a.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",o.morphTexture,e);else{let m=0;for(let x=0;x<c.length;x++)m+=c[x];const _=a.morphTargetsRelative?1:1-m;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",p.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",p.size)}return{update:s}}function fd(i,t,e,n){let r=new WeakMap;function s(l){const c=n.render.frame,u=l.geometry,f=t.get(l,u);if(r.get(f)!==c&&(t.update(f),r.set(f,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",a)===!1&&l.addEventListener("dispose",a),r.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),r.set(l,c))),l.isSkinnedMesh){const p=l.skeleton;r.get(p)!==c&&(p.update(),r.set(p,c))}return f}function o(){r=new WeakMap}function a(l){const c=l.target;c.removeEventListener("dispose",a),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:s,dispose:o}}class lo extends ve{constructor(t,e,n,r,s,o,a,l,c,u=Kn){if(u!==Kn&&u!==ti)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Kn&&(n=Jn),n===void 0&&u===ti&&(n=Qn),super(null,r,s,o,a,l,u,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:we,this.minFilter=l!==void 0?l:we,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const co=new ve,ho=new lo(1,1);ho.compareFunction=Ka;const uo=new ja,fo=new Ql,po=new so,ma=[],_a=[],ga=new Float32Array(16),va=new Float32Array(9),xa=new Float32Array(4);function ii(i,t,e){const n=i[0];if(n<=0||n>0)return i;const r=t*e;let s=ma[r];if(s===void 0&&(s=new Float32Array(r),ma[r]=s),t!==0){n.toArray(s,0);for(let o=1,a=0;o!==t;++o)a+=e,i[o].toArray(s,a)}return s}function ae(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function oe(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function nr(i,t){let e=_a[t];e===void 0&&(e=new Int32Array(t),_a[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function pd(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function md(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ae(e,t))return;i.uniform2fv(this.addr,t),oe(e,t)}}function _d(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(ae(e,t))return;i.uniform3fv(this.addr,t),oe(e,t)}}function gd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ae(e,t))return;i.uniform4fv(this.addr,t),oe(e,t)}}function vd(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ae(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),oe(e,t)}else{if(ae(e,n))return;xa.set(n),i.uniformMatrix2fv(this.addr,!1,xa),oe(e,n)}}function xd(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ae(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),oe(e,t)}else{if(ae(e,n))return;va.set(n),i.uniformMatrix3fv(this.addr,!1,va),oe(e,n)}}function Md(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(ae(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),oe(e,t)}else{if(ae(e,n))return;ga.set(n),i.uniformMatrix4fv(this.addr,!1,ga),oe(e,n)}}function Sd(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Ed(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ae(e,t))return;i.uniform2iv(this.addr,t),oe(e,t)}}function yd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ae(e,t))return;i.uniform3iv(this.addr,t),oe(e,t)}}function Td(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ae(e,t))return;i.uniform4iv(this.addr,t),oe(e,t)}}function Ad(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function bd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(ae(e,t))return;i.uniform2uiv(this.addr,t),oe(e,t)}}function wd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(ae(e,t))return;i.uniform3uiv(this.addr,t),oe(e,t)}}function Rd(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(ae(e,t))return;i.uniform4uiv(this.addr,t),oe(e,t)}}function Cd(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);const s=this.type===i.SAMPLER_2D_SHADOW?ho:co;e.setTexture2D(t||s,r)}function Pd(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture3D(t||fo,r)}function Ld(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTextureCube(t||po,r)}function Ud(i,t,e){const n=this.cache,r=e.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),e.setTexture2DArray(t||uo,r)}function Dd(i){switch(i){case 5126:return pd;case 35664:return md;case 35665:return _d;case 35666:return gd;case 35674:return vd;case 35675:return xd;case 35676:return Md;case 5124:case 35670:return Sd;case 35667:case 35671:return Ed;case 35668:case 35672:return yd;case 35669:case 35673:return Td;case 5125:return Ad;case 36294:return bd;case 36295:return wd;case 36296:return Rd;case 35678:case 36198:case 36298:case 36306:case 35682:return Cd;case 35679:case 36299:case 36307:return Pd;case 35680:case 36300:case 36308:case 36293:return Ld;case 36289:case 36303:case 36311:case 36292:return Ud}}function Id(i,t){i.uniform1fv(this.addr,t)}function Nd(i,t){const e=ii(t,this.size,2);i.uniform2fv(this.addr,e)}function Fd(i,t){const e=ii(t,this.size,3);i.uniform3fv(this.addr,e)}function Od(i,t){const e=ii(t,this.size,4);i.uniform4fv(this.addr,e)}function Bd(i,t){const e=ii(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function zd(i,t){const e=ii(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Hd(i,t){const e=ii(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Gd(i,t){i.uniform1iv(this.addr,t)}function Vd(i,t){i.uniform2iv(this.addr,t)}function kd(i,t){i.uniform3iv(this.addr,t)}function Wd(i,t){i.uniform4iv(this.addr,t)}function Xd(i,t){i.uniform1uiv(this.addr,t)}function qd(i,t){i.uniform2uiv(this.addr,t)}function Yd(i,t){i.uniform3uiv(this.addr,t)}function Kd(i,t){i.uniform4uiv(this.addr,t)}function $d(i,t,e){const n=this.cache,r=t.length,s=nr(e,r);ae(n,s)||(i.uniform1iv(this.addr,s),oe(n,s));for(let o=0;o!==r;++o)e.setTexture2D(t[o]||co,s[o])}function Zd(i,t,e){const n=this.cache,r=t.length,s=nr(e,r);ae(n,s)||(i.uniform1iv(this.addr,s),oe(n,s));for(let o=0;o!==r;++o)e.setTexture3D(t[o]||fo,s[o])}function jd(i,t,e){const n=this.cache,r=t.length,s=nr(e,r);ae(n,s)||(i.uniform1iv(this.addr,s),oe(n,s));for(let o=0;o!==r;++o)e.setTextureCube(t[o]||po,s[o])}function Jd(i,t,e){const n=this.cache,r=t.length,s=nr(e,r);ae(n,s)||(i.uniform1iv(this.addr,s),oe(n,s));for(let o=0;o!==r;++o)e.setTexture2DArray(t[o]||uo,s[o])}function Qd(i){switch(i){case 5126:return Id;case 35664:return Nd;case 35665:return Fd;case 35666:return Od;case 35674:return Bd;case 35675:return zd;case 35676:return Hd;case 5124:case 35670:return Gd;case 35667:case 35671:return Vd;case 35668:case 35672:return kd;case 35669:case 35673:return Wd;case 5125:return Xd;case 36294:return qd;case 36295:return Yd;case 36296:return Kd;case 35678:case 36198:case 36298:case 36306:case 35682:return $d;case 35679:case 36299:case 36307:return Zd;case 35680:case 36300:case 36308:case 36293:return jd;case 36289:case 36303:case 36311:case 36292:return Jd}}class tf{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Dd(e.type)}}class ef{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=Qd(e.type)}}class nf{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let s=0,o=r.length;s!==o;++s){const a=r[s];a.setValue(t,e[a.id],n)}}}const Fr=/(\w+)(\])?(\[|\.)?/g;function Ma(i,t){i.seq.push(t),i.map[t.id]=t}function rf(i,t,e){const n=i.name,r=n.length;for(Fr.lastIndex=0;;){const s=Fr.exec(n),o=Fr.lastIndex;let a=s[1];const l=s[2]==="]",c=s[3];if(l&&(a=a|0),c===void 0||c==="["&&o+2===r){Ma(e,c===void 0?new tf(a,i,t):new ef(a,i,t));break}else{let f=e.map[a];f===void 0&&(f=new nf(a),Ma(e,f)),e=f}}}class Wi{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const s=t.getActiveUniform(e,r),o=t.getUniformLocation(e,s.name);rf(s,o,this)}}setValue(t,e,n,r){const s=this.map[e];s!==void 0&&s.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];r!==void 0&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let s=0,o=e.length;s!==o;++s){const a=e[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(t,l.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,s=t.length;r!==s;++r){const o=t[r];o.id in e&&n.push(o)}return n}}function Sa(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const sf=37297;let af=0;function of(i,t){const e=i.split(`
3702
+ `),n=[],r=Math.max(t-6,0),s=Math.min(t+6,e.length);for(let o=r;o<s;o++){const a=o+1;n.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return n.join(`
3703
+ `)}function lf(i){const t=Xt.getPrimaries(Xt.workingColorSpace),e=Xt.getPrimaries(i);let n;switch(t===e?n="":t===$i&&e===Ki?n="LinearDisplayP3ToLinearSRGB":t===Ki&&e===$i&&(n="LinearSRGBToLinearDisplayP3"),i){case fn:case tr:return[n,"LinearTransferOETF"];case Fe:case Zr:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function Ea(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=i.getShaderInfoLog(t).trim();if(n&&r==="")return"";const s=/ERROR: 0:(\d+)/.exec(r);if(s){const o=parseInt(s[1]);return e.toUpperCase()+`
3704
+
3705
+ `+r+`
3706
+
3707
+ `+of(i.getShaderSource(t),o)}else return r}function cf(i,t){const e=lf(t);return`vec4 ${i}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function hf(i,t){let e;switch(t){case nl:e="Linear";break;case il:e="Reinhard";break;case rl:e="OptimizedCineon";break;case sl:e="ACESFilmic";break;case ol:e="AgX";break;case ll:e="Neutral";break;case al:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function uf(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ci).join(`
3708
+ `)}function df(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3709
+ `)}function ff(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const s=i.getActiveAttrib(t,r),o=s.name;let a=1;s.type===i.FLOAT_MAT2&&(a=2),s.type===i.FLOAT_MAT3&&(a=3),s.type===i.FLOAT_MAT4&&(a=4),e[o]={type:s.type,location:i.getAttribLocation(t,o),locationSize:a}}return e}function ci(i){return i!==""}function ya(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Ta(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const pf=/^[ \t]*#include +<([\w\d./]+)>/gm;function Yr(i){return i.replace(pf,_f)}const mf=new Map;function _f(i,t){let e=At[t];if(e===void 0){const n=mf.get(t);if(n!==void 0)e=At[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Yr(e)}const gf=/#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 Aa(i){return i.replace(gf,vf)}function vf(i,t,e,n){let r="";for(let s=parseInt(t);s<parseInt(e);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function ba(i){let t=`precision ${i.precision} float;
3710
+ precision ${i.precision} int;
3711
+ precision ${i.precision} sampler2D;
3712
+ precision ${i.precision} samplerCube;
3713
+ precision ${i.precision} sampler3D;
3714
+ precision ${i.precision} sampler2DArray;
3715
+ precision ${i.precision} sampler2DShadow;
3716
+ precision ${i.precision} samplerCubeShadow;
3717
+ precision ${i.precision} sampler2DArrayShadow;
3718
+ precision ${i.precision} isampler2D;
3719
+ precision ${i.precision} isampler3D;
3720
+ precision ${i.precision} isamplerCube;
3721
+ precision ${i.precision} isampler2DArray;
3722
+ precision ${i.precision} usampler2D;
3723
+ precision ${i.precision} usampler3D;
3724
+ precision ${i.precision} usamplerCube;
3725
+ precision ${i.precision} usampler2DArray;
3726
+ `;return i.precision==="highp"?t+=`
3727
+ #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3728
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3729
+ #define LOW_PRECISION`),t}function xf(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Ba?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===Ro?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Ye&&(t="SHADOWMAP_TYPE_VSM"),t}function Mf(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Zn:case jn:t="ENVMAP_TYPE_CUBE";break;case Ji:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Sf(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case jn:t="ENVMAP_MODE_REFRACTION";break}return t}function Ef(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case za:t="ENVMAP_BLENDING_MULTIPLY";break;case tl:t="ENVMAP_BLENDING_MIX";break;case el:t="ENVMAP_BLENDING_ADD";break}return t}function yf(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function Tf(i,t,e,n){const r=i.getContext(),s=e.defines;let o=e.vertexShader,a=e.fragmentShader;const l=xf(e),c=Mf(e),u=Sf(e),f=Ef(e),p=yf(e),m=uf(e),_=df(s),x=r.createProgram();let d,h,y=e.glslVersion?"#version "+e.glslVersion+`
3730
+ `:"";e.isRawShaderMaterial?(d=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_].filter(ci).join(`
3731
+ `),d.length>0&&(d+=`
3732
+ `),h=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_].filter(ci).join(`
3733
+ `),h.length>0&&(h+=`
3734
+ `)):(d=[ba(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+u:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","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",`
3735
+ `].filter(ci).join(`
3736
+ `),h=[ba(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,_,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+u:"",e.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==cn?"#define TONE_MAPPING":"",e.toneMapping!==cn?At.tonemapping_pars_fragment:"",e.toneMapping!==cn?hf("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",At.colorspace_pars_fragment,cf("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3737
+ `].filter(ci).join(`
3738
+ `)),o=Yr(o),o=ya(o,e),o=Ta(o,e),a=Yr(a),a=ya(a,e),a=Ta(a,e),o=Aa(o),a=Aa(a),e.isRawShaderMaterial!==!0&&(y=`#version 300 es
3739
+ `,d=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3740
+ `)+`
3741
+ `+d,h=["#define varying in",e.glslVersion===Gs?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Gs?"":"#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(`
3742
+ `)+`
3743
+ `+h);const S=y+d+o,A=y+h+a,F=Sa(r,r.VERTEX_SHADER,S),b=Sa(r,r.FRAGMENT_SHADER,A);r.attachShader(x,F),r.attachShader(x,b),e.index0AttributeName!==void 0?r.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&r.bindAttribLocation(x,0,"position"),r.linkProgram(x);function C(P){if(i.debug.checkShaderErrors){const X=r.getProgramInfoLog(x).trim(),z=r.getShaderInfoLog(F).trim(),W=r.getShaderInfoLog(b).trim();let K=!0,G=!0;if(r.getProgramParameter(x,r.LINK_STATUS)===!1)if(K=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,x,F,b);else{const J=Ea(r,F,"vertex"),H=Ea(r,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(x,r.VALIDATE_STATUS)+`
3744
+
3745
+ Material Name: `+P.name+`
3746
+ Material Type: `+P.type+`
3747
+
3748
+ Program Info Log: `+X+`
3749
+ `+J+`
3750
+ `+H)}else X!==""?console.warn("THREE.WebGLProgram: Program Info Log:",X):(z===""||W==="")&&(G=!1);G&&(P.diagnostics={runnable:K,programLog:X,vertexShader:{log:z,prefix:d},fragmentShader:{log:W,prefix:h}})}r.deleteShader(F),r.deleteShader(b),O=new Wi(r,x),E=ff(r,x)}let O;this.getUniforms=function(){return O===void 0&&C(this),O};let E;this.getAttributes=function(){return E===void 0&&C(this),E};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(x,sf)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=af++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=F,this.fragmentShader=b,this}let Af=0;class bf{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,r=this._getShaderStage(e),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new wf(t),e.set(t,n)),n}}class wf{constructor(t){this.id=Af++,this.code=t,this.usedTimes=0}}function Rf(i,t,e,n,r,s,o){const a=new ts,l=new bf,c=new Set,u=[],f=r.logarithmicDepthBuffer,p=r.vertexTextures;let m=r.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(E){return c.add(E),E===0?"uv":`uv${E}`}function d(E,M,P,X,z){const W=X.fog,K=z.geometry,G=E.isMeshStandardMaterial?X.environment:null,J=(E.isMeshStandardMaterial?e:t).get(E.envMap||G),H=J&&J.mapping===Ji?J.image.height:null,ct=_[E.type];E.precision!==null&&(m=r.getMaxPrecision(E.precision),m!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",m,"instead."));const dt=K.morphAttributes.position||K.morphAttributes.normal||K.morphAttributes.color,pt=dt!==void 0?dt.length:0;let Ft=0;K.morphAttributes.position!==void 0&&(Ft=1),K.morphAttributes.normal!==void 0&&(Ft=2),K.morphAttributes.color!==void 0&&(Ft=3);let qt,k,j,ut;if(ct){const Yt=Oe[ct];qt=Yt.vertexShader,k=Yt.fragmentShader}else qt=E.vertexShader,k=E.fragmentShader,l.update(E),j=l.getVertexShaderID(E),ut=l.getFragmentShaderID(E);const st=i.getRenderTarget(),Pt=z.isInstancedMesh===!0,wt=z.isBatchedMesh===!0,Bt=!!E.map,R=!!E.matcap,Ot=!!J,It=!!E.aoMap,jt=!!E.lightMap,xt=!!E.bumpMap,zt=!!E.normalMap,Lt=!!E.displacementMap,Tt=!!E.emissiveMap,ie=!!E.metalnessMap,T=!!E.roughnessMap,g=E.anisotropy>0,B=E.clearcoat>0,Y=E.dispersion>0,$=E.iridescence>0,Z=E.sheen>0,gt=E.transmission>0,it=g&&!!E.anisotropyMap,rt=B&&!!E.clearcoatMap,Rt=B&&!!E.clearcoatNormalMap,Q=B&&!!E.clearcoatRoughnessMap,mt=$&&!!E.iridescenceMap,Ut=$&&!!E.iridescenceThicknessMap,Et=Z&&!!E.sheenColorMap,at=Z&&!!E.sheenRoughnessMap,Ct=!!E.specularMap,Nt=!!E.specularColorMap,ee=!!E.specularIntensityMap,w=gt&&!!E.transmissionMap,ot=gt&&!!E.thicknessMap,V=!!E.gradientMap,q=!!E.alphaMap,et=E.alphaTest>0,yt=!!E.alphaHash,Gt=!!E.extensions;let ne=cn;E.toneMapped&&(st===null||st.isXRRenderTarget===!0)&&(ne=i.toneMapping);const le={shaderID:ct,shaderType:E.type,shaderName:E.name,vertexShader:qt,fragmentShader:k,defines:E.defines,customVertexShaderID:j,customFragmentShaderID:ut,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:m,batching:wt,batchingColor:wt&&z._colorsTexture!==null,instancing:Pt,instancingColor:Pt&&z.instanceColor!==null,instancingMorph:Pt&&z.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:st===null?i.outputColorSpace:st.isXRRenderTarget===!0?st.texture.colorSpace:fn,alphaToCoverage:!!E.alphaToCoverage,map:Bt,matcap:R,envMap:Ot,envMapMode:Ot&&J.mapping,envMapCubeUVHeight:H,aoMap:It,lightMap:jt,bumpMap:xt,normalMap:zt,displacementMap:p&&Lt,emissiveMap:Tt,normalMapObjectSpace:zt&&E.normalMapType===El,normalMapTangentSpace:zt&&E.normalMapType===Ya,metalnessMap:ie,roughnessMap:T,anisotropy:g,anisotropyMap:it,clearcoat:B,clearcoatMap:rt,clearcoatNormalMap:Rt,clearcoatRoughnessMap:Q,dispersion:Y,iridescence:$,iridescenceMap:mt,iridescenceThicknessMap:Ut,sheen:Z,sheenColorMap:Et,sheenRoughnessMap:at,specularMap:Ct,specularColorMap:Nt,specularIntensityMap:ee,transmission:gt,transmissionMap:w,thicknessMap:ot,gradientMap:V,opaque:E.transparent===!1&&E.blending===Yn&&E.alphaToCoverage===!1,alphaMap:q,alphaTest:et,alphaHash:yt,combine:E.combine,mapUv:Bt&&x(E.map.channel),aoMapUv:It&&x(E.aoMap.channel),lightMapUv:jt&&x(E.lightMap.channel),bumpMapUv:xt&&x(E.bumpMap.channel),normalMapUv:zt&&x(E.normalMap.channel),displacementMapUv:Lt&&x(E.displacementMap.channel),emissiveMapUv:Tt&&x(E.emissiveMap.channel),metalnessMapUv:ie&&x(E.metalnessMap.channel),roughnessMapUv:T&&x(E.roughnessMap.channel),anisotropyMapUv:it&&x(E.anisotropyMap.channel),clearcoatMapUv:rt&&x(E.clearcoatMap.channel),clearcoatNormalMapUv:Rt&&x(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Q&&x(E.clearcoatRoughnessMap.channel),iridescenceMapUv:mt&&x(E.iridescenceMap.channel),iridescenceThicknessMapUv:Ut&&x(E.iridescenceThicknessMap.channel),sheenColorMapUv:Et&&x(E.sheenColorMap.channel),sheenRoughnessMapUv:at&&x(E.sheenRoughnessMap.channel),specularMapUv:Ct&&x(E.specularMap.channel),specularColorMapUv:Nt&&x(E.specularColorMap.channel),specularIntensityMapUv:ee&&x(E.specularIntensityMap.channel),transmissionMapUv:w&&x(E.transmissionMap.channel),thicknessMapUv:ot&&x(E.thicknessMap.channel),alphaMapUv:q&&x(E.alphaMap.channel),vertexTangents:!!K.attributes.tangent&&(zt||g),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!K.attributes.color&&K.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!K.attributes.uv&&(Bt||q),fog:!!W,useFog:E.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:z.isSkinnedMesh===!0,morphTargets:K.morphAttributes.position!==void 0,morphNormals:K.morphAttributes.normal!==void 0,morphColors:K.morphAttributes.color!==void 0,morphTargetsCount:pt,morphTextureStride:Ft,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:ne,decodeVideoTexture:Bt&&E.map.isVideoTexture===!0&&Xt.getTransfer(E.map.colorSpace)===$t,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===Ke,flipSided:E.side===xe,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:Gt&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:Gt&&E.extensions.multiDraw===!0&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return le.vertexUv1s=c.has(1),le.vertexUv2s=c.has(2),le.vertexUv3s=c.has(3),c.clear(),le}function h(E){const M=[];if(E.shaderID?M.push(E.shaderID):(M.push(E.customVertexShaderID),M.push(E.customFragmentShaderID)),E.defines!==void 0)for(const P in E.defines)M.push(P),M.push(E.defines[P]);return E.isRawShaderMaterial===!1&&(y(M,E),S(M,E),M.push(i.outputColorSpace)),M.push(E.customProgramCacheKey),M.join()}function y(E,M){E.push(M.precision),E.push(M.outputColorSpace),E.push(M.envMapMode),E.push(M.envMapCubeUVHeight),E.push(M.mapUv),E.push(M.alphaMapUv),E.push(M.lightMapUv),E.push(M.aoMapUv),E.push(M.bumpMapUv),E.push(M.normalMapUv),E.push(M.displacementMapUv),E.push(M.emissiveMapUv),E.push(M.metalnessMapUv),E.push(M.roughnessMapUv),E.push(M.anisotropyMapUv),E.push(M.clearcoatMapUv),E.push(M.clearcoatNormalMapUv),E.push(M.clearcoatRoughnessMapUv),E.push(M.iridescenceMapUv),E.push(M.iridescenceThicknessMapUv),E.push(M.sheenColorMapUv),E.push(M.sheenRoughnessMapUv),E.push(M.specularMapUv),E.push(M.specularColorMapUv),E.push(M.specularIntensityMapUv),E.push(M.transmissionMapUv),E.push(M.thicknessMapUv),E.push(M.combine),E.push(M.fogExp2),E.push(M.sizeAttenuation),E.push(M.morphTargetsCount),E.push(M.morphAttributeCount),E.push(M.numDirLights),E.push(M.numPointLights),E.push(M.numSpotLights),E.push(M.numSpotLightMaps),E.push(M.numHemiLights),E.push(M.numRectAreaLights),E.push(M.numDirLightShadows),E.push(M.numPointLightShadows),E.push(M.numSpotLightShadows),E.push(M.numSpotLightShadowsWithMaps),E.push(M.numLightProbes),E.push(M.shadowMapType),E.push(M.toneMapping),E.push(M.numClippingPlanes),E.push(M.numClipIntersection),E.push(M.depthPacking)}function S(E,M){a.disableAll(),M.supportsVertexTextures&&a.enable(0),M.instancing&&a.enable(1),M.instancingColor&&a.enable(2),M.instancingMorph&&a.enable(3),M.matcap&&a.enable(4),M.envMap&&a.enable(5),M.normalMapObjectSpace&&a.enable(6),M.normalMapTangentSpace&&a.enable(7),M.clearcoat&&a.enable(8),M.iridescence&&a.enable(9),M.alphaTest&&a.enable(10),M.vertexColors&&a.enable(11),M.vertexAlphas&&a.enable(12),M.vertexUv1s&&a.enable(13),M.vertexUv2s&&a.enable(14),M.vertexUv3s&&a.enable(15),M.vertexTangents&&a.enable(16),M.anisotropy&&a.enable(17),M.alphaHash&&a.enable(18),M.batching&&a.enable(19),M.dispersion&&a.enable(20),M.batchingColor&&a.enable(21),E.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.skinning&&a.enable(4),M.morphTargets&&a.enable(5),M.morphNormals&&a.enable(6),M.morphColors&&a.enable(7),M.premultipliedAlpha&&a.enable(8),M.shadowMapEnabled&&a.enable(9),M.doubleSided&&a.enable(10),M.flipSided&&a.enable(11),M.useDepthPacking&&a.enable(12),M.dithering&&a.enable(13),M.transmission&&a.enable(14),M.sheen&&a.enable(15),M.opaque&&a.enable(16),M.pointsUvs&&a.enable(17),M.decodeVideoTexture&&a.enable(18),M.alphaToCoverage&&a.enable(19),E.push(a.mask)}function A(E){const M=_[E.type];let P;if(M){const X=Oe[M];P=uc.clone(X.uniforms)}else P=E.uniforms;return P}function F(E,M){let P;for(let X=0,z=u.length;X<z;X++){const W=u[X];if(W.cacheKey===M){P=W,++P.usedTimes;break}}return P===void 0&&(P=new Tf(i,M,E,s),u.push(P)),P}function b(E){if(--E.usedTimes===0){const M=u.indexOf(E);u[M]=u[u.length-1],u.pop(),E.destroy()}}function C(E){l.remove(E)}function O(){l.dispose()}return{getParameters:d,getProgramCacheKey:h,getUniforms:A,acquireProgram:F,releaseProgram:b,releaseShaderCache:C,programs:u,dispose:O}}function Cf(){let i=new WeakMap;function t(s){let o=i.get(s);return o===void 0&&(o={},i.set(s,o)),o}function e(s){i.delete(s)}function n(s,o,a){i.get(s)[o]=a}function r(){i=new WeakMap}return{get:t,remove:e,update:n,dispose:r}}function Pf(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function wa(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Ra(){const i=[];let t=0;const e=[],n=[],r=[];function s(){t=0,e.length=0,n.length=0,r.length=0}function o(f,p,m,_,x,d){let h=i[t];return h===void 0?(h={id:f.id,object:f,geometry:p,material:m,groupOrder:_,renderOrder:f.renderOrder,z:x,group:d},i[t]=h):(h.id=f.id,h.object=f,h.geometry=p,h.material=m,h.groupOrder=_,h.renderOrder=f.renderOrder,h.z=x,h.group=d),t++,h}function a(f,p,m,_,x,d){const h=o(f,p,m,_,x,d);m.transmission>0?n.push(h):m.transparent===!0?r.push(h):e.push(h)}function l(f,p,m,_,x,d){const h=o(f,p,m,_,x,d);m.transmission>0?n.unshift(h):m.transparent===!0?r.unshift(h):e.unshift(h)}function c(f,p){e.length>1&&e.sort(f||Pf),n.length>1&&n.sort(p||wa),r.length>1&&r.sort(p||wa)}function u(){for(let f=t,p=i.length;f<p;f++){const m=i[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:e,transmissive:n,transparent:r,init:s,push:a,unshift:l,finish:u,sort:c}}function Lf(){let i=new WeakMap;function t(n,r){const s=i.get(n);let o;return s===void 0?(o=new Ra,i.set(n,[o])):r>=s.length?(o=new Ra,s.push(o)):o=s[r],o}function e(){i=new WeakMap}return{get:t,dispose:e}}function Uf(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new U,color:new Ht};break;case"SpotLight":e={position:new U,direction:new U,color:new Ht,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new U,color:new Ht,distance:0,decay:0};break;case"HemisphereLight":e={direction:new U,skyColor:new Ht,groundColor:new Ht};break;case"RectAreaLight":e={color:new Ht,position:new U,halfWidth:new U,halfHeight:new U};break}return i[t.id]=e,e}}}function Df(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let If=0;function Nf(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Ff(i){const t=new Uf,e=Df(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new U);const r=new U,s=new Jt,o=new Jt;function a(c){let u=0,f=0,p=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let m=0,_=0,x=0,d=0,h=0,y=0,S=0,A=0,F=0,b=0,C=0;c.sort(Nf);for(let E=0,M=c.length;E<M;E++){const P=c[E],X=P.color,z=P.intensity,W=P.distance,K=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)u+=X.r*z,f+=X.g*z,p+=X.b*z;else if(P.isLightProbe){for(let G=0;G<9;G++)n.probe[G].addScaledVector(P.sh.coefficients[G],z);C++}else if(P.isDirectionalLight){const G=t.get(P);if(G.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){const J=P.shadow,H=e.get(P);H.shadowBias=J.bias,H.shadowNormalBias=J.normalBias,H.shadowRadius=J.radius,H.shadowMapSize=J.mapSize,n.directionalShadow[m]=H,n.directionalShadowMap[m]=K,n.directionalShadowMatrix[m]=P.shadow.matrix,y++}n.directional[m]=G,m++}else if(P.isSpotLight){const G=t.get(P);G.position.setFromMatrixPosition(P.matrixWorld),G.color.copy(X).multiplyScalar(z),G.distance=W,G.coneCos=Math.cos(P.angle),G.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),G.decay=P.decay,n.spot[x]=G;const J=P.shadow;if(P.map&&(n.spotLightMap[F]=P.map,F++,J.updateMatrices(P),P.castShadow&&b++),n.spotLightMatrix[x]=J.matrix,P.castShadow){const H=e.get(P);H.shadowBias=J.bias,H.shadowNormalBias=J.normalBias,H.shadowRadius=J.radius,H.shadowMapSize=J.mapSize,n.spotShadow[x]=H,n.spotShadowMap[x]=K,A++}x++}else if(P.isRectAreaLight){const G=t.get(P);G.color.copy(X).multiplyScalar(z),G.halfWidth.set(P.width*.5,0,0),G.halfHeight.set(0,P.height*.5,0),n.rectArea[d]=G,d++}else if(P.isPointLight){const G=t.get(P);if(G.color.copy(P.color).multiplyScalar(P.intensity),G.distance=P.distance,G.decay=P.decay,P.castShadow){const J=P.shadow,H=e.get(P);H.shadowBias=J.bias,H.shadowNormalBias=J.normalBias,H.shadowRadius=J.radius,H.shadowMapSize=J.mapSize,H.shadowCameraNear=J.camera.near,H.shadowCameraFar=J.camera.far,n.pointShadow[_]=H,n.pointShadowMap[_]=K,n.pointShadowMatrix[_]=P.shadow.matrix,S++}n.point[_]=G,_++}else if(P.isHemisphereLight){const G=t.get(P);G.skyColor.copy(P.color).multiplyScalar(z),G.groundColor.copy(P.groundColor).multiplyScalar(z),n.hemi[h]=G,h++}}d>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=nt.LTC_FLOAT_1,n.rectAreaLTC2=nt.LTC_FLOAT_2):(n.rectAreaLTC1=nt.LTC_HALF_1,n.rectAreaLTC2=nt.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=f,n.ambient[2]=p;const O=n.hash;(O.directionalLength!==m||O.pointLength!==_||O.spotLength!==x||O.rectAreaLength!==d||O.hemiLength!==h||O.numDirectionalShadows!==y||O.numPointShadows!==S||O.numSpotShadows!==A||O.numSpotMaps!==F||O.numLightProbes!==C)&&(n.directional.length=m,n.spot.length=x,n.rectArea.length=d,n.point.length=_,n.hemi.length=h,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=S,n.pointShadowMap.length=S,n.spotShadow.length=A,n.spotShadowMap.length=A,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=S,n.spotLightMatrix.length=A+F-b,n.spotLightMap.length=F,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=C,O.directionalLength=m,O.pointLength=_,O.spotLength=x,O.rectAreaLength=d,O.hemiLength=h,O.numDirectionalShadows=y,O.numPointShadows=S,O.numSpotShadows=A,O.numSpotMaps=F,O.numLightProbes=C,n.version=If++)}function l(c,u){let f=0,p=0,m=0,_=0,x=0;const d=u.matrixWorldInverse;for(let h=0,y=c.length;h<y;h++){const S=c[h];if(S.isDirectionalLight){const A=n.directional[f];A.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(d),f++}else if(S.isSpotLight){const A=n.spot[m];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(d),A.direction.setFromMatrixPosition(S.matrixWorld),r.setFromMatrixPosition(S.target.matrixWorld),A.direction.sub(r),A.direction.transformDirection(d),m++}else if(S.isRectAreaLight){const A=n.rectArea[_];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(d),o.identity(),s.copy(S.matrixWorld),s.premultiply(d),o.extractRotation(s),A.halfWidth.set(S.width*.5,0,0),A.halfHeight.set(0,S.height*.5,0),A.halfWidth.applyMatrix4(o),A.halfHeight.applyMatrix4(o),_++}else if(S.isPointLight){const A=n.point[p];A.position.setFromMatrixPosition(S.matrixWorld),A.position.applyMatrix4(d),p++}else if(S.isHemisphereLight){const A=n.hemi[x];A.direction.setFromMatrixPosition(S.matrixWorld),A.direction.transformDirection(d),x++}}}return{setup:a,setupView:l,state:n}}function Ca(i){const t=new Ff(i),e=[],n=[];function r(u){c.camera=u,e.length=0,n.length=0}function s(u){e.push(u)}function o(u){n.push(u)}function a(){t.setup(e)}function l(u){t.setupView(e,u)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:r,state:c,setupLights:a,setupLightsView:l,pushLight:s,pushShadow:o}}function Of(i){let t=new WeakMap;function e(r,s=0){const o=t.get(r);let a;return o===void 0?(a=new Ca(i),t.set(r,[a])):s>=o.length?(a=new Ca(i),o.push(a)):a=o[s],a}function n(){t=new WeakMap}return{get:e,dispose:n}}class Bf extends mi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ml,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class zf extends mi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const Hf=`void main() {
3751
+ gl_Position = vec4( position, 1.0 );
3752
+ }`,Gf=`uniform sampler2D shadow_pass;
3753
+ uniform vec2 resolution;
3754
+ uniform float radius;
3755
+ #include <packing>
3756
+ void main() {
3757
+ const float samples = float( VSM_SAMPLES );
3758
+ float mean = 0.0;
3759
+ float squared_mean = 0.0;
3760
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3761
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3762
+ for ( float i = 0.0; i < samples; i ++ ) {
3763
+ float uvOffset = uvStart + i * uvStride;
3764
+ #ifdef HORIZONTAL_PASS
3765
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3766
+ mean += distribution.x;
3767
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3768
+ #else
3769
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3770
+ mean += depth;
3771
+ squared_mean += depth * depth;
3772
+ #endif
3773
+ }
3774
+ mean = mean / samples;
3775
+ squared_mean = squared_mean / samples;
3776
+ float std_dev = sqrt( squared_mean - mean * mean );
3777
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3778
+ }`;function Vf(i,t,e){let n=new es;const r=new Dt,s=new Dt,o=new Zt,a=new Bf({depthPacking:Sl}),l=new zf,c={},u=e.maxTextureSize,f={[hn]:xe,[xe]:hn,[Ke]:Ke},p=new dn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:Hf,fragmentShader:Gf}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const _=new ye;_.setAttribute("position",new De(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new Ze(_,p),d=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ba;let h=this.type;this.render=function(b,C,O){if(d.enabled===!1||d.autoUpdate===!1&&d.needsUpdate===!1||b.length===0)return;const E=i.getRenderTarget(),M=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),X=i.state;X.setBlending(ln),X.buffers.color.setClear(1,1,1,1),X.buffers.depth.setTest(!0),X.setScissorTest(!1);const z=h!==Ye&&this.type===Ye,W=h===Ye&&this.type!==Ye;for(let K=0,G=b.length;K<G;K++){const J=b[K],H=J.shadow;if(H===void 0){console.warn("THREE.WebGLShadowMap:",J,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;r.copy(H.mapSize);const ct=H.getFrameExtents();if(r.multiply(ct),s.copy(H.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/ct.x),r.x=s.x*ct.x,H.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/ct.y),r.y=s.y*ct.y,H.mapSize.y=s.y)),H.map===null||z===!0||W===!0){const pt=this.type!==Ye?{minFilter:we,magFilter:we}:{};H.map!==null&&H.map.dispose(),H.map=new Rn(r.x,r.y,pt),H.map.texture.name=J.name+".shadowMap",H.camera.updateProjectionMatrix()}i.setRenderTarget(H.map),i.clear();const dt=H.getViewportCount();for(let pt=0;pt<dt;pt++){const Ft=H.getViewport(pt);o.set(s.x*Ft.x,s.y*Ft.y,s.x*Ft.z,s.y*Ft.w),X.viewport(o),H.updateMatrices(J,pt),n=H.getFrustum(),A(C,O,H.camera,J,this.type)}H.isPointLightShadow!==!0&&this.type===Ye&&y(H,O),H.needsUpdate=!1}h=this.type,d.needsUpdate=!1,i.setRenderTarget(E,M,P)};function y(b,C){const O=t.update(x);p.defines.VSM_SAMPLES!==b.blurSamples&&(p.defines.VSM_SAMPLES=b.blurSamples,m.defines.VSM_SAMPLES=b.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Rn(r.x,r.y)),p.uniforms.shadow_pass.value=b.map.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(C,null,O,p,x,null),m.uniforms.shadow_pass.value=b.mapPass.texture,m.uniforms.resolution.value=b.mapSize,m.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(C,null,O,m,x,null)}function S(b,C,O,E){let M=null;const P=O.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(P!==void 0)M=P;else if(M=O.isPointLight===!0?l:a,i.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const X=M.uuid,z=C.uuid;let W=c[X];W===void 0&&(W={},c[X]=W);let K=W[z];K===void 0&&(K=M.clone(),W[z]=K,C.addEventListener("dispose",F)),M=K}if(M.visible=C.visible,M.wireframe=C.wireframe,E===Ye?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:f[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.map=C.map,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,O.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const X=i.properties.get(M);X.light=O}return M}function A(b,C,O,E,M){if(b.visible===!1)return;if(b.layers.test(C.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&M===Ye)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,b.matrixWorld);const z=t.update(b),W=b.material;if(Array.isArray(W)){const K=z.groups;for(let G=0,J=K.length;G<J;G++){const H=K[G],ct=W[H.materialIndex];if(ct&&ct.visible){const dt=S(b,ct,E,M);b.onBeforeShadow(i,b,C,O,z,dt,H),i.renderBufferDirect(O,null,z,dt,b,H),b.onAfterShadow(i,b,C,O,z,dt,H)}}}else if(W.visible){const K=S(b,W,E,M);b.onBeforeShadow(i,b,C,O,z,K,null),i.renderBufferDirect(O,null,z,K,b,null),b.onAfterShadow(i,b,C,O,z,K,null)}}const X=b.children;for(let z=0,W=X.length;z<W;z++)A(X[z],C,O,E,M)}function F(b){b.target.removeEventListener("dispose",F);for(const O in c){const E=c[O],M=b.target.uuid;M in E&&(E[M].dispose(),delete E[M])}}}function kf(i){function t(){let w=!1;const ot=new Zt;let V=null;const q=new Zt(0,0,0,0);return{setMask:function(et){V!==et&&!w&&(i.colorMask(et,et,et,et),V=et)},setLocked:function(et){w=et},setClear:function(et,yt,Gt,ne,le){le===!0&&(et*=ne,yt*=ne,Gt*=ne),ot.set(et,yt,Gt,ne),q.equals(ot)===!1&&(i.clearColor(et,yt,Gt,ne),q.copy(ot))},reset:function(){w=!1,V=null,q.set(-1,0,0,0)}}}function e(){let w=!1,ot=null,V=null,q=null;return{setTest:function(et){et?ut(i.DEPTH_TEST):st(i.DEPTH_TEST)},setMask:function(et){ot!==et&&!w&&(i.depthMask(et),ot=et)},setFunc:function(et){if(V!==et){switch(et){case Yo:i.depthFunc(i.NEVER);break;case Ko:i.depthFunc(i.ALWAYS);break;case $o:i.depthFunc(i.LESS);break;case Xi:i.depthFunc(i.LEQUAL);break;case Zo:i.depthFunc(i.EQUAL);break;case jo:i.depthFunc(i.GEQUAL);break;case Jo:i.depthFunc(i.GREATER);break;case Qo:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}V=et}},setLocked:function(et){w=et},setClear:function(et){q!==et&&(i.clearDepth(et),q=et)},reset:function(){w=!1,ot=null,V=null,q=null}}}function n(){let w=!1,ot=null,V=null,q=null,et=null,yt=null,Gt=null,ne=null,le=null;return{setTest:function(Yt){w||(Yt?ut(i.STENCIL_TEST):st(i.STENCIL_TEST))},setMask:function(Yt){ot!==Yt&&!w&&(i.stencilMask(Yt),ot=Yt)},setFunc:function(Yt,Ie,Ne){(V!==Yt||q!==Ie||et!==Ne)&&(i.stencilFunc(Yt,Ie,Ne),V=Yt,q=Ie,et=Ne)},setOp:function(Yt,Ie,Ne){(yt!==Yt||Gt!==Ie||ne!==Ne)&&(i.stencilOp(Yt,Ie,Ne),yt=Yt,Gt=Ie,ne=Ne)},setLocked:function(Yt){w=Yt},setClear:function(Yt){le!==Yt&&(i.clearStencil(Yt),le=Yt)},reset:function(){w=!1,ot=null,V=null,q=null,et=null,yt=null,Gt=null,ne=null,le=null}}}const r=new t,s=new e,o=new n,a=new WeakMap,l=new WeakMap;let c={},u={},f=new WeakMap,p=[],m=null,_=!1,x=null,d=null,h=null,y=null,S=null,A=null,F=null,b=new Ht(0,0,0),C=0,O=!1,E=null,M=null,P=null,X=null,z=null;const W=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,G=0;const J=i.getParameter(i.VERSION);J.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\d)/.exec(J)[1]),K=G>=1):J.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\d)/.exec(J)[1]),K=G>=2);let H=null,ct={};const dt=i.getParameter(i.SCISSOR_BOX),pt=i.getParameter(i.VIEWPORT),Ft=new Zt().fromArray(dt),qt=new Zt().fromArray(pt);function k(w,ot,V,q){const et=new Uint8Array(4),yt=i.createTexture();i.bindTexture(w,yt),i.texParameteri(w,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(w,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Gt=0;Gt<V;Gt++)w===i.TEXTURE_3D||w===i.TEXTURE_2D_ARRAY?i.texImage3D(ot,0,i.RGBA,1,1,q,0,i.RGBA,i.UNSIGNED_BYTE,et):i.texImage2D(ot+Gt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,et);return yt}const j={};j[i.TEXTURE_2D]=k(i.TEXTURE_2D,i.TEXTURE_2D,1),j[i.TEXTURE_CUBE_MAP]=k(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),j[i.TEXTURE_2D_ARRAY]=k(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),j[i.TEXTURE_3D]=k(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),s.setClear(1),o.setClear(0),ut(i.DEPTH_TEST),s.setFunc(Xi),xt(!1),zt(hs),ut(i.CULL_FACE),It(ln);function ut(w){c[w]!==!0&&(i.enable(w),c[w]=!0)}function st(w){c[w]!==!1&&(i.disable(w),c[w]=!1)}function Pt(w,ot){return u[w]!==ot?(i.bindFramebuffer(w,ot),u[w]=ot,w===i.DRAW_FRAMEBUFFER&&(u[i.FRAMEBUFFER]=ot),w===i.FRAMEBUFFER&&(u[i.DRAW_FRAMEBUFFER]=ot),!0):!1}function wt(w,ot){let V=p,q=!1;if(w){V=f.get(ot),V===void 0&&(V=[],f.set(ot,V));const et=w.textures;if(V.length!==et.length||V[0]!==i.COLOR_ATTACHMENT0){for(let yt=0,Gt=et.length;yt<Gt;yt++)V[yt]=i.COLOR_ATTACHMENT0+yt;V.length=et.length,q=!0}}else V[0]!==i.BACK&&(V[0]=i.BACK,q=!0);q&&i.drawBuffers(V)}function Bt(w){return m!==w?(i.useProgram(w),m=w,!0):!1}const R={[Tn]:i.FUNC_ADD,[Po]:i.FUNC_SUBTRACT,[Lo]:i.FUNC_REVERSE_SUBTRACT};R[Uo]=i.MIN,R[Do]=i.MAX;const Ot={[Io]:i.ZERO,[No]:i.ONE,[Fo]:i.SRC_COLOR,[Hr]:i.SRC_ALPHA,[Vo]:i.SRC_ALPHA_SATURATE,[Ho]:i.DST_COLOR,[Bo]:i.DST_ALPHA,[Oo]:i.ONE_MINUS_SRC_COLOR,[Gr]:i.ONE_MINUS_SRC_ALPHA,[Go]:i.ONE_MINUS_DST_COLOR,[zo]:i.ONE_MINUS_DST_ALPHA,[ko]:i.CONSTANT_COLOR,[Wo]:i.ONE_MINUS_CONSTANT_COLOR,[Xo]:i.CONSTANT_ALPHA,[qo]:i.ONE_MINUS_CONSTANT_ALPHA};function It(w,ot,V,q,et,yt,Gt,ne,le,Yt){if(w===ln){_===!0&&(st(i.BLEND),_=!1);return}if(_===!1&&(ut(i.BLEND),_=!0),w!==Co){if(w!==x||Yt!==O){if((d!==Tn||S!==Tn)&&(i.blendEquation(i.FUNC_ADD),d=Tn,S=Tn),Yt)switch(w){case Yn:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case us:i.blendFunc(i.ONE,i.ONE);break;case ds:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case fs:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}else switch(w){case Yn:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case us:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case ds:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case fs:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",w);break}h=null,y=null,A=null,F=null,b.set(0,0,0),C=0,x=w,O=Yt}return}et=et||ot,yt=yt||V,Gt=Gt||q,(ot!==d||et!==S)&&(i.blendEquationSeparate(R[ot],R[et]),d=ot,S=et),(V!==h||q!==y||yt!==A||Gt!==F)&&(i.blendFuncSeparate(Ot[V],Ot[q],Ot[yt],Ot[Gt]),h=V,y=q,A=yt,F=Gt),(ne.equals(b)===!1||le!==C)&&(i.blendColor(ne.r,ne.g,ne.b,le),b.copy(ne),C=le),x=w,O=!1}function jt(w,ot){w.side===Ke?st(i.CULL_FACE):ut(i.CULL_FACE);let V=w.side===xe;ot&&(V=!V),xt(V),w.blending===Yn&&w.transparent===!1?It(ln):It(w.blending,w.blendEquation,w.blendSrc,w.blendDst,w.blendEquationAlpha,w.blendSrcAlpha,w.blendDstAlpha,w.blendColor,w.blendAlpha,w.premultipliedAlpha),s.setFunc(w.depthFunc),s.setTest(w.depthTest),s.setMask(w.depthWrite),r.setMask(w.colorWrite);const q=w.stencilWrite;o.setTest(q),q&&(o.setMask(w.stencilWriteMask),o.setFunc(w.stencilFunc,w.stencilRef,w.stencilFuncMask),o.setOp(w.stencilFail,w.stencilZFail,w.stencilZPass)),Tt(w.polygonOffset,w.polygonOffsetFactor,w.polygonOffsetUnits),w.alphaToCoverage===!0?ut(i.SAMPLE_ALPHA_TO_COVERAGE):st(i.SAMPLE_ALPHA_TO_COVERAGE)}function xt(w){E!==w&&(w?i.frontFace(i.CW):i.frontFace(i.CCW),E=w)}function zt(w){w!==bo?(ut(i.CULL_FACE),w!==M&&(w===hs?i.cullFace(i.BACK):w===wo?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):st(i.CULL_FACE),M=w}function Lt(w){w!==P&&(K&&i.lineWidth(w),P=w)}function Tt(w,ot,V){w?(ut(i.POLYGON_OFFSET_FILL),(X!==ot||z!==V)&&(i.polygonOffset(ot,V),X=ot,z=V)):st(i.POLYGON_OFFSET_FILL)}function ie(w){w?ut(i.SCISSOR_TEST):st(i.SCISSOR_TEST)}function T(w){w===void 0&&(w=i.TEXTURE0+W-1),H!==w&&(i.activeTexture(w),H=w)}function g(w,ot,V){V===void 0&&(H===null?V=i.TEXTURE0+W-1:V=H);let q=ct[V];q===void 0&&(q={type:void 0,texture:void 0},ct[V]=q),(q.type!==w||q.texture!==ot)&&(H!==V&&(i.activeTexture(V),H=V),i.bindTexture(w,ot||j[w]),q.type=w,q.texture=ot)}function B(){const w=ct[H];w!==void 0&&w.type!==void 0&&(i.bindTexture(w.type,null),w.type=void 0,w.texture=void 0)}function Y(){try{i.compressedTexImage2D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function $(){try{i.compressedTexImage3D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Z(){try{i.texSubImage2D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function gt(){try{i.texSubImage3D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function it(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function rt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Rt(){try{i.texStorage2D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Q(){try{i.texStorage3D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function mt(){try{i.texImage2D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Ut(){try{i.texImage3D.apply(i,arguments)}catch(w){console.error("THREE.WebGLState:",w)}}function Et(w){Ft.equals(w)===!1&&(i.scissor(w.x,w.y,w.z,w.w),Ft.copy(w))}function at(w){qt.equals(w)===!1&&(i.viewport(w.x,w.y,w.z,w.w),qt.copy(w))}function Ct(w,ot){let V=l.get(ot);V===void 0&&(V=new WeakMap,l.set(ot,V));let q=V.get(w);q===void 0&&(q=i.getUniformBlockIndex(ot,w.name),V.set(w,q))}function Nt(w,ot){const q=l.get(ot).get(w);a.get(ot)!==q&&(i.uniformBlockBinding(ot,q,w.__bindingPointIndex),a.set(ot,q))}function ee(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},H=null,ct={},u={},f=new WeakMap,p=[],m=null,_=!1,x=null,d=null,h=null,y=null,S=null,A=null,F=null,b=new Ht(0,0,0),C=0,O=!1,E=null,M=null,P=null,X=null,z=null,Ft.set(0,0,i.canvas.width,i.canvas.height),qt.set(0,0,i.canvas.width,i.canvas.height),r.reset(),s.reset(),o.reset()}return{buffers:{color:r,depth:s,stencil:o},enable:ut,disable:st,bindFramebuffer:Pt,drawBuffers:wt,useProgram:Bt,setBlending:It,setMaterial:jt,setFlipSided:xt,setCullFace:zt,setLineWidth:Lt,setPolygonOffset:Tt,setScissorTest:ie,activeTexture:T,bindTexture:g,unbindTexture:B,compressedTexImage2D:Y,compressedTexImage3D:$,texImage2D:mt,texImage3D:Ut,updateUBOMapping:Ct,uniformBlockBinding:Nt,texStorage2D:Rt,texStorage3D:Q,texSubImage2D:Z,texSubImage3D:gt,compressedTexSubImage2D:it,compressedTexSubImage3D:rt,scissor:Et,viewport:at,reset:ee}}function Wf(i,t,e,n,r,s,o){const a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Dt,u=new WeakMap;let f;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(T,g){return m?new OffscreenCanvas(T,g):ji("canvas")}function x(T,g,B){let Y=1;const $=ie(T);if(($.width>B||$.height>B)&&(Y=B/Math.max($.width,$.height)),Y<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const Z=Math.floor(Y*$.width),gt=Math.floor(Y*$.height);f===void 0&&(f=_(Z,gt));const it=g?_(Z,gt):f;return it.width=Z,it.height=gt,it.getContext("2d").drawImage(T,0,0,Z,gt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+Z+"x"+gt+")."),it}else return"data"in T&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function d(T){return T.generateMipmaps&&T.minFilter!==we&&T.minFilter!==Le}function h(T){i.generateMipmap(T)}function y(T,g,B,Y,$=!1){if(T!==null){if(i[T]!==void 0)return i[T];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let Z=g;if(g===i.RED&&(B===i.FLOAT&&(Z=i.R32F),B===i.HALF_FLOAT&&(Z=i.R16F),B===i.UNSIGNED_BYTE&&(Z=i.R8)),g===i.RED_INTEGER&&(B===i.UNSIGNED_BYTE&&(Z=i.R8UI),B===i.UNSIGNED_SHORT&&(Z=i.R16UI),B===i.UNSIGNED_INT&&(Z=i.R32UI),B===i.BYTE&&(Z=i.R8I),B===i.SHORT&&(Z=i.R16I),B===i.INT&&(Z=i.R32I)),g===i.RG&&(B===i.FLOAT&&(Z=i.RG32F),B===i.HALF_FLOAT&&(Z=i.RG16F),B===i.UNSIGNED_BYTE&&(Z=i.RG8)),g===i.RG_INTEGER&&(B===i.UNSIGNED_BYTE&&(Z=i.RG8UI),B===i.UNSIGNED_SHORT&&(Z=i.RG16UI),B===i.UNSIGNED_INT&&(Z=i.RG32UI),B===i.BYTE&&(Z=i.RG8I),B===i.SHORT&&(Z=i.RG16I),B===i.INT&&(Z=i.RG32I)),g===i.RGB&&B===i.UNSIGNED_INT_5_9_9_9_REV&&(Z=i.RGB9_E5),g===i.RGBA){const gt=$?Yi:Xt.getTransfer(Y);B===i.FLOAT&&(Z=i.RGBA32F),B===i.HALF_FLOAT&&(Z=i.RGBA16F),B===i.UNSIGNED_BYTE&&(Z=gt===$t?i.SRGB8_ALPHA8:i.RGBA8),B===i.UNSIGNED_SHORT_4_4_4_4&&(Z=i.RGBA4),B===i.UNSIGNED_SHORT_5_5_5_1&&(Z=i.RGB5_A1)}return(Z===i.R16F||Z===i.R32F||Z===i.RG16F||Z===i.RG32F||Z===i.RGBA16F||Z===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function S(T,g){let B;return T?g===null||g===Jn||g===Qn?B=i.DEPTH24_STENCIL8:g===on?B=i.DEPTH32F_STENCIL8:g===qi&&(B=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):g===null||g===Jn||g===Qn?B=i.DEPTH_COMPONENT24:g===on?B=i.DEPTH_COMPONENT32F:g===qi&&(B=i.DEPTH_COMPONENT16),B}function A(T,g){return d(T)===!0||T.isFramebufferTexture&&T.minFilter!==we&&T.minFilter!==Le?Math.log2(Math.max(g.width,g.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?g.mipmaps.length:1}function F(T){const g=T.target;g.removeEventListener("dispose",F),C(g),g.isVideoTexture&&u.delete(g)}function b(T){const g=T.target;g.removeEventListener("dispose",b),E(g)}function C(T){const g=n.get(T);if(g.__webglInit===void 0)return;const B=T.source,Y=p.get(B);if(Y){const $=Y[g.__cacheKey];$.usedTimes--,$.usedTimes===0&&O(T),Object.keys(Y).length===0&&p.delete(B)}n.remove(T)}function O(T){const g=n.get(T);i.deleteTexture(g.__webglTexture);const B=T.source,Y=p.get(B);delete Y[g.__cacheKey],o.memory.textures--}function E(T){const g=n.get(T);if(T.depthTexture&&T.depthTexture.dispose(),T.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(g.__webglFramebuffer[Y]))for(let $=0;$<g.__webglFramebuffer[Y].length;$++)i.deleteFramebuffer(g.__webglFramebuffer[Y][$]);else i.deleteFramebuffer(g.__webglFramebuffer[Y]);g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer[Y])}else{if(Array.isArray(g.__webglFramebuffer))for(let Y=0;Y<g.__webglFramebuffer.length;Y++)i.deleteFramebuffer(g.__webglFramebuffer[Y]);else i.deleteFramebuffer(g.__webglFramebuffer);if(g.__webglDepthbuffer&&i.deleteRenderbuffer(g.__webglDepthbuffer),g.__webglMultisampledFramebuffer&&i.deleteFramebuffer(g.__webglMultisampledFramebuffer),g.__webglColorRenderbuffer)for(let Y=0;Y<g.__webglColorRenderbuffer.length;Y++)g.__webglColorRenderbuffer[Y]&&i.deleteRenderbuffer(g.__webglColorRenderbuffer[Y]);g.__webglDepthRenderbuffer&&i.deleteRenderbuffer(g.__webglDepthRenderbuffer)}const B=T.textures;for(let Y=0,$=B.length;Y<$;Y++){const Z=n.get(B[Y]);Z.__webglTexture&&(i.deleteTexture(Z.__webglTexture),o.memory.textures--),n.remove(B[Y])}n.remove(T)}let M=0;function P(){M=0}function X(){const T=M;return T>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+r.maxTextures),M+=1,T}function z(T){const g=[];return g.push(T.wrapS),g.push(T.wrapT),g.push(T.wrapR||0),g.push(T.magFilter),g.push(T.minFilter),g.push(T.anisotropy),g.push(T.internalFormat),g.push(T.format),g.push(T.type),g.push(T.generateMipmaps),g.push(T.premultiplyAlpha),g.push(T.flipY),g.push(T.unpackAlignment),g.push(T.colorSpace),g.join()}function W(T,g){const B=n.get(T);if(T.isVideoTexture&&Lt(T),T.isRenderTargetTexture===!1&&T.version>0&&B.__version!==T.version){const Y=T.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{qt(B,T,g);return}}e.bindTexture(i.TEXTURE_2D,B.__webglTexture,i.TEXTURE0+g)}function K(T,g){const B=n.get(T);if(T.version>0&&B.__version!==T.version){qt(B,T,g);return}e.bindTexture(i.TEXTURE_2D_ARRAY,B.__webglTexture,i.TEXTURE0+g)}function G(T,g){const B=n.get(T);if(T.version>0&&B.__version!==T.version){qt(B,T,g);return}e.bindTexture(i.TEXTURE_3D,B.__webglTexture,i.TEXTURE0+g)}function J(T,g){const B=n.get(T);if(T.version>0&&B.__version!==T.version){k(B,T,g);return}e.bindTexture(i.TEXTURE_CUBE_MAP,B.__webglTexture,i.TEXTURE0+g)}const H={[Wr]:i.REPEAT,[bn]:i.CLAMP_TO_EDGE,[Xr]:i.MIRRORED_REPEAT},ct={[we]:i.NEAREST,[cl]:i.NEAREST_MIPMAP_NEAREST,[Mi]:i.NEAREST_MIPMAP_LINEAR,[Le]:i.LINEAR,[or]:i.LINEAR_MIPMAP_NEAREST,[wn]:i.LINEAR_MIPMAP_LINEAR},dt={[yl]:i.NEVER,[Cl]:i.ALWAYS,[Tl]:i.LESS,[Ka]:i.LEQUAL,[Al]:i.EQUAL,[Rl]:i.GEQUAL,[bl]:i.GREATER,[wl]:i.NOTEQUAL};function pt(T,g){if(g.type===on&&t.has("OES_texture_float_linear")===!1&&(g.magFilter===Le||g.magFilter===or||g.magFilter===Mi||g.magFilter===wn||g.minFilter===Le||g.minFilter===or||g.minFilter===Mi||g.minFilter===wn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,H[g.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,H[g.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,H[g.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,ct[g.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,ct[g.minFilter]),g.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,dt[g.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(g.magFilter===we||g.minFilter!==Mi&&g.minFilter!==wn||g.type===on&&t.has("OES_texture_float_linear")===!1)return;if(g.anisotropy>1||n.get(g).__currentAnisotropy){const B=t.get("EXT_texture_filter_anisotropic");i.texParameterf(T,B.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(g.anisotropy,r.getMaxAnisotropy())),n.get(g).__currentAnisotropy=g.anisotropy}}}function Ft(T,g){let B=!1;T.__webglInit===void 0&&(T.__webglInit=!0,g.addEventListener("dispose",F));const Y=g.source;let $=p.get(Y);$===void 0&&($={},p.set(Y,$));const Z=z(g);if(Z!==T.__cacheKey){$[Z]===void 0&&($[Z]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,B=!0),$[Z].usedTimes++;const gt=$[T.__cacheKey];gt!==void 0&&($[T.__cacheKey].usedTimes--,gt.usedTimes===0&&O(g)),T.__cacheKey=Z,T.__webglTexture=$[Z].texture}return B}function qt(T,g,B){let Y=i.TEXTURE_2D;(g.isDataArrayTexture||g.isCompressedArrayTexture)&&(Y=i.TEXTURE_2D_ARRAY),g.isData3DTexture&&(Y=i.TEXTURE_3D);const $=Ft(T,g),Z=g.source;e.bindTexture(Y,T.__webglTexture,i.TEXTURE0+B);const gt=n.get(Z);if(Z.version!==gt.__version||$===!0){e.activeTexture(i.TEXTURE0+B);const it=Xt.getPrimaries(Xt.workingColorSpace),rt=g.colorSpace===an?null:Xt.getPrimaries(g.colorSpace),Rt=g.colorSpace===an||it===rt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Rt);let Q=x(g.image,!1,r.maxTextureSize);Q=Tt(g,Q);const mt=s.convert(g.format,g.colorSpace),Ut=s.convert(g.type);let Et=y(g.internalFormat,mt,Ut,g.colorSpace,g.isVideoTexture);pt(Y,g);let at;const Ct=g.mipmaps,Nt=g.isVideoTexture!==!0,ee=gt.__version===void 0||$===!0,w=Z.dataReady,ot=A(g,Q);if(g.isDepthTexture)Et=S(g.format===ti,g.type),ee&&(Nt?e.texStorage2D(i.TEXTURE_2D,1,Et,Q.width,Q.height):e.texImage2D(i.TEXTURE_2D,0,Et,Q.width,Q.height,0,mt,Ut,null));else if(g.isDataTexture)if(Ct.length>0){Nt&&ee&&e.texStorage2D(i.TEXTURE_2D,ot,Et,Ct[0].width,Ct[0].height);for(let V=0,q=Ct.length;V<q;V++)at=Ct[V],Nt?w&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,at.width,at.height,mt,Ut,at.data):e.texImage2D(i.TEXTURE_2D,V,Et,at.width,at.height,0,mt,Ut,at.data);g.generateMipmaps=!1}else Nt?(ee&&e.texStorage2D(i.TEXTURE_2D,ot,Et,Q.width,Q.height),w&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,Q.width,Q.height,mt,Ut,Q.data)):e.texImage2D(i.TEXTURE_2D,0,Et,Q.width,Q.height,0,mt,Ut,Q.data);else if(g.isCompressedTexture)if(g.isCompressedArrayTexture){Nt&&ee&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ot,Et,Ct[0].width,Ct[0].height,Q.depth);for(let V=0,q=Ct.length;V<q;V++)if(at=Ct[V],g.format!==ze)if(mt!==null)if(Nt){if(w)if(g.layerUpdates.size>0){for(const et of g.layerUpdates){const yt=at.width*at.height;e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,et,at.width,at.height,1,mt,at.data.slice(yt*et,yt*(et+1)),0,0)}g.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,at.width,at.height,Q.depth,mt,at.data,0,0)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,V,Et,at.width,at.height,Q.depth,0,at.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Nt?w&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,at.width,at.height,Q.depth,mt,Ut,at.data):e.texImage3D(i.TEXTURE_2D_ARRAY,V,Et,at.width,at.height,Q.depth,0,mt,Ut,at.data)}else{Nt&&ee&&e.texStorage2D(i.TEXTURE_2D,ot,Et,Ct[0].width,Ct[0].height);for(let V=0,q=Ct.length;V<q;V++)at=Ct[V],g.format!==ze?mt!==null?Nt?w&&e.compressedTexSubImage2D(i.TEXTURE_2D,V,0,0,at.width,at.height,mt,at.data):e.compressedTexImage2D(i.TEXTURE_2D,V,Et,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Nt?w&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,at.width,at.height,mt,Ut,at.data):e.texImage2D(i.TEXTURE_2D,V,Et,at.width,at.height,0,mt,Ut,at.data)}else if(g.isDataArrayTexture)if(Nt){if(ee&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ot,Et,Q.width,Q.height,Q.depth),w)if(g.layerUpdates.size>0){let V;switch(Ut){case i.UNSIGNED_BYTE:switch(mt){case i.ALPHA:V=1;break;case i.LUMINANCE:V=1;break;case i.LUMINANCE_ALPHA:V=2;break;case i.RGB:V=3;break;case i.RGBA:V=4;break;default:throw new Error(`Unknown texel size for format ${mt}.`)}break;case i.UNSIGNED_SHORT_4_4_4_4:case i.UNSIGNED_SHORT_5_5_5_1:case i.UNSIGNED_SHORT_5_6_5:V=1;break;default:throw new Error(`Unknown texel size for type ${Ut}.`)}const q=Q.width*Q.height*V;for(const et of g.layerUpdates)e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,et,Q.width,Q.height,1,mt,Ut,Q.data.slice(q*et,q*(et+1)));g.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,mt,Ut,Q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Et,Q.width,Q.height,Q.depth,0,mt,Ut,Q.data);else if(g.isData3DTexture)Nt?(ee&&e.texStorage3D(i.TEXTURE_3D,ot,Et,Q.width,Q.height,Q.depth),w&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,mt,Ut,Q.data)):e.texImage3D(i.TEXTURE_3D,0,Et,Q.width,Q.height,Q.depth,0,mt,Ut,Q.data);else if(g.isFramebufferTexture){if(ee)if(Nt)e.texStorage2D(i.TEXTURE_2D,ot,Et,Q.width,Q.height);else{let V=Q.width,q=Q.height;for(let et=0;et<ot;et++)e.texImage2D(i.TEXTURE_2D,et,Et,V,q,0,mt,Ut,null),V>>=1,q>>=1}}else if(Ct.length>0){if(Nt&&ee){const V=ie(Ct[0]);e.texStorage2D(i.TEXTURE_2D,ot,Et,V.width,V.height)}for(let V=0,q=Ct.length;V<q;V++)at=Ct[V],Nt?w&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,mt,Ut,at):e.texImage2D(i.TEXTURE_2D,V,Et,mt,Ut,at);g.generateMipmaps=!1}else if(Nt){if(ee){const V=ie(Q);e.texStorage2D(i.TEXTURE_2D,ot,Et,V.width,V.height)}w&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,mt,Ut,Q)}else e.texImage2D(i.TEXTURE_2D,0,Et,mt,Ut,Q);d(g)&&h(Y),gt.__version=Z.version,g.onUpdate&&g.onUpdate(g)}T.__version=g.version}function k(T,g,B){if(g.image.length!==6)return;const Y=Ft(T,g),$=g.source;e.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+B);const Z=n.get($);if($.version!==Z.__version||Y===!0){e.activeTexture(i.TEXTURE0+B);const gt=Xt.getPrimaries(Xt.workingColorSpace),it=g.colorSpace===an?null:Xt.getPrimaries(g.colorSpace),rt=g.colorSpace===an||gt===it?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,g.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,g.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,g.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,rt);const Rt=g.isCompressedTexture||g.image[0].isCompressedTexture,Q=g.image[0]&&g.image[0].isDataTexture,mt=[];for(let q=0;q<6;q++)!Rt&&!Q?mt[q]=x(g.image[q],!0,r.maxCubemapSize):mt[q]=Q?g.image[q].image:g.image[q],mt[q]=Tt(g,mt[q]);const Ut=mt[0],Et=s.convert(g.format,g.colorSpace),at=s.convert(g.type),Ct=y(g.internalFormat,Et,at,g.colorSpace),Nt=g.isVideoTexture!==!0,ee=Z.__version===void 0||Y===!0,w=$.dataReady;let ot=A(g,Ut);pt(i.TEXTURE_CUBE_MAP,g);let V;if(Rt){Nt&&ee&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ot,Ct,Ut.width,Ut.height);for(let q=0;q<6;q++){V=mt[q].mipmaps;for(let et=0;et<V.length;et++){const yt=V[et];g.format!==ze?Et!==null?Nt?w&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et,0,0,yt.width,yt.height,Et,yt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et,Ct,yt.width,yt.height,0,yt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Nt?w&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et,0,0,yt.width,yt.height,Et,at,yt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et,Ct,yt.width,yt.height,0,Et,at,yt.data)}}}else{if(V=g.mipmaps,Nt&&ee){V.length>0&&ot++;const q=ie(mt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ot,Ct,q.width,q.height)}for(let q=0;q<6;q++)if(Q){Nt?w&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,mt[q].width,mt[q].height,Et,at,mt[q].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Ct,mt[q].width,mt[q].height,0,Et,at,mt[q].data);for(let et=0;et<V.length;et++){const Gt=V[et].image[q].image;Nt?w&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et+1,0,0,Gt.width,Gt.height,Et,at,Gt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et+1,Ct,Gt.width,Gt.height,0,Et,at,Gt.data)}}else{Nt?w&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,0,0,Et,at,mt[q]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,0,Ct,Et,at,mt[q]);for(let et=0;et<V.length;et++){const yt=V[et];Nt?w&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et+1,0,0,Et,at,yt.image[q]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+q,et+1,Ct,Et,at,yt.image[q])}}}d(g)&&h(i.TEXTURE_CUBE_MAP),Z.__version=$.version,g.onUpdate&&g.onUpdate(g)}T.__version=g.version}function j(T,g,B,Y,$,Z){const gt=s.convert(B.format,B.colorSpace),it=s.convert(B.type),rt=y(B.internalFormat,gt,it,B.colorSpace);if(!n.get(g).__hasExternalTextures){const Q=Math.max(1,g.width>>Z),mt=Math.max(1,g.height>>Z);$===i.TEXTURE_3D||$===i.TEXTURE_2D_ARRAY?e.texImage3D($,Z,rt,Q,mt,g.depth,0,gt,it,null):e.texImage2D($,Z,rt,Q,mt,0,gt,it,null)}e.bindFramebuffer(i.FRAMEBUFFER,T),zt(g)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Y,$,n.get(B).__webglTexture,0,xt(g)):($===i.TEXTURE_2D||$>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Y,$,n.get(B).__webglTexture,Z),e.bindFramebuffer(i.FRAMEBUFFER,null)}function ut(T,g,B){if(i.bindRenderbuffer(i.RENDERBUFFER,T),g.depthBuffer){const Y=g.depthTexture,$=Y&&Y.isDepthTexture?Y.type:null,Z=S(g.stencilBuffer,$),gt=g.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,it=xt(g);zt(g)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it,Z,g.width,g.height):B?i.renderbufferStorageMultisample(i.RENDERBUFFER,it,Z,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,Z,g.width,g.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,gt,i.RENDERBUFFER,T)}else{const Y=g.textures;for(let $=0;$<Y.length;$++){const Z=Y[$],gt=s.convert(Z.format,Z.colorSpace),it=s.convert(Z.type),rt=y(Z.internalFormat,gt,it,Z.colorSpace),Rt=xt(g);B&&zt(g)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Rt,rt,g.width,g.height):zt(g)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Rt,rt,g.width,g.height):i.renderbufferStorage(i.RENDERBUFFER,rt,g.width,g.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function st(T,g){if(g&&g.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,T),!(g.depthTexture&&g.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(g.depthTexture).__webglTexture||g.depthTexture.image.width!==g.width||g.depthTexture.image.height!==g.height)&&(g.depthTexture.image.width=g.width,g.depthTexture.image.height=g.height,g.depthTexture.needsUpdate=!0),W(g.depthTexture,0);const Y=n.get(g.depthTexture).__webglTexture,$=xt(g);if(g.depthTexture.format===Kn)zt(g)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0,$):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Y,0);else if(g.depthTexture.format===ti)zt(g)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0,$):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Y,0);else throw new Error("Unknown depthTexture format")}function Pt(T){const g=n.get(T),B=T.isWebGLCubeRenderTarget===!0;if(T.depthTexture&&!g.__autoAllocateDepthBuffer){if(B)throw new Error("target.depthTexture not supported in Cube render targets");st(g.__webglFramebuffer,T)}else if(B){g.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)e.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer[Y]),g.__webglDepthbuffer[Y]=i.createRenderbuffer(),ut(g.__webglDepthbuffer[Y],T,!1)}else e.bindFramebuffer(i.FRAMEBUFFER,g.__webglFramebuffer),g.__webglDepthbuffer=i.createRenderbuffer(),ut(g.__webglDepthbuffer,T,!1);e.bindFramebuffer(i.FRAMEBUFFER,null)}function wt(T,g,B){const Y=n.get(T);g!==void 0&&j(Y.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),B!==void 0&&Pt(T)}function Bt(T){const g=T.texture,B=n.get(T),Y=n.get(g);T.addEventListener("dispose",b);const $=T.textures,Z=T.isWebGLCubeRenderTarget===!0,gt=$.length>1;if(gt||(Y.__webglTexture===void 0&&(Y.__webglTexture=i.createTexture()),Y.__version=g.version,o.memory.textures++),Z){B.__webglFramebuffer=[];for(let it=0;it<6;it++)if(g.mipmaps&&g.mipmaps.length>0){B.__webglFramebuffer[it]=[];for(let rt=0;rt<g.mipmaps.length;rt++)B.__webglFramebuffer[it][rt]=i.createFramebuffer()}else B.__webglFramebuffer[it]=i.createFramebuffer()}else{if(g.mipmaps&&g.mipmaps.length>0){B.__webglFramebuffer=[];for(let it=0;it<g.mipmaps.length;it++)B.__webglFramebuffer[it]=i.createFramebuffer()}else B.__webglFramebuffer=i.createFramebuffer();if(gt)for(let it=0,rt=$.length;it<rt;it++){const Rt=n.get($[it]);Rt.__webglTexture===void 0&&(Rt.__webglTexture=i.createTexture(),o.memory.textures++)}if(T.samples>0&&zt(T)===!1){B.__webglMultisampledFramebuffer=i.createFramebuffer(),B.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let it=0;it<$.length;it++){const rt=$[it];B.__webglColorRenderbuffer[it]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,B.__webglColorRenderbuffer[it]);const Rt=s.convert(rt.format,rt.colorSpace),Q=s.convert(rt.type),mt=y(rt.internalFormat,Rt,Q,rt.colorSpace,T.isXRRenderTarget===!0),Ut=xt(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ut,mt,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+it,i.RENDERBUFFER,B.__webglColorRenderbuffer[it])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(B.__webglDepthRenderbuffer=i.createRenderbuffer(),ut(B.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Z){e.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),pt(i.TEXTURE_CUBE_MAP,g);for(let it=0;it<6;it++)if(g.mipmaps&&g.mipmaps.length>0)for(let rt=0;rt<g.mipmaps.length;rt++)j(B.__webglFramebuffer[it][rt],T,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+it,rt);else j(B.__webglFramebuffer[it],T,g,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+it,0);d(g)&&h(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(gt){for(let it=0,rt=$.length;it<rt;it++){const Rt=$[it],Q=n.get(Rt);e.bindTexture(i.TEXTURE_2D,Q.__webglTexture),pt(i.TEXTURE_2D,Rt),j(B.__webglFramebuffer,T,Rt,i.COLOR_ATTACHMENT0+it,i.TEXTURE_2D,0),d(Rt)&&h(i.TEXTURE_2D)}e.unbindTexture()}else{let it=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(it=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(it,Y.__webglTexture),pt(it,g),g.mipmaps&&g.mipmaps.length>0)for(let rt=0;rt<g.mipmaps.length;rt++)j(B.__webglFramebuffer[rt],T,g,i.COLOR_ATTACHMENT0,it,rt);else j(B.__webglFramebuffer,T,g,i.COLOR_ATTACHMENT0,it,0);d(g)&&h(it),e.unbindTexture()}T.depthBuffer&&Pt(T)}function R(T){const g=T.textures;for(let B=0,Y=g.length;B<Y;B++){const $=g[B];if(d($)){const Z=T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,gt=n.get($).__webglTexture;e.bindTexture(Z,gt),h(Z),e.unbindTexture()}}}const Ot=[],It=[];function jt(T){if(T.samples>0){if(zt(T)===!1){const g=T.textures,B=T.width,Y=T.height;let $=i.COLOR_BUFFER_BIT;const Z=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,gt=n.get(T),it=g.length>1;if(it)for(let rt=0;rt<g.length;rt++)e.bindFramebuffer(i.FRAMEBUFFER,gt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+rt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,gt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+rt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,gt.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,gt.__webglFramebuffer);for(let rt=0;rt<g.length;rt++){if(T.resolveDepthBuffer&&(T.depthBuffer&&($|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&($|=i.STENCIL_BUFFER_BIT)),it){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,gt.__webglColorRenderbuffer[rt]);const Rt=n.get(g[rt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Rt,0)}i.blitFramebuffer(0,0,B,Y,0,0,B,Y,$,i.NEAREST),l===!0&&(Ot.length=0,It.length=0,Ot.push(i.COLOR_ATTACHMENT0+rt),T.depthBuffer&&T.resolveDepthBuffer===!1&&(Ot.push(Z),It.push(Z),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,It)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Ot))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),it)for(let rt=0;rt<g.length;rt++){e.bindFramebuffer(i.FRAMEBUFFER,gt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+rt,i.RENDERBUFFER,gt.__webglColorRenderbuffer[rt]);const Rt=n.get(g[rt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,gt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+rt,i.TEXTURE_2D,Rt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,gt.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&l){const g=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[g])}}}function xt(T){return Math.min(r.maxSamples,T.samples)}function zt(T){const g=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&g.__useRenderToTexture!==!1}function Lt(T){const g=o.render.frame;u.get(T)!==g&&(u.set(T,g),T.update())}function Tt(T,g){const B=T.colorSpace,Y=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||B!==fn&&B!==an&&(Xt.getTransfer(B)===$t?(Y!==ze||$!==un)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",B)),g}function ie(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(c.width=T.naturalWidth||T.width,c.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(c.width=T.displayWidth,c.height=T.displayHeight):(c.width=T.width,c.height=T.height),c}this.allocateTextureUnit=X,this.resetTextureUnits=P,this.setTexture2D=W,this.setTexture2DArray=K,this.setTexture3D=G,this.setTextureCube=J,this.rebindTextures=wt,this.setupRenderTarget=Bt,this.updateRenderTargetMipmap=R,this.updateMultisampleRenderTarget=jt,this.setupDepthRenderbuffer=Pt,this.setupFrameBufferTexture=j,this.useMultisampledRTT=zt}function Xf(i,t){function e(n,r=an){let s;const o=Xt.getTransfer(r);if(n===un)return i.UNSIGNED_BYTE;if(n===Va)return i.UNSIGNED_SHORT_4_4_4_4;if(n===ka)return i.UNSIGNED_SHORT_5_5_5_1;if(n===dl)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===hl)return i.BYTE;if(n===ul)return i.SHORT;if(n===qi)return i.UNSIGNED_SHORT;if(n===Ga)return i.INT;if(n===Jn)return i.UNSIGNED_INT;if(n===on)return i.FLOAT;if(n===Qi)return i.HALF_FLOAT;if(n===fl)return i.ALPHA;if(n===pl)return i.RGB;if(n===ze)return i.RGBA;if(n===ml)return i.LUMINANCE;if(n===_l)return i.LUMINANCE_ALPHA;if(n===Kn)return i.DEPTH_COMPONENT;if(n===ti)return i.DEPTH_STENCIL;if(n===gl)return i.RED;if(n===Wa)return i.RED_INTEGER;if(n===vl)return i.RG;if(n===Xa)return i.RG_INTEGER;if(n===qa)return i.RGBA_INTEGER;if(n===lr||n===cr||n===hr||n===ur)if(o===$t)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===lr)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===cr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===hr)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ur)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===lr)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===cr)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===hr)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ur)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ps||n===ms||n===_s||n===gs)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===ps)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ms)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===_s)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===gs)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===vs||n===xs||n===Ms)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===vs||n===xs)return o===$t?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===Ms)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Ss||n===Es||n===ys||n===Ts||n===As||n===bs||n===ws||n===Rs||n===Cs||n===Ps||n===Ls||n===Us||n===Ds||n===Is)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===Ss)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Es)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ys)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ts)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===As)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===bs)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ws)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Rs)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Cs)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ps)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ls)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Us)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ds)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Is)return o===$t?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===dr||n===Ns||n===Fs)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===dr)return o===$t?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ns)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Fs)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===xl||n===Os||n===Bs||n===zs)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===dr)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Os)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Bs)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===zs)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Qn?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}class qf extends be{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Vi extends pe{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yf={type:"move"};class Or{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Vi,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 Vi,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Vi,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let r=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){o=!0;for(const x of t.hand.values()){const d=e.getJointPose(x,n),h=this._getHandJoint(c,x);d!==null&&(h.matrix.fromArray(d.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=d.radius),h.visible=d!==null}const u=c.joints["index-finger-tip"],f=c.joints["thumb-tip"],p=u.position.distanceTo(f.position),m=.02,_=.005;c.inputState.pinching&&p>m+_?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&p<=m-_&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=e.getPose(t.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Yf)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Vi;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const Kf=`
3779
+ void main() {
3780
+
3781
+ gl_Position = vec4( position, 1.0 );
3782
+
3783
+ }`,$f=`
3784
+ uniform sampler2DArray depthColor;
3785
+ uniform float depthWidth;
3786
+ uniform float depthHeight;
3787
+
3788
+ void main() {
3789
+
3790
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3791
+
3792
+ if ( coord.x >= 1.0 ) {
3793
+
3794
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3795
+
3796
+ } else {
3797
+
3798
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3799
+
3800
+ }
3801
+
3802
+ }`;class Zf{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const r=new ve,s=t.properties.get(r);s.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new dn({vertexShader:Kf,fragmentShader:$f,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Ze(new er(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}}class jf extends ni{constructor(t,e){super();const n=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,f=null,p=null,m=null,_=null;const x=new Zf,d=e.getContextAttributes();let h=null,y=null;const S=[],A=[],F=new Dt;let b=null;const C=new be;C.layers.enable(1),C.viewport=new Zt;const O=new be;O.layers.enable(2),O.viewport=new Zt;const E=[C,O],M=new qf;M.layers.enable(1),M.layers.enable(2);let P=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(k){let j=S[k];return j===void 0&&(j=new Or,S[k]=j),j.getTargetRaySpace()},this.getControllerGrip=function(k){let j=S[k];return j===void 0&&(j=new Or,S[k]=j),j.getGripSpace()},this.getHand=function(k){let j=S[k];return j===void 0&&(j=new Or,S[k]=j),j.getHandSpace()};function z(k){const j=A.indexOf(k.inputSource);if(j===-1)return;const ut=S[j];ut!==void 0&&(ut.update(k.inputSource,k.frame,c||o),ut.dispatchEvent({type:k.type,data:k.inputSource}))}function W(){r.removeEventListener("select",z),r.removeEventListener("selectstart",z),r.removeEventListener("selectend",z),r.removeEventListener("squeeze",z),r.removeEventListener("squeezestart",z),r.removeEventListener("squeezeend",z),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",K);for(let k=0;k<S.length;k++){const j=A[k];j!==null&&(A[k]=null,S[k].disconnect(j))}P=null,X=null,x.reset(),t.setRenderTarget(h),m=null,p=null,f=null,r=null,y=null,qt.stop(),n.isPresenting=!1,t.setPixelRatio(b),t.setSize(F.width,F.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(k){s=k,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(k){a=k,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||o},this.setReferenceSpace=function(k){c=k},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f},this.getFrame=function(){return _},this.getSession=function(){return r},this.setSession=async function(k){if(r=k,r!==null){if(h=t.getRenderTarget(),r.addEventListener("select",z),r.addEventListener("selectstart",z),r.addEventListener("selectend",z),r.addEventListener("squeeze",z),r.addEventListener("squeezestart",z),r.addEventListener("squeezeend",z),r.addEventListener("end",W),r.addEventListener("inputsourceschange",K),d.xrCompatible!==!0&&await e.makeXRCompatible(),b=t.getPixelRatio(),t.getSize(F),r.renderState.layers===void 0){const j={antialias:d.antialias,alpha:!0,depth:d.depth,stencil:d.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,e,j),r.updateRenderState({baseLayer:m}),t.setPixelRatio(1),t.setSize(m.framebufferWidth,m.framebufferHeight,!1),y=new Rn(m.framebufferWidth,m.framebufferHeight,{format:ze,type:un,colorSpace:t.outputColorSpace,stencilBuffer:d.stencil})}else{let j=null,ut=null,st=null;d.depth&&(st=d.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,j=d.stencil?ti:Kn,ut=d.stencil?Qn:Jn);const Pt={colorFormat:e.RGBA8,depthFormat:st,scaleFactor:s};f=new XRWebGLBinding(r,e),p=f.createProjectionLayer(Pt),r.updateRenderState({layers:[p]}),t.setPixelRatio(1),t.setSize(p.textureWidth,p.textureHeight,!1),y=new Rn(p.textureWidth,p.textureHeight,{format:ze,type:un,depthTexture:new lo(p.textureWidth,p.textureHeight,ut,void 0,void 0,void 0,void 0,void 0,void 0,j),stencilBuffer:d.stencil,colorSpace:t.outputColorSpace,samples:d.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,o=await r.requestReferenceSpace(a),qt.setContext(r),qt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function K(k){for(let j=0;j<k.removed.length;j++){const ut=k.removed[j],st=A.indexOf(ut);st>=0&&(A[st]=null,S[st].disconnect(ut))}for(let j=0;j<k.added.length;j++){const ut=k.added[j];let st=A.indexOf(ut);if(st===-1){for(let wt=0;wt<S.length;wt++)if(wt>=A.length){A.push(ut),st=wt;break}else if(A[wt]===null){A[wt]=ut,st=wt;break}if(st===-1)break}const Pt=S[st];Pt&&Pt.connect(ut)}}const G=new U,J=new U;function H(k,j,ut){G.setFromMatrixPosition(j.matrixWorld),J.setFromMatrixPosition(ut.matrixWorld);const st=G.distanceTo(J),Pt=j.projectionMatrix.elements,wt=ut.projectionMatrix.elements,Bt=Pt[14]/(Pt[10]-1),R=Pt[14]/(Pt[10]+1),Ot=(Pt[9]+1)/Pt[5],It=(Pt[9]-1)/Pt[5],jt=(Pt[8]-1)/Pt[0],xt=(wt[8]+1)/wt[0],zt=Bt*jt,Lt=Bt*xt,Tt=st/(-jt+xt),ie=Tt*-jt;j.matrixWorld.decompose(k.position,k.quaternion,k.scale),k.translateX(ie),k.translateZ(Tt),k.matrixWorld.compose(k.position,k.quaternion,k.scale),k.matrixWorldInverse.copy(k.matrixWorld).invert();const T=Bt+Tt,g=R+Tt,B=zt-ie,Y=Lt+(st-ie),$=Ot*R/g*T,Z=It*R/g*T;k.projectionMatrix.makePerspective(B,Y,$,Z,T,g),k.projectionMatrixInverse.copy(k.projectionMatrix).invert()}function ct(k,j){j===null?k.matrixWorld.copy(k.matrix):k.matrixWorld.multiplyMatrices(j.matrixWorld,k.matrix),k.matrixWorldInverse.copy(k.matrixWorld).invert()}this.updateCamera=function(k){if(r===null)return;x.texture!==null&&(k.near=x.depthNear,k.far=x.depthFar),M.near=O.near=C.near=k.near,M.far=O.far=C.far=k.far,(P!==M.near||X!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),P=M.near,X=M.far,C.near=P,C.far=X,O.near=P,O.far=X,C.updateProjectionMatrix(),O.updateProjectionMatrix(),k.updateProjectionMatrix());const j=k.parent,ut=M.cameras;ct(M,j);for(let st=0;st<ut.length;st++)ct(ut[st],j);ut.length===2?H(M,C,O):M.projectionMatrix.copy(C.projectionMatrix),dt(k,M,j)};function dt(k,j,ut){ut===null?k.matrix.copy(j.matrixWorld):(k.matrix.copy(ut.matrixWorld),k.matrix.invert(),k.matrix.multiply(j.matrixWorld)),k.matrix.decompose(k.position,k.quaternion,k.scale),k.updateMatrixWorld(!0),k.projectionMatrix.copy(j.projectionMatrix),k.projectionMatrixInverse.copy(j.projectionMatrixInverse),k.isPerspectiveCamera&&(k.fov=di*2*Math.atan(1/k.projectionMatrix.elements[5]),k.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(p===null&&m===null))return l},this.setFoveation=function(k){l=k,p!==null&&(p.fixedFoveation=k),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=k)},this.hasDepthSensing=function(){return x.texture!==null},this.getDepthSensingMesh=function(){return x.getMesh(M)};let pt=null;function Ft(k,j){if(u=j.getViewerPose(c||o),_=j,u!==null){const ut=u.views;m!==null&&(t.setRenderTargetFramebuffer(y,m.framebuffer),t.setRenderTarget(y));let st=!1;ut.length!==M.cameras.length&&(M.cameras.length=0,st=!0);for(let wt=0;wt<ut.length;wt++){const Bt=ut[wt];let R=null;if(m!==null)R=m.getViewport(Bt);else{const It=f.getViewSubImage(p,Bt);R=It.viewport,wt===0&&(t.setRenderTargetTextures(y,It.colorTexture,p.ignoreDepthValues?void 0:It.depthStencilTexture),t.setRenderTarget(y))}let Ot=E[wt];Ot===void 0&&(Ot=new be,Ot.layers.enable(wt),Ot.viewport=new Zt,E[wt]=Ot),Ot.matrix.fromArray(Bt.transform.matrix),Ot.matrix.decompose(Ot.position,Ot.quaternion,Ot.scale),Ot.projectionMatrix.fromArray(Bt.projectionMatrix),Ot.projectionMatrixInverse.copy(Ot.projectionMatrix).invert(),Ot.viewport.set(R.x,R.y,R.width,R.height),wt===0&&(M.matrix.copy(Ot.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),st===!0&&M.cameras.push(Ot)}const Pt=r.enabledFeatures;if(Pt&&Pt.includes("depth-sensing")){const wt=f.getDepthInformation(ut[0]);wt&&wt.isValid&&wt.texture&&x.init(t,wt,r.renderState)}}for(let ut=0;ut<S.length;ut++){const st=A[ut],Pt=S[ut];st!==null&&Pt!==void 0&&Pt.update(st,j,c||o)}pt&&pt(k,j),j.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:j}),_=null}const qt=new ao;qt.setAnimationLoop(Ft),this.setAnimationLoop=function(k){pt=k},this.dispose=function(){}}}const Sn=new He,Jf=new Jt;function Qf(i,t){function e(d,h){d.matrixAutoUpdate===!0&&d.updateMatrix(),h.value.copy(d.matrix)}function n(d,h){h.color.getRGB(d.fogColor.value,io(i)),h.isFog?(d.fogNear.value=h.near,d.fogFar.value=h.far):h.isFogExp2&&(d.fogDensity.value=h.density)}function r(d,h,y,S,A){h.isMeshBasicMaterial||h.isMeshLambertMaterial?s(d,h):h.isMeshToonMaterial?(s(d,h),f(d,h)):h.isMeshPhongMaterial?(s(d,h),u(d,h)):h.isMeshStandardMaterial?(s(d,h),p(d,h),h.isMeshPhysicalMaterial&&m(d,h,A)):h.isMeshMatcapMaterial?(s(d,h),_(d,h)):h.isMeshDepthMaterial?s(d,h):h.isMeshDistanceMaterial?(s(d,h),x(d,h)):h.isMeshNormalMaterial?s(d,h):h.isLineBasicMaterial?(o(d,h),h.isLineDashedMaterial&&a(d,h)):h.isPointsMaterial?l(d,h,y,S):h.isSpriteMaterial?c(d,h):h.isShadowMaterial?(d.color.value.copy(h.color),d.opacity.value=h.opacity):h.isShaderMaterial&&(h.uniformsNeedUpdate=!1)}function s(d,h){d.opacity.value=h.opacity,h.color&&d.diffuse.value.copy(h.color),h.emissive&&d.emissive.value.copy(h.emissive).multiplyScalar(h.emissiveIntensity),h.map&&(d.map.value=h.map,e(h.map,d.mapTransform)),h.alphaMap&&(d.alphaMap.value=h.alphaMap,e(h.alphaMap,d.alphaMapTransform)),h.bumpMap&&(d.bumpMap.value=h.bumpMap,e(h.bumpMap,d.bumpMapTransform),d.bumpScale.value=h.bumpScale,h.side===xe&&(d.bumpScale.value*=-1)),h.normalMap&&(d.normalMap.value=h.normalMap,e(h.normalMap,d.normalMapTransform),d.normalScale.value.copy(h.normalScale),h.side===xe&&d.normalScale.value.negate()),h.displacementMap&&(d.displacementMap.value=h.displacementMap,e(h.displacementMap,d.displacementMapTransform),d.displacementScale.value=h.displacementScale,d.displacementBias.value=h.displacementBias),h.emissiveMap&&(d.emissiveMap.value=h.emissiveMap,e(h.emissiveMap,d.emissiveMapTransform)),h.specularMap&&(d.specularMap.value=h.specularMap,e(h.specularMap,d.specularMapTransform)),h.alphaTest>0&&(d.alphaTest.value=h.alphaTest);const y=t.get(h),S=y.envMap,A=y.envMapRotation;S&&(d.envMap.value=S,Sn.copy(A),Sn.x*=-1,Sn.y*=-1,Sn.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(Sn.y*=-1,Sn.z*=-1),d.envMapRotation.value.setFromMatrix4(Jf.makeRotationFromEuler(Sn)),d.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,d.reflectivity.value=h.reflectivity,d.ior.value=h.ior,d.refractionRatio.value=h.refractionRatio),h.lightMap&&(d.lightMap.value=h.lightMap,d.lightMapIntensity.value=h.lightMapIntensity,e(h.lightMap,d.lightMapTransform)),h.aoMap&&(d.aoMap.value=h.aoMap,d.aoMapIntensity.value=h.aoMapIntensity,e(h.aoMap,d.aoMapTransform))}function o(d,h){d.diffuse.value.copy(h.color),d.opacity.value=h.opacity,h.map&&(d.map.value=h.map,e(h.map,d.mapTransform))}function a(d,h){d.dashSize.value=h.dashSize,d.totalSize.value=h.dashSize+h.gapSize,d.scale.value=h.scale}function l(d,h,y,S){d.diffuse.value.copy(h.color),d.opacity.value=h.opacity,d.size.value=h.size*y,d.scale.value=S*.5,h.map&&(d.map.value=h.map,e(h.map,d.uvTransform)),h.alphaMap&&(d.alphaMap.value=h.alphaMap,e(h.alphaMap,d.alphaMapTransform)),h.alphaTest>0&&(d.alphaTest.value=h.alphaTest)}function c(d,h){d.diffuse.value.copy(h.color),d.opacity.value=h.opacity,d.rotation.value=h.rotation,h.map&&(d.map.value=h.map,e(h.map,d.mapTransform)),h.alphaMap&&(d.alphaMap.value=h.alphaMap,e(h.alphaMap,d.alphaMapTransform)),h.alphaTest>0&&(d.alphaTest.value=h.alphaTest)}function u(d,h){d.specular.value.copy(h.specular),d.shininess.value=Math.max(h.shininess,1e-4)}function f(d,h){h.gradientMap&&(d.gradientMap.value=h.gradientMap)}function p(d,h){d.metalness.value=h.metalness,h.metalnessMap&&(d.metalnessMap.value=h.metalnessMap,e(h.metalnessMap,d.metalnessMapTransform)),d.roughness.value=h.roughness,h.roughnessMap&&(d.roughnessMap.value=h.roughnessMap,e(h.roughnessMap,d.roughnessMapTransform)),h.envMap&&(d.envMapIntensity.value=h.envMapIntensity)}function m(d,h,y){d.ior.value=h.ior,h.sheen>0&&(d.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),d.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(d.sheenColorMap.value=h.sheenColorMap,e(h.sheenColorMap,d.sheenColorMapTransform)),h.sheenRoughnessMap&&(d.sheenRoughnessMap.value=h.sheenRoughnessMap,e(h.sheenRoughnessMap,d.sheenRoughnessMapTransform))),h.clearcoat>0&&(d.clearcoat.value=h.clearcoat,d.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(d.clearcoatMap.value=h.clearcoatMap,e(h.clearcoatMap,d.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(d.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,e(h.clearcoatRoughnessMap,d.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(d.clearcoatNormalMap.value=h.clearcoatNormalMap,e(h.clearcoatNormalMap,d.clearcoatNormalMapTransform),d.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===xe&&d.clearcoatNormalScale.value.negate())),h.dispersion>0&&(d.dispersion.value=h.dispersion),h.iridescence>0&&(d.iridescence.value=h.iridescence,d.iridescenceIOR.value=h.iridescenceIOR,d.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],d.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(d.iridescenceMap.value=h.iridescenceMap,e(h.iridescenceMap,d.iridescenceMapTransform)),h.iridescenceThicknessMap&&(d.iridescenceThicknessMap.value=h.iridescenceThicknessMap,e(h.iridescenceThicknessMap,d.iridescenceThicknessMapTransform))),h.transmission>0&&(d.transmission.value=h.transmission,d.transmissionSamplerMap.value=y.texture,d.transmissionSamplerSize.value.set(y.width,y.height),h.transmissionMap&&(d.transmissionMap.value=h.transmissionMap,e(h.transmissionMap,d.transmissionMapTransform)),d.thickness.value=h.thickness,h.thicknessMap&&(d.thicknessMap.value=h.thicknessMap,e(h.thicknessMap,d.thicknessMapTransform)),d.attenuationDistance.value=h.attenuationDistance,d.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(d.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(d.anisotropyMap.value=h.anisotropyMap,e(h.anisotropyMap,d.anisotropyMapTransform))),d.specularIntensity.value=h.specularIntensity,d.specularColor.value.copy(h.specularColor),h.specularColorMap&&(d.specularColorMap.value=h.specularColorMap,e(h.specularColorMap,d.specularColorMapTransform)),h.specularIntensityMap&&(d.specularIntensityMap.value=h.specularIntensityMap,e(h.specularIntensityMap,d.specularIntensityMapTransform))}function _(d,h){h.matcap&&(d.matcap.value=h.matcap)}function x(d,h){const y=t.get(h).light;d.referencePosition.value.setFromMatrixPosition(y.matrixWorld),d.nearDistance.value=y.shadow.camera.near,d.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function tp(i,t,e,n){let r={},s={},o=[];const a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,S){const A=S.program;n.uniformBlockBinding(y,A)}function c(y,S){let A=r[y.id];A===void 0&&(_(y),A=u(y),r[y.id]=A,y.addEventListener("dispose",d));const F=S.program;n.updateUBOMapping(y,F);const b=t.render.frame;s[y.id]!==b&&(p(y),s[y.id]=b)}function u(y){const S=f();y.__bindingPointIndex=S;const A=i.createBuffer(),F=y.__size,b=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,A),i.bufferData(i.UNIFORM_BUFFER,F,b),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,A),A}function f(){for(let y=0;y<a;y++)if(o.indexOf(y)===-1)return o.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(y){const S=r[y.id],A=y.uniforms,F=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let b=0,C=A.length;b<C;b++){const O=Array.isArray(A[b])?A[b]:[A[b]];for(let E=0,M=O.length;E<M;E++){const P=O[E];if(m(P,b,E,F)===!0){const X=P.__offset,z=Array.isArray(P.value)?P.value:[P.value];let W=0;for(let K=0;K<z.length;K++){const G=z[K],J=x(G);typeof G=="number"||typeof G=="boolean"?(P.__data[0]=G,i.bufferSubData(i.UNIFORM_BUFFER,X+W,P.__data)):G.isMatrix3?(P.__data[0]=G.elements[0],P.__data[1]=G.elements[1],P.__data[2]=G.elements[2],P.__data[3]=0,P.__data[4]=G.elements[3],P.__data[5]=G.elements[4],P.__data[6]=G.elements[5],P.__data[7]=0,P.__data[8]=G.elements[6],P.__data[9]=G.elements[7],P.__data[10]=G.elements[8],P.__data[11]=0):(G.toArray(P.__data,W),W+=J.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,X,P.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(y,S,A,F){const b=y.value,C=S+"_"+A;if(F[C]===void 0)return typeof b=="number"||typeof b=="boolean"?F[C]=b:F[C]=b.clone(),!0;{const O=F[C];if(typeof b=="number"||typeof b=="boolean"){if(O!==b)return F[C]=b,!0}else if(O.equals(b)===!1)return O.copy(b),!0}return!1}function _(y){const S=y.uniforms;let A=0;const F=16;for(let C=0,O=S.length;C<O;C++){const E=Array.isArray(S[C])?S[C]:[S[C]];for(let M=0,P=E.length;M<P;M++){const X=E[M],z=Array.isArray(X.value)?X.value:[X.value];for(let W=0,K=z.length;W<K;W++){const G=z[W],J=x(G),H=A%F;H!==0&&F-H<J.boundary&&(A+=F-H),X.__data=new Float32Array(J.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=A,A+=J.storage}}}const b=A%F;return b>0&&(A+=F-b),y.__size=A,y.__cache={},this}function x(y){const S={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(S.boundary=4,S.storage=4):y.isVector2?(S.boundary=8,S.storage=8):y.isVector3||y.isColor?(S.boundary=16,S.storage=12):y.isVector4?(S.boundary=16,S.storage=16):y.isMatrix3?(S.boundary=48,S.storage=48):y.isMatrix4?(S.boundary=64,S.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),S}function d(y){const S=y.target;S.removeEventListener("dispose",d);const A=o.indexOf(S.__bindingPointIndex);o.splice(A,1),i.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function h(){for(const y in r)i.deleteBuffer(r[y]);o=[],r={},s={}}return{bind:l,update:c,dispose:h}}class op{constructor(t={}){const{canvas:e=ql(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:f=!1}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;const m=new Uint32Array(4),_=new Int32Array(4);let x=null,d=null;const h=[],y=[];this.domElement=e,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=Fe,this.toneMapping=cn,this.toneMappingExposure=1;const S=this;let A=!1,F=0,b=0,C=null,O=-1,E=null;const M=new Zt,P=new Zt;let X=null;const z=new Ht(0);let W=0,K=e.width,G=e.height,J=1,H=null,ct=null;const dt=new Zt(0,0,K,G),pt=new Zt(0,0,K,G);let Ft=!1;const qt=new es;let k=!1,j=!1;const ut=new Jt,st=new U,Pt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let wt=!1;function Bt(){return C===null?J:1}let R=n;function Ot(v,L){return e.getContext(v,L)}try{const v={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:f};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${$r}`),e.addEventListener("webglcontextlost",ot,!1),e.addEventListener("webglcontextrestored",V,!1),e.addEventListener("webglcontextcreationerror",q,!1),R===null){const L="webgl2";if(R=Ot(L,v),R===null)throw Ot(L)?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 It,jt,xt,zt,Lt,Tt,ie,T,g,B,Y,$,Z,gt,it,rt,Rt,Q,mt,Ut,Et,at,Ct,Nt;function ee(){It=new ld(R),It.init(),at=new Xf(R,It),jt=new nd(R,It,t,at),xt=new kf(R),zt=new ud(R),Lt=new Cf,Tt=new Wf(R,It,xt,Lt,jt,at,zt),ie=new rd(S),T=new od(S),g=new vc(R),Ct=new td(R,g),B=new cd(R,g,zt,Ct),Y=new fd(R,B,g,zt),mt=new dd(R,jt,Tt),rt=new id(Lt),$=new Rf(S,ie,T,It,jt,Ct,rt),Z=new Qf(S,Lt),gt=new Lf,it=new Of(It),Q=new Qu(S,ie,T,xt,Y,p,l),Rt=new Vf(S,Y,jt),Nt=new tp(R,zt,jt,xt),Ut=new ed(R,It,zt),Et=new hd(R,It,zt),zt.programs=$.programs,S.capabilities=jt,S.extensions=It,S.properties=Lt,S.renderLists=gt,S.shadowMap=Rt,S.state=xt,S.info=zt}ee();const w=new jf(S,R);this.xr=w,this.getContext=function(){return R},this.getContextAttributes=function(){return R.getContextAttributes()},this.forceContextLoss=function(){const v=It.get("WEBGL_lose_context");v&&v.loseContext()},this.forceContextRestore=function(){const v=It.get("WEBGL_lose_context");v&&v.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(v){v!==void 0&&(J=v,this.setSize(K,G,!1))},this.getSize=function(v){return v.set(K,G)},this.setSize=function(v,L,I=!0){if(w.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}K=v,G=L,e.width=Math.floor(v*J),e.height=Math.floor(L*J),I===!0&&(e.style.width=v+"px",e.style.height=L+"px"),this.setViewport(0,0,v,L)},this.getDrawingBufferSize=function(v){return v.set(K*J,G*J).floor()},this.setDrawingBufferSize=function(v,L,I){K=v,G=L,J=I,e.width=Math.floor(v*I),e.height=Math.floor(L*I),this.setViewport(0,0,v,L)},this.getCurrentViewport=function(v){return v.copy(M)},this.getViewport=function(v){return v.copy(dt)},this.setViewport=function(v,L,I,N){v.isVector4?dt.set(v.x,v.y,v.z,v.w):dt.set(v,L,I,N),xt.viewport(M.copy(dt).multiplyScalar(J).round())},this.getScissor=function(v){return v.copy(pt)},this.setScissor=function(v,L,I,N){v.isVector4?pt.set(v.x,v.y,v.z,v.w):pt.set(v,L,I,N),xt.scissor(P.copy(pt).multiplyScalar(J).round())},this.getScissorTest=function(){return Ft},this.setScissorTest=function(v){xt.setScissorTest(Ft=v)},this.setOpaqueSort=function(v){H=v},this.setTransparentSort=function(v){ct=v},this.getClearColor=function(v){return v.copy(Q.getClearColor())},this.setClearColor=function(){Q.setClearColor.apply(Q,arguments)},this.getClearAlpha=function(){return Q.getClearAlpha()},this.setClearAlpha=function(){Q.setClearAlpha.apply(Q,arguments)},this.clear=function(v=!0,L=!0,I=!0){let N=0;if(v){let D=!1;if(C!==null){const tt=C.texture.format;D=tt===qa||tt===Xa||tt===Wa}if(D){const tt=C.texture.type,lt=tt===un||tt===Jn||tt===qi||tt===Qn||tt===Va||tt===ka,ht=Q.getClearColor(),ft=Q.getClearAlpha(),Mt=ht.r,St=ht.g,vt=ht.b;lt?(m[0]=Mt,m[1]=St,m[2]=vt,m[3]=ft,R.clearBufferuiv(R.COLOR,0,m)):(_[0]=Mt,_[1]=St,_[2]=vt,_[3]=ft,R.clearBufferiv(R.COLOR,0,_))}else N|=R.COLOR_BUFFER_BIT}L&&(N|=R.DEPTH_BUFFER_BIT),I&&(N|=R.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),R.clear(N)},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(){e.removeEventListener("webglcontextlost",ot,!1),e.removeEventListener("webglcontextrestored",V,!1),e.removeEventListener("webglcontextcreationerror",q,!1),gt.dispose(),it.dispose(),Lt.dispose(),ie.dispose(),T.dispose(),Y.dispose(),Ct.dispose(),Nt.dispose(),$.dispose(),w.dispose(),w.removeEventListener("sessionstart",Ie),w.removeEventListener("sessionend",Ne),pn.stop()};function ot(v){v.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),A=!0}function V(){console.log("THREE.WebGLRenderer: Context Restored."),A=!1;const v=zt.autoReset,L=Rt.enabled,I=Rt.autoUpdate,N=Rt.needsUpdate,D=Rt.type;ee(),zt.autoReset=v,Rt.enabled=L,Rt.autoUpdate=I,Rt.needsUpdate=N,Rt.type=D}function q(v){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",v.statusMessage)}function et(v){const L=v.target;L.removeEventListener("dispose",et),yt(L)}function yt(v){Gt(v),Lt.remove(v)}function Gt(v){const L=Lt.get(v).programs;L!==void 0&&(L.forEach(function(I){$.releaseProgram(I)}),v.isShaderMaterial&&$.releaseShaderCache(v))}this.renderBufferDirect=function(v,L,I,N,D,tt){L===null&&(L=Pt);const lt=D.isMesh&&D.matrixWorld.determinant()<0,ht=Eo(v,L,I,N,D);xt.setMaterial(N,lt);let ft=I.index,Mt=1;if(N.wireframe===!0){if(ft=B.getWireframeAttribute(I),ft===void 0)return;Mt=2}const St=I.drawRange,vt=I.attributes.position;let Vt=St.start*Mt,Qt=(St.start+St.count)*Mt;tt!==null&&(Vt=Math.max(Vt,tt.start*Mt),Qt=Math.min(Qt,(tt.start+tt.count)*Mt)),ft!==null?(Vt=Math.max(Vt,0),Qt=Math.min(Qt,ft.count)):vt!=null&&(Vt=Math.max(Vt,0),Qt=Math.min(Qt,vt.count));const te=Qt-Vt;if(te<0||te===1/0)return;Ct.setup(D,N,ht,I,ft);let Me,kt=Ut;if(ft!==null&&(Me=g.get(ft),kt=Et,kt.setIndex(Me)),D.isMesh)N.wireframe===!0?(xt.setLineWidth(N.wireframeLinewidth*Bt()),kt.setMode(R.LINES)):kt.setMode(R.TRIANGLES);else if(D.isLine){let _t=N.linewidth;_t===void 0&&(_t=1),xt.setLineWidth(_t*Bt()),D.isLineSegments?kt.setMode(R.LINES):D.isLineLoop?kt.setMode(R.LINE_LOOP):kt.setMode(R.LINE_STRIP)}else D.isPoints?kt.setMode(R.POINTS):D.isSprite&&kt.setMode(R.TRIANGLES);if(D.isBatchedMesh)D._multiDrawInstances!==null?kt.renderMultiDrawInstances(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount,D._multiDrawInstances):kt.renderMultiDraw(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount);else if(D.isInstancedMesh)kt.renderInstances(Vt,te,D.count);else if(I.isInstancedBufferGeometry){const _t=I._maxInstanceCount!==void 0?I._maxInstanceCount:1/0,me=Math.min(I.instanceCount,_t);kt.renderInstances(Vt,te,me)}else kt.render(Vt,te)};function ne(v,L,I){v.transparent===!0&&v.side===Ke&&v.forceSinglePass===!1?(v.side=xe,v.needsUpdate=!0,vi(v,L,I),v.side=hn,v.needsUpdate=!0,vi(v,L,I),v.side=Ke):vi(v,L,I)}this.compile=function(v,L,I=null){I===null&&(I=v),d=it.get(I),d.init(L),y.push(d),I.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(d.pushLight(D),D.castShadow&&d.pushShadow(D))}),v!==I&&v.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(d.pushLight(D),D.castShadow&&d.pushShadow(D))}),d.setupLights();const N=new Set;return v.traverse(function(D){const tt=D.material;if(tt)if(Array.isArray(tt))for(let lt=0;lt<tt.length;lt++){const ht=tt[lt];ne(ht,I,D),N.add(ht)}else ne(tt,I,D),N.add(tt)}),y.pop(),d=null,N},this.compileAsync=function(v,L,I=null){const N=this.compile(v,L,I);return new Promise(D=>{function tt(){if(N.forEach(function(lt){Lt.get(lt).currentProgram.isReady()&&N.delete(lt)}),N.size===0){D(v);return}setTimeout(tt,10)}It.get("KHR_parallel_shader_compile")!==null?tt():setTimeout(tt,10)})};let le=null;function Yt(v){le&&le(v)}function Ie(){pn.stop()}function Ne(){pn.start()}const pn=new ao;pn.setAnimationLoop(Yt),typeof self<"u"&&pn.setContext(self),this.setAnimationLoop=function(v){le=v,w.setAnimationLoop(v),v===null?pn.stop():pn.start()},w.addEventListener("sessionstart",Ie),w.addEventListener("sessionend",Ne),this.render=function(v,L){if(L!==void 0&&L.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(A===!0)return;if(v.matrixWorldAutoUpdate===!0&&v.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),w.enabled===!0&&w.isPresenting===!0&&(w.cameraAutoUpdate===!0&&w.updateCamera(L),L=w.getCamera()),v.isScene===!0&&v.onBeforeRender(S,v,L,C),d=it.get(v,y.length),d.init(L),y.push(d),ut.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),qt.setFromProjectionMatrix(ut),j=this.localClippingEnabled,k=rt.init(this.clippingPlanes,j),x=gt.get(v,h.length),x.init(),h.push(x),w.enabled===!0&&w.isPresenting===!0){const tt=S.xr.getDepthSensingMesh();tt!==null&&ir(tt,L,-1/0,S.sortObjects)}ir(v,L,0,S.sortObjects),x.finish(),S.sortObjects===!0&&x.sort(H,ct),wt=w.enabled===!1||w.isPresenting===!1||w.hasDepthSensing()===!1,wt&&Q.addToRenderList(x,v),this.info.render.frame++,k===!0&&rt.beginShadows();const I=d.state.shadowsArray;Rt.render(I,v,L),k===!0&&rt.endShadows(),this.info.autoReset===!0&&this.info.reset();const N=x.opaque,D=x.transmissive;if(d.setupLights(),L.isArrayCamera){const tt=L.cameras;if(D.length>0)for(let lt=0,ht=tt.length;lt<ht;lt++){const ft=tt[lt];ss(N,D,v,ft)}wt&&Q.render(v);for(let lt=0,ht=tt.length;lt<ht;lt++){const ft=tt[lt];rs(x,v,ft,ft.viewport)}}else D.length>0&&ss(N,D,v,L),wt&&Q.render(v),rs(x,v,L);C!==null&&(Tt.updateMultisampleRenderTarget(C),Tt.updateRenderTargetMipmap(C)),v.isScene===!0&&v.onAfterRender(S,v,L),Ct.resetDefaultState(),O=-1,E=null,y.pop(),y.length>0?(d=y[y.length-1],k===!0&&rt.setGlobalState(S.clippingPlanes,d.state.camera)):d=null,h.pop(),h.length>0?x=h[h.length-1]:x=null};function ir(v,L,I,N){if(v.visible===!1)return;if(v.layers.test(L.layers)){if(v.isGroup)I=v.renderOrder;else if(v.isLOD)v.autoUpdate===!0&&v.update(L);else if(v.isLight)d.pushLight(v),v.castShadow&&d.pushShadow(v);else if(v.isSprite){if(!v.frustumCulled||qt.intersectsSprite(v)){N&&st.setFromMatrixPosition(v.matrixWorld).applyMatrix4(ut);const lt=Y.update(v),ht=v.material;ht.visible&&x.push(v,lt,ht,I,st.z,null)}}else if((v.isMesh||v.isLine||v.isPoints)&&(!v.frustumCulled||qt.intersectsObject(v))){const lt=Y.update(v),ht=v.material;if(N&&(v.boundingSphere!==void 0?(v.boundingSphere===null&&v.computeBoundingSphere(),st.copy(v.boundingSphere.center)):(lt.boundingSphere===null&&lt.computeBoundingSphere(),st.copy(lt.boundingSphere.center)),st.applyMatrix4(v.matrixWorld).applyMatrix4(ut)),Array.isArray(ht)){const ft=lt.groups;for(let Mt=0,St=ft.length;Mt<St;Mt++){const vt=ft[Mt],Vt=ht[vt.materialIndex];Vt&&Vt.visible&&x.push(v,lt,Vt,I,st.z,vt)}}else ht.visible&&x.push(v,lt,ht,I,st.z,null)}}const tt=v.children;for(let lt=0,ht=tt.length;lt<ht;lt++)ir(tt[lt],L,I,N)}function rs(v,L,I,N){const D=v.opaque,tt=v.transmissive,lt=v.transparent;d.setupLightsView(I),k===!0&&rt.setGlobalState(S.clippingPlanes,I),N&&xt.viewport(M.copy(N)),D.length>0&&gi(D,L,I),tt.length>0&&gi(tt,L,I),lt.length>0&&gi(lt,L,I),xt.buffers.depth.setTest(!0),xt.buffers.depth.setMask(!0),xt.buffers.color.setMask(!0),xt.setPolygonOffset(!1)}function ss(v,L,I,N){if((I.isScene===!0?I.overrideMaterial:null)!==null)return;d.state.transmissionRenderTarget[N.id]===void 0&&(d.state.transmissionRenderTarget[N.id]=new Rn(1,1,{generateMipmaps:!0,type:It.has("EXT_color_buffer_half_float")||It.has("EXT_color_buffer_float")?Qi:un,minFilter:wn,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xt.workingColorSpace}));const tt=d.state.transmissionRenderTarget[N.id],lt=N.viewport||M;tt.setSize(lt.z,lt.w);const ht=S.getRenderTarget();S.setRenderTarget(tt),S.getClearColor(z),W=S.getClearAlpha(),W<1&&S.setClearColor(16777215,.5),wt?Q.render(I):S.clear();const ft=S.toneMapping;S.toneMapping=cn;const Mt=N.viewport;if(N.viewport!==void 0&&(N.viewport=void 0),d.setupLightsView(N),k===!0&&rt.setGlobalState(S.clippingPlanes,N),gi(v,I,N),Tt.updateMultisampleRenderTarget(tt),Tt.updateRenderTargetMipmap(tt),It.has("WEBGL_multisampled_render_to_texture")===!1){let St=!1;for(let vt=0,Vt=L.length;vt<Vt;vt++){const Qt=L[vt],te=Qt.object,Me=Qt.geometry,kt=Qt.material,_t=Qt.group;if(kt.side===Ke&&te.layers.test(N.layers)){const me=kt.side;kt.side=xe,kt.needsUpdate=!0,as(te,I,N,Me,kt,_t),kt.side=me,kt.needsUpdate=!0,St=!0}}St===!0&&(Tt.updateMultisampleRenderTarget(tt),Tt.updateRenderTargetMipmap(tt))}S.setRenderTarget(ht),S.setClearColor(z,W),Mt!==void 0&&(N.viewport=Mt),S.toneMapping=ft}function gi(v,L,I){const N=L.isScene===!0?L.overrideMaterial:null;for(let D=0,tt=v.length;D<tt;D++){const lt=v[D],ht=lt.object,ft=lt.geometry,Mt=N===null?lt.material:N,St=lt.group;ht.layers.test(I.layers)&&as(ht,L,I,ft,Mt,St)}}function as(v,L,I,N,D,tt){v.onBeforeRender(S,L,I,N,D,tt),v.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,v.matrixWorld),v.normalMatrix.getNormalMatrix(v.modelViewMatrix),D.onBeforeRender(S,L,I,N,v,tt),D.transparent===!0&&D.side===Ke&&D.forceSinglePass===!1?(D.side=xe,D.needsUpdate=!0,S.renderBufferDirect(I,L,N,D,v,tt),D.side=hn,D.needsUpdate=!0,S.renderBufferDirect(I,L,N,D,v,tt),D.side=Ke):S.renderBufferDirect(I,L,N,D,v,tt),v.onAfterRender(S,L,I,N,D,tt)}function vi(v,L,I){L.isScene!==!0&&(L=Pt);const N=Lt.get(v),D=d.state.lights,tt=d.state.shadowsArray,lt=D.state.version,ht=$.getParameters(v,D.state,tt,L,I),ft=$.getProgramCacheKey(ht);let Mt=N.programs;N.environment=v.isMeshStandardMaterial?L.environment:null,N.fog=L.fog,N.envMap=(v.isMeshStandardMaterial?T:ie).get(v.envMap||N.environment),N.envMapRotation=N.environment!==null&&v.envMap===null?L.environmentRotation:v.envMapRotation,Mt===void 0&&(v.addEventListener("dispose",et),Mt=new Map,N.programs=Mt);let St=Mt.get(ft);if(St!==void 0){if(N.currentProgram===St&&N.lightsStateVersion===lt)return ls(v,ht),St}else ht.uniforms=$.getUniforms(v),v.onBuild(I,ht,S),v.onBeforeCompile(ht,S),St=$.acquireProgram(ht,ft),Mt.set(ft,St),N.uniforms=ht.uniforms;const vt=N.uniforms;return(!v.isShaderMaterial&&!v.isRawShaderMaterial||v.clipping===!0)&&(vt.clippingPlanes=rt.uniform),ls(v,ht),N.needsLights=To(v),N.lightsStateVersion=lt,N.needsLights&&(vt.ambientLightColor.value=D.state.ambient,vt.lightProbe.value=D.state.probe,vt.directionalLights.value=D.state.directional,vt.directionalLightShadows.value=D.state.directionalShadow,vt.spotLights.value=D.state.spot,vt.spotLightShadows.value=D.state.spotShadow,vt.rectAreaLights.value=D.state.rectArea,vt.ltc_1.value=D.state.rectAreaLTC1,vt.ltc_2.value=D.state.rectAreaLTC2,vt.pointLights.value=D.state.point,vt.pointLightShadows.value=D.state.pointShadow,vt.hemisphereLights.value=D.state.hemi,vt.directionalShadowMap.value=D.state.directionalShadowMap,vt.directionalShadowMatrix.value=D.state.directionalShadowMatrix,vt.spotShadowMap.value=D.state.spotShadowMap,vt.spotLightMatrix.value=D.state.spotLightMatrix,vt.spotLightMap.value=D.state.spotLightMap,vt.pointShadowMap.value=D.state.pointShadowMap,vt.pointShadowMatrix.value=D.state.pointShadowMatrix),N.currentProgram=St,N.uniformsList=null,St}function os(v){if(v.uniformsList===null){const L=v.currentProgram.getUniforms();v.uniformsList=Wi.seqWithValue(L.seq,v.uniforms)}return v.uniformsList}function ls(v,L){const I=Lt.get(v);I.outputColorSpace=L.outputColorSpace,I.batching=L.batching,I.batchingColor=L.batchingColor,I.instancing=L.instancing,I.instancingColor=L.instancingColor,I.instancingMorph=L.instancingMorph,I.skinning=L.skinning,I.morphTargets=L.morphTargets,I.morphNormals=L.morphNormals,I.morphColors=L.morphColors,I.morphTargetsCount=L.morphTargetsCount,I.numClippingPlanes=L.numClippingPlanes,I.numIntersection=L.numClipIntersection,I.vertexAlphas=L.vertexAlphas,I.vertexTangents=L.vertexTangents,I.toneMapping=L.toneMapping}function Eo(v,L,I,N,D){L.isScene!==!0&&(L=Pt),Tt.resetTextureUnits();const tt=L.fog,lt=N.isMeshStandardMaterial?L.environment:null,ht=C===null?S.outputColorSpace:C.isXRRenderTarget===!0?C.texture.colorSpace:fn,ft=(N.isMeshStandardMaterial?T:ie).get(N.envMap||lt),Mt=N.vertexColors===!0&&!!I.attributes.color&&I.attributes.color.itemSize===4,St=!!I.attributes.tangent&&(!!N.normalMap||N.anisotropy>0),vt=!!I.morphAttributes.position,Vt=!!I.morphAttributes.normal,Qt=!!I.morphAttributes.color;let te=cn;N.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(te=S.toneMapping);const Me=I.morphAttributes.position||I.morphAttributes.normal||I.morphAttributes.color,kt=Me!==void 0?Me.length:0,_t=Lt.get(N),me=d.state.lights;if(k===!0&&(j===!0||v!==E)){const Te=v===E&&N.id===O;rt.setState(N,v,Te)}let Kt=!1;N.version===_t.__version?(_t.needsLights&&_t.lightsStateVersion!==me.state.version||_t.outputColorSpace!==ht||D.isBatchedMesh&&_t.batching===!1||!D.isBatchedMesh&&_t.batching===!0||D.isBatchedMesh&&_t.batchingColor===!0&&D.colorTexture===null||D.isBatchedMesh&&_t.batchingColor===!1&&D.colorTexture!==null||D.isInstancedMesh&&_t.instancing===!1||!D.isInstancedMesh&&_t.instancing===!0||D.isSkinnedMesh&&_t.skinning===!1||!D.isSkinnedMesh&&_t.skinning===!0||D.isInstancedMesh&&_t.instancingColor===!0&&D.instanceColor===null||D.isInstancedMesh&&_t.instancingColor===!1&&D.instanceColor!==null||D.isInstancedMesh&&_t.instancingMorph===!0&&D.morphTexture===null||D.isInstancedMesh&&_t.instancingMorph===!1&&D.morphTexture!==null||_t.envMap!==ft||N.fog===!0&&_t.fog!==tt||_t.numClippingPlanes!==void 0&&(_t.numClippingPlanes!==rt.numPlanes||_t.numIntersection!==rt.numIntersection)||_t.vertexAlphas!==Mt||_t.vertexTangents!==St||_t.morphTargets!==vt||_t.morphNormals!==Vt||_t.morphColors!==Qt||_t.toneMapping!==te||_t.morphTargetsCount!==kt)&&(Kt=!0):(Kt=!0,_t.__version=N.version);let Ge=_t.currentProgram;Kt===!0&&(Ge=vi(N,L,D));let xi=!1,mn=!1,rr=!1;const ce=Ge.getUniforms(),Je=_t.uniforms;if(xt.useProgram(Ge.program)&&(xi=!0,mn=!0,rr=!0),N.id!==O&&(O=N.id,mn=!0),xi||E!==v){ce.setValue(R,"projectionMatrix",v.projectionMatrix),ce.setValue(R,"viewMatrix",v.matrixWorldInverse);const Te=ce.map.cameraPosition;Te!==void 0&&Te.setValue(R,st.setFromMatrixPosition(v.matrixWorld)),jt.logarithmicDepthBuffer&&ce.setValue(R,"logDepthBufFC",2/(Math.log(v.far+1)/Math.LN2)),(N.isMeshPhongMaterial||N.isMeshToonMaterial||N.isMeshLambertMaterial||N.isMeshBasicMaterial||N.isMeshStandardMaterial||N.isShaderMaterial)&&ce.setValue(R,"isOrthographic",v.isOrthographicCamera===!0),E!==v&&(E=v,mn=!0,rr=!0)}if(D.isSkinnedMesh){ce.setOptional(R,D,"bindMatrix"),ce.setOptional(R,D,"bindMatrixInverse");const Te=D.skeleton;Te&&(Te.boneTexture===null&&Te.computeBoneTexture(),ce.setValue(R,"boneTexture",Te.boneTexture,Tt))}D.isBatchedMesh&&(ce.setOptional(R,D,"batchingTexture"),ce.setValue(R,"batchingTexture",D._matricesTexture,Tt),ce.setOptional(R,D,"batchingColorTexture"),D._colorsTexture!==null&&ce.setValue(R,"batchingColorTexture",D._colorsTexture,Tt));const sr=I.morphAttributes;if((sr.position!==void 0||sr.normal!==void 0||sr.color!==void 0)&&mt.update(D,I,Ge),(mn||_t.receiveShadow!==D.receiveShadow)&&(_t.receiveShadow=D.receiveShadow,ce.setValue(R,"receiveShadow",D.receiveShadow)),N.isMeshGouraudMaterial&&N.envMap!==null&&(Je.envMap.value=ft,Je.flipEnvMap.value=ft.isCubeTexture&&ft.isRenderTargetTexture===!1?-1:1),N.isMeshStandardMaterial&&N.envMap===null&&L.environment!==null&&(Je.envMapIntensity.value=L.environmentIntensity),mn&&(ce.setValue(R,"toneMappingExposure",S.toneMappingExposure),_t.needsLights&&yo(Je,rr),tt&&N.fog===!0&&Z.refreshFogUniforms(Je,tt),Z.refreshMaterialUniforms(Je,N,J,G,d.state.transmissionRenderTarget[v.id]),Wi.upload(R,os(_t),Je,Tt)),N.isShaderMaterial&&N.uniformsNeedUpdate===!0&&(Wi.upload(R,os(_t),Je,Tt),N.uniformsNeedUpdate=!1),N.isSpriteMaterial&&ce.setValue(R,"center",D.center),ce.setValue(R,"modelViewMatrix",D.modelViewMatrix),ce.setValue(R,"normalMatrix",D.normalMatrix),ce.setValue(R,"modelMatrix",D.matrixWorld),N.isShaderMaterial||N.isRawShaderMaterial){const Te=N.uniformsGroups;for(let ar=0,Ao=Te.length;ar<Ao;ar++){const cs=Te[ar];Nt.update(cs,Ge),Nt.bind(cs,Ge)}}return Ge}function yo(v,L){v.ambientLightColor.needsUpdate=L,v.lightProbe.needsUpdate=L,v.directionalLights.needsUpdate=L,v.directionalLightShadows.needsUpdate=L,v.pointLights.needsUpdate=L,v.pointLightShadows.needsUpdate=L,v.spotLights.needsUpdate=L,v.spotLightShadows.needsUpdate=L,v.rectAreaLights.needsUpdate=L,v.hemisphereLights.needsUpdate=L}function To(v){return v.isMeshLambertMaterial||v.isMeshToonMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isShadowMaterial||v.isShaderMaterial&&v.lights===!0}this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(v,L,I){Lt.get(v.texture).__webglTexture=L,Lt.get(v.depthTexture).__webglTexture=I;const N=Lt.get(v);N.__hasExternalTextures=!0,N.__autoAllocateDepthBuffer=I===void 0,N.__autoAllocateDepthBuffer||It.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),N.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(v,L){const I=Lt.get(v);I.__webglFramebuffer=L,I.__useDefaultFramebuffer=L===void 0},this.setRenderTarget=function(v,L=0,I=0){C=v,F=L,b=I;let N=!0,D=null,tt=!1,lt=!1;if(v){const ft=Lt.get(v);ft.__useDefaultFramebuffer!==void 0?(xt.bindFramebuffer(R.FRAMEBUFFER,null),N=!1):ft.__webglFramebuffer===void 0?Tt.setupRenderTarget(v):ft.__hasExternalTextures&&Tt.rebindTextures(v,Lt.get(v.texture).__webglTexture,Lt.get(v.depthTexture).__webglTexture);const Mt=v.texture;(Mt.isData3DTexture||Mt.isDataArrayTexture||Mt.isCompressedArrayTexture)&&(lt=!0);const St=Lt.get(v).__webglFramebuffer;v.isWebGLCubeRenderTarget?(Array.isArray(St[L])?D=St[L][I]:D=St[L],tt=!0):v.samples>0&&Tt.useMultisampledRTT(v)===!1?D=Lt.get(v).__webglMultisampledFramebuffer:Array.isArray(St)?D=St[I]:D=St,M.copy(v.viewport),P.copy(v.scissor),X=v.scissorTest}else M.copy(dt).multiplyScalar(J).floor(),P.copy(pt).multiplyScalar(J).floor(),X=Ft;if(xt.bindFramebuffer(R.FRAMEBUFFER,D)&&N&&xt.drawBuffers(v,D),xt.viewport(M),xt.scissor(P),xt.setScissorTest(X),tt){const ft=Lt.get(v.texture);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_CUBE_MAP_POSITIVE_X+L,ft.__webglTexture,I)}else if(lt){const ft=Lt.get(v.texture),Mt=L||0;R.framebufferTextureLayer(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,ft.__webglTexture,I||0,Mt)}O=-1},this.readRenderTargetPixels=function(v,L,I,N,D,tt,lt){if(!(v&&v.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ht=Lt.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&lt!==void 0&&(ht=ht[lt]),ht){xt.bindFramebuffer(R.FRAMEBUFFER,ht);try{const ft=v.texture,Mt=ft.format,St=ft.type;if(!jt.textureFormatReadable(Mt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!jt.textureTypeReadable(St)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=v.width-N&&I>=0&&I<=v.height-D&&R.readPixels(L,I,N,D,at.convert(Mt),at.convert(St),tt)}finally{const ft=C!==null?Lt.get(C).__webglFramebuffer:null;xt.bindFramebuffer(R.FRAMEBUFFER,ft)}}},this.readRenderTargetPixelsAsync=async function(v,L,I,N,D,tt,lt){if(!(v&&v.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ht=Lt.get(v).__webglFramebuffer;if(v.isWebGLCubeRenderTarget&&lt!==void 0&&(ht=ht[lt]),ht){xt.bindFramebuffer(R.FRAMEBUFFER,ht);try{const ft=v.texture,Mt=ft.format,St=ft.type;if(!jt.textureFormatReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!jt.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(L>=0&&L<=v.width-N&&I>=0&&I<=v.height-D){const vt=R.createBuffer();R.bindBuffer(R.PIXEL_PACK_BUFFER,vt),R.bufferData(R.PIXEL_PACK_BUFFER,tt.byteLength,R.STREAM_READ),R.readPixels(L,I,N,D,at.convert(Mt),at.convert(St),0),R.flush();const Vt=R.fenceSync(R.SYNC_GPU_COMMANDS_COMPLETE,0);await Yl(R,Vt,4);try{R.bindBuffer(R.PIXEL_PACK_BUFFER,vt),R.getBufferSubData(R.PIXEL_PACK_BUFFER,0,tt)}finally{R.deleteBuffer(vt),R.deleteSync(Vt)}return tt}}finally{const ft=C!==null?Lt.get(C).__webglFramebuffer:null;xt.bindFramebuffer(R.FRAMEBUFFER,ft)}}},this.copyFramebufferToTexture=function(v,L=null,I=0){v.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),L=arguments[0]||null,v=arguments[1]);const N=Math.pow(2,-I),D=Math.floor(v.image.width*N),tt=Math.floor(v.image.height*N),lt=L!==null?L.x:0,ht=L!==null?L.y:0;Tt.setTexture2D(v,0),R.copyTexSubImage2D(R.TEXTURE_2D,I,0,0,lt,ht,D,tt),xt.unbindTexture()},this.copyTextureToTexture=function(v,L,I=null,N=null,D=0){v.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),N=arguments[0]||null,v=arguments[1],L=arguments[2],D=arguments[3]||0,I=null);let tt,lt,ht,ft,Mt,St;I!==null?(tt=I.max.x-I.min.x,lt=I.max.y-I.min.y,ht=I.min.x,ft=I.min.y):(tt=v.image.width,lt=v.image.height,ht=0,ft=0),N!==null?(Mt=N.x,St=N.y):(Mt=0,St=0);const vt=at.convert(L.format),Vt=at.convert(L.type);Tt.setTexture2D(L,0),R.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,L.flipY),R.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),R.pixelStorei(R.UNPACK_ALIGNMENT,L.unpackAlignment);const Qt=R.getParameter(R.UNPACK_ROW_LENGTH),te=R.getParameter(R.UNPACK_IMAGE_HEIGHT),Me=R.getParameter(R.UNPACK_SKIP_PIXELS),kt=R.getParameter(R.UNPACK_SKIP_ROWS),_t=R.getParameter(R.UNPACK_SKIP_IMAGES),me=v.isCompressedTexture?v.mipmaps[D]:v.image;R.pixelStorei(R.UNPACK_ROW_LENGTH,me.width),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,me.height),R.pixelStorei(R.UNPACK_SKIP_PIXELS,ht),R.pixelStorei(R.UNPACK_SKIP_ROWS,ft),v.isDataTexture?R.texSubImage2D(R.TEXTURE_2D,D,Mt,St,tt,lt,vt,Vt,me.data):v.isCompressedTexture?R.compressedTexSubImage2D(R.TEXTURE_2D,D,Mt,St,me.width,me.height,vt,me.data):R.texSubImage2D(R.TEXTURE_2D,D,Mt,St,vt,Vt,me),R.pixelStorei(R.UNPACK_ROW_LENGTH,Qt),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,te),R.pixelStorei(R.UNPACK_SKIP_PIXELS,Me),R.pixelStorei(R.UNPACK_SKIP_ROWS,kt),R.pixelStorei(R.UNPACK_SKIP_IMAGES,_t),D===0&&L.generateMipmaps&&R.generateMipmap(R.TEXTURE_2D),xt.unbindTexture()},this.copyTextureToTexture3D=function(v,L,I=null,N=null,D=0){v.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),I=arguments[0]||null,N=arguments[1]||null,v=arguments[2],L=arguments[3],D=arguments[4]||0);let tt,lt,ht,ft,Mt,St,vt,Vt,Qt;const te=v.isCompressedTexture?v.mipmaps[D]:v.image;I!==null?(tt=I.max.x-I.min.x,lt=I.max.y-I.min.y,ht=I.max.z-I.min.z,ft=I.min.x,Mt=I.min.y,St=I.min.z):(tt=te.width,lt=te.height,ht=te.depth,ft=0,Mt=0,St=0),N!==null?(vt=N.x,Vt=N.y,Qt=N.z):(vt=0,Vt=0,Qt=0);const Me=at.convert(L.format),kt=at.convert(L.type);let _t;if(L.isData3DTexture)Tt.setTexture3D(L,0),_t=R.TEXTURE_3D;else if(L.isDataArrayTexture||L.isCompressedArrayTexture)Tt.setTexture2DArray(L,0),_t=R.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}R.pixelStorei(R.UNPACK_FLIP_Y_WEBGL,L.flipY),R.pixelStorei(R.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),R.pixelStorei(R.UNPACK_ALIGNMENT,L.unpackAlignment);const me=R.getParameter(R.UNPACK_ROW_LENGTH),Kt=R.getParameter(R.UNPACK_IMAGE_HEIGHT),Ge=R.getParameter(R.UNPACK_SKIP_PIXELS),xi=R.getParameter(R.UNPACK_SKIP_ROWS),mn=R.getParameter(R.UNPACK_SKIP_IMAGES);R.pixelStorei(R.UNPACK_ROW_LENGTH,te.width),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,te.height),R.pixelStorei(R.UNPACK_SKIP_PIXELS,ft),R.pixelStorei(R.UNPACK_SKIP_ROWS,Mt),R.pixelStorei(R.UNPACK_SKIP_IMAGES,St),v.isDataTexture||v.isData3DTexture?R.texSubImage3D(_t,D,vt,Vt,Qt,tt,lt,ht,Me,kt,te.data):L.isCompressedArrayTexture?R.compressedTexSubImage3D(_t,D,vt,Vt,Qt,tt,lt,ht,Me,te.data):R.texSubImage3D(_t,D,vt,Vt,Qt,tt,lt,ht,Me,kt,te),R.pixelStorei(R.UNPACK_ROW_LENGTH,me),R.pixelStorei(R.UNPACK_IMAGE_HEIGHT,Kt),R.pixelStorei(R.UNPACK_SKIP_PIXELS,Ge),R.pixelStorei(R.UNPACK_SKIP_ROWS,xi),R.pixelStorei(R.UNPACK_SKIP_IMAGES,mn),D===0&&L.generateMipmaps&&R.generateMipmap(_t),xt.unbindTexture()},this.initRenderTarget=function(v){Lt.get(v).__webglFramebuffer===void 0&&Tt.setupRenderTarget(v)},this.initTexture=function(v){v.isCubeTexture?Tt.setTextureCube(v,0):v.isData3DTexture?Tt.setTexture3D(v,0):v.isDataArrayTexture||v.isCompressedArrayTexture?Tt.setTexture2DArray(v,0):Tt.setTexture2D(v,0),xt.unbindTexture()},this.resetState=function(){F=0,b=0,C=null,xt.reset(),Ct.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return $e}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Zr?"display-p3":"srgb",e.unpackColorSpace=Xt.workingColorSpace===tr?"display-p3":"srgb"}}class mo{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Ht(t),this.near=e,this.far=n}clone(){return new mo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class lp extends pe{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 He,this.environmentIntensity=1,this.environmentRotation=new He,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ep{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=qr,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=je()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Jr("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,s=this.stride;r<s;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=je()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=je()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const _e=new U;class _o{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)_e.fromBufferAttribute(this,e),_e.applyMatrix4(t),this.setXYZ(e,_e.x,_e.y,_e.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)_e.fromBufferAttribute(this,e),_e.applyNormalMatrix(t),this.setXYZ(e,_e.x,_e.y,_e.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)_e.fromBufferAttribute(this,e),_e.transformDirection(t),this.setXYZ(e,_e.x,_e.y,_e.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Ue(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Wt(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Wt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Ue(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Ue(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Ue(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Ue(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Wt(e,this.array),n=Wt(n,this.array),r=Wt(r,this.array),s=Wt(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=s,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return new De(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new _o(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class cp extends ve{constructor(t,e,n,r,s,o,a,l,c){super(t,e,n,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class go extends ye{constructor(t=1,e=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const s=[],o=[],a=[],l=[],c=new U,u=new Dt;o.push(0,0,0),a.push(0,0,1),l.push(.5,.5);for(let f=0,p=3;f<=e;f++,p+=3){const m=n+f/e*r;c.x=t*Math.cos(m),c.y=t*Math.sin(m),o.push(c.x,c.y,c.z),a.push(0,0,1),u.x=(o[p]/t+1)/2,u.y=(o[p+1]/t+1)/2,l.push(u.x,u.y)}for(let f=1;f<=e;f++)s.push(f,f+1,0);this.setIndex(s),this.setAttribute("position",new se(o,3)),this.setAttribute("normal",new se(a,3)),this.setAttribute("uv",new se(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new go(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class vo extends ye{constructor(t=.5,e=1,n=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:o},n=Math.max(3,n),r=Math.max(1,r);const a=[],l=[],c=[],u=[];let f=t;const p=(e-t)/r,m=new U,_=new Dt;for(let x=0;x<=r;x++){for(let d=0;d<=n;d++){const h=s+d/n*o;m.x=f*Math.cos(h),m.y=f*Math.sin(h),l.push(m.x,m.y,m.z),c.push(0,0,1),_.x=(m.x/e+1)/2,_.y=(m.y/e+1)/2,u.push(_.x,_.y)}f+=p}for(let x=0;x<r;x++){const d=x*(n+1);for(let h=0;h<n;h++){const y=h+d,S=y,A=y+n+1,F=y+n+2,b=y+1;a.push(S,A,b),a.push(A,F,b)}}this.setIndex(a),this.setAttribute("position",new se(l,3)),this.setAttribute("normal",new se(c,3)),this.setAttribute("uv",new se(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new vo(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class xo extends ye{constructor(t=1,e=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(o+a,Math.PI);let c=0;const u=[],f=new U,p=new U,m=[],_=[],x=[],d=[];for(let h=0;h<=n;h++){const y=[],S=h/n;let A=0;h===0&&o===0?A=.5/e:h===n&&l===Math.PI&&(A=-.5/e);for(let F=0;F<=e;F++){const b=F/e;f.x=-t*Math.cos(r+b*s)*Math.sin(o+S*a),f.y=t*Math.cos(o+S*a),f.z=t*Math.sin(r+b*s)*Math.sin(o+S*a),_.push(f.x,f.y,f.z),p.copy(f).normalize(),x.push(p.x,p.y,p.z),d.push(b+A,1-S),y.push(c++)}u.push(y)}for(let h=0;h<n;h++)for(let y=0;y<e;y++){const S=u[h][y+1],A=u[h][y],F=u[h+1][y],b=u[h+1][y+1];(h!==0||o>0)&&m.push(S,A,b),(h!==n-1||l<Math.PI)&&m.push(A,F,b)}this.setIndex(m),this.setAttribute("position",new se(_,3)),this.setAttribute("normal",new se(x,3)),this.setAttribute("uv",new se(d,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new xo(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Mo extends ye{constructor(t=1,e=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);const o=[],a=[],l=[],c=[],u=new U,f=new U,p=new U;for(let m=0;m<=n;m++)for(let _=0;_<=r;_++){const x=_/r*s,d=m/n*Math.PI*2;f.x=(t+e*Math.cos(d))*Math.cos(x),f.y=(t+e*Math.cos(d))*Math.sin(x),f.z=e*Math.sin(d),a.push(f.x,f.y,f.z),u.x=t*Math.cos(x),u.y=t*Math.sin(x),p.subVectors(f,u).normalize(),l.push(p.x,p.y,p.z),c.push(_/r),c.push(m/n)}for(let m=1;m<=n;m++)for(let _=1;_<=r;_++){const x=(r+1)*m+_-1,d=(r+1)*(m-1)+_-1,h=(r+1)*(m-1)+_,y=(r+1)*m+_;o.push(x,d,y),o.push(d,h,y)}this.setIndex(o),this.setAttribute("position",new se(a,3)),this.setAttribute("normal",new se(l,3)),this.setAttribute("uv",new se(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mo(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class hp extends ye{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},t!==null){const e=[],n=new Set,r=new U,s=new U;if(t.index!==null){const o=t.attributes.position,a=t.index;let l=t.groups;l.length===0&&(l=[{start:0,count:a.count,materialIndex:0}]);for(let c=0,u=l.length;c<u;++c){const f=l[c],p=f.start,m=f.count;for(let _=p,x=p+m;_<x;_+=3)for(let d=0;d<3;d++){const h=a.getX(_+d),y=a.getX(_+(d+1)%3);r.fromBufferAttribute(o,h),s.fromBufferAttribute(o,y),Pa(r,s,n)===!0&&(e.push(r.x,r.y,r.z),e.push(s.x,s.y,s.z))}}}else{const o=t.attributes.position;for(let a=0,l=o.count/3;a<l;a++)for(let c=0;c<3;c++){const u=3*a+c,f=3*a+(c+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,f),Pa(r,s,n)===!0&&(e.push(r.x,r.y,r.z),e.push(s.x,s.y,s.z))}}this.setAttribute("position",new se(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}}function Pa(i,t,e){const n=`${i.x},${i.y},${i.z}-${t.x},${t.y},${t.z}`,r=`${t.x},${t.y},${t.z}-${i.x},${i.y},${i.z}`;return e.has(n)===!0||e.has(r)===!0?!1:(e.add(n),e.add(r),!0)}class up extends mi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ht(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 Ht(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ya,this.normalScale=new Dt(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 He,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class is extends pe{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Ht(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}}const Br=new Jt,La=new U,Ua=new U;class So{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Dt(512,512),this.map=null,this.mapPass=null,this.matrix=new Jt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new es,this._frameExtents=new Dt(1,1),this._viewportCount=1,this._viewports=[new Zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;La.setFromMatrixPosition(t.matrixWorld),e.position.copy(La),Ua.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Ua),e.updateMatrixWorld(),Br.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Br),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Br)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const Da=new Jt,li=new U,zr=new U;class np extends So{constructor(){super(new be(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Dt(4,2),this._viewportCount=6,this._viewports=[new Zt(2,1,1,1),new Zt(0,1,1,1),new Zt(3,1,1,1),new Zt(1,1,1,1),new Zt(3,0,1,1),new Zt(1,0,1,1)],this._cubeDirections=[new U(1,0,0),new U(-1,0,0),new U(0,0,1),new U(0,0,-1),new U(0,1,0),new U(0,-1,0)],this._cubeUps=[new U(0,1,0),new U(0,1,0),new U(0,1,0),new U(0,1,0),new U(0,0,1),new U(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,r=this.matrix,s=t.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),li.setFromMatrixPosition(t.matrixWorld),n.position.copy(li),zr.copy(n.position),zr.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(zr),n.updateMatrixWorld(),r.makeTranslation(-li.x,-li.y,-li.z),Da.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Da)}}class dp extends is{constructor(t,e,n=0,r=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new np}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class ip extends So{constructor(){super(new oo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class fp extends is{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(pe.DEFAULT_UP),this.updateMatrix(),this.target=new pe,this.shadow=new ip}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class pp extends is{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class mp extends ye{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class _p{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Ia(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Ia();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Ia(){return(typeof performance>"u"?Date:performance).now()}class gp extends ep{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}const Na=new Jt;class vp{constructor(t,e,n=0,r=1/0){this.ray=new Ja(t,e),this.near=n,this.far=r,this.camera=null,this.layers=new ts,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Na.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Na),this}intersectObject(t,e=!0,n=[]){return Kr(t,this,n,e),n.sort(Fa),n}intersectObjects(t,e=!0,n=[]){for(let r=0,s=t.length;r<s;r++)Kr(t[r],this,n,e);return n.sort(Fa),n}}function Fa(i,t){return i.distance-t.distance}function Kr(i,t,e,n){let r=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(r=!1),r===!0&&n===!0){const s=i.children;for(let o=0,a=s.length;o<a;o++)Kr(s[o],t,e,!0)}}class xp{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(ue(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const Oa=new U,ki=new U;class Mp{constructor(t=new U,e=new U){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Oa.subVectors(t,this.start),ki.subVectors(this.end,this.start);const n=ki.dot(ki);let s=ki.dot(Oa)/n;return e&&(s=ue(s,0,1)),s}closestPointToPoint(t,e,n){const r=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:$r}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=$r);export{sl as A,pi as B,_p as C,fp as D,ni as E,se as F,wn as G,Le as H,mp as I,Ht as J,Vi as K,Mp as L,rp as M,up as N,pe as O,En as P,fi as Q,Ja as R,xp as S,sp as T,uc as U,U as V,hp as W,us as X,xe as Y,er as Z,Dt as a,ap as b,Jt as c,gp as d,_o as e,Qr as f,dn as g,Oe as h,nt as i,Ze as j,Zt as k,vp as l,op as m,Fe as n,lp as o,mo as p,be as q,pp as r,dp as s,xo as t,go as u,to as v,Ke as w,vo as x,Mo as y,cp as z};