@beeson-group/tycho 0.1.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,3910 @@
1
+ var Wi=class i{constructor(t,e,n){this.header=t,this.body=e,this.bodyOffset=n}static parse(t){let e=new DataView(t);if(e.getUint32(0,!0)!==1145264468)throw new Error("not a Tycho data container");let n=e.getUint32(4,!0);if(n!==1)throw new Error(`unsupported container version ${n}`);let s=e.getUint32(8,!0),r=JSON.parse(new TextDecoder().decode(new Uint8Array(t,12,s))),a=12+s,o=a+(8-a%8)%8;return new i(r,t,o)}get datasets(){return this.header.datasets}viewInfo(t){let e=this.header.views[t];if(!e)throw new Error(`unknown view ${t}`);return e}view(t){let e=this.viewInfo(t),n=this.bodyOffset+e.offset;switch(e.dtype){case"float32":return new Float32Array(this.body,n,e.length/4);case"float64":return new Float64Array(this.body,n,e.length/8);case"int32":return new Int32Array(this.body,n,e.length/4);case"uint8":return new Uint8Array(this.body,n,e.length)}}f32(t){let e=this.view(t);return e instanceof Float32Array?e:Float32Array.from(e)}f64(t){let e=this.view(t);return e instanceof Float64Array?e:Float64Array.from(e)}};function vh(i){let t=atob(i.replace(/\s+/g,"")),e=new Uint8Array(new ArrayBuffer(t.length));for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}async function dl(i){let t=i.dataset.encoding??"base64",e=vh(i.textContent??"");if(t==="base64")return e.buffer;if(t==="gzip+base64"){if(typeof DecompressionStream>"u")throw new Error("this browser lacks DecompressionStream; rebuild the page with compress=False");let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Response(n).arrayBuffer()}throw new Error(`unknown data encoding ${t}`)}async function Fa(i){if(i.startsWith("#")){let e=document.querySelector(i);if(!e)throw new Error(`no element matches ${i}`);return Wi.parse(await dl(e))}let t=await fetch(i);if(!t.ok)throw new Error(`failed to fetch ${i}: ${t.status}`);return Wi.parse(await t.arrayBuffer())}var bn=[{id:"rotating_pulsating",label:"rotating-pulsating",axes:["x [DU]","y [DU]"],cmap:"viridis"},{id:"rotating",label:"rotating",axes:["x\u0303 [DU]","y\u0303 [DU]"],cmap:"blues"},{id:"barycentric_inertial",label:"barycentric inertial",axes:["\u03BE [DU]","\u03B7 [DU]"],cmap:"plasma"},{id:"inertial_primary",label:"inertial, centred on m\u2081",axes:["\u03BE\u2081 [DU]","\u03B7\u2081 [DU]"],cmap:"reds"},{id:"inertial_secondary",label:"inertial, centred on m\u2082",axes:["\u03BE\u2082 [DU]","\u03B7\u2082 [DU]"],cmap:"cividis"}];function Ba(i,t){return(1-i*i)/(1+i*Math.cos(t))}function Oa(i,t){let e=Math.round(t/(2*Math.PI)),n=t-2*Math.PI*e,s=2*Math.atan2(Math.sqrt(1-i)*Math.sin(n/2),Math.sqrt(1+i)*Math.cos(n/2));return s-i*Math.sin(s)+2*Math.PI*e}function Ls(i,t,e){return Oa(i,e)-Oa(i,t)}function ai(i,t,e,n,s,r=0){let a=i==="primary"?-t.mu:1-t.mu,o=Ba(t.e,n),c=Math.cos(n),l=Math.sin(n);switch(e){case"rotating_pulsating":s[r]=a,s[r+1]=0;return;case"rotating":s[r]=o*a,s[r+1]=0;return;case"barycentric_inertial":s[r]=o*a*c,s[r+1]=o*a*l;return;case"inertial_primary":{let h=i==="primary"?0:o;s[r]=h*c,s[r+1]=h*l;return}case"inertial_secondary":{let h=i==="secondary"?0:-o;s[r]=h*c,s[r+1]=h*l;return}}}function Ds(i,t,e,n,s){let r=t.length,a=new Float32Array(2);for(let o=0;o<r;o++){let c=i[2*o],l=i[2*o+1],h=e.f0+t[o],f,u;if(n==="rotating_pulsating")f=c,u=l;else{let p=Ba(e.e,h);if(n==="rotating")f=p*c,u=p*l;else{let g=Math.cos(h),_=Math.sin(h);f=p*(c*g-l*_),u=p*(c*_+l*g),n!=="barycentric_inertial"&&(ai(n==="inertial_primary"?"primary":"secondary",e,"barycentric_inertial",h,a),f-=a[0],u-=a[1])}}s[3*o]=f,s[3*o+1]=u,s[3*o+2]=0}return s}function Us(i,t,e,n,s){let r=new Float32Array(2);for(let a=0;a<t.length;a++)ai(i,e,n,e.f0+t[a],r),s[3*a]=r[0],s[3*a+1]=r[1],s[3*a+2]=0;return s}function za(i,t,e){let n=Oa(i,t)+e,s=Math.floor(n/(2*Math.PI)),r=n-2*Math.PI*s,a=i<.8?r:Math.PI;for(let c=0;c<30;c++){let l=(a-i*Math.sin(a)-r)/(1-i*Math.cos(a));if(a-=l,Math.abs(l)<1e-13)break}let o=2*Math.atan2(Math.sqrt(1+i)*Math.sin(a/2),Math.sqrt(1-i)*Math.cos(a/2));return o<0&&(o+=2*Math.PI),o+2*Math.PI*s}function ka(i,t){let e=0,n=i.length-1;if(t<=i[0])return 0;if(t>=i[n])return n-1;for(;n-e>1;){let s=e+n>>1;i[s]<=t?e=s:n=s}return e}var Mh={viridis:[[.267,.005,.329],[.283,.141,.458],[.254,.265,.53],[.207,.372,.553],[.164,.471,.558],[.128,.567,.551],[.135,.659,.518],[.267,.749,.441],[.478,.821,.318],[.741,.873,.15],[.993,.906,.144]],plasma:[[.05,.03,.528],[.294,.012,.615],[.492,.012,.658],[.665,.139,.586],[.798,.28,.47],[.902,.418,.36],[.973,.585,.252],[.993,.771,.155],[.94,.975,.131]],cividis:[[0,.135,.304],[.086,.218,.396],[.243,.301,.42],[.365,.383,.432],[.478,.466,.448],[.588,.55,.437],[.702,.638,.402],[.822,.73,.343],[.945,.827,.244],[.996,.91,.149]],blues:[[.19,.42,.71],[.33,.6,.8],[.53,.76,.87],[.7,.85,.92],[.85,.93,.98]],reds:[[.72,.1,.1],[.89,.27,.2],[.98,.5,.36],[.99,.7,.58],[1,.86,.78]]};function Xi(i,t,e=[0,0,0]){let n=Mh[i],s=Math.max(0,Math.min(1,t))*(n.length-1),r=Math.min(n.length-2,Math.floor(s)),a=s-r;for(let o=0;o<3;o++)e[o]=n[r][o]+(n[r+1][o]-n[r][o])*a;return e}function Ns(i,t){let[e,n,s]=Xi(i,t);return`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}var Se={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Be={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ol=0,_o=1,Bl=2;var xo=1,zl=2,rn=3,gn=0,Ee=1,Xe=2,yn=0,_n=1,ys=2,yo=3,vo=4,kl=5,In=100,Hl=101,Vl=102,Gl=103,Wl=104,Xl=200,ql=201,Yl=202,Zl=203,rr=204,ar=205,$l=206,Jl=207,Kl=208,jl=209,Ql=210,tc=211,ec=212,nc=213,ic=214,Cr=0,Pr=1,Ir=2,Yn=3,Lr=4,Dr=5,Ur=6,Nr=7,Mo=0,sc=1,rc=2,vn=0,ac=1,oc=2,lc=3,cc=4,hc=5,uc=6,dc=7;var bo=300,Kn=301,jn=302,Fr=303,Or=304,vs=306,or=1e3,Pn=1001,lr=1002,Ge=1003,fc=1004;var Ms=1005;var Ke=1006,Br=1007;var On=1008;var an=1009,So=1010,Eo=1011,Li=1012,zr=1013,Bn=1014,on=1015,Di=1016,kr=1017,Hr=1018,Ui=1020,To=35902,wo=35899,Ao=1021,Ro=1022,qe=1023,Mi=1026,Ni=1027,Co=1028,Vr=1029,Po=1030,Gr=1031;var Wr=1033,bs=33776,Ss=33777,Es=33778,Ts=33779,Xr=35840,qr=35841,Yr=35842,Zr=35843,$r=36196,Jr=37492,Kr=37496,jr=37808,Qr=37809,ta=37810,ea=37811,na=37812,ia=37813,sa=37814,ra=37815,aa=37816,oa=37817,la=37818,ca=37819,ha=37820,ua=37821,da=36492,fa=36494,pa=36495,ma=36283,ga=36284,_a=36285,xa=36286;var Qi=2300,cr=2301,sr=2302,co=2400,ho=2401,uo=2402;var pc=3200,mc=3201;var gc=0,_c=1,Mn="",Fe="srgb",Zn="srgb-linear",ts="linear",qt="srgb";var Xn=7680;var fo=519,xc=512,yc=513,vc=514,Io=515,Mc=516,bc=517,Sc=518,Ec=519,po=35044;var Lo="300 es",Je=2e3,es=2001;var tn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let s=n[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}},_e=["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"],fl=1234567,Ki=Math.PI/180,bi=180/Math.PI;function Fi(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(_e[i&255]+_e[i>>8&255]+_e[i>>16&255]+_e[i>>24&255]+"-"+_e[t&255]+_e[t>>8&255]+"-"+_e[t>>16&15|64]+_e[t>>24&255]+"-"+_e[e&63|128]+_e[e>>8&255]+"-"+_e[e>>16&255]+_e[e>>24&255]+_e[n&255]+_e[n>>8&255]+_e[n>>16&255]+_e[n>>24&255]).toLowerCase()}function Ot(i,t,e){return Math.max(t,Math.min(e,i))}function Do(i,t){return(i%t+t)%t}function bh(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function Sh(i,t,e){return i!==t?(e-i)/(t-i):0}function ji(i,t,e){return(1-e)*i+e*t}function Eh(i,t,e,n){return ji(i,t,1-Math.exp(-e*n))}function Th(i,t=1){return t-Math.abs(Do(i,t*2)-t)}function wh(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function Ah(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Rh(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Ch(i,t){return i+Math.random()*(t-i)}function Ph(i){return i*(.5-Math.random())}function Ih(i){i!==void 0&&(fl=i);let t=fl+=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 Lh(i){return i*Ki}function Dh(i){return i*bi}function Uh(i){return(i&i-1)===0&&i!==0}function Nh(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Fh(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Oh(i,t,e,n,s){let r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),f=r((t-n)/2),u=a((t-n)/2),p=r((n-t)/2),g=a((n-t)/2);switch(s){case"XYX":i.set(o*h,c*f,c*u,o*l);break;case"YZY":i.set(c*u,o*h,c*f,o*l);break;case"ZXZ":i.set(c*f,c*u,o*h,o*l);break;case"XZX":i.set(o*h,c*g,c*p,o*l);break;case"YXY":i.set(c*p,o*h,c*g,o*l);break;case"ZYZ":i.set(c*g,c*p,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function yi(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 be(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.")}}var Uo={DEG2RAD:Ki,RAD2DEG:bi,generateUUID:Fi,clamp:Ot,euclideanModulo:Do,mapLinear:bh,inverseLerp:Sh,lerp:ji,damp:Eh,pingpong:Th,smoothstep:wh,smootherstep:Ah,randInt:Rh,randFloat:Ch,randFloatSpread:Ph,seededRandom:Ih,degToRad:Lh,radToDeg:Dh,isPowerOfTwo:Uh,ceilPowerOfTwo:Nh,floorPowerOfTwo:Fh,setQuaternionFromProperEuler:Oh,normalize:be,denormalize:yi},Ut=class i{constructor(t=0,e=0){i.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){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[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=Ot(this.x,t.x,e.x),this.y=Ot(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Ot(this.x,t,e),this.y=Ot(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ot(n,t,e))}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){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ot(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let 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){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},We=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],f=n[s+3],u=r[a+0],p=r[a+1],g=r[a+2],_=r[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=f;return}if(o===1){t[e+0]=u,t[e+1]=p,t[e+2]=g,t[e+3]=_;return}if(f!==_||c!==u||l!==p||h!==g){let m=1-o,d=c*u+l*p+h*g+f*_,T=d>=0?1:-1,M=1-d*d;if(M>Number.EPSILON){let R=Math.sqrt(M),w=Math.atan2(R,d*T);m=Math.sin(m*w)/R,o=Math.sin(o*w)/R}let v=o*T;if(c=c*m+u*v,l=l*m+p*v,h=h*m+g*v,f=f*m+_*v,m===1-o){let R=1/Math.sqrt(c*c+l*l+h*h+f*f);c*=R,l*=R,h*=R,f*=R}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=f}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],f=r[a],u=r[a+1],p=r[a+2],g=r[a+3];return t[e]=o*g+h*f+c*p-l*u,t[e+1]=c*g+h*u+l*f-o*p,t[e+2]=l*g+h*p+o*u-c*f,t[e+3]=h*g-o*f-c*u-l*p,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,s){return this._x=t,this._y=e,this._z=n,this._w=s,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){let n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),f=o(r/2),u=c(n/2),p=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=u*h*f+l*p*g,this._y=l*p*f-u*h*g,this._z=l*h*g+u*p*f,this._w=l*h*f-u*p*g;break;case"YXZ":this._x=u*h*f+l*p*g,this._y=l*p*f-u*h*g,this._z=l*h*g-u*p*f,this._w=l*h*f+u*p*g;break;case"ZXY":this._x=u*h*f-l*p*g,this._y=l*p*f+u*h*g,this._z=l*h*g+u*p*f,this._w=l*h*f-u*p*g;break;case"ZYX":this._x=u*h*f-l*p*g,this._y=l*p*f+u*h*g,this._z=l*h*g-u*p*f,this._w=l*h*f+u*p*g;break;case"YZX":this._x=u*h*f+l*p*g,this._y=l*p*f+u*h*g,this._z=l*h*g-u*p*f,this._w=l*h*f-u*p*g;break;case"XZY":this._x=u*h*f-l*p*g,this._y=l*p*f-u*h*g,this._z=l*h*g+u*p*f,this._w=l*h*f+u*p*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],f=e[10],u=n+o+f;if(u>0){let p=.5/Math.sqrt(u+1);this._w=.25/p,this._x=(h-c)*p,this._y=(r-l)*p,this._z=(a-s)*p}else if(n>o&&n>f){let p=2*Math.sqrt(1+n-o-f);this._w=(h-c)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+l)/p}else if(o>f){let p=2*Math.sqrt(1+o-n-f);this._w=(r-l)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(c+h)/p}else{let p=2*Math.sqrt(1+f-n-o);this._w=(a-s)/p,this._x=(r+l)/p,this._y=(c+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(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(Ot(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),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){let n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,s=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let p=1-e;return this._w=p*a+e*this._w,this._x=p*n+e*this._x,this._y=p*s+e*this._y,this._z=p*r+e*this._z,this.normalize(),this}let l=Math.sqrt(c),h=Math.atan2(l,o),f=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=a*f+this._w*u,this._x=n*f+this._x*u,this._y=s*f+this._y*u,this._z=r*f+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*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}},N=class i{constructor(t=0,e=0,n=0){i.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(pl.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(pl.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*s-o*n),h=2*(o*e-r*s),f=2*(r*n-a*e);return this.x=e+c*l+a*f-o*h,this.y=n+c*h+o*l-r*f,this.z=s+c*f+r*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,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=Ot(this.x,t.x,e.x),this.y=Ot(this.y,t.y,e.y),this.z=Ot(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Ot(this.x,t,e),this.y=Ot(this.y,t,e),this.z=Ot(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ot(n,t,e))}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){let n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ha.copy(this).projectOnVector(t),this.sub(Ha)}reflect(t){return this.sub(Ha.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Ot(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}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){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*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){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,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(){let 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}},Ha=new N,pl=new We,Lt=class i{constructor(t,e,n,s,r,a,o,c,l){i.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l)}set(t,e,n,s,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let 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){let 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){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],f=n[7],u=n[2],p=n[5],g=n[8],_=s[0],m=s[3],d=s[6],T=s[1],M=s[4],v=s[7],R=s[2],w=s[5],C=s[8];return r[0]=a*_+o*T+c*R,r[3]=a*m+o*M+c*w,r[6]=a*d+o*v+c*C,r[1]=l*_+h*T+f*R,r[4]=l*m+h*M+f*w,r[7]=l*d+h*v+f*C,r[2]=u*_+p*T+g*R,r[5]=u*m+p*M+g*w,r[8]=u*d+p*v+g*C,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],f=h*a-o*l,u=o*c-h*r,p=l*r-a*c,g=e*f+n*u+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/g;return t[0]=f*_,t[1]=(s*l-h*n)*_,t[2]=(o*n-s*a)*_,t[3]=u*_,t[4]=(h*e-s*c)*_,t[5]=(s*r-o*e)*_,t[6]=p*_,t[7]=(n*c-l*e)*_,t[8]=(a*e-n*r)*_,this}transpose(){let t,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){let 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,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-s*l,s*c,-s*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Va.makeScale(t,e)),this}rotate(t){return this.premultiply(Va.makeRotation(-t)),this}translate(t,e){return this.premultiply(Va.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){let 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){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])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){let 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)}},Va=new Lt;function No(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function ns(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Tc(){let i=ns("canvas");return i.style.display="block",i}var ml={};function Si(i){i in ml||(ml[i]=!0,console.warn(i))}function wc(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var gl=new Lt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),_l=new Lt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Bh(){let i={enabled:!0,workingColorSpace:Zn,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===qt&&(s.r=mn(s.r),s.g=mn(s.g),s.b=mn(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===qt&&(s.r=vi(s.r),s.g=vi(s.g),s.b=vi(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Mn?ts:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Si("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Si("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Zn]:{primaries:t,whitePoint:n,transfer:ts,toXYZ:gl,fromXYZ:_l,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Fe},outputColorSpaceConfig:{drawingBufferColorSpace:Fe}},[Fe]:{primaries:t,whitePoint:n,transfer:qt,toXYZ:gl,fromXYZ:_l,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Fe}}}),i}var Vt=Bh();function mn(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function vi(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var oi,hr=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{oi===void 0&&(oi=ns("canvas")),oi.width=t.width,oi.height=t.height;let s=oi.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=oi}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=ns("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=mn(r[a]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(mn(e[n]/255)*255):e[n]=mn(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}},zh=0,Ei=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zh++}),this.uuid=Fi(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(Ga(s[a].image)):r.push(Ga(s[a]))}else r=Ga(s);n.url=r}return e||(t.images[this.uuid]=n),n}};function Ga(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?hr.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."),{})}var kh=0,Wa=new N,Re=class i extends tn{constructor(t=i.DEFAULT_IMAGE,e=i.DEFAULT_MAPPING,n=Pn,s=Pn,r=Ke,a=On,o=qe,c=an,l=i.DEFAULT_ANISOTROPY,h=Mn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kh++}),this.uuid=Fi(),this.name="",this.source=new Ei(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ut(0,0),this.repeat=new Ut(1,1),this.center=new Ut(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Lt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Wa).x}get height(){return this.source.getSize(Wa).y}get depth(){return this.source.getSize(Wa).z}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)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}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.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,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!==bo)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case or:t.x=t.x-Math.floor(t.x);break;case Pn:t.x=t.x<0?0:1;break;case lr: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 or:t.y=t.y-Math.floor(t.y);break;case Pn:t.y=t.y<0?0:1;break;case lr: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++}};Re.DEFAULT_IMAGE=null;Re.DEFAULT_MAPPING=bo;Re.DEFAULT_ANISOTROPY=1;var oe=class i{constructor(t=0,e=0,n=0,s=1){i.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}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,s){return this.x=t,this.y=e,this.z=n,this.w=s,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){let e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let 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,s,r,c=t.elements,l=c[0],h=c[4],f=c[8],u=c[1],p=c[5],g=c[9],_=c[2],m=c[6],d=c[10];if(Math.abs(h-u)<.01&&Math.abs(f-_)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+u)<.1&&Math.abs(f+_)<.1&&Math.abs(g+m)<.1&&Math.abs(l+p+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let M=(l+1)/2,v=(p+1)/2,R=(d+1)/2,w=(h+u)/4,C=(f+_)/4,U=(g+m)/4;return M>v&&M>R?M<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(M),s=w/n,r=C/n):v>R?v<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(v),n=w/s,r=U/s):R<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(R),n=C/r,s=U/r),this.set(n,s,r,e),this}let T=Math.sqrt((m-g)*(m-g)+(f-_)*(f-_)+(u-h)*(u-h));return Math.abs(T)<.001&&(T=1),this.x=(m-g)/T,this.y=(f-_)/T,this.z=(u-h)/T,this.w=Math.acos((l+p+d-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],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=Ot(this.x,t.x,e.x),this.y=Ot(this.y,t.y,e.y),this.z=Ot(this.z,t.z,e.z),this.w=Ot(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Ot(this.x,t,e),this.y=Ot(this.y,t,e),this.z=Ot(this.z,t,e),this.w=Ot(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Ot(n,t,e))}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}},ur=class extends tn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ke,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new oe(0,0,t,e),this.scissorTest=!1,this.viewport=new oe(0,0,t,e);let s={width:t,height:e,depth:n.depth},r=new Re(s);this.textures=[];let a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){let e={minFilter:Ke,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}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 s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n,this.textures[s].isArrayTexture=this.textures[s].image.depth>1;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 e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let s=Object.assign({},t.textures[e].image);this.textures[e].source=new Ei(s)}return 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"})}},en=class extends ur{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},is=class extends Re{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ge,this.minFilter=Ge,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}};var dr=class extends Re{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=Ge,this.minFilter=Ge,this.wrapR=Pn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var nn=class{constructor(t=new N(1/0,1/0,1/0),e=new N(-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(Ye.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Ye.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){let n=Ye.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);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Ye):Ye.fromBufferAttribute(r,a),Ye.applyMatrix4(t.matrixWorld),this.expandByPoint(Ye);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Fs.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Fs.copy(n.boundingBox)),Fs.applyMatrix4(t.matrixWorld),this.union(Fs)}let s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],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,Ye),Ye.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(qi),Os.subVectors(this.max,qi),li.subVectors(t.a,qi),ci.subVectors(t.b,qi),hi.subVectors(t.c,qi),Sn.subVectors(ci,li),En.subVectors(hi,ci),Hn.subVectors(li,hi);let e=[0,-Sn.z,Sn.y,0,-En.z,En.y,0,-Hn.z,Hn.y,Sn.z,0,-Sn.x,En.z,0,-En.x,Hn.z,0,-Hn.x,-Sn.y,Sn.x,0,-En.y,En.x,0,-Hn.y,Hn.x,0];return!Xa(e,li,ci,hi,Os)||(e=[1,0,0,0,1,0,0,0,1],!Xa(e,li,ci,hi,Os))?!1:(Bs.crossVectors(Sn,En),e=[Bs.x,Bs.y,Bs.z],Xa(e,li,ci,hi,Os))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ye).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Ye).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:(hn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),hn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),hn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),hn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),hn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),hn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),hn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),hn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(hn),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)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},hn=[new N,new N,new N,new N,new N,new N,new N,new N],Ye=new N,Fs=new nn,li=new N,ci=new N,hi=new N,Sn=new N,En=new N,Hn=new N,qi=new N,Os=new N,Bs=new N,Vn=new N;function Xa(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Vn.fromArray(i,r);let o=s.x*Math.abs(Vn.x)+s.y*Math.abs(Vn.y)+s.z*Math.abs(Vn.z),c=t.dot(Vn),l=e.dot(Vn),h=n.dot(Vn);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var Hh=new nn,Yi=new N,qa=new N,Ln=class{constructor(t=new N,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){let n=this.center;e!==void 0?n.copy(e):Hh.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),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){let 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){let 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;Yi.subVectors(t,this.center);let e=Yi.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Yi,s/n),this.radius+=s}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):(qa.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Yi.copy(t.center).add(qa)),this.expandByPoint(Yi.copy(t.center).sub(qa))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},un=new N,Ya=new N,zs=new N,Tn=new N,Za=new N,ks=new N,$a=new N,Dn=class{constructor(t=new N,e=new N(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,un)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let 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){let e=un.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(un.copy(this.origin).addScaledVector(this.direction,e),un.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Ya.copy(t).add(e).multiplyScalar(.5),zs.copy(e).sub(t).normalize(),Tn.copy(this.origin).sub(Ya);let r=t.distanceTo(e)*.5,a=-this.direction.dot(zs),o=Tn.dot(this.direction),c=-Tn.dot(zs),l=Tn.lengthSq(),h=Math.abs(1-a*a),f,u,p,g;if(h>0)if(f=a*c-o,u=a*o-c,g=r*h,f>=0)if(u>=-g)if(u<=g){let _=1/h;f*=_,u*=_,p=f*(f+a*u+2*o)+u*(a*f+u+2*c)+l}else u=r,f=Math.max(0,-(a*u+o)),p=-f*f+u*(u+2*c)+l;else u=-r,f=Math.max(0,-(a*u+o)),p=-f*f+u*(u+2*c)+l;else u<=-g?(f=Math.max(0,-(-a*r+o)),u=f>0?-r:Math.min(Math.max(-r,-c),r),p=-f*f+u*(u+2*c)+l):u<=g?(f=0,u=Math.min(Math.max(-r,-c),r),p=u*(u+2*c)+l):(f=Math.max(0,-(a*r+o)),u=f>0?r:Math.min(Math.max(-r,-c),r),p=-f*f+u*(u+2*c)+l);else u=a>0?-r:r,f=Math.max(0,-(a*u+o)),p=-f*f+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,f),s&&s.copy(Ya).addScaledVector(zs,u),p}intersectSphere(t,e){un.subVectors(t.center,this.origin);let n=un.dot(this.direction),s=un.dot(un)-n*n,r=t.radius*t.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,f=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,s=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,s=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),f>=0?(o=(t.min.z-u.z)*f,c=(t.max.z-u.z)*f):(o=(t.max.z-u.z)*f,c=(t.min.z-u.z)*f),n>c||o>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,un)!==null}intersectTriangle(t,e,n,s,r){Za.subVectors(e,t),ks.subVectors(n,t),$a.crossVectors(Za,ks);let a=this.direction.dot($a),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Tn.subVectors(this.origin,t);let c=o*this.direction.dot(ks.crossVectors(Tn,ks));if(c<0)return null;let l=o*this.direction.dot(Za.cross(Tn));if(l<0||c+l>a)return null;let h=-o*Tn.dot($a);return h<0?null:this.at(h/a,r)}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)}},ce=class i{constructor(t,e,n,s,r,a,o,c,l,h,f,u,p,g,_,m){i.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,s,r,a,o,c,l,h,f,u,p,g,_,m)}set(t,e,n,s,r,a,o,c,l,h,f,u,p,g,_,m){let d=this.elements;return d[0]=t,d[4]=e,d[8]=n,d[12]=s,d[1]=r,d[5]=a,d[9]=o,d[13]=c,d[2]=l,d[6]=h,d[10]=f,d[14]=u,d[3]=p,d[7]=g,d[11]=_,d[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new i().fromArray(this.elements)}copy(t){let 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){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let 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){let e=this.elements,n=t.elements,s=1/ui.setFromMatrixColumn(t,0).length(),r=1/ui.setFromMatrixColumn(t,1).length(),a=1/ui.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),f=Math.sin(r);if(t.order==="XYZ"){let u=a*h,p=a*f,g=o*h,_=o*f;e[0]=c*h,e[4]=-c*f,e[8]=l,e[1]=p+g*l,e[5]=u-_*l,e[9]=-o*c,e[2]=_-u*l,e[6]=g+p*l,e[10]=a*c}else if(t.order==="YXZ"){let u=c*h,p=c*f,g=l*h,_=l*f;e[0]=u+_*o,e[4]=g*o-p,e[8]=a*l,e[1]=a*f,e[5]=a*h,e[9]=-o,e[2]=p*o-g,e[6]=_+u*o,e[10]=a*c}else if(t.order==="ZXY"){let u=c*h,p=c*f,g=l*h,_=l*f;e[0]=u-_*o,e[4]=-a*f,e[8]=g+p*o,e[1]=p+g*o,e[5]=a*h,e[9]=_-u*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let u=a*h,p=a*f,g=o*h,_=o*f;e[0]=c*h,e[4]=g*l-p,e[8]=u*l+_,e[1]=c*f,e[5]=_*l+u,e[9]=p*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let u=a*c,p=a*l,g=o*c,_=o*l;e[0]=c*h,e[4]=_-u*f,e[8]=g*f+p,e[1]=f,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=p*f+g,e[10]=u-_*f}else if(t.order==="XZY"){let u=a*c,p=a*l,g=o*c,_=o*l;e[0]=c*h,e[4]=-f,e[8]=l*h,e[1]=u*f+_,e[5]=a*h,e[9]=p*f-g,e[2]=g*f-p,e[6]=o*h,e[10]=_*f+u}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(Vh,t,Gh)}lookAt(t,e,n){let s=this.elements;return Ue.subVectors(t,e),Ue.lengthSq()===0&&(Ue.z=1),Ue.normalize(),wn.crossVectors(n,Ue),wn.lengthSq()===0&&(Math.abs(n.z)===1?Ue.x+=1e-4:Ue.z+=1e-4,Ue.normalize(),wn.crossVectors(n,Ue)),wn.normalize(),Hs.crossVectors(Ue,wn),s[0]=wn.x,s[4]=Hs.x,s[8]=Ue.x,s[1]=wn.y,s[5]=Hs.y,s[9]=Ue.y,s[2]=wn.z,s[6]=Hs.z,s[10]=Ue.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],f=n[5],u=n[9],p=n[13],g=n[2],_=n[6],m=n[10],d=n[14],T=n[3],M=n[7],v=n[11],R=n[15],w=s[0],C=s[4],U=s[8],S=s[12],b=s[1],P=s[5],B=s[9],V=s[13],X=s[2],Z=s[6],W=s[10],et=s[14],k=s[3],rt=s[7],ct=s[11],bt=s[15];return r[0]=a*w+o*b+c*X+l*k,r[4]=a*C+o*P+c*Z+l*rt,r[8]=a*U+o*B+c*W+l*ct,r[12]=a*S+o*V+c*et+l*bt,r[1]=h*w+f*b+u*X+p*k,r[5]=h*C+f*P+u*Z+p*rt,r[9]=h*U+f*B+u*W+p*ct,r[13]=h*S+f*V+u*et+p*bt,r[2]=g*w+_*b+m*X+d*k,r[6]=g*C+_*P+m*Z+d*rt,r[10]=g*U+_*B+m*W+d*ct,r[14]=g*S+_*V+m*et+d*bt,r[3]=T*w+M*b+v*X+R*k,r[7]=T*C+M*P+v*Z+R*rt,r[11]=T*U+M*B+v*W+R*ct,r[15]=T*S+M*V+v*et+R*bt,this}multiplyScalar(t){let 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(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],f=t[6],u=t[10],p=t[14],g=t[3],_=t[7],m=t[11],d=t[15];return g*(+r*c*f-s*l*f-r*o*u+n*l*u+s*o*p-n*c*p)+_*(+e*c*p-e*l*u+r*a*u-s*a*p+s*l*h-r*c*h)+m*(+e*l*f-e*o*p-r*a*f+n*a*p+r*o*h-n*l*h)+d*(-s*o*h-e*c*f+e*o*u+s*a*f-n*a*u+n*c*h)}transpose(){let t=this.elements,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){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],f=t[9],u=t[10],p=t[11],g=t[12],_=t[13],m=t[14],d=t[15],T=f*m*l-_*u*l+_*c*p-o*m*p-f*c*d+o*u*d,M=g*u*l-h*m*l-g*c*p+a*m*p+h*c*d-a*u*d,v=h*_*l-g*f*l+g*o*p-a*_*p-h*o*d+a*f*d,R=g*f*c-h*_*c-g*o*u+a*_*u+h*o*m-a*f*m,w=e*T+n*M+s*v+r*R;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/w;return t[0]=T*C,t[1]=(_*u*r-f*m*r-_*s*p+n*m*p+f*s*d-n*u*d)*C,t[2]=(o*m*r-_*c*r+_*s*l-n*m*l-o*s*d+n*c*d)*C,t[3]=(f*c*r-o*u*r-f*s*l+n*u*l+o*s*p-n*c*p)*C,t[4]=M*C,t[5]=(h*m*r-g*u*r+g*s*p-e*m*p-h*s*d+e*u*d)*C,t[6]=(g*c*r-a*m*r-g*s*l+e*m*l+a*s*d-e*c*d)*C,t[7]=(a*u*r-h*c*r+h*s*l-e*u*l-a*s*p+e*c*p)*C,t[8]=v*C,t[9]=(g*f*r-h*_*r-g*n*p+e*_*p+h*n*d-e*f*d)*C,t[10]=(a*_*r-g*o*r+g*n*l-e*_*l-a*n*d+e*o*d)*C,t[11]=(h*o*r-a*f*r-h*n*l+e*f*l+a*n*p-e*o*p)*C,t[12]=R*C,t[13]=(h*_*s-g*f*s+g*n*u-e*_*u-h*n*m+e*f*m)*C,t[14]=(g*o*s-a*_*s-g*n*c+e*_*c+a*n*m-e*o*m)*C,t[15]=(a*f*s-h*o*s+h*n*c-e*f*c-a*n*u+e*o*u)*C,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let 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],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}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){let 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){let 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){let 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){let n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+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,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,f=o+o,u=r*l,p=r*h,g=r*f,_=a*h,m=a*f,d=o*f,T=c*l,M=c*h,v=c*f,R=n.x,w=n.y,C=n.z;return s[0]=(1-(_+d))*R,s[1]=(p+v)*R,s[2]=(g-M)*R,s[3]=0,s[4]=(p-v)*w,s[5]=(1-(u+d))*w,s[6]=(m+T)*w,s[7]=0,s[8]=(g+M)*C,s[9]=(m-T)*C,s[10]=(1-(u+_))*C,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements,r=ui.set(s[0],s[1],s[2]).length(),a=ui.set(s[4],s[5],s[6]).length(),o=ui.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Ze.copy(this);let l=1/r,h=1/a,f=1/o;return Ze.elements[0]*=l,Ze.elements[1]*=l,Ze.elements[2]*=l,Ze.elements[4]*=h,Ze.elements[5]*=h,Ze.elements[6]*=h,Ze.elements[8]*=f,Ze.elements[9]*=f,Ze.elements[10]*=f,e.setFromRotationMatrix(Ze),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=Je,c=!1){let l=this.elements,h=2*r/(e-t),f=2*r/(n-s),u=(e+t)/(e-t),p=(n+s)/(n-s),g,_;if(c)g=r/(a-r),_=a*r/(a-r);else if(o===Je)g=-(a+r)/(a-r),_=-2*a*r/(a-r);else if(o===es)g=-a/(a-r),_=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=f,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=_,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=Je,c=!1){let l=this.elements,h=2/(e-t),f=2/(n-s),u=-(e+t)/(e-t),p=-(n+s)/(n-s),g,_;if(c)g=1/(a-r),_=a/(a-r);else if(o===Je)g=-2/(a-r),_=-(a+r)/(a-r);else if(o===es)g=-1/(a-r),_=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=u,l[1]=0,l[5]=f,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=g,l[14]=_,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])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){let 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}},ui=new N,Ze=new ce,Vh=new N(0,0,0),Gh=new N(1,1,1),wn=new N,Hs=new N,Ue=new N,xl=new ce,yl=new We,sn=class i{constructor(t=0,e=0,n=0,s=i.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}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,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,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){let s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],f=s[2],u=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(Ot(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ot(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-f,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ot(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-f,p),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Ot(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(u,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Ot(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-f,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ot(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),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 xl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(xl,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return yl.setFromEuler(this),this.setFromQuaternion(yl,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}};sn.DEFAULT_ORDER="XYZ";var ss=class{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}},Wh=0,vl=new N,di=new We,dn=new ce,Vs=new N,Zi=new N,Xh=new N,qh=new We,Ml=new N(1,0,0),bl=new N(0,1,0),Sl=new N(0,0,1),El={type:"added"},Yh={type:"removed"},fi={type:"childadded",child:null},Ja={type:"childremoved",child:null},Ce=class i extends tn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Wh++}),this.uuid=Fi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let t=new N,e=new sn,n=new We,s=new N(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),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:s},modelViewMatrix:{value:new ce},normalMatrix:{value:new Lt}}),this.matrix=new ce,this.matrixWorld=new ce,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new ss,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,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 di.setFromAxisAngle(t,e),this.quaternion.multiply(di),this}rotateOnWorldAxis(t,e){return di.setFromAxisAngle(t,e),this.quaternion.premultiply(di),this}rotateX(t){return this.rotateOnAxis(Ml,t)}rotateY(t){return this.rotateOnAxis(bl,t)}rotateZ(t){return this.rotateOnAxis(Sl,t)}translateOnAxis(t,e){return vl.copy(t).applyQuaternion(this.quaternion),this.position.add(vl.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ml,t)}translateY(t){return this.translateOnAxis(bl,t)}translateZ(t){return this.translateOnAxis(Sl,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(dn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Vs.copy(t):Vs.set(t,e,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Zi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?dn.lookAt(Zi,Vs,this.up):dn.lookAt(Vs,Zi,this.up),this.quaternion.setFromRotationMatrix(dn),s&&(dn.extractRotation(s.matrixWorld),di.setFromRotationMatrix(dn),this.quaternion.premultiply(di.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(El),fi.child=t,this.dispatchEvent(fi),fi.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}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Yh),Ja.child=t,this.dispatchEvent(Ja),Ja.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),dn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),dn.multiply(t.parent.matrixWorld)),t.applyMatrix4(dn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(El),fi.child=t,this.dispatchEvent(fi),fi.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,s=this.children.length;n<s;n++){let a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].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(Zi,t,Xh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Zi,qh,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){let 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.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){let s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){let f=c[l];r(t.shapes,f)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){let c=this.animations[o];s.animations.push(r(t.animations,c))}}if(e){let o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),f=a(t.shapes),u=a(t.skeletons),p=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),f.length>0&&(n.shapes=f),u.length>0&&(n.skeletons=u),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}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++){let s=t.children[n];this.add(s.clone())}return this}};Ce.DEFAULT_UP=new N(0,1,0);Ce.DEFAULT_MATRIX_AUTO_UPDATE=!0;Ce.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var $e=new N,fn=new N,Ka=new N,pn=new N,pi=new N,mi=new N,Tl=new N,ja=new N,Qa=new N,to=new N,eo=new oe,no=new oe,io=new oe,Cn=class i{constructor(t=new N,e=new N,n=new N){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),$e.subVectors(t,e),s.cross($e);let r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){$e.subVectors(s,e),fn.subVectors(n,e),Ka.subVectors(t,e);let a=$e.dot($e),o=$e.dot(fn),c=$e.dot(Ka),l=fn.dot(fn),h=fn.dot(Ka),f=a*l-o*o;if(f===0)return r.set(0,0,0),null;let u=1/f,p=(l*c-o*h)*u,g=(a*h-o*c)*u;return r.set(1-p-g,g,p)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,pn)===null?!1:pn.x>=0&&pn.y>=0&&pn.x+pn.y<=1}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,pn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,pn.x),c.addScaledVector(a,pn.y),c.addScaledVector(o,pn.z),c)}static getInterpolatedAttribute(t,e,n,s,r,a){return eo.setScalar(0),no.setScalar(0),io.setScalar(0),eo.fromBufferAttribute(t,e),no.fromBufferAttribute(t,n),io.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(eo,r.x),a.addScaledVector(no,r.y),a.addScaledVector(io,r.z),a}static isFrontFacing(t,e,n,s){return $e.subVectors(n,e),fn.subVectors(t,e),$e.cross(fn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),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 $e.subVectors(this.c,this.b),fn.subVectors(this.a,this.b),$e.cross(fn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return i.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return i.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return i.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return i.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return i.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,a,o;pi.subVectors(s,n),mi.subVectors(r,n),ja.subVectors(t,n);let c=pi.dot(ja),l=mi.dot(ja);if(c<=0&&l<=0)return e.copy(n);Qa.subVectors(t,s);let h=pi.dot(Qa),f=mi.dot(Qa);if(h>=0&&f<=h)return e.copy(s);let u=c*f-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(pi,a);to.subVectors(t,r);let p=pi.dot(to),g=mi.dot(to);if(g>=0&&p<=g)return e.copy(r);let _=p*l-c*g;if(_<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(mi,o);let m=h*g-p*f;if(m<=0&&f-h>=0&&p-g>=0)return Tl.subVectors(r,s),o=(f-h)/(f-h+(p-g)),e.copy(s).addScaledVector(Tl,o);let d=1/(m+_+u);return a=_*d,o=u*d,e.copy(n).addScaledVector(pi,a).addScaledVector(mi,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},Ac={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},An={h:0,s:0,l:0},Gs={h:0,s:0,l:0};function so(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}var zt=class{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){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}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,Vt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Vt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Vt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Vt.workingColorSpace){if(t=Do(t,1),e=Ot(e,0,1),n=Ot(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=so(a,r,t+1/3),this.g=so(a,r,t),this.b=so(a,r,t-1/3)}return Vt.colorSpaceToWorking(this,s),this}setStyle(t,e=Fe){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,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){let n=Ac[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=mn(t.r),this.g=mn(t.g),this.b=mn(t.b),this}copyLinearToSRGB(t){return this.r=vi(t.r),this.g=vi(t.g),this.b=vi(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Fe){return Vt.workingToColorSpace(xe.copy(this),t),Math.round(Ot(xe.r*255,0,255))*65536+Math.round(Ot(xe.g*255,0,255))*256+Math.round(Ot(xe.b*255,0,255))}getHexString(t=Fe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Vt.workingColorSpace){Vt.workingToColorSpace(xe.copy(this),e);let n=xe.r,s=xe.g,r=xe.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let f=a-o;switch(l=h<=.5?f/(a+o):f/(2-a-o),a){case n:c=(s-r)/f+(s<r?6:0);break;case s:c=(r-n)/f+2;break;case r:c=(n-s)/f+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Vt.workingColorSpace){return Vt.workingToColorSpace(xe.copy(this),e),t.r=xe.r,t.g=xe.g,t.b=xe.b,t}getStyle(t=Fe){Vt.workingToColorSpace(xe.copy(this),t);let e=xe.r,n=xe.g,s=xe.b;return t!==Fe?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(An),this.setHSL(An.h+t,An.s+e,An.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(An),t.getHSL(Gs);let n=ji(An.h,Gs.h,e),s=ji(An.s,Gs.s,e),r=ji(An.l,Gs.l,e);return this.setHSL(n,s,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,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}},xe=new zt;zt.NAMES=Ac;var Zh=0,xn=class extends tn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Zh++}),this.uuid=Fi(),this.name="",this.type="Material",this.blending=_n,this.side=gn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=rr,this.blendDst=ar,this.blendEquation=In,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new zt(0,0,0),this.blendAlpha=0,this.depthFunc=Yn,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=fo,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xn,this.stencilZFail=Xn,this.stencilZPass=Xn,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.allowOverride=!0,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}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,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.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),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!==_n&&(n.blending=this.blending),this.side!==gn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==rr&&(n.blendSrc=this.blendSrc),this.blendDst!==ar&&(n.blendDst=this.blendDst),this.blendEquation!==In&&(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!==Yn&&(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!==fo&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Xn&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Xn&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Xn&&(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 s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}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;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].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++}},$n=class extends xn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new zt(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 sn,this.combine=Mo,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}};var he=new N,Ws=new Ut,$h=0,ae=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$h++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=po,this.updateRanges=[],this.gpuType=on,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}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 s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];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++)Ws.fromBufferAttribute(this,e),Ws.applyMatrix3(t),this.setXY(e,Ws.x,Ws.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix3(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyMatrix4(t),this.setXYZ(e,he.x,he.y,he.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.applyNormalMatrix(t),this.setXYZ(e,he.x,he.y,he.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)he.fromBufferAttribute(this,e),he.transformDirection(t),this.setXYZ(e,he.x,he.y,he.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=yi(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=be(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=yi(e,this.array)),e}setX(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=yi(e,this.array)),e}setY(t,e){return this.normalized&&(e=be(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=yi(e,this.array)),e}setZ(t,e){return this.normalized&&(e=be(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=yi(e,this.array)),e}setW(t,e){return this.normalized&&(e=be(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),s=be(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=be(e,this.array),n=be(n,this.array),s=be(s,this.array),r=be(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let 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!==po&&(t.usage=this.usage),t}};var rs=class extends ae{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var as=class extends ae{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var Ae=class extends ae{constructor(t,e,n){super(new Float32Array(t),e,n)}},Jh=0,He=new ce,ro=new Ce,gi=new N,Ne=new nn,$i=new nn,me=new N,ye=class i extends tn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Jh++}),this.uuid=Fi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(No(t)?as:rs)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}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){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new Lt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return He.makeRotationFromQuaternion(t),this.applyMatrix4(He),this}rotateX(t){return He.makeRotationX(t),this.applyMatrix4(He),this}rotateY(t){return He.makeRotationY(t),this.applyMatrix4(He),this}rotateZ(t){return He.makeRotationZ(t),this.applyMatrix4(He),this}translate(t,e,n){return He.makeTranslation(t,e,n),this.applyMatrix4(He),this}scale(t,e,n){return He.makeScale(t,e,n),this.applyMatrix4(He),this}lookAt(t){return ro.lookAt(t),ro.updateMatrix(),this.applyMatrix4(ro.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(gi).negate(),this.translate(gi.x,gi.y,gi.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let s=0,r=t.length;s<r;s++){let a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ae(n,3))}else{let n=Math.min(t.length,e.count);for(let s=0;s<n;s++){let r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new nn);let 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 N(-1/0,-1/0,-1/0),new N(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){let r=e[n];Ne.setFromBufferAttribute(r),this.morphTargetsRelative?(me.addVectors(this.boundingBox.min,Ne.min),this.boundingBox.expandByPoint(me),me.addVectors(this.boundingBox.max,Ne.max),this.boundingBox.expandByPoint(me)):(this.boundingBox.expandByPoint(Ne.min),this.boundingBox.expandByPoint(Ne.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 Ln);let 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 N,1/0);return}if(t){let n=this.boundingSphere.center;if(Ne.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){let o=e[r];$i.setFromBufferAttribute(o),this.morphTargetsRelative?(me.addVectors(Ne.min,$i.min),Ne.expandByPoint(me),me.addVectors(Ne.max,$i.max),Ne.expandByPoint(me)):(Ne.expandByPoint($i.min),Ne.expandByPoint($i.max))}Ne.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)me.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(me));if(e)for(let r=0,a=e.length;r<a;r++){let o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)me.fromBufferAttribute(o,l),c&&(gi.fromBufferAttribute(t,l),me.add(gi)),s=Math.max(s,n.distanceToSquared(me))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let 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}let n=e.position,s=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ae(new Float32Array(4*n.count),4));let a=this.getAttribute("tangent"),o=[],c=[];for(let U=0;U<n.count;U++)o[U]=new N,c[U]=new N;let l=new N,h=new N,f=new N,u=new Ut,p=new Ut,g=new Ut,_=new N,m=new N;function d(U,S,b){l.fromBufferAttribute(n,U),h.fromBufferAttribute(n,S),f.fromBufferAttribute(n,b),u.fromBufferAttribute(r,U),p.fromBufferAttribute(r,S),g.fromBufferAttribute(r,b),h.sub(l),f.sub(l),p.sub(u),g.sub(u);let P=1/(p.x*g.y-g.x*p.y);isFinite(P)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(f,-p.y).multiplyScalar(P),m.copy(f).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(P),o[U].add(_),o[S].add(_),o[b].add(_),c[U].add(m),c[S].add(m),c[b].add(m))}let T=this.groups;T.length===0&&(T=[{start:0,count:t.count}]);for(let U=0,S=T.length;U<S;++U){let b=T[U],P=b.start,B=b.count;for(let V=P,X=P+B;V<X;V+=3)d(t.getX(V+0),t.getX(V+1),t.getX(V+2))}let M=new N,v=new N,R=new N,w=new N;function C(U){R.fromBufferAttribute(s,U),w.copy(R);let S=o[U];M.copy(S),M.sub(R.multiplyScalar(R.dot(S))).normalize(),v.crossVectors(w,S);let P=v.dot(c[U])<0?-1:1;a.setXYZW(U,M.x,M.y,M.z,P)}for(let U=0,S=T.length;U<S;++U){let b=T[U],P=b.start,B=b.count;for(let V=P,X=P+B;V<X;V+=3)C(t.getX(V+0)),C(t.getX(V+1)),C(t.getX(V+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ae(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let u=0,p=n.count;u<p;u++)n.setXYZ(u,0,0,0);let s=new N,r=new N,a=new N,o=new N,c=new N,l=new N,h=new N,f=new N;if(t)for(let u=0,p=t.count;u<p;u+=3){let g=t.getX(u+0),_=t.getX(u+1),m=t.getX(u+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,_),a.fromBufferAttribute(e,m),h.subVectors(a,r),f.subVectors(s,r),h.cross(f),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,_),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let u=0,p=e.count;u<p;u+=3)s.fromBufferAttribute(e,u+0),r.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,r),f.subVectors(s,r),h.cross(f),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)me.fromBufferAttribute(t,e),me.normalize(),t.setXYZ(e,me.x,me.y,me.z)}toNonIndexed(){function t(o,c){let l=o.array,h=o.itemSize,f=o.normalized,u=new l.constructor(c.length*h),p=0,g=0;for(let _=0,m=c.length;_<m;_++){o.isInterleavedBufferAttribute?p=c[_]*o.data.stride+o.offset:p=c[_]*h;for(let d=0;d<h;d++)u[g++]=l[p++]}return new ae(u,h,f)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new i,n=this.index.array,s=this.attributes;for(let o in s){let c=s[o],l=t(c,n);e.setAttribute(o,l)}let r=this.morphAttributes;for(let o in r){let c=[],l=r[o];for(let h=0,f=l.length;h<f;h++){let u=l[h],p=t(u,n);c.push(p)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;let a=this.groups;for(let o=0,c=a.length;o<c;o++){let l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,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){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let f=0,u=l.length;f<u;f++){let p=l[f];h.push(p.toJSON(t.data))}h.length>0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),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;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let s=t.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],f=r[l];for(let u=0,p=f.length;u<p;u++)h.push(f[u].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;let a=t.groups;for(let l=0,h=a.length;l<h;l++){let f=a[l];this.addGroup(f.start,f.count,f.materialIndex)}let o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());let c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},wl=new ce,Gn=new Dn,Xs=new Ln,Al=new N,qs=new N,Ys=new N,Zs=new N,ao=new N,$s=new N,Rl=new N,Js=new N,Pe=class extends Ce{constructor(t=new ye,e=new $n){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,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(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){let n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);let o=this.morphTargetInfluences;if(r&&o){$s.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],f=r[c];h!==0&&(ao.fromBufferAttribute(f,t),a?$s.addScaledVector(ao,h):$s.addScaledVector(ao.sub(e),h))}e.add($s)}return e}raycast(t,e){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Xs.copy(n.boundingSphere),Xs.applyMatrix4(r),Gn.copy(t.ray).recast(t.near),!(Xs.containsPoint(Gn.origin)===!1&&(Gn.intersectSphere(Xs,Al)===null||Gn.origin.distanceToSquared(Al)>(t.far-t.near)**2))&&(wl.copy(r).invert(),Gn.copy(t.ray).applyMatrix4(wl),!(n.boundingBox!==null&&Gn.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Gn)))}_computeIntersections(t,e,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,f=r.attributes.normal,u=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,_=u.length;g<_;g++){let m=u[g],d=a[m.materialIndex],T=Math.max(m.start,p.start),M=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let v=T,R=M;v<R;v+=3){let w=o.getX(v),C=o.getX(v+1),U=o.getX(v+2);s=Ks(this,d,t,n,l,h,f,w,C,U),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{let g=Math.max(0,p.start),_=Math.min(o.count,p.start+p.count);for(let m=g,d=_;m<d;m+=3){let T=o.getX(m),M=o.getX(m+1),v=o.getX(m+2);s=Ks(this,a,t,n,l,h,f,T,M,v),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,_=u.length;g<_;g++){let m=u[g],d=a[m.materialIndex],T=Math.max(m.start,p.start),M=Math.min(c.count,Math.min(m.start+m.count,p.start+p.count));for(let v=T,R=M;v<R;v+=3){let w=v,C=v+1,U=v+2;s=Ks(this,d,t,n,l,h,f,w,C,U),s&&(s.faceIndex=Math.floor(v/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{let g=Math.max(0,p.start),_=Math.min(c.count,p.start+p.count);for(let m=g,d=_;m<d;m+=3){let T=m,M=m+1,v=m+2;s=Ks(this,a,t,n,l,h,f,T,M,v),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}};function Kh(i,t,e,n,s,r,a,o){let c;if(t.side===Ee?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===gn,o),c===null)return null;Js.copy(o),Js.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(Js);return l<e.near||l>e.far?null:{distance:l,point:Js.clone(),object:i}}function Ks(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,qs),i.getVertexPosition(c,Ys),i.getVertexPosition(l,Zs);let h=Kh(i,t,e,n,qs,Ys,Zs,Rl);if(h){let f=new N;Cn.getBarycoord(Rl,qs,Ys,Zs,f),s&&(h.uv=Cn.getInterpolatedAttribute(s,o,c,l,f,new Ut)),r&&(h.uv1=Cn.getInterpolatedAttribute(r,o,c,l,f,new Ut)),a&&(h.normal=Cn.getInterpolatedAttribute(a,o,c,l,f,new N),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let u={a:o,b:c,c:l,normal:new N,materialIndex:0};Cn.getNormal(qs,Ys,Zs,u.normal),h.face=u,h.barycoord=f}return h}var Ti=class i extends ye{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],f=[],u=0,p=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new Ae(l,3)),this.setAttribute("normal",new Ae(h,3)),this.setAttribute("uv",new Ae(f,2));function g(_,m,d,T,M,v,R,w,C,U,S){let b=v/C,P=R/U,B=v/2,V=R/2,X=w/2,Z=C+1,W=U+1,et=0,k=0,rt=new N;for(let ct=0;ct<W;ct++){let bt=ct*P-V;for(let Bt=0;Bt<Z;Bt++){let Jt=Bt*b-B;rt[_]=Jt*T,rt[m]=bt*M,rt[d]=X,l.push(rt.x,rt.y,rt.z),rt[_]=0,rt[m]=0,rt[d]=w>0?1:-1,h.push(rt.x,rt.y,rt.z),f.push(Bt/C),f.push(1-ct/U),et+=1}}for(let ct=0;ct<U;ct++)for(let bt=0;bt<C;bt++){let Bt=u+bt+Z*ct,Jt=u+bt+Z*(ct+1),te=u+(bt+1)+Z*(ct+1),Wt=u+(bt+1)+Z*ct;c.push(Bt,Jt,Wt),c.push(Jt,te,Wt),k+=6}o.addGroup(p,k,S),p+=k,u+=et}}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 Qn(i){let t={};for(let e in i){t[e]={};for(let n in i[e]){let s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function ve(i){let t={};for(let e=0;e<i.length;e++){let n=Qn(i[e]);for(let s in n)t[s]=n[s]}return t}function jh(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function Fo(i){let t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Vt.workingColorSpace}var Rc={clone:Qn,merge:ve},Qh=`void main() {
2
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
3
+ }`,tu=`void main() {
4
+ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
5
+ }`,je=class extends xn{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Qh,this.fragmentShader=tu,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=Qn(t.uniforms),this.uniformsGroups=jh(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){let e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(let s in this.uniforms){let a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={value:a}}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;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},os=class extends Ce{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ce,this.projectionMatrix=new ce,this.projectionMatrixInverse=new ce,this.coordinateSystem=Je,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}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)}},Rn=new N,Cl=new Ut,Pl=new Ut,we=class extends os{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,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){let e=.5*this.getFilmHeight()/t;this.fov=bi*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Ki*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return bi*2*Math.atan(Math.tan(Ki*.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){Rn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Rn.x,Rn.y).multiplyScalar(-t/Rn.z),Rn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Rn.x,Rn.y).multiplyScalar(-t/Rn.z)}getViewSize(t,e){return this.getViewBounds(t,Cl,Pl),e.subVectors(Pl,Cl)}setViewOffset(t,e,n,s,r,a){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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(Ki*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let 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}},_i=-90,xi=1,fr=class extends Ce{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let s=new we(_i,xi,t,e);s.layers=this.layers,this.add(s);let r=new we(_i,xi,t,e);r.layers=this.layers,this.add(r);let a=new we(_i,xi,t,e);a.layers=this.layers,this.add(a);let o=new we(_i,xi,t,e);o.layers=this.layers,this.add(o);let c=new we(_i,xi,t,e);c.layers=this.layers,this.add(c);let l=new we(_i,xi,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===Je)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===es)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,f=t.getRenderTarget(),u=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;let _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,s),t.render(e,r),t.setRenderTarget(n,1,s),t.render(e,a),t.setRenderTarget(n,2,s),t.render(e,o),t.setRenderTarget(n,3,s),t.render(e,c),t.setRenderTarget(n,4,s),t.render(e,l),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,s),t.render(e,h),t.setRenderTarget(f,u,p),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},ls=class extends Re{constructor(t=[],e=Kn,n,s,r,a,o,c,l,h){super(t,e,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},pr=class extends en{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new ls(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}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;let n={uniforms:{tEquirect:{value:null}},vertexShader:`
6
+
7
+ varying vec3 vWorldDirection;
8
+
9
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
10
+
11
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
12
+
13
+ }
14
+
15
+ void main() {
16
+
17
+ vWorldDirection = transformDirection( position, modelMatrix );
18
+
19
+ #include <begin_vertex>
20
+ #include <project_vertex>
21
+
22
+ }
23
+ `,fragmentShader:`
24
+
25
+ uniform sampler2D tEquirect;
26
+
27
+ varying vec3 vWorldDirection;
28
+
29
+ #include <common>
30
+
31
+ void main() {
32
+
33
+ vec3 direction = normalize( vWorldDirection );
34
+
35
+ vec2 sampleUV = equirectUv( direction );
36
+
37
+ gl_FragColor = texture2D( tEquirect, sampleUV );
38
+
39
+ }
40
+ `},s=new Ti(5,5,5),r=new je({name:"CubemapFromEquirect",uniforms:Qn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ee,blending:yn});r.uniforms.tEquirect.value=e;let a=new Pe(s,r),o=e.minFilter;return e.minFilter===On&&(e.minFilter=Ke),new fr(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}},qn=class extends Ce{constructor(){super(),this.isGroup=!0,this.type="Group"}},eu={type:"move"},wi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new qn,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 qn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new N,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new N),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new qn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new N,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new N),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){let e=this._hand;if(e)for(let 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 s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(let _ of t.hand.values()){let m=e.getJointPose(_,n),d=this._getHandJoint(l,_);m!==null&&(d.matrix.fromArray(m.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,d.jointRadius=m.radius),d.visible=m!==null}let h=l.joints["index-finger-tip"],f=l.joints["thumb-tip"],u=h.position.distanceTo(f.position),p=.02,g=.005;l.inputState.pinching&&u>p+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&u<=p-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(eu)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new qn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}};var cs=class extends Ce{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 sn,this.environmentIntensity=1,this.environmentRotation=new sn,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){let 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}};var oo=new N,nu=new N,iu=new Lt,Ve=class{constructor(t=new N(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,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=oo.subVectors(n,e).cross(nu.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let 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){let n=t.delta(oo),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let 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){let n=e||iu.getNormalMatrix(t),s=this.coplanarPoint(oo).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),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)}},Wn=new Ln,su=new Ut(.5,.5),js=new N,hs=class{constructor(t=new Ve,e=new Ve,n=new Ve,s=new Ve,r=new Ve,a=new Ve){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Je,n=!1){let s=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],f=r[5],u=r[6],p=r[7],g=r[8],_=r[9],m=r[10],d=r[11],T=r[12],M=r[13],v=r[14],R=r[15];if(s[0].setComponents(l-a,p-h,d-g,R-T).normalize(),s[1].setComponents(l+a,p+h,d+g,R+T).normalize(),s[2].setComponents(l+o,p+f,d+_,R+M).normalize(),s[3].setComponents(l-o,p-f,d-_,R-M).normalize(),n)s[4].setComponents(c,u,m,v).normalize(),s[5].setComponents(l-c,p-u,d-m,R-v).normalize();else if(s[4].setComponents(l-c,p-u,d-m,R-v).normalize(),e===Je)s[5].setComponents(l+c,p+u,d+m,R+v).normalize();else if(e===es)s[5].setComponents(c,u,m,v).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(),Wn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Wn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Wn)}intersectsSprite(t){Wn.center.set(0,0,0);let e=su.distanceTo(t.center);return Wn.radius=.7071067811865476+e,Wn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Wn)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let s=e[n];if(js.x=s.normal.x>0?t.max.x:t.min.x,js.y=s.normal.y>0?t.max.y:t.min.y,js.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(js)<0)return!1}return!0}containsPoint(t){let 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)}};var Un=class extends xn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new zt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},mr=new N,gr=new N,Il=new ce,Ji=new Dn,Qs=new Ln,lo=new N,Ll=new N,Ai=class extends Ce{constructor(t=new ye,e=new Un){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let s=1,r=e.count;s<r;s++)mr.fromBufferAttribute(e,s-1),gr.fromBufferAttribute(e,s),n[s]=n[s-1],n[s]+=mr.distanceTo(gr);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Qs.copy(n.boundingSphere),Qs.applyMatrix4(s),Qs.radius+=r,t.ray.intersectsSphere(Qs)===!1)return;Il.copy(s).invert(),Ji.copy(t.ray).applyMatrix4(Il);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,u=n.attributes.position;if(h!==null){let p=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let _=p,m=g-1;_<m;_+=l){let d=h.getX(_),T=h.getX(_+1),M=tr(this,t,Ji,c,d,T,_);M&&e.push(M)}if(this.isLineLoop){let _=h.getX(g-1),m=h.getX(p),d=tr(this,t,Ji,c,_,m,g-1);d&&e.push(d)}}else{let p=Math.max(0,a.start),g=Math.min(u.count,a.start+a.count);for(let _=p,m=g-1;_<m;_+=l){let d=tr(this,t,Ji,c,_,_+1,_);d&&e.push(d)}if(this.isLineLoop){let _=tr(this,t,Ji,c,g-1,p,g-1);_&&e.push(_)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function tr(i,t,e,n,s,r,a){let o=i.geometry.attributes.position;if(mr.fromBufferAttribute(o,s),gr.fromBufferAttribute(o,r),e.distanceSqToSegment(mr,gr,lo,Ll)>n)return;lo.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(lo);if(!(l<t.near||l>t.far))return{distance:l,point:Ll.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}var Dl=new N,Ul=new N,Ri=class extends Ai{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let s=0,r=e.count;s<r;s+=2)Dl.fromBufferAttribute(e,s),Ul.fromBufferAttribute(e,s+1),n[s]=s===0?0:n[s-1],n[s+1]=n[s]+Dl.distanceTo(Ul);t.setAttribute("lineDistance",new Ae(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}};var Ci=class extends xn{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new zt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},Nl=new ce,mo=new Dn,er=new Ln,nr=new N,us=class extends Ce{constructor(t=new ye,e=new Ci){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,s=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),er.copy(n.boundingSphere),er.applyMatrix4(s),er.radius+=r,t.ray.intersectsSphere(er)===!1)return;Nl.copy(s).invert(),mo.copy(t.ray).applyMatrix4(Nl);let o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,f=n.attributes.position;if(l!==null){let u=Math.max(0,a.start),p=Math.min(l.count,a.start+a.count);for(let g=u,_=p;g<_;g++){let m=l.getX(g);nr.fromBufferAttribute(f,m),Fl(nr,m,c,s,t,e,this)}}else{let u=Math.max(0,a.start),p=Math.min(f.count,a.start+a.count);for(let g=u,_=p;g<_;g++)nr.fromBufferAttribute(f,g),Fl(nr,g,c,s,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){let o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}};function Fl(i,t,e,n,s,r,a){let o=mo.distanceSqToPoint(i);if(o<e){let c=new N;mo.closestPointToPoint(i,c),c.applyMatrix4(n);let l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}var ds=class extends Re{constructor(t,e,n,s,r,a,o,c,l){super(t,e,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},fs=class extends Re{constructor(t,e,n=Bn,s,r,a,o=Ge,c=Ge,l,h=Mi,f=1){if(h!==Mi&&h!==Ni)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let u={width:t,height:e,depth:f};super(u,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Ei(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},ps=class extends Re{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}};var ms=class i extends ye{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};let r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,f=t/o,u=e/c,p=[],g=[],_=[],m=[];for(let d=0;d<h;d++){let T=d*u-a;for(let M=0;M<l;M++){let v=M*f-r;g.push(v,-T,0),_.push(0,0,1),m.push(M/o),m.push(1-d/c)}}for(let d=0;d<c;d++)for(let T=0;T<o;T++){let M=T+l*d,v=T+l*(d+1),R=T+1+l*(d+1),w=T+1+l*d;p.push(M,v,w),p.push(v,R,w)}this.setIndex(p),this.setAttribute("position",new Ae(g,3)),this.setAttribute("normal",new Ae(_,3)),this.setAttribute("uv",new Ae(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new i(t.width,t.height,t.widthSegments,t.heightSegments)}};var _r=class extends xn{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=pc,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}},xr=class extends xn{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}};function ir(i,t){return!i||i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function ru(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var Jn=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<s)){for(let o=n+2;;){if(s===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=s,s=e[++n],t<s)break t}a=e.length;break e}if(!(t>=r)){let o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(s=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){let o=n+a>>>1;t<e[o]?a=o:n=o+1}if(s=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,s)}return this.interpolate_(n,r,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s;for(let a=0;a!==s;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},yr=class extends Jn{constructor(t,e,n,s){super(t,e,n,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:co,endingEnd:co}}intervalChanged_(t,e,n){let s=this.parameterPositions,r=t-2,a=t+1,o=s[r],c=s[a];if(o===void 0)switch(this.getSettings_().endingStart){case ho:r=t,o=2*e-n;break;case uo:r=s.length-2,o=e+s[r]-s[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case ho:a=t,c=2*n-e;break;case uo:a=1,c=n+s[1]-s[0];break;default:a=t-1,c=e}let l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,f=this._offsetNext,u=this._weightPrev,p=this._weightNext,g=(n-e)/(s-e),_=g*g,m=_*g,d=-u*m+2*u*_-u*g,T=(1+u)*m+(-1.5-2*u)*_+(-.5+u)*g+1,M=(-1-p)*m+(1.5+p)*_+.5*g,v=p*m-p*_;for(let R=0;R!==o;++R)r[R]=d*a[h+R]+T*a[l+R]+M*a[c+R]+v*a[f+R];return r}},vr=class extends Jn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(s-e),f=1-h;for(let u=0;u!==o;++u)r[u]=a[l+u]*f+a[c+u]*h;return r}},Mr=class extends Jn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t){return this.copySampleValue_(t-1)}},Oe=class{constructor(t,e,n,s){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ir(e,this.TimeBufferType),this.values=ir(n,this.ValueBufferType),this.setInterpolation(s||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ir(t.times,Array),values:ir(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Mr(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new vr(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new yr(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Qi:e=this.InterpolantFactoryMethodDiscrete;break;case cr:e=this.InterpolantFactoryMethodLinear;break;case sr:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Qi;case this.InterpolantFactoryMethodLinear:return cr;case this.InterpolantFactoryMethodSmooth:return sr}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,s=e.length;n!==s;++n)e[n]*=t}return this}trim(t,e){let n=this.times,s=n.length,r=0,a=s-1;for(;r!==s&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(s!==void 0&&ru(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),s=this.getInterpolation()===sr,r=t.length-1,a=1;for(let o=1;o<r;++o){let c=!1,l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(s)c=!0;else{let f=o*n,u=f-n,p=f+n;for(let g=0;g!==n;++g){let _=e[f+g];if(_!==e[u+g]||_!==e[p+g]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];let f=o*n,u=a*n;for(let p=0;p!==n;++p)e[u+p]=e[f+p]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};Oe.prototype.ValueTypeName="";Oe.prototype.TimeBufferType=Float32Array;Oe.prototype.ValueBufferType=Float32Array;Oe.prototype.DefaultInterpolation=cr;var Nn=class extends Oe{constructor(t,e,n){super(t,e,n)}};Nn.prototype.ValueTypeName="bool";Nn.prototype.ValueBufferType=Array;Nn.prototype.DefaultInterpolation=Qi;Nn.prototype.InterpolantFactoryMethodLinear=void 0;Nn.prototype.InterpolantFactoryMethodSmooth=void 0;var br=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}};br.prototype.ValueTypeName="color";var Sr=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}};Sr.prototype.ValueTypeName="number";var Er=class extends Jn{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(s-e),l=t*o;for(let h=l+o;l!==h;l+=4)We.slerpFlat(r,0,a,l-o,a,l,c);return r}},gs=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}InterpolantFactoryMethodLinear(t){return new Er(this.times,this.values,this.getValueSize(),t)}};gs.prototype.ValueTypeName="quaternion";gs.prototype.InterpolantFactoryMethodSmooth=void 0;var Fn=class extends Oe{constructor(t,e,n){super(t,e,n)}};Fn.prototype.ValueTypeName="string";Fn.prototype.ValueBufferType=Array;Fn.prototype.DefaultInterpolation=Qi;Fn.prototype.InterpolantFactoryMethodLinear=void 0;Fn.prototype.InterpolantFactoryMethodSmooth=void 0;var Tr=class extends Oe{constructor(t,e,n,s){super(t,e,n,s)}};Tr.prototype.ValueTypeName="vector";var wr=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.abortController=new AbortController,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,f){return l.push(h,f),this},this.removeHandler=function(h){let f=l.indexOf(h);return f!==-1&&l.splice(f,2),this},this.getHandler=function(h){for(let f=0,u=l.length;f<u;f+=2){let p=l[f],g=l[f+1];if(p.global&&(p.lastIndex=0),p.test(h))return g}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}},Cc=new wr,Ar=class{constructor(t){this.manager=t!==void 0?t:Cc,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(s,r){n.load(t,s,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}};Ar.DEFAULT_MATERIAL_NAME="__DEFAULT";var Pi=class extends os{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=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=s,this.near=r,this.far=a,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,s,r,a){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=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let 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}};var Rr=class extends we{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}};var Oo="\\[\\]\\.:\\/",au=new RegExp("["+Oo+"]","g"),Bo="[^"+Oo+"]",ou="[^"+Oo.replace("\\.","")+"]",lu=/((?:WC+[\/:])*)/.source.replace("WC",Bo),cu=/(WCOD+)?/.source.replace("WCOD",ou),hu=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Bo),uu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Bo),du=new RegExp("^"+lu+cu+hu+uu+"$"),fu=["material","materials","bones","map"],go=class{constructor(t,e,n){let s=n||Qt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,s=this._bindings[n];s!==void 0&&s.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let s=this._targetGroup.nCachedObjects_,r=n.length;s!==r;++s)n[s].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},Qt=class i{constructor(t,e,n){this.path=e,this.parsedPath=n||i.parseTrackName(e),this.node=i.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new i.Composite(t,e,n):new i(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(au,"")}static parseTrackName(t){let e=du.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=n.nodeName&&n.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let r=n.nodeName.substring(s+1);fu.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,s),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a<r.length;a++){let o=r[a];if(o.name===e||o.uuid===e)return o;let c=n(o.children);if(c)return c}return null},s=n(t.children);if(s)return s}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)t[e++]=n[s]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let s=0,r=n.length;s!==r;++s)n[s]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,s=e.propertyName,r=e.propertyIndex;if(t||(t=i.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let a=t[s];if(a===void 0){let l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+s+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(s==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=s;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Qt.Composite=go;Qt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Qt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Qt.prototype.GetterByBindingType=[Qt.prototype._getValue_direct,Qt.prototype._getValue_array,Qt.prototype._getValue_arrayElement,Qt.prototype._getValue_toArray];Qt.prototype.SetterByBindingTypeAndVersioning=[[Qt.prototype._setValue_direct,Qt.prototype._setValue_direct_setNeedsUpdate,Qt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_array,Qt.prototype._setValue_array_setNeedsUpdate,Qt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_arrayElement,Qt.prototype._setValue_arrayElement_setNeedsUpdate,Qt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Qt.prototype._setValue_fromArray,Qt.prototype._setValue_fromArray_setNeedsUpdate,Qt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var yg=new Float32Array(1);var Ii=class{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}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=Ot(this.phi,1e-6,Math.PI-1e-6),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(Ot(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};var _s=class extends Ri{constructor(t=10,e=10,n=4473924,s=8947848){n=new zt(n),s=new zt(s);let r=e/2,a=t/e,o=t/2,c=[],l=[];for(let u=0,p=0,g=-o;u<=e;u++,g+=a){c.push(-o,0,g,o,0,g),c.push(g,0,-o,g,0,o);let _=u===r?n:s;_.toArray(l,p),p+=3,_.toArray(l,p),p+=3,_.toArray(l,p),p+=3,_.toArray(l,p),p+=3}let h=new ye;h.setAttribute("position",new Ae(c,3)),h.setAttribute("color",new Ae(l,3));let f=new Un({vertexColors:!0,toneMapped:!1});super(h,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}};var xs=class extends tn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}};function zo(i,t,e,n){let s=pu(n);switch(e){case Ao:return i*t;case Co:return i*t/s.components*s.byteLength;case Vr:return i*t/s.components*s.byteLength;case Po:return i*t*2/s.components*s.byteLength;case Gr:return i*t*2/s.components*s.byteLength;case Ro:return i*t*3/s.components*s.byteLength;case qe:return i*t*4/s.components*s.byteLength;case Wr:return i*t*4/s.components*s.byteLength;case bs:case Ss:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Es:case Ts:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case qr:case Zr:return Math.max(i,16)*Math.max(t,8)/4;case Xr:case Yr:return Math.max(i,8)*Math.max(t,8)/2;case $r:case Jr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Kr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case jr:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Qr:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case ta:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case ea:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case na:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case ia:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case sa:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case ra:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case aa:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case oa:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case la:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case ca:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case ha:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case ua:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case da:case fa:case pa:return Math.ceil(i/4)*Math.ceil(t/4)*16;case ma:case ga:return Math.ceil(i/4)*Math.ceil(t/4)*8;case _a:case xa:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function pu(i){switch(i){case an:case So:return{byteLength:1,components:1};case Li:case Eo:case Di:return{byteLength:2,components:1};case kr:case Hr:return{byteLength:2,components:4};case Bn:case zr:case on:return{byteLength:4,components:1};case To:case wo:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"180"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="180");function Qc(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function gu(i){let t=new WeakMap;function e(o,c){let l=o.array,h=o.usage,f=l.byteLength,u=i.createBuffer();i.bindBuffer(c,u),i.bufferData(c,l,h),o.onUploadCallback();let p;if(l instanceof Float32Array)p=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?p=i.HALF_FLOAT:p=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=i.SHORT;else if(l instanceof Uint32Array)p=i.UNSIGNED_INT;else if(l instanceof Int32Array)p=i.INT;else if(l instanceof Int8Array)p=i.BYTE;else if(l instanceof Uint8Array)p=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:u,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:f}}function n(o,c,l){let h=c.array,f=c.updateRanges;if(i.bindBuffer(l,o),f.length===0)i.bufferSubData(l,0,h);else{f.sort((p,g)=>p.start-g.start);let u=0;for(let p=1;p<f.length;p++){let g=f[u],_=f[p];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++u,f[u]=_)}f.length=u+1;for(let p=0,g=f.length;p<g;p++){let _=f[p];i.bufferSubData(l,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);let c=t.get(o);c&&(i.deleteBuffer(c.buffer),t.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){let h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}let l=t.get(o);if(l===void 0)t.set(o,e(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:s,remove:r,update:a}}var _u=`#ifdef USE_ALPHAHASH
41
+ if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
42
+ #endif`,xu=`#ifdef USE_ALPHAHASH
43
+ const float ALPHA_HASH_SCALE = 0.05;
44
+ float hash2D( vec2 value ) {
45
+ return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
46
+ }
47
+ float hash3D( vec3 value ) {
48
+ return hash2D( vec2( hash2D( value.xy ), value.z ) );
49
+ }
50
+ float getAlphaHashThreshold( vec3 position ) {
51
+ float maxDeriv = max(
52
+ length( dFdx( position.xyz ) ),
53
+ length( dFdy( position.xyz ) )
54
+ );
55
+ float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
56
+ vec2 pixScales = vec2(
57
+ exp2( floor( log2( pixScale ) ) ),
58
+ exp2( ceil( log2( pixScale ) ) )
59
+ );
60
+ vec2 alpha = vec2(
61
+ hash3D( floor( pixScales.x * position.xyz ) ),
62
+ hash3D( floor( pixScales.y * position.xyz ) )
63
+ );
64
+ float lerpFactor = fract( log2( pixScale ) );
65
+ float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
66
+ float a = min( lerpFactor, 1.0 - lerpFactor );
67
+ vec3 cases = vec3(
68
+ x * x / ( 2.0 * a * ( 1.0 - a ) ),
69
+ ( x - 0.5 * a ) / ( 1.0 - a ),
70
+ 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
71
+ );
72
+ float threshold = ( x < ( 1.0 - a ) )
73
+ ? ( ( x < a ) ? cases.x : cases.y )
74
+ : cases.z;
75
+ return clamp( threshold , 1.0e-6, 1.0 );
76
+ }
77
+ #endif`,yu=`#ifdef USE_ALPHAMAP
78
+ diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
79
+ #endif`,vu=`#ifdef USE_ALPHAMAP
80
+ uniform sampler2D alphaMap;
81
+ #endif`,Mu=`#ifdef USE_ALPHATEST
82
+ #ifdef ALPHA_TO_COVERAGE
83
+ diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
84
+ if ( diffuseColor.a == 0.0 ) discard;
85
+ #else
86
+ if ( diffuseColor.a < alphaTest ) discard;
87
+ #endif
88
+ #endif`,bu=`#ifdef USE_ALPHATEST
89
+ uniform float alphaTest;
90
+ #endif`,Su=`#ifdef USE_AOMAP
91
+ float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
92
+ reflectedLight.indirectDiffuse *= ambientOcclusion;
93
+ #if defined( USE_CLEARCOAT )
94
+ clearcoatSpecularIndirect *= ambientOcclusion;
95
+ #endif
96
+ #if defined( USE_SHEEN )
97
+ sheenSpecularIndirect *= ambientOcclusion;
98
+ #endif
99
+ #if defined( USE_ENVMAP ) && defined( STANDARD )
100
+ float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
101
+ reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
102
+ #endif
103
+ #endif`,Eu=`#ifdef USE_AOMAP
104
+ uniform sampler2D aoMap;
105
+ uniform float aoMapIntensity;
106
+ #endif`,Tu=`#ifdef USE_BATCHING
107
+ #if ! defined( GL_ANGLE_multi_draw )
108
+ #define gl_DrawID _gl_DrawID
109
+ uniform int _gl_DrawID;
110
+ #endif
111
+ uniform highp sampler2D batchingTexture;
112
+ uniform highp usampler2D batchingIdTexture;
113
+ mat4 getBatchingMatrix( const in float i ) {
114
+ int size = textureSize( batchingTexture, 0 ).x;
115
+ int j = int( i ) * 4;
116
+ int x = j % size;
117
+ int y = j / size;
118
+ vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
119
+ vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
120
+ vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
121
+ vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
122
+ return mat4( v1, v2, v3, v4 );
123
+ }
124
+ float getIndirectIndex( const in int i ) {
125
+ int size = textureSize( batchingIdTexture, 0 ).x;
126
+ int x = i % size;
127
+ int y = i / size;
128
+ return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
129
+ }
130
+ #endif
131
+ #ifdef USE_BATCHING_COLOR
132
+ uniform sampler2D batchingColorTexture;
133
+ vec3 getBatchingColor( const in float i ) {
134
+ int size = textureSize( batchingColorTexture, 0 ).x;
135
+ int j = int( i );
136
+ int x = j % size;
137
+ int y = j / size;
138
+ return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
139
+ }
140
+ #endif`,wu=`#ifdef USE_BATCHING
141
+ mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
142
+ #endif`,Au=`vec3 transformed = vec3( position );
143
+ #ifdef USE_ALPHAHASH
144
+ vPosition = vec3( position );
145
+ #endif`,Ru=`vec3 objectNormal = vec3( normal );
146
+ #ifdef USE_TANGENT
147
+ vec3 objectTangent = vec3( tangent.xyz );
148
+ #endif`,Cu=`float G_BlinnPhong_Implicit( ) {
149
+ return 0.25;
150
+ }
151
+ float D_BlinnPhong( const in float shininess, const in float dotNH ) {
152
+ return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
153
+ }
154
+ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
155
+ vec3 halfDir = normalize( lightDir + viewDir );
156
+ float dotNH = saturate( dot( normal, halfDir ) );
157
+ float dotVH = saturate( dot( viewDir, halfDir ) );
158
+ vec3 F = F_Schlick( specularColor, 1.0, dotVH );
159
+ float G = G_BlinnPhong_Implicit( );
160
+ float D = D_BlinnPhong( shininess, dotNH );
161
+ return F * ( G * D );
162
+ } // validated`,Pu=`#ifdef USE_IRIDESCENCE
163
+ const mat3 XYZ_TO_REC709 = mat3(
164
+ 3.2404542, -0.9692660, 0.0556434,
165
+ -1.5371385, 1.8760108, -0.2040259,
166
+ -0.4985314, 0.0415560, 1.0572252
167
+ );
168
+ vec3 Fresnel0ToIor( vec3 fresnel0 ) {
169
+ vec3 sqrtF0 = sqrt( fresnel0 );
170
+ return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
171
+ }
172
+ vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
173
+ return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
174
+ }
175
+ float IorToFresnel0( float transmittedIor, float incidentIor ) {
176
+ return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
177
+ }
178
+ vec3 evalSensitivity( float OPD, vec3 shift ) {
179
+ float phase = 2.0 * PI * OPD * 1.0e-9;
180
+ vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
181
+ vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
182
+ vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
183
+ vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
184
+ xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
185
+ xyz /= 1.0685e-7;
186
+ vec3 rgb = XYZ_TO_REC709 * xyz;
187
+ return rgb;
188
+ }
189
+ vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
190
+ vec3 I;
191
+ float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
192
+ float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
193
+ float cosTheta2Sq = 1.0 - sinTheta2Sq;
194
+ if ( cosTheta2Sq < 0.0 ) {
195
+ return vec3( 1.0 );
196
+ }
197
+ float cosTheta2 = sqrt( cosTheta2Sq );
198
+ float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
199
+ float R12 = F_Schlick( R0, 1.0, cosTheta1 );
200
+ float T121 = 1.0 - R12;
201
+ float phi12 = 0.0;
202
+ if ( iridescenceIOR < outsideIOR ) phi12 = PI;
203
+ float phi21 = PI - phi12;
204
+ vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
205
+ vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
206
+ vec3 phi23 = vec3( 0.0 );
207
+ if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
208
+ if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
209
+ if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
210
+ float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
211
+ vec3 phi = vec3( phi21 ) + phi23;
212
+ vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
213
+ vec3 r123 = sqrt( R123 );
214
+ vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
215
+ vec3 C0 = R12 + Rs;
216
+ I = C0;
217
+ vec3 Cm = Rs - T121;
218
+ for ( int m = 1; m <= 2; ++ m ) {
219
+ Cm *= r123;
220
+ vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
221
+ I += Cm * Sm;
222
+ }
223
+ return max( I, vec3( 0.0 ) );
224
+ }
225
+ #endif`,Iu=`#ifdef USE_BUMPMAP
226
+ uniform sampler2D bumpMap;
227
+ uniform float bumpScale;
228
+ vec2 dHdxy_fwd() {
229
+ vec2 dSTdx = dFdx( vBumpMapUv );
230
+ vec2 dSTdy = dFdy( vBumpMapUv );
231
+ float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
232
+ float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
233
+ float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
234
+ return vec2( dBx, dBy );
235
+ }
236
+ vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
237
+ vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
238
+ vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
239
+ vec3 vN = surf_norm;
240
+ vec3 R1 = cross( vSigmaY, vN );
241
+ vec3 R2 = cross( vN, vSigmaX );
242
+ float fDet = dot( vSigmaX, R1 ) * faceDirection;
243
+ vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
244
+ return normalize( abs( fDet ) * surf_norm - vGrad );
245
+ }
246
+ #endif`,Lu=`#if NUM_CLIPPING_PLANES > 0
247
+ vec4 plane;
248
+ #ifdef ALPHA_TO_COVERAGE
249
+ float distanceToPlane, distanceGradient;
250
+ float clipOpacity = 1.0;
251
+ #pragma unroll_loop_start
252
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
253
+ plane = clippingPlanes[ i ];
254
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
255
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
256
+ clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
257
+ if ( clipOpacity == 0.0 ) discard;
258
+ }
259
+ #pragma unroll_loop_end
260
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
261
+ float unionClipOpacity = 1.0;
262
+ #pragma unroll_loop_start
263
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
264
+ plane = clippingPlanes[ i ];
265
+ distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
266
+ distanceGradient = fwidth( distanceToPlane ) / 2.0;
267
+ unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
268
+ }
269
+ #pragma unroll_loop_end
270
+ clipOpacity *= 1.0 - unionClipOpacity;
271
+ #endif
272
+ diffuseColor.a *= clipOpacity;
273
+ if ( diffuseColor.a == 0.0 ) discard;
274
+ #else
275
+ #pragma unroll_loop_start
276
+ for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
277
+ plane = clippingPlanes[ i ];
278
+ if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
279
+ }
280
+ #pragma unroll_loop_end
281
+ #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
282
+ bool clipped = true;
283
+ #pragma unroll_loop_start
284
+ for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
285
+ plane = clippingPlanes[ i ];
286
+ clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
287
+ }
288
+ #pragma unroll_loop_end
289
+ if ( clipped ) discard;
290
+ #endif
291
+ #endif
292
+ #endif`,Du=`#if NUM_CLIPPING_PLANES > 0
293
+ varying vec3 vClipPosition;
294
+ uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
295
+ #endif`,Uu=`#if NUM_CLIPPING_PLANES > 0
296
+ varying vec3 vClipPosition;
297
+ #endif`,Nu=`#if NUM_CLIPPING_PLANES > 0
298
+ vClipPosition = - mvPosition.xyz;
299
+ #endif`,Fu=`#if defined( USE_COLOR_ALPHA )
300
+ diffuseColor *= vColor;
301
+ #elif defined( USE_COLOR )
302
+ diffuseColor.rgb *= vColor;
303
+ #endif`,Ou=`#if defined( USE_COLOR_ALPHA )
304
+ varying vec4 vColor;
305
+ #elif defined( USE_COLOR )
306
+ varying vec3 vColor;
307
+ #endif`,Bu=`#if defined( USE_COLOR_ALPHA )
308
+ varying vec4 vColor;
309
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
310
+ varying vec3 vColor;
311
+ #endif`,zu=`#if defined( USE_COLOR_ALPHA )
312
+ vColor = vec4( 1.0 );
313
+ #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
314
+ vColor = vec3( 1.0 );
315
+ #endif
316
+ #ifdef USE_COLOR
317
+ vColor *= color;
318
+ #endif
319
+ #ifdef USE_INSTANCING_COLOR
320
+ vColor.xyz *= instanceColor.xyz;
321
+ #endif
322
+ #ifdef USE_BATCHING_COLOR
323
+ vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
324
+ vColor.xyz *= batchingColor.xyz;
325
+ #endif`,ku=`#define PI 3.141592653589793
326
+ #define PI2 6.283185307179586
327
+ #define PI_HALF 1.5707963267948966
328
+ #define RECIPROCAL_PI 0.3183098861837907
329
+ #define RECIPROCAL_PI2 0.15915494309189535
330
+ #define EPSILON 1e-6
331
+ #ifndef saturate
332
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
333
+ #endif
334
+ #define whiteComplement( a ) ( 1.0 - saturate( a ) )
335
+ float pow2( const in float x ) { return x*x; }
336
+ vec3 pow2( const in vec3 x ) { return x*x; }
337
+ float pow3( const in float x ) { return x*x*x; }
338
+ float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
339
+ float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
340
+ float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
341
+ highp float rand( const in vec2 uv ) {
342
+ const highp float a = 12.9898, b = 78.233, c = 43758.5453;
343
+ highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
344
+ return fract( sin( sn ) * c );
345
+ }
346
+ #ifdef HIGH_PRECISION
347
+ float precisionSafeLength( vec3 v ) { return length( v ); }
348
+ #else
349
+ float precisionSafeLength( vec3 v ) {
350
+ float maxComponent = max3( abs( v ) );
351
+ return length( v / maxComponent ) * maxComponent;
352
+ }
353
+ #endif
354
+ struct IncidentLight {
355
+ vec3 color;
356
+ vec3 direction;
357
+ bool visible;
358
+ };
359
+ struct ReflectedLight {
360
+ vec3 directDiffuse;
361
+ vec3 directSpecular;
362
+ vec3 indirectDiffuse;
363
+ vec3 indirectSpecular;
364
+ };
365
+ #ifdef USE_ALPHAHASH
366
+ varying vec3 vPosition;
367
+ #endif
368
+ vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
369
+ return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
370
+ }
371
+ vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
372
+ return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
373
+ }
374
+ mat3 transposeMat3( const in mat3 m ) {
375
+ mat3 tmp;
376
+ tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
377
+ tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
378
+ tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
379
+ return tmp;
380
+ }
381
+ bool isPerspectiveMatrix( mat4 m ) {
382
+ return m[ 2 ][ 3 ] == - 1.0;
383
+ }
384
+ vec2 equirectUv( in vec3 dir ) {
385
+ float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
386
+ float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
387
+ return vec2( u, v );
388
+ }
389
+ vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
390
+ return RECIPROCAL_PI * diffuseColor;
391
+ }
392
+ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
393
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
394
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
395
+ }
396
+ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
397
+ float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
398
+ return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
399
+ } // validated`,Hu=`#ifdef ENVMAP_TYPE_CUBE_UV
400
+ #define cubeUV_minMipLevel 4.0
401
+ #define cubeUV_minTileSize 16.0
402
+ float getFace( vec3 direction ) {
403
+ vec3 absDirection = abs( direction );
404
+ float face = - 1.0;
405
+ if ( absDirection.x > absDirection.z ) {
406
+ if ( absDirection.x > absDirection.y )
407
+ face = direction.x > 0.0 ? 0.0 : 3.0;
408
+ else
409
+ face = direction.y > 0.0 ? 1.0 : 4.0;
410
+ } else {
411
+ if ( absDirection.z > absDirection.y )
412
+ face = direction.z > 0.0 ? 2.0 : 5.0;
413
+ else
414
+ face = direction.y > 0.0 ? 1.0 : 4.0;
415
+ }
416
+ return face;
417
+ }
418
+ vec2 getUV( vec3 direction, float face ) {
419
+ vec2 uv;
420
+ if ( face == 0.0 ) {
421
+ uv = vec2( direction.z, direction.y ) / abs( direction.x );
422
+ } else if ( face == 1.0 ) {
423
+ uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
424
+ } else if ( face == 2.0 ) {
425
+ uv = vec2( - direction.x, direction.y ) / abs( direction.z );
426
+ } else if ( face == 3.0 ) {
427
+ uv = vec2( - direction.z, direction.y ) / abs( direction.x );
428
+ } else if ( face == 4.0 ) {
429
+ uv = vec2( - direction.x, direction.z ) / abs( direction.y );
430
+ } else {
431
+ uv = vec2( direction.x, direction.y ) / abs( direction.z );
432
+ }
433
+ return 0.5 * ( uv + 1.0 );
434
+ }
435
+ vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
436
+ float face = getFace( direction );
437
+ float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
438
+ mipInt = max( mipInt, cubeUV_minMipLevel );
439
+ float faceSize = exp2( mipInt );
440
+ highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
441
+ if ( face > 2.0 ) {
442
+ uv.y += faceSize;
443
+ face -= 3.0;
444
+ }
445
+ uv.x += face * faceSize;
446
+ uv.x += filterInt * 3.0 * cubeUV_minTileSize;
447
+ uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
448
+ uv.x *= CUBEUV_TEXEL_WIDTH;
449
+ uv.y *= CUBEUV_TEXEL_HEIGHT;
450
+ #ifdef texture2DGradEXT
451
+ return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
452
+ #else
453
+ return texture2D( envMap, uv ).rgb;
454
+ #endif
455
+ }
456
+ #define cubeUV_r0 1.0
457
+ #define cubeUV_m0 - 2.0
458
+ #define cubeUV_r1 0.8
459
+ #define cubeUV_m1 - 1.0
460
+ #define cubeUV_r4 0.4
461
+ #define cubeUV_m4 2.0
462
+ #define cubeUV_r5 0.305
463
+ #define cubeUV_m5 3.0
464
+ #define cubeUV_r6 0.21
465
+ #define cubeUV_m6 4.0
466
+ float roughnessToMip( float roughness ) {
467
+ float mip = 0.0;
468
+ if ( roughness >= cubeUV_r1 ) {
469
+ mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
470
+ } else if ( roughness >= cubeUV_r4 ) {
471
+ mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
472
+ } else if ( roughness >= cubeUV_r5 ) {
473
+ mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
474
+ } else if ( roughness >= cubeUV_r6 ) {
475
+ mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
476
+ } else {
477
+ mip = - 2.0 * log2( 1.16 * roughness ); }
478
+ return mip;
479
+ }
480
+ vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
481
+ float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
482
+ float mipF = fract( mip );
483
+ float mipInt = floor( mip );
484
+ vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
485
+ if ( mipF == 0.0 ) {
486
+ return vec4( color0, 1.0 );
487
+ } else {
488
+ vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
489
+ return vec4( mix( color0, color1, mipF ), 1.0 );
490
+ }
491
+ }
492
+ #endif`,Vu=`vec3 transformedNormal = objectNormal;
493
+ #ifdef USE_TANGENT
494
+ vec3 transformedTangent = objectTangent;
495
+ #endif
496
+ #ifdef USE_BATCHING
497
+ mat3 bm = mat3( batchingMatrix );
498
+ transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
499
+ transformedNormal = bm * transformedNormal;
500
+ #ifdef USE_TANGENT
501
+ transformedTangent = bm * transformedTangent;
502
+ #endif
503
+ #endif
504
+ #ifdef USE_INSTANCING
505
+ mat3 im = mat3( instanceMatrix );
506
+ transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
507
+ transformedNormal = im * transformedNormal;
508
+ #ifdef USE_TANGENT
509
+ transformedTangent = im * transformedTangent;
510
+ #endif
511
+ #endif
512
+ transformedNormal = normalMatrix * transformedNormal;
513
+ #ifdef FLIP_SIDED
514
+ transformedNormal = - transformedNormal;
515
+ #endif
516
+ #ifdef USE_TANGENT
517
+ transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
518
+ #ifdef FLIP_SIDED
519
+ transformedTangent = - transformedTangent;
520
+ #endif
521
+ #endif`,Gu=`#ifdef USE_DISPLACEMENTMAP
522
+ uniform sampler2D displacementMap;
523
+ uniform float displacementScale;
524
+ uniform float displacementBias;
525
+ #endif`,Wu=`#ifdef USE_DISPLACEMENTMAP
526
+ transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
527
+ #endif`,Xu=`#ifdef USE_EMISSIVEMAP
528
+ vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
529
+ #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
530
+ emissiveColor = sRGBTransferEOTF( emissiveColor );
531
+ #endif
532
+ totalEmissiveRadiance *= emissiveColor.rgb;
533
+ #endif`,qu=`#ifdef USE_EMISSIVEMAP
534
+ uniform sampler2D emissiveMap;
535
+ #endif`,Yu="gl_FragColor = linearToOutputTexel( gl_FragColor );",Zu=`vec4 LinearTransferOETF( in vec4 value ) {
536
+ return value;
537
+ }
538
+ vec4 sRGBTransferEOTF( in vec4 value ) {
539
+ return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
540
+ }
541
+ vec4 sRGBTransferOETF( in vec4 value ) {
542
+ return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
543
+ }`,$u=`#ifdef USE_ENVMAP
544
+ #ifdef ENV_WORLDPOS
545
+ vec3 cameraToFrag;
546
+ if ( isOrthographic ) {
547
+ cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
548
+ } else {
549
+ cameraToFrag = normalize( vWorldPosition - cameraPosition );
550
+ }
551
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
552
+ #ifdef ENVMAP_MODE_REFLECTION
553
+ vec3 reflectVec = reflect( cameraToFrag, worldNormal );
554
+ #else
555
+ vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
556
+ #endif
557
+ #else
558
+ vec3 reflectVec = vReflect;
559
+ #endif
560
+ #ifdef ENVMAP_TYPE_CUBE
561
+ vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
562
+ #else
563
+ vec4 envColor = vec4( 0.0 );
564
+ #endif
565
+ #ifdef ENVMAP_BLENDING_MULTIPLY
566
+ outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
567
+ #elif defined( ENVMAP_BLENDING_MIX )
568
+ outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
569
+ #elif defined( ENVMAP_BLENDING_ADD )
570
+ outgoingLight += envColor.xyz * specularStrength * reflectivity;
571
+ #endif
572
+ #endif`,Ju=`#ifdef USE_ENVMAP
573
+ uniform float envMapIntensity;
574
+ uniform float flipEnvMap;
575
+ uniform mat3 envMapRotation;
576
+ #ifdef ENVMAP_TYPE_CUBE
577
+ uniform samplerCube envMap;
578
+ #else
579
+ uniform sampler2D envMap;
580
+ #endif
581
+
582
+ #endif`,Ku=`#ifdef USE_ENVMAP
583
+ uniform float reflectivity;
584
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
585
+ #define ENV_WORLDPOS
586
+ #endif
587
+ #ifdef ENV_WORLDPOS
588
+ varying vec3 vWorldPosition;
589
+ uniform float refractionRatio;
590
+ #else
591
+ varying vec3 vReflect;
592
+ #endif
593
+ #endif`,ju=`#ifdef USE_ENVMAP
594
+ #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
595
+ #define ENV_WORLDPOS
596
+ #endif
597
+ #ifdef ENV_WORLDPOS
598
+
599
+ varying vec3 vWorldPosition;
600
+ #else
601
+ varying vec3 vReflect;
602
+ uniform float refractionRatio;
603
+ #endif
604
+ #endif`,Qu=`#ifdef USE_ENVMAP
605
+ #ifdef ENV_WORLDPOS
606
+ vWorldPosition = worldPosition.xyz;
607
+ #else
608
+ vec3 cameraToVertex;
609
+ if ( isOrthographic ) {
610
+ cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
611
+ } else {
612
+ cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
613
+ }
614
+ vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
615
+ #ifdef ENVMAP_MODE_REFLECTION
616
+ vReflect = reflect( cameraToVertex, worldNormal );
617
+ #else
618
+ vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
619
+ #endif
620
+ #endif
621
+ #endif`,td=`#ifdef USE_FOG
622
+ vFogDepth = - mvPosition.z;
623
+ #endif`,ed=`#ifdef USE_FOG
624
+ varying float vFogDepth;
625
+ #endif`,nd=`#ifdef USE_FOG
626
+ #ifdef FOG_EXP2
627
+ float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
628
+ #else
629
+ float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
630
+ #endif
631
+ gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
632
+ #endif`,id=`#ifdef USE_FOG
633
+ uniform vec3 fogColor;
634
+ varying float vFogDepth;
635
+ #ifdef FOG_EXP2
636
+ uniform float fogDensity;
637
+ #else
638
+ uniform float fogNear;
639
+ uniform float fogFar;
640
+ #endif
641
+ #endif`,sd=`#ifdef USE_GRADIENTMAP
642
+ uniform sampler2D gradientMap;
643
+ #endif
644
+ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
645
+ float dotNL = dot( normal, lightDirection );
646
+ vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
647
+ #ifdef USE_GRADIENTMAP
648
+ return vec3( texture2D( gradientMap, coord ).r );
649
+ #else
650
+ vec2 fw = fwidth( coord ) * 0.5;
651
+ return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
652
+ #endif
653
+ }`,rd=`#ifdef USE_LIGHTMAP
654
+ uniform sampler2D lightMap;
655
+ uniform float lightMapIntensity;
656
+ #endif`,ad=`LambertMaterial material;
657
+ material.diffuseColor = diffuseColor.rgb;
658
+ material.specularStrength = specularStrength;`,od=`varying vec3 vViewPosition;
659
+ struct LambertMaterial {
660
+ vec3 diffuseColor;
661
+ float specularStrength;
662
+ };
663
+ void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
664
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
665
+ vec3 irradiance = dotNL * directLight.color;
666
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
667
+ }
668
+ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
669
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
670
+ }
671
+ #define RE_Direct RE_Direct_Lambert
672
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,ld=`uniform bool receiveShadow;
673
+ uniform vec3 ambientLightColor;
674
+ #if defined( USE_LIGHT_PROBES )
675
+ uniform vec3 lightProbe[ 9 ];
676
+ #endif
677
+ vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
678
+ float x = normal.x, y = normal.y, z = normal.z;
679
+ vec3 result = shCoefficients[ 0 ] * 0.886227;
680
+ result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
681
+ result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
682
+ result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
683
+ result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
684
+ result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
685
+ result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
686
+ result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
687
+ result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
688
+ return result;
689
+ }
690
+ vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
691
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
692
+ vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
693
+ return irradiance;
694
+ }
695
+ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
696
+ vec3 irradiance = ambientLightColor;
697
+ return irradiance;
698
+ }
699
+ float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
700
+ float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
701
+ if ( cutoffDistance > 0.0 ) {
702
+ distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
703
+ }
704
+ return distanceFalloff;
705
+ }
706
+ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
707
+ return smoothstep( coneCosine, penumbraCosine, angleCosine );
708
+ }
709
+ #if NUM_DIR_LIGHTS > 0
710
+ struct DirectionalLight {
711
+ vec3 direction;
712
+ vec3 color;
713
+ };
714
+ uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
715
+ void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
716
+ light.color = directionalLight.color;
717
+ light.direction = directionalLight.direction;
718
+ light.visible = true;
719
+ }
720
+ #endif
721
+ #if NUM_POINT_LIGHTS > 0
722
+ struct PointLight {
723
+ vec3 position;
724
+ vec3 color;
725
+ float distance;
726
+ float decay;
727
+ };
728
+ uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
729
+ void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
730
+ vec3 lVector = pointLight.position - geometryPosition;
731
+ light.direction = normalize( lVector );
732
+ float lightDistance = length( lVector );
733
+ light.color = pointLight.color;
734
+ light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
735
+ light.visible = ( light.color != vec3( 0.0 ) );
736
+ }
737
+ #endif
738
+ #if NUM_SPOT_LIGHTS > 0
739
+ struct SpotLight {
740
+ vec3 position;
741
+ vec3 direction;
742
+ vec3 color;
743
+ float distance;
744
+ float decay;
745
+ float coneCos;
746
+ float penumbraCos;
747
+ };
748
+ uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
749
+ void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
750
+ vec3 lVector = spotLight.position - geometryPosition;
751
+ light.direction = normalize( lVector );
752
+ float angleCos = dot( light.direction, spotLight.direction );
753
+ float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
754
+ if ( spotAttenuation > 0.0 ) {
755
+ float lightDistance = length( lVector );
756
+ light.color = spotLight.color * spotAttenuation;
757
+ light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
758
+ light.visible = ( light.color != vec3( 0.0 ) );
759
+ } else {
760
+ light.color = vec3( 0.0 );
761
+ light.visible = false;
762
+ }
763
+ }
764
+ #endif
765
+ #if NUM_RECT_AREA_LIGHTS > 0
766
+ struct RectAreaLight {
767
+ vec3 color;
768
+ vec3 position;
769
+ vec3 halfWidth;
770
+ vec3 halfHeight;
771
+ };
772
+ uniform sampler2D ltc_1; uniform sampler2D ltc_2;
773
+ uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
774
+ #endif
775
+ #if NUM_HEMI_LIGHTS > 0
776
+ struct HemisphereLight {
777
+ vec3 direction;
778
+ vec3 skyColor;
779
+ vec3 groundColor;
780
+ };
781
+ uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
782
+ vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
783
+ float dotNL = dot( normal, hemiLight.direction );
784
+ float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
785
+ vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
786
+ return irradiance;
787
+ }
788
+ #endif`,cd=`#ifdef USE_ENVMAP
789
+ vec3 getIBLIrradiance( const in vec3 normal ) {
790
+ #ifdef ENVMAP_TYPE_CUBE_UV
791
+ vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
792
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
793
+ return PI * envMapColor.rgb * envMapIntensity;
794
+ #else
795
+ return vec3( 0.0 );
796
+ #endif
797
+ }
798
+ vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
799
+ #ifdef ENVMAP_TYPE_CUBE_UV
800
+ vec3 reflectVec = reflect( - viewDir, normal );
801
+ reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
802
+ reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
803
+ vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
804
+ return envMapColor.rgb * envMapIntensity;
805
+ #else
806
+ return vec3( 0.0 );
807
+ #endif
808
+ }
809
+ #ifdef USE_ANISOTROPY
810
+ vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
811
+ #ifdef ENVMAP_TYPE_CUBE_UV
812
+ vec3 bentNormal = cross( bitangent, viewDir );
813
+ bentNormal = normalize( cross( bentNormal, bitangent ) );
814
+ bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
815
+ return getIBLRadiance( viewDir, bentNormal, roughness );
816
+ #else
817
+ return vec3( 0.0 );
818
+ #endif
819
+ }
820
+ #endif
821
+ #endif`,hd=`ToonMaterial material;
822
+ material.diffuseColor = diffuseColor.rgb;`,ud=`varying vec3 vViewPosition;
823
+ struct ToonMaterial {
824
+ vec3 diffuseColor;
825
+ };
826
+ void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
827
+ vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
828
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
829
+ }
830
+ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
831
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
832
+ }
833
+ #define RE_Direct RE_Direct_Toon
834
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,dd=`BlinnPhongMaterial material;
835
+ material.diffuseColor = diffuseColor.rgb;
836
+ material.specularColor = specular;
837
+ material.specularShininess = shininess;
838
+ material.specularStrength = specularStrength;`,fd=`varying vec3 vViewPosition;
839
+ struct BlinnPhongMaterial {
840
+ vec3 diffuseColor;
841
+ vec3 specularColor;
842
+ float specularShininess;
843
+ float specularStrength;
844
+ };
845
+ void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
846
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
847
+ vec3 irradiance = dotNL * directLight.color;
848
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
849
+ reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
850
+ }
851
+ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
852
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
853
+ }
854
+ #define RE_Direct RE_Direct_BlinnPhong
855
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,pd=`PhysicalMaterial material;
856
+ material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
857
+ vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
858
+ float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
859
+ material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
860
+ material.roughness = min( material.roughness, 1.0 );
861
+ #ifdef IOR
862
+ material.ior = ior;
863
+ #ifdef USE_SPECULAR
864
+ float specularIntensityFactor = specularIntensity;
865
+ vec3 specularColorFactor = specularColor;
866
+ #ifdef USE_SPECULAR_COLORMAP
867
+ specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
868
+ #endif
869
+ #ifdef USE_SPECULAR_INTENSITYMAP
870
+ specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
871
+ #endif
872
+ material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
873
+ #else
874
+ float specularIntensityFactor = 1.0;
875
+ vec3 specularColorFactor = vec3( 1.0 );
876
+ material.specularF90 = 1.0;
877
+ #endif
878
+ material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
879
+ #else
880
+ material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
881
+ material.specularF90 = 1.0;
882
+ #endif
883
+ #ifdef USE_CLEARCOAT
884
+ material.clearcoat = clearcoat;
885
+ material.clearcoatRoughness = clearcoatRoughness;
886
+ material.clearcoatF0 = vec3( 0.04 );
887
+ material.clearcoatF90 = 1.0;
888
+ #ifdef USE_CLEARCOATMAP
889
+ material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
890
+ #endif
891
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
892
+ material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
893
+ #endif
894
+ material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
895
+ material.clearcoatRoughness += geometryRoughness;
896
+ material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
897
+ #endif
898
+ #ifdef USE_DISPERSION
899
+ material.dispersion = dispersion;
900
+ #endif
901
+ #ifdef USE_IRIDESCENCE
902
+ material.iridescence = iridescence;
903
+ material.iridescenceIOR = iridescenceIOR;
904
+ #ifdef USE_IRIDESCENCEMAP
905
+ material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
906
+ #endif
907
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
908
+ material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
909
+ #else
910
+ material.iridescenceThickness = iridescenceThicknessMaximum;
911
+ #endif
912
+ #endif
913
+ #ifdef USE_SHEEN
914
+ material.sheenColor = sheenColor;
915
+ #ifdef USE_SHEEN_COLORMAP
916
+ material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
917
+ #endif
918
+ material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
919
+ #ifdef USE_SHEEN_ROUGHNESSMAP
920
+ material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
921
+ #endif
922
+ #endif
923
+ #ifdef USE_ANISOTROPY
924
+ #ifdef USE_ANISOTROPYMAP
925
+ mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
926
+ vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
927
+ vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
928
+ #else
929
+ vec2 anisotropyV = anisotropyVector;
930
+ #endif
931
+ material.anisotropy = length( anisotropyV );
932
+ if( material.anisotropy == 0.0 ) {
933
+ anisotropyV = vec2( 1.0, 0.0 );
934
+ } else {
935
+ anisotropyV /= material.anisotropy;
936
+ material.anisotropy = saturate( material.anisotropy );
937
+ }
938
+ material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
939
+ material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
940
+ material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
941
+ #endif`,md=`struct PhysicalMaterial {
942
+ vec3 diffuseColor;
943
+ float roughness;
944
+ vec3 specularColor;
945
+ float specularF90;
946
+ float dispersion;
947
+ #ifdef USE_CLEARCOAT
948
+ float clearcoat;
949
+ float clearcoatRoughness;
950
+ vec3 clearcoatF0;
951
+ float clearcoatF90;
952
+ #endif
953
+ #ifdef USE_IRIDESCENCE
954
+ float iridescence;
955
+ float iridescenceIOR;
956
+ float iridescenceThickness;
957
+ vec3 iridescenceFresnel;
958
+ vec3 iridescenceF0;
959
+ #endif
960
+ #ifdef USE_SHEEN
961
+ vec3 sheenColor;
962
+ float sheenRoughness;
963
+ #endif
964
+ #ifdef IOR
965
+ float ior;
966
+ #endif
967
+ #ifdef USE_TRANSMISSION
968
+ float transmission;
969
+ float transmissionAlpha;
970
+ float thickness;
971
+ float attenuationDistance;
972
+ vec3 attenuationColor;
973
+ #endif
974
+ #ifdef USE_ANISOTROPY
975
+ float anisotropy;
976
+ float alphaT;
977
+ vec3 anisotropyT;
978
+ vec3 anisotropyB;
979
+ #endif
980
+ };
981
+ vec3 clearcoatSpecularDirect = vec3( 0.0 );
982
+ vec3 clearcoatSpecularIndirect = vec3( 0.0 );
983
+ vec3 sheenSpecularDirect = vec3( 0.0 );
984
+ vec3 sheenSpecularIndirect = vec3(0.0 );
985
+ vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
986
+ float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
987
+ float x2 = x * x;
988
+ float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
989
+ return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
990
+ }
991
+ float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
992
+ float a2 = pow2( alpha );
993
+ float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
994
+ float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
995
+ return 0.5 / max( gv + gl, EPSILON );
996
+ }
997
+ float D_GGX( const in float alpha, const in float dotNH ) {
998
+ float a2 = pow2( alpha );
999
+ float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
1000
+ return RECIPROCAL_PI * a2 / pow2( denom );
1001
+ }
1002
+ #ifdef USE_ANISOTROPY
1003
+ float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
1004
+ float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
1005
+ float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
1006
+ float v = 0.5 / ( gv + gl );
1007
+ return saturate(v);
1008
+ }
1009
+ float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
1010
+ float a2 = alphaT * alphaB;
1011
+ highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
1012
+ highp float v2 = dot( v, v );
1013
+ float w2 = a2 / v2;
1014
+ return RECIPROCAL_PI * a2 * pow2 ( w2 );
1015
+ }
1016
+ #endif
1017
+ #ifdef USE_CLEARCOAT
1018
+ vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
1019
+ vec3 f0 = material.clearcoatF0;
1020
+ float f90 = material.clearcoatF90;
1021
+ float roughness = material.clearcoatRoughness;
1022
+ float alpha = pow2( roughness );
1023
+ vec3 halfDir = normalize( lightDir + viewDir );
1024
+ float dotNL = saturate( dot( normal, lightDir ) );
1025
+ float dotNV = saturate( dot( normal, viewDir ) );
1026
+ float dotNH = saturate( dot( normal, halfDir ) );
1027
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1028
+ vec3 F = F_Schlick( f0, f90, dotVH );
1029
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1030
+ float D = D_GGX( alpha, dotNH );
1031
+ return F * ( V * D );
1032
+ }
1033
+ #endif
1034
+ vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
1035
+ vec3 f0 = material.specularColor;
1036
+ float f90 = material.specularF90;
1037
+ float roughness = material.roughness;
1038
+ float alpha = pow2( roughness );
1039
+ vec3 halfDir = normalize( lightDir + viewDir );
1040
+ float dotNL = saturate( dot( normal, lightDir ) );
1041
+ float dotNV = saturate( dot( normal, viewDir ) );
1042
+ float dotNH = saturate( dot( normal, halfDir ) );
1043
+ float dotVH = saturate( dot( viewDir, halfDir ) );
1044
+ vec3 F = F_Schlick( f0, f90, dotVH );
1045
+ #ifdef USE_IRIDESCENCE
1046
+ F = mix( F, material.iridescenceFresnel, material.iridescence );
1047
+ #endif
1048
+ #ifdef USE_ANISOTROPY
1049
+ float dotTL = dot( material.anisotropyT, lightDir );
1050
+ float dotTV = dot( material.anisotropyT, viewDir );
1051
+ float dotTH = dot( material.anisotropyT, halfDir );
1052
+ float dotBL = dot( material.anisotropyB, lightDir );
1053
+ float dotBV = dot( material.anisotropyB, viewDir );
1054
+ float dotBH = dot( material.anisotropyB, halfDir );
1055
+ float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
1056
+ float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
1057
+ #else
1058
+ float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
1059
+ float D = D_GGX( alpha, dotNH );
1060
+ #endif
1061
+ return F * ( V * D );
1062
+ }
1063
+ vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
1064
+ const float LUT_SIZE = 64.0;
1065
+ const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
1066
+ const float LUT_BIAS = 0.5 / LUT_SIZE;
1067
+ float dotNV = saturate( dot( N, V ) );
1068
+ vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
1069
+ uv = uv * LUT_SCALE + LUT_BIAS;
1070
+ return uv;
1071
+ }
1072
+ float LTC_ClippedSphereFormFactor( const in vec3 f ) {
1073
+ float l = length( f );
1074
+ return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
1075
+ }
1076
+ vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
1077
+ float x = dot( v1, v2 );
1078
+ float y = abs( x );
1079
+ float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
1080
+ float b = 3.4175940 + ( 4.1616724 + y ) * y;
1081
+ float v = a / b;
1082
+ float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
1083
+ return cross( v1, v2 ) * theta_sintheta;
1084
+ }
1085
+ vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
1086
+ vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
1087
+ vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
1088
+ vec3 lightNormal = cross( v1, v2 );
1089
+ if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
1090
+ vec3 T1, T2;
1091
+ T1 = normalize( V - N * dot( V, N ) );
1092
+ T2 = - cross( N, T1 );
1093
+ mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
1094
+ vec3 coords[ 4 ];
1095
+ coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
1096
+ coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
1097
+ coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
1098
+ coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
1099
+ coords[ 0 ] = normalize( coords[ 0 ] );
1100
+ coords[ 1 ] = normalize( coords[ 1 ] );
1101
+ coords[ 2 ] = normalize( coords[ 2 ] );
1102
+ coords[ 3 ] = normalize( coords[ 3 ] );
1103
+ vec3 vectorFormFactor = vec3( 0.0 );
1104
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
1105
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
1106
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
1107
+ vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
1108
+ float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
1109
+ return vec3( result );
1110
+ }
1111
+ #if defined( USE_SHEEN )
1112
+ float D_Charlie( float roughness, float dotNH ) {
1113
+ float alpha = pow2( roughness );
1114
+ float invAlpha = 1.0 / alpha;
1115
+ float cos2h = dotNH * dotNH;
1116
+ float sin2h = max( 1.0 - cos2h, 0.0078125 );
1117
+ return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
1118
+ }
1119
+ float V_Neubelt( float dotNV, float dotNL ) {
1120
+ return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
1121
+ }
1122
+ vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
1123
+ vec3 halfDir = normalize( lightDir + viewDir );
1124
+ float dotNL = saturate( dot( normal, lightDir ) );
1125
+ float dotNV = saturate( dot( normal, viewDir ) );
1126
+ float dotNH = saturate( dot( normal, halfDir ) );
1127
+ float D = D_Charlie( sheenRoughness, dotNH );
1128
+ float V = V_Neubelt( dotNV, dotNL );
1129
+ return sheenColor * ( D * V );
1130
+ }
1131
+ #endif
1132
+ float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1133
+ float dotNV = saturate( dot( normal, viewDir ) );
1134
+ float r2 = roughness * roughness;
1135
+ float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
1136
+ float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
1137
+ float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
1138
+ return saturate( DG * RECIPROCAL_PI );
1139
+ }
1140
+ vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
1141
+ float dotNV = saturate( dot( normal, viewDir ) );
1142
+ const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
1143
+ const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
1144
+ vec4 r = roughness * c0 + c1;
1145
+ float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
1146
+ vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
1147
+ return fab;
1148
+ }
1149
+ vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
1150
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1151
+ return specularColor * fab.x + specularF90 * fab.y;
1152
+ }
1153
+ #ifdef USE_IRIDESCENCE
1154
+ void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1155
+ #else
1156
+ void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
1157
+ #endif
1158
+ vec2 fab = DFGApprox( normal, viewDir, roughness );
1159
+ #ifdef USE_IRIDESCENCE
1160
+ vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
1161
+ #else
1162
+ vec3 Fr = specularColor;
1163
+ #endif
1164
+ vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
1165
+ float Ess = fab.x + fab.y;
1166
+ float Ems = 1.0 - Ess;
1167
+ vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
1168
+ singleScatter += FssEss;
1169
+ multiScatter += Fms * Ems;
1170
+ }
1171
+ #if NUM_RECT_AREA_LIGHTS > 0
1172
+ void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1173
+ vec3 normal = geometryNormal;
1174
+ vec3 viewDir = geometryViewDir;
1175
+ vec3 position = geometryPosition;
1176
+ vec3 lightPos = rectAreaLight.position;
1177
+ vec3 halfWidth = rectAreaLight.halfWidth;
1178
+ vec3 halfHeight = rectAreaLight.halfHeight;
1179
+ vec3 lightColor = rectAreaLight.color;
1180
+ float roughness = material.roughness;
1181
+ vec3 rectCoords[ 4 ];
1182
+ rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
1183
+ rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
1184
+ rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
1185
+ vec2 uv = LTC_Uv( normal, viewDir, roughness );
1186
+ vec4 t1 = texture2D( ltc_1, uv );
1187
+ vec4 t2 = texture2D( ltc_2, uv );
1188
+ mat3 mInv = mat3(
1189
+ vec3( t1.x, 0, t1.y ),
1190
+ vec3( 0, 1, 0 ),
1191
+ vec3( t1.z, 0, t1.w )
1192
+ );
1193
+ vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
1194
+ reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
1195
+ reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
1196
+ }
1197
+ #endif
1198
+ void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1199
+ float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
1200
+ vec3 irradiance = dotNL * directLight.color;
1201
+ #ifdef USE_CLEARCOAT
1202
+ float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
1203
+ vec3 ccIrradiance = dotNLcc * directLight.color;
1204
+ clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
1205
+ #endif
1206
+ #ifdef USE_SHEEN
1207
+ sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
1208
+ #endif
1209
+ reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
1210
+ reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1211
+ }
1212
+ void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
1213
+ reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
1214
+ }
1215
+ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
1216
+ #ifdef USE_CLEARCOAT
1217
+ clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
1218
+ #endif
1219
+ #ifdef USE_SHEEN
1220
+ sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
1221
+ #endif
1222
+ vec3 singleScattering = vec3( 0.0 );
1223
+ vec3 multiScattering = vec3( 0.0 );
1224
+ vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
1225
+ #ifdef USE_IRIDESCENCE
1226
+ computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
1227
+ #else
1228
+ computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
1229
+ #endif
1230
+ vec3 totalScattering = singleScattering + multiScattering;
1231
+ vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
1232
+ reflectedLight.indirectSpecular += radiance * singleScattering;
1233
+ reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
1234
+ reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
1235
+ }
1236
+ #define RE_Direct RE_Direct_Physical
1237
+ #define RE_Direct_RectArea RE_Direct_RectArea_Physical
1238
+ #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
1239
+ #define RE_IndirectSpecular RE_IndirectSpecular_Physical
1240
+ float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
1241
+ return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
1242
+ }`,gd=`
1243
+ vec3 geometryPosition = - vViewPosition;
1244
+ vec3 geometryNormal = normal;
1245
+ vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
1246
+ vec3 geometryClearcoatNormal = vec3( 0.0 );
1247
+ #ifdef USE_CLEARCOAT
1248
+ geometryClearcoatNormal = clearcoatNormal;
1249
+ #endif
1250
+ #ifdef USE_IRIDESCENCE
1251
+ float dotNVi = saturate( dot( normal, geometryViewDir ) );
1252
+ if ( material.iridescenceThickness == 0.0 ) {
1253
+ material.iridescence = 0.0;
1254
+ } else {
1255
+ material.iridescence = saturate( material.iridescence );
1256
+ }
1257
+ if ( material.iridescence > 0.0 ) {
1258
+ material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
1259
+ material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
1260
+ }
1261
+ #endif
1262
+ IncidentLight directLight;
1263
+ #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
1264
+ PointLight pointLight;
1265
+ #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
1266
+ PointLightShadow pointLightShadow;
1267
+ #endif
1268
+ #pragma unroll_loop_start
1269
+ for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
1270
+ pointLight = pointLights[ i ];
1271
+ getPointLightInfo( pointLight, geometryPosition, directLight );
1272
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
1273
+ pointLightShadow = pointLightShadows[ i ];
1274
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
1275
+ #endif
1276
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1277
+ }
1278
+ #pragma unroll_loop_end
1279
+ #endif
1280
+ #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
1281
+ SpotLight spotLight;
1282
+ vec4 spotColor;
1283
+ vec3 spotLightCoord;
1284
+ bool inSpotLightMap;
1285
+ #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
1286
+ SpotLightShadow spotLightShadow;
1287
+ #endif
1288
+ #pragma unroll_loop_start
1289
+ for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
1290
+ spotLight = spotLights[ i ];
1291
+ getSpotLightInfo( spotLight, geometryPosition, directLight );
1292
+ #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1293
+ #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
1294
+ #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1295
+ #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
1296
+ #else
1297
+ #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
1298
+ #endif
1299
+ #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
1300
+ spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
1301
+ inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
1302
+ spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
1303
+ directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
1304
+ #endif
1305
+ #undef SPOT_LIGHT_MAP_INDEX
1306
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1307
+ spotLightShadow = spotLightShadows[ i ];
1308
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1309
+ #endif
1310
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1311
+ }
1312
+ #pragma unroll_loop_end
1313
+ #endif
1314
+ #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
1315
+ DirectionalLight directionalLight;
1316
+ #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
1317
+ DirectionalLightShadow directionalLightShadow;
1318
+ #endif
1319
+ #pragma unroll_loop_start
1320
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
1321
+ directionalLight = directionalLights[ i ];
1322
+ getDirectionalLightInfo( directionalLight, directLight );
1323
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
1324
+ directionalLightShadow = directionalLightShadows[ i ];
1325
+ directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1326
+ #endif
1327
+ RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1328
+ }
1329
+ #pragma unroll_loop_end
1330
+ #endif
1331
+ #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
1332
+ RectAreaLight rectAreaLight;
1333
+ #pragma unroll_loop_start
1334
+ for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
1335
+ rectAreaLight = rectAreaLights[ i ];
1336
+ RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1337
+ }
1338
+ #pragma unroll_loop_end
1339
+ #endif
1340
+ #if defined( RE_IndirectDiffuse )
1341
+ vec3 iblIrradiance = vec3( 0.0 );
1342
+ vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
1343
+ #if defined( USE_LIGHT_PROBES )
1344
+ irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
1345
+ #endif
1346
+ #if ( NUM_HEMI_LIGHTS > 0 )
1347
+ #pragma unroll_loop_start
1348
+ for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
1349
+ irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
1350
+ }
1351
+ #pragma unroll_loop_end
1352
+ #endif
1353
+ #endif
1354
+ #if defined( RE_IndirectSpecular )
1355
+ vec3 radiance = vec3( 0.0 );
1356
+ vec3 clearcoatRadiance = vec3( 0.0 );
1357
+ #endif`,_d=`#if defined( RE_IndirectDiffuse )
1358
+ #ifdef USE_LIGHTMAP
1359
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
1360
+ vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
1361
+ irradiance += lightMapIrradiance;
1362
+ #endif
1363
+ #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
1364
+ iblIrradiance += getIBLIrradiance( geometryNormal );
1365
+ #endif
1366
+ #endif
1367
+ #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
1368
+ #ifdef USE_ANISOTROPY
1369
+ radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
1370
+ #else
1371
+ radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
1372
+ #endif
1373
+ #ifdef USE_CLEARCOAT
1374
+ clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
1375
+ #endif
1376
+ #endif`,xd=`#if defined( RE_IndirectDiffuse )
1377
+ RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1378
+ #endif
1379
+ #if defined( RE_IndirectSpecular )
1380
+ RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
1381
+ #endif`,yd=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1382
+ gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
1383
+ #endif`,vd=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
1384
+ uniform float logDepthBufFC;
1385
+ varying float vFragDepth;
1386
+ varying float vIsPerspective;
1387
+ #endif`,Md=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1388
+ varying float vFragDepth;
1389
+ varying float vIsPerspective;
1390
+ #endif`,bd=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
1391
+ vFragDepth = 1.0 + gl_Position.w;
1392
+ vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
1393
+ #endif`,Sd=`#ifdef USE_MAP
1394
+ vec4 sampledDiffuseColor = texture2D( map, vMapUv );
1395
+ #ifdef DECODE_VIDEO_TEXTURE
1396
+ sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
1397
+ #endif
1398
+ diffuseColor *= sampledDiffuseColor;
1399
+ #endif`,Ed=`#ifdef USE_MAP
1400
+ uniform sampler2D map;
1401
+ #endif`,Td=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1402
+ #if defined( USE_POINTS_UV )
1403
+ vec2 uv = vUv;
1404
+ #else
1405
+ vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
1406
+ #endif
1407
+ #endif
1408
+ #ifdef USE_MAP
1409
+ diffuseColor *= texture2D( map, uv );
1410
+ #endif
1411
+ #ifdef USE_ALPHAMAP
1412
+ diffuseColor.a *= texture2D( alphaMap, uv ).g;
1413
+ #endif`,wd=`#if defined( USE_POINTS_UV )
1414
+ varying vec2 vUv;
1415
+ #else
1416
+ #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
1417
+ uniform mat3 uvTransform;
1418
+ #endif
1419
+ #endif
1420
+ #ifdef USE_MAP
1421
+ uniform sampler2D map;
1422
+ #endif
1423
+ #ifdef USE_ALPHAMAP
1424
+ uniform sampler2D alphaMap;
1425
+ #endif`,Ad=`float metalnessFactor = metalness;
1426
+ #ifdef USE_METALNESSMAP
1427
+ vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
1428
+ metalnessFactor *= texelMetalness.b;
1429
+ #endif`,Rd=`#ifdef USE_METALNESSMAP
1430
+ uniform sampler2D metalnessMap;
1431
+ #endif`,Cd=`#ifdef USE_INSTANCING_MORPH
1432
+ float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1433
+ float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
1434
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1435
+ morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
1436
+ }
1437
+ #endif`,Pd=`#if defined( USE_MORPHCOLORS )
1438
+ vColor *= morphTargetBaseInfluence;
1439
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1440
+ #if defined( USE_COLOR_ALPHA )
1441
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
1442
+ #elif defined( USE_COLOR )
1443
+ if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
1444
+ #endif
1445
+ }
1446
+ #endif`,Id=`#ifdef USE_MORPHNORMALS
1447
+ objectNormal *= morphTargetBaseInfluence;
1448
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1449
+ if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
1450
+ }
1451
+ #endif`,Ld=`#ifdef USE_MORPHTARGETS
1452
+ #ifndef USE_INSTANCING_MORPH
1453
+ uniform float morphTargetBaseInfluence;
1454
+ uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
1455
+ #endif
1456
+ uniform sampler2DArray morphTargetsTexture;
1457
+ uniform ivec2 morphTargetsTextureSize;
1458
+ vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
1459
+ int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
1460
+ int y = texelIndex / morphTargetsTextureSize.x;
1461
+ int x = texelIndex - y * morphTargetsTextureSize.x;
1462
+ ivec3 morphUV = ivec3( x, y, morphTargetIndex );
1463
+ return texelFetch( morphTargetsTexture, morphUV, 0 );
1464
+ }
1465
+ #endif`,Dd=`#ifdef USE_MORPHTARGETS
1466
+ transformed *= morphTargetBaseInfluence;
1467
+ for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
1468
+ if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
1469
+ }
1470
+ #endif`,Ud=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
1471
+ #ifdef FLAT_SHADED
1472
+ vec3 fdx = dFdx( vViewPosition );
1473
+ vec3 fdy = dFdy( vViewPosition );
1474
+ vec3 normal = normalize( cross( fdx, fdy ) );
1475
+ #else
1476
+ vec3 normal = normalize( vNormal );
1477
+ #ifdef DOUBLE_SIDED
1478
+ normal *= faceDirection;
1479
+ #endif
1480
+ #endif
1481
+ #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
1482
+ #ifdef USE_TANGENT
1483
+ mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1484
+ #else
1485
+ mat3 tbn = getTangentFrame( - vViewPosition, normal,
1486
+ #if defined( USE_NORMALMAP )
1487
+ vNormalMapUv
1488
+ #elif defined( USE_CLEARCOAT_NORMALMAP )
1489
+ vClearcoatNormalMapUv
1490
+ #else
1491
+ vUv
1492
+ #endif
1493
+ );
1494
+ #endif
1495
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1496
+ tbn[0] *= faceDirection;
1497
+ tbn[1] *= faceDirection;
1498
+ #endif
1499
+ #endif
1500
+ #ifdef USE_CLEARCOAT_NORMALMAP
1501
+ #ifdef USE_TANGENT
1502
+ mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
1503
+ #else
1504
+ mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
1505
+ #endif
1506
+ #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
1507
+ tbn2[0] *= faceDirection;
1508
+ tbn2[1] *= faceDirection;
1509
+ #endif
1510
+ #endif
1511
+ vec3 nonPerturbedNormal = normal;`,Nd=`#ifdef USE_NORMALMAP_OBJECTSPACE
1512
+ normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1513
+ #ifdef FLIP_SIDED
1514
+ normal = - normal;
1515
+ #endif
1516
+ #ifdef DOUBLE_SIDED
1517
+ normal = normal * faceDirection;
1518
+ #endif
1519
+ normal = normalize( normalMatrix * normal );
1520
+ #elif defined( USE_NORMALMAP_TANGENTSPACE )
1521
+ vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
1522
+ mapN.xy *= normalScale;
1523
+ normal = normalize( tbn * mapN );
1524
+ #elif defined( USE_BUMPMAP )
1525
+ normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
1526
+ #endif`,Fd=`#ifndef FLAT_SHADED
1527
+ varying vec3 vNormal;
1528
+ #ifdef USE_TANGENT
1529
+ varying vec3 vTangent;
1530
+ varying vec3 vBitangent;
1531
+ #endif
1532
+ #endif`,Od=`#ifndef FLAT_SHADED
1533
+ varying vec3 vNormal;
1534
+ #ifdef USE_TANGENT
1535
+ varying vec3 vTangent;
1536
+ varying vec3 vBitangent;
1537
+ #endif
1538
+ #endif`,Bd=`#ifndef FLAT_SHADED
1539
+ vNormal = normalize( transformedNormal );
1540
+ #ifdef USE_TANGENT
1541
+ vTangent = normalize( transformedTangent );
1542
+ vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
1543
+ #endif
1544
+ #endif`,zd=`#ifdef USE_NORMALMAP
1545
+ uniform sampler2D normalMap;
1546
+ uniform vec2 normalScale;
1547
+ #endif
1548
+ #ifdef USE_NORMALMAP_OBJECTSPACE
1549
+ uniform mat3 normalMatrix;
1550
+ #endif
1551
+ #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
1552
+ mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
1553
+ vec3 q0 = dFdx( eye_pos.xyz );
1554
+ vec3 q1 = dFdy( eye_pos.xyz );
1555
+ vec2 st0 = dFdx( uv.st );
1556
+ vec2 st1 = dFdy( uv.st );
1557
+ vec3 N = surf_norm;
1558
+ vec3 q1perp = cross( q1, N );
1559
+ vec3 q0perp = cross( N, q0 );
1560
+ vec3 T = q1perp * st0.x + q0perp * st1.x;
1561
+ vec3 B = q1perp * st0.y + q0perp * st1.y;
1562
+ float det = max( dot( T, T ), dot( B, B ) );
1563
+ float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
1564
+ return mat3( T * scale, B * scale, N );
1565
+ }
1566
+ #endif`,kd=`#ifdef USE_CLEARCOAT
1567
+ vec3 clearcoatNormal = nonPerturbedNormal;
1568
+ #endif`,Hd=`#ifdef USE_CLEARCOAT_NORMALMAP
1569
+ vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
1570
+ clearcoatMapN.xy *= clearcoatNormalScale;
1571
+ clearcoatNormal = normalize( tbn2 * clearcoatMapN );
1572
+ #endif`,Vd=`#ifdef USE_CLEARCOATMAP
1573
+ uniform sampler2D clearcoatMap;
1574
+ #endif
1575
+ #ifdef USE_CLEARCOAT_NORMALMAP
1576
+ uniform sampler2D clearcoatNormalMap;
1577
+ uniform vec2 clearcoatNormalScale;
1578
+ #endif
1579
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
1580
+ uniform sampler2D clearcoatRoughnessMap;
1581
+ #endif`,Gd=`#ifdef USE_IRIDESCENCEMAP
1582
+ uniform sampler2D iridescenceMap;
1583
+ #endif
1584
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
1585
+ uniform sampler2D iridescenceThicknessMap;
1586
+ #endif`,Wd=`#ifdef OPAQUE
1587
+ diffuseColor.a = 1.0;
1588
+ #endif
1589
+ #ifdef USE_TRANSMISSION
1590
+ diffuseColor.a *= material.transmissionAlpha;
1591
+ #endif
1592
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Xd=`vec3 packNormalToRGB( const in vec3 normal ) {
1593
+ return normalize( normal ) * 0.5 + 0.5;
1594
+ }
1595
+ vec3 unpackRGBToNormal( const in vec3 rgb ) {
1596
+ return 2.0 * rgb.xyz - 1.0;
1597
+ }
1598
+ const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
1599
+ const float Inv255 = 1. / 255.;
1600
+ const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
1601
+ const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
1602
+ const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
1603
+ const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
1604
+ vec4 packDepthToRGBA( const in float v ) {
1605
+ if( v <= 0.0 )
1606
+ return vec4( 0., 0., 0., 0. );
1607
+ if( v >= 1.0 )
1608
+ return vec4( 1., 1., 1., 1. );
1609
+ float vuf;
1610
+ float af = modf( v * PackFactors.a, vuf );
1611
+ float bf = modf( vuf * ShiftRight8, vuf );
1612
+ float gf = modf( vuf * ShiftRight8, vuf );
1613
+ return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
1614
+ }
1615
+ vec3 packDepthToRGB( const in float v ) {
1616
+ if( v <= 0.0 )
1617
+ return vec3( 0., 0., 0. );
1618
+ if( v >= 1.0 )
1619
+ return vec3( 1., 1., 1. );
1620
+ float vuf;
1621
+ float bf = modf( v * PackFactors.b, vuf );
1622
+ float gf = modf( vuf * ShiftRight8, vuf );
1623
+ return vec3( vuf * Inv255, gf * PackUpscale, bf );
1624
+ }
1625
+ vec2 packDepthToRG( const in float v ) {
1626
+ if( v <= 0.0 )
1627
+ return vec2( 0., 0. );
1628
+ if( v >= 1.0 )
1629
+ return vec2( 1., 1. );
1630
+ float vuf;
1631
+ float gf = modf( v * 256., vuf );
1632
+ return vec2( vuf * Inv255, gf );
1633
+ }
1634
+ float unpackRGBAToDepth( const in vec4 v ) {
1635
+ return dot( v, UnpackFactors4 );
1636
+ }
1637
+ float unpackRGBToDepth( const in vec3 v ) {
1638
+ return dot( v, UnpackFactors3 );
1639
+ }
1640
+ float unpackRGToDepth( const in vec2 v ) {
1641
+ return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
1642
+ }
1643
+ vec4 pack2HalfToRGBA( const in vec2 v ) {
1644
+ vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
1645
+ return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
1646
+ }
1647
+ vec2 unpackRGBATo2Half( const in vec4 v ) {
1648
+ return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
1649
+ }
1650
+ float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
1651
+ return ( viewZ + near ) / ( near - far );
1652
+ }
1653
+ float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
1654
+ return depth * ( near - far ) - near;
1655
+ }
1656
+ float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
1657
+ return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
1658
+ }
1659
+ float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
1660
+ return ( near * far ) / ( ( far - near ) * depth - far );
1661
+ }`,qd=`#ifdef PREMULTIPLIED_ALPHA
1662
+ gl_FragColor.rgb *= gl_FragColor.a;
1663
+ #endif`,Yd=`vec4 mvPosition = vec4( transformed, 1.0 );
1664
+ #ifdef USE_BATCHING
1665
+ mvPosition = batchingMatrix * mvPosition;
1666
+ #endif
1667
+ #ifdef USE_INSTANCING
1668
+ mvPosition = instanceMatrix * mvPosition;
1669
+ #endif
1670
+ mvPosition = modelViewMatrix * mvPosition;
1671
+ gl_Position = projectionMatrix * mvPosition;`,Zd=`#ifdef DITHERING
1672
+ gl_FragColor.rgb = dithering( gl_FragColor.rgb );
1673
+ #endif`,$d=`#ifdef DITHERING
1674
+ vec3 dithering( vec3 color ) {
1675
+ float grid_position = rand( gl_FragCoord.xy );
1676
+ vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
1677
+ dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
1678
+ return color + dither_shift_RGB;
1679
+ }
1680
+ #endif`,Jd=`float roughnessFactor = roughness;
1681
+ #ifdef USE_ROUGHNESSMAP
1682
+ vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
1683
+ roughnessFactor *= texelRoughness.g;
1684
+ #endif`,Kd=`#ifdef USE_ROUGHNESSMAP
1685
+ uniform sampler2D roughnessMap;
1686
+ #endif`,jd=`#if NUM_SPOT_LIGHT_COORDS > 0
1687
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1688
+ #endif
1689
+ #if NUM_SPOT_LIGHT_MAPS > 0
1690
+ uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
1691
+ #endif
1692
+ #ifdef USE_SHADOWMAP
1693
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1694
+ uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
1695
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1696
+ struct DirectionalLightShadow {
1697
+ float shadowIntensity;
1698
+ float shadowBias;
1699
+ float shadowNormalBias;
1700
+ float shadowRadius;
1701
+ vec2 shadowMapSize;
1702
+ };
1703
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1704
+ #endif
1705
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1706
+ uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
1707
+ struct SpotLightShadow {
1708
+ float shadowIntensity;
1709
+ float shadowBias;
1710
+ float shadowNormalBias;
1711
+ float shadowRadius;
1712
+ vec2 shadowMapSize;
1713
+ };
1714
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1715
+ #endif
1716
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1717
+ uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
1718
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1719
+ struct PointLightShadow {
1720
+ float shadowIntensity;
1721
+ float shadowBias;
1722
+ float shadowNormalBias;
1723
+ float shadowRadius;
1724
+ vec2 shadowMapSize;
1725
+ float shadowCameraNear;
1726
+ float shadowCameraFar;
1727
+ };
1728
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1729
+ #endif
1730
+ float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
1731
+ float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
1732
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1733
+ return step( depth, compare );
1734
+ #else
1735
+ return step( compare, depth );
1736
+ #endif
1737
+ }
1738
+ vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
1739
+ return unpackRGBATo2Half( texture2D( shadow, uv ) );
1740
+ }
1741
+ float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
1742
+ float occlusion = 1.0;
1743
+ vec2 distribution = texture2DDistribution( shadow, uv );
1744
+ #ifdef USE_REVERSED_DEPTH_BUFFER
1745
+ float hard_shadow = step( distribution.x, compare );
1746
+ #else
1747
+ float hard_shadow = step( compare, distribution.x );
1748
+ #endif
1749
+ if ( hard_shadow != 1.0 ) {
1750
+ float distance = compare - distribution.x;
1751
+ float variance = max( 0.00000, distribution.y * distribution.y );
1752
+ 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 );
1753
+ }
1754
+ return occlusion;
1755
+ }
1756
+ float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
1757
+ float shadow = 1.0;
1758
+ shadowCoord.xyz /= shadowCoord.w;
1759
+ shadowCoord.z += shadowBias;
1760
+ bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
1761
+ bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
1762
+ if ( frustumTest ) {
1763
+ #if defined( SHADOWMAP_TYPE_PCF )
1764
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1765
+ float dx0 = - texelSize.x * shadowRadius;
1766
+ float dy0 = - texelSize.y * shadowRadius;
1767
+ float dx1 = + texelSize.x * shadowRadius;
1768
+ float dy1 = + texelSize.y * shadowRadius;
1769
+ float dx2 = dx0 / 2.0;
1770
+ float dy2 = dy0 / 2.0;
1771
+ float dx3 = dx1 / 2.0;
1772
+ float dy3 = dy1 / 2.0;
1773
+ shadow = (
1774
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
1775
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
1776
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
1777
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
1778
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
1779
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
1780
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
1781
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
1782
+ texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
1783
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
1784
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
1785
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
1786
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
1787
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
1788
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
1789
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
1790
+ texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
1791
+ ) * ( 1.0 / 17.0 );
1792
+ #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
1793
+ vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
1794
+ float dx = texelSize.x;
1795
+ float dy = texelSize.y;
1796
+ vec2 uv = shadowCoord.xy;
1797
+ vec2 f = fract( uv * shadowMapSize + 0.5 );
1798
+ uv -= f * texelSize;
1799
+ shadow = (
1800
+ texture2DCompare( shadowMap, uv, shadowCoord.z ) +
1801
+ texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
1802
+ texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
1803
+ texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
1804
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
1805
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
1806
+ f.x ) +
1807
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
1808
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
1809
+ f.x ) +
1810
+ mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
1811
+ texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
1812
+ f.y ) +
1813
+ mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
1814
+ texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
1815
+ f.y ) +
1816
+ mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
1817
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
1818
+ f.x ),
1819
+ mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
1820
+ texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
1821
+ f.x ),
1822
+ f.y )
1823
+ ) * ( 1.0 / 9.0 );
1824
+ #elif defined( SHADOWMAP_TYPE_VSM )
1825
+ shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
1826
+ #else
1827
+ shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
1828
+ #endif
1829
+ }
1830
+ return mix( 1.0, shadow, shadowIntensity );
1831
+ }
1832
+ vec2 cubeToUV( vec3 v, float texelSizeY ) {
1833
+ vec3 absV = abs( v );
1834
+ float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
1835
+ absV *= scaleToCube;
1836
+ v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
1837
+ vec2 planar = v.xy;
1838
+ float almostATexel = 1.5 * texelSizeY;
1839
+ float almostOne = 1.0 - almostATexel;
1840
+ if ( absV.z >= almostOne ) {
1841
+ if ( v.z > 0.0 )
1842
+ planar.x = 4.0 - v.x;
1843
+ } else if ( absV.x >= almostOne ) {
1844
+ float signX = sign( v.x );
1845
+ planar.x = v.z * signX + 2.0 * signX;
1846
+ } else if ( absV.y >= almostOne ) {
1847
+ float signY = sign( v.y );
1848
+ planar.x = v.x + 2.0 * signY + 2.0;
1849
+ planar.y = v.z * signY - 2.0;
1850
+ }
1851
+ return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
1852
+ }
1853
+ float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
1854
+ float shadow = 1.0;
1855
+ vec3 lightToPosition = shadowCoord.xyz;
1856
+
1857
+ float lightToPositionLength = length( lightToPosition );
1858
+ if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
1859
+ float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
1860
+ vec3 bd3D = normalize( lightToPosition );
1861
+ vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
1862
+ #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
1863
+ vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
1864
+ shadow = (
1865
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
1866
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
1867
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
1868
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
1869
+ texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
1870
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
1871
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
1872
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
1873
+ texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
1874
+ ) * ( 1.0 / 9.0 );
1875
+ #else
1876
+ shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
1877
+ #endif
1878
+ }
1879
+ return mix( 1.0, shadow, shadowIntensity );
1880
+ }
1881
+ #endif`,Qd=`#if NUM_SPOT_LIGHT_COORDS > 0
1882
+ uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
1883
+ varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
1884
+ #endif
1885
+ #ifdef USE_SHADOWMAP
1886
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1887
+ uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
1888
+ varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1889
+ struct DirectionalLightShadow {
1890
+ float shadowIntensity;
1891
+ float shadowBias;
1892
+ float shadowNormalBias;
1893
+ float shadowRadius;
1894
+ vec2 shadowMapSize;
1895
+ };
1896
+ uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
1897
+ #endif
1898
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1899
+ struct SpotLightShadow {
1900
+ float shadowIntensity;
1901
+ float shadowBias;
1902
+ float shadowNormalBias;
1903
+ float shadowRadius;
1904
+ vec2 shadowMapSize;
1905
+ };
1906
+ uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
1907
+ #endif
1908
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1909
+ uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
1910
+ varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
1911
+ struct PointLightShadow {
1912
+ float shadowIntensity;
1913
+ float shadowBias;
1914
+ float shadowNormalBias;
1915
+ float shadowRadius;
1916
+ vec2 shadowMapSize;
1917
+ float shadowCameraNear;
1918
+ float shadowCameraFar;
1919
+ };
1920
+ uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
1921
+ #endif
1922
+ #endif`,tf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
1923
+ vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
1924
+ vec4 shadowWorldPosition;
1925
+ #endif
1926
+ #if defined( USE_SHADOWMAP )
1927
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1928
+ #pragma unroll_loop_start
1929
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1930
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
1931
+ vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
1932
+ }
1933
+ #pragma unroll_loop_end
1934
+ #endif
1935
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1936
+ #pragma unroll_loop_start
1937
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1938
+ shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
1939
+ vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
1940
+ }
1941
+ #pragma unroll_loop_end
1942
+ #endif
1943
+ #endif
1944
+ #if NUM_SPOT_LIGHT_COORDS > 0
1945
+ #pragma unroll_loop_start
1946
+ for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
1947
+ shadowWorldPosition = worldPosition;
1948
+ #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
1949
+ shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
1950
+ #endif
1951
+ vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
1952
+ }
1953
+ #pragma unroll_loop_end
1954
+ #endif`,ef=`float getShadowMask() {
1955
+ float shadow = 1.0;
1956
+ #ifdef USE_SHADOWMAP
1957
+ #if NUM_DIR_LIGHT_SHADOWS > 0
1958
+ DirectionalLightShadow directionalLight;
1959
+ #pragma unroll_loop_start
1960
+ for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
1961
+ directionalLight = directionalLightShadows[ i ];
1962
+ shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
1963
+ }
1964
+ #pragma unroll_loop_end
1965
+ #endif
1966
+ #if NUM_SPOT_LIGHT_SHADOWS > 0
1967
+ SpotLightShadow spotLight;
1968
+ #pragma unroll_loop_start
1969
+ for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
1970
+ spotLight = spotLightShadows[ i ];
1971
+ shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
1972
+ }
1973
+ #pragma unroll_loop_end
1974
+ #endif
1975
+ #if NUM_POINT_LIGHT_SHADOWS > 0
1976
+ PointLightShadow pointLight;
1977
+ #pragma unroll_loop_start
1978
+ for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
1979
+ pointLight = pointLightShadows[ i ];
1980
+ shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
1981
+ }
1982
+ #pragma unroll_loop_end
1983
+ #endif
1984
+ #endif
1985
+ return shadow;
1986
+ }`,nf=`#ifdef USE_SKINNING
1987
+ mat4 boneMatX = getBoneMatrix( skinIndex.x );
1988
+ mat4 boneMatY = getBoneMatrix( skinIndex.y );
1989
+ mat4 boneMatZ = getBoneMatrix( skinIndex.z );
1990
+ mat4 boneMatW = getBoneMatrix( skinIndex.w );
1991
+ #endif`,sf=`#ifdef USE_SKINNING
1992
+ uniform mat4 bindMatrix;
1993
+ uniform mat4 bindMatrixInverse;
1994
+ uniform highp sampler2D boneTexture;
1995
+ mat4 getBoneMatrix( const in float i ) {
1996
+ int size = textureSize( boneTexture, 0 ).x;
1997
+ int j = int( i ) * 4;
1998
+ int x = j % size;
1999
+ int y = j / size;
2000
+ vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
2001
+ vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
2002
+ vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
2003
+ vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
2004
+ return mat4( v1, v2, v3, v4 );
2005
+ }
2006
+ #endif`,rf=`#ifdef USE_SKINNING
2007
+ vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
2008
+ vec4 skinned = vec4( 0.0 );
2009
+ skinned += boneMatX * skinVertex * skinWeight.x;
2010
+ skinned += boneMatY * skinVertex * skinWeight.y;
2011
+ skinned += boneMatZ * skinVertex * skinWeight.z;
2012
+ skinned += boneMatW * skinVertex * skinWeight.w;
2013
+ transformed = ( bindMatrixInverse * skinned ).xyz;
2014
+ #endif`,af=`#ifdef USE_SKINNING
2015
+ mat4 skinMatrix = mat4( 0.0 );
2016
+ skinMatrix += skinWeight.x * boneMatX;
2017
+ skinMatrix += skinWeight.y * boneMatY;
2018
+ skinMatrix += skinWeight.z * boneMatZ;
2019
+ skinMatrix += skinWeight.w * boneMatW;
2020
+ skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
2021
+ objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
2022
+ #ifdef USE_TANGENT
2023
+ objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
2024
+ #endif
2025
+ #endif`,of=`float specularStrength;
2026
+ #ifdef USE_SPECULARMAP
2027
+ vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
2028
+ specularStrength = texelSpecular.r;
2029
+ #else
2030
+ specularStrength = 1.0;
2031
+ #endif`,lf=`#ifdef USE_SPECULARMAP
2032
+ uniform sampler2D specularMap;
2033
+ #endif`,cf=`#if defined( TONE_MAPPING )
2034
+ gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2035
+ #endif`,hf=`#ifndef saturate
2036
+ #define saturate( a ) clamp( a, 0.0, 1.0 )
2037
+ #endif
2038
+ uniform float toneMappingExposure;
2039
+ vec3 LinearToneMapping( vec3 color ) {
2040
+ return saturate( toneMappingExposure * color );
2041
+ }
2042
+ vec3 ReinhardToneMapping( vec3 color ) {
2043
+ color *= toneMappingExposure;
2044
+ return saturate( color / ( vec3( 1.0 ) + color ) );
2045
+ }
2046
+ vec3 CineonToneMapping( vec3 color ) {
2047
+ color *= toneMappingExposure;
2048
+ color = max( vec3( 0.0 ), color - 0.004 );
2049
+ return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
2050
+ }
2051
+ vec3 RRTAndODTFit( vec3 v ) {
2052
+ vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
2053
+ vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
2054
+ return a / b;
2055
+ }
2056
+ vec3 ACESFilmicToneMapping( vec3 color ) {
2057
+ const mat3 ACESInputMat = mat3(
2058
+ vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
2059
+ vec3( 0.04823, 0.01566, 0.83777 )
2060
+ );
2061
+ const mat3 ACESOutputMat = mat3(
2062
+ vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
2063
+ vec3( -0.07367, -0.00605, 1.07602 )
2064
+ );
2065
+ color *= toneMappingExposure / 0.6;
2066
+ color = ACESInputMat * color;
2067
+ color = RRTAndODTFit( color );
2068
+ color = ACESOutputMat * color;
2069
+ return saturate( color );
2070
+ }
2071
+ const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
2072
+ vec3( 1.6605, - 0.1246, - 0.0182 ),
2073
+ vec3( - 0.5876, 1.1329, - 0.1006 ),
2074
+ vec3( - 0.0728, - 0.0083, 1.1187 )
2075
+ );
2076
+ const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
2077
+ vec3( 0.6274, 0.0691, 0.0164 ),
2078
+ vec3( 0.3293, 0.9195, 0.0880 ),
2079
+ vec3( 0.0433, 0.0113, 0.8956 )
2080
+ );
2081
+ vec3 agxDefaultContrastApprox( vec3 x ) {
2082
+ vec3 x2 = x * x;
2083
+ vec3 x4 = x2 * x2;
2084
+ return + 15.5 * x4 * x2
2085
+ - 40.14 * x4 * x
2086
+ + 31.96 * x4
2087
+ - 6.868 * x2 * x
2088
+ + 0.4298 * x2
2089
+ + 0.1191 * x
2090
+ - 0.00232;
2091
+ }
2092
+ vec3 AgXToneMapping( vec3 color ) {
2093
+ const mat3 AgXInsetMatrix = mat3(
2094
+ vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
2095
+ vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
2096
+ vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
2097
+ );
2098
+ const mat3 AgXOutsetMatrix = mat3(
2099
+ vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
2100
+ vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
2101
+ vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
2102
+ );
2103
+ const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
2104
+ color *= toneMappingExposure;
2105
+ color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
2106
+ color = AgXInsetMatrix * color;
2107
+ color = max( color, 1e-10 ); color = log2( color );
2108
+ color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
2109
+ color = clamp( color, 0.0, 1.0 );
2110
+ color = agxDefaultContrastApprox( color );
2111
+ color = AgXOutsetMatrix * color;
2112
+ color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
2113
+ color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
2114
+ color = clamp( color, 0.0, 1.0 );
2115
+ return color;
2116
+ }
2117
+ vec3 NeutralToneMapping( vec3 color ) {
2118
+ const float StartCompression = 0.8 - 0.04;
2119
+ const float Desaturation = 0.15;
2120
+ color *= toneMappingExposure;
2121
+ float x = min( color.r, min( color.g, color.b ) );
2122
+ float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
2123
+ color -= offset;
2124
+ float peak = max( color.r, max( color.g, color.b ) );
2125
+ if ( peak < StartCompression ) return color;
2126
+ float d = 1. - StartCompression;
2127
+ float newPeak = 1. - d * d / ( peak + d - StartCompression );
2128
+ color *= newPeak / peak;
2129
+ float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
2130
+ return mix( color, vec3( newPeak ), g );
2131
+ }
2132
+ vec3 CustomToneMapping( vec3 color ) { return color; }`,uf=`#ifdef USE_TRANSMISSION
2133
+ material.transmission = transmission;
2134
+ material.transmissionAlpha = 1.0;
2135
+ material.thickness = thickness;
2136
+ material.attenuationDistance = attenuationDistance;
2137
+ material.attenuationColor = attenuationColor;
2138
+ #ifdef USE_TRANSMISSIONMAP
2139
+ material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
2140
+ #endif
2141
+ #ifdef USE_THICKNESSMAP
2142
+ material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
2143
+ #endif
2144
+ vec3 pos = vWorldPosition;
2145
+ vec3 v = normalize( cameraPosition - pos );
2146
+ vec3 n = inverseTransformDirection( normal, viewMatrix );
2147
+ vec4 transmitted = getIBLVolumeRefraction(
2148
+ n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
2149
+ pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
2150
+ material.attenuationColor, material.attenuationDistance );
2151
+ material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
2152
+ totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
2153
+ #endif`,df=`#ifdef USE_TRANSMISSION
2154
+ uniform float transmission;
2155
+ uniform float thickness;
2156
+ uniform float attenuationDistance;
2157
+ uniform vec3 attenuationColor;
2158
+ #ifdef USE_TRANSMISSIONMAP
2159
+ uniform sampler2D transmissionMap;
2160
+ #endif
2161
+ #ifdef USE_THICKNESSMAP
2162
+ uniform sampler2D thicknessMap;
2163
+ #endif
2164
+ uniform vec2 transmissionSamplerSize;
2165
+ uniform sampler2D transmissionSamplerMap;
2166
+ uniform mat4 modelMatrix;
2167
+ uniform mat4 projectionMatrix;
2168
+ varying vec3 vWorldPosition;
2169
+ float w0( float a ) {
2170
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
2171
+ }
2172
+ float w1( float a ) {
2173
+ return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
2174
+ }
2175
+ float w2( float a ){
2176
+ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
2177
+ }
2178
+ float w3( float a ) {
2179
+ return ( 1.0 / 6.0 ) * ( a * a * a );
2180
+ }
2181
+ float g0( float a ) {
2182
+ return w0( a ) + w1( a );
2183
+ }
2184
+ float g1( float a ) {
2185
+ return w2( a ) + w3( a );
2186
+ }
2187
+ float h0( float a ) {
2188
+ return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
2189
+ }
2190
+ float h1( float a ) {
2191
+ return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
2192
+ }
2193
+ vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
2194
+ uv = uv * texelSize.zw + 0.5;
2195
+ vec2 iuv = floor( uv );
2196
+ vec2 fuv = fract( uv );
2197
+ float g0x = g0( fuv.x );
2198
+ float g1x = g1( fuv.x );
2199
+ float h0x = h0( fuv.x );
2200
+ float h1x = h1( fuv.x );
2201
+ float h0y = h0( fuv.y );
2202
+ float h1y = h1( fuv.y );
2203
+ vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2204
+ vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
2205
+ vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2206
+ vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
2207
+ return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
2208
+ g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
2209
+ }
2210
+ vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
2211
+ vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
2212
+ vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
2213
+ vec2 fLodSizeInv = 1.0 / fLodSize;
2214
+ vec2 cLodSizeInv = 1.0 / cLodSize;
2215
+ vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
2216
+ vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
2217
+ return mix( fSample, cSample, fract( lod ) );
2218
+ }
2219
+ vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
2220
+ vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
2221
+ vec3 modelScale;
2222
+ modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
2223
+ modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
2224
+ modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
2225
+ return normalize( refractionVector ) * thickness * modelScale;
2226
+ }
2227
+ float applyIorToRoughness( const in float roughness, const in float ior ) {
2228
+ return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
2229
+ }
2230
+ vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
2231
+ float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
2232
+ return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
2233
+ }
2234
+ vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
2235
+ if ( isinf( attenuationDistance ) ) {
2236
+ return vec3( 1.0 );
2237
+ } else {
2238
+ vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
2239
+ vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
2240
+ }
2241
+ }
2242
+ vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
2243
+ const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
2244
+ const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
2245
+ const in vec3 attenuationColor, const in float attenuationDistance ) {
2246
+ vec4 transmittedLight;
2247
+ vec3 transmittance;
2248
+ #ifdef USE_DISPERSION
2249
+ float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
2250
+ vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
2251
+ for ( int i = 0; i < 3; i ++ ) {
2252
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
2253
+ vec3 refractedRayExit = position + transmissionRay;
2254
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2255
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2256
+ refractionCoords += 1.0;
2257
+ refractionCoords /= 2.0;
2258
+ vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
2259
+ transmittedLight[ i ] = transmissionSample[ i ];
2260
+ transmittedLight.a += transmissionSample.a;
2261
+ transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
2262
+ }
2263
+ transmittedLight.a /= 3.0;
2264
+ #else
2265
+ vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
2266
+ vec3 refractedRayExit = position + transmissionRay;
2267
+ vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
2268
+ vec2 refractionCoords = ndcPos.xy / ndcPos.w;
2269
+ refractionCoords += 1.0;
2270
+ refractionCoords /= 2.0;
2271
+ transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
2272
+ transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
2273
+ #endif
2274
+ vec3 attenuatedColor = transmittance * transmittedLight.rgb;
2275
+ vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
2276
+ float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
2277
+ return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
2278
+ }
2279
+ #endif`,ff=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2280
+ varying vec2 vUv;
2281
+ #endif
2282
+ #ifdef USE_MAP
2283
+ varying vec2 vMapUv;
2284
+ #endif
2285
+ #ifdef USE_ALPHAMAP
2286
+ varying vec2 vAlphaMapUv;
2287
+ #endif
2288
+ #ifdef USE_LIGHTMAP
2289
+ varying vec2 vLightMapUv;
2290
+ #endif
2291
+ #ifdef USE_AOMAP
2292
+ varying vec2 vAoMapUv;
2293
+ #endif
2294
+ #ifdef USE_BUMPMAP
2295
+ varying vec2 vBumpMapUv;
2296
+ #endif
2297
+ #ifdef USE_NORMALMAP
2298
+ varying vec2 vNormalMapUv;
2299
+ #endif
2300
+ #ifdef USE_EMISSIVEMAP
2301
+ varying vec2 vEmissiveMapUv;
2302
+ #endif
2303
+ #ifdef USE_METALNESSMAP
2304
+ varying vec2 vMetalnessMapUv;
2305
+ #endif
2306
+ #ifdef USE_ROUGHNESSMAP
2307
+ varying vec2 vRoughnessMapUv;
2308
+ #endif
2309
+ #ifdef USE_ANISOTROPYMAP
2310
+ varying vec2 vAnisotropyMapUv;
2311
+ #endif
2312
+ #ifdef USE_CLEARCOATMAP
2313
+ varying vec2 vClearcoatMapUv;
2314
+ #endif
2315
+ #ifdef USE_CLEARCOAT_NORMALMAP
2316
+ varying vec2 vClearcoatNormalMapUv;
2317
+ #endif
2318
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2319
+ varying vec2 vClearcoatRoughnessMapUv;
2320
+ #endif
2321
+ #ifdef USE_IRIDESCENCEMAP
2322
+ varying vec2 vIridescenceMapUv;
2323
+ #endif
2324
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2325
+ varying vec2 vIridescenceThicknessMapUv;
2326
+ #endif
2327
+ #ifdef USE_SHEEN_COLORMAP
2328
+ varying vec2 vSheenColorMapUv;
2329
+ #endif
2330
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2331
+ varying vec2 vSheenRoughnessMapUv;
2332
+ #endif
2333
+ #ifdef USE_SPECULARMAP
2334
+ varying vec2 vSpecularMapUv;
2335
+ #endif
2336
+ #ifdef USE_SPECULAR_COLORMAP
2337
+ varying vec2 vSpecularColorMapUv;
2338
+ #endif
2339
+ #ifdef USE_SPECULAR_INTENSITYMAP
2340
+ varying vec2 vSpecularIntensityMapUv;
2341
+ #endif
2342
+ #ifdef USE_TRANSMISSIONMAP
2343
+ uniform mat3 transmissionMapTransform;
2344
+ varying vec2 vTransmissionMapUv;
2345
+ #endif
2346
+ #ifdef USE_THICKNESSMAP
2347
+ uniform mat3 thicknessMapTransform;
2348
+ varying vec2 vThicknessMapUv;
2349
+ #endif`,pf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2350
+ varying vec2 vUv;
2351
+ #endif
2352
+ #ifdef USE_MAP
2353
+ uniform mat3 mapTransform;
2354
+ varying vec2 vMapUv;
2355
+ #endif
2356
+ #ifdef USE_ALPHAMAP
2357
+ uniform mat3 alphaMapTransform;
2358
+ varying vec2 vAlphaMapUv;
2359
+ #endif
2360
+ #ifdef USE_LIGHTMAP
2361
+ uniform mat3 lightMapTransform;
2362
+ varying vec2 vLightMapUv;
2363
+ #endif
2364
+ #ifdef USE_AOMAP
2365
+ uniform mat3 aoMapTransform;
2366
+ varying vec2 vAoMapUv;
2367
+ #endif
2368
+ #ifdef USE_BUMPMAP
2369
+ uniform mat3 bumpMapTransform;
2370
+ varying vec2 vBumpMapUv;
2371
+ #endif
2372
+ #ifdef USE_NORMALMAP
2373
+ uniform mat3 normalMapTransform;
2374
+ varying vec2 vNormalMapUv;
2375
+ #endif
2376
+ #ifdef USE_DISPLACEMENTMAP
2377
+ uniform mat3 displacementMapTransform;
2378
+ varying vec2 vDisplacementMapUv;
2379
+ #endif
2380
+ #ifdef USE_EMISSIVEMAP
2381
+ uniform mat3 emissiveMapTransform;
2382
+ varying vec2 vEmissiveMapUv;
2383
+ #endif
2384
+ #ifdef USE_METALNESSMAP
2385
+ uniform mat3 metalnessMapTransform;
2386
+ varying vec2 vMetalnessMapUv;
2387
+ #endif
2388
+ #ifdef USE_ROUGHNESSMAP
2389
+ uniform mat3 roughnessMapTransform;
2390
+ varying vec2 vRoughnessMapUv;
2391
+ #endif
2392
+ #ifdef USE_ANISOTROPYMAP
2393
+ uniform mat3 anisotropyMapTransform;
2394
+ varying vec2 vAnisotropyMapUv;
2395
+ #endif
2396
+ #ifdef USE_CLEARCOATMAP
2397
+ uniform mat3 clearcoatMapTransform;
2398
+ varying vec2 vClearcoatMapUv;
2399
+ #endif
2400
+ #ifdef USE_CLEARCOAT_NORMALMAP
2401
+ uniform mat3 clearcoatNormalMapTransform;
2402
+ varying vec2 vClearcoatNormalMapUv;
2403
+ #endif
2404
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2405
+ uniform mat3 clearcoatRoughnessMapTransform;
2406
+ varying vec2 vClearcoatRoughnessMapUv;
2407
+ #endif
2408
+ #ifdef USE_SHEEN_COLORMAP
2409
+ uniform mat3 sheenColorMapTransform;
2410
+ varying vec2 vSheenColorMapUv;
2411
+ #endif
2412
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2413
+ uniform mat3 sheenRoughnessMapTransform;
2414
+ varying vec2 vSheenRoughnessMapUv;
2415
+ #endif
2416
+ #ifdef USE_IRIDESCENCEMAP
2417
+ uniform mat3 iridescenceMapTransform;
2418
+ varying vec2 vIridescenceMapUv;
2419
+ #endif
2420
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2421
+ uniform mat3 iridescenceThicknessMapTransform;
2422
+ varying vec2 vIridescenceThicknessMapUv;
2423
+ #endif
2424
+ #ifdef USE_SPECULARMAP
2425
+ uniform mat3 specularMapTransform;
2426
+ varying vec2 vSpecularMapUv;
2427
+ #endif
2428
+ #ifdef USE_SPECULAR_COLORMAP
2429
+ uniform mat3 specularColorMapTransform;
2430
+ varying vec2 vSpecularColorMapUv;
2431
+ #endif
2432
+ #ifdef USE_SPECULAR_INTENSITYMAP
2433
+ uniform mat3 specularIntensityMapTransform;
2434
+ varying vec2 vSpecularIntensityMapUv;
2435
+ #endif
2436
+ #ifdef USE_TRANSMISSIONMAP
2437
+ uniform mat3 transmissionMapTransform;
2438
+ varying vec2 vTransmissionMapUv;
2439
+ #endif
2440
+ #ifdef USE_THICKNESSMAP
2441
+ uniform mat3 thicknessMapTransform;
2442
+ varying vec2 vThicknessMapUv;
2443
+ #endif`,mf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
2444
+ vUv = vec3( uv, 1 ).xy;
2445
+ #endif
2446
+ #ifdef USE_MAP
2447
+ vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
2448
+ #endif
2449
+ #ifdef USE_ALPHAMAP
2450
+ vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
2451
+ #endif
2452
+ #ifdef USE_LIGHTMAP
2453
+ vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
2454
+ #endif
2455
+ #ifdef USE_AOMAP
2456
+ vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
2457
+ #endif
2458
+ #ifdef USE_BUMPMAP
2459
+ vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
2460
+ #endif
2461
+ #ifdef USE_NORMALMAP
2462
+ vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
2463
+ #endif
2464
+ #ifdef USE_DISPLACEMENTMAP
2465
+ vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
2466
+ #endif
2467
+ #ifdef USE_EMISSIVEMAP
2468
+ vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
2469
+ #endif
2470
+ #ifdef USE_METALNESSMAP
2471
+ vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
2472
+ #endif
2473
+ #ifdef USE_ROUGHNESSMAP
2474
+ vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
2475
+ #endif
2476
+ #ifdef USE_ANISOTROPYMAP
2477
+ vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
2478
+ #endif
2479
+ #ifdef USE_CLEARCOATMAP
2480
+ vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
2481
+ #endif
2482
+ #ifdef USE_CLEARCOAT_NORMALMAP
2483
+ vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
2484
+ #endif
2485
+ #ifdef USE_CLEARCOAT_ROUGHNESSMAP
2486
+ vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
2487
+ #endif
2488
+ #ifdef USE_IRIDESCENCEMAP
2489
+ vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
2490
+ #endif
2491
+ #ifdef USE_IRIDESCENCE_THICKNESSMAP
2492
+ vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
2493
+ #endif
2494
+ #ifdef USE_SHEEN_COLORMAP
2495
+ vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
2496
+ #endif
2497
+ #ifdef USE_SHEEN_ROUGHNESSMAP
2498
+ vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
2499
+ #endif
2500
+ #ifdef USE_SPECULARMAP
2501
+ vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
2502
+ #endif
2503
+ #ifdef USE_SPECULAR_COLORMAP
2504
+ vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
2505
+ #endif
2506
+ #ifdef USE_SPECULAR_INTENSITYMAP
2507
+ vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
2508
+ #endif
2509
+ #ifdef USE_TRANSMISSIONMAP
2510
+ vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
2511
+ #endif
2512
+ #ifdef USE_THICKNESSMAP
2513
+ vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
2514
+ #endif`,gf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
2515
+ vec4 worldPosition = vec4( transformed, 1.0 );
2516
+ #ifdef USE_BATCHING
2517
+ worldPosition = batchingMatrix * worldPosition;
2518
+ #endif
2519
+ #ifdef USE_INSTANCING
2520
+ worldPosition = instanceMatrix * worldPosition;
2521
+ #endif
2522
+ worldPosition = modelMatrix * worldPosition;
2523
+ #endif`,_f=`varying vec2 vUv;
2524
+ uniform mat3 uvTransform;
2525
+ void main() {
2526
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2527
+ gl_Position = vec4( position.xy, 1.0, 1.0 );
2528
+ }`,xf=`uniform sampler2D t2D;
2529
+ uniform float backgroundIntensity;
2530
+ varying vec2 vUv;
2531
+ void main() {
2532
+ vec4 texColor = texture2D( t2D, vUv );
2533
+ #ifdef DECODE_VIDEO_TEXTURE
2534
+ 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 );
2535
+ #endif
2536
+ texColor.rgb *= backgroundIntensity;
2537
+ gl_FragColor = texColor;
2538
+ #include <tonemapping_fragment>
2539
+ #include <colorspace_fragment>
2540
+ }`,yf=`varying vec3 vWorldDirection;
2541
+ #include <common>
2542
+ void main() {
2543
+ vWorldDirection = transformDirection( position, modelMatrix );
2544
+ #include <begin_vertex>
2545
+ #include <project_vertex>
2546
+ gl_Position.z = gl_Position.w;
2547
+ }`,vf=`#ifdef ENVMAP_TYPE_CUBE
2548
+ uniform samplerCube envMap;
2549
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2550
+ uniform sampler2D envMap;
2551
+ #endif
2552
+ uniform float flipEnvMap;
2553
+ uniform float backgroundBlurriness;
2554
+ uniform float backgroundIntensity;
2555
+ uniform mat3 backgroundRotation;
2556
+ varying vec3 vWorldDirection;
2557
+ #include <cube_uv_reflection_fragment>
2558
+ void main() {
2559
+ #ifdef ENVMAP_TYPE_CUBE
2560
+ vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
2561
+ #elif defined( ENVMAP_TYPE_CUBE_UV )
2562
+ vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
2563
+ #else
2564
+ vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
2565
+ #endif
2566
+ texColor.rgb *= backgroundIntensity;
2567
+ gl_FragColor = texColor;
2568
+ #include <tonemapping_fragment>
2569
+ #include <colorspace_fragment>
2570
+ }`,Mf=`varying vec3 vWorldDirection;
2571
+ #include <common>
2572
+ void main() {
2573
+ vWorldDirection = transformDirection( position, modelMatrix );
2574
+ #include <begin_vertex>
2575
+ #include <project_vertex>
2576
+ gl_Position.z = gl_Position.w;
2577
+ }`,bf=`uniform samplerCube tCube;
2578
+ uniform float tFlip;
2579
+ uniform float opacity;
2580
+ varying vec3 vWorldDirection;
2581
+ void main() {
2582
+ vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
2583
+ gl_FragColor = texColor;
2584
+ gl_FragColor.a *= opacity;
2585
+ #include <tonemapping_fragment>
2586
+ #include <colorspace_fragment>
2587
+ }`,Sf=`#include <common>
2588
+ #include <batching_pars_vertex>
2589
+ #include <uv_pars_vertex>
2590
+ #include <displacementmap_pars_vertex>
2591
+ #include <morphtarget_pars_vertex>
2592
+ #include <skinning_pars_vertex>
2593
+ #include <logdepthbuf_pars_vertex>
2594
+ #include <clipping_planes_pars_vertex>
2595
+ varying vec2 vHighPrecisionZW;
2596
+ void main() {
2597
+ #include <uv_vertex>
2598
+ #include <batching_vertex>
2599
+ #include <skinbase_vertex>
2600
+ #include <morphinstance_vertex>
2601
+ #ifdef USE_DISPLACEMENTMAP
2602
+ #include <beginnormal_vertex>
2603
+ #include <morphnormal_vertex>
2604
+ #include <skinnormal_vertex>
2605
+ #endif
2606
+ #include <begin_vertex>
2607
+ #include <morphtarget_vertex>
2608
+ #include <skinning_vertex>
2609
+ #include <displacementmap_vertex>
2610
+ #include <project_vertex>
2611
+ #include <logdepthbuf_vertex>
2612
+ #include <clipping_planes_vertex>
2613
+ vHighPrecisionZW = gl_Position.zw;
2614
+ }`,Ef=`#if DEPTH_PACKING == 3200
2615
+ uniform float opacity;
2616
+ #endif
2617
+ #include <common>
2618
+ #include <packing>
2619
+ #include <uv_pars_fragment>
2620
+ #include <map_pars_fragment>
2621
+ #include <alphamap_pars_fragment>
2622
+ #include <alphatest_pars_fragment>
2623
+ #include <alphahash_pars_fragment>
2624
+ #include <logdepthbuf_pars_fragment>
2625
+ #include <clipping_planes_pars_fragment>
2626
+ varying vec2 vHighPrecisionZW;
2627
+ void main() {
2628
+ vec4 diffuseColor = vec4( 1.0 );
2629
+ #include <clipping_planes_fragment>
2630
+ #if DEPTH_PACKING == 3200
2631
+ diffuseColor.a = opacity;
2632
+ #endif
2633
+ #include <map_fragment>
2634
+ #include <alphamap_fragment>
2635
+ #include <alphatest_fragment>
2636
+ #include <alphahash_fragment>
2637
+ #include <logdepthbuf_fragment>
2638
+ #ifdef USE_REVERSED_DEPTH_BUFFER
2639
+ float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
2640
+ #else
2641
+ float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
2642
+ #endif
2643
+ #if DEPTH_PACKING == 3200
2644
+ gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
2645
+ #elif DEPTH_PACKING == 3201
2646
+ gl_FragColor = packDepthToRGBA( fragCoordZ );
2647
+ #elif DEPTH_PACKING == 3202
2648
+ gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
2649
+ #elif DEPTH_PACKING == 3203
2650
+ gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
2651
+ #endif
2652
+ }`,Tf=`#define DISTANCE
2653
+ varying vec3 vWorldPosition;
2654
+ #include <common>
2655
+ #include <batching_pars_vertex>
2656
+ #include <uv_pars_vertex>
2657
+ #include <displacementmap_pars_vertex>
2658
+ #include <morphtarget_pars_vertex>
2659
+ #include <skinning_pars_vertex>
2660
+ #include <clipping_planes_pars_vertex>
2661
+ void main() {
2662
+ #include <uv_vertex>
2663
+ #include <batching_vertex>
2664
+ #include <skinbase_vertex>
2665
+ #include <morphinstance_vertex>
2666
+ #ifdef USE_DISPLACEMENTMAP
2667
+ #include <beginnormal_vertex>
2668
+ #include <morphnormal_vertex>
2669
+ #include <skinnormal_vertex>
2670
+ #endif
2671
+ #include <begin_vertex>
2672
+ #include <morphtarget_vertex>
2673
+ #include <skinning_vertex>
2674
+ #include <displacementmap_vertex>
2675
+ #include <project_vertex>
2676
+ #include <worldpos_vertex>
2677
+ #include <clipping_planes_vertex>
2678
+ vWorldPosition = worldPosition.xyz;
2679
+ }`,wf=`#define DISTANCE
2680
+ uniform vec3 referencePosition;
2681
+ uniform float nearDistance;
2682
+ uniform float farDistance;
2683
+ varying vec3 vWorldPosition;
2684
+ #include <common>
2685
+ #include <packing>
2686
+ #include <uv_pars_fragment>
2687
+ #include <map_pars_fragment>
2688
+ #include <alphamap_pars_fragment>
2689
+ #include <alphatest_pars_fragment>
2690
+ #include <alphahash_pars_fragment>
2691
+ #include <clipping_planes_pars_fragment>
2692
+ void main () {
2693
+ vec4 diffuseColor = vec4( 1.0 );
2694
+ #include <clipping_planes_fragment>
2695
+ #include <map_fragment>
2696
+ #include <alphamap_fragment>
2697
+ #include <alphatest_fragment>
2698
+ #include <alphahash_fragment>
2699
+ float dist = length( vWorldPosition - referencePosition );
2700
+ dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
2701
+ dist = saturate( dist );
2702
+ gl_FragColor = packDepthToRGBA( dist );
2703
+ }`,Af=`varying vec3 vWorldDirection;
2704
+ #include <common>
2705
+ void main() {
2706
+ vWorldDirection = transformDirection( position, modelMatrix );
2707
+ #include <begin_vertex>
2708
+ #include <project_vertex>
2709
+ }`,Rf=`uniform sampler2D tEquirect;
2710
+ varying vec3 vWorldDirection;
2711
+ #include <common>
2712
+ void main() {
2713
+ vec3 direction = normalize( vWorldDirection );
2714
+ vec2 sampleUV = equirectUv( direction );
2715
+ gl_FragColor = texture2D( tEquirect, sampleUV );
2716
+ #include <tonemapping_fragment>
2717
+ #include <colorspace_fragment>
2718
+ }`,Cf=`uniform float scale;
2719
+ attribute float lineDistance;
2720
+ varying float vLineDistance;
2721
+ #include <common>
2722
+ #include <uv_pars_vertex>
2723
+ #include <color_pars_vertex>
2724
+ #include <fog_pars_vertex>
2725
+ #include <morphtarget_pars_vertex>
2726
+ #include <logdepthbuf_pars_vertex>
2727
+ #include <clipping_planes_pars_vertex>
2728
+ void main() {
2729
+ vLineDistance = scale * lineDistance;
2730
+ #include <uv_vertex>
2731
+ #include <color_vertex>
2732
+ #include <morphinstance_vertex>
2733
+ #include <morphcolor_vertex>
2734
+ #include <begin_vertex>
2735
+ #include <morphtarget_vertex>
2736
+ #include <project_vertex>
2737
+ #include <logdepthbuf_vertex>
2738
+ #include <clipping_planes_vertex>
2739
+ #include <fog_vertex>
2740
+ }`,Pf=`uniform vec3 diffuse;
2741
+ uniform float opacity;
2742
+ uniform float dashSize;
2743
+ uniform float totalSize;
2744
+ varying float vLineDistance;
2745
+ #include <common>
2746
+ #include <color_pars_fragment>
2747
+ #include <uv_pars_fragment>
2748
+ #include <map_pars_fragment>
2749
+ #include <fog_pars_fragment>
2750
+ #include <logdepthbuf_pars_fragment>
2751
+ #include <clipping_planes_pars_fragment>
2752
+ void main() {
2753
+ vec4 diffuseColor = vec4( diffuse, opacity );
2754
+ #include <clipping_planes_fragment>
2755
+ if ( mod( vLineDistance, totalSize ) > dashSize ) {
2756
+ discard;
2757
+ }
2758
+ vec3 outgoingLight = vec3( 0.0 );
2759
+ #include <logdepthbuf_fragment>
2760
+ #include <map_fragment>
2761
+ #include <color_fragment>
2762
+ outgoingLight = diffuseColor.rgb;
2763
+ #include <opaque_fragment>
2764
+ #include <tonemapping_fragment>
2765
+ #include <colorspace_fragment>
2766
+ #include <fog_fragment>
2767
+ #include <premultiplied_alpha_fragment>
2768
+ }`,If=`#include <common>
2769
+ #include <batching_pars_vertex>
2770
+ #include <uv_pars_vertex>
2771
+ #include <envmap_pars_vertex>
2772
+ #include <color_pars_vertex>
2773
+ #include <fog_pars_vertex>
2774
+ #include <morphtarget_pars_vertex>
2775
+ #include <skinning_pars_vertex>
2776
+ #include <logdepthbuf_pars_vertex>
2777
+ #include <clipping_planes_pars_vertex>
2778
+ void main() {
2779
+ #include <uv_vertex>
2780
+ #include <color_vertex>
2781
+ #include <morphinstance_vertex>
2782
+ #include <morphcolor_vertex>
2783
+ #include <batching_vertex>
2784
+ #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
2785
+ #include <beginnormal_vertex>
2786
+ #include <morphnormal_vertex>
2787
+ #include <skinbase_vertex>
2788
+ #include <skinnormal_vertex>
2789
+ #include <defaultnormal_vertex>
2790
+ #endif
2791
+ #include <begin_vertex>
2792
+ #include <morphtarget_vertex>
2793
+ #include <skinning_vertex>
2794
+ #include <project_vertex>
2795
+ #include <logdepthbuf_vertex>
2796
+ #include <clipping_planes_vertex>
2797
+ #include <worldpos_vertex>
2798
+ #include <envmap_vertex>
2799
+ #include <fog_vertex>
2800
+ }`,Lf=`uniform vec3 diffuse;
2801
+ uniform float opacity;
2802
+ #ifndef FLAT_SHADED
2803
+ varying vec3 vNormal;
2804
+ #endif
2805
+ #include <common>
2806
+ #include <dithering_pars_fragment>
2807
+ #include <color_pars_fragment>
2808
+ #include <uv_pars_fragment>
2809
+ #include <map_pars_fragment>
2810
+ #include <alphamap_pars_fragment>
2811
+ #include <alphatest_pars_fragment>
2812
+ #include <alphahash_pars_fragment>
2813
+ #include <aomap_pars_fragment>
2814
+ #include <lightmap_pars_fragment>
2815
+ #include <envmap_common_pars_fragment>
2816
+ #include <envmap_pars_fragment>
2817
+ #include <fog_pars_fragment>
2818
+ #include <specularmap_pars_fragment>
2819
+ #include <logdepthbuf_pars_fragment>
2820
+ #include <clipping_planes_pars_fragment>
2821
+ void main() {
2822
+ vec4 diffuseColor = vec4( diffuse, opacity );
2823
+ #include <clipping_planes_fragment>
2824
+ #include <logdepthbuf_fragment>
2825
+ #include <map_fragment>
2826
+ #include <color_fragment>
2827
+ #include <alphamap_fragment>
2828
+ #include <alphatest_fragment>
2829
+ #include <alphahash_fragment>
2830
+ #include <specularmap_fragment>
2831
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2832
+ #ifdef USE_LIGHTMAP
2833
+ vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
2834
+ reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
2835
+ #else
2836
+ reflectedLight.indirectDiffuse += vec3( 1.0 );
2837
+ #endif
2838
+ #include <aomap_fragment>
2839
+ reflectedLight.indirectDiffuse *= diffuseColor.rgb;
2840
+ vec3 outgoingLight = reflectedLight.indirectDiffuse;
2841
+ #include <envmap_fragment>
2842
+ #include <opaque_fragment>
2843
+ #include <tonemapping_fragment>
2844
+ #include <colorspace_fragment>
2845
+ #include <fog_fragment>
2846
+ #include <premultiplied_alpha_fragment>
2847
+ #include <dithering_fragment>
2848
+ }`,Df=`#define LAMBERT
2849
+ varying vec3 vViewPosition;
2850
+ #include <common>
2851
+ #include <batching_pars_vertex>
2852
+ #include <uv_pars_vertex>
2853
+ #include <displacementmap_pars_vertex>
2854
+ #include <envmap_pars_vertex>
2855
+ #include <color_pars_vertex>
2856
+ #include <fog_pars_vertex>
2857
+ #include <normal_pars_vertex>
2858
+ #include <morphtarget_pars_vertex>
2859
+ #include <skinning_pars_vertex>
2860
+ #include <shadowmap_pars_vertex>
2861
+ #include <logdepthbuf_pars_vertex>
2862
+ #include <clipping_planes_pars_vertex>
2863
+ void main() {
2864
+ #include <uv_vertex>
2865
+ #include <color_vertex>
2866
+ #include <morphinstance_vertex>
2867
+ #include <morphcolor_vertex>
2868
+ #include <batching_vertex>
2869
+ #include <beginnormal_vertex>
2870
+ #include <morphnormal_vertex>
2871
+ #include <skinbase_vertex>
2872
+ #include <skinnormal_vertex>
2873
+ #include <defaultnormal_vertex>
2874
+ #include <normal_vertex>
2875
+ #include <begin_vertex>
2876
+ #include <morphtarget_vertex>
2877
+ #include <skinning_vertex>
2878
+ #include <displacementmap_vertex>
2879
+ #include <project_vertex>
2880
+ #include <logdepthbuf_vertex>
2881
+ #include <clipping_planes_vertex>
2882
+ vViewPosition = - mvPosition.xyz;
2883
+ #include <worldpos_vertex>
2884
+ #include <envmap_vertex>
2885
+ #include <shadowmap_vertex>
2886
+ #include <fog_vertex>
2887
+ }`,Uf=`#define LAMBERT
2888
+ uniform vec3 diffuse;
2889
+ uniform vec3 emissive;
2890
+ uniform float opacity;
2891
+ #include <common>
2892
+ #include <packing>
2893
+ #include <dithering_pars_fragment>
2894
+ #include <color_pars_fragment>
2895
+ #include <uv_pars_fragment>
2896
+ #include <map_pars_fragment>
2897
+ #include <alphamap_pars_fragment>
2898
+ #include <alphatest_pars_fragment>
2899
+ #include <alphahash_pars_fragment>
2900
+ #include <aomap_pars_fragment>
2901
+ #include <lightmap_pars_fragment>
2902
+ #include <emissivemap_pars_fragment>
2903
+ #include <envmap_common_pars_fragment>
2904
+ #include <envmap_pars_fragment>
2905
+ #include <fog_pars_fragment>
2906
+ #include <bsdfs>
2907
+ #include <lights_pars_begin>
2908
+ #include <normal_pars_fragment>
2909
+ #include <lights_lambert_pars_fragment>
2910
+ #include <shadowmap_pars_fragment>
2911
+ #include <bumpmap_pars_fragment>
2912
+ #include <normalmap_pars_fragment>
2913
+ #include <specularmap_pars_fragment>
2914
+ #include <logdepthbuf_pars_fragment>
2915
+ #include <clipping_planes_pars_fragment>
2916
+ void main() {
2917
+ vec4 diffuseColor = vec4( diffuse, opacity );
2918
+ #include <clipping_planes_fragment>
2919
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
2920
+ vec3 totalEmissiveRadiance = emissive;
2921
+ #include <logdepthbuf_fragment>
2922
+ #include <map_fragment>
2923
+ #include <color_fragment>
2924
+ #include <alphamap_fragment>
2925
+ #include <alphatest_fragment>
2926
+ #include <alphahash_fragment>
2927
+ #include <specularmap_fragment>
2928
+ #include <normal_fragment_begin>
2929
+ #include <normal_fragment_maps>
2930
+ #include <emissivemap_fragment>
2931
+ #include <lights_lambert_fragment>
2932
+ #include <lights_fragment_begin>
2933
+ #include <lights_fragment_maps>
2934
+ #include <lights_fragment_end>
2935
+ #include <aomap_fragment>
2936
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
2937
+ #include <envmap_fragment>
2938
+ #include <opaque_fragment>
2939
+ #include <tonemapping_fragment>
2940
+ #include <colorspace_fragment>
2941
+ #include <fog_fragment>
2942
+ #include <premultiplied_alpha_fragment>
2943
+ #include <dithering_fragment>
2944
+ }`,Nf=`#define MATCAP
2945
+ varying vec3 vViewPosition;
2946
+ #include <common>
2947
+ #include <batching_pars_vertex>
2948
+ #include <uv_pars_vertex>
2949
+ #include <color_pars_vertex>
2950
+ #include <displacementmap_pars_vertex>
2951
+ #include <fog_pars_vertex>
2952
+ #include <normal_pars_vertex>
2953
+ #include <morphtarget_pars_vertex>
2954
+ #include <skinning_pars_vertex>
2955
+ #include <logdepthbuf_pars_vertex>
2956
+ #include <clipping_planes_pars_vertex>
2957
+ void main() {
2958
+ #include <uv_vertex>
2959
+ #include <color_vertex>
2960
+ #include <morphinstance_vertex>
2961
+ #include <morphcolor_vertex>
2962
+ #include <batching_vertex>
2963
+ #include <beginnormal_vertex>
2964
+ #include <morphnormal_vertex>
2965
+ #include <skinbase_vertex>
2966
+ #include <skinnormal_vertex>
2967
+ #include <defaultnormal_vertex>
2968
+ #include <normal_vertex>
2969
+ #include <begin_vertex>
2970
+ #include <morphtarget_vertex>
2971
+ #include <skinning_vertex>
2972
+ #include <displacementmap_vertex>
2973
+ #include <project_vertex>
2974
+ #include <logdepthbuf_vertex>
2975
+ #include <clipping_planes_vertex>
2976
+ #include <fog_vertex>
2977
+ vViewPosition = - mvPosition.xyz;
2978
+ }`,Ff=`#define MATCAP
2979
+ uniform vec3 diffuse;
2980
+ uniform float opacity;
2981
+ uniform sampler2D matcap;
2982
+ varying vec3 vViewPosition;
2983
+ #include <common>
2984
+ #include <dithering_pars_fragment>
2985
+ #include <color_pars_fragment>
2986
+ #include <uv_pars_fragment>
2987
+ #include <map_pars_fragment>
2988
+ #include <alphamap_pars_fragment>
2989
+ #include <alphatest_pars_fragment>
2990
+ #include <alphahash_pars_fragment>
2991
+ #include <fog_pars_fragment>
2992
+ #include <normal_pars_fragment>
2993
+ #include <bumpmap_pars_fragment>
2994
+ #include <normalmap_pars_fragment>
2995
+ #include <logdepthbuf_pars_fragment>
2996
+ #include <clipping_planes_pars_fragment>
2997
+ void main() {
2998
+ vec4 diffuseColor = vec4( diffuse, opacity );
2999
+ #include <clipping_planes_fragment>
3000
+ #include <logdepthbuf_fragment>
3001
+ #include <map_fragment>
3002
+ #include <color_fragment>
3003
+ #include <alphamap_fragment>
3004
+ #include <alphatest_fragment>
3005
+ #include <alphahash_fragment>
3006
+ #include <normal_fragment_begin>
3007
+ #include <normal_fragment_maps>
3008
+ vec3 viewDir = normalize( vViewPosition );
3009
+ vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
3010
+ vec3 y = cross( viewDir, x );
3011
+ vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
3012
+ #ifdef USE_MATCAP
3013
+ vec4 matcapColor = texture2D( matcap, uv );
3014
+ #else
3015
+ vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3016
+ #endif
3017
+ vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
3018
+ #include <opaque_fragment>
3019
+ #include <tonemapping_fragment>
3020
+ #include <colorspace_fragment>
3021
+ #include <fog_fragment>
3022
+ #include <premultiplied_alpha_fragment>
3023
+ #include <dithering_fragment>
3024
+ }`,Of=`#define NORMAL
3025
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3026
+ varying vec3 vViewPosition;
3027
+ #endif
3028
+ #include <common>
3029
+ #include <batching_pars_vertex>
3030
+ #include <uv_pars_vertex>
3031
+ #include <displacementmap_pars_vertex>
3032
+ #include <normal_pars_vertex>
3033
+ #include <morphtarget_pars_vertex>
3034
+ #include <skinning_pars_vertex>
3035
+ #include <logdepthbuf_pars_vertex>
3036
+ #include <clipping_planes_pars_vertex>
3037
+ void main() {
3038
+ #include <uv_vertex>
3039
+ #include <batching_vertex>
3040
+ #include <beginnormal_vertex>
3041
+ #include <morphinstance_vertex>
3042
+ #include <morphnormal_vertex>
3043
+ #include <skinbase_vertex>
3044
+ #include <skinnormal_vertex>
3045
+ #include <defaultnormal_vertex>
3046
+ #include <normal_vertex>
3047
+ #include <begin_vertex>
3048
+ #include <morphtarget_vertex>
3049
+ #include <skinning_vertex>
3050
+ #include <displacementmap_vertex>
3051
+ #include <project_vertex>
3052
+ #include <logdepthbuf_vertex>
3053
+ #include <clipping_planes_vertex>
3054
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3055
+ vViewPosition = - mvPosition.xyz;
3056
+ #endif
3057
+ }`,Bf=`#define NORMAL
3058
+ uniform float opacity;
3059
+ #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
3060
+ varying vec3 vViewPosition;
3061
+ #endif
3062
+ #include <packing>
3063
+ #include <uv_pars_fragment>
3064
+ #include <normal_pars_fragment>
3065
+ #include <bumpmap_pars_fragment>
3066
+ #include <normalmap_pars_fragment>
3067
+ #include <logdepthbuf_pars_fragment>
3068
+ #include <clipping_planes_pars_fragment>
3069
+ void main() {
3070
+ vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
3071
+ #include <clipping_planes_fragment>
3072
+ #include <logdepthbuf_fragment>
3073
+ #include <normal_fragment_begin>
3074
+ #include <normal_fragment_maps>
3075
+ gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
3076
+ #ifdef OPAQUE
3077
+ gl_FragColor.a = 1.0;
3078
+ #endif
3079
+ }`,zf=`#define PHONG
3080
+ varying vec3 vViewPosition;
3081
+ #include <common>
3082
+ #include <batching_pars_vertex>
3083
+ #include <uv_pars_vertex>
3084
+ #include <displacementmap_pars_vertex>
3085
+ #include <envmap_pars_vertex>
3086
+ #include <color_pars_vertex>
3087
+ #include <fog_pars_vertex>
3088
+ #include <normal_pars_vertex>
3089
+ #include <morphtarget_pars_vertex>
3090
+ #include <skinning_pars_vertex>
3091
+ #include <shadowmap_pars_vertex>
3092
+ #include <logdepthbuf_pars_vertex>
3093
+ #include <clipping_planes_pars_vertex>
3094
+ void main() {
3095
+ #include <uv_vertex>
3096
+ #include <color_vertex>
3097
+ #include <morphcolor_vertex>
3098
+ #include <batching_vertex>
3099
+ #include <beginnormal_vertex>
3100
+ #include <morphinstance_vertex>
3101
+ #include <morphnormal_vertex>
3102
+ #include <skinbase_vertex>
3103
+ #include <skinnormal_vertex>
3104
+ #include <defaultnormal_vertex>
3105
+ #include <normal_vertex>
3106
+ #include <begin_vertex>
3107
+ #include <morphtarget_vertex>
3108
+ #include <skinning_vertex>
3109
+ #include <displacementmap_vertex>
3110
+ #include <project_vertex>
3111
+ #include <logdepthbuf_vertex>
3112
+ #include <clipping_planes_vertex>
3113
+ vViewPosition = - mvPosition.xyz;
3114
+ #include <worldpos_vertex>
3115
+ #include <envmap_vertex>
3116
+ #include <shadowmap_vertex>
3117
+ #include <fog_vertex>
3118
+ }`,kf=`#define PHONG
3119
+ uniform vec3 diffuse;
3120
+ uniform vec3 emissive;
3121
+ uniform vec3 specular;
3122
+ uniform float shininess;
3123
+ uniform float opacity;
3124
+ #include <common>
3125
+ #include <packing>
3126
+ #include <dithering_pars_fragment>
3127
+ #include <color_pars_fragment>
3128
+ #include <uv_pars_fragment>
3129
+ #include <map_pars_fragment>
3130
+ #include <alphamap_pars_fragment>
3131
+ #include <alphatest_pars_fragment>
3132
+ #include <alphahash_pars_fragment>
3133
+ #include <aomap_pars_fragment>
3134
+ #include <lightmap_pars_fragment>
3135
+ #include <emissivemap_pars_fragment>
3136
+ #include <envmap_common_pars_fragment>
3137
+ #include <envmap_pars_fragment>
3138
+ #include <fog_pars_fragment>
3139
+ #include <bsdfs>
3140
+ #include <lights_pars_begin>
3141
+ #include <normal_pars_fragment>
3142
+ #include <lights_phong_pars_fragment>
3143
+ #include <shadowmap_pars_fragment>
3144
+ #include <bumpmap_pars_fragment>
3145
+ #include <normalmap_pars_fragment>
3146
+ #include <specularmap_pars_fragment>
3147
+ #include <logdepthbuf_pars_fragment>
3148
+ #include <clipping_planes_pars_fragment>
3149
+ void main() {
3150
+ vec4 diffuseColor = vec4( diffuse, opacity );
3151
+ #include <clipping_planes_fragment>
3152
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3153
+ vec3 totalEmissiveRadiance = emissive;
3154
+ #include <logdepthbuf_fragment>
3155
+ #include <map_fragment>
3156
+ #include <color_fragment>
3157
+ #include <alphamap_fragment>
3158
+ #include <alphatest_fragment>
3159
+ #include <alphahash_fragment>
3160
+ #include <specularmap_fragment>
3161
+ #include <normal_fragment_begin>
3162
+ #include <normal_fragment_maps>
3163
+ #include <emissivemap_fragment>
3164
+ #include <lights_phong_fragment>
3165
+ #include <lights_fragment_begin>
3166
+ #include <lights_fragment_maps>
3167
+ #include <lights_fragment_end>
3168
+ #include <aomap_fragment>
3169
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
3170
+ #include <envmap_fragment>
3171
+ #include <opaque_fragment>
3172
+ #include <tonemapping_fragment>
3173
+ #include <colorspace_fragment>
3174
+ #include <fog_fragment>
3175
+ #include <premultiplied_alpha_fragment>
3176
+ #include <dithering_fragment>
3177
+ }`,Hf=`#define STANDARD
3178
+ varying vec3 vViewPosition;
3179
+ #ifdef USE_TRANSMISSION
3180
+ varying vec3 vWorldPosition;
3181
+ #endif
3182
+ #include <common>
3183
+ #include <batching_pars_vertex>
3184
+ #include <uv_pars_vertex>
3185
+ #include <displacementmap_pars_vertex>
3186
+ #include <color_pars_vertex>
3187
+ #include <fog_pars_vertex>
3188
+ #include <normal_pars_vertex>
3189
+ #include <morphtarget_pars_vertex>
3190
+ #include <skinning_pars_vertex>
3191
+ #include <shadowmap_pars_vertex>
3192
+ #include <logdepthbuf_pars_vertex>
3193
+ #include <clipping_planes_pars_vertex>
3194
+ void main() {
3195
+ #include <uv_vertex>
3196
+ #include <color_vertex>
3197
+ #include <morphinstance_vertex>
3198
+ #include <morphcolor_vertex>
3199
+ #include <batching_vertex>
3200
+ #include <beginnormal_vertex>
3201
+ #include <morphnormal_vertex>
3202
+ #include <skinbase_vertex>
3203
+ #include <skinnormal_vertex>
3204
+ #include <defaultnormal_vertex>
3205
+ #include <normal_vertex>
3206
+ #include <begin_vertex>
3207
+ #include <morphtarget_vertex>
3208
+ #include <skinning_vertex>
3209
+ #include <displacementmap_vertex>
3210
+ #include <project_vertex>
3211
+ #include <logdepthbuf_vertex>
3212
+ #include <clipping_planes_vertex>
3213
+ vViewPosition = - mvPosition.xyz;
3214
+ #include <worldpos_vertex>
3215
+ #include <shadowmap_vertex>
3216
+ #include <fog_vertex>
3217
+ #ifdef USE_TRANSMISSION
3218
+ vWorldPosition = worldPosition.xyz;
3219
+ #endif
3220
+ }`,Vf=`#define STANDARD
3221
+ #ifdef PHYSICAL
3222
+ #define IOR
3223
+ #define USE_SPECULAR
3224
+ #endif
3225
+ uniform vec3 diffuse;
3226
+ uniform vec3 emissive;
3227
+ uniform float roughness;
3228
+ uniform float metalness;
3229
+ uniform float opacity;
3230
+ #ifdef IOR
3231
+ uniform float ior;
3232
+ #endif
3233
+ #ifdef USE_SPECULAR
3234
+ uniform float specularIntensity;
3235
+ uniform vec3 specularColor;
3236
+ #ifdef USE_SPECULAR_COLORMAP
3237
+ uniform sampler2D specularColorMap;
3238
+ #endif
3239
+ #ifdef USE_SPECULAR_INTENSITYMAP
3240
+ uniform sampler2D specularIntensityMap;
3241
+ #endif
3242
+ #endif
3243
+ #ifdef USE_CLEARCOAT
3244
+ uniform float clearcoat;
3245
+ uniform float clearcoatRoughness;
3246
+ #endif
3247
+ #ifdef USE_DISPERSION
3248
+ uniform float dispersion;
3249
+ #endif
3250
+ #ifdef USE_IRIDESCENCE
3251
+ uniform float iridescence;
3252
+ uniform float iridescenceIOR;
3253
+ uniform float iridescenceThicknessMinimum;
3254
+ uniform float iridescenceThicknessMaximum;
3255
+ #endif
3256
+ #ifdef USE_SHEEN
3257
+ uniform vec3 sheenColor;
3258
+ uniform float sheenRoughness;
3259
+ #ifdef USE_SHEEN_COLORMAP
3260
+ uniform sampler2D sheenColorMap;
3261
+ #endif
3262
+ #ifdef USE_SHEEN_ROUGHNESSMAP
3263
+ uniform sampler2D sheenRoughnessMap;
3264
+ #endif
3265
+ #endif
3266
+ #ifdef USE_ANISOTROPY
3267
+ uniform vec2 anisotropyVector;
3268
+ #ifdef USE_ANISOTROPYMAP
3269
+ uniform sampler2D anisotropyMap;
3270
+ #endif
3271
+ #endif
3272
+ varying vec3 vViewPosition;
3273
+ #include <common>
3274
+ #include <packing>
3275
+ #include <dithering_pars_fragment>
3276
+ #include <color_pars_fragment>
3277
+ #include <uv_pars_fragment>
3278
+ #include <map_pars_fragment>
3279
+ #include <alphamap_pars_fragment>
3280
+ #include <alphatest_pars_fragment>
3281
+ #include <alphahash_pars_fragment>
3282
+ #include <aomap_pars_fragment>
3283
+ #include <lightmap_pars_fragment>
3284
+ #include <emissivemap_pars_fragment>
3285
+ #include <iridescence_fragment>
3286
+ #include <cube_uv_reflection_fragment>
3287
+ #include <envmap_common_pars_fragment>
3288
+ #include <envmap_physical_pars_fragment>
3289
+ #include <fog_pars_fragment>
3290
+ #include <lights_pars_begin>
3291
+ #include <normal_pars_fragment>
3292
+ #include <lights_physical_pars_fragment>
3293
+ #include <transmission_pars_fragment>
3294
+ #include <shadowmap_pars_fragment>
3295
+ #include <bumpmap_pars_fragment>
3296
+ #include <normalmap_pars_fragment>
3297
+ #include <clearcoat_pars_fragment>
3298
+ #include <iridescence_pars_fragment>
3299
+ #include <roughnessmap_pars_fragment>
3300
+ #include <metalnessmap_pars_fragment>
3301
+ #include <logdepthbuf_pars_fragment>
3302
+ #include <clipping_planes_pars_fragment>
3303
+ void main() {
3304
+ vec4 diffuseColor = vec4( diffuse, opacity );
3305
+ #include <clipping_planes_fragment>
3306
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3307
+ vec3 totalEmissiveRadiance = emissive;
3308
+ #include <logdepthbuf_fragment>
3309
+ #include <map_fragment>
3310
+ #include <color_fragment>
3311
+ #include <alphamap_fragment>
3312
+ #include <alphatest_fragment>
3313
+ #include <alphahash_fragment>
3314
+ #include <roughnessmap_fragment>
3315
+ #include <metalnessmap_fragment>
3316
+ #include <normal_fragment_begin>
3317
+ #include <normal_fragment_maps>
3318
+ #include <clearcoat_normal_fragment_begin>
3319
+ #include <clearcoat_normal_fragment_maps>
3320
+ #include <emissivemap_fragment>
3321
+ #include <lights_physical_fragment>
3322
+ #include <lights_fragment_begin>
3323
+ #include <lights_fragment_maps>
3324
+ #include <lights_fragment_end>
3325
+ #include <aomap_fragment>
3326
+ vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
3327
+ vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
3328
+ #include <transmission_fragment>
3329
+ vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
3330
+ #ifdef USE_SHEEN
3331
+ float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
3332
+ outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
3333
+ #endif
3334
+ #ifdef USE_CLEARCOAT
3335
+ float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
3336
+ vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
3337
+ outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
3338
+ #endif
3339
+ #include <opaque_fragment>
3340
+ #include <tonemapping_fragment>
3341
+ #include <colorspace_fragment>
3342
+ #include <fog_fragment>
3343
+ #include <premultiplied_alpha_fragment>
3344
+ #include <dithering_fragment>
3345
+ }`,Gf=`#define TOON
3346
+ varying vec3 vViewPosition;
3347
+ #include <common>
3348
+ #include <batching_pars_vertex>
3349
+ #include <uv_pars_vertex>
3350
+ #include <displacementmap_pars_vertex>
3351
+ #include <color_pars_vertex>
3352
+ #include <fog_pars_vertex>
3353
+ #include <normal_pars_vertex>
3354
+ #include <morphtarget_pars_vertex>
3355
+ #include <skinning_pars_vertex>
3356
+ #include <shadowmap_pars_vertex>
3357
+ #include <logdepthbuf_pars_vertex>
3358
+ #include <clipping_planes_pars_vertex>
3359
+ void main() {
3360
+ #include <uv_vertex>
3361
+ #include <color_vertex>
3362
+ #include <morphinstance_vertex>
3363
+ #include <morphcolor_vertex>
3364
+ #include <batching_vertex>
3365
+ #include <beginnormal_vertex>
3366
+ #include <morphnormal_vertex>
3367
+ #include <skinbase_vertex>
3368
+ #include <skinnormal_vertex>
3369
+ #include <defaultnormal_vertex>
3370
+ #include <normal_vertex>
3371
+ #include <begin_vertex>
3372
+ #include <morphtarget_vertex>
3373
+ #include <skinning_vertex>
3374
+ #include <displacementmap_vertex>
3375
+ #include <project_vertex>
3376
+ #include <logdepthbuf_vertex>
3377
+ #include <clipping_planes_vertex>
3378
+ vViewPosition = - mvPosition.xyz;
3379
+ #include <worldpos_vertex>
3380
+ #include <shadowmap_vertex>
3381
+ #include <fog_vertex>
3382
+ }`,Wf=`#define TOON
3383
+ uniform vec3 diffuse;
3384
+ uniform vec3 emissive;
3385
+ uniform float opacity;
3386
+ #include <common>
3387
+ #include <packing>
3388
+ #include <dithering_pars_fragment>
3389
+ #include <color_pars_fragment>
3390
+ #include <uv_pars_fragment>
3391
+ #include <map_pars_fragment>
3392
+ #include <alphamap_pars_fragment>
3393
+ #include <alphatest_pars_fragment>
3394
+ #include <alphahash_pars_fragment>
3395
+ #include <aomap_pars_fragment>
3396
+ #include <lightmap_pars_fragment>
3397
+ #include <emissivemap_pars_fragment>
3398
+ #include <gradientmap_pars_fragment>
3399
+ #include <fog_pars_fragment>
3400
+ #include <bsdfs>
3401
+ #include <lights_pars_begin>
3402
+ #include <normal_pars_fragment>
3403
+ #include <lights_toon_pars_fragment>
3404
+ #include <shadowmap_pars_fragment>
3405
+ #include <bumpmap_pars_fragment>
3406
+ #include <normalmap_pars_fragment>
3407
+ #include <logdepthbuf_pars_fragment>
3408
+ #include <clipping_planes_pars_fragment>
3409
+ void main() {
3410
+ vec4 diffuseColor = vec4( diffuse, opacity );
3411
+ #include <clipping_planes_fragment>
3412
+ ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
3413
+ vec3 totalEmissiveRadiance = emissive;
3414
+ #include <logdepthbuf_fragment>
3415
+ #include <map_fragment>
3416
+ #include <color_fragment>
3417
+ #include <alphamap_fragment>
3418
+ #include <alphatest_fragment>
3419
+ #include <alphahash_fragment>
3420
+ #include <normal_fragment_begin>
3421
+ #include <normal_fragment_maps>
3422
+ #include <emissivemap_fragment>
3423
+ #include <lights_toon_fragment>
3424
+ #include <lights_fragment_begin>
3425
+ #include <lights_fragment_maps>
3426
+ #include <lights_fragment_end>
3427
+ #include <aomap_fragment>
3428
+ vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
3429
+ #include <opaque_fragment>
3430
+ #include <tonemapping_fragment>
3431
+ #include <colorspace_fragment>
3432
+ #include <fog_fragment>
3433
+ #include <premultiplied_alpha_fragment>
3434
+ #include <dithering_fragment>
3435
+ }`,Xf=`uniform float size;
3436
+ uniform float scale;
3437
+ #include <common>
3438
+ #include <color_pars_vertex>
3439
+ #include <fog_pars_vertex>
3440
+ #include <morphtarget_pars_vertex>
3441
+ #include <logdepthbuf_pars_vertex>
3442
+ #include <clipping_planes_pars_vertex>
3443
+ #ifdef USE_POINTS_UV
3444
+ varying vec2 vUv;
3445
+ uniform mat3 uvTransform;
3446
+ #endif
3447
+ void main() {
3448
+ #ifdef USE_POINTS_UV
3449
+ vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
3450
+ #endif
3451
+ #include <color_vertex>
3452
+ #include <morphinstance_vertex>
3453
+ #include <morphcolor_vertex>
3454
+ #include <begin_vertex>
3455
+ #include <morphtarget_vertex>
3456
+ #include <project_vertex>
3457
+ gl_PointSize = size;
3458
+ #ifdef USE_SIZEATTENUATION
3459
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3460
+ if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
3461
+ #endif
3462
+ #include <logdepthbuf_vertex>
3463
+ #include <clipping_planes_vertex>
3464
+ #include <worldpos_vertex>
3465
+ #include <fog_vertex>
3466
+ }`,qf=`uniform vec3 diffuse;
3467
+ uniform float opacity;
3468
+ #include <common>
3469
+ #include <color_pars_fragment>
3470
+ #include <map_particle_pars_fragment>
3471
+ #include <alphatest_pars_fragment>
3472
+ #include <alphahash_pars_fragment>
3473
+ #include <fog_pars_fragment>
3474
+ #include <logdepthbuf_pars_fragment>
3475
+ #include <clipping_planes_pars_fragment>
3476
+ void main() {
3477
+ vec4 diffuseColor = vec4( diffuse, opacity );
3478
+ #include <clipping_planes_fragment>
3479
+ vec3 outgoingLight = vec3( 0.0 );
3480
+ #include <logdepthbuf_fragment>
3481
+ #include <map_particle_fragment>
3482
+ #include <color_fragment>
3483
+ #include <alphatest_fragment>
3484
+ #include <alphahash_fragment>
3485
+ outgoingLight = diffuseColor.rgb;
3486
+ #include <opaque_fragment>
3487
+ #include <tonemapping_fragment>
3488
+ #include <colorspace_fragment>
3489
+ #include <fog_fragment>
3490
+ #include <premultiplied_alpha_fragment>
3491
+ }`,Yf=`#include <common>
3492
+ #include <batching_pars_vertex>
3493
+ #include <fog_pars_vertex>
3494
+ #include <morphtarget_pars_vertex>
3495
+ #include <skinning_pars_vertex>
3496
+ #include <logdepthbuf_pars_vertex>
3497
+ #include <shadowmap_pars_vertex>
3498
+ void main() {
3499
+ #include <batching_vertex>
3500
+ #include <beginnormal_vertex>
3501
+ #include <morphinstance_vertex>
3502
+ #include <morphnormal_vertex>
3503
+ #include <skinbase_vertex>
3504
+ #include <skinnormal_vertex>
3505
+ #include <defaultnormal_vertex>
3506
+ #include <begin_vertex>
3507
+ #include <morphtarget_vertex>
3508
+ #include <skinning_vertex>
3509
+ #include <project_vertex>
3510
+ #include <logdepthbuf_vertex>
3511
+ #include <worldpos_vertex>
3512
+ #include <shadowmap_vertex>
3513
+ #include <fog_vertex>
3514
+ }`,Zf=`uniform vec3 color;
3515
+ uniform float opacity;
3516
+ #include <common>
3517
+ #include <packing>
3518
+ #include <fog_pars_fragment>
3519
+ #include <bsdfs>
3520
+ #include <lights_pars_begin>
3521
+ #include <logdepthbuf_pars_fragment>
3522
+ #include <shadowmap_pars_fragment>
3523
+ #include <shadowmask_pars_fragment>
3524
+ void main() {
3525
+ #include <logdepthbuf_fragment>
3526
+ gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
3527
+ #include <tonemapping_fragment>
3528
+ #include <colorspace_fragment>
3529
+ #include <fog_fragment>
3530
+ }`,$f=`uniform float rotation;
3531
+ uniform vec2 center;
3532
+ #include <common>
3533
+ #include <uv_pars_vertex>
3534
+ #include <fog_pars_vertex>
3535
+ #include <logdepthbuf_pars_vertex>
3536
+ #include <clipping_planes_pars_vertex>
3537
+ void main() {
3538
+ #include <uv_vertex>
3539
+ vec4 mvPosition = modelViewMatrix[ 3 ];
3540
+ vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
3541
+ #ifndef USE_SIZEATTENUATION
3542
+ bool isPerspective = isPerspectiveMatrix( projectionMatrix );
3543
+ if ( isPerspective ) scale *= - mvPosition.z;
3544
+ #endif
3545
+ vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
3546
+ vec2 rotatedPosition;
3547
+ rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
3548
+ rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
3549
+ mvPosition.xy += rotatedPosition;
3550
+ gl_Position = projectionMatrix * mvPosition;
3551
+ #include <logdepthbuf_vertex>
3552
+ #include <clipping_planes_vertex>
3553
+ #include <fog_vertex>
3554
+ }`,Jf=`uniform vec3 diffuse;
3555
+ uniform float opacity;
3556
+ #include <common>
3557
+ #include <uv_pars_fragment>
3558
+ #include <map_pars_fragment>
3559
+ #include <alphamap_pars_fragment>
3560
+ #include <alphatest_pars_fragment>
3561
+ #include <alphahash_pars_fragment>
3562
+ #include <fog_pars_fragment>
3563
+ #include <logdepthbuf_pars_fragment>
3564
+ #include <clipping_planes_pars_fragment>
3565
+ void main() {
3566
+ vec4 diffuseColor = vec4( diffuse, opacity );
3567
+ #include <clipping_planes_fragment>
3568
+ vec3 outgoingLight = vec3( 0.0 );
3569
+ #include <logdepthbuf_fragment>
3570
+ #include <map_fragment>
3571
+ #include <alphamap_fragment>
3572
+ #include <alphatest_fragment>
3573
+ #include <alphahash_fragment>
3574
+ outgoingLight = diffuseColor.rgb;
3575
+ #include <opaque_fragment>
3576
+ #include <tonemapping_fragment>
3577
+ #include <colorspace_fragment>
3578
+ #include <fog_fragment>
3579
+ }`,Ft={alphahash_fragment:_u,alphahash_pars_fragment:xu,alphamap_fragment:yu,alphamap_pars_fragment:vu,alphatest_fragment:Mu,alphatest_pars_fragment:bu,aomap_fragment:Su,aomap_pars_fragment:Eu,batching_pars_vertex:Tu,batching_vertex:wu,begin_vertex:Au,beginnormal_vertex:Ru,bsdfs:Cu,iridescence_fragment:Pu,bumpmap_pars_fragment:Iu,clipping_planes_fragment:Lu,clipping_planes_pars_fragment:Du,clipping_planes_pars_vertex:Uu,clipping_planes_vertex:Nu,color_fragment:Fu,color_pars_fragment:Ou,color_pars_vertex:Bu,color_vertex:zu,common:ku,cube_uv_reflection_fragment:Hu,defaultnormal_vertex:Vu,displacementmap_pars_vertex:Gu,displacementmap_vertex:Wu,emissivemap_fragment:Xu,emissivemap_pars_fragment:qu,colorspace_fragment:Yu,colorspace_pars_fragment:Zu,envmap_fragment:$u,envmap_common_pars_fragment:Ju,envmap_pars_fragment:Ku,envmap_pars_vertex:ju,envmap_physical_pars_fragment:cd,envmap_vertex:Qu,fog_vertex:td,fog_pars_vertex:ed,fog_fragment:nd,fog_pars_fragment:id,gradientmap_pars_fragment:sd,lightmap_pars_fragment:rd,lights_lambert_fragment:ad,lights_lambert_pars_fragment:od,lights_pars_begin:ld,lights_toon_fragment:hd,lights_toon_pars_fragment:ud,lights_phong_fragment:dd,lights_phong_pars_fragment:fd,lights_physical_fragment:pd,lights_physical_pars_fragment:md,lights_fragment_begin:gd,lights_fragment_maps:_d,lights_fragment_end:xd,logdepthbuf_fragment:yd,logdepthbuf_pars_fragment:vd,logdepthbuf_pars_vertex:Md,logdepthbuf_vertex:bd,map_fragment:Sd,map_pars_fragment:Ed,map_particle_fragment:Td,map_particle_pars_fragment:wd,metalnessmap_fragment:Ad,metalnessmap_pars_fragment:Rd,morphinstance_vertex:Cd,morphcolor_vertex:Pd,morphnormal_vertex:Id,morphtarget_pars_vertex:Ld,morphtarget_vertex:Dd,normal_fragment_begin:Ud,normal_fragment_maps:Nd,normal_pars_fragment:Fd,normal_pars_vertex:Od,normal_vertex:Bd,normalmap_pars_fragment:zd,clearcoat_normal_fragment_begin:kd,clearcoat_normal_fragment_maps:Hd,clearcoat_pars_fragment:Vd,iridescence_pars_fragment:Gd,opaque_fragment:Wd,packing:Xd,premultiplied_alpha_fragment:qd,project_vertex:Yd,dithering_fragment:Zd,dithering_pars_fragment:$d,roughnessmap_fragment:Jd,roughnessmap_pars_fragment:Kd,shadowmap_pars_fragment:jd,shadowmap_pars_vertex:Qd,shadowmap_vertex:tf,shadowmask_pars_fragment:ef,skinbase_vertex:nf,skinning_pars_vertex:sf,skinning_vertex:rf,skinnormal_vertex:af,specularmap_fragment:of,specularmap_pars_fragment:lf,tonemapping_fragment:cf,tonemapping_pars_fragment:hf,transmission_fragment:uf,transmission_pars_fragment:df,uv_pars_fragment:ff,uv_pars_vertex:pf,uv_vertex:mf,worldpos_vertex:gf,background_vert:_f,background_frag:xf,backgroundCube_vert:yf,backgroundCube_frag:vf,cube_vert:Mf,cube_frag:bf,depth_vert:Sf,depth_frag:Ef,distanceRGBA_vert:Tf,distanceRGBA_frag:wf,equirect_vert:Af,equirect_frag:Rf,linedashed_vert:Cf,linedashed_frag:Pf,meshbasic_vert:If,meshbasic_frag:Lf,meshlambert_vert:Df,meshlambert_frag:Uf,meshmatcap_vert:Nf,meshmatcap_frag:Ff,meshnormal_vert:Of,meshnormal_frag:Bf,meshphong_vert:zf,meshphong_frag:kf,meshphysical_vert:Hf,meshphysical_frag:Vf,meshtoon_vert:Gf,meshtoon_frag:Wf,points_vert:Xf,points_frag:qf,shadow_vert:Yf,shadow_frag:Zf,sprite_vert:$f,sprite_frag:Jf},st={common:{diffuse:{value:new zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Lt}},envmap:{envMap:{value:null},envMapRotation:{value:new Lt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Lt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Lt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Lt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Lt},normalScale:{value:new Ut(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Lt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Lt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Lt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Lt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0},uvTransform:{value:new Lt}},sprite:{diffuse:{value:new zt(16777215)},opacity:{value:1},center:{value:new Ut(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Lt},alphaMap:{value:null},alphaMapTransform:{value:new Lt},alphaTest:{value:0}}},ln={basic:{uniforms:ve([st.common,st.specularmap,st.envmap,st.aomap,st.lightmap,st.fog]),vertexShader:Ft.meshbasic_vert,fragmentShader:Ft.meshbasic_frag},lambert:{uniforms:ve([st.common,st.specularmap,st.envmap,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.fog,st.lights,{emissive:{value:new zt(0)}}]),vertexShader:Ft.meshlambert_vert,fragmentShader:Ft.meshlambert_frag},phong:{uniforms:ve([st.common,st.specularmap,st.envmap,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.fog,st.lights,{emissive:{value:new zt(0)},specular:{value:new zt(1118481)},shininess:{value:30}}]),vertexShader:Ft.meshphong_vert,fragmentShader:Ft.meshphong_frag},standard:{uniforms:ve([st.common,st.envmap,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.roughnessmap,st.metalnessmap,st.fog,st.lights,{emissive:{value:new zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag},toon:{uniforms:ve([st.common,st.aomap,st.lightmap,st.emissivemap,st.bumpmap,st.normalmap,st.displacementmap,st.gradientmap,st.fog,st.lights,{emissive:{value:new zt(0)}}]),vertexShader:Ft.meshtoon_vert,fragmentShader:Ft.meshtoon_frag},matcap:{uniforms:ve([st.common,st.bumpmap,st.normalmap,st.displacementmap,st.fog,{matcap:{value:null}}]),vertexShader:Ft.meshmatcap_vert,fragmentShader:Ft.meshmatcap_frag},points:{uniforms:ve([st.points,st.fog]),vertexShader:Ft.points_vert,fragmentShader:Ft.points_frag},dashed:{uniforms:ve([st.common,st.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ft.linedashed_vert,fragmentShader:Ft.linedashed_frag},depth:{uniforms:ve([st.common,st.displacementmap]),vertexShader:Ft.depth_vert,fragmentShader:Ft.depth_frag},normal:{uniforms:ve([st.common,st.bumpmap,st.normalmap,st.displacementmap,{opacity:{value:1}}]),vertexShader:Ft.meshnormal_vert,fragmentShader:Ft.meshnormal_frag},sprite:{uniforms:ve([st.sprite,st.fog]),vertexShader:Ft.sprite_vert,fragmentShader:Ft.sprite_frag},background:{uniforms:{uvTransform:{value:new Lt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ft.background_vert,fragmentShader:Ft.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Lt}},vertexShader:Ft.backgroundCube_vert,fragmentShader:Ft.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ft.cube_vert,fragmentShader:Ft.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ft.equirect_vert,fragmentShader:Ft.equirect_frag},distanceRGBA:{uniforms:ve([st.common,st.displacementmap,{referencePosition:{value:new N},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ft.distanceRGBA_vert,fragmentShader:Ft.distanceRGBA_frag},shadow:{uniforms:ve([st.lights,st.fog,{color:{value:new zt(0)},opacity:{value:1}}]),vertexShader:Ft.shadow_vert,fragmentShader:Ft.shadow_frag}};ln.physical={uniforms:ve([ln.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Lt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Lt},clearcoatNormalScale:{value:new Ut(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Lt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Lt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Lt},sheen:{value:0},sheenColor:{value:new zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Lt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Lt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Lt},transmissionSamplerSize:{value:new Ut},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Lt},attenuationDistance:{value:0},attenuationColor:{value:new zt(0)},specularColor:{value:new zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Lt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Lt},anisotropyVector:{value:new Ut},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Lt}}]),vertexShader:Ft.meshphysical_vert,fragmentShader:Ft.meshphysical_frag};var ya={r:0,b:0,g:0},ti=new sn,Kf=new ce;function jf(i,t,e,n,s,r,a){let o=new zt(0),c=r===!0?0:1,l,h,f=null,u=0,p=null;function g(M){let v=M.isScene===!0?M.background:null;return v&&v.isTexture&&(v=(M.backgroundBlurriness>0?e:t).get(v)),v}function _(M){let v=!1,R=g(M);R===null?d(o,c):R&&R.isColor&&(d(R,1),v=!0);let w=i.xr.getEnvironmentBlendMode();w==="additive"?n.buffers.color.setClear(0,0,0,1,a):w==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||v)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function m(M,v){let R=g(v);R&&(R.isCubeTexture||R.mapping===vs)?(h===void 0&&(h=new Pe(new Ti(1,1,1),new je({name:"BackgroundCubeMaterial",uniforms:Qn(ln.backgroundCube.uniforms),vertexShader:ln.backgroundCube.vertexShader,fragmentShader:ln.backgroundCube.fragmentShader,side:Ee,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(w,C,U){this.matrixWorld.copyPosition(U.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),ti.copy(v.backgroundRotation),ti.x*=-1,ti.y*=-1,ti.z*=-1,R.isCubeTexture&&R.isRenderTargetTexture===!1&&(ti.y*=-1,ti.z*=-1),h.material.uniforms.envMap.value=R,h.material.uniforms.flipEnvMap.value=R.isCubeTexture&&R.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(Kf.makeRotationFromEuler(ti)),h.material.toneMapped=Vt.getTransfer(R.colorSpace)!==qt,(f!==R||u!==R.version||p!==i.toneMapping)&&(h.material.needsUpdate=!0,f=R,u=R.version,p=i.toneMapping),h.layers.enableAll(),M.unshift(h,h.geometry,h.material,0,0,null)):R&&R.isTexture&&(l===void 0&&(l=new Pe(new ms(2,2),new je({name:"BackgroundMaterial",uniforms:Qn(ln.background.uniforms),vertexShader:ln.background.vertexShader,fragmentShader:ln.background.fragmentShader,side:gn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=R,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=Vt.getTransfer(R.colorSpace)!==qt,R.matrixAutoUpdate===!0&&R.updateMatrix(),l.material.uniforms.uvTransform.value.copy(R.matrix),(f!==R||u!==R.version||p!==i.toneMapping)&&(l.material.needsUpdate=!0,f=R,u=R.version,p=i.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null))}function d(M,v){M.getRGB(ya,Fo(i)),n.buffers.color.setClear(ya.r,ya.g,ya.b,v,a)}function T(){h!==void 0&&(h.geometry.dispose(),h.material.dispose(),h=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(M,v=1){o.set(M),c=v,d(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(M){c=M,d(o,c)},render:_,addToRenderList:m,dispose:T}}function Qf(i,t){let e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=u(null),r=s,a=!1;function o(b,P,B,V,X){let Z=!1,W=f(V,B,P);r!==W&&(r=W,l(r.object)),Z=p(b,V,B,X),Z&&g(b,V,B,X),X!==null&&t.update(X,i.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,v(b,P,B,V),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(X).buffer))}function c(){return i.createVertexArray()}function l(b){return i.bindVertexArray(b)}function h(b){return i.deleteVertexArray(b)}function f(b,P,B){let V=B.wireframe===!0,X=n[b.id];X===void 0&&(X={},n[b.id]=X);let Z=X[P.id];Z===void 0&&(Z={},X[P.id]=Z);let W=Z[V];return W===void 0&&(W=u(c()),Z[V]=W),W}function u(b){let P=[],B=[],V=[];for(let X=0;X<e;X++)P[X]=0,B[X]=0,V[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:B,attributeDivisors:V,object:b,attributes:{},index:null}}function p(b,P,B,V){let X=r.attributes,Z=P.attributes,W=0,et=B.getAttributes();for(let k in et)if(et[k].location>=0){let ct=X[k],bt=Z[k];if(bt===void 0&&(k==="instanceMatrix"&&b.instanceMatrix&&(bt=b.instanceMatrix),k==="instanceColor"&&b.instanceColor&&(bt=b.instanceColor)),ct===void 0||ct.attribute!==bt||bt&&ct.data!==bt.data)return!0;W++}return r.attributesNum!==W||r.index!==V}function g(b,P,B,V){let X={},Z=P.attributes,W=0,et=B.getAttributes();for(let k in et)if(et[k].location>=0){let ct=Z[k];ct===void 0&&(k==="instanceMatrix"&&b.instanceMatrix&&(ct=b.instanceMatrix),k==="instanceColor"&&b.instanceColor&&(ct=b.instanceColor));let bt={};bt.attribute=ct,ct&&ct.data&&(bt.data=ct.data),X[k]=bt,W++}r.attributes=X,r.attributesNum=W,r.index=V}function _(){let b=r.newAttributes;for(let P=0,B=b.length;P<B;P++)b[P]=0}function m(b){d(b,0)}function d(b,P){let B=r.newAttributes,V=r.enabledAttributes,X=r.attributeDivisors;B[b]=1,V[b]===0&&(i.enableVertexAttribArray(b),V[b]=1),X[b]!==P&&(i.vertexAttribDivisor(b,P),X[b]=P)}function T(){let b=r.newAttributes,P=r.enabledAttributes;for(let B=0,V=P.length;B<V;B++)P[B]!==b[B]&&(i.disableVertexAttribArray(B),P[B]=0)}function M(b,P,B,V,X,Z,W){W===!0?i.vertexAttribIPointer(b,P,B,X,Z):i.vertexAttribPointer(b,P,B,V,X,Z)}function v(b,P,B,V){_();let X=V.attributes,Z=B.getAttributes(),W=P.defaultAttributeValues;for(let et in Z){let k=Z[et];if(k.location>=0){let rt=X[et];if(rt===void 0&&(et==="instanceMatrix"&&b.instanceMatrix&&(rt=b.instanceMatrix),et==="instanceColor"&&b.instanceColor&&(rt=b.instanceColor)),rt!==void 0){let ct=rt.normalized,bt=rt.itemSize,Bt=t.get(rt);if(Bt===void 0)continue;let Jt=Bt.buffer,te=Bt.type,Wt=Bt.bytesPerElement,q=te===i.INT||te===i.UNSIGNED_INT||rt.gpuType===zr;if(rt.isInterleavedBufferAttribute){let J=rt.data,dt=J.stride,Ct=rt.offset;if(J.isInstancedInterleavedBuffer){for(let Mt=0;Mt<k.locationSize;Mt++)d(k.location+Mt,J.meshPerAttribute);b.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let Mt=0;Mt<k.locationSize;Mt++)m(k.location+Mt);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let Mt=0;Mt<k.locationSize;Mt++)M(k.location+Mt,bt/k.locationSize,te,ct,dt*Wt,(Ct+bt/k.locationSize*Mt)*Wt,q)}else{if(rt.isInstancedBufferAttribute){for(let J=0;J<k.locationSize;J++)d(k.location+J,rt.meshPerAttribute);b.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=rt.meshPerAttribute*rt.count)}else for(let J=0;J<k.locationSize;J++)m(k.location+J);i.bindBuffer(i.ARRAY_BUFFER,Jt);for(let J=0;J<k.locationSize;J++)M(k.location+J,bt/k.locationSize,te,ct,bt*Wt,bt/k.locationSize*J*Wt,q)}}else if(W!==void 0){let ct=W[et];if(ct!==void 0)switch(ct.length){case 2:i.vertexAttrib2fv(k.location,ct);break;case 3:i.vertexAttrib3fv(k.location,ct);break;case 4:i.vertexAttrib4fv(k.location,ct);break;default:i.vertexAttrib1fv(k.location,ct)}}}}T()}function R(){U();for(let b in n){let P=n[b];for(let B in P){let V=P[B];for(let X in V)h(V[X].object),delete V[X];delete P[B]}delete n[b]}}function w(b){if(n[b.id]===void 0)return;let P=n[b.id];for(let B in P){let V=P[B];for(let X in V)h(V[X].object),delete V[X];delete P[B]}delete n[b.id]}function C(b){for(let P in n){let B=n[P];if(B[b.id]===void 0)continue;let V=B[b.id];for(let X in V)h(V[X].object),delete V[X];delete B[b.id]}}function U(){S(),a=!0,r!==s&&(r=s,l(r.object))}function S(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:U,resetDefaultState:S,dispose:R,releaseStatesOfGeometry:w,releaseStatesOfProgram:C,initAttributes:_,enableAttribute:m,disableUnusedAttributes:T}}function tp(i,t,e){let n;function s(l){n=l}function r(l,h){i.drawArrays(n,l,h),e.update(h,n,1)}function a(l,h,f){f!==0&&(i.drawArraysInstanced(n,l,h,f),e.update(h,n,f))}function o(l,h,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,h,0,f);let p=0;for(let g=0;g<f;g++)p+=h[g];e.update(p,n,1)}function c(l,h,f,u){if(f===0)return;let p=t.get("WEBGL_multi_draw");if(p===null)for(let g=0;g<l.length;g++)a(l[g],h[g],u[g]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,h,0,u,0,f);let g=0;for(let _=0;_<f;_++)g+=h[_]*u[_];e.update(g,n,1)}}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o,this.renderMultiDrawInstances=c}function ep(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){let C=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(C.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(C){return!(C!==qe&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(C){let U=C===Di&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(C!==an&&n.convert(C)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&C!==on&&!U)}function c(C){if(C==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp",h=c(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let f=e.logarithmicDepthBuffer===!0,u=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),d=i.getParameter(i.MAX_VERTEX_ATTRIBS),T=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),M=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),R=g>0,w=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:f,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:m,maxAttributes:d,maxVertexUniforms:T,maxVaryings:M,maxFragmentUniforms:v,vertexTextures:R,maxSamples:w}}function np(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Ve,o=new Lt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,u){let p=f.length!==0||u||n!==0||s;return s=u,n=f.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(f,u){e=h(f,u,0)},this.setState=function(f,u,p){let g=f.clippingPlanes,_=f.clipIntersection,m=f.clipShadows,d=i.get(f);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{let T=r?0:n,M=T*4,v=d.clippingState||null;c.value=v,v=h(g,u,M,p);for(let R=0;R!==M;++R)v[R]=e[R];d.clippingState=v,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=T}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(f,u,p,g){let _=f!==null?f.length:0,m=null;if(_!==0){if(m=c.value,g!==!0||m===null){let d=p+_*4,T=u.matrixWorldInverse;o.getNormalMatrix(T),(m===null||m.length<d)&&(m=new Float32Array(d));for(let M=0,v=p;M!==_;++M,v+=4)a.copy(f[M]).applyMatrix4(T,o),a.normal.toArray(m,v),m[v+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,m}}function ip(i){let t=new WeakMap;function e(a,o){return o===Fr?a.mapping=Kn:o===Or&&(a.mapping=jn),a}function n(a){if(a&&a.isTexture){let o=a.mapping;if(o===Fr||o===Or)if(t.has(a)){let c=t.get(a).texture;return e(c,a.mapping)}else{let c=a.image;if(c&&c.height>0){let l=new pr(c.height);return l.fromEquirectangularTexture(i,a),t.set(a,l),a.addEventListener("dispose",s),e(l.texture,a.mapping)}else return null}}return a}function s(a){let o=a.target;o.removeEventListener("dispose",s);let c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var Bi=4,Pc=[.125,.215,.35,.446,.526,.582],ii=20,ko=new Pi,Ic=new zt,Ho=null,Vo=0,Go=0,Wo=!1,ni=(1+Math.sqrt(5))/2,Oi=1/ni,Lc=[new N(-ni,Oi,0),new N(ni,Oi,0),new N(-Oi,0,ni),new N(Oi,0,ni),new N(0,ni,-Oi),new N(0,ni,Oi),new N(-1,1,-1),new N(1,1,-1),new N(-1,1,1),new N(1,1,1)],sp=new N,ba=class{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,s=100,r={}){let{size:a=256,position:o=sp}=r;Ho=this._renderer.getRenderTarget(),Vo=this._renderer.getActiveCubeFace(),Go=this._renderer.getActiveMipmapLevel(),Wo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,s,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Nc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Uc(),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(Ho,Vo,Go),this._renderer.xr.enabled=Wo,t.scissorTest=!1,va(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Kn||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),Ho=this._renderer.getRenderTarget(),Vo=this._renderer.getActiveCubeFace(),Go=this._renderer.getActiveMipmapLevel(),Wo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ke,minFilter:Ke,generateMipmaps:!1,type:Di,format:qe,colorSpace:Zn,depthBuffer:!1},s=Dc(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Dc(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=rp(r)),this._blurMaterial=ap(r,t,e)}return s}_compileMaterial(t){let e=new Pe(this._lodPlanes[0],t);this._renderer.compile(e,ko)}_sceneToCubeUV(t,e,n,s,r){let c=new we(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],f=this._renderer,u=f.autoClear,p=f.toneMapping;f.getClearColor(Ic),f.toneMapping=vn,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(s),f.clearDepth(),f.setRenderTarget(null));let _=new $n({name:"PMREM.Background",side:Ee,depthWrite:!1,depthTest:!1}),m=new Pe(new Ti,_),d=!1,T=t.background;T?T.isColor&&(_.color.copy(T),t.background=null,d=!0):(_.color.copy(Ic),d=!0);for(let M=0;M<6;M++){let v=M%3;v===0?(c.up.set(0,l[M],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[M],r.y,r.z)):v===1?(c.up.set(0,0,l[M]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[M],r.z)):(c.up.set(0,l[M],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[M]));let R=this._cubeSize;va(s,v*R,M>2?R:0,R,R),f.setRenderTarget(s),d&&f.render(m,c),f.render(t,c)}m.geometry.dispose(),m.material.dispose(),f.toneMapping=p,f.autoClear=u,t.background=T}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===Kn||t.mapping===jn;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Nc()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Uc());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Pe(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;va(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,ko)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let s=this._lodPlanes.length;for(let r=1;r<s;r++){let a=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),o=Lc[(s-r-1)%Lc.length];this._blur(t,r-1,r,a,o)}e.autoClear=n}_blur(t,e,n,s,r){let a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){let c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let h=3,f=new Pe(this._lodPlanes[s],l),u=l.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*ii-1),_=r/g,m=isFinite(r)?1+Math.floor(h*_):ii;m>ii&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ii}`);let d=[],T=0;for(let C=0;C<ii;++C){let U=C/_,S=Math.exp(-U*U/2);d.push(S),C===0?T+=S:C<m&&(T+=2*S)}for(let C=0;C<d.length;C++)d[C]=d[C]/T;u.envMap.value=t.texture,u.samples.value=m,u.weights.value=d,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);let{_lodMax:M}=this;u.dTheta.value=g,u.mipInt.value=M-n;let v=this._sizeLods[s],R=3*v*(s>M-Bi?s-M+Bi:0),w=4*(this._cubeSize-v);va(e,R,w,3*v,2*v),c.setRenderTarget(e),c.render(f,ko)}};function rp(i){let t=[],e=[],n=[],s=i,r=i-Bi+1+Pc.length;for(let a=0;a<r;a++){let o=Math.pow(2,s);e.push(o);let c=1/o;a>i-Bi?c=Pc[a-i+Bi-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,f=1+l,u=[h,h,f,h,f,f,h,h,f,f,h,f],p=6,g=6,_=3,m=2,d=1,T=new Float32Array(_*g*p),M=new Float32Array(m*g*p),v=new Float32Array(d*g*p);for(let w=0;w<p;w++){let C=w%3*2/3-1,U=w>2?0:-1,S=[C,U,0,C+2/3,U,0,C+2/3,U+1,0,C,U,0,C+2/3,U+1,0,C,U+1,0];T.set(S,_*g*w),M.set(u,m*g*w);let b=[w,w,w,w,w,w];v.set(b,d*g*w)}let R=new ye;R.setAttribute("position",new ae(T,_)),R.setAttribute("uv",new ae(M,m)),R.setAttribute("faceIndex",new ae(v,d)),t.push(R),s>Bi&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Dc(i,t,e){let n=new en(i,t,e);return n.texture.mapping=vs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function va(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function ap(i,t,e){let n=new Float32Array(ii),s=new N(0,1,0);return new je({name:"SphericalGaussianBlur",defines:{n:ii,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:s}},vertexShader:tl(),fragmentShader:`
3580
+
3581
+ precision mediump float;
3582
+ precision mediump int;
3583
+
3584
+ varying vec3 vOutputDirection;
3585
+
3586
+ uniform sampler2D envMap;
3587
+ uniform int samples;
3588
+ uniform float weights[ n ];
3589
+ uniform bool latitudinal;
3590
+ uniform float dTheta;
3591
+ uniform float mipInt;
3592
+ uniform vec3 poleAxis;
3593
+
3594
+ #define ENVMAP_TYPE_CUBE_UV
3595
+ #include <cube_uv_reflection_fragment>
3596
+
3597
+ vec3 getSample( float theta, vec3 axis ) {
3598
+
3599
+ float cosTheta = cos( theta );
3600
+ // Rodrigues' axis-angle rotation
3601
+ vec3 sampleDirection = vOutputDirection * cosTheta
3602
+ + cross( axis, vOutputDirection ) * sin( theta )
3603
+ + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
3604
+
3605
+ return bilinearCubeUV( envMap, sampleDirection, mipInt );
3606
+
3607
+ }
3608
+
3609
+ void main() {
3610
+
3611
+ vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
3612
+
3613
+ if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
3614
+
3615
+ axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
3616
+
3617
+ }
3618
+
3619
+ axis = normalize( axis );
3620
+
3621
+ gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
3622
+ gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
3623
+
3624
+ for ( int i = 1; i < n; i++ ) {
3625
+
3626
+ if ( i >= samples ) {
3627
+
3628
+ break;
3629
+
3630
+ }
3631
+
3632
+ float theta = dTheta * float( i );
3633
+ gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
3634
+ gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
3635
+
3636
+ }
3637
+
3638
+ }
3639
+ `,blending:yn,depthTest:!1,depthWrite:!1})}function Uc(){return new je({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:tl(),fragmentShader:`
3640
+
3641
+ precision mediump float;
3642
+ precision mediump int;
3643
+
3644
+ varying vec3 vOutputDirection;
3645
+
3646
+ uniform sampler2D envMap;
3647
+
3648
+ #include <common>
3649
+
3650
+ void main() {
3651
+
3652
+ vec3 outputDirection = normalize( vOutputDirection );
3653
+ vec2 uv = equirectUv( outputDirection );
3654
+
3655
+ gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3656
+
3657
+ }
3658
+ `,blending:yn,depthTest:!1,depthWrite:!1})}function Nc(){return new je({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:tl(),fragmentShader:`
3659
+
3660
+ precision mediump float;
3661
+ precision mediump int;
3662
+
3663
+ uniform float flipEnvMap;
3664
+
3665
+ varying vec3 vOutputDirection;
3666
+
3667
+ uniform samplerCube envMap;
3668
+
3669
+ void main() {
3670
+
3671
+ gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
3672
+
3673
+ }
3674
+ `,blending:yn,depthTest:!1,depthWrite:!1})}function tl(){return`
3675
+
3676
+ precision mediump float;
3677
+ precision mediump int;
3678
+
3679
+ attribute float faceIndex;
3680
+
3681
+ varying vec3 vOutputDirection;
3682
+
3683
+ // RH coordinate system; PMREM face-indexing convention
3684
+ vec3 getDirection( vec2 uv, float face ) {
3685
+
3686
+ uv = 2.0 * uv - 1.0;
3687
+
3688
+ vec3 direction = vec3( uv, 1.0 );
3689
+
3690
+ if ( face == 0.0 ) {
3691
+
3692
+ direction = direction.zyx; // ( 1, v, u ) pos x
3693
+
3694
+ } else if ( face == 1.0 ) {
3695
+
3696
+ direction = direction.xzy;
3697
+ direction.xz *= -1.0; // ( -u, 1, -v ) pos y
3698
+
3699
+ } else if ( face == 2.0 ) {
3700
+
3701
+ direction.x *= -1.0; // ( -u, v, 1 ) pos z
3702
+
3703
+ } else if ( face == 3.0 ) {
3704
+
3705
+ direction = direction.zyx;
3706
+ direction.xz *= -1.0; // ( -1, v, -u ) neg x
3707
+
3708
+ } else if ( face == 4.0 ) {
3709
+
3710
+ direction = direction.xzy;
3711
+ direction.xy *= -1.0; // ( -u, -1, v ) neg y
3712
+
3713
+ } else if ( face == 5.0 ) {
3714
+
3715
+ direction.z *= -1.0; // ( u, v, -1 ) neg z
3716
+
3717
+ }
3718
+
3719
+ return direction;
3720
+
3721
+ }
3722
+
3723
+ void main() {
3724
+
3725
+ vOutputDirection = getDirection( uv, faceIndex );
3726
+ gl_Position = vec4( position, 1.0 );
3727
+
3728
+ }
3729
+ `}function op(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===Fr||c===Or,h=c===Kn||c===jn;if(l||h){let f=t.get(o),u=f!==void 0?f.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==u)return e===null&&(e=new ba(i)),f=l?e.fromEquirectangular(o,f):e.fromCubemap(o,f),f.texture.pmremVersion=o.pmremVersion,t.set(o,f),f.texture;if(f!==void 0)return f.texture;{let p=o.image;return l&&p&&p.height>0||h&&p&&s(p)?(e===null&&(e=new ba(i)),f=l?e.fromEquirectangular(o):e.fromCubemap(o),f.texture.pmremVersion=o.pmremVersion,t.set(o,f),o.addEventListener("dispose",r),f.texture):null}}}return o}function s(o){let c=0,l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function r(o){let c=o.target;c.removeEventListener("dispose",r);let l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function a(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:a}}function lp(i){let t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=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":s=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":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}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){let s=e(n);return s===null&&Si("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function cp(i,t,e,n){let s={},r=new WeakMap;function a(f){let u=f.target;u.index!==null&&t.remove(u.index);for(let g in u.attributes)t.remove(u.attributes[g]);u.removeEventListener("dispose",a),delete s[u.id];let p=r.get(u);p&&(t.remove(p),r.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,e.memory.geometries--}function o(f,u){return s[u.id]===!0||(u.addEventListener("dispose",a),s[u.id]=!0,e.memory.geometries++),u}function c(f){let u=f.attributes;for(let p in u)t.update(u[p],i.ARRAY_BUFFER)}function l(f){let u=[],p=f.index,g=f.attributes.position,_=0;if(p!==null){let T=p.array;_=p.version;for(let M=0,v=T.length;M<v;M+=3){let R=T[M+0],w=T[M+1],C=T[M+2];u.push(R,w,w,C,C,R)}}else if(g!==void 0){let T=g.array;_=g.version;for(let M=0,v=T.length/3-1;M<v;M+=3){let R=M+0,w=M+1,C=M+2;u.push(R,w,w,C,C,R)}}else return;let m=new(No(u)?as:rs)(u,1);m.version=_;let d=r.get(f);d&&t.remove(d),r.set(f,m)}function h(f){let u=r.get(f);if(u){let p=f.index;p!==null&&u.version<p.version&&l(f)}else l(f);return r.get(f)}return{get:o,update:c,getWireframeAttribute:h}}function hp(i,t,e){let n;function s(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,p){i.drawElements(n,p,r,u*a),e.update(p,n,1)}function l(u,p,g){g!==0&&(i.drawElementsInstanced(n,p,r,u*a,g),e.update(p,n,g))}function h(u,p,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,u,0,g);let m=0;for(let d=0;d<g;d++)m+=p[d];e.update(m,n,1)}function f(u,p,g,_){if(g===0)return;let m=t.get("WEBGL_multi_draw");if(m===null)for(let d=0;d<u.length;d++)l(u[d]/a,p[d],_[d]);else{m.multiDrawElementsInstancedWEBGL(n,p,0,r,u,0,_,0,g);let d=0;for(let T=0;T<g;T++)d+=p[T]*_[T];e.update(d,n,1)}}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function up(i){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",a);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function dp(i,t,e){let n=new WeakMap,s=new oe;function r(a,o,c){let l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,f=h!==void 0?h.length:0,u=n.get(o);if(u===void 0||u.count!==f){let S=function(){C.dispose(),n.delete(o),o.removeEventListener("dispose",S)};u!==void 0&&u.texture.dispose();let p=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,_=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],d=o.morphAttributes.normal||[],T=o.morphAttributes.color||[],M=0;p===!0&&(M=1),g===!0&&(M=2),_===!0&&(M=3);let v=o.attributes.position.count*M,R=1;v>t.maxTextureSize&&(R=Math.ceil(v/t.maxTextureSize),v=t.maxTextureSize);let w=new Float32Array(v*R*4*f),C=new is(w,v,R,f);C.type=on,C.needsUpdate=!0;let U=M*4;for(let b=0;b<f;b++){let P=m[b],B=d[b],V=T[b],X=v*R*4*b;for(let Z=0;Z<P.count;Z++){let W=Z*U;p===!0&&(s.fromBufferAttribute(P,Z),w[X+W+0]=s.x,w[X+W+1]=s.y,w[X+W+2]=s.z,w[X+W+3]=0),g===!0&&(s.fromBufferAttribute(B,Z),w[X+W+4]=s.x,w[X+W+5]=s.y,w[X+W+6]=s.z,w[X+W+7]=0),_===!0&&(s.fromBufferAttribute(V,Z),w[X+W+8]=s.x,w[X+W+9]=s.y,w[X+W+10]=s.z,w[X+W+11]=V.itemSize===4?s.w:1)}}u={count:f,texture:C,size:new Ut(v,R)},n.set(o,u),o.addEventListener("dispose",S)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let p=0;for(let _=0;_<l.length;_++)p+=l[_];let g=o.morphTargetsRelative?1:1-p;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",u.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",u.size)}return{update:r}}function fp(i,t,e,n){let s=new WeakMap;function r(c){let l=n.render.frame,h=c.geometry,f=t.get(c,h);if(s.get(f)!==l&&(t.update(f),s.set(f,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),s.get(c)!==l&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),s.set(c,l))),c.isSkinnedMesh){let u=c.skeleton;s.get(u)!==l&&(u.update(),s.set(u,l))}return f}function a(){s=new WeakMap}function o(c){let l=c.target;l.removeEventListener("dispose",o),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:r,dispose:a}}var th=new Re,Fc=new fs(1,1),eh=new is,nh=new dr,ih=new ls,Oc=[],Bc=[],zc=new Float32Array(16),kc=new Float32Array(9),Hc=new Float32Array(4);function ki(i,t,e){let n=i[0];if(n<=0||n>0)return i;let s=t*e,r=Oc[s];if(r===void 0&&(r=new Float32Array(s),Oc[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function ue(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 de(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Ea(i,t){let e=Bc[t];e===void 0&&(e=new Int32Array(t),Bc[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function pp(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function mp(i,t){let 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(ue(e,t))return;i.uniform2fv(this.addr,t),de(e,t)}}function gp(i,t){let 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(ue(e,t))return;i.uniform3fv(this.addr,t),de(e,t)}}function _p(i,t){let 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(ue(e,t))return;i.uniform4fv(this.addr,t),de(e,t)}}function xp(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ue(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),de(e,t)}else{if(ue(e,n))return;Hc.set(n),i.uniformMatrix2fv(this.addr,!1,Hc),de(e,n)}}function yp(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ue(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),de(e,t)}else{if(ue(e,n))return;kc.set(n),i.uniformMatrix3fv(this.addr,!1,kc),de(e,n)}}function vp(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ue(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),de(e,t)}else{if(ue(e,n))return;zc.set(n),i.uniformMatrix4fv(this.addr,!1,zc),de(e,n)}}function Mp(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function bp(i,t){let 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(ue(e,t))return;i.uniform2iv(this.addr,t),de(e,t)}}function Sp(i,t){let 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(ue(e,t))return;i.uniform3iv(this.addr,t),de(e,t)}}function Ep(i,t){let 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(ue(e,t))return;i.uniform4iv(this.addr,t),de(e,t)}}function Tp(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function wp(i,t){let 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(ue(e,t))return;i.uniform2uiv(this.addr,t),de(e,t)}}function Ap(i,t){let 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(ue(e,t))return;i.uniform3uiv(this.addr,t),de(e,t)}}function Rp(i,t){let 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(ue(e,t))return;i.uniform4uiv(this.addr,t),de(e,t)}}function Cp(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(Fc.compareFunction=Io,r=Fc):r=th,e.setTexture2D(t||r,s)}function Pp(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||nh,s)}function Ip(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||ih,s)}function Lp(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||eh,s)}function Dp(i){switch(i){case 5126:return pp;case 35664:return mp;case 35665:return gp;case 35666:return _p;case 35674:return xp;case 35675:return yp;case 35676:return vp;case 5124:case 35670:return Mp;case 35667:case 35671:return bp;case 35668:case 35672:return Sp;case 35669:case 35673:return Ep;case 5125:return Tp;case 36294:return wp;case 36295:return Ap;case 36296:return Rp;case 35678:case 36198:case 36298:case 36306:case 35682:return Cp;case 35679:case 36299:case 36307:return Pp;case 35680:case 36300:case 36308:case 36293:return Ip;case 36289:case 36303:case 36311:case 36292:return Lp}}function Up(i,t){i.uniform1fv(this.addr,t)}function Np(i,t){let e=ki(t,this.size,2);i.uniform2fv(this.addr,e)}function Fp(i,t){let e=ki(t,this.size,3);i.uniform3fv(this.addr,e)}function Op(i,t){let e=ki(t,this.size,4);i.uniform4fv(this.addr,e)}function Bp(i,t){let e=ki(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function zp(i,t){let e=ki(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function kp(i,t){let e=ki(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function Hp(i,t){i.uniform1iv(this.addr,t)}function Vp(i,t){i.uniform2iv(this.addr,t)}function Gp(i,t){i.uniform3iv(this.addr,t)}function Wp(i,t){i.uniform4iv(this.addr,t)}function Xp(i,t){i.uniform1uiv(this.addr,t)}function qp(i,t){i.uniform2uiv(this.addr,t)}function Yp(i,t){i.uniform3uiv(this.addr,t)}function Zp(i,t){i.uniform4uiv(this.addr,t)}function $p(i,t,e){let n=this.cache,s=t.length,r=Ea(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||th,r[a])}function Jp(i,t,e){let n=this.cache,s=t.length,r=Ea(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||nh,r[a])}function Kp(i,t,e){let n=this.cache,s=t.length,r=Ea(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||ih,r[a])}function jp(i,t,e){let n=this.cache,s=t.length,r=Ea(e,s);ue(n,r)||(i.uniform1iv(this.addr,r),de(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||eh,r[a])}function Qp(i){switch(i){case 5126:return Up;case 35664:return Np;case 35665:return Fp;case 35666:return Op;case 35674:return Bp;case 35675:return zp;case 35676:return kp;case 5124:case 35670:return Hp;case 35667:case 35671:return Vp;case 35668:case 35672:return Gp;case 35669:case 35673:return Wp;case 5125:return Xp;case 36294:return qp;case 36295:return Yp;case 36296:return Zp;case 35678:case 36198:case 36298:case 36306:case 35682:return $p;case 35679:case 36299:case 36307:return Jp;case 35680:case 36300:case 36308:case 36293:return Kp;case 36289:case 36303:case 36311:case 36292:return jp}}var qo=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Dp(e.type)}},Yo=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=Qp(e.type)}},Zo=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let s=this.seq;for(let r=0,a=s.length;r!==a;++r){let o=s[r];o.setValue(t,e[o.id],n)}}},Xo=/(\w+)(\])?(\[|\.)?/g;function Vc(i,t){i.seq.push(t),i.map[t.id]=t}function tm(i,t,e){let n=i.name,s=n.length;for(Xo.lastIndex=0;;){let r=Xo.exec(n),a=Xo.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Vc(e,l===void 0?new qo(o,i,t):new Yo(o,i,t));break}else{let f=e.map[o];f===void 0&&(f=new Zo(o),Vc(e,f)),e=f}}}var zi=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){let r=t.getActiveUniform(e,s),a=t.getUniformLocation(e,r.name);tm(r,a,this)}}setValue(t,e,n,s){let r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){let s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let r=0,a=e.length;r!==a;++r){let o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,s)}}static seqWithValue(t,e){let n=[];for(let s=0,r=t.length;s!==r;++s){let a=t[s];a.id in e&&n.push(a)}return n}};function Gc(i,t,e){let n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}var em=37297,nm=0;function im(i,t){let e=i.split(`
3730
+ `),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){let o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
3731
+ `)}var Wc=new Lt;function sm(i){Vt._getMatrix(Wc,Vt.workingColorSpace,i);let t=`mat3( ${Wc.elements.map(e=>e.toFixed(4))} )`;switch(Vt.getTransfer(i)){case ts:return[t,"LinearTransferOETF"];case qt:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Xc(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let o=parseInt(a[1]);return e.toUpperCase()+`
3732
+
3733
+ `+r+`
3734
+
3735
+ `+im(i.getShaderSource(t),o)}else return r}function rm(i,t){let e=sm(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
3736
+ `)}function am(i,t){let e;switch(t){case ac:e="Linear";break;case oc:e="Reinhard";break;case lc:e="Cineon";break;case cc:e="ACESFilmic";break;case uc:e="AgX";break;case dc:e="Neutral";break;case hc:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var Ma=new N;function om(){Vt.getLuminanceCoefficients(Ma);let i=Ma.x.toFixed(4),t=Ma.y.toFixed(4),e=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3737
+ `)}function lm(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ws).join(`
3738
+ `)}function cm(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3739
+ `)}function hm(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let r=i.getActiveAttrib(t,s),a=r.name,o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function ws(i){return i!==""}function qc(i,t){let 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 Yc(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var um=/^[ \t]*#include +<([\w\d./]+)>/gm;function $o(i){return i.replace(um,fm)}var dm=new Map;function fm(i,t){let e=Ft[t];if(e===void 0){let n=dm.get(t);if(n!==void 0)e=Ft[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 $o(e)}var pm=/#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 Zc(i){return i.replace(pm,mm)}function mm(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function $c(i){let t=`precision ${i.precision} float;
3740
+ precision ${i.precision} int;
3741
+ precision ${i.precision} sampler2D;
3742
+ precision ${i.precision} samplerCube;
3743
+ precision ${i.precision} sampler3D;
3744
+ precision ${i.precision} sampler2DArray;
3745
+ precision ${i.precision} sampler2DShadow;
3746
+ precision ${i.precision} samplerCubeShadow;
3747
+ precision ${i.precision} sampler2DArrayShadow;
3748
+ precision ${i.precision} isampler2D;
3749
+ precision ${i.precision} isampler3D;
3750
+ precision ${i.precision} isamplerCube;
3751
+ precision ${i.precision} isampler2DArray;
3752
+ precision ${i.precision} usampler2D;
3753
+ precision ${i.precision} usampler3D;
3754
+ precision ${i.precision} usamplerCube;
3755
+ precision ${i.precision} usampler2DArray;
3756
+ `;return i.precision==="highp"?t+=`
3757
+ #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3758
+ #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3759
+ #define LOW_PRECISION`),t}function gm(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===xo?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===zl?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===rn&&(t="SHADOWMAP_TYPE_VSM"),t}function _m(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Kn:case jn:t="ENVMAP_TYPE_CUBE";break;case vs:t="ENVMAP_TYPE_CUBE_UV";break}return t}function xm(i){let t="ENVMAP_MODE_REFLECTION";return i.envMap&&i.envMapMode===jn&&(t="ENVMAP_MODE_REFRACTION"),t}function ym(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Mo:t="ENVMAP_BLENDING_MULTIPLY";break;case sc:t="ENVMAP_BLENDING_MIX";break;case rc:t="ENVMAP_BLENDING_ADD";break}return t}function vm(i){let t=i.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function Mm(i,t,e,n){let s=i.getContext(),r=e.defines,a=e.vertexShader,o=e.fragmentShader,c=gm(e),l=_m(e),h=xm(e),f=ym(e),u=vm(e),p=lm(e),g=cm(r),_=s.createProgram(),m,d,T=e.glslVersion?"#version "+e.glslVersion+`
3760
+ `:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ws).join(`
3761
+ `),m.length>0&&(m+=`
3762
+ `),d=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ws).join(`
3763
+ `),d.length>0&&(d+=`
3764
+ `)):(m=[$c(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,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 "+h:"",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 "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","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",`
3765
+ `].filter(ws).join(`
3766
+ `),d=[$c(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,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 "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+f:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.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 "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==vn?"#define TONE_MAPPING":"",e.toneMapping!==vn?Ft.tonemapping_pars_fragment:"",e.toneMapping!==vn?am("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Ft.colorspace_pars_fragment,rm("linearToOutputTexel",e.outputColorSpace),om(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
3767
+ `].filter(ws).join(`
3768
+ `)),a=$o(a),a=qc(a,e),a=Yc(a,e),o=$o(o),o=qc(o,e),o=Yc(o,e),a=Zc(a),o=Zc(o),e.isRawShaderMaterial!==!0&&(T=`#version 300 es
3769
+ `,m=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
3770
+ `)+`
3771
+ `+m,d=["#define varying in",e.glslVersion===Lo?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Lo?"":"#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(`
3772
+ `)+`
3773
+ `+d);let M=T+m+a,v=T+d+o,R=Gc(s,s.VERTEX_SHADER,M),w=Gc(s,s.FRAGMENT_SHADER,v);s.attachShader(_,R),s.attachShader(_,w),e.index0AttributeName!==void 0?s.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function C(P){if(i.debug.checkShaderErrors){let B=s.getProgramInfoLog(_)||"",V=s.getShaderInfoLog(R)||"",X=s.getShaderInfoLog(w)||"",Z=B.trim(),W=V.trim(),et=X.trim(),k=!0,rt=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(k=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,_,R,w);else{let ct=Xc(s,R,"vertex"),bt=Xc(s,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+`
3774
+
3775
+ Material Name: `+P.name+`
3776
+ Material Type: `+P.type+`
3777
+
3778
+ Program Info Log: `+Z+`
3779
+ `+ct+`
3780
+ `+bt)}else Z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Z):(W===""||et==="")&&(rt=!1);rt&&(P.diagnostics={runnable:k,programLog:Z,vertexShader:{log:W,prefix:m},fragmentShader:{log:et,prefix:d}})}s.deleteShader(R),s.deleteShader(w),U=new zi(s,_),S=hm(s,_)}let U;this.getUniforms=function(){return U===void 0&&C(this),U};let S;this.getAttributes=function(){return S===void 0&&C(this),S};let b=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=s.getProgramParameter(_,em)),b},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=nm++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=R,this.fragmentShader=w,this}var bm=0,Jo=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let 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){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new Ko(t),e.set(t,n)),n}},Ko=class{constructor(t){this.id=bm++,this.code=t,this.usedTimes=0}};function Sm(i,t,e,n,s,r,a){let o=new ss,c=new Jo,l=new Set,h=[],f=s.logarithmicDepthBuffer,u=s.vertexTextures,p=s.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(S){return l.add(S),S===0?"uv":`uv${S}`}function m(S,b,P,B,V){let X=B.fog,Z=V.geometry,W=S.isMeshStandardMaterial?B.environment:null,et=(S.isMeshStandardMaterial?e:t).get(S.envMap||W),k=et&&et.mapping===vs?et.image.height:null,rt=g[S.type];S.precision!==null&&(p=s.getMaxPrecision(S.precision),p!==S.precision&&console.warn("THREE.WebGLProgram.getParameters:",S.precision,"not supported, using",p,"instead."));let ct=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,bt=ct!==void 0?ct.length:0,Bt=0;Z.morphAttributes.position!==void 0&&(Bt=1),Z.morphAttributes.normal!==void 0&&(Bt=2),Z.morphAttributes.color!==void 0&&(Bt=3);let Jt,te,Wt,q;if(rt){let Xt=ln[rt];Jt=Xt.vertexShader,te=Xt.fragmentShader}else Jt=S.vertexShader,te=S.fragmentShader,c.update(S),Wt=c.getVertexShaderID(S),q=c.getFragmentShaderID(S);let J=i.getRenderTarget(),dt=i.state.buffers.depth.getReversed(),Ct=V.isInstancedMesh===!0,Mt=V.isBatchedMesh===!0,Ht=!!S.map,ge=!!S.matcap,A=!!et,ee=!!S.aoMap,It=!!S.lightMap,At=!!S.bumpMap,mt=!!S.normalMap,ne=!!S.displacementMap,gt=!!S.emissiveMap,Nt=!!S.metalnessMap,pe=!!S.roughnessMap,le=S.anisotropy>0,E=S.clearcoat>0,x=S.dispersion>0,F=S.iridescence>0,G=S.sheen>0,$=S.transmission>0,H=le&&!!S.anisotropyMap,vt=E&&!!S.clearcoatMap,nt=E&&!!S.clearcoatNormalMap,_t=E&&!!S.clearcoatRoughnessMap,xt=F&&!!S.iridescenceMap,Q=F&&!!S.iridescenceThicknessMap,lt=G&&!!S.sheenColorMap,wt=G&&!!S.sheenRoughnessMap,yt=!!S.specularMap,at=!!S.specularColorMap,Dt=!!S.specularIntensityMap,I=$&&!!S.transmissionMap,tt=$&&!!S.thicknessMap,it=!!S.gradientMap,ut=!!S.alphaMap,K=S.alphaTest>0,Y=!!S.alphaHash,pt=!!S.extensions,Pt=vn;S.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(Pt=i.toneMapping);let Kt={shaderID:rt,shaderType:S.type,shaderName:S.name,vertexShader:Jt,fragmentShader:te,defines:S.defines,customVertexShaderID:Wt,customFragmentShaderID:q,isRawShaderMaterial:S.isRawShaderMaterial===!0,glslVersion:S.glslVersion,precision:p,batching:Mt,batchingColor:Mt&&V._colorsTexture!==null,instancing:Ct,instancingColor:Ct&&V.instanceColor!==null,instancingMorph:Ct&&V.morphTexture!==null,supportsVertexTextures:u,outputColorSpace:J===null?i.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:Zn,alphaToCoverage:!!S.alphaToCoverage,map:Ht,matcap:ge,envMap:A,envMapMode:A&&et.mapping,envMapCubeUVHeight:k,aoMap:ee,lightMap:It,bumpMap:At,normalMap:mt,displacementMap:u&&ne,emissiveMap:gt,normalMapObjectSpace:mt&&S.normalMapType===_c,normalMapTangentSpace:mt&&S.normalMapType===gc,metalnessMap:Nt,roughnessMap:pe,anisotropy:le,anisotropyMap:H,clearcoat:E,clearcoatMap:vt,clearcoatNormalMap:nt,clearcoatRoughnessMap:_t,dispersion:x,iridescence:F,iridescenceMap:xt,iridescenceThicknessMap:Q,sheen:G,sheenColorMap:lt,sheenRoughnessMap:wt,specularMap:yt,specularColorMap:at,specularIntensityMap:Dt,transmission:$,transmissionMap:I,thicknessMap:tt,gradientMap:it,opaque:S.transparent===!1&&S.blending===_n&&S.alphaToCoverage===!1,alphaMap:ut,alphaTest:K,alphaHash:Y,combine:S.combine,mapUv:Ht&&_(S.map.channel),aoMapUv:ee&&_(S.aoMap.channel),lightMapUv:It&&_(S.lightMap.channel),bumpMapUv:At&&_(S.bumpMap.channel),normalMapUv:mt&&_(S.normalMap.channel),displacementMapUv:ne&&_(S.displacementMap.channel),emissiveMapUv:gt&&_(S.emissiveMap.channel),metalnessMapUv:Nt&&_(S.metalnessMap.channel),roughnessMapUv:pe&&_(S.roughnessMap.channel),anisotropyMapUv:H&&_(S.anisotropyMap.channel),clearcoatMapUv:vt&&_(S.clearcoatMap.channel),clearcoatNormalMapUv:nt&&_(S.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:_t&&_(S.clearcoatRoughnessMap.channel),iridescenceMapUv:xt&&_(S.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&_(S.iridescenceThicknessMap.channel),sheenColorMapUv:lt&&_(S.sheenColorMap.channel),sheenRoughnessMapUv:wt&&_(S.sheenRoughnessMap.channel),specularMapUv:yt&&_(S.specularMap.channel),specularColorMapUv:at&&_(S.specularColorMap.channel),specularIntensityMapUv:Dt&&_(S.specularIntensityMap.channel),transmissionMapUv:I&&_(S.transmissionMap.channel),thicknessMapUv:tt&&_(S.thicknessMap.channel),alphaMapUv:ut&&_(S.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(mt||le),vertexColors:S.vertexColors,vertexAlphas:S.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:V.isPoints===!0&&!!Z.attributes.uv&&(Ht||ut),fog:!!X,useFog:S.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:S.flatShading===!0&&S.wireframe===!1,sizeAttenuation:S.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:dt,skinning:V.isSkinnedMesh===!0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:bt,morphTextureStride:Bt,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:S.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:Pt,decodeVideoTexture:Ht&&S.map.isVideoTexture===!0&&Vt.getTransfer(S.map.colorSpace)===qt,decodeVideoTextureEmissive:gt&&S.emissiveMap.isVideoTexture===!0&&Vt.getTransfer(S.emissiveMap.colorSpace)===qt,premultipliedAlpha:S.premultipliedAlpha,doubleSided:S.side===Xe,flipSided:S.side===Ee,useDepthPacking:S.depthPacking>=0,depthPacking:S.depthPacking||0,index0AttributeName:S.index0AttributeName,extensionClipCullDistance:pt&&S.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(pt&&S.extensions.multiDraw===!0||Mt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:S.customProgramCacheKey()};return Kt.vertexUv1s=l.has(1),Kt.vertexUv2s=l.has(2),Kt.vertexUv3s=l.has(3),l.clear(),Kt}function d(S){let b=[];if(S.shaderID?b.push(S.shaderID):(b.push(S.customVertexShaderID),b.push(S.customFragmentShaderID)),S.defines!==void 0)for(let P in S.defines)b.push(P),b.push(S.defines[P]);return S.isRawShaderMaterial===!1&&(T(b,S),M(b,S),b.push(i.outputColorSpace)),b.push(S.customProgramCacheKey),b.join()}function T(S,b){S.push(b.precision),S.push(b.outputColorSpace),S.push(b.envMapMode),S.push(b.envMapCubeUVHeight),S.push(b.mapUv),S.push(b.alphaMapUv),S.push(b.lightMapUv),S.push(b.aoMapUv),S.push(b.bumpMapUv),S.push(b.normalMapUv),S.push(b.displacementMapUv),S.push(b.emissiveMapUv),S.push(b.metalnessMapUv),S.push(b.roughnessMapUv),S.push(b.anisotropyMapUv),S.push(b.clearcoatMapUv),S.push(b.clearcoatNormalMapUv),S.push(b.clearcoatRoughnessMapUv),S.push(b.iridescenceMapUv),S.push(b.iridescenceThicknessMapUv),S.push(b.sheenColorMapUv),S.push(b.sheenRoughnessMapUv),S.push(b.specularMapUv),S.push(b.specularColorMapUv),S.push(b.specularIntensityMapUv),S.push(b.transmissionMapUv),S.push(b.thicknessMapUv),S.push(b.combine),S.push(b.fogExp2),S.push(b.sizeAttenuation),S.push(b.morphTargetsCount),S.push(b.morphAttributeCount),S.push(b.numDirLights),S.push(b.numPointLights),S.push(b.numSpotLights),S.push(b.numSpotLightMaps),S.push(b.numHemiLights),S.push(b.numRectAreaLights),S.push(b.numDirLightShadows),S.push(b.numPointLightShadows),S.push(b.numSpotLightShadows),S.push(b.numSpotLightShadowsWithMaps),S.push(b.numLightProbes),S.push(b.shadowMapType),S.push(b.toneMapping),S.push(b.numClippingPlanes),S.push(b.numClipIntersection),S.push(b.depthPacking)}function M(S,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),b.gradientMap&&o.enable(22),S.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reversedDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.decodeVideoTextureEmissive&&o.enable(20),b.alphaToCoverage&&o.enable(21),S.push(o.mask)}function v(S){let b=g[S.type],P;if(b){let B=ln[b];P=Rc.clone(B.uniforms)}else P=S.uniforms;return P}function R(S,b){let P;for(let B=0,V=h.length;B<V;B++){let X=h[B];if(X.cacheKey===b){P=X,++P.usedTimes;break}}return P===void 0&&(P=new Mm(i,b,S,r),h.push(P)),P}function w(S){if(--S.usedTimes===0){let b=h.indexOf(S);h[b]=h[h.length-1],h.pop(),S.destroy()}}function C(S){c.remove(S)}function U(){c.dispose()}return{getParameters:m,getProgramCacheKey:d,getUniforms:v,acquireProgram:R,releaseProgram:w,releaseShaderCache:C,programs:h,dispose:U}}function Em(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function Tm(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 Jc(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 Kc(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(f,u,p,g,_,m){let d=i[t];return d===void 0?(d={id:f.id,object:f,geometry:u,material:p,groupOrder:g,renderOrder:f.renderOrder,z:_,group:m},i[t]=d):(d.id=f.id,d.object=f,d.geometry=u,d.material=p,d.groupOrder=g,d.renderOrder=f.renderOrder,d.z=_,d.group=m),t++,d}function o(f,u,p,g,_,m){let d=a(f,u,p,g,_,m);p.transmission>0?n.push(d):p.transparent===!0?s.push(d):e.push(d)}function c(f,u,p,g,_,m){let d=a(f,u,p,g,_,m);p.transmission>0?n.unshift(d):p.transparent===!0?s.unshift(d):e.unshift(d)}function l(f,u){e.length>1&&e.sort(f||Tm),n.length>1&&n.sort(u||Jc),s.length>1&&s.sort(u||Jc)}function h(){for(let f=t,u=i.length;f<u;f++){let p=i[f];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:c,finish:h,sort:l}}function wm(){let i=new WeakMap;function t(n,s){let r=i.get(n),a;return r===void 0?(a=new Kc,i.set(n,[a])):s>=r.length?(a=new Kc,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Am(){let 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 N,color:new zt};break;case"SpotLight":e={position:new N,direction:new N,color:new zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new N,color:new zt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new N,skyColor:new zt,groundColor:new zt};break;case"RectAreaLight":e={color:new zt,position:new N,halfWidth:new N,halfHeight:new N};break}return i[t.id]=e,e}}}function Rm(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ut};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ut};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ut,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Cm=0;function Pm(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Im(i){let t=new Am,e=Rm(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new N);let s=new N,r=new ce,a=new ce;function o(l){let h=0,f=0,u=0;for(let S=0;S<9;S++)n.probe[S].set(0,0,0);let p=0,g=0,_=0,m=0,d=0,T=0,M=0,v=0,R=0,w=0,C=0;l.sort(Pm);for(let S=0,b=l.length;S<b;S++){let P=l[S],B=P.color,V=P.intensity,X=P.distance,Z=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)h+=B.r*V,f+=B.g*V,u+=B.b*V;else if(P.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(P.sh.coefficients[W],V);C++}else if(P.isDirectionalLight){let W=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let et=P.shadow,k=e.get(P);k.shadowIntensity=et.intensity,k.shadowBias=et.bias,k.shadowNormalBias=et.normalBias,k.shadowRadius=et.radius,k.shadowMapSize=et.mapSize,n.directionalShadow[p]=k,n.directionalShadowMap[p]=Z,n.directionalShadowMatrix[p]=P.shadow.matrix,T++}n.directional[p]=W,p++}else if(P.isSpotLight){let W=t.get(P);W.position.setFromMatrixPosition(P.matrixWorld),W.color.copy(B).multiplyScalar(V),W.distance=X,W.coneCos=Math.cos(P.angle),W.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),W.decay=P.decay,n.spot[_]=W;let et=P.shadow;if(P.map&&(n.spotLightMap[R]=P.map,R++,et.updateMatrices(P),P.castShadow&&w++),n.spotLightMatrix[_]=et.matrix,P.castShadow){let k=e.get(P);k.shadowIntensity=et.intensity,k.shadowBias=et.bias,k.shadowNormalBias=et.normalBias,k.shadowRadius=et.radius,k.shadowMapSize=et.mapSize,n.spotShadow[_]=k,n.spotShadowMap[_]=Z,v++}_++}else if(P.isRectAreaLight){let W=t.get(P);W.color.copy(B).multiplyScalar(V),W.halfWidth.set(P.width*.5,0,0),W.halfHeight.set(0,P.height*.5,0),n.rectArea[m]=W,m++}else if(P.isPointLight){let W=t.get(P);if(W.color.copy(P.color).multiplyScalar(P.intensity),W.distance=P.distance,W.decay=P.decay,P.castShadow){let et=P.shadow,k=e.get(P);k.shadowIntensity=et.intensity,k.shadowBias=et.bias,k.shadowNormalBias=et.normalBias,k.shadowRadius=et.radius,k.shadowMapSize=et.mapSize,k.shadowCameraNear=et.camera.near,k.shadowCameraFar=et.camera.far,n.pointShadow[g]=k,n.pointShadowMap[g]=Z,n.pointShadowMatrix[g]=P.shadow.matrix,M++}n.point[g]=W,g++}else if(P.isHemisphereLight){let W=t.get(P);W.skyColor.copy(P.color).multiplyScalar(V),W.groundColor.copy(P.groundColor).multiplyScalar(V),n.hemi[d]=W,d++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=st.LTC_FLOAT_1,n.rectAreaLTC2=st.LTC_FLOAT_2):(n.rectAreaLTC1=st.LTC_HALF_1,n.rectAreaLTC2=st.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=f,n.ambient[2]=u;let U=n.hash;(U.directionalLength!==p||U.pointLength!==g||U.spotLength!==_||U.rectAreaLength!==m||U.hemiLength!==d||U.numDirectionalShadows!==T||U.numPointShadows!==M||U.numSpotShadows!==v||U.numSpotMaps!==R||U.numLightProbes!==C)&&(n.directional.length=p,n.spot.length=_,n.rectArea.length=m,n.point.length=g,n.hemi.length=d,n.directionalShadow.length=T,n.directionalShadowMap.length=T,n.pointShadow.length=M,n.pointShadowMap.length=M,n.spotShadow.length=v,n.spotShadowMap.length=v,n.directionalShadowMatrix.length=T,n.pointShadowMatrix.length=M,n.spotLightMatrix.length=v+R-w,n.spotLightMap.length=R,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=C,U.directionalLength=p,U.pointLength=g,U.spotLength=_,U.rectAreaLength=m,U.hemiLength=d,U.numDirectionalShadows=T,U.numPointShadows=M,U.numSpotShadows=v,U.numSpotMaps=R,U.numLightProbes=C,n.version=Cm++)}function c(l,h){let f=0,u=0,p=0,g=0,_=0,m=h.matrixWorldInverse;for(let d=0,T=l.length;d<T;d++){let M=l[d];if(M.isDirectionalLight){let v=n.directional[f];v.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),v.direction.sub(s),v.direction.transformDirection(m),f++}else if(M.isSpotLight){let v=n.spot[p];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),v.direction.setFromMatrixPosition(M.matrixWorld),s.setFromMatrixPosition(M.target.matrixWorld),v.direction.sub(s),v.direction.transformDirection(m),p++}else if(M.isRectAreaLight){let v=n.rectArea[g];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),a.identity(),r.copy(M.matrixWorld),r.premultiply(m),a.extractRotation(r),v.halfWidth.set(M.width*.5,0,0),v.halfHeight.set(0,M.height*.5,0),v.halfWidth.applyMatrix4(a),v.halfHeight.applyMatrix4(a),g++}else if(M.isPointLight){let v=n.point[u];v.position.setFromMatrixPosition(M.matrixWorld),v.position.applyMatrix4(m),u++}else if(M.isHemisphereLight){let v=n.hemi[_];v.direction.setFromMatrixPosition(M.matrixWorld),v.direction.transformDirection(m),_++}}}return{setup:o,setupView:c,state:n}}function jc(i){let t=new Im(i),e=[],n=[];function s(h){l.camera=h,e.length=0,n.length=0}function r(h){e.push(h)}function a(h){n.push(h)}function o(){t.setup(e)}function c(h){t.setupView(e,h)}let l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:l,setupLights:o,setupLightsView:c,pushLight:r,pushShadow:a}}function Lm(i){let t=new WeakMap;function e(s,r=0){let a=t.get(s),o;return a===void 0?(o=new jc(i),t.set(s,[o])):r>=a.length?(o=new jc(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}var Dm=`void main() {
3781
+ gl_Position = vec4( position, 1.0 );
3782
+ }`,Um=`uniform sampler2D shadow_pass;
3783
+ uniform vec2 resolution;
3784
+ uniform float radius;
3785
+ #include <packing>
3786
+ void main() {
3787
+ const float samples = float( VSM_SAMPLES );
3788
+ float mean = 0.0;
3789
+ float squared_mean = 0.0;
3790
+ float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
3791
+ float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
3792
+ for ( float i = 0.0; i < samples; i ++ ) {
3793
+ float uvOffset = uvStart + i * uvStride;
3794
+ #ifdef HORIZONTAL_PASS
3795
+ vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
3796
+ mean += distribution.x;
3797
+ squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
3798
+ #else
3799
+ float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
3800
+ mean += depth;
3801
+ squared_mean += depth * depth;
3802
+ #endif
3803
+ }
3804
+ mean = mean / samples;
3805
+ squared_mean = squared_mean / samples;
3806
+ float std_dev = sqrt( squared_mean - mean * mean );
3807
+ gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3808
+ }`;function Nm(i,t,e){let n=new hs,s=new Ut,r=new Ut,a=new oe,o=new _r({depthPacking:mc}),c=new xr,l={},h=e.maxTextureSize,f={[gn]:Ee,[Ee]:gn,[Xe]:Xe},u=new je({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ut},radius:{value:4}},vertexShader:Dm,fragmentShader:Um}),p=u.clone();p.defines.HORIZONTAL_PASS=1;let g=new ye;g.setAttribute("position",new ae(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new Pe(g,u),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xo;let d=this.type;this.render=function(w,C,U){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||w.length===0)return;let S=i.getRenderTarget(),b=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),B=i.state;B.setBlending(yn),B.buffers.depth.getReversed()===!0?B.buffers.color.setClear(0,0,0,0):B.buffers.color.setClear(1,1,1,1),B.buffers.depth.setTest(!0),B.setScissorTest(!1);let V=d!==rn&&this.type===rn,X=d===rn&&this.type!==rn;for(let Z=0,W=w.length;Z<W;Z++){let et=w[Z],k=et.shadow;if(k===void 0){console.warn("THREE.WebGLShadowMap:",et,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;s.copy(k.mapSize);let rt=k.getFrameExtents();if(s.multiply(rt),r.copy(k.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/rt.x),s.x=r.x*rt.x,k.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/rt.y),s.y=r.y*rt.y,k.mapSize.y=r.y)),k.map===null||V===!0||X===!0){let bt=this.type!==rn?{minFilter:Ge,magFilter:Ge}:{};k.map!==null&&k.map.dispose(),k.map=new en(s.x,s.y,bt),k.map.texture.name=et.name+".shadowMap",k.camera.updateProjectionMatrix()}i.setRenderTarget(k.map),i.clear();let ct=k.getViewportCount();for(let bt=0;bt<ct;bt++){let Bt=k.getViewport(bt);a.set(r.x*Bt.x,r.y*Bt.y,r.x*Bt.z,r.y*Bt.w),B.viewport(a),k.updateMatrices(et,bt),n=k.getFrustum(),v(C,U,k.camera,et,this.type)}k.isPointLightShadow!==!0&&this.type===rn&&T(k,U),k.needsUpdate=!1}d=this.type,m.needsUpdate=!1,i.setRenderTarget(S,b,P)};function T(w,C){let U=t.update(_);u.defines.VSM_SAMPLES!==w.blurSamples&&(u.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,u.needsUpdate=!0,p.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new en(s.x,s.y)),u.uniforms.shadow_pass.value=w.map.texture,u.uniforms.resolution.value=w.mapSize,u.uniforms.radius.value=w.radius,i.setRenderTarget(w.mapPass),i.clear(),i.renderBufferDirect(C,null,U,u,_,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,i.setRenderTarget(w.map),i.clear(),i.renderBufferDirect(C,null,U,p,_,null)}function M(w,C,U,S){let b=null,P=U.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(P!==void 0)b=P;else if(b=U.isPointLight===!0?c:o,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||C.alphaToCoverage===!0){let B=b.uuid,V=C.uuid,X=l[B];X===void 0&&(X={},l[B]=X);let Z=X[V];Z===void 0&&(Z=b.clone(),X[V]=Z,C.addEventListener("dispose",R)),b=Z}if(b.visible=C.visible,b.wireframe=C.wireframe,S===rn?b.side=C.shadowSide!==null?C.shadowSide:C.side:b.side=C.shadowSide!==null?C.shadowSide:f[C.side],b.alphaMap=C.alphaMap,b.alphaTest=C.alphaToCoverage===!0?.5:C.alphaTest,b.map=C.map,b.clipShadows=C.clipShadows,b.clippingPlanes=C.clippingPlanes,b.clipIntersection=C.clipIntersection,b.displacementMap=C.displacementMap,b.displacementScale=C.displacementScale,b.displacementBias=C.displacementBias,b.wireframeLinewidth=C.wireframeLinewidth,b.linewidth=C.linewidth,U.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let B=i.properties.get(b);B.light=U}return b}function v(w,C,U,S,b){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&b===rn)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(U.matrixWorldInverse,w.matrixWorld);let V=t.update(w),X=w.material;if(Array.isArray(X)){let Z=V.groups;for(let W=0,et=Z.length;W<et;W++){let k=Z[W],rt=X[k.materialIndex];if(rt&&rt.visible){let ct=M(w,rt,S,b);w.onBeforeShadow(i,w,C,U,V,ct,k),i.renderBufferDirect(U,null,V,ct,w,k),w.onAfterShadow(i,w,C,U,V,ct,k)}}}else if(X.visible){let Z=M(w,X,S,b);w.onBeforeShadow(i,w,C,U,V,Z,null),i.renderBufferDirect(U,null,V,Z,w,null),w.onAfterShadow(i,w,C,U,V,Z,null)}}let B=w.children;for(let V=0,X=B.length;V<X;V++)v(B[V],C,U,S,b)}function R(w){w.target.removeEventListener("dispose",R);for(let U in l){let S=l[U],b=w.target.uuid;b in S&&(S[b].dispose(),delete S[b])}}}var Fm={[Cr]:Pr,[Ir]:Ur,[Lr]:Nr,[Yn]:Dr,[Pr]:Cr,[Ur]:Ir,[Nr]:Lr,[Dr]:Yn};function Om(i,t){function e(){let I=!1,tt=new oe,it=null,ut=new oe(0,0,0,0);return{setMask:function(K){it!==K&&!I&&(i.colorMask(K,K,K,K),it=K)},setLocked:function(K){I=K},setClear:function(K,Y,pt,Pt,Kt){Kt===!0&&(K*=Pt,Y*=Pt,pt*=Pt),tt.set(K,Y,pt,Pt),ut.equals(tt)===!1&&(i.clearColor(K,Y,pt,Pt),ut.copy(tt))},reset:function(){I=!1,it=null,ut.set(-1,0,0,0)}}}function n(){let I=!1,tt=!1,it=null,ut=null,K=null;return{setReversed:function(Y){if(tt!==Y){let pt=t.get("EXT_clip_control");Y?pt.clipControlEXT(pt.LOWER_LEFT_EXT,pt.ZERO_TO_ONE_EXT):pt.clipControlEXT(pt.LOWER_LEFT_EXT,pt.NEGATIVE_ONE_TO_ONE_EXT),tt=Y;let Pt=K;K=null,this.setClear(Pt)}},getReversed:function(){return tt},setTest:function(Y){Y?J(i.DEPTH_TEST):dt(i.DEPTH_TEST)},setMask:function(Y){it!==Y&&!I&&(i.depthMask(Y),it=Y)},setFunc:function(Y){if(tt&&(Y=Fm[Y]),ut!==Y){switch(Y){case Cr:i.depthFunc(i.NEVER);break;case Pr:i.depthFunc(i.ALWAYS);break;case Ir:i.depthFunc(i.LESS);break;case Yn:i.depthFunc(i.LEQUAL);break;case Lr:i.depthFunc(i.EQUAL);break;case Dr:i.depthFunc(i.GEQUAL);break;case Ur:i.depthFunc(i.GREATER);break;case Nr:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ut=Y}},setLocked:function(Y){I=Y},setClear:function(Y){K!==Y&&(tt&&(Y=1-Y),i.clearDepth(Y),K=Y)},reset:function(){I=!1,it=null,ut=null,K=null,tt=!1}}}function s(){let I=!1,tt=null,it=null,ut=null,K=null,Y=null,pt=null,Pt=null,Kt=null;return{setTest:function(Xt){I||(Xt?J(i.STENCIL_TEST):dt(i.STENCIL_TEST))},setMask:function(Xt){tt!==Xt&&!I&&(i.stencilMask(Xt),tt=Xt)},setFunc:function(Xt,cn,Qe){(it!==Xt||ut!==cn||K!==Qe)&&(i.stencilFunc(Xt,cn,Qe),it=Xt,ut=cn,K=Qe)},setOp:function(Xt,cn,Qe){(Y!==Xt||pt!==cn||Pt!==Qe)&&(i.stencilOp(Xt,cn,Qe),Y=Xt,pt=cn,Pt=Qe)},setLocked:function(Xt){I=Xt},setClear:function(Xt){Kt!==Xt&&(i.clearStencil(Xt),Kt=Xt)},reset:function(){I=!1,tt=null,it=null,ut=null,K=null,Y=null,pt=null,Pt=null,Kt=null}}}let r=new e,a=new n,o=new s,c=new WeakMap,l=new WeakMap,h={},f={},u=new WeakMap,p=[],g=null,_=!1,m=null,d=null,T=null,M=null,v=null,R=null,w=null,C=new zt(0,0,0),U=0,S=!1,b=null,P=null,B=null,V=null,X=null,Z=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),W=!1,et=0,k=i.getParameter(i.VERSION);k.indexOf("WebGL")!==-1?(et=parseFloat(/^WebGL (\d)/.exec(k)[1]),W=et>=1):k.indexOf("OpenGL ES")!==-1&&(et=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),W=et>=2);let rt=null,ct={},bt=i.getParameter(i.SCISSOR_BOX),Bt=i.getParameter(i.VIEWPORT),Jt=new oe().fromArray(bt),te=new oe().fromArray(Bt);function Wt(I,tt,it,ut){let K=new Uint8Array(4),Y=i.createTexture();i.bindTexture(I,Y),i.texParameteri(I,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(I,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let pt=0;pt<it;pt++)I===i.TEXTURE_3D||I===i.TEXTURE_2D_ARRAY?i.texImage3D(tt,0,i.RGBA,1,1,ut,0,i.RGBA,i.UNSIGNED_BYTE,K):i.texImage2D(tt+pt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,K);return Y}let q={};q[i.TEXTURE_2D]=Wt(i.TEXTURE_2D,i.TEXTURE_2D,1),q[i.TEXTURE_CUBE_MAP]=Wt(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),q[i.TEXTURE_2D_ARRAY]=Wt(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),q[i.TEXTURE_3D]=Wt(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),J(i.DEPTH_TEST),a.setFunc(Yn),At(!1),mt(_o),J(i.CULL_FACE),ee(yn);function J(I){h[I]!==!0&&(i.enable(I),h[I]=!0)}function dt(I){h[I]!==!1&&(i.disable(I),h[I]=!1)}function Ct(I,tt){return f[I]!==tt?(i.bindFramebuffer(I,tt),f[I]=tt,I===i.DRAW_FRAMEBUFFER&&(f[i.FRAMEBUFFER]=tt),I===i.FRAMEBUFFER&&(f[i.DRAW_FRAMEBUFFER]=tt),!0):!1}function Mt(I,tt){let it=p,ut=!1;if(I){it=u.get(tt),it===void 0&&(it=[],u.set(tt,it));let K=I.textures;if(it.length!==K.length||it[0]!==i.COLOR_ATTACHMENT0){for(let Y=0,pt=K.length;Y<pt;Y++)it[Y]=i.COLOR_ATTACHMENT0+Y;it.length=K.length,ut=!0}}else it[0]!==i.BACK&&(it[0]=i.BACK,ut=!0);ut&&i.drawBuffers(it)}function Ht(I){return g!==I?(i.useProgram(I),g=I,!0):!1}let ge={[In]:i.FUNC_ADD,[Hl]:i.FUNC_SUBTRACT,[Vl]:i.FUNC_REVERSE_SUBTRACT};ge[Gl]=i.MIN,ge[Wl]=i.MAX;let A={[Xl]:i.ZERO,[ql]:i.ONE,[Yl]:i.SRC_COLOR,[rr]:i.SRC_ALPHA,[Ql]:i.SRC_ALPHA_SATURATE,[Kl]:i.DST_COLOR,[$l]:i.DST_ALPHA,[Zl]:i.ONE_MINUS_SRC_COLOR,[ar]:i.ONE_MINUS_SRC_ALPHA,[jl]:i.ONE_MINUS_DST_COLOR,[Jl]:i.ONE_MINUS_DST_ALPHA,[tc]:i.CONSTANT_COLOR,[ec]:i.ONE_MINUS_CONSTANT_COLOR,[nc]:i.CONSTANT_ALPHA,[ic]:i.ONE_MINUS_CONSTANT_ALPHA};function ee(I,tt,it,ut,K,Y,pt,Pt,Kt,Xt){if(I===yn){_===!0&&(dt(i.BLEND),_=!1);return}if(_===!1&&(J(i.BLEND),_=!0),I!==kl){if(I!==m||Xt!==S){if((d!==In||v!==In)&&(i.blendEquation(i.FUNC_ADD),d=In,v=In),Xt)switch(I){case _n:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ys:i.blendFunc(i.ONE,i.ONE);break;case yo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case vo:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}else switch(I){case _n:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case ys:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case yo:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case vo:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",I);break}T=null,M=null,R=null,w=null,C.set(0,0,0),U=0,m=I,S=Xt}return}K=K||tt,Y=Y||it,pt=pt||ut,(tt!==d||K!==v)&&(i.blendEquationSeparate(ge[tt],ge[K]),d=tt,v=K),(it!==T||ut!==M||Y!==R||pt!==w)&&(i.blendFuncSeparate(A[it],A[ut],A[Y],A[pt]),T=it,M=ut,R=Y,w=pt),(Pt.equals(C)===!1||Kt!==U)&&(i.blendColor(Pt.r,Pt.g,Pt.b,Kt),C.copy(Pt),U=Kt),m=I,S=!1}function It(I,tt){I.side===Xe?dt(i.CULL_FACE):J(i.CULL_FACE);let it=I.side===Ee;tt&&(it=!it),At(it),I.blending===_n&&I.transparent===!1?ee(yn):ee(I.blending,I.blendEquation,I.blendSrc,I.blendDst,I.blendEquationAlpha,I.blendSrcAlpha,I.blendDstAlpha,I.blendColor,I.blendAlpha,I.premultipliedAlpha),a.setFunc(I.depthFunc),a.setTest(I.depthTest),a.setMask(I.depthWrite),r.setMask(I.colorWrite);let ut=I.stencilWrite;o.setTest(ut),ut&&(o.setMask(I.stencilWriteMask),o.setFunc(I.stencilFunc,I.stencilRef,I.stencilFuncMask),o.setOp(I.stencilFail,I.stencilZFail,I.stencilZPass)),gt(I.polygonOffset,I.polygonOffsetFactor,I.polygonOffsetUnits),I.alphaToCoverage===!0?J(i.SAMPLE_ALPHA_TO_COVERAGE):dt(i.SAMPLE_ALPHA_TO_COVERAGE)}function At(I){b!==I&&(I?i.frontFace(i.CW):i.frontFace(i.CCW),b=I)}function mt(I){I!==Ol?(J(i.CULL_FACE),I!==P&&(I===_o?i.cullFace(i.BACK):I===Bl?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):dt(i.CULL_FACE),P=I}function ne(I){I!==B&&(W&&i.lineWidth(I),B=I)}function gt(I,tt,it){I?(J(i.POLYGON_OFFSET_FILL),(V!==tt||X!==it)&&(i.polygonOffset(tt,it),V=tt,X=it)):dt(i.POLYGON_OFFSET_FILL)}function Nt(I){I?J(i.SCISSOR_TEST):dt(i.SCISSOR_TEST)}function pe(I){I===void 0&&(I=i.TEXTURE0+Z-1),rt!==I&&(i.activeTexture(I),rt=I)}function le(I,tt,it){it===void 0&&(rt===null?it=i.TEXTURE0+Z-1:it=rt);let ut=ct[it];ut===void 0&&(ut={type:void 0,texture:void 0},ct[it]=ut),(ut.type!==I||ut.texture!==tt)&&(rt!==it&&(i.activeTexture(it),rt=it),i.bindTexture(I,tt||q[I]),ut.type=I,ut.texture=tt)}function E(){let I=ct[rt];I!==void 0&&I.type!==void 0&&(i.bindTexture(I.type,null),I.type=void 0,I.texture=void 0)}function x(){try{i.compressedTexImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function F(){try{i.compressedTexImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function G(){try{i.texSubImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function $(){try{i.texSubImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function H(){try{i.compressedTexSubImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function vt(){try{i.compressedTexSubImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function nt(){try{i.texStorage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function _t(){try{i.texStorage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function xt(){try{i.texImage2D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function Q(){try{i.texImage3D(...arguments)}catch(I){console.error("THREE.WebGLState:",I)}}function lt(I){Jt.equals(I)===!1&&(i.scissor(I.x,I.y,I.z,I.w),Jt.copy(I))}function wt(I){te.equals(I)===!1&&(i.viewport(I.x,I.y,I.z,I.w),te.copy(I))}function yt(I,tt){let it=l.get(tt);it===void 0&&(it=new WeakMap,l.set(tt,it));let ut=it.get(I);ut===void 0&&(ut=i.getUniformBlockIndex(tt,I.name),it.set(I,ut))}function at(I,tt){let ut=l.get(tt).get(I);c.get(tt)!==ut&&(i.uniformBlockBinding(tt,ut,I.__bindingPointIndex),c.set(tt,ut))}function Dt(){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),a.setReversed(!1),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),h={},rt=null,ct={},f={},u=new WeakMap,p=[],g=null,_=!1,m=null,d=null,T=null,M=null,v=null,R=null,w=null,C=new zt(0,0,0),U=0,S=!1,b=null,P=null,B=null,V=null,X=null,Jt.set(0,0,i.canvas.width,i.canvas.height),te.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:J,disable:dt,bindFramebuffer:Ct,drawBuffers:Mt,useProgram:Ht,setBlending:ee,setMaterial:It,setFlipSided:At,setCullFace:mt,setLineWidth:ne,setPolygonOffset:gt,setScissorTest:Nt,activeTexture:pe,bindTexture:le,unbindTexture:E,compressedTexImage2D:x,compressedTexImage3D:F,texImage2D:xt,texImage3D:Q,updateUBOMapping:yt,uniformBlockBinding:at,texStorage2D:nt,texStorage3D:_t,texSubImage2D:G,texSubImage3D:$,compressedTexSubImage2D:H,compressedTexSubImage3D:vt,scissor:lt,viewport:wt,reset:Dt}}function Bm(i,t,e,n,s,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ut,h=new WeakMap,f,u=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(E,x){return p?new OffscreenCanvas(E,x):ns("canvas")}function _(E,x,F){let G=1,$=le(E);if(($.width>F||$.height>F)&&(G=F/Math.max($.width,$.height)),G<1)if(typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&E instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&E instanceof ImageBitmap||typeof VideoFrame<"u"&&E instanceof VideoFrame){let H=Math.floor(G*$.width),vt=Math.floor(G*$.height);f===void 0&&(f=g(H,vt));let nt=x?g(H,vt):f;return nt.width=H,nt.height=vt,nt.getContext("2d").drawImage(E,0,0,H,vt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+H+"x"+vt+")."),nt}else return"data"in E&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),E;return E}function m(E){return E.generateMipmaps}function d(E){i.generateMipmap(E)}function T(E){return E.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:E.isWebGL3DRenderTarget?i.TEXTURE_3D:E.isWebGLArrayRenderTarget||E.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(E,x,F,G,$=!1){if(E!==null){if(i[E]!==void 0)return i[E];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+E+"'")}let H=x;if(x===i.RED&&(F===i.FLOAT&&(H=i.R32F),F===i.HALF_FLOAT&&(H=i.R16F),F===i.UNSIGNED_BYTE&&(H=i.R8)),x===i.RED_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.R8UI),F===i.UNSIGNED_SHORT&&(H=i.R16UI),F===i.UNSIGNED_INT&&(H=i.R32UI),F===i.BYTE&&(H=i.R8I),F===i.SHORT&&(H=i.R16I),F===i.INT&&(H=i.R32I)),x===i.RG&&(F===i.FLOAT&&(H=i.RG32F),F===i.HALF_FLOAT&&(H=i.RG16F),F===i.UNSIGNED_BYTE&&(H=i.RG8)),x===i.RG_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.RG8UI),F===i.UNSIGNED_SHORT&&(H=i.RG16UI),F===i.UNSIGNED_INT&&(H=i.RG32UI),F===i.BYTE&&(H=i.RG8I),F===i.SHORT&&(H=i.RG16I),F===i.INT&&(H=i.RG32I)),x===i.RGB_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.RGB8UI),F===i.UNSIGNED_SHORT&&(H=i.RGB16UI),F===i.UNSIGNED_INT&&(H=i.RGB32UI),F===i.BYTE&&(H=i.RGB8I),F===i.SHORT&&(H=i.RGB16I),F===i.INT&&(H=i.RGB32I)),x===i.RGBA_INTEGER&&(F===i.UNSIGNED_BYTE&&(H=i.RGBA8UI),F===i.UNSIGNED_SHORT&&(H=i.RGBA16UI),F===i.UNSIGNED_INT&&(H=i.RGBA32UI),F===i.BYTE&&(H=i.RGBA8I),F===i.SHORT&&(H=i.RGBA16I),F===i.INT&&(H=i.RGBA32I)),x===i.RGB&&(F===i.UNSIGNED_INT_5_9_9_9_REV&&(H=i.RGB9_E5),F===i.UNSIGNED_INT_10F_11F_11F_REV&&(H=i.R11F_G11F_B10F)),x===i.RGBA){let vt=$?ts:Vt.getTransfer(G);F===i.FLOAT&&(H=i.RGBA32F),F===i.HALF_FLOAT&&(H=i.RGBA16F),F===i.UNSIGNED_BYTE&&(H=vt===qt?i.SRGB8_ALPHA8:i.RGBA8),F===i.UNSIGNED_SHORT_4_4_4_4&&(H=i.RGBA4),F===i.UNSIGNED_SHORT_5_5_5_1&&(H=i.RGB5_A1)}return(H===i.R16F||H===i.R32F||H===i.RG16F||H===i.RG32F||H===i.RGBA16F||H===i.RGBA32F)&&t.get("EXT_color_buffer_float"),H}function v(E,x){let F;return E?x===null||x===Bn||x===Ui?F=i.DEPTH24_STENCIL8:x===on?F=i.DEPTH32F_STENCIL8:x===Li&&(F=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Bn||x===Ui?F=i.DEPTH_COMPONENT24:x===on?F=i.DEPTH_COMPONENT32F:x===Li&&(F=i.DEPTH_COMPONENT16),F}function R(E,x){return m(E)===!0||E.isFramebufferTexture&&E.minFilter!==Ge&&E.minFilter!==Ke?Math.log2(Math.max(x.width,x.height))+1:E.mipmaps!==void 0&&E.mipmaps.length>0?E.mipmaps.length:E.isCompressedTexture&&Array.isArray(E.image)?x.mipmaps.length:1}function w(E){let x=E.target;x.removeEventListener("dispose",w),U(x),x.isVideoTexture&&h.delete(x)}function C(E){let x=E.target;x.removeEventListener("dispose",C),b(x)}function U(E){let x=n.get(E);if(x.__webglInit===void 0)return;let F=E.source,G=u.get(F);if(G){let $=G[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&S(E),Object.keys(G).length===0&&u.delete(F)}n.remove(E)}function S(E){let x=n.get(E);i.deleteTexture(x.__webglTexture);let F=E.source,G=u.get(F);delete G[x.__cacheKey],a.memory.textures--}function b(E){let x=n.get(E);if(E.depthTexture&&(E.depthTexture.dispose(),n.remove(E.depthTexture)),E.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(x.__webglFramebuffer[G]))for(let $=0;$<x.__webglFramebuffer[G].length;$++)i.deleteFramebuffer(x.__webglFramebuffer[G][$]);else i.deleteFramebuffer(x.__webglFramebuffer[G]);x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer[G])}else{if(Array.isArray(x.__webglFramebuffer))for(let G=0;G<x.__webglFramebuffer.length;G++)i.deleteFramebuffer(x.__webglFramebuffer[G]);else i.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&i.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&i.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let G=0;G<x.__webglColorRenderbuffer.length;G++)x.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(x.__webglColorRenderbuffer[G]);x.__webglDepthRenderbuffer&&i.deleteRenderbuffer(x.__webglDepthRenderbuffer)}let F=E.textures;for(let G=0,$=F.length;G<$;G++){let H=n.get(F[G]);H.__webglTexture&&(i.deleteTexture(H.__webglTexture),a.memory.textures--),n.remove(F[G])}n.remove(E)}let P=0;function B(){P=0}function V(){let E=P;return E>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+E+" texture units while this GPU supports only "+s.maxTextures),P+=1,E}function X(E){let x=[];return x.push(E.wrapS),x.push(E.wrapT),x.push(E.wrapR||0),x.push(E.magFilter),x.push(E.minFilter),x.push(E.anisotropy),x.push(E.internalFormat),x.push(E.format),x.push(E.type),x.push(E.generateMipmaps),x.push(E.premultiplyAlpha),x.push(E.flipY),x.push(E.unpackAlignment),x.push(E.colorSpace),x.join()}function Z(E,x){let F=n.get(E);if(E.isVideoTexture&&Nt(E),E.isRenderTargetTexture===!1&&E.isExternalTexture!==!0&&E.version>0&&F.__version!==E.version){let G=E.image;if(G===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{q(F,E,x);return}}else E.isExternalTexture&&(F.__webglTexture=E.sourceTexture?E.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,F.__webglTexture,i.TEXTURE0+x)}function W(E,x){let F=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){q(F,E,x);return}e.bindTexture(i.TEXTURE_2D_ARRAY,F.__webglTexture,i.TEXTURE0+x)}function et(E,x){let F=n.get(E);if(E.isRenderTargetTexture===!1&&E.version>0&&F.__version!==E.version){q(F,E,x);return}e.bindTexture(i.TEXTURE_3D,F.__webglTexture,i.TEXTURE0+x)}function k(E,x){let F=n.get(E);if(E.version>0&&F.__version!==E.version){J(F,E,x);return}e.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture,i.TEXTURE0+x)}let rt={[or]:i.REPEAT,[Pn]:i.CLAMP_TO_EDGE,[lr]:i.MIRRORED_REPEAT},ct={[Ge]:i.NEAREST,[fc]:i.NEAREST_MIPMAP_NEAREST,[Ms]:i.NEAREST_MIPMAP_LINEAR,[Ke]:i.LINEAR,[Br]:i.LINEAR_MIPMAP_NEAREST,[On]:i.LINEAR_MIPMAP_LINEAR},bt={[xc]:i.NEVER,[Ec]:i.ALWAYS,[yc]:i.LESS,[Io]:i.LEQUAL,[vc]:i.EQUAL,[Sc]:i.GEQUAL,[Mc]:i.GREATER,[bc]:i.NOTEQUAL};function Bt(E,x){if(x.type===on&&t.has("OES_texture_float_linear")===!1&&(x.magFilter===Ke||x.magFilter===Br||x.magFilter===Ms||x.magFilter===On||x.minFilter===Ke||x.minFilter===Br||x.minFilter===Ms||x.minFilter===On)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(E,i.TEXTURE_WRAP_S,rt[x.wrapS]),i.texParameteri(E,i.TEXTURE_WRAP_T,rt[x.wrapT]),(E===i.TEXTURE_3D||E===i.TEXTURE_2D_ARRAY)&&i.texParameteri(E,i.TEXTURE_WRAP_R,rt[x.wrapR]),i.texParameteri(E,i.TEXTURE_MAG_FILTER,ct[x.magFilter]),i.texParameteri(E,i.TEXTURE_MIN_FILTER,ct[x.minFilter]),x.compareFunction&&(i.texParameteri(E,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(E,i.TEXTURE_COMPARE_FUNC,bt[x.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Ge||x.minFilter!==Ms&&x.minFilter!==On||x.type===on&&t.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){let F=t.get("EXT_texture_filter_anisotropic");i.texParameterf(E,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function Jt(E,x){let F=!1;E.__webglInit===void 0&&(E.__webglInit=!0,x.addEventListener("dispose",w));let G=x.source,$=u.get(G);$===void 0&&($={},u.set(G,$));let H=X(x);if(H!==E.__cacheKey){$[H]===void 0&&($[H]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,F=!0),$[H].usedTimes++;let vt=$[E.__cacheKey];vt!==void 0&&($[E.__cacheKey].usedTimes--,vt.usedTimes===0&&S(x)),E.__cacheKey=H,E.__webglTexture=$[H].texture}return F}function te(E,x,F){return Math.floor(Math.floor(E/F)/x)}function Wt(E,x,F,G){let H=E.updateRanges;if(H.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,x.width,x.height,F,G,x.data);else{H.sort((Q,lt)=>Q.start-lt.start);let vt=0;for(let Q=1;Q<H.length;Q++){let lt=H[vt],wt=H[Q],yt=lt.start+lt.count,at=te(wt.start,x.width,4),Dt=te(lt.start,x.width,4);wt.start<=yt+1&&at===Dt&&te(wt.start+wt.count-1,x.width,4)===at?lt.count=Math.max(lt.count,wt.start+wt.count-lt.start):(++vt,H[vt]=wt)}H.length=vt+1;let nt=i.getParameter(i.UNPACK_ROW_LENGTH),_t=i.getParameter(i.UNPACK_SKIP_PIXELS),xt=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,x.width);for(let Q=0,lt=H.length;Q<lt;Q++){let wt=H[Q],yt=Math.floor(wt.start/4),at=Math.ceil(wt.count/4),Dt=yt%x.width,I=Math.floor(yt/x.width),tt=at,it=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Dt),i.pixelStorei(i.UNPACK_SKIP_ROWS,I),e.texSubImage2D(i.TEXTURE_2D,0,Dt,I,tt,it,F,G,x.data)}E.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,nt),i.pixelStorei(i.UNPACK_SKIP_PIXELS,_t),i.pixelStorei(i.UNPACK_SKIP_ROWS,xt)}}function q(E,x,F){let G=i.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),x.isData3DTexture&&(G=i.TEXTURE_3D);let $=Jt(E,x),H=x.source;e.bindTexture(G,E.__webglTexture,i.TEXTURE0+F);let vt=n.get(H);if(H.version!==vt.__version||$===!0){e.activeTexture(i.TEXTURE0+F);let nt=Vt.getPrimaries(Vt.workingColorSpace),_t=x.colorSpace===Mn?null:Vt.getPrimaries(x.colorSpace),xt=x.colorSpace===Mn||nt===_t?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,xt);let Q=_(x.image,!1,s.maxTextureSize);Q=pe(x,Q);let lt=r.convert(x.format,x.colorSpace),wt=r.convert(x.type),yt=M(x.internalFormat,lt,wt,x.colorSpace,x.isVideoTexture);Bt(G,x);let at,Dt=x.mipmaps,I=x.isVideoTexture!==!0,tt=vt.__version===void 0||$===!0,it=H.dataReady,ut=R(x,Q);if(x.isDepthTexture)yt=v(x.format===Ni,x.type),tt&&(I?e.texStorage2D(i.TEXTURE_2D,1,yt,Q.width,Q.height):e.texImage2D(i.TEXTURE_2D,0,yt,Q.width,Q.height,0,lt,wt,null));else if(x.isDataTexture)if(Dt.length>0){I&&tt&&e.texStorage2D(i.TEXTURE_2D,ut,yt,Dt[0].width,Dt[0].height);for(let K=0,Y=Dt.length;K<Y;K++)at=Dt[K],I?it&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,at.width,at.height,lt,wt,at.data):e.texImage2D(i.TEXTURE_2D,K,yt,at.width,at.height,0,lt,wt,at.data);x.generateMipmaps=!1}else I?(tt&&e.texStorage2D(i.TEXTURE_2D,ut,yt,Q.width,Q.height),it&&Wt(x,Q,lt,wt)):e.texImage2D(i.TEXTURE_2D,0,yt,Q.width,Q.height,0,lt,wt,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){I&&tt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ut,yt,Dt[0].width,Dt[0].height,Q.depth);for(let K=0,Y=Dt.length;K<Y;K++)if(at=Dt[K],x.format!==qe)if(lt!==null)if(I){if(it)if(x.layerUpdates.size>0){let pt=zo(at.width,at.height,x.format,x.type);for(let Pt of x.layerUpdates){let Kt=at.data.subarray(Pt*pt/at.data.BYTES_PER_ELEMENT,(Pt+1)*pt/at.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,Pt,at.width,at.height,1,lt,Kt)}x.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,at.width,at.height,Q.depth,lt,at.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,K,yt,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 I?it&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,K,0,0,0,at.width,at.height,Q.depth,lt,wt,at.data):e.texImage3D(i.TEXTURE_2D_ARRAY,K,yt,at.width,at.height,Q.depth,0,lt,wt,at.data)}else{I&&tt&&e.texStorage2D(i.TEXTURE_2D,ut,yt,Dt[0].width,Dt[0].height);for(let K=0,Y=Dt.length;K<Y;K++)at=Dt[K],x.format!==qe?lt!==null?I?it&&e.compressedTexSubImage2D(i.TEXTURE_2D,K,0,0,at.width,at.height,lt,at.data):e.compressedTexImage2D(i.TEXTURE_2D,K,yt,at.width,at.height,0,at.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):I?it&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,at.width,at.height,lt,wt,at.data):e.texImage2D(i.TEXTURE_2D,K,yt,at.width,at.height,0,lt,wt,at.data)}else if(x.isDataArrayTexture)if(I){if(tt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,ut,yt,Q.width,Q.height,Q.depth),it)if(x.layerUpdates.size>0){let K=zo(Q.width,Q.height,x.format,x.type);for(let Y of x.layerUpdates){let pt=Q.data.subarray(Y*K/Q.data.BYTES_PER_ELEMENT,(Y+1)*K/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Y,Q.width,Q.height,1,lt,wt,pt)}x.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,lt,wt,Q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,yt,Q.width,Q.height,Q.depth,0,lt,wt,Q.data);else if(x.isData3DTexture)I?(tt&&e.texStorage3D(i.TEXTURE_3D,ut,yt,Q.width,Q.height,Q.depth),it&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,lt,wt,Q.data)):e.texImage3D(i.TEXTURE_3D,0,yt,Q.width,Q.height,Q.depth,0,lt,wt,Q.data);else if(x.isFramebufferTexture){if(tt)if(I)e.texStorage2D(i.TEXTURE_2D,ut,yt,Q.width,Q.height);else{let K=Q.width,Y=Q.height;for(let pt=0;pt<ut;pt++)e.texImage2D(i.TEXTURE_2D,pt,yt,K,Y,0,lt,wt,null),K>>=1,Y>>=1}}else if(Dt.length>0){if(I&&tt){let K=le(Dt[0]);e.texStorage2D(i.TEXTURE_2D,ut,yt,K.width,K.height)}for(let K=0,Y=Dt.length;K<Y;K++)at=Dt[K],I?it&&e.texSubImage2D(i.TEXTURE_2D,K,0,0,lt,wt,at):e.texImage2D(i.TEXTURE_2D,K,yt,lt,wt,at);x.generateMipmaps=!1}else if(I){if(tt){let K=le(Q);e.texStorage2D(i.TEXTURE_2D,ut,yt,K.width,K.height)}it&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,lt,wt,Q)}else e.texImage2D(i.TEXTURE_2D,0,yt,lt,wt,Q);m(x)&&d(G),vt.__version=H.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function J(E,x,F){if(x.image.length!==6)return;let G=Jt(E,x),$=x.source;e.bindTexture(i.TEXTURE_CUBE_MAP,E.__webglTexture,i.TEXTURE0+F);let H=n.get($);if($.version!==H.__version||G===!0){e.activeTexture(i.TEXTURE0+F);let vt=Vt.getPrimaries(Vt.workingColorSpace),nt=x.colorSpace===Mn?null:Vt.getPrimaries(x.colorSpace),_t=x.colorSpace===Mn||vt===nt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,x.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,x.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,_t);let xt=x.isCompressedTexture||x.image[0].isCompressedTexture,Q=x.image[0]&&x.image[0].isDataTexture,lt=[];for(let Y=0;Y<6;Y++)!xt&&!Q?lt[Y]=_(x.image[Y],!0,s.maxCubemapSize):lt[Y]=Q?x.image[Y].image:x.image[Y],lt[Y]=pe(x,lt[Y]);let wt=lt[0],yt=r.convert(x.format,x.colorSpace),at=r.convert(x.type),Dt=M(x.internalFormat,yt,at,x.colorSpace),I=x.isVideoTexture!==!0,tt=H.__version===void 0||G===!0,it=$.dataReady,ut=R(x,wt);Bt(i.TEXTURE_CUBE_MAP,x);let K;if(xt){I&&tt&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ut,Dt,wt.width,wt.height);for(let Y=0;Y<6;Y++){K=lt[Y].mipmaps;for(let pt=0;pt<K.length;pt++){let Pt=K[pt];x.format!==qe?yt!==null?I?it&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,0,0,Pt.width,Pt.height,yt,Pt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,Dt,Pt.width,Pt.height,0,Pt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,0,0,Pt.width,Pt.height,yt,at,Pt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt,Dt,Pt.width,Pt.height,0,yt,at,Pt.data)}}}else{if(K=x.mipmaps,I&&tt){K.length>0&&ut++;let Y=le(lt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ut,Dt,Y.width,Y.height)}for(let Y=0;Y<6;Y++)if(Q){I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,lt[Y].width,lt[Y].height,yt,at,lt[Y].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Dt,lt[Y].width,lt[Y].height,0,yt,at,lt[Y].data);for(let pt=0;pt<K.length;pt++){let Kt=K[pt].image[Y].image;I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,0,0,Kt.width,Kt.height,yt,at,Kt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,Dt,Kt.width,Kt.height,0,yt,at,Kt.data)}}else{I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,0,0,yt,at,lt[Y]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,0,Dt,yt,at,lt[Y]);for(let pt=0;pt<K.length;pt++){let Pt=K[pt];I?it&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,0,0,yt,at,Pt.image[Y]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+Y,pt+1,Dt,yt,at,Pt.image[Y])}}}m(x)&&d(i.TEXTURE_CUBE_MAP),H.__version=$.version,x.onUpdate&&x.onUpdate(x)}E.__version=x.version}function dt(E,x,F,G,$,H){let vt=r.convert(F.format,F.colorSpace),nt=r.convert(F.type),_t=M(F.internalFormat,vt,nt,F.colorSpace),xt=n.get(x),Q=n.get(F);if(Q.__renderTarget=x,!xt.__hasExternalTextures){let lt=Math.max(1,x.width>>H),wt=Math.max(1,x.height>>H);$===i.TEXTURE_3D||$===i.TEXTURE_2D_ARRAY?e.texImage3D($,H,_t,lt,wt,x.depth,0,vt,nt,null):e.texImage2D($,H,_t,lt,wt,0,vt,nt,null)}e.bindFramebuffer(i.FRAMEBUFFER,E),gt(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,$,Q.__webglTexture,0,ne(x)):($===i.TEXTURE_2D||$>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,$,Q.__webglTexture,H),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Ct(E,x,F){if(i.bindRenderbuffer(i.RENDERBUFFER,E),x.depthBuffer){let G=x.depthTexture,$=G&&G.isDepthTexture?G.type:null,H=v(x.stencilBuffer,$),vt=x.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,nt=ne(x);gt(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,nt,H,x.width,x.height):F?i.renderbufferStorageMultisample(i.RENDERBUFFER,nt,H,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,H,x.width,x.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,vt,i.RENDERBUFFER,E)}else{let G=x.textures;for(let $=0;$<G.length;$++){let H=G[$],vt=r.convert(H.format,H.colorSpace),nt=r.convert(H.type),_t=M(H.internalFormat,vt,nt,H.colorSpace),xt=ne(x);F&&gt(x)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,xt,_t,x.width,x.height):gt(x)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,xt,_t,x.width,x.height):i.renderbufferStorage(i.RENDERBUFFER,_t,x.width,x.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Mt(E,x){if(x&&x.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,E),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let G=n.get(x.depthTexture);G.__renderTarget=x,(!G.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),Z(x.depthTexture,0);let $=G.__webglTexture,H=ne(x);if(x.depthTexture.format===Mi)gt(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0,H):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,$,0);else if(x.depthTexture.format===Ni)gt(x)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0,H):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,$,0);else throw new Error("Unknown depthTexture format")}function Ht(E){let x=n.get(E),F=E.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==E.depthTexture){let G=E.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),G){let $=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,G.removeEventListener("dispose",$)};G.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=G}if(E.depthTexture&&!x.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");let G=E.texture.mipmaps;G&&G.length>0?Mt(x.__webglFramebuffer[0],E):Mt(x.__webglFramebuffer,E)}else if(F){x.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[G]),x.__webglDepthbuffer[G]===void 0)x.__webglDepthbuffer[G]=i.createRenderbuffer(),Ct(x.__webglDepthbuffer[G],E,!1);else{let $=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,H=x.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,H),i.framebufferRenderbuffer(i.FRAMEBUFFER,$,i.RENDERBUFFER,H)}}else{let G=E.texture.mipmaps;if(G&&G.length>0?e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=i.createRenderbuffer(),Ct(x.__webglDepthbuffer,E,!1);else{let $=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,H=x.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,H),i.framebufferRenderbuffer(i.FRAMEBUFFER,$,i.RENDERBUFFER,H)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function ge(E,x,F){let G=n.get(E);x!==void 0&&dt(G.__webglFramebuffer,E,E.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),F!==void 0&&Ht(E)}function A(E){let x=E.texture,F=n.get(E),G=n.get(x);E.addEventListener("dispose",C);let $=E.textures,H=E.isWebGLCubeRenderTarget===!0,vt=$.length>1;if(vt||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=x.version,a.memory.textures++),H){F.__webglFramebuffer=[];for(let nt=0;nt<6;nt++)if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer[nt]=[];for(let _t=0;_t<x.mipmaps.length;_t++)F.__webglFramebuffer[nt][_t]=i.createFramebuffer()}else F.__webglFramebuffer[nt]=i.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer=[];for(let nt=0;nt<x.mipmaps.length;nt++)F.__webglFramebuffer[nt]=i.createFramebuffer()}else F.__webglFramebuffer=i.createFramebuffer();if(vt)for(let nt=0,_t=$.length;nt<_t;nt++){let xt=n.get($[nt]);xt.__webglTexture===void 0&&(xt.__webglTexture=i.createTexture(),a.memory.textures++)}if(E.samples>0&&gt(E)===!1){F.__webglMultisampledFramebuffer=i.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let nt=0;nt<$.length;nt++){let _t=$[nt];F.__webglColorRenderbuffer[nt]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,F.__webglColorRenderbuffer[nt]);let xt=r.convert(_t.format,_t.colorSpace),Q=r.convert(_t.type),lt=M(_t.internalFormat,xt,Q,_t.colorSpace,E.isXRRenderTarget===!0),wt=ne(E);i.renderbufferStorageMultisample(i.RENDERBUFFER,wt,lt,E.width,E.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+nt,i.RENDERBUFFER,F.__webglColorRenderbuffer[nt])}i.bindRenderbuffer(i.RENDERBUFFER,null),E.depthBuffer&&(F.__webglDepthRenderbuffer=i.createRenderbuffer(),Ct(F.__webglDepthRenderbuffer,E,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(H){e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,x);for(let nt=0;nt<6;nt++)if(x.mipmaps&&x.mipmaps.length>0)for(let _t=0;_t<x.mipmaps.length;_t++)dt(F.__webglFramebuffer[nt][_t],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,_t);else dt(F.__webglFramebuffer[nt],E,x,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+nt,0);m(x)&&d(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(vt){for(let nt=0,_t=$.length;nt<_t;nt++){let xt=$[nt],Q=n.get(xt),lt=i.TEXTURE_2D;(E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(lt=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(lt,Q.__webglTexture),Bt(lt,xt),dt(F.__webglFramebuffer,E,xt,i.COLOR_ATTACHMENT0+nt,lt,0),m(xt)&&d(lt)}e.unbindTexture()}else{let nt=i.TEXTURE_2D;if((E.isWebGL3DRenderTarget||E.isWebGLArrayRenderTarget)&&(nt=E.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(nt,G.__webglTexture),Bt(nt,x),x.mipmaps&&x.mipmaps.length>0)for(let _t=0;_t<x.mipmaps.length;_t++)dt(F.__webglFramebuffer[_t],E,x,i.COLOR_ATTACHMENT0,nt,_t);else dt(F.__webglFramebuffer,E,x,i.COLOR_ATTACHMENT0,nt,0);m(x)&&d(nt),e.unbindTexture()}E.depthBuffer&&Ht(E)}function ee(E){let x=E.textures;for(let F=0,G=x.length;F<G;F++){let $=x[F];if(m($)){let H=T(E),vt=n.get($).__webglTexture;e.bindTexture(H,vt),d(H),e.unbindTexture()}}}let It=[],At=[];function mt(E){if(E.samples>0){if(gt(E)===!1){let x=E.textures,F=E.width,G=E.height,$=i.COLOR_BUFFER_BIT,H=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,vt=n.get(E),nt=x.length>1;if(nt)for(let xt=0;xt<x.length;xt++)e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,vt.__webglMultisampledFramebuffer);let _t=E.texture.mipmaps;_t&&_t.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,vt.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,vt.__webglFramebuffer);for(let xt=0;xt<x.length;xt++){if(E.resolveDepthBuffer&&(E.depthBuffer&&($|=i.DEPTH_BUFFER_BIT),E.stencilBuffer&&E.resolveStencilBuffer&&($|=i.STENCIL_BUFFER_BIT)),nt){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,vt.__webglColorRenderbuffer[xt]);let Q=n.get(x[xt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Q,0)}i.blitFramebuffer(0,0,F,G,0,0,F,G,$,i.NEAREST),c===!0&&(It.length=0,At.length=0,It.push(i.COLOR_ATTACHMENT0+xt),E.depthBuffer&&E.resolveDepthBuffer===!1&&(It.push(H),At.push(H),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,At)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,It))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),nt)for(let xt=0;xt<x.length;xt++){e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.RENDERBUFFER,vt.__webglColorRenderbuffer[xt]);let Q=n.get(x[xt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,vt.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+xt,i.TEXTURE_2D,Q,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,vt.__webglMultisampledFramebuffer)}else if(E.depthBuffer&&E.resolveDepthBuffer===!1&&c){let x=E.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[x])}}}function ne(E){return Math.min(s.maxSamples,E.samples)}function gt(E){let x=n.get(E);return E.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function Nt(E){let x=a.render.frame;h.get(E)!==x&&(h.set(E,x),E.update())}function pe(E,x){let F=E.colorSpace,G=E.format,$=E.type;return E.isCompressedTexture===!0||E.isVideoTexture===!0||F!==Zn&&F!==Mn&&(Vt.getTransfer(F)===qt?(G!==qe||$!==an)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),x}function le(E){return typeof HTMLImageElement<"u"&&E instanceof HTMLImageElement?(l.width=E.naturalWidth||E.width,l.height=E.naturalHeight||E.height):typeof VideoFrame<"u"&&E instanceof VideoFrame?(l.width=E.displayWidth,l.height=E.displayHeight):(l.width=E.width,l.height=E.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=B,this.setTexture2D=Z,this.setTexture2DArray=W,this.setTexture3D=et,this.setTextureCube=k,this.rebindTextures=ge,this.setupRenderTarget=A,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=mt,this.setupDepthRenderbuffer=Ht,this.setupFrameBufferTexture=dt,this.useMultisampledRTT=gt}function zm(i,t){function e(n,s=Mn){let r,a=Vt.getTransfer(s);if(n===an)return i.UNSIGNED_BYTE;if(n===kr)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Hr)return i.UNSIGNED_SHORT_5_5_5_1;if(n===To)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===wo)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===So)return i.BYTE;if(n===Eo)return i.SHORT;if(n===Li)return i.UNSIGNED_SHORT;if(n===zr)return i.INT;if(n===Bn)return i.UNSIGNED_INT;if(n===on)return i.FLOAT;if(n===Di)return i.HALF_FLOAT;if(n===Ao)return i.ALPHA;if(n===Ro)return i.RGB;if(n===qe)return i.RGBA;if(n===Mi)return i.DEPTH_COMPONENT;if(n===Ni)return i.DEPTH_STENCIL;if(n===Co)return i.RED;if(n===Vr)return i.RED_INTEGER;if(n===Po)return i.RG;if(n===Gr)return i.RG_INTEGER;if(n===Wr)return i.RGBA_INTEGER;if(n===bs||n===Ss||n===Es||n===Ts)if(a===qt)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===bs)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ss)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Es)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ts)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===bs)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ss)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Es)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ts)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Xr||n===qr||n===Yr||n===Zr)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Xr)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===qr)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Yr)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Zr)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===$r||n===Jr||n===Kr)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===$r||n===Jr)return a===qt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Kr)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===jr||n===Qr||n===ta||n===ea||n===na||n===ia||n===sa||n===ra||n===aa||n===oa||n===la||n===ca||n===ha||n===ua)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===jr)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Qr)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ta)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ea)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===na)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ia)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===sa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ra)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===aa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===oa)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===la)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===ca)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ha)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===ua)return a===qt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===da||n===fa||n===pa)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===da)return a===qt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===fa)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===pa)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===ma||n===ga||n===_a||n===xa)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===ma)return r.COMPRESSED_RED_RGTC1_EXT;if(n===ga)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===_a)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===xa)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ui?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}var km=`
3809
+ void main() {
3810
+
3811
+ gl_Position = vec4( position, 1.0 );
3812
+
3813
+ }`,Hm=`
3814
+ uniform sampler2DArray depthColor;
3815
+ uniform float depthWidth;
3816
+ uniform float depthHeight;
3817
+
3818
+ void main() {
3819
+
3820
+ vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
3821
+
3822
+ if ( coord.x >= 1.0 ) {
3823
+
3824
+ gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
3825
+
3826
+ } else {
3827
+
3828
+ gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
3829
+
3830
+ }
3831
+
3832
+ }`,jo=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new ps(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new je({vertexShader:km,fragmentShader:Hm,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Pe(new ms(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Qo=class extends tn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,f=null,u=null,p=null,g=null,_=typeof XRWebGLBinding<"u",m=new jo,d={},T=e.getContextAttributes(),M=null,v=null,R=[],w=[],C=new Ut,U=null,S=new we;S.viewport=new oe;let b=new we;b.viewport=new oe;let P=[S,b],B=new Rr,V=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let J=R[q];return J===void 0&&(J=new wi,R[q]=J),J.getTargetRaySpace()},this.getControllerGrip=function(q){let J=R[q];return J===void 0&&(J=new wi,R[q]=J),J.getGripSpace()},this.getHand=function(q){let J=R[q];return J===void 0&&(J=new wi,R[q]=J),J.getHandSpace()};function Z(q){let J=w.indexOf(q.inputSource);if(J===-1)return;let dt=R[J];dt!==void 0&&(dt.update(q.inputSource,q.frame,l||a),dt.dispatchEvent({type:q.type,data:q.inputSource}))}function W(){s.removeEventListener("select",Z),s.removeEventListener("selectstart",Z),s.removeEventListener("selectend",Z),s.removeEventListener("squeeze",Z),s.removeEventListener("squeezestart",Z),s.removeEventListener("squeezeend",Z),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",et);for(let q=0;q<R.length;q++){let J=w[q];J!==null&&(w[q]=null,R[q].disconnect(J))}V=null,X=null,m.reset();for(let q in d)delete d[q];t.setRenderTarget(M),p=null,u=null,f=null,s=null,v=null,Wt.stop(),n.isPresenting=!1,t.setPixelRatio(U),t.setSize(C.width,C.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){r=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(q){l=q},this.getBaseLayer=function(){return u!==null?u:p},this.getBinding=function(){return f===null&&_&&(f=new XRWebGLBinding(s,e)),f},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(q){if(s=q,s!==null){if(M=t.getRenderTarget(),s.addEventListener("select",Z),s.addEventListener("selectstart",Z),s.addEventListener("selectend",Z),s.addEventListener("squeeze",Z),s.addEventListener("squeezestart",Z),s.addEventListener("squeezeend",Z),s.addEventListener("end",W),s.addEventListener("inputsourceschange",et),T.xrCompatible!==!0&&await e.makeXRCompatible(),U=t.getPixelRatio(),t.getSize(C),_&&"createProjectionLayer"in XRWebGLBinding.prototype){let dt=null,Ct=null,Mt=null;T.depth&&(Mt=T.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,dt=T.stencil?Ni:Mi,Ct=T.stencil?Ui:Bn);let Ht={colorFormat:e.RGBA8,depthFormat:Mt,scaleFactor:r};f=this.getBinding(),u=f.createProjectionLayer(Ht),s.updateRenderState({layers:[u]}),t.setPixelRatio(1),t.setSize(u.textureWidth,u.textureHeight,!1),v=new en(u.textureWidth,u.textureHeight,{format:qe,type:an,depthTexture:new fs(u.textureWidth,u.textureHeight,Ct,void 0,void 0,void 0,void 0,void 0,void 0,dt),stencilBuffer:T.stencil,colorSpace:t.outputColorSpace,samples:T.antialias?4:0,resolveDepthBuffer:u.ignoreDepthValues===!1,resolveStencilBuffer:u.ignoreDepthValues===!1})}else{let dt={antialias:T.antialias,alpha:!0,depth:T.depth,stencil:T.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,e,dt),s.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),v=new en(p.framebufferWidth,p.framebufferHeight,{format:qe,type:an,colorSpace:t.outputColorSpace,stencilBuffer:T.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Wt.setContext(s),Wt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function et(q){for(let J=0;J<q.removed.length;J++){let dt=q.removed[J],Ct=w.indexOf(dt);Ct>=0&&(w[Ct]=null,R[Ct].disconnect(dt))}for(let J=0;J<q.added.length;J++){let dt=q.added[J],Ct=w.indexOf(dt);if(Ct===-1){for(let Ht=0;Ht<R.length;Ht++)if(Ht>=w.length){w.push(dt),Ct=Ht;break}else if(w[Ht]===null){w[Ht]=dt,Ct=Ht;break}if(Ct===-1)break}let Mt=R[Ct];Mt&&Mt.connect(dt)}}let k=new N,rt=new N;function ct(q,J,dt){k.setFromMatrixPosition(J.matrixWorld),rt.setFromMatrixPosition(dt.matrixWorld);let Ct=k.distanceTo(rt),Mt=J.projectionMatrix.elements,Ht=dt.projectionMatrix.elements,ge=Mt[14]/(Mt[10]-1),A=Mt[14]/(Mt[10]+1),ee=(Mt[9]+1)/Mt[5],It=(Mt[9]-1)/Mt[5],At=(Mt[8]-1)/Mt[0],mt=(Ht[8]+1)/Ht[0],ne=ge*At,gt=ge*mt,Nt=Ct/(-At+mt),pe=Nt*-At;if(J.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(pe),q.translateZ(Nt),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),Mt[10]===-1)q.projectionMatrix.copy(J.projectionMatrix),q.projectionMatrixInverse.copy(J.projectionMatrixInverse);else{let le=ge+Nt,E=A+Nt,x=ne-pe,F=gt+(Ct-pe),G=ee*A/E*le,$=It*A/E*le;q.projectionMatrix.makePerspective(x,F,G,$,le,E),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function bt(q,J){J===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(J.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let J=q.near,dt=q.far;m.texture!==null&&(m.depthNear>0&&(J=m.depthNear),m.depthFar>0&&(dt=m.depthFar)),B.near=b.near=S.near=J,B.far=b.far=S.far=dt,(V!==B.near||X!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),V=B.near,X=B.far),B.layers.mask=q.layers.mask|6,S.layers.mask=B.layers.mask&3,b.layers.mask=B.layers.mask&5;let Ct=q.parent,Mt=B.cameras;bt(B,Ct);for(let Ht=0;Ht<Mt.length;Ht++)bt(Mt[Ht],Ct);Mt.length===2?ct(B,S,b):B.projectionMatrix.copy(S.projectionMatrix),Bt(q,B,Ct)};function Bt(q,J,dt){dt===null?q.matrix.copy(J.matrixWorld):(q.matrix.copy(dt.matrixWorld),q.matrix.invert(),q.matrix.multiply(J.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(J.projectionMatrix),q.projectionMatrixInverse.copy(J.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=bi*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(u===null&&p===null))return c},this.setFoveation=function(q){c=q,u!==null&&(u.fixedFoveation=q),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=q)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(B)},this.getCameraTexture=function(q){return d[q]};let Jt=null;function te(q,J){if(h=J.getViewerPose(l||a),g=J,h!==null){let dt=h.views;p!==null&&(t.setRenderTargetFramebuffer(v,p.framebuffer),t.setRenderTarget(v));let Ct=!1;dt.length!==B.cameras.length&&(B.cameras.length=0,Ct=!0);for(let A=0;A<dt.length;A++){let ee=dt[A],It=null;if(p!==null)It=p.getViewport(ee);else{let mt=f.getViewSubImage(u,ee);It=mt.viewport,A===0&&(t.setRenderTargetTextures(v,mt.colorTexture,mt.depthStencilTexture),t.setRenderTarget(v))}let At=P[A];At===void 0&&(At=new we,At.layers.enable(A),At.viewport=new oe,P[A]=At),At.matrix.fromArray(ee.transform.matrix),At.matrix.decompose(At.position,At.quaternion,At.scale),At.projectionMatrix.fromArray(ee.projectionMatrix),At.projectionMatrixInverse.copy(At.projectionMatrix).invert(),At.viewport.set(It.x,It.y,It.width,It.height),A===0&&(B.matrix.copy(At.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),Ct===!0&&B.cameras.push(At)}let Mt=s.enabledFeatures;if(Mt&&Mt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&_){f=n.getBinding();let A=f.getDepthInformation(dt[0]);A&&A.isValid&&A.texture&&m.init(A,s.renderState)}if(Mt&&Mt.includes("camera-access")&&_){t.state.unbindTexture(),f=n.getBinding();for(let A=0;A<dt.length;A++){let ee=dt[A].camera;if(ee){let It=d[ee];It||(It=new ps,d[ee]=It);let At=f.getCameraImage(ee);It.sourceTexture=At}}}}for(let dt=0;dt<R.length;dt++){let Ct=w[dt],Mt=R[dt];Ct!==null&&Mt!==void 0&&Mt.update(Ct,J,l||a)}Jt&&Jt(q,J),J.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:J}),g=null}let Wt=new Qc;Wt.setAnimationLoop(te),this.setAnimationLoop=function(q){Jt=q},this.dispose=function(){}}},ei=new sn,Vm=new ce;function Gm(i,t){function e(m,d){m.matrixAutoUpdate===!0&&m.updateMatrix(),d.value.copy(m.matrix)}function n(m,d){d.color.getRGB(m.fogColor.value,Fo(i)),d.isFog?(m.fogNear.value=d.near,m.fogFar.value=d.far):d.isFogExp2&&(m.fogDensity.value=d.density)}function s(m,d,T,M,v){d.isMeshBasicMaterial||d.isMeshLambertMaterial?r(m,d):d.isMeshToonMaterial?(r(m,d),f(m,d)):d.isMeshPhongMaterial?(r(m,d),h(m,d)):d.isMeshStandardMaterial?(r(m,d),u(m,d),d.isMeshPhysicalMaterial&&p(m,d,v)):d.isMeshMatcapMaterial?(r(m,d),g(m,d)):d.isMeshDepthMaterial?r(m,d):d.isMeshDistanceMaterial?(r(m,d),_(m,d)):d.isMeshNormalMaterial?r(m,d):d.isLineBasicMaterial?(a(m,d),d.isLineDashedMaterial&&o(m,d)):d.isPointsMaterial?c(m,d,T,M):d.isSpriteMaterial?l(m,d):d.isShadowMaterial?(m.color.value.copy(d.color),m.opacity.value=d.opacity):d.isShaderMaterial&&(d.uniformsNeedUpdate=!1)}function r(m,d){m.opacity.value=d.opacity,d.color&&m.diffuse.value.copy(d.color),d.emissive&&m.emissive.value.copy(d.emissive).multiplyScalar(d.emissiveIntensity),d.map&&(m.map.value=d.map,e(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,e(d.alphaMap,m.alphaMapTransform)),d.bumpMap&&(m.bumpMap.value=d.bumpMap,e(d.bumpMap,m.bumpMapTransform),m.bumpScale.value=d.bumpScale,d.side===Ee&&(m.bumpScale.value*=-1)),d.normalMap&&(m.normalMap.value=d.normalMap,e(d.normalMap,m.normalMapTransform),m.normalScale.value.copy(d.normalScale),d.side===Ee&&m.normalScale.value.negate()),d.displacementMap&&(m.displacementMap.value=d.displacementMap,e(d.displacementMap,m.displacementMapTransform),m.displacementScale.value=d.displacementScale,m.displacementBias.value=d.displacementBias),d.emissiveMap&&(m.emissiveMap.value=d.emissiveMap,e(d.emissiveMap,m.emissiveMapTransform)),d.specularMap&&(m.specularMap.value=d.specularMap,e(d.specularMap,m.specularMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest);let T=t.get(d),M=T.envMap,v=T.envMapRotation;M&&(m.envMap.value=M,ei.copy(v),ei.x*=-1,ei.y*=-1,ei.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(ei.y*=-1,ei.z*=-1),m.envMapRotation.value.setFromMatrix4(Vm.makeRotationFromEuler(ei)),m.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,m.reflectivity.value=d.reflectivity,m.ior.value=d.ior,m.refractionRatio.value=d.refractionRatio),d.lightMap&&(m.lightMap.value=d.lightMap,m.lightMapIntensity.value=d.lightMapIntensity,e(d.lightMap,m.lightMapTransform)),d.aoMap&&(m.aoMap.value=d.aoMap,m.aoMapIntensity.value=d.aoMapIntensity,e(d.aoMap,m.aoMapTransform))}function a(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,d.map&&(m.map.value=d.map,e(d.map,m.mapTransform))}function o(m,d){m.dashSize.value=d.dashSize,m.totalSize.value=d.dashSize+d.gapSize,m.scale.value=d.scale}function c(m,d,T,M){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.size.value=d.size*T,m.scale.value=M*.5,d.map&&(m.map.value=d.map,e(d.map,m.uvTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,e(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function l(m,d){m.diffuse.value.copy(d.color),m.opacity.value=d.opacity,m.rotation.value=d.rotation,d.map&&(m.map.value=d.map,e(d.map,m.mapTransform)),d.alphaMap&&(m.alphaMap.value=d.alphaMap,e(d.alphaMap,m.alphaMapTransform)),d.alphaTest>0&&(m.alphaTest.value=d.alphaTest)}function h(m,d){m.specular.value.copy(d.specular),m.shininess.value=Math.max(d.shininess,1e-4)}function f(m,d){d.gradientMap&&(m.gradientMap.value=d.gradientMap)}function u(m,d){m.metalness.value=d.metalness,d.metalnessMap&&(m.metalnessMap.value=d.metalnessMap,e(d.metalnessMap,m.metalnessMapTransform)),m.roughness.value=d.roughness,d.roughnessMap&&(m.roughnessMap.value=d.roughnessMap,e(d.roughnessMap,m.roughnessMapTransform)),d.envMap&&(m.envMapIntensity.value=d.envMapIntensity)}function p(m,d,T){m.ior.value=d.ior,d.sheen>0&&(m.sheenColor.value.copy(d.sheenColor).multiplyScalar(d.sheen),m.sheenRoughness.value=d.sheenRoughness,d.sheenColorMap&&(m.sheenColorMap.value=d.sheenColorMap,e(d.sheenColorMap,m.sheenColorMapTransform)),d.sheenRoughnessMap&&(m.sheenRoughnessMap.value=d.sheenRoughnessMap,e(d.sheenRoughnessMap,m.sheenRoughnessMapTransform))),d.clearcoat>0&&(m.clearcoat.value=d.clearcoat,m.clearcoatRoughness.value=d.clearcoatRoughness,d.clearcoatMap&&(m.clearcoatMap.value=d.clearcoatMap,e(d.clearcoatMap,m.clearcoatMapTransform)),d.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=d.clearcoatRoughnessMap,e(d.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),d.clearcoatNormalMap&&(m.clearcoatNormalMap.value=d.clearcoatNormalMap,e(d.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(d.clearcoatNormalScale),d.side===Ee&&m.clearcoatNormalScale.value.negate())),d.dispersion>0&&(m.dispersion.value=d.dispersion),d.iridescence>0&&(m.iridescence.value=d.iridescence,m.iridescenceIOR.value=d.iridescenceIOR,m.iridescenceThicknessMinimum.value=d.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=d.iridescenceThicknessRange[1],d.iridescenceMap&&(m.iridescenceMap.value=d.iridescenceMap,e(d.iridescenceMap,m.iridescenceMapTransform)),d.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=d.iridescenceThicknessMap,e(d.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),d.transmission>0&&(m.transmission.value=d.transmission,m.transmissionSamplerMap.value=T.texture,m.transmissionSamplerSize.value.set(T.width,T.height),d.transmissionMap&&(m.transmissionMap.value=d.transmissionMap,e(d.transmissionMap,m.transmissionMapTransform)),m.thickness.value=d.thickness,d.thicknessMap&&(m.thicknessMap.value=d.thicknessMap,e(d.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=d.attenuationDistance,m.attenuationColor.value.copy(d.attenuationColor)),d.anisotropy>0&&(m.anisotropyVector.value.set(d.anisotropy*Math.cos(d.anisotropyRotation),d.anisotropy*Math.sin(d.anisotropyRotation)),d.anisotropyMap&&(m.anisotropyMap.value=d.anisotropyMap,e(d.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=d.specularIntensity,m.specularColor.value.copy(d.specularColor),d.specularColorMap&&(m.specularColorMap.value=d.specularColorMap,e(d.specularColorMap,m.specularColorMapTransform)),d.specularIntensityMap&&(m.specularIntensityMap.value=d.specularIntensityMap,e(d.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,d){d.matcap&&(m.matcap.value=d.matcap)}function _(m,d){let T=t.get(d).light;m.referencePosition.value.setFromMatrixPosition(T.matrixWorld),m.nearDistance.value=T.shadow.camera.near,m.farDistance.value=T.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Wm(i,t,e,n){let s={},r={},a=[],o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(T,M){let v=M.program;n.uniformBlockBinding(T,v)}function l(T,M){let v=s[T.id];v===void 0&&(g(T),v=h(T),s[T.id]=v,T.addEventListener("dispose",m));let R=M.program;n.updateUBOMapping(T,R);let w=t.render.frame;r[T.id]!==w&&(u(T),r[T.id]=w)}function h(T){let M=f();T.__bindingPointIndex=M;let v=i.createBuffer(),R=T.__size,w=T.usage;return i.bindBuffer(i.UNIFORM_BUFFER,v),i.bufferData(i.UNIFORM_BUFFER,R,w),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,M,v),v}function f(){for(let T=0;T<o;T++)if(a.indexOf(T)===-1)return a.push(T),T;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function u(T){let M=s[T.id],v=T.uniforms,R=T.__cache;i.bindBuffer(i.UNIFORM_BUFFER,M);for(let w=0,C=v.length;w<C;w++){let U=Array.isArray(v[w])?v[w]:[v[w]];for(let S=0,b=U.length;S<b;S++){let P=U[S];if(p(P,w,S,R)===!0){let B=P.__offset,V=Array.isArray(P.value)?P.value:[P.value],X=0;for(let Z=0;Z<V.length;Z++){let W=V[Z],et=_(W);typeof W=="number"||typeof W=="boolean"?(P.__data[0]=W,i.bufferSubData(i.UNIFORM_BUFFER,B+X,P.__data)):W.isMatrix3?(P.__data[0]=W.elements[0],P.__data[1]=W.elements[1],P.__data[2]=W.elements[2],P.__data[3]=0,P.__data[4]=W.elements[3],P.__data[5]=W.elements[4],P.__data[6]=W.elements[5],P.__data[7]=0,P.__data[8]=W.elements[6],P.__data[9]=W.elements[7],P.__data[10]=W.elements[8],P.__data[11]=0):(W.toArray(P.__data,X),X+=et.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,B,P.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(T,M,v,R){let w=T.value,C=M+"_"+v;if(R[C]===void 0)return typeof w=="number"||typeof w=="boolean"?R[C]=w:R[C]=w.clone(),!0;{let U=R[C];if(typeof w=="number"||typeof w=="boolean"){if(U!==w)return R[C]=w,!0}else if(U.equals(w)===!1)return U.copy(w),!0}return!1}function g(T){let M=T.uniforms,v=0,R=16;for(let C=0,U=M.length;C<U;C++){let S=Array.isArray(M[C])?M[C]:[M[C]];for(let b=0,P=S.length;b<P;b++){let B=S[b],V=Array.isArray(B.value)?B.value:[B.value];for(let X=0,Z=V.length;X<Z;X++){let W=V[X],et=_(W),k=v%R,rt=k%et.boundary,ct=k+rt;v+=rt,ct!==0&&R-ct<et.storage&&(v+=R-ct),B.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),B.__offset=v,v+=et.storage}}}let w=v%R;return w>0&&(v+=R-w),T.__size=v,T.__cache={},this}function _(T){let M={boundary:0,storage:0};return typeof T=="number"||typeof T=="boolean"?(M.boundary=4,M.storage=4):T.isVector2?(M.boundary=8,M.storage=8):T.isVector3||T.isColor?(M.boundary=16,M.storage=12):T.isVector4?(M.boundary=16,M.storage=16):T.isMatrix3?(M.boundary=48,M.storage=48):T.isMatrix4?(M.boundary=64,M.storage=64):T.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",T),M}function m(T){let M=T.target;M.removeEventListener("dispose",m);let v=a.indexOf(M.__bindingPointIndex);a.splice(v,1),i.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function d(){for(let T in s)i.deleteBuffer(s[T]);a=[],s={},r={}}return{bind:c,update:l,dispose:d}}var Sa=class{constructor(t={}){let{canvas:e=Tc(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:u=!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=a;let g=new Uint32Array(4),_=new Int32Array(4),m=null,d=null,T=[],M=[];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.toneMapping=vn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let v=this,R=!1;this._outputColorSpace=Fe;let w=0,C=0,U=null,S=-1,b=null,P=new oe,B=new oe,V=null,X=new zt(0),Z=0,W=e.width,et=e.height,k=1,rt=null,ct=null,bt=new oe(0,0,W,et),Bt=new oe(0,0,W,et),Jt=!1,te=new hs,Wt=!1,q=!1,J=new ce,dt=new N,Ct=new oe,Mt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ht=!1;function ge(){return U===null?k:1}let A=n;function ee(y,L){return e.getContext(y,L)}try{let y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:f};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${"180"}`),e.addEventListener("webglcontextlost",it,!1),e.addEventListener("webglcontextrestored",ut,!1),e.addEventListener("webglcontextcreationerror",K,!1),A===null){let L="webgl2";if(A=ee(L,y),A===null)throw ee(L)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(y){throw console.error("THREE.WebGLRenderer: "+y.message),y}let It,At,mt,ne,gt,Nt,pe,le,E,x,F,G,$,H,vt,nt,_t,xt,Q,lt,wt,yt,at,Dt;function I(){It=new lp(A),It.init(),yt=new zm(A,It),At=new ep(A,It,t,yt),mt=new Om(A,It),At.reversedDepthBuffer&&u&&mt.buffers.depth.setReversed(!0),ne=new up(A),gt=new Em,Nt=new Bm(A,It,mt,gt,At,yt,ne),pe=new ip(v),le=new op(v),E=new gu(A),at=new Qf(A,E),x=new cp(A,E,ne,at),F=new fp(A,x,E,ne),Q=new dp(A,At,Nt),nt=new np(gt),G=new Sm(v,pe,le,It,At,at,nt),$=new Gm(v,gt),H=new wm,vt=new Lm(It),xt=new jf(v,pe,le,mt,F,p,c),_t=new Nm(v,F,At),Dt=new Wm(A,ne,At,mt),lt=new tp(A,It,ne),wt=new hp(A,It,ne),ne.programs=G.programs,v.capabilities=At,v.extensions=It,v.properties=gt,v.renderLists=H,v.shadowMap=_t,v.state=mt,v.info=ne}I();let tt=new Qo(v,A);this.xr=tt,this.getContext=function(){return A},this.getContextAttributes=function(){return A.getContextAttributes()},this.forceContextLoss=function(){let y=It.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){let y=It.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return k},this.setPixelRatio=function(y){y!==void 0&&(k=y,this.setSize(W,et,!1))},this.getSize=function(y){return y.set(W,et)},this.setSize=function(y,L,O=!0){if(tt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=y,et=L,e.width=Math.floor(y*k),e.height=Math.floor(L*k),O===!0&&(e.style.width=y+"px",e.style.height=L+"px"),this.setViewport(0,0,y,L)},this.getDrawingBufferSize=function(y){return y.set(W*k,et*k).floor()},this.setDrawingBufferSize=function(y,L,O){W=y,et=L,k=O,e.width=Math.floor(y*O),e.height=Math.floor(L*O),this.setViewport(0,0,y,L)},this.getCurrentViewport=function(y){return y.copy(P)},this.getViewport=function(y){return y.copy(bt)},this.setViewport=function(y,L,O,z){y.isVector4?bt.set(y.x,y.y,y.z,y.w):bt.set(y,L,O,z),mt.viewport(P.copy(bt).multiplyScalar(k).round())},this.getScissor=function(y){return y.copy(Bt)},this.setScissor=function(y,L,O,z){y.isVector4?Bt.set(y.x,y.y,y.z,y.w):Bt.set(y,L,O,z),mt.scissor(B.copy(Bt).multiplyScalar(k).round())},this.getScissorTest=function(){return Jt},this.setScissorTest=function(y){mt.setScissorTest(Jt=y)},this.setOpaqueSort=function(y){rt=y},this.setTransparentSort=function(y){ct=y},this.getClearColor=function(y){return y.copy(xt.getClearColor())},this.setClearColor=function(){xt.setClearColor(...arguments)},this.getClearAlpha=function(){return xt.getClearAlpha()},this.setClearAlpha=function(){xt.setClearAlpha(...arguments)},this.clear=function(y=!0,L=!0,O=!0){let z=0;if(y){let D=!1;if(U!==null){let j=U.texture.format;D=j===Wr||j===Gr||j===Vr}if(D){let j=U.texture.type,ot=j===an||j===Bn||j===Li||j===Ui||j===kr||j===Hr,ft=xt.getClearColor(),ht=xt.getClearAlpha(),Tt=ft.r,Rt=ft.g,St=ft.b;ot?(g[0]=Tt,g[1]=Rt,g[2]=St,g[3]=ht,A.clearBufferuiv(A.COLOR,0,g)):(_[0]=Tt,_[1]=Rt,_[2]=St,_[3]=ht,A.clearBufferiv(A.COLOR,0,_))}else z|=A.COLOR_BUFFER_BIT}L&&(z|=A.DEPTH_BUFFER_BIT),O&&(z|=A.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),A.clear(z)},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",it,!1),e.removeEventListener("webglcontextrestored",ut,!1),e.removeEventListener("webglcontextcreationerror",K,!1),xt.dispose(),H.dispose(),vt.dispose(),gt.dispose(),pe.dispose(),le.dispose(),F.dispose(),at.dispose(),Dt.dispose(),G.dispose(),tt.dispose(),tt.removeEventListener("sessionstart",Qe),tt.removeEventListener("sessionend",al),zn.stop()};function it(y){y.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),R=!0}function ut(){console.log("THREE.WebGLRenderer: Context Restored."),R=!1;let y=ne.autoReset,L=_t.enabled,O=_t.autoUpdate,z=_t.needsUpdate,D=_t.type;I(),ne.autoReset=y,_t.enabled=L,_t.autoUpdate=O,_t.needsUpdate=z,_t.type=D}function K(y){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Y(y){let L=y.target;L.removeEventListener("dispose",Y),pt(L)}function pt(y){Pt(y),gt.remove(y)}function Pt(y){let L=gt.get(y).programs;L!==void 0&&(L.forEach(function(O){G.releaseProgram(O)}),y.isShaderMaterial&&G.releaseShaderCache(y))}this.renderBufferDirect=function(y,L,O,z,D,j){L===null&&(L=Mt);let ot=D.isMesh&&D.matrixWorld.determinant()<0,ft=ph(y,L,O,z,D);mt.setMaterial(z,ot);let ht=O.index,Tt=1;if(z.wireframe===!0){if(ht=x.getWireframeAttribute(O),ht===void 0)return;Tt=2}let Rt=O.drawRange,St=O.attributes.position,kt=Rt.start*Tt,Yt=(Rt.start+Rt.count)*Tt;j!==null&&(kt=Math.max(kt,j.start*Tt),Yt=Math.min(Yt,(j.start+j.count)*Tt)),ht!==null?(kt=Math.max(kt,0),Yt=Math.min(Yt,ht.count)):St!=null&&(kt=Math.max(kt,0),Yt=Math.min(Yt,St.count));let re=Yt-kt;if(re<0||re===1/0)return;at.setup(D,z,ft,O,ht);let jt,$t=lt;if(ht!==null&&(jt=E.get(ht),$t=wt,$t.setIndex(jt)),D.isMesh)z.wireframe===!0?(mt.setLineWidth(z.wireframeLinewidth*ge()),$t.setMode(A.LINES)):$t.setMode(A.TRIANGLES);else if(D.isLine){let Et=z.linewidth;Et===void 0&&(Et=1),mt.setLineWidth(Et*ge()),D.isLineSegments?$t.setMode(A.LINES):D.isLineLoop?$t.setMode(A.LINE_LOOP):$t.setMode(A.LINE_STRIP)}else D.isPoints?$t.setMode(A.POINTS):D.isSprite&&$t.setMode(A.TRIANGLES);if(D.isBatchedMesh)if(D._multiDrawInstances!==null)Si("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),$t.renderMultiDrawInstances(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount,D._multiDrawInstances);else if(It.get("WEBGL_multi_draw"))$t.renderMultiDraw(D._multiDrawStarts,D._multiDrawCounts,D._multiDrawCount);else{let Et=D._multiDrawStarts,ie=D._multiDrawCounts,Gt=D._multiDrawCount,Le=ht?E.get(ht).bytesPerElement:1,ri=gt.get(z).currentProgram.getUniforms();for(let De=0;De<Gt;De++)ri.setValue(A,"_gl_DrawID",De),$t.render(Et[De]/Le,ie[De])}else if(D.isInstancedMesh)$t.renderInstances(kt,re,D.count);else if(O.isInstancedBufferGeometry){let Et=O._maxInstanceCount!==void 0?O._maxInstanceCount:1/0,ie=Math.min(O.instanceCount,Et);$t.renderInstances(kt,re,ie)}else $t.render(kt,re)};function Kt(y,L,O){y.transparent===!0&&y.side===Xe&&y.forceSinglePass===!1?(y.side=Ee,y.needsUpdate=!0,Is(y,L,O),y.side=gn,y.needsUpdate=!0,Is(y,L,O),y.side=Xe):Is(y,L,O)}this.compile=function(y,L,O=null){O===null&&(O=y),d=vt.get(O),d.init(L),M.push(d),O.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(d.pushLight(D),D.castShadow&&d.pushShadow(D))}),y!==O&&y.traverseVisible(function(D){D.isLight&&D.layers.test(L.layers)&&(d.pushLight(D),D.castShadow&&d.pushShadow(D))}),d.setupLights();let z=new Set;return y.traverse(function(D){if(!(D.isMesh||D.isPoints||D.isLine||D.isSprite))return;let j=D.material;if(j)if(Array.isArray(j))for(let ot=0;ot<j.length;ot++){let ft=j[ot];Kt(ft,O,D),z.add(ft)}else Kt(j,O,D),z.add(j)}),d=M.pop(),z},this.compileAsync=function(y,L,O=null){let z=this.compile(y,L,O);return new Promise(D=>{function j(){if(z.forEach(function(ot){gt.get(ot).currentProgram.isReady()&&z.delete(ot)}),z.size===0){D(y);return}setTimeout(j,10)}It.get("KHR_parallel_shader_compile")!==null?j():setTimeout(j,10)})};let Xt=null;function cn(y){Xt&&Xt(y)}function Qe(){zn.stop()}function al(){zn.start()}let zn=new Qc;zn.setAnimationLoop(cn),typeof self<"u"&&zn.setContext(self),this.setAnimationLoop=function(y){Xt=y,tt.setAnimationLoop(y),y===null?zn.stop():zn.start()},tt.addEventListener("sessionstart",Qe),tt.addEventListener("sessionend",al),this.render=function(y,L){if(L!==void 0&&L.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),L.parent===null&&L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),tt.enabled===!0&&tt.isPresenting===!0&&(tt.cameraAutoUpdate===!0&&tt.updateCamera(L),L=tt.getCamera()),y.isScene===!0&&y.onBeforeRender(v,y,L,U),d=vt.get(y,M.length),d.init(L),M.push(d),J.multiplyMatrices(L.projectionMatrix,L.matrixWorldInverse),te.setFromProjectionMatrix(J,Je,L.reversedDepth),q=this.localClippingEnabled,Wt=nt.init(this.clippingPlanes,q),m=H.get(y,T.length),m.init(),T.push(m),tt.enabled===!0&&tt.isPresenting===!0){let j=v.xr.getDepthSensingMesh();j!==null&&Ua(j,L,-1/0,v.sortObjects)}Ua(y,L,0,v.sortObjects),m.finish(),v.sortObjects===!0&&m.sort(rt,ct),Ht=tt.enabled===!1||tt.isPresenting===!1||tt.hasDepthSensing()===!1,Ht&&xt.addToRenderList(m,y),this.info.render.frame++,Wt===!0&&nt.beginShadows();let O=d.state.shadowsArray;_t.render(O,y,L),Wt===!0&&nt.endShadows(),this.info.autoReset===!0&&this.info.reset();let z=m.opaque,D=m.transmissive;if(d.setupLights(),L.isArrayCamera){let j=L.cameras;if(D.length>0)for(let ot=0,ft=j.length;ot<ft;ot++){let ht=j[ot];ll(z,D,y,ht)}Ht&&xt.render(y);for(let ot=0,ft=j.length;ot<ft;ot++){let ht=j[ot];ol(m,y,ht,ht.viewport)}}else D.length>0&&ll(z,D,y,L),Ht&&xt.render(y),ol(m,y,L);U!==null&&C===0&&(Nt.updateMultisampleRenderTarget(U),Nt.updateRenderTargetMipmap(U)),y.isScene===!0&&y.onAfterRender(v,y,L),at.resetDefaultState(),S=-1,b=null,M.pop(),M.length>0?(d=M[M.length-1],Wt===!0&&nt.setGlobalState(v.clippingPlanes,d.state.camera)):d=null,T.pop(),T.length>0?m=T[T.length-1]:m=null};function Ua(y,L,O,z){if(y.visible===!1)return;if(y.layers.test(L.layers)){if(y.isGroup)O=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(L);else if(y.isLight)d.pushLight(y),y.castShadow&&d.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||te.intersectsSprite(y)){z&&Ct.setFromMatrixPosition(y.matrixWorld).applyMatrix4(J);let ot=F.update(y),ft=y.material;ft.visible&&m.push(y,ot,ft,O,Ct.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||te.intersectsObject(y))){let ot=F.update(y),ft=y.material;if(z&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ct.copy(y.boundingSphere.center)):(ot.boundingSphere===null&&ot.computeBoundingSphere(),Ct.copy(ot.boundingSphere.center)),Ct.applyMatrix4(y.matrixWorld).applyMatrix4(J)),Array.isArray(ft)){let ht=ot.groups;for(let Tt=0,Rt=ht.length;Tt<Rt;Tt++){let St=ht[Tt],kt=ft[St.materialIndex];kt&&kt.visible&&m.push(y,ot,kt,O,Ct.z,St)}}else ft.visible&&m.push(y,ot,ft,O,Ct.z,null)}}let j=y.children;for(let ot=0,ft=j.length;ot<ft;ot++)Ua(j[ot],L,O,z)}function ol(y,L,O,z){let D=y.opaque,j=y.transmissive,ot=y.transparent;d.setupLightsView(O),Wt===!0&&nt.setGlobalState(v.clippingPlanes,O),z&&mt.viewport(P.copy(z)),D.length>0&&Ps(D,L,O),j.length>0&&Ps(j,L,O),ot.length>0&&Ps(ot,L,O),mt.buffers.depth.setTest(!0),mt.buffers.depth.setMask(!0),mt.buffers.color.setMask(!0),mt.setPolygonOffset(!1)}function ll(y,L,O,z){if((O.isScene===!0?O.overrideMaterial:null)!==null)return;d.state.transmissionRenderTarget[z.id]===void 0&&(d.state.transmissionRenderTarget[z.id]=new en(1,1,{generateMipmaps:!0,type:It.has("EXT_color_buffer_half_float")||It.has("EXT_color_buffer_float")?Di:an,minFilter:On,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Vt.workingColorSpace}));let j=d.state.transmissionRenderTarget[z.id],ot=z.viewport||P;j.setSize(ot.z*v.transmissionResolutionScale,ot.w*v.transmissionResolutionScale);let ft=v.getRenderTarget(),ht=v.getActiveCubeFace(),Tt=v.getActiveMipmapLevel();v.setRenderTarget(j),v.getClearColor(X),Z=v.getClearAlpha(),Z<1&&v.setClearColor(16777215,.5),v.clear(),Ht&&xt.render(O);let Rt=v.toneMapping;v.toneMapping=vn;let St=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),d.setupLightsView(z),Wt===!0&&nt.setGlobalState(v.clippingPlanes,z),Ps(y,O,z),Nt.updateMultisampleRenderTarget(j),Nt.updateRenderTargetMipmap(j),It.has("WEBGL_multisampled_render_to_texture")===!1){let kt=!1;for(let Yt=0,re=L.length;Yt<re;Yt++){let jt=L[Yt],$t=jt.object,Et=jt.geometry,ie=jt.material,Gt=jt.group;if(ie.side===Xe&&$t.layers.test(z.layers)){let Le=ie.side;ie.side=Ee,ie.needsUpdate=!0,cl($t,O,z,Et,ie,Gt),ie.side=Le,ie.needsUpdate=!0,kt=!0}}kt===!0&&(Nt.updateMultisampleRenderTarget(j),Nt.updateRenderTargetMipmap(j))}v.setRenderTarget(ft,ht,Tt),v.setClearColor(X,Z),St!==void 0&&(z.viewport=St),v.toneMapping=Rt}function Ps(y,L,O){let z=L.isScene===!0?L.overrideMaterial:null;for(let D=0,j=y.length;D<j;D++){let ot=y[D],ft=ot.object,ht=ot.geometry,Tt=ot.group,Rt=ot.material;Rt.allowOverride===!0&&z!==null&&(Rt=z),ft.layers.test(O.layers)&&cl(ft,L,O,ht,Rt,Tt)}}function cl(y,L,O,z,D,j){y.onBeforeRender(v,L,O,z,D,j),y.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),D.onBeforeRender(v,L,O,z,y,j),D.transparent===!0&&D.side===Xe&&D.forceSinglePass===!1?(D.side=Ee,D.needsUpdate=!0,v.renderBufferDirect(O,L,z,D,y,j),D.side=gn,D.needsUpdate=!0,v.renderBufferDirect(O,L,z,D,y,j),D.side=Xe):v.renderBufferDirect(O,L,z,D,y,j),y.onAfterRender(v,L,O,z,D,j)}function Is(y,L,O){L.isScene!==!0&&(L=Mt);let z=gt.get(y),D=d.state.lights,j=d.state.shadowsArray,ot=D.state.version,ft=G.getParameters(y,D.state,j,L,O),ht=G.getProgramCacheKey(ft),Tt=z.programs;z.environment=y.isMeshStandardMaterial?L.environment:null,z.fog=L.fog,z.envMap=(y.isMeshStandardMaterial?le:pe).get(y.envMap||z.environment),z.envMapRotation=z.environment!==null&&y.envMap===null?L.environmentRotation:y.envMapRotation,Tt===void 0&&(y.addEventListener("dispose",Y),Tt=new Map,z.programs=Tt);let Rt=Tt.get(ht);if(Rt!==void 0){if(z.currentProgram===Rt&&z.lightsStateVersion===ot)return ul(y,ft),Rt}else ft.uniforms=G.getUniforms(y),y.onBeforeCompile(ft,v),Rt=G.acquireProgram(ft,ht),Tt.set(ht,Rt),z.uniforms=ft.uniforms;let St=z.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(St.clippingPlanes=nt.uniform),ul(y,ft),z.needsLights=gh(y),z.lightsStateVersion=ot,z.needsLights&&(St.ambientLightColor.value=D.state.ambient,St.lightProbe.value=D.state.probe,St.directionalLights.value=D.state.directional,St.directionalLightShadows.value=D.state.directionalShadow,St.spotLights.value=D.state.spot,St.spotLightShadows.value=D.state.spotShadow,St.rectAreaLights.value=D.state.rectArea,St.ltc_1.value=D.state.rectAreaLTC1,St.ltc_2.value=D.state.rectAreaLTC2,St.pointLights.value=D.state.point,St.pointLightShadows.value=D.state.pointShadow,St.hemisphereLights.value=D.state.hemi,St.directionalShadowMap.value=D.state.directionalShadowMap,St.directionalShadowMatrix.value=D.state.directionalShadowMatrix,St.spotShadowMap.value=D.state.spotShadowMap,St.spotLightMatrix.value=D.state.spotLightMatrix,St.spotLightMap.value=D.state.spotLightMap,St.pointShadowMap.value=D.state.pointShadowMap,St.pointShadowMatrix.value=D.state.pointShadowMatrix),z.currentProgram=Rt,z.uniformsList=null,Rt}function hl(y){if(y.uniformsList===null){let L=y.currentProgram.getUniforms();y.uniformsList=zi.seqWithValue(L.seq,y.uniforms)}return y.uniformsList}function ul(y,L){let O=gt.get(y);O.outputColorSpace=L.outputColorSpace,O.batching=L.batching,O.batchingColor=L.batchingColor,O.instancing=L.instancing,O.instancingColor=L.instancingColor,O.instancingMorph=L.instancingMorph,O.skinning=L.skinning,O.morphTargets=L.morphTargets,O.morphNormals=L.morphNormals,O.morphColors=L.morphColors,O.morphTargetsCount=L.morphTargetsCount,O.numClippingPlanes=L.numClippingPlanes,O.numIntersection=L.numClipIntersection,O.vertexAlphas=L.vertexAlphas,O.vertexTangents=L.vertexTangents,O.toneMapping=L.toneMapping}function ph(y,L,O,z,D){L.isScene!==!0&&(L=Mt),Nt.resetTextureUnits();let j=L.fog,ot=z.isMeshStandardMaterial?L.environment:null,ft=U===null?v.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:Zn,ht=(z.isMeshStandardMaterial?le:pe).get(z.envMap||ot),Tt=z.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,Rt=!!O.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),St=!!O.morphAttributes.position,kt=!!O.morphAttributes.normal,Yt=!!O.morphAttributes.color,re=vn;z.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(re=v.toneMapping);let jt=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,$t=jt!==void 0?jt.length:0,Et=gt.get(z),ie=d.state.lights;if(Wt===!0&&(q===!0||y!==b)){let Me=y===b&&z.id===S;nt.setState(z,y,Me)}let Gt=!1;z.version===Et.__version?(Et.needsLights&&Et.lightsStateVersion!==ie.state.version||Et.outputColorSpace!==ft||D.isBatchedMesh&&Et.batching===!1||!D.isBatchedMesh&&Et.batching===!0||D.isBatchedMesh&&Et.batchingColor===!0&&D.colorTexture===null||D.isBatchedMesh&&Et.batchingColor===!1&&D.colorTexture!==null||D.isInstancedMesh&&Et.instancing===!1||!D.isInstancedMesh&&Et.instancing===!0||D.isSkinnedMesh&&Et.skinning===!1||!D.isSkinnedMesh&&Et.skinning===!0||D.isInstancedMesh&&Et.instancingColor===!0&&D.instanceColor===null||D.isInstancedMesh&&Et.instancingColor===!1&&D.instanceColor!==null||D.isInstancedMesh&&Et.instancingMorph===!0&&D.morphTexture===null||D.isInstancedMesh&&Et.instancingMorph===!1&&D.morphTexture!==null||Et.envMap!==ht||z.fog===!0&&Et.fog!==j||Et.numClippingPlanes!==void 0&&(Et.numClippingPlanes!==nt.numPlanes||Et.numIntersection!==nt.numIntersection)||Et.vertexAlphas!==Tt||Et.vertexTangents!==Rt||Et.morphTargets!==St||Et.morphNormals!==kt||Et.morphColors!==Yt||Et.toneMapping!==re||Et.morphTargetsCount!==$t)&&(Gt=!0):(Gt=!0,Et.__version=z.version);let Le=Et.currentProgram;Gt===!0&&(Le=Is(z,L,D));let ri=!1,De=!1,Gi=!1,se=Le.getUniforms(),ze=Et.uniforms;if(mt.useProgram(Le.program)&&(ri=!0,De=!0,Gi=!0),z.id!==S&&(S=z.id,De=!0),ri||b!==y){mt.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),se.setValue(A,"projectionMatrix",y.projectionMatrix),se.setValue(A,"viewMatrix",y.matrixWorldInverse);let Te=se.map.cameraPosition;Te!==void 0&&Te.setValue(A,dt.setFromMatrixPosition(y.matrixWorld)),At.logarithmicDepthBuffer&&se.setValue(A,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&se.setValue(A,"isOrthographic",y.isOrthographicCamera===!0),b!==y&&(b=y,De=!0,Gi=!0)}if(D.isSkinnedMesh){se.setOptional(A,D,"bindMatrix"),se.setOptional(A,D,"bindMatrixInverse");let Me=D.skeleton;Me&&(Me.boneTexture===null&&Me.computeBoneTexture(),se.setValue(A,"boneTexture",Me.boneTexture,Nt))}D.isBatchedMesh&&(se.setOptional(A,D,"batchingTexture"),se.setValue(A,"batchingTexture",D._matricesTexture,Nt),se.setOptional(A,D,"batchingIdTexture"),se.setValue(A,"batchingIdTexture",D._indirectTexture,Nt),se.setOptional(A,D,"batchingColorTexture"),D._colorsTexture!==null&&se.setValue(A,"batchingColorTexture",D._colorsTexture,Nt));let ke=O.morphAttributes;if((ke.position!==void 0||ke.normal!==void 0||ke.color!==void 0)&&Q.update(D,O,Le),(De||Et.receiveShadow!==D.receiveShadow)&&(Et.receiveShadow=D.receiveShadow,se.setValue(A,"receiveShadow",D.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(ze.envMap.value=ht,ze.flipEnvMap.value=ht.isCubeTexture&&ht.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&L.environment!==null&&(ze.envMapIntensity.value=L.environmentIntensity),De&&(se.setValue(A,"toneMappingExposure",v.toneMappingExposure),Et.needsLights&&mh(ze,Gi),j&&z.fog===!0&&$.refreshFogUniforms(ze,j),$.refreshMaterialUniforms(ze,z,k,et,d.state.transmissionRenderTarget[y.id]),zi.upload(A,hl(Et),ze,Nt)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(zi.upload(A,hl(Et),ze,Nt),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&se.setValue(A,"center",D.center),se.setValue(A,"modelViewMatrix",D.modelViewMatrix),se.setValue(A,"normalMatrix",D.normalMatrix),se.setValue(A,"modelMatrix",D.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){let Me=z.uniformsGroups;for(let Te=0,Na=Me.length;Te<Na;Te++){let kn=Me[Te];Dt.update(kn,Le),Dt.bind(kn,Le)}}return Le}function mh(y,L){y.ambientLightColor.needsUpdate=L,y.lightProbe.needsUpdate=L,y.directionalLights.needsUpdate=L,y.directionalLightShadows.needsUpdate=L,y.pointLights.needsUpdate=L,y.pointLightShadows.needsUpdate=L,y.spotLights.needsUpdate=L,y.spotLightShadows.needsUpdate=L,y.rectAreaLights.needsUpdate=L,y.hemisphereLights.needsUpdate=L}function gh(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(y,L,O){let z=gt.get(y);z.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),gt.get(y.texture).__webglTexture=L,gt.get(y.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:O,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,L){let O=gt.get(y);O.__webglFramebuffer=L,O.__useDefaultFramebuffer=L===void 0};let _h=A.createFramebuffer();this.setRenderTarget=function(y,L=0,O=0){U=y,w=L,C=O;let z=!0,D=null,j=!1,ot=!1;if(y){let ht=gt.get(y);if(ht.__useDefaultFramebuffer!==void 0)mt.bindFramebuffer(A.FRAMEBUFFER,null),z=!1;else if(ht.__webglFramebuffer===void 0)Nt.setupRenderTarget(y);else if(ht.__hasExternalTextures)Nt.rebindTextures(y,gt.get(y.texture).__webglTexture,gt.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){let St=y.depthTexture;if(ht.__boundDepthTexture!==St){if(St!==null&&gt.has(St)&&(y.width!==St.image.width||y.height!==St.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Nt.setupDepthRenderbuffer(y)}}let Tt=y.texture;(Tt.isData3DTexture||Tt.isDataArrayTexture||Tt.isCompressedArrayTexture)&&(ot=!0);let Rt=gt.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Rt[L])?D=Rt[L][O]:D=Rt[L],j=!0):y.samples>0&&Nt.useMultisampledRTT(y)===!1?D=gt.get(y).__webglMultisampledFramebuffer:Array.isArray(Rt)?D=Rt[O]:D=Rt,P.copy(y.viewport),B.copy(y.scissor),V=y.scissorTest}else P.copy(bt).multiplyScalar(k).floor(),B.copy(Bt).multiplyScalar(k).floor(),V=Jt;if(O!==0&&(D=_h),mt.bindFramebuffer(A.FRAMEBUFFER,D)&&z&&mt.drawBuffers(y,D),mt.viewport(P),mt.scissor(B),mt.setScissorTest(V),j){let ht=gt.get(y.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_CUBE_MAP_POSITIVE_X+L,ht.__webglTexture,O)}else if(ot){let ht=L;for(let Tt=0;Tt<y.textures.length;Tt++){let Rt=gt.get(y.textures[Tt]);A.framebufferTextureLayer(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0+Tt,Rt.__webglTexture,O,ht)}}else if(y!==null&&O!==0){let ht=gt.get(y.texture);A.framebufferTexture2D(A.FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,ht.__webglTexture,O)}S=-1},this.readRenderTargetPixels=function(y,L,O,z,D,j,ot,ft=0){if(!(y&&y.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ht=gt.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ot!==void 0&&(ht=ht[ot]),ht){mt.bindFramebuffer(A.FRAMEBUFFER,ht);try{let Tt=y.textures[ft],Rt=Tt.format,St=Tt.type;if(!At.textureFormatReadable(Rt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!At.textureTypeReadable(St)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}L>=0&&L<=y.width-z&&O>=0&&O<=y.height-D&&(y.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+ft),A.readPixels(L,O,z,D,yt.convert(Rt),yt.convert(St),j))}finally{let Tt=U!==null?gt.get(U).__webglFramebuffer:null;mt.bindFramebuffer(A.FRAMEBUFFER,Tt)}}},this.readRenderTargetPixelsAsync=async function(y,L,O,z,D,j,ot,ft=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ht=gt.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&ot!==void 0&&(ht=ht[ot]),ht)if(L>=0&&L<=y.width-z&&O>=0&&O<=y.height-D){mt.bindFramebuffer(A.FRAMEBUFFER,ht);let Tt=y.textures[ft],Rt=Tt.format,St=Tt.type;if(!At.textureFormatReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!At.textureTypeReadable(St))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let kt=A.createBuffer();A.bindBuffer(A.PIXEL_PACK_BUFFER,kt),A.bufferData(A.PIXEL_PACK_BUFFER,j.byteLength,A.STREAM_READ),y.textures.length>1&&A.readBuffer(A.COLOR_ATTACHMENT0+ft),A.readPixels(L,O,z,D,yt.convert(Rt),yt.convert(St),0);let Yt=U!==null?gt.get(U).__webglFramebuffer:null;mt.bindFramebuffer(A.FRAMEBUFFER,Yt);let re=A.fenceSync(A.SYNC_GPU_COMMANDS_COMPLETE,0);return A.flush(),await wc(A,re,4),A.bindBuffer(A.PIXEL_PACK_BUFFER,kt),A.getBufferSubData(A.PIXEL_PACK_BUFFER,0,j),A.deleteBuffer(kt),A.deleteSync(re),j}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,L=null,O=0){let z=Math.pow(2,-O),D=Math.floor(y.image.width*z),j=Math.floor(y.image.height*z),ot=L!==null?L.x:0,ft=L!==null?L.y:0;Nt.setTexture2D(y,0),A.copyTexSubImage2D(A.TEXTURE_2D,O,0,0,ot,ft,D,j),mt.unbindTexture()};let xh=A.createFramebuffer(),yh=A.createFramebuffer();this.copyTextureToTexture=function(y,L,O=null,z=null,D=0,j=null){j===null&&(D!==0?(Si("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),j=D,D=0):j=0);let ot,ft,ht,Tt,Rt,St,kt,Yt,re,jt=y.isCompressedTexture?y.mipmaps[j]:y.image;if(O!==null)ot=O.max.x-O.min.x,ft=O.max.y-O.min.y,ht=O.isBox3?O.max.z-O.min.z:1,Tt=O.min.x,Rt=O.min.y,St=O.isBox3?O.min.z:0;else{let ke=Math.pow(2,-D);ot=Math.floor(jt.width*ke),ft=Math.floor(jt.height*ke),y.isDataArrayTexture?ht=jt.depth:y.isData3DTexture?ht=Math.floor(jt.depth*ke):ht=1,Tt=0,Rt=0,St=0}z!==null?(kt=z.x,Yt=z.y,re=z.z):(kt=0,Yt=0,re=0);let $t=yt.convert(L.format),Et=yt.convert(L.type),ie;L.isData3DTexture?(Nt.setTexture3D(L,0),ie=A.TEXTURE_3D):L.isDataArrayTexture||L.isCompressedArrayTexture?(Nt.setTexture2DArray(L,0),ie=A.TEXTURE_2D_ARRAY):(Nt.setTexture2D(L,0),ie=A.TEXTURE_2D),A.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,L.flipY),A.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,L.premultiplyAlpha),A.pixelStorei(A.UNPACK_ALIGNMENT,L.unpackAlignment);let Gt=A.getParameter(A.UNPACK_ROW_LENGTH),Le=A.getParameter(A.UNPACK_IMAGE_HEIGHT),ri=A.getParameter(A.UNPACK_SKIP_PIXELS),De=A.getParameter(A.UNPACK_SKIP_ROWS),Gi=A.getParameter(A.UNPACK_SKIP_IMAGES);A.pixelStorei(A.UNPACK_ROW_LENGTH,jt.width),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,jt.height),A.pixelStorei(A.UNPACK_SKIP_PIXELS,Tt),A.pixelStorei(A.UNPACK_SKIP_ROWS,Rt),A.pixelStorei(A.UNPACK_SKIP_IMAGES,St);let se=y.isDataArrayTexture||y.isData3DTexture,ze=L.isDataArrayTexture||L.isData3DTexture;if(y.isDepthTexture){let ke=gt.get(y),Me=gt.get(L),Te=gt.get(ke.__renderTarget),Na=gt.get(Me.__renderTarget);mt.bindFramebuffer(A.READ_FRAMEBUFFER,Te.__webglFramebuffer),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,Na.__webglFramebuffer);for(let kn=0;kn<ht;kn++)se&&(A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,gt.get(y).__webglTexture,D,St+kn),A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,gt.get(L).__webglTexture,j,re+kn)),A.blitFramebuffer(Tt,Rt,ot,ft,kt,Yt,ot,ft,A.DEPTH_BUFFER_BIT,A.NEAREST);mt.bindFramebuffer(A.READ_FRAMEBUFFER,null),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else if(D!==0||y.isRenderTargetTexture||gt.has(y)){let ke=gt.get(y),Me=gt.get(L);mt.bindFramebuffer(A.READ_FRAMEBUFFER,xh),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,yh);for(let Te=0;Te<ht;Te++)se?A.framebufferTextureLayer(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,ke.__webglTexture,D,St+Te):A.framebufferTexture2D(A.READ_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,ke.__webglTexture,D),ze?A.framebufferTextureLayer(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,Me.__webglTexture,j,re+Te):A.framebufferTexture2D(A.DRAW_FRAMEBUFFER,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,Me.__webglTexture,j),D!==0?A.blitFramebuffer(Tt,Rt,ot,ft,kt,Yt,ot,ft,A.COLOR_BUFFER_BIT,A.NEAREST):ze?A.copyTexSubImage3D(ie,j,kt,Yt,re+Te,Tt,Rt,ot,ft):A.copyTexSubImage2D(ie,j,kt,Yt,Tt,Rt,ot,ft);mt.bindFramebuffer(A.READ_FRAMEBUFFER,null),mt.bindFramebuffer(A.DRAW_FRAMEBUFFER,null)}else ze?y.isDataTexture||y.isData3DTexture?A.texSubImage3D(ie,j,kt,Yt,re,ot,ft,ht,$t,Et,jt.data):L.isCompressedArrayTexture?A.compressedTexSubImage3D(ie,j,kt,Yt,re,ot,ft,ht,$t,jt.data):A.texSubImage3D(ie,j,kt,Yt,re,ot,ft,ht,$t,Et,jt):y.isDataTexture?A.texSubImage2D(A.TEXTURE_2D,j,kt,Yt,ot,ft,$t,Et,jt.data):y.isCompressedTexture?A.compressedTexSubImage2D(A.TEXTURE_2D,j,kt,Yt,jt.width,jt.height,$t,jt.data):A.texSubImage2D(A.TEXTURE_2D,j,kt,Yt,ot,ft,$t,Et,jt);A.pixelStorei(A.UNPACK_ROW_LENGTH,Gt),A.pixelStorei(A.UNPACK_IMAGE_HEIGHT,Le),A.pixelStorei(A.UNPACK_SKIP_PIXELS,ri),A.pixelStorei(A.UNPACK_SKIP_ROWS,De),A.pixelStorei(A.UNPACK_SKIP_IMAGES,Gi),j===0&&L.generateMipmaps&&A.generateMipmap(ie),mt.unbindTexture()},this.initRenderTarget=function(y){gt.get(y).__webglFramebuffer===void 0&&Nt.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?Nt.setTextureCube(y,0):y.isData3DTexture?Nt.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?Nt.setTexture2DArray(y,0):Nt.setTexture2D(y,0),mt.unbindTexture()},this.resetState=function(){w=0,C=0,U=null,mt.reset(),at.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Je}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=Vt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Vt._getUnpackColorSpace()}};var sh={type:"change"},nl={type:"start"},ah={type:"end"},Ta=new Dn,rh=new Ve,qm=Math.cos(70*Uo.DEG2RAD),fe=new N,Ie=2*Math.PI,Zt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},el=1e-6,wa=class extends xs{constructor(t,e=null){super(t,e),this.state=Zt.NONE,this.target=new N,this.cursor=new N,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Se.ROTATE,MIDDLE:Se.DOLLY,RIGHT:Se.PAN},this.touches={ONE:Be.ROTATE,TWO:Be.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new N,this._lastQuaternion=new We,this._lastTargetPosition=new N,this._quat=new We().setFromUnitVectors(t.up,new N(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Ii,this._sphericalDelta=new Ii,this._scale=1,this._panOffset=new N,this._rotateStart=new Ut,this._rotateEnd=new Ut,this._rotateDelta=new Ut,this._panStart=new Ut,this._panEnd=new Ut,this._panDelta=new Ut,this._dollyStart=new Ut,this._dollyEnd=new Ut,this._dollyDelta=new Ut,this._dollyDirection=new N,this._mouse=new Ut,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Zm.bind(this),this._onPointerDown=Ym.bind(this),this._onPointerUp=$m.bind(this),this._onContextMenu=ng.bind(this),this._onMouseWheel=jm.bind(this),this._onKeyDown=Qm.bind(this),this._onTouchStart=tg.bind(this),this._onTouchMove=eg.bind(this),this._onMouseDown=Jm.bind(this),this._onMouseMove=Km.bind(this),this._interceptControlDown=ig.bind(this),this._interceptControlUp=sg.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(t){super.connect(t),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(sh),this.update(),this.state=Zt.NONE}update(t=null){let e=this.object.position;fe.copy(e).sub(this.target),fe.applyQuaternion(this._quat),this._spherical.setFromVector3(fe),this.autoRotate&&this.state===Zt.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=Ie:n>Math.PI&&(n-=Ie),s<-Math.PI?s+=Ie:s>Math.PI&&(s-=Ie),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(fe.setFromSpherical(this._spherical),fe.applyQuaternion(this._quatInverse),e.copy(this.target).add(fe),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){let o=fe.length();a=this._clampDistance(o*this._scale);let c=o-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),r=!!c}else if(this.object.isOrthographicCamera){let o=new N(this._mouse.x,this._mouse.y,0);o.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=c!==this.object.zoom;let l=new N(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(o),this.object.updateMatrixWorld(),a=fe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Ta.origin.copy(this.object.position),Ta.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ta.direction))<qm?this.object.lookAt(this.target):(rh.setFromNormalAndCoplanarPoint(this.object.up,this.target),Ta.intersectPlane(rh,this.target))))}else if(this.object.isOrthographicCamera){let a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>el||8*(1-this._lastQuaternion.dot(this.object.quaternion))>el||this._lastTargetPosition.distanceToSquared(this.target)>el?(this.dispatchEvent(sh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?Ie/60*this.autoRotateSpeed*t:Ie/60/60*this.autoRotateSpeed}_getZoomScale(t){let e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){fe.setFromMatrixColumn(e,0),fe.multiplyScalar(-t),this._panOffset.add(fe)}_panUp(t,e){this.screenSpacePanning===!0?fe.setFromMatrixColumn(e,1):(fe.setFromMatrixColumn(e,0),fe.crossVectors(this.object.up,fe)),fe.multiplyScalar(t),this._panOffset.add(fe)}_pan(t,e){let n=this.domElement;if(this.object.isPerspectiveCamera){let s=this.object.position;fe.copy(s).sub(this.target);let r=fe.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*r/n.clientHeight,this.object.matrix),this._panUp(2*e*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),s=t-n.left,r=e-n.top,a=n.width,o=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Ie*this._rotateDelta.x/e.clientHeight),this._rotateUp(Ie*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateUp(-Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this.enableRotate&&this._rotateLeft(-Ie*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{let n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),r=.5*(t.pageY+n.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let e=this.domElement;this._rotateLeft(Ie*this._rotateDelta.x/e.clientHeight),this._rotateUp(Ie*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{let e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){let e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,r=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new Ut,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){let e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){let e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function Ym(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function Zm(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function $m(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(ah),this.state=Zt.NONE;break;case 1:let t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function Jm(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case Se.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Zt.DOLLY;break;case Se.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Zt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Zt.ROTATE}break;case Se.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Zt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Zt.PAN}break;default:this.state=Zt.NONE}this.state!==Zt.NONE&&this.dispatchEvent(nl)}function Km(i){switch(this.state){case Zt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Zt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Zt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function jm(i){this.enabled===!1||this.enableZoom===!1||this.state!==Zt.NONE||(i.preventDefault(),this.dispatchEvent(nl),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(ah))}function Qm(i){this.enabled!==!1&&this._handleKeyDown(i)}function tg(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case Be.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Zt.TOUCH_ROTATE;break;case Be.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Zt.TOUCH_PAN;break;default:this.state=Zt.NONE}break;case 2:switch(this.touches.TWO){case Be.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Zt.TOUCH_DOLLY_PAN;break;case Be.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Zt.TOUCH_DOLLY_ROTATE;break;default:this.state=Zt.NONE}break;default:this.state=Zt.NONE}this.state!==Zt.NONE&&this.dispatchEvent(nl)}function eg(i){switch(this._trackPointer(i),this.state){case Zt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Zt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Zt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Zt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Zt.NONE}}function ng(i){this.enabled!==!1&&i.preventDefault()}function ig(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function sg(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}var ch={background:"#000000",craft:"#F0E442",primary:"#56B4E9",secondary:"#A8A8A8",grid:"#1e1e1e",axis:"#555555",text:"#cfcfcf"},oh=.05,rg=.55,ag=40,og=.4,lg=.3,Aa=.07,cg=6,hg=22,ug=60,dg=320;function fg(){let i=document.createElement("canvas");i.width=i.height=64;let t=i.getContext("2d");t.fillStyle="#fff",t.beginPath(),t.arc(32,32,28,0,Math.PI*2),t.fill();let e=new ds(i);return e.needsUpdate=!0,e}function il(i,t,e,n){let s=new ye;s.setAttribute("position",new ae(new Float32Array(3*n),3));let r=new Ci({color:i,size:t,map:e,transparent:!0,alphaTest:.5,sizeAttenuation:!1,depthTest:!1});return new us(s,r)}function Ra(i,t,e){let n=new ye;n.setAttribute("position",new ae(new Float32Array(3*e),3));let s=new Un({color:i,transparent:!0,opacity:t,depthTest:!1});return new Ai(n,s)}function lh(i,t=6){let e=i/t,n=Math.pow(10,Math.floor(Math.log10(e))),s=e/n;return(s<1.5?1:s<3.5?2:s<7.5?5:10)*n}var As=class{constructor(t,e="rotating_pulsating"){this.scene=new cs;this.palette=ch;this.frame="rotating_pulsating";this.showGhost=!0;this.showTitle=!1;this.threeD=!1;this.sys={mu:.5,e:0,f0:0};this.xy=new Float32Array(0);this.fRel=new Float32Array(0);this.xyz=new Float32Array(0);this.fNow=0;this.tracks=null;this.familyMode="hidden";this.paramRange=null;this.alphaNow=new Float32Array(0);this.alphaFrom=new Float32Array(0);this.alphaTo=new Float32Array(0);this.baseAlpha=new Float32Array(0);this.written=new Float32Array(0);this.fadeLast=0;this.fadeRaf=0;this.trailPts=new Float32Array(0);this.trailT=new Float32Array(0);this.trailCount=0;this.memberRgb=[1,1,1];this.userMoved=!1;this.host=t,this.frame=e,this.canvas=document.createElement("canvas"),this.overlay=document.createElement("canvas");for(let a of[this.canvas,this.overlay])a.style.position="absolute",a.style.inset="0",a.style.width="100%",a.style.height="100%";this.overlay.style.pointerEvents="none",t.style.position="relative",t.appendChild(this.canvas),t.appendChild(this.overlay),this.renderer=new Sa({canvas:this.canvas,antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.setClearColor(new zt(this.palette.background),1),this.camera=new Pi(-1,1,1,-1,-100,100),this.camera.position.set(0,0,10),this.camera.up.set(0,1,0),this.controls=new wa(this.camera,this.canvas),this.controls.enableDamping=!1,this.controls.screenSpacePanning=!0,this.controls.zoomToCursor=!0,this.controls.addEventListener("change",()=>{this.userMoved=!0,this.render()});let n=fg();this.family=new Ri(new ye,new Un({vertexColors:!0,transparent:!0,opacity:1,depthTest:!1})),this.family.visible=!1,this.ghost=Ra("#d0d0d0",.8,2),this.orbit=Ra("#ffffff",1,2);let s=a=>new Pe(new ye,new $n({vertexColors:!0,transparent:!0,depthTest:!1,depthWrite:!1,blending:a,side:Xe}));this.trailGlow=s(ys),this.trailCore=s(_n),this.primaryTrail=Ra(this.palette.primary,.3,2),this.secondaryTrail=Ra(this.palette.secondary,.3,2),this.craft=il(this.palette.craft,9,n,1),this.primary=il(this.palette.primary,8,n,1),this.secondary=il(this.palette.secondary,6,n,1),this.grid=new _s(4,16,this.palette.axis,this.palette.grid),this.grid.rotation.x=Math.PI/2,this.grid.visible=!1;let r=[this.grid,this.family,this.primaryTrail,this.secondaryTrail,this.ghost,this.trailGlow,this.trailCore,this.orbit,this.primary,this.secondary,this.craft];r.forEach((a,o)=>a.renderOrder=o),this.scene.add(...r),this.setThreeD(!1),this.ro=new ResizeObserver(()=>this.resize()),this.ro.observe(t),this.resize()}dispose(){cancelAnimationFrame(this.fadeRaf),this.ro.disconnect(),this.controls.dispose(),this.renderer.dispose()}get system(){return this.sys}get epoch(){return this.fNow}memberColor(){let t=this.paramRange,e=t&&t[1]>t[0]?(this.sys.e-t[0])/(t[1]-t[0]):.5;return Ns(this.spec().cmap,e)}setTrajectory(t,e,n,s=!1){let r=n.e!==this.sys.e;this.xy=t,this.fRel=e,this.sys=n;let a=e.length;if(this.xyz.length!==3*a){this.xyz=new Float32Array(3*a);for(let l of[this.ghost,this.primaryTrail,this.secondaryTrail])l.geometry.setAttribute("position",new ae(new Float32Array(3*a),3));this.orbit.geometry.setAttribute("position",new ae(new Float32Array(3*(a+1)),3));let o=a+3;this.trailPts=new Float32Array(2*o),this.trailT=new Float32Array(o);let c=[];for(let l=0;l<o-1;l++)c.push(2*l,2*l+1,2*l+2,2*l+1,2*l+3,2*l+2);for(let l of[this.trailCore,this.trailGlow])l.geometry.setAttribute("position",new ae(new Float32Array(6*o),3)),l.geometry.setAttribute("color",new ae(new Float32Array(8*o),4)),l.geometry.setIndex(c),l.frustumCulled=!1}this.recompute(),r&&this.focusFamily(!1),s&&this.fit()}setFamily(t,e){let n=t!==this.tracks;this.tracks=t,this.familyMode=t?e:"hidden",n&&this.rebuildFamily(),this.family.visible=this.familyMode!=="hidden"&&!!t,this.focusFamily(!0),this.recolour(),this.render()}setFrame(t){t!==this.frame&&(this.frame=t,this.recompute(),this.rebuildFamily(),this.fit())}setThreeD(t){this.threeD=t,this.controls.enableRotate=t,this.controls.mouseButtons=t?{LEFT:Se.ROTATE,MIDDLE:Se.DOLLY,RIGHT:Se.PAN}:{LEFT:Se.PAN,MIDDLE:Se.DOLLY,RIGHT:Se.PAN},this.controls.touches=t?{ONE:Be.ROTATE,TWO:Be.DOLLY_PAN}:{ONE:Be.PAN,TWO:Be.DOLLY_PAN},this.grid.visible=t,this.overlay.style.display=t?"none":"",t?this.render():this.fit()}spec(){return bn.find(t=>t.id===this.frame)}rebuildFamily(){let t=this.tracks;if(!t){this.paramRange=null,this.family.visible=!1;return}let e=t.count,n=t.samples,s=1/0,r=-1/0;for(let _=0;_<e;_++)s=Math.min(s,t.params[_]),r=Math.max(r,t.params[_]);this.paramRange=[s,r],this.alphaNow.length!==e&&(this.alphaNow=new Float32Array(e),this.alphaFrom=new Float32Array(e),this.alphaTo=new Float32Array(e),this.baseAlpha=new Float32Array(e),this.written=new Float32Array(e)),this.written.fill(-2);let a=e*(n-1),o=new Float32Array(a*6),c=new Float32Array(a*8),l=new Float32Array(3*n),h=[0,0,0],f=this.spec().cmap,u=0,p=0;for(let _=0;_<e;_++){let m=t.positions.subarray(_*n*2,(_+1)*n*2),d=t.anomalies.subarray(_*n,(_+1)*n);Ds(m,d,{mu:t.mu,e:t.params[_],f0:t.f0},this.frame,l);let T=r>s?(t.params[_]-s)/(r-s):.5;Xi(f,T,h);let M=0;for(let v=0;v<n-1;v++)o[u]=l[3*v],o[u+1]=l[3*v+1],o[u+2]=0,o[u+3]=l[3*v+3],o[u+4]=l[3*v+4],o[u+5]=0,u+=6,c[p]=c[p+4]=h[0],c[p+1]=c[p+5]=h[1],c[p+2]=c[p+6]=h[2],c[p+3]=c[p+7]=M,p+=8}let g=this.family.geometry;g.setAttribute("position",new ae(o,3)),g.setAttribute("color",new ae(c,4)),g.computeBoundingSphere(),this.family.visible=this.familyMode!=="hidden"}focusFamily(t=!1){let e=this.tracks,n=this.paramRange;if(!e||!n)return;let s=e.count,r=Math.max(1e-9,n[1]-n[0]),a=oh*r,o=Math.max(1,Math.round(s/ag)),c=-1;for(let h=0;h<s;h++)e.params[h]===this.sys.e&&(c=h);for(let h=0;h<s;h++){let f=this.familyMode==="family"&&(h%o===0||h===s-1),u=(e.params[h]-this.sys.e)/a;this.baseAlpha[h]=f&&h!==c?og:0,this.alphaTo[h]=h===c?0:rg*Math.exp(-u*u)}if(this.familyMode==="hidden"&&(this.alphaTo.fill(0),this.baseAlpha.fill(0)),cancelAnimationFrame(this.fadeRaf),t||this.familyMode==="hidden"){this.alphaNow.set(this.alphaTo),this.writeAlpha();return}this.fadeLast=performance.now();let l=h=>{let f=Math.max(0,h-this.fadeLast);this.fadeLast=h;let u=1-Math.exp(-f/ug),p=1-Math.exp(-f/dg),g=0;for(let _=0;_<s;_++){let m=this.alphaNow[_],d=this.alphaTo[_],T=m+(d-m)*(d>m?u:p);this.alphaNow[_]=T,g=Math.max(g,Math.abs(d-T))}g<.004&&this.alphaNow.set(this.alphaTo),this.writeAlpha(),this.render(),g>=.004&&(this.fadeRaf=requestAnimationFrame(l))};this.fadeRaf=requestAnimationFrame(l)}writeAlpha(){let t=this.tracks,e=this.family.geometry.getAttribute("color");if(!t||!e)return;let n=e.array,s=(t.samples-1)*8,r=!1;for(let a=0;a<t.count;a++){let o=Math.max(this.baseAlpha[a],this.alphaNow[a]);if(this.written[a]===o)continue;let c=a*s;for(let l=c+3;l<c+s;l+=4)n[l]=o;this.written[a]=o,r=!0}r&&(e.needsUpdate=!0)}recolour(){let t=this.memberColor();this.orbit.material.color.set(t),this.ghost.material.color.set(t);let e=this.paramRange,n=e&&e[1]>e[0]?(this.sys.e-e[0])/(e[1]-e[0]):.5;Xi(this.spec().cmap,n,this.memberRgb)}recompute(){let t=this.fRel.length;if(!t)return;Ds(this.xy,this.fRel,this.sys,this.frame,this.xyz),this.ghost.geometry.getAttribute("position").set(this.xyz).needsUpdate=!0,this.ghost.geometry.setDrawRange(0,t),this.recolour();let e=this.primaryTrail.geometry.getAttribute("position"),n=this.secondaryTrail.geometry.getAttribute("position");Us("primary",this.fRel,this.sys,this.frame,e.array),Us("secondary",this.fRel,this.sys,this.frame,n.array),e.needsUpdate=n.needsUpdate=!0,this.primaryTrail.geometry.setDrawRange(0,t),this.secondaryTrail.geometry.setDrawRange(0,t);for(let s of[this.ghost,this.primaryTrail,this.secondaryTrail])s.geometry.computeBoundingSphere();this.showAt(this.fNow)}showAt(t){let e=this.fRel.length;if(!e)return;let n=this.fRel,s=Math.max(n[0],Math.min(n[e-1],t));this.fNow=s;let r=ka(n,s),a=n[r+1]-n[r],o=a>0?(s-n[r])/a:0,c=this.xyz[3*r]+(this.xyz[3*r+3]-this.xyz[3*r])*o,l=this.xyz[3*r+1]+(this.xyz[3*r+4]-this.xyz[3*r+1])*o,h=n[e-1]-n[0],f=lg*h,u=this.trailPts,p=this.trailT,g=0;u[0]=c,u[1]=l,p[0]=0,g=1;let _=r,m=!1;for(;g<e;){let w=(m?s+h:s)-n[_];if(w>=f){let C=p[g-1]*f,U=(f-C)/Math.max(1e-12,w-C);u[2*g]=u[2*g-2]+(this.xyz[3*_]-u[2*g-2])*U,u[2*g+1]=u[2*g-1]+(this.xyz[3*_+1]-u[2*g-1])*U,p[g]=1,g++;break}if(u[2*g]=this.xyz[3*_],u[2*g+1]=this.xyz[3*_+1],p[g]=w/f,g++,_===0){if(m)break;m=!0,_=e-2}else _--}if(g>=2&&p[1]>Aa){for(let C=g-1;C>=1;C--)u[2*(C+2)]=u[2*C],u[2*(C+2)+1]=u[2*C+1],p[C+2]=p[C];let w=p[3];for(let C=1;C<=2;C++){let U=Aa*C/2,S=U/w;u[2*C]=u[0]+(u[6]-u[0])*S,u[2*C+1]=u[1]+(u[7]-u[1])*S,p[C]=U}g+=2}this.trailCount=g;let d=this.orbit.geometry.getAttribute("position"),T=d.array;for(let w=0;w<g;w++)T[3*w]=u[2*w],T[3*w+1]=u[2*w+1],T[3*w+2]=0;d.needsUpdate=!0,this.orbit.geometry.setDrawRange(0,g),this.ghost.visible=this.showGhost;let M=(w,C,U)=>{let S=w.geometry.getAttribute("position");S.setXYZ(0,C,U,0),S.needsUpdate=!0};M(this.craft,c,l);let v=this.sys.f0+s,R=new Float32Array(2);ai("primary",this.sys,this.frame,v,R),M(this.primary,R[0],R[1]),ai("secondary",this.sys,this.frame,v,R),M(this.secondary,R[0],R[1]),this.render()}fit(){if(!this.fRel.length)return;let e=new nn;for(let c of[this.ghost,this.primaryTrail,this.secondaryTrail])c.geometry.computeBoundingBox(),c.geometry.boundingBox&&e.union(c.geometry.boundingBox);let n=new N,s=new N;e.getSize(n),e.getCenter(s);let r=Math.max(n.x,1e-6)*1.15,a=Math.max(n.y,1e-6)*1.15,o=this.aspect();this.camera.zoom=Math.min(2*o/r,2/a),this.camera.position.set(s.x,s.y,10),this.camera.up.set(0,1,0),this.controls.target.set(s.x,s.y,0),this.camera.updateProjectionMatrix(),this.controls.update(),this.userMoved=!1,this.render()}aspect(){let t=this.host.getBoundingClientRect();return Math.max(t.width,1)/Math.max(t.height,1)}resize(){let t=this.host.getBoundingClientRect(),e=Math.max(1,Math.floor(t.width)),n=Math.max(1,Math.floor(t.height));this.renderer.setSize(e,n,!1);let s=Math.min(window.devicePixelRatio||1,2);this.overlay.width=Math.floor(e*s),this.overlay.height=Math.floor(n*s);let r=e/n;this.camera.left=-r,this.camera.right=r,this.camera.top=1,this.camera.bottom=-1,this.camera.updateProjectionMatrix(),this.userMoved?this.render():this.fit()}visibleRect(){let t=(this.camera.right-this.camera.left)/(2*this.camera.zoom),e=(this.camera.top-this.camera.bottom)/(2*this.camera.zoom),n=this.camera.position.x,s=this.camera.position.y;return{x0:n-t,x1:n+t,y0:s-e,y1:s+e}}pixelSize(){let t=Math.max(1,this.host.getBoundingClientRect().width);return(this.camera.right-this.camera.left)/(this.camera.zoom*t)}layoutRibbon(){let t=this.trailCount,e=this.pixelSize(),[n,s,r]=this.memberRgb;for(let[a,o,c]of[[this.trailCore,cg,1],[this.trailGlow,hg,.32]]){let l=a.geometry.getAttribute("position"),h=a.geometry.getAttribute("color");if(!l||!h||t<2){a.visible=!1;continue}a.visible=!0;let f=l.array,u=h.array,p=this.trailPts;for(let g=0;g<t;g++){let _=Math.max(0,g-1),m=Math.min(t-1,g+1),d=p[2*m]-p[2*_],T=p[2*m+1]-p[2*_+1],M=Math.hypot(d,T)||1;d/=M,T/=M;let v=this.trailT[g],R=v<Aa?1-Math.pow(1-v/Aa,2):1,w=Math.pow(1-v,.8)*R,C=.5*o*e*w,U=-T*C,S=d*C,b=p[2*g],P=p[2*g+1];f[6*g]=b+U,f[6*g+1]=P+S,f[6*g+2]=0,f[6*g+3]=b-U,f[6*g+4]=P-S,f[6*g+5]=0;let B=c*Math.pow(1-v,1.6);u[8*g]=u[8*g+4]=n,u[8*g+1]=u[8*g+5]=s,u[8*g+2]=u[8*g+6]=r,u[8*g+3]=u[8*g+7]=B}l.needsUpdate=h.needsUpdate=!0,a.geometry.setDrawRange(0,(t-1)*6)}}render(){this.layoutRibbon(),this.renderer.render(this.scene,this.camera),this.threeD||this.drawOverlay()}drawOverlay(){let t=this.overlay.getContext("2d");if(!t)return;let e=Math.min(window.devicePixelRatio||1,2),n=this.overlay.width/e,s=this.overlay.height/e;t.setTransform(e,0,0,e,0,0),t.clearRect(0,0,n,s);let{x0:r,x1:a,y0:o,y1:c}=this.visibleRect(),l=M=>(M-r)/(a-r)*n,h=M=>s-(M-o)/(c-o)*s,f='12px "Helvetica Neue", Arial, sans-serif';t.font=f,t.lineWidth=1;let u=lh(a-r,Math.max(3,n/110)),p=lh(c-o,Math.max(3,s/70)),g=M=>Math.max(0,-Math.floor(Math.log10(M))),_=g(u),m=g(p);t.strokeStyle=this.palette.grid,t.fillStyle=this.palette.text,t.textAlign="center",t.textBaseline="top";for(let M=Math.ceil(r/u)*u;M<=a;M+=u){let v=Math.round(l(M))+.5;t.beginPath(),t.moveTo(v,0),t.lineTo(v,s),t.stroke(),v>56&&t.fillText((Math.abs(M)<1e-12?0:M).toFixed(_),v,s-30)}t.textAlign="right",t.textBaseline="middle";for(let M=Math.ceil(o/p)*p;M<=c;M+=p){let v=Math.round(h(M))+.5;t.beginPath(),t.moveTo(0,v),t.lineTo(n,v),t.stroke(),v<s-40&&v>22&&t.fillText((Math.abs(M)<1e-12?0:M).toFixed(m),44,v)}if(t.strokeStyle=this.palette.axis,r<0&&a>0){let M=Math.round(l(0))+.5;t.beginPath(),t.moveTo(M,0),t.lineTo(M,s),t.stroke()}if(o<0&&c>0){let M=Math.round(h(0))+.5;t.beginPath(),t.moveTo(0,M),t.lineTo(n,M),t.stroke()}let d=this.spec(),T=(M,v,R)=>{t.strokeStyle=this.palette.background,t.lineWidth=4,t.lineJoin="round",t.strokeText(M,v,R),t.fillStyle=this.palette.text,t.fillText(M,v,R),t.lineWidth=1};if(t.font='13px "Helvetica Neue", Arial, sans-serif',t.textAlign="center",t.textBaseline="top",this.showTitle&&T(d.label,n/2,8),t.textBaseline="bottom",T(d.axes[0],n/2,s-6),t.save(),t.translate(14,s/2),t.rotate(-Math.PI/2),t.textBaseline="middle",T(d.axes[1],0,0),t.restore(),this.paramRange&&this.tracks){let[M,v]=this.paramRange,R=8,w=Math.min(s*.5,220),C=n-46,U=(s-w)/2,S=t.createLinearGradient(0,U+w,0,U);for(let P=0;P<=10;P++)S.addColorStop(P/10,Ns(d.cmap,P/10));t.fillStyle=S,t.fillRect(C,U,R,w),t.strokeStyle=this.palette.axis,t.strokeRect(C+.5,U+.5,R,w),t.fillStyle=this.palette.text,t.font=f,t.textAlign="left",t.textBaseline="middle";let b=4;for(let P=0;P<=b;P++){let B=M+(v-M)*P/b,V=U+w-w*P/b;t.fillText(B.toFixed(2),C+R+5,V)}if(t.textAlign="center",t.textBaseline="bottom",t.fillText("e",C+R/2,U-4),v>M){let P=U+w-w*(this.sys.e-M)/(v-M);if(this.familyMode!=="hidden"){let B=w*oh*1.5;t.fillStyle="rgba(255,255,255,0.18)",t.fillRect(C-3,P-B,R+6,2*B)}t.fillStyle=this.palette.text,t.beginPath(),t.moveTo(C-2,P),t.lineTo(C-8,P-4),t.lineTo(C-8,P+4),t.closePath(),t.fill()}}}};function Hi(i){return i?i.kind==="panel"?[i.id]:[...Hi(i.a),...Hi(i.b)]:[]}function hh(i,t){return Hi(i).includes(t)}function Vi(i,t,e,n){if(i.kind==="panel"){if(i.id!==t)return i;if(n==="centre")return{kind:"panel",id:e};let s={kind:"panel",id:e},r=n==="left"||n==="right"?"row":"col",a=n==="left"||n==="top";return{kind:"split",dir:r,ratio:.5,a:a?s:i,b:a?i:s}}return{...i,a:Vi(i.a,t,e,n),b:Vi(i.b,t,e,n)}}function si(i,t){if(i.kind==="panel")return i.id===t?null:i;let e=si(i.a,t),n=si(i.b,t);return e?n?{...i,a:e,b:n}:e:n}function Ca(i,t,e){return i===t&&i.kind==="split"?{...i,ratio:e}:i.kind==="panel"?i:{...i,a:Ca(i.a,t,e),b:Ca(i.b,t,e)}}function Pa(i,t=1){return i.kind==="panel"?[{id:i.id,area:t}]:[...Pa(i.a,t*i.ratio),...Pa(i.b,t*(1-i.ratio))]}function uh(i,t,e,n){let s=i/Math.max(1,e),r=t/Math.max(1,n),a=.28,o=[{zone:"left",v:s},{zone:"right",v:1-s},{zone:"top",v:r},{zone:"bottom",v:1-r}].sort((c,l)=>c.v-l.v)[0];return o.v<a?o.zone:"centre"}function Ia(i){if(!i||typeof i!="object")return!1;let t=i;return t.kind==="panel"?typeof t.id=="string":t.kind==="split"?(t.dir==="row"||t.dir==="col")&&typeof t.ratio=="number"&&Ia(t.a)&&Ia(t.b):!1}var La=400,pg=4,dh=8,Rs=["periapsis","apoapsis"],mg=`
3833
+ :host { display: block; position: relative; background: #000; color: #d8d8d8;
3834
+ font: 13px/1.4 "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
3835
+ * { box-sizing: border-box; }
3836
+ [hidden] { display: none !important; }
3837
+ .root { position: absolute; inset: 0; display: grid; grid-template-rows: auto auto 1fr auto; }
3838
+ .root.kiosk { grid-template-rows: 1fr; }
3839
+ .root.kiosk header, .root.kiosk .controls, .root.kiosk footer, .root.kiosk .phead { display: none; }
3840
+ header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; padding: 10px 14px 4px; }
3841
+ header h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
3842
+ header .caption { color: #9a9a9a; font-variant-numeric: tabular-nums; }
3843
+ .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 6px 14px 8px; }
3844
+ .seg { display: inline-flex; border: 1px solid #333; border-radius: 6px; overflow: hidden; }
3845
+ .seg button { background: #0d0d0d; color: #bbb; border: 0; padding: 5px 11px; cursor: pointer; font: inherit; }
3846
+ .seg button + button { border-left: 1px solid #333; }
3847
+ .seg button[aria-pressed="true"] { background: #2b2b2b; color: #fff; }
3848
+ .seg.mini button { padding: 1px 7px; font-size: 11px; }
3849
+ .seg button:hover { color: #fff; }
3850
+ label.field { display: inline-flex; align-items: center; gap: 8px; }
3851
+ label.field span.k { color: #9a9a9a; }
3852
+ input[type=range] { accent-color: #E69F00; width: 220px; }
3853
+ input[type=range].scrub { flex: 1; min-width: 160px; width: auto; }
3854
+ .chips { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
3855
+ .chips .k { color: #9a9a9a; margin-right: 2px; }
3856
+ .chip { display: inline-flex; align-items: center; gap: 6px; background: #0d0d0d; color: #ccc; border: 1px solid #333;
3857
+ border-radius: 6px; padding: 4px 10px 4px 8px; cursor: grab; user-select: none; touch-action: none; }
3858
+ .chip:hover { color: #fff; border-color: #666; }
3859
+ .chip .grip { color: #555; font-size: 11px; letter-spacing: -2px; }
3860
+ .chip .n { min-width: 16px; text-align: center; font-size: 11px; color: #ffd9a8; background: #3a2a14; border-radius: 8px; padding: 0 5px; }
3861
+ .chip .n:empty { display: none; }
3862
+ .stage { position: relative; min-height: 120px; background: #141414; display: flex; }
3863
+ .stage > .split, .stage > .panel { flex: 1 1 0; }
3864
+ .split { display: flex; min-width: 0; min-height: 0; }
3865
+ .split.row { flex-direction: row; }
3866
+ .split.col { flex-direction: column; }
3867
+ .gutter { flex: 0 0 6px; background: #141414; touch-action: none; }
3868
+ .split.row > .gutter { cursor: col-resize; }
3869
+ .split.col > .gutter { cursor: row-resize; }
3870
+ .gutter:hover, .gutter.active { background: #3a2a14; }
3871
+ .panel { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #000; }
3872
+ .phead { display: flex; align-items: center; gap: 8px; padding: 3px 8px; background: #0a0a0a; border-bottom: 1px solid #1a1a1a;
3873
+ cursor: grab; user-select: none; touch-action: none; font-size: 12px; white-space: nowrap; min-width: 0; }
3874
+ .phead .t { font-weight: 600; color: #ddd; flex: 0 1 auto; min-width: 3em; overflow: hidden; text-overflow: ellipsis; }
3875
+ .phead .m { color: #8a8a8a; font-variant-numeric: tabular-nums; flex: 0 10 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
3876
+ .phead .sp { flex: 1 0 0; }
3877
+ .phead .seg, .phead .x { flex: 0 0 auto; }
3878
+ .phead .x { background: none; border: 0; color: #777; cursor: pointer; font: inherit; font-size: 14px; padding: 0 4px; }
3879
+ .phead .x:hover { color: #fff; }
3880
+ .phead .home { display: inline-flex; align-items: center; }
3881
+ .pbody { position: relative; flex: 1 1 0; min-height: 0; }
3882
+ .drop { position: absolute; inset: 0; background: rgba(230,159,0,0.18); border: 2px solid rgba(230,159,0,0.7); pointer-events: none; z-index: 2; }
3883
+ .drop.centre { background: rgba(86,180,233,0.16); border-color: rgba(86,180,233,0.7); }
3884
+ .ghostchip { position: fixed; z-index: 10; pointer-events: none; background: #2b2b2b; color: #fff; border: 1px solid #666;
3885
+ border-radius: 6px; padding: 4px 10px; font-size: 12px; transform: translate(12px, 12px); }
3886
+ .hint { flex: 1; display: grid; place-items: center; color: #777; background: #000; }
3887
+ .hint.over { color: #ffd9a8; background: #120d05; }
3888
+ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 8px 14px 10px; border-top: 1px solid #1a1a1a; }
3889
+ footer button { background: #0d0d0d; color: #ddd; border: 1px solid #333; border-radius: 6px; padding: 5px 12px; cursor: pointer; font: inherit; min-width: 68px; }
3890
+ footer button:hover { border-color: #666; color: #fff; }
3891
+ .readout { color: #bbb; font-variant-numeric: tabular-nums; white-space: nowrap; }
3892
+ .fps { color: #8a8a8a; font-variant-numeric: tabular-nums; min-width: 5.5em; text-align: right; }
3893
+ .legend { display: inline-flex; gap: 10px; color: #9a9a9a; }
3894
+ .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
3895
+ select { background: #0d0d0d; color: #ddd; border: 1px solid #333; border-radius: 6px; padding: 4px 6px; font: inherit; }
3896
+ .check { display: inline-flex; align-items: center; gap: 5px; color: #bbb; cursor: pointer; }
3897
+ .check input { accent-color: #E69F00; }
3898
+ .status { position: absolute; inset: 0; display: grid; place-items: center; color: #888; }
3899
+ .warn { color: #e0a24a; }
3900
+ `;function sl(i,t,e="seg"){let n=document.createElement("div");n.className=e;let s=new Map;for(let r of i){let a=document.createElement("button");a.type="button",a.textContent=r.label,a.setAttribute("aria-pressed","false"),a.addEventListener("pointerdown",o=>o.stopPropagation()),a.addEventListener("click",()=>t(r.id)),s.set(r.id,a),n.appendChild(a)}return{el:n,set(r){for(let[a,o]of s)o.setAttribute("aria-pressed",String(a===r))}}}function fh(i,t,e){let n=document.createElement("select");for(let s of i){let r=document.createElement("option");r.value=s.id,r.textContent=s.label,s.id===t&&(r.selected=!0),n.appendChild(r)}return n.addEventListener("change",()=>e(n.value)),n}function Cs(i){return bn.find(t=>t.id===i)?.label??i}var Da=class extends HTMLElement{constructor(){super(...arguments);this.container=null;this.families=[];this.groups=[];this.group="";this.e=0;this.eStep=.005;this.eMax=1;this.playing=!1;this.speed=1;this.spacing="anomaly";this.ghostMode="family";this.progress=0;this.raf=0;this.showGhost=!0;this.threeD=!1;this.fpsEma=0;this.lastTick=0;this.kiosk=!1;this.tree=null;this.panels=new Map;this.nextId=1;this.tracksCache=new Map;this.chips=new Map}connectedCallback(){this.kiosk=this.hasAttribute("kiosk");let e=this.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=mg,e.appendChild(n),this.root=document.createElement("div"),this.root.className=this.kiosk?"root kiosk":"root",e.appendChild(this.root);let s=document.createElement("header");this.titleEl=document.createElement("h1"),this.titleEl.textContent=this.getAttribute("title")??"",this.captionEl=document.createElement("span"),this.captionEl.className="caption",s.append(this.titleEl,this.captionEl);let r=document.createElement("div");r.className="controls",this.groupSeg=sl([],()=>{});let a=document.createElement("label");a.className="field";let o=document.createElement("span");o.className="k",o.textContent="e",this.slider=document.createElement("input"),this.slider.type="range",this.slider.min="0",this.slider.addEventListener("input",()=>this.setE(Number(this.slider.value))),this.sliderOut=document.createElement("span"),a.append(o,this.slider,this.sliderOut);let c=document.createElement("div");c.className="chips";let l=document.createElement("span");l.className="k",l.textContent="frames",c.appendChild(l);for(let T of bn){let M=document.createElement("span");M.className="chip",M.title="drag onto a panel to split it there or replace it; click to add";let v=document.createElement("span");v.className="grip",v.textContent="\u2807";let R=document.createElement("span");R.className="n",M.append(v,document.createTextNode(T.label),R),M.addEventListener("pointerdown",w=>this.startDrag(w,{kind:"frame",frame:T.id},M)),this.chips.set(T.id,M),c.appendChild(M)}r.append(this.groupSeg.el,a,c),this.stage=document.createElement("div"),this.stage.className="stage",this.statusEl=document.createElement("div"),this.statusEl.className="status",this.statusEl.textContent="loading\u2026",this.hint=document.createElement("div"),this.hint.className="hint",this.hint.textContent="drag a frame here",this.hint.hidden=!0,this.stage.append(this.statusEl,this.hint);let h=document.createElement("footer");this.playBtn=document.createElement("button"),this.playBtn.type="button",this.playBtn.textContent="play",this.playBtn.addEventListener("click",()=>this.togglePlay()),this.scrub=document.createElement("input"),this.scrub.type="range",this.scrub.className="scrub",this.scrub.min="0",this.scrub.max="1000",this.scrub.step="1",this.scrub.addEventListener("input",()=>{this.pause(),this.progress=Number(this.scrub.value)/1e3,this.drawAll()});let f=fh([.25,.5,1,2,4].map(T=>({id:String(T),label:`${T}\xD7`})),"1",T=>this.speed=Number(T)),u=fh([{id:"anomaly",label:"uniform in f"},{id:"time",label:"uniform in \u03C4"},{id:"arclength",label:"uniform in arclength"}],this.spacing,T=>{this.spacing=T,this.drawAll()}),p=this.checkbox("full orbit",!0,T=>{this.showGhost=T;for(let M of this.panels.values())M.viewer.showGhost=T;this.drawAll()}),g=this.checkbox("3D orbit camera",!1,T=>{this.threeD=T;for(let M of this.panels.values())M.viewer.setThreeD(T)}),_=document.createElement("button");_.type="button",_.textContent="reset layout",_.addEventListener("click",()=>{this.forget(),this.applyDefaultLayout()}),this.readout=document.createElement("span"),this.readout.className="readout",this.fpsEl=document.createElement("span"),this.fpsEl.className="fps",this.fpsEl.textContent="\u2014 fps";let m=document.createElement("span");m.className="legend";for(let[T,M]of[["#F0E442","spacecraft"],["#56B4E9","m\u2081"],["#A8A8A8","m\u2082"]]){let v=document.createElement("span"),R=document.createElement("i");R.style.background=T,v.append(R,document.createTextNode(M)),m.appendChild(v)}h.append(this.playBtn,this.scrub,f,u,p,g,_,m,this.readout,this.fpsEl),this.root.append(s,r,this.stage,h),this.tabIndex=0,this.addEventListener("keydown",T=>this.onKey(T));let d=this.getAttribute("data");if(!d){this.statusEl.textContent="no data attribute";return}Fa(d).then(T=>{this.container=T,this.statusEl.remove(),this.populate()}).catch(T=>{this.statusEl.textContent=`failed to load data: ${T.message}`})}disconnectedCallback(){this.pause();for(let e of this.panels.values())e.viewer.dispose();this.panels.clear()}checkbox(e,n,s){let r=document.createElement("label");r.className="check";let a=document.createElement("input");return a.type="checkbox",a.checked=n,a.addEventListener("change",()=>s(a.checked)),r.append(a,document.createTextNode(e)),r}populate(){let e=this.container;this.families=e.datasets.filter(o=>o.kind==="periodic_orbit_family"),this.groups=[...new Set(this.families.map(o=>o.group))];let n=sl(this.groups.map(o=>({id:o,label:o})),o=>this.setGroup(o));this.groupSeg.el.replaceWith(n.el),this.groupSeg=n;let s=this.kiosk?null:this.recall(),r=this.parseLayout(this.getAttribute("layout")),a=s??r;a&&this.groups.includes(a.group)?(this.group=a.group,this.groupSeg.set(this.group),this.rangeForGroup(),this.e=Math.min(a.e,this.eMax),this.restore(a)):(this.groups.length&&(this.group=this.groups[0],this.groupSeg.set(this.group),this.rangeForGroup()),this.applyDefaultLayout()),this.kiosk&&this.play()}branchDataset(e){return this.families.find(n=>n.group===this.group&&n.branch===e)}tracksFor(e){let n=this.tracksCache.get(e.id);if(n)return n;let s=this.container,r=s.viewInfo(e.positions.view);return n={count:r.shape[0],samples:r.shape[1],positions:s.f32(e.positions.view),anomalies:s.f32(e.independent_variable.view),params:s.f64(e.parameter.view),mu:e.system.mu,f0:e.system.f0},this.tracksCache.set(e.id,n),n}rangeForGroup(){let e=0,n=1/0;for(let s of this.families.filter(r=>r.group===this.group)){let r=this.tracksFor(s).params;e=Math.max(e,r[r.length-1]);for(let a=1;a<r.length;a++)n=Math.min(n,Math.abs(r[a]-r[a-1]))}this.eMax=e,this.eStep=Number.isFinite(n)&&n>0?n:.005,this.slider.max=String(this.eMax),this.slider.step=String(this.eStep),this.e=Math.min(this.e,this.eMax)}setGroup(e){this.group=e,this.groupSeg.set(e),this.rangeForGroup();for(let n of this.panels.values())this.loadPanel(n,!0);this.drawAll(),this.updateCaption(),this.remember()}setE(e){this.e=Math.max(0,Math.min(this.eMax,e));for(let n of this.panels.values())this.loadPanel(n,!1);this.drawAll(),this.updateCaption(),this.remember()}loadPanel(e,n){let s=this.branchDataset(e.branch);if(!s){e.tracks=null,e.fRel=new Float32Array(0),e.meta.textContent="no data";return}let r=this.tracksFor(s),a=0,o=1/0;for(let u=0;u<r.count;u++){let p=Math.abs(r.params[u]-this.e);p<o&&(o=p,a=u)}let c=r.samples,l=e.tracks!==r;e.tracks=r,e.member=a;let h=r.positions.subarray(a*c*2,(a+1)*c*2);e.fRel=s.independent_variable.per_member?r.anomalies.subarray(a*c,(a+1)*c):r.anomalies.subarray(0,c),e.sys={mu:r.mu,e:r.params[a],f0:r.f0},e.period=e.fRel[c-1],e.tauPeriod=Ls(e.sys.e,e.sys.f0,e.sys.f0+e.period),l&&e.viewer.setFamily(r,this.ghostMode),e.viewer.setTrajectory(h,e.fRel,e.sys,n);let f="";if(s.closure_error){let u=this.container.f32(s.closure_error.view)[a];u>1e-4&&(f=` \xB7 closure ${u.toExponential(1)}`)}e.meta.textContent=`e = ${e.sys.e.toFixed(4)}${f}`,e.meta.classList.toggle("warn",f!=="")}createPanel(e,n,s){let r=s??`p${this.nextId++}`,a=Number(r.slice(1));Number.isFinite(a)&&a>=this.nextId&&(this.nextId=a+1);let o=document.createElement("div");o.className="panel",o.dataset.id=r;let c=document.createElement("div");c.className="phead";let l=document.createElement("span");l.className="t",l.textContent=Cs(e);let h=document.createElement("span");h.className="m";let f=document.createElement("span");f.className="sp";let u=sl([{id:"periapsis",label:"peri"},{id:"apoapsis",label:"apo"}],M=>{let v=this.panels.get(r);v&&(v.branch=M,v.branchSeg.set(M),this.loadPanel(v,!1),this.drawAll(),this.updateCaption(),this.remember())},"seg mini");u.set(n);let p=document.createElement("button");p.className="x home",p.type="button",p.title="reset the view",p.innerHTML='<svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path d="M8 2.2 1.8 7.6h1.7V13.5h3.3V9.7h2.4v3.8h3.3V7.6h1.7z" fill="currentColor"/></svg>',p.addEventListener("pointerdown",M=>M.stopPropagation()),p.addEventListener("click",()=>this.panels.get(r)?.viewer.fit());let g=document.createElement("button");g.className="x",g.type="button",g.title="close panel",g.textContent="\xD7",g.addEventListener("pointerdown",M=>M.stopPropagation()),g.addEventListener("click",()=>this.closePanel(r)),c.append(l,h,f,u.el,p,g),c.addEventListener("pointerdown",M=>this.startDrag(M,{kind:"panel",id:r},c));let _=document.createElement("div");_.className="pbody";let m=document.createElement("div");m.className="drop",m.hidden=!0,o.append(c,_);let d=new As(_,e);_.appendChild(m),d.showGhost=this.showGhost,d.setThreeD(this.threeD);let T={id:r,frame:e,branch:n,host:o,body:_,title:l,meta:h,branchSeg:u,drop:m,viewer:d,tracks:null,member:0,sys:{mu:.5,e:0,f0:0},fRel:new Float32Array(0),period:0,tauPeriod:0};return this.panels.set(r,T),this.loadPanel(T,!0),T}destroyPanel(e){let n=this.panels.get(e);n&&(n.viewer.dispose(),n.host.remove(),this.panels.delete(e))}closePanel(e){this.tree&&(this.tree=si(this.tree,e),this.destroyPanel(e),this.renderLayout(),this.remember())}addPanel(e,n){if(this.panels.size>=dh)return;let s=n??this.defaultBranch();if(this.tree){let r=Pa(this.tree).sort((l,h)=>h.area-l.area)[0],o=this.panels.get(r.id).host.getBoundingClientRect(),c=this.createPanel(e,s);this.tree=Vi(this.tree,r.id,c.id,o.width>=o.height?"right":"bottom")}else{let r=this.createPanel(e,s);this.tree={kind:"panel",id:r.id}}this.renderLayout(),this.drawAll(),this.remember()}defaultBranch(){return[...this.panels.values()].pop()?.branch??Rs[0]}dropOn(e,n,s){if(this.tree){if(s.kind==="panel"){if(s.id===e)return;if(n==="centre"){let r=this.panels.get(s.id),a=this.panels.get(e);[r.frame,a.frame]=[a.frame,r.frame],[r.branch,a.branch]=[a.branch,r.branch];for(let o of[r,a])o.viewer.setFrame(o.frame),o.title.textContent=Cs(o.frame),o.branchSeg.set(o.branch),this.loadPanel(o,!0)}else this.tree=si(this.tree,s.id)??this.tree,this.tree=Vi(this.tree,e,s.id,n)}else if(n==="centre"){let r=this.panels.get(e);r.frame=s.frame,r.viewer.setFrame(r.frame),r.title.textContent=Cs(r.frame),this.loadPanel(r,!0)}else{if(this.panels.size>=dh)return;let r=this.createPanel(s.frame,this.panels.get(e).branch);this.tree=Vi(this.tree,e,r.id,n)}this.renderLayout(),this.drawAll(),this.remember()}}renderLayout(){for(let n of[...this.stage.children])n!==this.hint&&n.remove();this.hint.hidden=!!this.tree,this.tree&&this.stage.appendChild(this.build(this.tree));for(let n of this.panels.values())n.viewer.resize();let e=new Map;for(let n of this.panels.values())e.set(n.frame,(e.get(n.frame)??0)+1);for(let[n,s]of this.chips)s.querySelector(".n").textContent=e.get(n)?String(e.get(n)):"";this.updateCaption()}build(e){if(e.kind==="panel"){let o=this.panels.get(e.id);if(!o)throw new Error(`layout references unknown panel ${e.id}`);return o.host.style.flex="",o.host}let n=document.createElement("div");n.className=`split ${e.dir}`;let s=this.build(e.a),r=this.build(e.b);s.style.flex=`${e.ratio} 1 0`,r.style.flex=`${1-e.ratio} 1 0`;let a=document.createElement("div");return a.className="gutter",a.addEventListener("pointerdown",o=>this.startResize(o,e,n,s,r,a)),n.append(s,a,r),n}startResize(e,n,s,r,a,o){if(n.kind!=="split")return;e.preventDefault(),o.classList.add("active"),o.setPointerCapture(e.pointerId);let c=n.ratio,l=f=>{let u=s.getBoundingClientRect();c=n.dir==="row"?(f.clientX-u.left)/Math.max(1,u.width):(f.clientY-u.top)/Math.max(1,u.height),c=Math.max(.1,Math.min(.9,c)),r.style.flex=`${c} 1 0`,a.style.flex=`${1-c} 1 0`},h=()=>{o.classList.remove("active"),o.removeEventListener("pointermove",l),o.removeEventListener("pointerup",h),o.removeEventListener("pointercancel",h),this.tree&&(this.tree=Ca(this.tree,n,c));for(let f of this.panels.values())f.viewer.resize();this.remember()};o.addEventListener("pointermove",l),o.addEventListener("pointerup",h),o.addEventListener("pointercancel",h)}startDrag(e,n,s){if(e.button!==0)return;e.preventDefault();let r=e.clientX,a=e.clientY,o=null,c=null,l=!1,h=this.shadowRoot;s.setPointerCapture(e.pointerId);let f=()=>{for(let g of this.panels.values())g.drop.hidden=!0;this.hint.classList.remove("over")},u=g=>{if(!o){if(Math.hypot(g.clientX-r,g.clientY-a)<4)return;o=document.createElement("div"),o.className="ghostchip",o.textContent=n.kind==="frame"?Cs(n.frame):Cs(this.panels.get(n.id).frame),h.appendChild(o)}o.style.left=`${g.clientX}px`,o.style.top=`${g.clientY}px`,f(),c=null,l=!1;let _=h.elementFromPoint(g.clientX,g.clientY);if(_&&(_===this.hint||this.hint.contains(_))){l=!0,this.hint.classList.add("over");return}let m=_?.closest(".panel");if(!m)return;let d=m.dataset.id;if(n.kind==="panel"&&n.id===d)return;let T=this.panels.get(d),M=T.body.getBoundingClientRect(),v=uh(g.clientX-M.left,g.clientY-M.top,M.width,M.height);c={id:d,zone:v};let R=T.drop;R.hidden=!1,R.classList.toggle("centre",v==="centre"),R.style.inset=v==="left"?"0 50% 0 0":v==="right"?"0 0 0 50%":v==="top"?"0 0 50% 0":v==="bottom"?"50% 0 0 0":"0"},p=()=>{s.removeEventListener("pointermove",u),s.removeEventListener("pointerup",p),s.removeEventListener("pointercancel",p),f();let g=!!o;if(o?.remove(),!g){n.kind==="frame"&&this.addPanel(n.frame);return}l&&n.kind==="frame"&&!this.tree?this.addPanel(n.frame):c&&this.dropOn(c.id,c.zone,n)};s.addEventListener("pointermove",u),s.addEventListener("pointerup",p),s.addEventListener("pointercancel",p)}applyDefaultLayout(){for(let n of[...this.panels.keys()])this.destroyPanel(n);this.tree=null;let e=(this.getAttribute("frames")??"rotating_pulsating").split(/[\s,]+/);for(let n of e)bn.some(s=>s.id===n)&&this.addPanel(n);this.renderLayout(),this.drawAll()}restore(e){for(let s of[...this.panels.keys()])this.destroyPanel(s);this.tree=null;let n=e.tree;for(let[s,r]of Object.entries(e.panels))if(!(!n||!hh(n,s))){if(!bn.some(a=>a.id===r.frame)){n=si(n,s);continue}this.createPanel(r.frame,Rs.includes(r.branch)?r.branch:Rs[0],s)}for(let s of Hi(n))n&&!this.panels.has(s)&&(n=si(n,s));if(this.tree=n,!this.tree){this.applyDefaultLayout();return}this.renderLayout(),this.drawAll()}snapshot(){let e={};for(let n of this.panels.values())e[n.id]={frame:n.frame,branch:n.branch};return{version:1,group:this.group,e:this.e,tree:this.tree,panels:e}}get layoutJSON(){return JSON.stringify(this.snapshot())}storageKey(){return`tycho:layout:${this.getAttribute("title")??""}`}remember(){if(!this.kiosk)try{localStorage.setItem(this.storageKey(),this.layoutJSON)}catch{}}forget(){try{localStorage.removeItem(this.storageKey())}catch{}}recall(){try{return this.parseLayout(localStorage.getItem(this.storageKey()))}catch{return null}}parseLayout(e){if(!e)return null;try{let n=JSON.parse(e);return n.version!==1||typeof n.group!="string"||typeof n.e!="number"||n.tree!==null&&!Ia(n.tree)||!n.panels||typeof n.panels!="object"?null:n}catch{return null}}currentF(e){let n=Math.max(0,Math.min(1,this.progress));switch(this.spacing){case"anomaly":return n*e.period;case"time":return za(e.sys.e,e.sys.f0,n*e.tauPeriod)-e.sys.f0;case"arclength":{let s=e.fRel.length;if(s<2)return 0;let r=n*(s-1),a=Math.min(s-2,Math.floor(r));return e.fRel[a]+(e.fRel[a+1]-e.fRel[a])*(r-a)}}}firstPanel(){let e=Hi(this.tree);return e.length?this.panels.get(e[0]):void 0}drawAll(){for(let e of this.panels.values())e.fRel.length&&e.viewer.showAt(this.currentF(e));this.updateReadout()}updateCaption(){let e=[...new Set([...this.panels.values()].map(s=>s.branch))].join(" and "),n=this.branchDataset(Rs[0])?.system.mu??this.branchDataset(Rs[1])?.system.mu;this.captionEl.textContent=this.group?`${this.group}${e?`, ${e}`:""}, e \u2248 ${this.e.toFixed(3)}${n!==void 0?`, \u03BC = ${n}`:""}`:"",this.slider.value=String(this.e),this.sliderOut.textContent=this.e.toFixed(4)}updateReadout(){let e=this.firstPanel();if(!e||!e.fRel.length){this.readout.textContent="";return}let n=this.currentF(e),s=Ls(e.sys.e,e.sys.f0,e.sys.f0+n),r=Math.round(this.progress*La);this.readout.textContent=`f \u2212 f\u2080 = ${n.toFixed(2)} rad\u2003\u03C4 = ${s.toFixed(2)} TU\u2003frame ${r}/${La}`,this.scrub.value=String(Math.round(this.progress*1e3))}togglePlay(){this.playing?this.pause():this.play()}play(){if(this.playing)return;this.playing=!0,this.playBtn.textContent="pause",this.lastTick=0,this.fpsEma=0;let e=n=>{if(this.playing){if(this.lastTick){let s=1e3/Math.max(1,n-this.lastTick);this.fpsEma=this.fpsEma?this.fpsEma*.9+s*.1:s,this.fpsEl.textContent=`${this.fpsEma.toFixed(0)} fps`}this.lastTick=n,this.progress+=this.speed/(La*pg),this.progress>=1&&(this.progress-=1),this.drawAll(),this.raf=requestAnimationFrame(e)}};this.raf=requestAnimationFrame(e)}pause(){this.playing=!1,this.playBtn.textContent="play",this.fpsEl.textContent="\u2014 fps",cancelAnimationFrame(this.raf)}onKey(e){let n=(e.shiftKey?10:1)/La;switch(e.key){case" ":e.preventDefault(),this.togglePlay();break;case"ArrowRight":e.preventDefault(),this.pause(),this.progress=(this.progress+n)%1,this.drawAll();break;case"ArrowLeft":e.preventDefault(),this.pause(),this.progress=(this.progress-n+1)%1,this.drawAll();break;case"ArrowUp":e.preventDefault(),this.setE(this.e+this.eStep*(e.shiftKey?10:1));break;case"ArrowDown":e.preventDefault(),this.setE(this.e-this.eStep*(e.shiftKey?10:1));break}}};function rl(i="tycho-viewer"){customElements.get(i)||customElements.define(i,Da)}rl();export{Wi as Container,ch as DARK,bn as FRAMES,As as OrbitViewer,Da as TychoViewerElement,ai as bodyPosition,Us as bodyTrail,Xi as colormap,Ns as colormapCss,dl as decodeEmbedded,rl as define,Ls as elapsedTime,Fa as loadContainer,Ba as rho,ka as segmentIndex,Ds as transformTrajectory,za as trueAnomalyFromTime};
3901
+ /*! Bundled license information:
3902
+
3903
+ three/build/three.core.js:
3904
+ three/build/three.module.js:
3905
+ (**
3906
+ * @license
3907
+ * Copyright 2010-2025 Three.js Authors
3908
+ * SPDX-License-Identifier: MIT
3909
+ *)
3910
+ */